maquette 4.1.3 → 4.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cache.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { CalculationCache } from "./interfaces";
2
2
  /**
3
- * Creates a [[CalculationCache]] object, useful for caching [[VNode]] trees.
4
- * In practice, caching of [[VNode]] trees is not needed, because achieving 60 frames per second is almost never a problem.
5
- * For more information, see [[CalculationCache]].
3
+ * Creates a {@link CalculationCache} object, useful for caching {@link VNode} trees.
4
+ * In practice, caching of {@link VNode} trees is not needed, because achieving 60 frames per second is almost never a problem.
5
+ * For more information, see {@link CalculationCache}.
6
6
  *
7
7
  * @param <Result> The type of the value that is cached.
8
8
  */
package/dist/cache.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Creates a [[CalculationCache]] object, useful for caching [[VNode]] trees.
3
- * In practice, caching of [[VNode]] trees is not needed, because achieving 60 frames per second is almost never a problem.
4
- * For more information, see [[CalculationCache]].
2
+ * Creates a {@link CalculationCache} object, useful for caching {@link VNode} trees.
3
+ * In practice, caching of {@link VNode} trees is not needed, because achieving 60 frames per second is almost never a problem.
4
+ * For more information, see {@link CalculationCache}.
5
5
  *
6
6
  * @param <Result> The type of the value that is cached.
7
7
  */
package/dist/cache.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,IAAI,WAAW,GAAG;IACvB,IAAI,YAAmC,CAAC;IACxC,IAAI,aAAiC,CAAC;IAEtC,OAAO;QACL,UAAU,EAAE;YACV,aAAa,GAAG,SAAS,CAAC;YAC1B,YAAY,GAAG,SAAS,CAAC;QAC3B,CAAC;QAED,MAAM,EAAE,UAAC,MAAiB,EAAE,WAAyB;YACnD,IAAI,YAAY,EAAE,CAAC;gBACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACvC,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;wBAClC,aAAa,GAAG,SAAS,CAAC;oBAC5B,CAAC;gBACH,CAAC;YACH,CAAC;YACD,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,aAAa,GAAG,WAAW,EAAE,CAAC;gBAC9B,YAAY,GAAG,MAAM,CAAC;YACxB,CAAC;YACD,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { CalculationCache } from \"./interfaces\";\n\n/**\n * Creates a [[CalculationCache]] object, useful for caching [[VNode]] trees.\n * In practice, caching of [[VNode]] trees is not needed, because achieving 60 frames per second is almost never a problem.\n * For more information, see [[CalculationCache]].\n *\n * @param <Result> The type of the value that is cached.\n */\nexport let createCache = <Result,>(): CalculationCache<Result> => {\n let cachedInputs: unknown[] | undefined;\n let cachedOutcome: Result | undefined;\n\n return {\n invalidate: () => {\n cachedOutcome = undefined;\n cachedInputs = undefined;\n },\n\n result: (inputs: unknown[], calculation: () => Result) => {\n if (cachedInputs) {\n for (let i = 0; i < inputs.length; i++) {\n if (cachedInputs[i] !== inputs[i]) {\n cachedOutcome = undefined;\n }\n }\n }\n if (!cachedOutcome) {\n cachedOutcome = calculation();\n cachedInputs = inputs;\n }\n return cachedOutcome;\n },\n };\n};\n"]}
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,IAAI,WAAW,GAAG;IACvB,IAAI,YAAmC,CAAC;IACxC,IAAI,aAAiC,CAAC;IAEtC,OAAO;QACL,UAAU,EAAE;YACV,aAAa,GAAG,SAAS,CAAC;YAC1B,YAAY,GAAG,SAAS,CAAC;QAC3B,CAAC;QAED,MAAM,EAAE,UAAC,MAAiB,EAAE,WAAyB;YACnD,IAAI,YAAY,EAAE,CAAC;gBACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACvC,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;wBAClC,aAAa,GAAG,SAAS,CAAC;oBAC5B,CAAC;gBACH,CAAC;YACH,CAAC;YACD,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,aAAa,GAAG,WAAW,EAAE,CAAC;gBAC9B,YAAY,GAAG,MAAM,CAAC;YACxB,CAAC;YACD,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { CalculationCache } from \"./interfaces\";\n\n/**\n * Creates a {@link CalculationCache} object, useful for caching {@link VNode} trees.\n * In practice, caching of {@link VNode} trees is not needed, because achieving 60 frames per second is almost never a problem.\n * For more information, see {@link CalculationCache}.\n *\n * @param <Result> The type of the value that is cached.\n */\nexport let createCache = <Result>(): CalculationCache<Result> => {\n let cachedInputs: unknown[] | undefined;\n let cachedOutcome: Result | undefined;\n\n return {\n invalidate: () => {\n cachedOutcome = undefined;\n cachedInputs = undefined;\n },\n\n result: (inputs: unknown[], calculation: () => Result) => {\n if (cachedInputs) {\n for (let i = 0; i < inputs.length; i++) {\n if (cachedInputs[i] !== inputs[i]) {\n cachedOutcome = undefined;\n }\n }\n }\n if (!cachedOutcome) {\n cachedOutcome = calculation();\n cachedInputs = inputs;\n }\n return cachedOutcome;\n },\n };\n};\n"]}
package/dist/dom.d.ts CHANGED
@@ -5,55 +5,55 @@ import { Projection, ProjectionOptions, VNode } from "./interfaces";
5
5
  export declare let applyDefaultProjectionOptions: (projectorOptions?: ProjectionOptions) => ProjectionOptions;
