diff --git a/jael_web/build.yaml b/jael_web/build.yaml new file mode 100644 index 00000000..9082d3c2 --- /dev/null +++ b/jael_web/build.yaml @@ -0,0 +1,10 @@ +builders: + jael_web: + import: "package:jael_web/builder.dart" + builder_factories: + - jaelComponentBuilder + build_extensions: + .dart: + - .jael_web_cmp.g.part + auto_apply: root_package + applies_builders: ["source_gen|combining_builder", "source_gen|part_cleanup"] \ No newline at end of file diff --git a/jael_web/example/main.dart b/jael_web/example/main.dart index b82b7e86..55bfc068 100644 --- a/jael_web/example/main.dart +++ b/jael_web/example/main.dart @@ -1,3 +1,30 @@ import 'package:jael_web/jael_web.dart'; +import 'package:jael_web/elements.dart'; +part 'main.g.dart'; -void main() {} \ No newline at end of file +@Dsx(template: ''' +
+

Hello, Jael!

+ Current time: {now} +
+''') +class Hello extends Component with _HelloJaelTemplate { + DateTime get now => DateTime.now(); +} + +// Could also have been: +class Hello2 extends Component { + DateTime get now => DateTime.now(); + + @override + DomNode render() { + return div(c: [ + h1(c: [ + text('Hello, Jael!'), + ]), + i(c: [ + text('Current time: $now'), + ]), + ]); + } +} diff --git a/jael_web/example/main.g.dart b/jael_web/example/main.g.dart new file mode 100644 index 00000000..6a208fa6 --- /dev/null +++ b/jael_web/example/main.g.dart @@ -0,0 +1,18 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'main.dart'; + +// ************************************************************************** +// JaelComponentGenerator +// ************************************************************************** + +abstract class _HelloJaelTemplate implements Component { + DateTime get now; + @override + DomNode render() { + return h('div', {}, [ + h('h1', {}, [text('Hello, Jael!')]), + h('i', {}, [text('Current time: '), text(now.toString())]) + ]); + } +} diff --git a/jael_web/example/stateful.dart b/jael_web/example/stateful.dart new file mode 100644 index 00000000..664a1fe0 --- /dev/null +++ b/jael_web/example/stateful.dart @@ -0,0 +1,32 @@ +import 'dart:async'; +import 'package:jael_web/jael_web.dart'; +part 'stateful.g.dart'; + +void main() {} + +class _AppState { + final int ticks; + + _AppState({this.ticks}); + + _AppState copyWith({int ticks}) { + return _AppState(ticks: ticks ?? this.ticks); + } +} + +@Dsx(template: '
Tick count: {state.ticks}
') +class StatefulApp extends Component<_AppState> with _StatefulAppJaelTemplate { + Timer _timer; + + StatefulApp() { + state =_AppState(ticks: 0); + _timer = Timer.periodic(Duration(seconds: 1), (t) { + setState(state.copyWith(ticks: t.tick)); + }); + } + + @override + void beforeDestroy() { + _timer.cancel(); + } +} diff --git a/jael_web/example/stateful.g.dart b/jael_web/example/stateful.g.dart new file mode 100644 index 00000000..5d26147d --- /dev/null +++ b/jael_web/example/stateful.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'stateful.dart'; + +// ************************************************************************** +// JaelComponentGenerator +// ************************************************************************** + +abstract class _StatefulAppJaelTemplate implements Component<_AppState> { + Timer get _timer; + @override + DomNode render() { + return h('div', {}, [text('Tick count: '), text(state.ticks.toString())]); + } +} diff --git a/jael_web/lib/builder.dart b/jael_web/lib/builder.dart new file mode 100644 index 00000000..0c9f4b71 --- /dev/null +++ b/jael_web/lib/builder.dart @@ -0,0 +1 @@ +export 'src/builder/builder.dart'; \ No newline at end of file diff --git a/jael_web/lib/elements.dart b/jael_web/lib/elements.dart new file mode 100644 index 00000000..01ea2e52 --- /dev/null +++ b/jael_web/lib/elements.dart @@ -0,0 +1 @@ +export 'src/elements.dart'; \ No newline at end of file diff --git a/jael_web/lib/jael_web.dart b/jael_web/lib/jael_web.dart index 98c7b7f7..f8f56f7f 100644 --- a/jael_web/lib/jael_web.dart +++ b/jael_web/lib/jael_web.dart @@ -3,3 +3,4 @@ export 'src/component.dart'; export 'src/dom_builder.dart'; export 'src/dom_node.dart'; export 'src/fn.dart'; +export 'src/jael_component.dart'; diff --git a/jael_web/lib/src/builder/builder.dart b/jael_web/lib/src/builder/builder.dart new file mode 100644 index 00000000..fc5fe05a --- /dev/null +++ b/jael_web/lib/src/builder/builder.dart @@ -0,0 +1,123 @@ +import 'dart:async'; + +import 'package:analyzer/dart/element/element.dart'; +import 'package:build/build.dart'; +import 'package:code_builder/code_builder.dart'; +import 'package:jael/jael.dart' as jael; +import 'package:jael_preprocessor/jael_preprocessor.dart' as jael; +import 'package:jael_web/jael_web.dart'; +import 'package:path/path.dart' as p; +import 'package:source_gen/source_gen.dart'; +import 'util.dart'; + +Builder jaelComponentBuilder(_) { + return SharedPartBuilder([JaelComponentGenerator()], 'jael_web_cmp'); +} + +class JaelComponentGenerator extends GeneratorForAnnotation { + @override + Future generateForAnnotatedElement( + Element element, ConstantReader annotation, BuildStep buildStep) async { + if (element is ClassElement) { + // Load the template + String templateString; + var inputId = buildStep.inputId; + var ann = Jael( + template: annotation.peek('template')?.stringValue, + templateUrl: annotation.peek('templateUrl')?.stringValue, + asDsx: annotation.peek('asDsx')?.boolValue ?? false, + ); + + if (ann.template == null && ann.templateUrl == null) { + throw 'Both `template` and `templateUrl` cannot be null.'; + } + + if (ann.template != null) + templateString = ann.template; + else { + var dir = p.dirname(inputId.path); + var assetId = AssetId(inputId.package, p.join(dir, ann.templateUrl)); + if (!await buildStep.canRead(assetId)) { + throw 'Cannot find template "${assetId.uri}"'; + } else { + templateString = await buildStep.readAsString(assetId); + } + } + + var fs = BuildFileSystem(buildStep, inputId.package); + var errors = []; + var doc = await jael.parseDocument(templateString, + sourceUrl: inputId.uri, asDSX: ann.asDsx, onError: errors.add); + if (errors.isEmpty) { + doc = await jael.resolve(doc, fs.file(inputId.uri).parent, + onError: errors.add); + } + + if (errors.isNotEmpty) { + errors.forEach(log.severe); + throw 'Jael processing finished with ${errors.length} error(s).'; + } + + // Generate a _XJaelTemplate mixin class + var clazz = Class((b) { + b + ..abstract = true + ..name = '_${element.name}JaelTemplate' + ..implements.add(convertTypeReference(element.supertype)); + + // Add fields corresponding to each of the class's fields. + for (var field in element.fields) { + b.methods.add(Method((b) { + b + ..name = field.name + ..type = MethodType.getter + ..returns = convertTypeReference(field.type); + })); + } + + // Add a render() stub + b.methods.add(Method((b) { + b + ..name = 'render' + ..returns = refer('DomNode') + ..annotations.add(refer('override')) + ..body = Block((b) { + var result = compileElementChild(doc.root); + b.addExpression(result.returned); + }); + })); + }); + + return clazz.accept(DartEmitter()).toString(); + } else { + throw '@Jael() is only supported for classes.'; + } + } + + Expression compileElementChild(jael.ElementChild child) { + if (child is jael.TextNode || child is jael.Text) { + return refer('text').call([literalString(child.span.text)]); + } else if (child is jael.Interpolation) { + Expression expr = CodeExpression(Code(child.expression.span.text)); + expr = expr.property('toString').call([]); + return refer('text').call([expr]); + } else if (child is jael.Element) { + // TODO: Handle strict resolution + var attrs = {}; + for (var attr in child.attributes) { + attrs[attr.name] = attr.value == null + ? literalTrue + : CodeExpression(Code(attr.value.span.text)); + } + + return refer('h').call([ + literalString(child.tagName.name), + literalMap(attrs), + literalList(child.children.map(compileElementChild)), + ]); + // return refer(child.tagName.name).newInstance([]); + } else { + throw 'Unsupported: $child'; + } + } +} diff --git a/jael_web/lib/src/builder/util.dart b/jael_web/lib/src/builder/util.dart new file mode 100644 index 00000000..72ac0974 --- /dev/null +++ b/jael_web/lib/src/builder/util.dart @@ -0,0 +1,375 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:analyzer/dart/element/type.dart'; +import 'package:build/build.dart'; +import 'package:code_builder/code_builder.dart'; +import 'package:file/file.dart'; +import 'package:path/src/context.dart'; + +/// Converts a [DartType] to a [TypeReference]. +TypeReference convertTypeReference(DartType t) { + return new TypeReference((b) { + b..symbol = t.name; + + if (t is InterfaceType) { + b.types.addAll(t.typeArguments.map(convertTypeReference)); + } + }); +} + +UnsupportedError _unsupported() => + UnsupportedError('Not support in R/O build file system.'); + +class BuildFileSystem extends FileSystem { + final AssetReader reader; + final String package; + Context _path = Context(); + + BuildFileSystem(this.reader, this.package); + + Context get path => _path; + + @override + Directory get currentDirectory { + return BuildSystemDirectory(this, reader, package, _path.current); + } + + set currentDirectory(value) { + if (value is Directory) { + _path = Context(current: value.path); + } else if (value is String) { + _path = Context(current: value); + } else { + throw ArgumentError(); + } + } + + @override + Directory directory(path) { + String p; + if (path is String) + p = path; + else if (path is Uri) + p = p.toString(); + else if (path is FileSystemEntity) + p = path.path; + else + throw ArgumentError(); + return BuildSystemDirectory(this, reader, package, p); + } + + @override + File file(path) { + String p; + if (path is String) + p = path; + else if (path is Uri) + p = p.toString(); + else if (path is FileSystemEntity) + p = path.path; + else + throw ArgumentError(); + return BuildSystemFile(this, reader, package, p); + } + + @override + Future identical(String path1, String path2) => throw _unsupported(); + + @override + bool identicalSync(String path1, String path2) => throw _unsupported(); + + @override + bool get isWatchSupported => false; + + @override + Link link(path) => throw _unsupported(); + + @override + Future stat(String path) => throw _unsupported(); + + @override + FileStat statSync(String path) => throw _unsupported(); + + @override + Directory get systemTempDirectory => throw _unsupported(); + + @override + Future type(String path, {bool followLinks = true}) => + throw _unsupported(); + + @override + FileSystemEntityType typeSync(String path, {bool followLinks = true}) => + throw _unsupported(); +} + +class BuildSystemFile extends File { + final BuildFileSystem fileSystem; + final AssetReader reader; + final String package; + final String path; + + BuildSystemFile(this.fileSystem, this.reader, this.package, this.path); + + Uri get uri => fileSystem.path.toUri(path); + + @override + File get absolute => this; + + @override + String get basename => fileSystem.path.basename(path); + + @override + Future copy(String newPath) => throw _unsupported(); + + @override + File copySync(String newPath) => throw _unsupported(); + + @override + Future create({bool recursive = false}) => throw _unsupported(); + + @override + void createSync({bool recursive = false}) => throw _unsupported(); + + @override + Future delete({bool recursive = false}) => + throw _unsupported(); + + @override + void deleteSync({bool recursive = false}) => throw _unsupported(); + + @override + String get dirname => fileSystem.path.dirname(path); + + @override + Future exists() => throw _unsupported(); + @override + bool existsSync() => throw _unsupported(); + + @override + bool get isAbsolute => true; + + @override + Future lastAccessed() => throw _unsupported(); + + @override + DateTime lastAccessedSync() => throw _unsupported(); + + @override + Future lastModified() => throw _unsupported(); + + @override + DateTime lastModifiedSync() => throw _unsupported(); + + @override + Future length() => throw _unsupported(); + @override + int lengthSync() => throw _unsupported(); + + @override + Future open({FileMode mode = FileMode.read}) => + throw _unsupported(); + + @override + Stream> openRead([int start, int end]) => throw _unsupported(); + + @override + RandomAccessFile openSync({FileMode mode = FileMode.read}) => + throw _unsupported(); + + @override + IOSink openWrite( + {FileMode mode = FileMode.write, Encoding encoding = utf8}) => + throw _unsupported(); + + @override + Directory get parent => + BuildSystemDirectory(fileSystem, reader, package, fileSystem.path.dirname(path)); + + @override + Future> readAsBytes() { + var assetId = AssetId(package, path); + return reader.readAsBytes(assetId); + } + + @override + List readAsBytesSync() => throw _unsupported(); + @override + Future> readAsLines({Encoding encoding = utf8}) => + throw _unsupported(); + + @override + List readAsLinesSync({Encoding encoding = utf8}) => + throw _unsupported(); + + @override + Future readAsString({Encoding encoding = utf8}) { + var assetId = AssetId(package, path); + return reader.readAsString(assetId); + } + + @override + String readAsStringSync({Encoding encoding = utf8}) => throw _unsupported(); + + @override + Future rename(String newPath) => throw _unsupported(); + + @override + File renameSync(String newPath) => throw _unsupported(); + + @override + Future resolveSymbolicLinks() => throw _unsupported(); + + @override + String resolveSymbolicLinksSync() => throw _unsupported(); + + @override + Future setLastAccessed(DateTime time) => throw _unsupported(); + + @override + void setLastAccessedSync(DateTime time) => throw _unsupported(); + + @override + Future setLastModified(DateTime time) => throw _unsupported(); + + @override + void setLastModifiedSync(DateTime time) => throw _unsupported(); + + @override + Future stat() => throw _unsupported(); + + @override + FileStat statSync() => throw _unsupported(); + + @override + Stream watch( + {int events = FileSystemEvent.all, bool recursive = false}) => + throw _unsupported(); + + @override + Future writeAsBytes(List bytes, + {FileMode mode = FileMode.write, bool flush = false}) => + throw _unsupported(); + + @override + void writeAsBytesSync(List bytes, + {FileMode mode = FileMode.write, bool flush = false}) => + throw _unsupported(); + + @override + Future writeAsString(String contents, + {FileMode mode = FileMode.write, + Encoding encoding = utf8, + bool flush = false}) => + throw _unsupported(); + + @override + void writeAsStringSync(String contents, + {FileMode mode = FileMode.write, + Encoding encoding = utf8, + bool flush = false}) => + throw _unsupported(); +} + +class BuildSystemDirectory extends Directory { + final BuildFileSystem fileSystem; + final AssetReader reader; + final String package; + final String path; + + BuildSystemDirectory(this.fileSystem, this.reader, this.package, this.path); + + @override + Directory get absolute => this; + + @override + String get basename => fileSystem.path.basename(path); + + @override + Directory childDirectory(String basename) { + return BuildSystemDirectory( + fileSystem, reader, package, fileSystem.path.join(path, basename)); + } + + @override + File childFile(String basename) { + return BuildSystemFile( + fileSystem, reader, package, fileSystem.path.join(path, basename)); + } + + @override + Link childLink(String basename) => throw _unsupported(); + + @override + Future create({bool recursive = false}) => throw _unsupported(); + + @override + void createSync({bool recursive = false}) => throw _unsupported(); + + @override + Future createTemp([String prefix]) => throw _unsupported(); + + @override + Directory createTempSync([String prefix]) => throw _unsupported(); + + @override + Future delete({bool recursive = false}) => + throw _unsupported(); + + @override + void deleteSync({bool recursive = false}) => throw _unsupported(); + + @override + String get dirname => fileSystem.path.dirname(path); + + @override + Future exists() => throw _unsupported(); + + @override + bool existsSync() => throw _unsupported(); + + @override + bool get isAbsolute => true; + + @override + Stream list( + {bool recursive = false, bool followLinks = true}) => + throw _unsupported(); + + @override + List listSync( + {bool recursive = false, bool followLinks = true}) => + throw _unsupported(); + + @override + Directory get parent { + return BuildSystemDirectory( + fileSystem, reader, package, fileSystem.path.dirname(path)); + } + + @override + Future rename(String newPath) => throw _unsupported(); + + @override + Directory renameSync(String newPath) => throw _unsupported(); + + @override + Future resolveSymbolicLinks() => throw _unsupported(); + + @override + String resolveSymbolicLinksSync() => throw _unsupported(); + + @override + Future stat() => throw _unsupported(); + + @override + FileStat statSync() => throw _unsupported(); + + @override + Uri get uri => fileSystem.path.toUri(path); + + @override + Stream watch( + {int events = FileSystemEvent.all, bool recursive = false}) => + throw _unsupported(); +} diff --git a/jael_web/lib/src/builder_node.dart b/jael_web/lib/src/builder_node.dart index 555187ff..91c5970e 100644 --- a/jael_web/lib/src/builder_node.dart +++ b/jael_web/lib/src/builder_node.dart @@ -6,3 +6,48 @@ abstract class BuilderNode extends DomNode { void destroy(DomBuilderElement el); } + +DomNode h(String tagName, + [Map props = const {}, + Iterable children = const []]) { + return _H(tagName, props, children); +} + +DomNode text(String value) => _Text(value); + +class _Text extends BuilderNode { + final String text; + + _Text(this.text); + + @override + DomBuilderElement build(DomBuilder dom) { + dom.text(text); + // TODO: implement build + return null; + } + + @override + void destroy(DomBuilderElement el) { + // TODO: implement destroy + } +} + +class _H extends BuilderNode { + final String tagName; + final Map props; + final Iterable children; + + _H(this.tagName, this.props, this.children); + + @override + DomBuilderElement build(DomBuilder dom) { + // TODO: implement build + return null; + } + + @override + void destroy(DomBuilderElement el) { + // TODO: implement destroy + } +} diff --git a/jael_web/lib/src/elements.dart b/jael_web/lib/src/elements.dart new file mode 100644 index 00000000..c20a99f3 --- /dev/null +++ b/jael_web/lib/src/elements.dart @@ -0,0 +1,2036 @@ +import 'builder_node.dart'; +import 'dom_node.dart'; + +Map _apply(Iterable> props, + [Map attrs]) { + var map = {}; + attrs?.forEach((k, attr) { + if (attr is String && attr?.isNotEmpty == true) { + map[k] = attr; + } else if (attr is Iterable && attr?.isNotEmpty == true) { + map[k] = attr.toList(); + } else if (attr != null) { + map[k] = attr; + } + }); + + for (var p in props) { + map.addAll(p ?? {}); + } + + return map.cast(); +} + +DomNode a( + {String href, + String rel, + String target, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'a', + _apply([ + p, + props + ], { + 'href': href, + 'rel': rel, + 'target': target, + 'id': id, + 'class': className, + 'style': style, + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode abbr( + {String title, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'addr', + _apply([p, props], + {'title': title, 'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode address( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'address', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode area( + {String alt, + Iterable coordinates, + String download, + String href, + String hreflang, + String media, + String nohref, + String rel, + String shape, + String target, + String type, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}}) => + h( + 'area', + _apply([ + p, + props + ], { + 'alt': alt, + 'coordinates': coordinates, + 'download': download, + 'href': href, + 'hreflang': hreflang, + 'media': media, + 'nohref': nohref, + 'rel': rel, + 'shape': shape, + 'target': target, + 'type': type, + 'id': id, + 'class': className, + 'style': style + })); + +DomNode article( + {className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('article', _apply([p, props], {'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode aside( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'aside', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode audio( + {bool autoplay, + bool controls, + bool loop, + bool muted, + String preload, + String src, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'audio', + _apply([ + p, + props + ], { + 'autoplay': autoplay, + 'controls': controls, + 'loop': loop, + 'muted': muted, + 'preload': preload, + 'src': src, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode b( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('b', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode base( + {String href, + String target, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}}) => + h( + 'base', + _apply([ + p, + props + ], { + 'href': href, + 'target': target, + 'id': id, + 'class': className, + 'style': style + })); + +DomNode bdi( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('bdi', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode bdo( + {String dir, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'bdo', + _apply([p, props], + {'dir': dir, 'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode blockquote( + {String cite, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'blockquote', + _apply([p, props], + {'cite': cite, 'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode body( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'body', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode br() => h('br'); + +DomNode button( + {bool autofocus, + bool disabled, + form, + String formaction, + String formenctype, + String formmethod, + bool formnovalidate, + String formtarget, + String name, + String type, + String value, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'button', + _apply([ + p, + props + ], { + 'autofocus': autofocus, + 'disabled': disabled, + 'form': form, + 'formaction': formaction, + 'formenctype': formenctype, + 'formmethod': formmethod, + 'formnovalidate': formnovalidate, + 'formtarget': formtarget, + 'name': name, + 'type': type, + 'value': value, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode canvas( + {num height, + num width, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'canvas', + _apply([ + p, + props + ], { + 'height': height, + 'width': width, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode cite( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'cite', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode caption( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'caption', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode code( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'code', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode col( + {num span, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'col', + _apply([p, props], + {'span': span, 'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode colgroup( + {num span, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'colgroup', + _apply([p, props], + {'span': span, 'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode datalist( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'datalist', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode dd( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('dd', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode del( + {String cite, + String datetime, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'del', + _apply([ + p, + props + ], { + 'cite': cite, + 'datetime': datetime, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode details( + {bool open, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'details', + _apply([p, props], + {'open': open, 'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode dfn( + {String title, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'dfn', + _apply([p, props], + {'title': title, 'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode dialog( + {bool open, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'dialog', + _apply([p, props], + {'open': open, 'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode div( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('div', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode dl( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('dl', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode dt( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('dt', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode em( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('em', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode embed( + {num height, + String src, + String type, + num width, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}}) => + h( + 'embed', + _apply([ + p, + props + ], { + 'height': height, + 'src': src, + 'type': type, + 'width': width, + 'id': id, + 'class': className, + 'style': style + })); + +DomNode fieldset( + {bool disabled, + String form, + String name, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'fieldset', + _apply([ + p, + props + ], { + 'disabled': disabled, + 'form': form, + 'name': name, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode figcaption( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'figcaption', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode figure( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'figure', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode footer( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'footer', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode form( + {String accept, + String acceptCharset, + String action, + bool autocomplete, + String enctype, + String method, + String name, + bool novalidate, + String target, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'form', + _apply([ + p, + props + ], { + 'accept': accept, + 'accept-charset': acceptCharset, + 'action': action, + 'autocomplete': + autocomplete != null ? (autocomplete ? 'on' : 'off') : null, + 'enctype': enctype, + 'method': method, + 'name': name, + 'novalidate': novalidate, + 'target': target, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode h1( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('h1', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode h2( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('h2', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); +DomNode h3( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('h3', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode h4( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('h4', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode h5( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('h5', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode h6( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('h6', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode head( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'head', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode header( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'header', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode hr() => h('hr'); + +DomNode html( + {String manifest, + String xmlns, + String lang, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'html', + _apply([ + p, + props + ], { + 'manifest': manifest, + 'xmlns': xmlns, + 'lang': lang, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode i( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('i', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode iframe( + {num height, + String name, + sandbox, + String src, + String srcdoc, + num width, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}}) => + h( + 'iframe', + _apply([ + p, + props + ], { + 'height': height, + 'name': name, + 'sandbox': sandbox, + 'src': src, + 'srcdoc': srcdoc, + 'width': width, + 'id': id, + 'class': className, + 'style': style + })); + +DomNode img( + {String alt, + String crossorigin, + num height, + String ismap, + String longdesc, + sizes, + String src, + String srcset, + String usemap, + num width, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}}) => + h( + 'img', + _apply([ + p, + props + ], { + 'alt': alt, + 'crossorigin': crossorigin, + 'height': height, + 'ismap': ismap, + 'longdesc': longdesc, + 'sizes': sizes, + 'src': src, + 'srcset': srcset, + 'usemap': usemap, + 'width': width, + 'id': id, + 'class': className, + 'style': style + })); + +DomNode input( + {String accept, + String alt, + bool autocomplete, + bool autofocus, + bool checked, + String dirname, + bool disabled, + String form, + String formaction, + String formenctype, + String method, + String formnovalidate, + String formtarget, + num height, + String list, + max, + num maxlength, + min, + bool multiple, + String name, + String pattern, + String placeholder, + bool readonly, + bool required, + num size, + String src, + num step, + String type, + String value, + num width, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}}) => + h( + 'input', + _apply([ + p, + props + ], { + 'accept': accept, + 'alt': alt, + 'autocomplete': + autocomplete == null ? null : (autocomplete ? 'on' : 'off'), + 'autofocus': autofocus, + 'checked': checked, + 'dirname': dirname, + 'disabled': disabled, + 'form': form, + 'formaction': formaction, + 'formenctype': formenctype, + 'method': method, + 'formnovalidate': formnovalidate, + 'formtarget': formtarget, + 'height': height, + 'list': list, + 'max': max, + 'maxlength': maxlength, + 'min': min, + 'multiple': multiple, + 'name': name, + 'pattern': pattern, + 'placeholder': placeholder, + 'readonly': readonly, + 'required': required, + 'size': size, + 'src': src, + 'step': step, + 'type': type, + 'value': value, + 'width': width, + 'id': id, + 'class': className, + 'style': style + })); + +DomNode ins( + {String cite, + String datetime, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'ins', + _apply([ + p, + props + ], { + 'cite': cite, + 'datetime': datetime, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode kbd( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('kbd', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode keygen( + {bool autofocus, + String challenge, + bool disabled, + String from, + String keytype, + String name, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'keygen', + _apply([ + p, + props + ], { + 'autofocus': autofocus, + 'challenge': challenge, + 'disabled': disabled, + 'from': from, + 'keytype': keytype, + 'name': name, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode label( + {String for_, + String form, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'label', + _apply([ + p, + props + ], { + 'for': for_, + 'form': form, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode legend( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'legend', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode li( + {num value, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'li', + _apply([p, props], + {'value': value, 'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode link( + {String crossorigin, + String href, + String hreflang, + String media, + String rel, + sizes, + String target, + String type, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}}) => + h( + 'link', + _apply([ + p, + props + ], { + 'crossorigin': crossorigin, + 'href': href, + 'hreflang': hreflang, + 'media': media, + 'rel': rel, + 'sizes': sizes, + 'target': target, + 'type': type, + 'id': id, + 'class': className, + 'style': style + })); + +DomNode main( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'main', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode map( + {String name, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'map', + _apply([p, props], + {'name': name, 'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode mark( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'mark', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode menu( + {String label, + String type, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'menu', + _apply([ + p, + props + ], { + 'label': label, + 'type': type, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode menuitem( + {bool checked, + command, + bool default_, + bool disabled, + String icon, + String label, + String radiogroup, + String type, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'menuitem', + _apply([ + p, + props + ], { + 'checked': checked, + 'command': command, + 'default': default_, + 'disabled': disabled, + 'icon': icon, + 'label': label, + 'radiogroup': radiogroup, + 'type': type, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode meta( + {String charset, + String content, + String httpEquiv, + String name, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}}) => + h( + 'meta', + _apply([ + p, + props + ], { + 'charset': charset, + 'content': content, + 'http-equiv': httpEquiv, + 'name': name, + 'id': id, + 'class': className, + 'style': style + })); + +DomNode nav( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('nav', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode noscript( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'noscript', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode object( + {String data, + String form, + num height, + String name, + String type, + String usemap, + num width, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'object', + _apply([ + p, + props + ], { + 'data': data, + 'form': form, + 'height': height, + 'name': name, + 'type': type, + 'usemap': usemap, + 'width': width, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode ol( + {bool reversed, + num start, + String type, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'ol', + _apply([ + p, + props + ], { + 'reversed': reversed, + 'start': start, + 'type': type, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode optgroup( + {bool disabled, + String label, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'optgroup', + _apply([ + p, + props + ], { + 'disabled': disabled, + 'label': label, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode option( + {bool disabled, + String label, + bool selected, + String value, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'option', + _apply([ + p, + props + ], { + 'disabled': disabled, + 'label': label, + 'selected': selected, + 'value': value, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode output( + {String for_, + String form, + String name, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'output', + _apply([ + p, + props + ], { + 'for': for_, + 'form': form, + 'name': name, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode p( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('p', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode param( + {String name, + value, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}}) => + h( + 'param', + _apply([ + p, + props + ], { + 'name': name, + 'value': value, + 'id': id, + 'class': className, + 'style': style + })); + +DomNode picture( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'picture', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode pre( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('pre', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode progress( + {num max, + num value, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'progress', + _apply([ + p, + props + ], { + 'max': max, + 'value': value, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode q( + {String cite, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'q', + _apply([p, props], + {'cite': cite, 'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode rp( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('rp', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode rt( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('rt', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode ruby( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'ruby', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode s( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('s', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode samp( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'samp', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode script( + {bool async, + String charset, + bool defer, + String src, + String type, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'script', + _apply([ + p, + props + ], { + 'async': async, + 'charset': charset, + 'defer': defer, + 'src': src, + 'type': type, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode section( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'section', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode select( + {bool autofocus, + bool disabled, + String form, + bool multiple, + bool required, + num size, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'select', + _apply([ + p, + props + ], { + 'autofocus': autofocus, + 'disabled': disabled, + 'form': form, + 'multiple': multiple, + 'required': required, + 'size': size, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode small( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'small', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode source( + {String src, + String srcset, + String media, + sizes, + String type, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}}) => + h( + 'source', + _apply([ + p, + props + ], { + 'src': src, + 'srcset': srcset, + 'media': media, + 'sizes': sizes, + 'type': type, + 'id': id, + 'class': className, + 'style': style + })); + +DomNode span( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'span', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode strong( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'strong', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode style( + {String media, + bool scoped, + String type, + String id, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'style', + _apply([p, props], + {'media': media, 'scoped': scoped, 'type': type, 'id': id}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode sub( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('sub', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode summary( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'summary', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode sup( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('sup', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode table( + {bool sortable, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'table', + _apply([ + p, + props + ], { + 'sortable': sortable, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode tbody( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'tbody', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode td( + {num colspan, + headers, + num rowspan, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'td', + _apply([ + p, + props + ], { + 'colspan': colspan, + 'headers': headers, + 'rowspan': rowspan, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode textarea( + {bool autofocus, + num cols, + String dirname, + bool disabled, + String form, + num maxlength, + String name, + String placeholder, + bool readonly, + bool required, + num rows, + String wrap, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'textarea', + _apply([ + p, + props + ], { + 'autofocus': autofocus, + 'cols': cols, + 'dirname': dirname, + 'disabled': disabled, + 'form': form, + 'maxlength': maxlength, + 'name': name, + 'placeholder': placeholder, + 'readonly': readonly, + 'required': required, + 'rows': rows, + 'wrap': wrap, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode tfoot( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'tfoot', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode th( + {String abbr, + num colspan, + headers, + num rowspan, + String scope, + sorted, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'th', + _apply([ + p, + props + ], { + 'abbr': abbr, + 'colspan': colspan, + 'headers': headers, + 'rowspan': rowspan, + 'scope': scope, + 'sorted': sorted, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode thead( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'thead', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode time( + {String datetime, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'time', + _apply([ + p, + props + ], { + 'datetime': datetime, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode title( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'title', + _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode tr( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('tr', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode track( + {bool default_, + String kind, + String label, + String src, + String srclang, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}}) => + h( + 'track', + _apply([ + p, + props + ], { + 'default': default_, + 'kind': kind, + 'label': label, + 'src': src, + 'srclang': srclang, + 'id': id, + 'class': className, + 'style': style + })); + +DomNode u( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('u', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode ul( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('ul', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode var_( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('var', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode video( + {bool autoplay, + bool controls, + num height, + bool loop, + bool muted, + String poster, + String preload, + String src, + num width, + String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h( + 'video', + _apply([ + p, + props + ], { + 'autoplay': autoplay, + 'controls': controls, + 'height': height, + 'loop': loop, + 'muted': muted, + 'poster': poster, + 'preload': preload, + 'src': src, + 'width': width, + 'id': id, + 'class': className, + 'style': style + }), + []..addAll(c ?? [])..addAll(children ?? [])); + +DomNode wbr( + {String id, + className, + style, + Map p: const {}, + @deprecated Map props: const {}, + Iterable c: const [], + @deprecated Iterable children: const []}) => + h('wbr', _apply([p, props], {'id': id, 'class': className, 'style': style}), + []..addAll(c ?? [])..addAll(children ?? [])); \ No newline at end of file diff --git a/jael_web/lib/src/jael_component.dart b/jael_web/lib/src/jael_component.dart new file mode 100644 index 00000000..0e0304fe --- /dev/null +++ b/jael_web/lib/src/jael_component.dart @@ -0,0 +1,19 @@ +/// A annotation for components that source-gen their `render()` methods. +class Jael { + /// The raw template. + final String template; + + /// The path to a [template]. + final String templateUrl; + + /// Whether to parse the [template] as `DSX`. + final bool asDsx; + + const Jael({this.template, this.templateUrl, this.asDsx}); +} + +/// Shorthand for enabling `DSX` syntax when using a [Jael] annotation. +class Dsx extends Jael { + const Dsx({String template, String templateUrl}) + : super(template: template, templateUrl: templateUrl, asDsx: true); +} diff --git a/jael_web/pubspec.yaml b/jael_web/pubspec.yaml index c8a0d607..0b613d1d 100644 --- a/jael_web/pubspec.yaml +++ b/jael_web/pubspec.yaml @@ -7,6 +7,8 @@ dependencies: build: ^1.0.0 build_config: ^0.3.0 code_builder: ^3.0.0 + jael: ^2.0.0 + jael_preprocessor: ^2.0.0 source_gen: ^0.9.0 dev_dependencies: build_runner: ^1.0.0