@cajoa/core 1.2.0 → 1.2.1

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/index.cjs CHANGED
@@ -514,7 +514,11 @@ function toNodes(value) {
514
514
  for (const v of [value].flat(Infinity)) {
515
515
  if (v == null || typeof v === "boolean") continue;
516
516
  if (typeof v === "function") {
517
- out.push(materialize(v));
517
+ const holder = r.createHolder ? r.createHolder() : r.createFragment();
518
+ appendChildren(holder, [v]);
519
+ const parts = r.unwrap?.(holder);
520
+ if (parts) out.push(...parts);
521
+ else out.push(holder);
518
522
  continue;
519
523
  }
520
524
  out.push(r.isNode(v) ? v : r.createText(String(v)));
package/dist/index.d.cts CHANGED
@@ -96,6 +96,16 @@ interface Renderer<N = any> {
96
96
  nextSibling(node: N): N | null;
97
97
  parentNode(node: N): N | null;
98
98
  portalRoot?(): N;
99
+ /**
100
+ * Experimental. Used by hydrate(). Like createFragment(), for the nodes of a block that a function
101
+ * returns, which are put in the page right away.
102
+ */
103
+ createHolder?(): N;
104
+ /**
105
+ * Experimental. Used by hydrate(), right after the nodes of a block were put in a holder. When they
106
+ * are already in the page, this returns them, so that they do not have to be moved.
107
+ */
108
+ unwrap?(holder: N): N[] | undefined;
99
109
  clear(parent: N): void;
100
110
  setProp(el: N, name: string, value: unknown): void;
101
111
  isServer?: boolean;
package/dist/index.d.ts CHANGED
@@ -96,6 +96,16 @@ interface Renderer<N = any> {
96
96
  nextSibling(node: N): N | null;
97
97
  parentNode(node: N): N | null;
98
98
  portalRoot?(): N;
99
+ /**
100
+ * Experimental. Used by hydrate(). Like createFragment(), for the nodes of a block that a function
101
+ * returns, which are put in the page right away.
102
+ */
103
+ createHolder?(): N;
104
+ /**
105
+ * Experimental. Used by hydrate(), right after the nodes of a block were put in a holder. When they
106
+ * are already in the page, this returns them, so that they do not have to be moved.
107
+ */
108
+ unwrap?(holder: N): N[] | undefined;
99
109
  clear(parent: N): void;
100
110
  setProp(el: N, name: string, value: unknown): void;
101
111
  isServer?: boolean;
package/dist/index.js CHANGED
@@ -452,7 +452,11 @@ function toNodes(value) {
452
452
  for (const v of [value].flat(Infinity)) {
453
453
  if (v == null || typeof v === "boolean") continue;
454
454
  if (typeof v === "function") {
455
- out.push(materialize(v));
455
+ const holder = r.createHolder ? r.createHolder() : r.createFragment();
456
+ appendChildren(holder, [v]);
457
+ const parts = r.unwrap?.(holder);
458
+ if (parts) out.push(...parts);
459
+ else out.push(holder);
456
460
  continue;
457
461
  }
458
462
  out.push(r.isNode(v) ? v : r.createText(String(v)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cajoa/core",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Cajoa core: signals, JSX runtime and the renderer interface.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",