6
6
  export declare let dom: {
7
7
  /**
8
- * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in
9
- * its [[Projection.domNode|domNode]] property.
10
- * This is a low-level method. Users will typically use a [[Projector]] instead.
11
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
8
+ * Creates a real DOM tree from `vnode`. The {@link Projection} object returned will contain the resulting DOM Node in
9
+ * its {@link Projection.domNode | domNode} property.
10
+ * This is a low-level method. Users will typically use a {@link Projector} instead.
11
+ * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode}
12
12
  * objects may only be rendered once.
13
13
  * @param projectionOptions - Options to be used to create and update the projection.
14
- * @returns The [[Projection]] which also contains the DOM Node that was created.
14
+ * @returns The {@link Projection} which also contains the DOM Node that was created.
15
15
  */
16
16
  create: (vnode: VNode, projectionOptions?: ProjectionOptions) => Projection;
17
17
  /**
18
- * Appends a new child node to the DOM which is generated from a [[VNode]].
19
- * This is a low-level method. Users will typically use a [[Projector]] instead.
18
+ * Appends a new child node to the DOM which is generated from a {@link VNode}.
19
+ * This is a low-level method. Users will typically use a {@link Projector} instead.
20
20
  * @param parentNode - The parent node for the new child node.
21
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
21
+ * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode}
22
22
  * objects may only be rendered once.
23
- * @param projectionOptions - Options to be used to create and update the [[Projection]].
24
- * @returns The [[Projection]] that was created.
23
+ * @param projectionOptions - Options to be used to create and update the {@link Projection}.
24
+ * @returns The {@link Projection} that was created.
25
25
  */
26
26
  append: (parentNode: Element, vnode: VNode, projectionOptions?: ProjectionOptions) => Projection;
27
27
  /**
28
- * Inserts a new DOM node which is generated from a [[VNode]].
29
- * This is a low-level method. Users wil typically use a [[Projector]] instead.
28
+ * Inserts a new DOM node which is generated from a {@link VNode}.
29
+ * This is a low-level method. Users wil typically use a {@link Projector} instead.
30
30
  * @param beforeNode - The node that the DOM Node is inserted before.
31
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function.
32
- * NOTE: [[VNode]] objects may only be rendered once.
33
- * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
34
- * @returns The [[Projection]] that was created.
31
+ * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function.
32
+ * NOTE: {@link VNode} objects may only be rendered once.
33
+ * @param projectionOptions - Options to be used to create and update the projection, see {@link createProjector}.
34
+ * @returns The {@link Projection} that was created.
35
35
  */
36
36
  insertBefore: (beforeNode: Element, vnode: VNode, projectionOptions?: ProjectionOptions) => Projection;
37
37
  /**
38
- * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node.
38
+ * Merges a new DOM node which is generated from a {@link VNode} with an existing DOM Node.
39
39
  * This means that the virtual DOM and the real DOM will have one overlapping element.
40
- * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided.
41
- * This is a low-level method. Users wil typically use a [[Projector]] instead.
40
+ * Therefore the selector for the root {@link VNode} will be ignored, but its properties and children will be applied to the Element provided.
41
+ * This is a low-level method. Users wil typically use a {@link Projector} instead.
42
42
  * @param element - The existing element to adopt as the root of the new virtual DOM. Existing attributes and child nodes are preserved.
43
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects
43
+ * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode} objects
44
44
  * may only be rendered once.
45
- * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
46
- * @returns The [[Projection]] that was created.
45
+ * @param projectionOptions - Options to be used to create and update the projection, see {@link createProjector}.
46
+ * @returns The {@link Projection} that was created.
47
47
  */
48
48
  merge: (element: Element, vnode: VNode, projectionOptions?: ProjectionOptions) => Projection;
49
49
  /**
50
- * Replaces an existing DOM node with a node generated from a [[VNode]].
51
- * This is a low-level method. Users will typically use a [[Projector]] instead.
52
- * @param element - The node for the [[VNode]] to replace.
53
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
50
+ * Replaces an existing DOM node with a node generated from a {@link VNode}.
51
+ * This is a low-level method. Users will typically use a {@link Projector} instead.
52
+ * @param element - The node for the {@link VNode} to replace.
53
+ * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode}
54
54
  * objects may only be rendered once.
55
- * @param projectionOptions - Options to be used to create and update the [[Projection]].
56
- * @returns The [[Projection]] that was created.
55
+ * @param projectionOptions - Options to be used to create and update the {@link Projection}.
56
+ * @returns The {@link Projection} that was created.
57
57
  */
58
58
  replace: (element: Element, vnode: VNode, projectionOptions?: ProjectionOptions) => Projection;
59
59
  };
package/dist/dom.js CHANGED
@@ -19,13 +19,13 @@ export var applyDefaultProjectionOptions = function (projectorOptions) {
19
19
  };
20
20
  export var dom = {
21
21
  /**
22
- * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in
23
- * its [[Projection.domNode|domNode]] property.
24
- * This is a low-level method. Users will typically use a [[Projector]] instead.
25
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
22
+ * Creates a real DOM tree from `vnode`. The {@link Projection} object returned will contain the resulting DOM Node in
23
+ * its {@link Projection.domNode | domNode} property.
24
+ * This is a low-level method. Users will typically use a {@link Projector} instead.
25
+ * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode}
26
26
  * objects may only be rendered once.
27
27
  * @param projectionOptions - Options to be used to create and update the projection.
28
- * @returns The [[Projection]] which also contains the DOM Node that was created.
28
+ * @returns The {@link Projection} which also contains the DOM Node that was created.
29
29
  */
30
30
  create: function (vnode, projectionOptions) {
31
31
  projectionOptions = applyDefaultProjectionOptions(projectionOptions);
@@ -33,13 +33,13 @@ export var dom = {
33
33
  return createProjection(vnode, projectionOptions);
34
34
  },
35
35
  /**
36
- * Appends a new child node to the DOM which is generated from a [[VNode]].
37
- * This is a low-level method. Users will typically use a [[Projector]] instead.
36
+ * Appends a new child node to the DOM which is generated from a {@link VNode}.
37
+ * This is a low-level method. Users will typically use a {@link Projector} instead.
38
38
  * @param parentNode - The parent node for the new child node.
39
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
39
+ * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode}
40
40
  * objects may only be rendered once.
41
- * @param projectionOptions - Options to be used to create and update the [[Projection]].
42
- * @returns The [[Projection]] that was created.
41
+ * @param projectionOptions - Options to be used to create and update the {@link Projection}.
42
+ * @returns The {@link Projection} that was created.
43
43
  */
44
44
  append: function (parentNode, vnode, projectionOptions) {
45
45
  projectionOptions = applyDefaultProjectionOptions(projectionOptions);
@@ -47,13 +47,13 @@ export var dom = {
47
47
  return createProjection(vnode, projectionOptions);
48
48
  },
49
49
  /**
50
- * Inserts a new DOM node which is generated from a [[VNode]].
51
- * This is a low-level method. Users wil typically use a [[Projector]] instead.
50
+ * Inserts a new DOM node which is generated from a {@link VNode}.
51
+ * This is a low-level method. Users wil typically use a {@link Projector} instead.
52
52
  * @param beforeNode - The node that the DOM Node is inserted before.
53
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function.
54
- * NOTE: [[VNode]] objects may only be rendered once.
55
- * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
56
- * @returns The [[Projection]] that was created.
53
+ * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function.
54
+ * NOTE: {@link VNode} objects may only be rendered once.
55
+ * @param projectionOptions - Options to be used to create and update the projection, see {@link createProjector}.
56
+ * @returns The {@link Projection} that was created.
57
57
  */
58
58
  insertBefore: function (beforeNode, vnode, projectionOptions) {
59
59
  projectionOptions = applyDefaultProjectionOptions(projectionOptions);
@@ -61,15 +61,15 @@ export var dom = {
61
61
  return createProjection(vnode, projectionOptions);
62
62
  },
63
63
  /**
64
- * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node.
64
+ * Merges a new DOM node which is generated from a {@link VNode} with an existing DOM Node.
65
65
  * This means that the virtual DOM and the real DOM will have one overlapping element.
66
- * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided.
67
- * This is a low-level method. Users wil typically use a [[Projector]] instead.
66
+ * Therefore the selector for the root {@link VNode} will be ignored, but its properties and children will be applied to the Element provided.
67
+ * This is a low-level method. Users wil typically use a {@link Projector} instead.
68
68
  * @param element - The existing element to adopt as the root of the new virtual DOM. Existing attributes and child nodes are preserved.
69
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects
69
+ * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode} objects
70
70
  * may only be rendered once.
71
- * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
72
- * @returns The [[Projection]] that was created.
71
+ * @param projectionOptions - Options to be used to create and update the projection, see {@link createProjector}.
72
+ * @returns The {@link Projection} that was created.
73
73
  */
74
74
  merge: function (element, vnode, projectionOptions) {
75
75
  projectionOptions = applyDefaultProjectionOptions(projectionOptions);
@@ -78,13 +78,13 @@ export var dom = {
78
78
  return createProjection(vnode, projectionOptions);
79
79
  },
80
80
  /**
81
- * Replaces an existing DOM node with a node generated from a [[VNode]].
82
- * This is a low-level method. Users will typically use a [[Projector]] instead.
83
- * @param element - The node for the [[VNode]] to replace.
84
- * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
81
+ * Replaces an existing DOM node with a node generated from a {@link VNode}.
82
+ * This is a low-level method. Users will typically use a {@link Projector} instead.
83
+ * @param element - The node for the {@link VNode} to replace.
84
+ * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode}
85
85
  * objects may only be rendered once.
86
- * @param projectionOptions - Options to be used to create and update the [[Projection]].
87
- * @returns The [[Projection]] that was created.
86
+ * @param projectionOptions - Options to be used to create and update the {@link Projection}.
87
+ * @returns The {@link Projection} that was created.
88
88
  */
89
89
  replace: function (element, vnode, projectionOptions) {
90
90
  projectionOptions = applyDefaultProjectionOptions(projectionOptions);
package/dist/dom.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,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C,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;QAC3D,OAAO,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;;OAQG;IACH,YAAY,EAAE,UACZ,UAAmB,EACnB,KAAY,EACZ,iBAAqC;QAErC,iBAAiB,GAAG,6BAA6B,CAAC,iBAAiB,CAAC,CAAC;QACrE,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,UAAW,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC;QACxE,OAAO,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,EAAE,UAAC,OAAgB,EAAE,KAAY,EAAE,iBAAqC;QAC3E,iBAAiB,GAAG,6BAA6B,CAAC,iBAAiB,CAAC,CAAC;QACrE,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;QACxB,yBAAyB,CAAC,OAAO,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;QAC7D,OAAO,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO,EAAE,UAAC,OAAgB,EAAE,KAAY,EAAE,iBAAqC;QAC7E,iBAAiB,GAAG,6BAA6B,CAAC,iBAAiB,CAAC,CAAC;QACrE,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,UAAW,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;QAClE,OAAO,CAAC,UAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACzC,OAAO,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACpD,CAAC;CACF,CAAC","sourcesContent":["/**\n * Contains simple low-level utility functions to manipulate the real DOM.\n */\nimport { Projection, ProjectionOptions, VNode } from \"./interfaces\";\nimport { createDom, createProjection, extend, initPropertiesAndChildren } from \"./projection\";\n\nconst DEFAULT_PROJECTION_OPTIONS: ProjectionOptions = {\n namespace: undefined,\n performanceLogger: () => undefined,\n eventHandlerInterceptor: undefined,\n styleApplyer: (domNode: HTMLElement, styleName: string, value: string) => {\n if (styleName.charAt(0) === \"-\") {\n // CSS variables must be set using setProperty\n domNode.style.setProperty(styleName, value);\n } else {\n // properties like 'backgroundColor' must be set as a js-property\n (domNode.style as any)[styleName] = value;\n }\n },\n};\n\nexport let applyDefaultProjectionOptions = (\n projectorOptions?: ProjectionOptions\n): ProjectionOptions => {\n return extend(DEFAULT_PROJECTION_OPTIONS, projectorOptions);\n};\n\nexport let dom = {\n /**\n * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in\n * its [[Projection.domNode|domNode]] property.\n * This is a low-level method. Users will typically use a [[Projector]] instead.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection.\n * @returns The [[Projection]] which also contains the DOM Node that was created.\n */\n create: (vnode: VNode, projectionOptions?: ProjectionOptions): Projection => {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, document.createElement(\"div\"), undefined, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n\n /**\n * Appends a new child node to the DOM which is generated from a [[VNode]].\n * This is a low-level method. Users will typically use a [[Projector]] instead.\n * @param parentNode - The parent node for the new child node.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the [[Projection]].\n * @returns The [[Projection]] that was created.\n */\n append: (\n parentNode: Element,\n vnode: VNode,\n projectionOptions?: ProjectionOptions\n ): Projection => {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, parentNode, undefined, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n\n /**\n * Inserts a new DOM node which is generated from a [[VNode]].\n * This is a low-level method. Users wil typically use a [[Projector]] instead.\n * @param beforeNode - The node that the DOM Node is inserted before.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function.\n * NOTE: [[VNode]] objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].\n * @returns The [[Projection]] that was created.\n */\n insertBefore: (\n beforeNode: Element,\n vnode: VNode,\n projectionOptions?: ProjectionOptions\n ): Projection => {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, beforeNode.parentNode!, beforeNode, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n\n /**\n * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node.\n * This means that the virtual DOM and the real DOM will have one overlapping element.\n * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided.\n * This is a low-level method. Users wil typically use a [[Projector]] instead.\n * @param element - The existing element to adopt as the root of the new virtual DOM. Existing attributes and child nodes are preserved.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects\n * may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].\n * @returns The [[Projection]] that was created.\n */\n merge: (element: Element, vnode: VNode, projectionOptions?: ProjectionOptions): Projection => {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n vnode.domNode = element;\n initPropertiesAndChildren(element, vnode, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n\n /**\n * Replaces an existing DOM node with a node generated from a [[VNode]].\n * This is a low-level method. Users will typically use a [[Projector]] instead.\n * @param element - The node for the [[VNode]] to replace.\n * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the [[Projection]].\n * @returns The [[Projection]] that was created.\n */\n replace: (element: Element, vnode: VNode, projectionOptions?: ProjectionOptions): Projection => {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, element.parentNode!, element, projectionOptions);\n element.parentNode!.removeChild(element);\n return createProjection(vnode, projectionOptions);\n },\n};\n"]}
1
+ {"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAE9F,IAAM,0BAA0B,GAAsB;IACpD,SAAS,EAAE,SAAS;IACpB,iBAAiB,EAAE,cAAM,OAAA,SAAS,EAAT,CAAS;IAClC,uBAAuB,EAAE,SAAS;IAClC,YAAY,EAAE,UAAC,OAAoB,EAAE,SAAiB,EAAE,KAAa;QACnE,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAChC,8CAA8C;YAC9C,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,iEAAiE;YAChE,OAAO,CAAC,KAAa,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;QAC5C,CAAC;IACH,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,IAAI,6BAA6B,GAAG,UACzC,gBAAoC;IAEpC,OAAO,MAAM,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,CAAC,IAAI,GAAG,GAAG;IACf;;;;;;;;OAQG;IACH,MAAM,EAAE,UAAC,KAAY,EAAE,iBAAqC;QAC1D,iBAAiB,GAAG,6BAA6B,CAAC,iBAAiB,CAAC,CAAC;QACrE,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;QAC9E,OAAO,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,EAAE,UACN,UAAmB,EACnB,KAAY,EACZ,iBAAqC;QAErC,iBAAiB,GAAG,6BAA6B,CAAC,iBAAiB,CAAC,CAAC;QACrE,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC;QAC3D,OAAO,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;;OAQG;IACH,YAAY,EAAE,UACZ,UAAmB,EACnB,KAAY,EACZ,iBAAqC;QAErC,iBAAiB,GAAG,6BAA6B,CAAC,iBAAiB,CAAC,CAAC;QACrE,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,UAAW,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC;QACxE,OAAO,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,EAAE,UAAC,OAAgB,EAAE,KAAY,EAAE,iBAAqC;QAC3E,iBAAiB,GAAG,6BAA6B,CAAC,iBAAiB,CAAC,CAAC;QACrE,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;QACxB,yBAAyB,CAAC,OAAO,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;QAC7D,OAAO,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO,EAAE,UAAC,OAAgB,EAAE,KAAY,EAAE,iBAAqC;QAC7E,iBAAiB,GAAG,6BAA6B,CAAC,iBAAiB,CAAC,CAAC;QACrE,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,UAAW,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;QAClE,OAAO,CAAC,UAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACzC,OAAO,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACpD,CAAC;CACF,CAAC","sourcesContent":["/**\n * Contains simple low-level utility functions to manipulate the real DOM.\n */\nimport { Projection, ProjectionOptions, VNode } from \"./interfaces\";\nimport { createDom, createProjection, extend, initPropertiesAndChildren } from \"./projection\";\n\nconst DEFAULT_PROJECTION_OPTIONS: ProjectionOptions = {\n namespace: undefined,\n performanceLogger: () => undefined,\n eventHandlerInterceptor: undefined,\n styleApplyer: (domNode: HTMLElement, styleName: string, value: string) => {\n if (styleName.charAt(0) === \"-\") {\n // CSS variables must be set using setProperty\n domNode.style.setProperty(styleName, value);\n } else {\n // properties like 'backgroundColor' must be set as a js-property\n (domNode.style as any)[styleName] = value;\n }\n },\n};\n\nexport let applyDefaultProjectionOptions = (\n projectorOptions?: ProjectionOptions\n): ProjectionOptions => {\n return extend(DEFAULT_PROJECTION_OPTIONS, projectorOptions);\n};\n\nexport let dom = {\n /**\n * Creates a real DOM tree from `vnode`. The {@link Projection} object returned will contain the resulting DOM Node in\n * its {@link Projection.domNode | domNode} property.\n * This is a low-level method. Users will typically use a {@link Projector} instead.\n * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode}\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection.\n * @returns The {@link Projection} which also contains the DOM Node that was created.\n */\n create: (vnode: VNode, projectionOptions?: ProjectionOptions): Projection => {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, document.createElement(\"div\"), undefined, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n\n /**\n * Appends a new child node to the DOM which is generated from a {@link VNode}.\n * This is a low-level method. Users will typically use a {@link Projector} instead.\n * @param parentNode - The parent node for the new child node.\n * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode}\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the {@link Projection}.\n * @returns The {@link Projection} that was created.\n */\n append: (\n parentNode: Element,\n vnode: VNode,\n projectionOptions?: ProjectionOptions\n ): Projection => {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, parentNode, undefined, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n\n /**\n * Inserts a new DOM node which is generated from a {@link VNode}.\n * This is a low-level method. Users wil typically use a {@link Projector} instead.\n * @param beforeNode - The node that the DOM Node is inserted before.\n * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function.\n * NOTE: {@link VNode} objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection, see {@link createProjector}.\n * @returns The {@link Projection} that was created.\n */\n insertBefore: (\n beforeNode: Element,\n vnode: VNode,\n projectionOptions?: ProjectionOptions\n ): Projection => {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, beforeNode.parentNode!, beforeNode, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n\n /**\n * Merges a new DOM node which is generated from a {@link VNode} with an existing DOM Node.\n * This means that the virtual DOM and the real DOM will have one overlapping element.\n * Therefore the selector for the root {@link VNode} will be ignored, but its properties and children will be applied to the Element provided.\n * This is a low-level method. Users wil typically use a {@link Projector} instead.\n * @param element - The existing element to adopt as the root of the new virtual DOM. Existing attributes and child nodes are preserved.\n * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode} objects\n * may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the projection, see {@link createProjector}.\n * @returns The {@link Projection} that was created.\n */\n merge: (element: Element, vnode: VNode, projectionOptions?: ProjectionOptions): Projection => {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n vnode.domNode = element;\n initPropertiesAndChildren(element, vnode, projectionOptions);\n return createProjection(vnode, projectionOptions);\n },\n\n /**\n * Replaces an existing DOM node with a node generated from a {@link VNode}.\n * This is a low-level method. Users will typically use a {@link Projector} instead.\n * @param element - The node for the {@link VNode} to replace.\n * @param vnode - The root of the virtual DOM tree that was created using the {@link h} function. NOTE: {@link VNode}\n * objects may only be rendered once.\n * @param projectionOptions - Options to be used to create and update the {@link Projection}.\n * @returns The {@link Projection} that was created.\n */\n replace: (element: Element, vnode: VNode, projectionOptions?: ProjectionOptions): Projection => {\n projectionOptions = applyDefaultProjectionOptions(projectionOptions);\n createDom(vnode, element.parentNode!, element, projectionOptions);\n element.parentNode!.removeChild(element);\n return createProjection(vnode, projectionOptions);\n },\n};\n"]}
package/dist/h.d.ts CHANGED
@@ -8,7 +8,7 @@ import { VNode, VNodeChild, VNodeProperties } from "./interfaces";
8
8
  * It is formatted as follows: `tagname.cssclass1.cssclass2#id`.
9
9
  * @param properties An object literal containing properties that will be placed on the DOM node.
10
10
  * @param children Virtual DOM nodes and strings to add as child nodes.
11
- * `children` may contain [[VNode]]s, `string`s, nested arrays, `null` and `undefined`.
11
+ * `children` may contain {@link VNode}s, `string`s, nested arrays, `null` and `undefined`.
12
12
  * Nested arrays are flattened, `null` and `undefined` are removed.
13
13
  *
14
14
  * @returns A VNode object, used to render a real DOM later.
@@ -24,7 +24,7 @@ export declare function h(selector: string, properties?: VNodeProperties, childr
24
24
  * @param selector Contains the tagName, id and fixed css classnames in CSS selector format.
25
25
  * It is formatted as follows: `tagname.cssclass1.cssclass2#id`.
26
26
  * @param children Virtual DOM nodes and strings to add as child nodes.
27
- * `children` may contain [[VNode]]s, `string`s, nested arrays, `null` and `undefined`.
27
+ * `children` may contain {@link VNode}s, `string`s, nested arrays, `null` and `undefined`.
28
28
  * Nested arrays are flattened, `null` and `undefined` are removed.
29
29
  *
30
30
  * @returns A VNode object, used to render a real DOM later.
package/dist/h.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"h.js","sourceRoot":"","sources":["../src/h.ts"],"names":[],"mappings":"AAEA,IAAI,WAAW,GAAG,UAAC,IAAY;IAC7B,OAAO;QACL,aAAa,EAAE,EAAE;QACjB,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,SAAS;QACnB,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE;QACrB,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC,CAAC;AAEF,IAAI,cAAc,GAAG,UAAC,cAAsB,EAAE,UAAwB,EAAE,IAAa;IACnF,KAAK,IAAI,CAAC,GAAG,C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AAK,QAAQ,EAAE,CAAC;QACzE,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;SAAM,IAAI,QAAQ,EAAE,CAAC;QACpB,iBAAiB,GAAG,EAAE,CAAC;QACvB,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QACtD,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,iBAAiB,GAAG,SAAS,CAAC;QAChC,CAAC;IACH,CAAC;IACD,OAAO;QACL,aAAa,EAAE,QAAQ;QACvB,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,iBAAiB;QAC3B,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;QACpC,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC","sourcesContent":["import { VNode, VNodeChild, VNodeProperties } from \"./interfaces\";\n\nlet toTextVNode = (data: string): VNode => {\n return {\n vnodeSelector: \"\",\n properties: undefined,\n children: undefined,\n text: data.toString(),\n domNode: null,\n };\n};\n\nlet appendChildren = (parentSelector: string, insertions: VNodeChild[], main: VNode[]) => {\n for (let i = 0, length = insertions.length; i < length; i++) {\n let item = insertions[i];\n if (Array.isArray(item)) {\n appendChildren(parentSelector, item, main);\n } else {\n if (item !== null && item !== undefined && item !== false) {\n if (typeof item === \"string\") {\n item = toTextVNode(item);\n }\n main.push(item);\n }\n }\n }\n};\n\n/**\n * The `h` function is used to create a virtual DOM node.\n * This function is largely inspired by the mercuryjs and mithril frameworks.\n * The `h` stands for (virtual) hyperscript.\n *\n * @param selector Contains the tagName, id and fixed css classnames in CSS selector format.\n * It is formatted as follows: `tagname.cssclass1.cssclass2#id`.\n * @param properties An object literal containing properties that will be placed on the DOM node.\n * @param children Virtual DOM nodes and strings to add as child nodes.\n * `children` may contain [[VNode]]s, `string`s, nested arrays, `null` and `undefined`.\n * Nested arrays are flattened, `null` and `undefined` are removed.\n *\n * @returns A VNode object, used to render a real DOM later.\n *\n * NOTE: There are {@link http://maquettejs.org/docs/rules.html two basic rules} you should be aware of when updating the virtual DOM.\n */\nexport function h(\n selector: string,\n properties?: VNodeProperties,\n children?: VNodeChild[] | null\n): VNode;\n/**\n * The `h` function is used to create a virtual DOM node.\n * This function is largely inspired by the mercuryjs and mithril frameworks.\n * The `h` stands for (virtual) hyperscript.\n *\n * @param selector Contains the tagName, id and fixed css classnames in CSS selector format.\n * It is formatted as follows: `tagname.cssclass1.cssclass2#id`.\n * @param children Virtual DOM nodes and strings to add as child nodes.\n * `children` may contain [[VNode]]s, `string`s, nested arrays, `null` and `undefined`.\n * Nested arrays are flattened, `null` and `undefined` are removed.\n *\n * @returns A VNode object, used to render a real DOM later.\n *\n * NOTE: There are {@link http://maquettejs.org/docs/rules.html two basic rules} you should be aware of when updating the virtual DOM.\n */\nexport function h(selector: string, children: VNodeChild[]): VNode;\n\nexport function h(\n selector: string,\n properties?: VNodeProperties,\n children?: VNodeChild[] | null\n): VNode {\n if (Array.isArray(properties)) {\n children = properties;\n properties = undefined;\n } else if (\n (properties && (typeof (properties as any) === \"string\" || properties.vnodeSelector)) ||\n (children && (typeof (children as any) === \"string\" || (children as any).vnodeSelector))\n ) {\n throw new Error(\"h called with invalid arguments\");\n }\n let text: string | undefined;\n let flattenedChildren: VNode[] | undefined;\n // Recognize a common special case where there is only a single text node\n if (children && children.length === 1 && typeof children[0] === \"string\") {\n text = children[0];\n } else if (children) {\n flattenedChildren = [];\n appendChildren(selector, children, flattenedChildren);\n if (flattenedChildren.length === 0) {\n flattenedChildren = undefined;\n }\n }\n return {\n vnodeSelector: selector,\n properties: properties,\n children: flattenedChildren,\n text: text === \"\" ? undefined : text,\n domNode: null,\n };\n}\n"]}
1
+ {"version":3,"file":"h.js","sourceRoot":"","sources":["../src/h.ts"],"names":[],"mappings":"AAEA,IAAI,WAAW,GAAG,UAAC,IAAY;IAC7B,OAAO;QACL,aAAa,EAAE,EAA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CAAC,EACxF,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,IAAwB,CAAC;IAC7B,IAAI,iBAAsC,CAAC;IAC3C,yEAAyE;IACzE,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;QACzE,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;SAAM,IAAI,QAAQ,EAAE,CAAC;QACpB,iBAAiB,GAAG,EAAE,CAAC;QACvB,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QACtD,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,iBAAiB,GAAG,SAAS,CAAC;QAChC,CAAC;IACH,CAAC;IACD,OAAO;QACL,aAAa,EAAE,QAAQ;QACvB,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,iBAAiB;QAC3B,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;QACpC,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC","sourcesContent":["import { VNode, VNodeChild, VNodeProperties } from \"./interfaces\";\n\nlet toTextVNode = (data: string): VNode => {\n return {\n vnodeSelector: \"\",\n properties: undefined,\n children: undefined,\n text: data.toString(),\n domNode: null,\n };\n};\n\nlet appendChildren = (parentSelector: string, insertions: VNodeChild[], main: VNode[]) => {\n for (let i = 0, length = insertions.length; i < length; i++) {\n let item = insertions[i];\n if (Array.isArray(item)) {\n appendChildren(parentSelector, item, main);\n } else {\n if (item !== null && item !== undefined && item !== false) {\n if (typeof item === \"string\") {\n item = toTextVNode(item);\n }\n main.push(item);\n }\n }\n }\n};\n\n/**\n * The `h` function is used to create a virtual DOM node.\n * This function is largely inspired by the mercuryjs and mithril frameworks.\n * The `h` stands for (virtual) hyperscript.\n *\n * @param selector Contains the tagName, id and fixed css classnames in CSS selector format.\n * It is formatted as follows: `tagname.cssclass1.cssclass2#id`.\n * @param properties An object literal containing properties that will be placed on the DOM node.\n * @param children Virtual DOM nodes and strings to add as child nodes.\n * `children` may contain {@link VNode}s, `string`s, nested arrays, `null` and `undefined`.\n * Nested arrays are flattened, `null` and `undefined` are removed.\n *\n * @returns A VNode object, used to render a real DOM later.\n *\n * NOTE: There are {@link http://maquettejs.org/docs/rules.html two basic rules} you should be aware of when updating the virtual DOM.\n */\nexport function h(\n selector: string,\n properties?: VNodeProperties,\n children?: VNodeChild[] | null\n): VNode;\n/**\n * The `h` function is used to create a virtual DOM node.\n * This function is largely inspired by the mercuryjs and mithril frameworks.\n * The `h` stands for (virtual) hyperscript.\n *\n * @param selector Contains the tagName, id and fixed css classnames in CSS selector format.\n * It is formatted as follows: `tagname.cssclass1.cssclass2#id`.\n * @param children Virtual DOM nodes and strings to add as child nodes.\n * `children` may contain {@link VNode}s, `string`s, nested arrays, `null` and `undefined`.\n * Nested arrays are flattened, `null` and `undefined` are removed.\n *\n * @returns A VNode object, used to render a real DOM later.\n *\n * NOTE: There are {@link http://maquettejs.org/docs/rules.html two basic rules} you should be aware of when updating the virtual DOM.\n */\nexport function h(selector: string, children: VNodeChild[]): VNode;\n\nexport function h(\n selector: string,\n properties?: VNodeProperties,\n children?: VNodeChild[] | null\n): VNode {\n if (Array.isArray(properties)) {\n children = properties;\n properties = undefined;\n } else if (\n (properties && (typeof (properties as any) === \"string\" || properties.vnodeSelector)) ||\n (children && (typeof (children as any) === \"string\" || (children as any).vnodeSelector))\n ) {\n throw new Error(\"h called with invalid arguments\");\n }\n let text: string | undefined;\n let flattenedChildren: VNode[] | undefined;\n // Recognize a common special case where there is only a single text node\n if (children && children.length === 1 && typeof children[0] === \"string\") {\n text = children[0];\n } else if (children) {\n flattenedChildren = [];\n appendChildren(selector, children, flattenedChildren);\n if (flattenedChildren.length === 0) {\n flattenedChildren = undefined;\n }\n }\n return {\n vnodeSelector: selector,\n properties: properties,\n children: flattenedChildren,\n text: text === \"\" ? undefined : text,\n domNode: null,\n };\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,16 @@
1
1
  /**
2
2
  * Welcome to the API documentation of the **maquette** library.
3
3
  *
4
- * [[https://maquettejs.org/|To the maquette homepage]]
4
+ * Maquette is a minimalistic virtual DOM library that provides a simple and efficient way to build
5
+ * interactive web applications. To get started, use {@link createProjector} to create a projector
6
+ * that manages the rendering lifecycle, and use the {@link h} function to create virtual DOM nodes.
7
+ *
8
+ * {@link https://maquettejs.org/ | ← Back to the maquette homepage}
9
+ * @module
5
10
  */
6
- export * from "./interfaces";
11
+ export { createCache } from "./cache";
7
12
  export { dom } from "./dom";
8
13
  export { h } from "./h";
9
- export { createProjector } from "./projector";
10
- export { createCache } from "./cache";
14
+ export * from "./interfaces";
11
15
  export { createMapping } from "./mapping";
16
+ export { createProjector } from "./projector";
package/dist/index.js CHANGED
@@ -2,12 +2,17 @@
2
2
  /**
3
3
  * Welcome to the API documentation of the **maquette** library.
4
4
  *
5
- * [[https://maquettejs.org/|To the maquette homepage]]
5
+ * Maquette is a minimalistic virtual DOM library that provides a simple and efficient way to build
6
+ * interactive web applications. To get started, use {@link createProjector} to create a projector
7
+ * that manages the rendering lifecycle, and use the {@link h} function to create virtual DOM nodes.
8
+ *
9
+ * {@link https://maquettejs.org/ | ← Back to the maquette homepage}
10
+ * @module
6
11
  */
7
- export * from "./interfaces";
12
+ export { createCache } from "./cache";
8
13
  export { dom } from "./dom";
9
14
  export { h } from "./h";
10
- export { createProjector } from "./projector";
11
- export { createCache } from "./cache";
15
+ export * from "./interfaces";
12
16
  export { createMapping } from "./mapping";
17
+ export { createProjector } from "./projector";
13
18
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E;;;;GAIG;AACH,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// Comment that is displayed in the API documentation for the maquette module:\n/**\n * Welcome to the API documentation of the **maquette** library.\n *\n * [[https://maquettejs.org/|To the maquette homepage]]\n */\nexport * from \"./interfaces\";\nexport { dom } from \"./dom\";\nexport { h } from \"./h\";\nexport { createProjector } from \"./projector\";\nexport { createCache } from \"./cache\";\nexport { createMapping } from \"./mapping\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E;;;;;;;;;GASG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC","sourcesContent":["// Comment that is displayed in the API documentation for the maquette module:\n/**\n * Welcome to the API documentation of the **maquette** library.\n *\n * Maquette is a minimalistic virtual DOM library that provides a simple and efficient way to build\n * interactive web applications. To get started, use {@link createProjector} to create a projector\n * that manages the rendering lifecycle, and use the {@link h} function to create virtual DOM nodes.\n *\n * {@link https://maquettejs.org/ | ← Back to the maquette homepage}\n * @module\n */\nexport { createCache } from \"./cache\";\nexport { dom } from \"./dom\";\nexport { h } from \"./h\";\nexport * from \"./interfaces\";\nexport { createMapping } from \"./mapping\";\nexport { createProjector } from \"./projector\";\n"]}