octane 0.14.3 → 0.15.0

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.
Files changed (45) hide show
  1. package/dist/cjs/index.cjs +2 -0
  2. package/dist/cjs/internal/universal-children.cjs +30 -0
  3. package/dist/cjs/runtime/block.cjs +2 -2
  4. package/dist/cjs/runtime/component-slots.cjs +22 -1
  5. package/dist/cjs/runtime/deopt.cjs +24 -10
  6. package/dist/cjs/runtime/elements.cjs +5 -1
  7. package/dist/cjs/runtime/hooks.cjs +2 -1
  8. package/dist/cjs/runtime/host-props.cjs +28 -1
  9. package/dist/cjs/runtime.cjs +2 -0
  10. package/dist/cjs/universal-children.cjs +183 -0
  11. package/dist/cjs/version.cjs +1 -1
  12. package/dist/compiler/compile-universal.js +2 -0
  13. package/dist/compiler/compile.js +201 -16
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +2 -0
  16. package/dist/internal/universal-children.d.ts +1 -0
  17. package/dist/internal/universal-children.js +8 -0
  18. package/dist/node/index.js +2 -0
  19. package/dist/node/internal/universal-children.js +8 -0
  20. package/dist/node/runtime/block.js +3 -3
  21. package/dist/node/runtime/component-slots.js +28 -2
  22. package/dist/node/runtime/deopt.js +23 -11
  23. package/dist/node/runtime/elements.js +7 -1
  24. package/dist/node/runtime/hooks.js +2 -1
  25. package/dist/node/runtime/host-props.js +28 -1
  26. package/dist/node/runtime.js +2 -0
  27. package/dist/node/universal-children.js +158 -0
  28. package/dist/node/universal-core.js +15 -0
  29. package/dist/node/version.js +1 -1
  30. package/dist/runtime/block.js +3 -3
  31. package/dist/runtime/component-slots.d.ts +5 -0
  32. package/dist/runtime/component-slots.js +28 -2
  33. package/dist/runtime/deopt.d.ts +4 -0
  34. package/dist/runtime/deopt.js +23 -11
  35. package/dist/runtime/elements.js +7 -1
  36. package/dist/runtime/hooks.js +2 -1
  37. package/dist/runtime/host-props.js +28 -1
  38. package/dist/runtime.d.ts +1 -1
  39. package/dist/runtime.js +2 -0
  40. package/dist/universal-children.d.ts +23 -0
  41. package/dist/universal-children.js +158 -0
  42. package/dist/universal-core.d.ts +5 -0
  43. package/dist/universal-core.js +15 -0
  44. package/dist/version.js +1 -1
  45. package/package.json +12 -1
@@ -88,6 +88,7 @@ __export(index_exports, {
88
88
  compilerOwnsContextProvider: () => import_runtime.compilerOwnsContextProvider,
89
89
  componentSlot: () => import_runtime.componentSlot,
90
90
  componentSlotFromConfig: () => import_runtime.componentSlotFromConfig,
91
+ componentSlotFunction: () => import_runtime.componentSlotFunction,
91
92
  componentSlotLite: () => import_runtime.componentSlotLite,
92
93
  componentSlotVoid: () => import_runtime.componentSlotVoid,
93
94
  createCompiledContext: () => import_runtime.createCompiledContext,
@@ -345,6 +346,7 @@ var import_method_dep = require("./method-dep.cjs");
345
346
  compilerOwnsContextProvider,
346
347
  componentSlot,
347
348
  componentSlotFromConfig,
349
+ componentSlotFunction,
348
350
  componentSlotLite,
349
351
  componentSlotVoid,
350
352
  createCompiledContext,
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var universal_children_exports = {};
20
+ __export(universal_children_exports, {
21
+ createUniversalChildren: () => import_universal_children.createUniversalChildren,
22
+ descriptorChildren: () => import_universal_children.descriptorChildren
23
+ });
24
+ module.exports = __toCommonJS(universal_children_exports);
25
+ var import_universal_children = require("../universal-children.cjs");
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ createUniversalChildren,
29
+ descriptorChildren
30
+ });
@@ -351,7 +351,7 @@ function renderReturnedValue(block, out, reset) {
351
351
  (0, import_profile_probes.withProfileComponentOverride)(
352
352
  d.type,
353
353
  null,
354
- () => (0, import_component_slots.componentSlot)(
354
+ () => (0, import_component_slots.componentSlotFunction)(
355
355
  block,
356
356
  0,
357
357
  domParent,
@@ -366,7 +366,7 @@ function renderReturnedValue(block, out, reset) {
366
366
  )
367
367
  );
368
368
  } else {
369
- (0, import_component_slots.componentSlot)(
369
+ (0, import_component_slots.componentSlotFunction)(
370
370
  block,
371
371
  0,
372
372
  domParent,
@@ -31,6 +31,7 @@ __export(component_slots_exports, {
31
31
  compilerCacheContext: () => compilerCacheContext,
32
32
  compilerOpaqueTag: () => compilerOpaqueTag,
33
33
  componentSlot: () => componentSlot,
34
+ componentSlotFunction: () => componentSlotFunction,
34
35
  componentSlotImpl: () => componentSlotImpl,
35
36
  componentSlotVoid: () => componentSlotVoid,
36
37
  ctxDirectChanged: () => ctxDirectChanged,
@@ -387,6 +388,7 @@ function componentSlot(parentScope, slotKey, domParent, comp, props, invocationS
387
388
  if (!activity && typeof comp !== "function" && typeof comp !== "string") {
388
389
  throw (0, import_elements.invalidElementTypeError)(comp);
389
390
  }
391
+ if (typeof comp === "string" && !import_deopt.DESCRIPTOR_HOST_PROPS) (0, import_deopt.enableHostDescriptors)();
390
392
  const body = activity ? dispatch.body : typeof comp === "string" ? import_deopt.hostStringTagBody : comp;
391
393
  if (activity) {
392
394
  singleRoot = false;
@@ -422,6 +424,25 @@ function componentSlot(parentScope, slotKey, domParent, comp, props, invocationS
422
424
  typeof comp === "string" ? import_signal_owners.RENDERER_INVOCATION_SITE : invocationSite
423
425
  );
424
426
  }
427
+ function componentSlotFunction(parentScope, slotKey, domParent, comp, props, invocationSite, anchor, singleRoot, inherit, key, hasKey) {
428
+ if (typeof comp !== "function") throw (0, import_elements.invalidElementTypeError)(comp);
429
+ componentSlotImpl(
430
+ import_block.renderReturnedValue,
431
+ parentScope,
432
+ slotKey,
433
+ domParent,
434
+ comp,
435
+ comp,
436
+ props,
437
+ props,
438
+ anchor,
439
+ key,
440
+ singleRoot,
441
+ inherit,
442
+ hasKey,
443
+ invocationSite
444
+ );
445
+ }
425
446
  function componentSlotVoid(parentScope, slotKey, domParent, comp, props, invocationSite, anchor, singleRoot, inherit, key, hasKey) {
426
447
  if (typeof comp !== "function") throw (0, import_elements.invalidElementTypeError)(comp);
427
448
  componentSlotImpl(
@@ -1342,7 +1363,6 @@ function hmr(fn) {
1342
1363
  meta.liveBlocks.delete(b);
1343
1364
  continue;
1344
1365
  }
1345
- b.body = wrapper;
1346
1366
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__)
1347
1367
  (0, import_profiling.__profileSchedule)(b, "hmr");
1348
1368
  (0, import_block.resetHmrBlock)(b);
@@ -1385,6 +1405,7 @@ function hmr(fn) {
1385
1405
  compilerCacheContext,
1386
1406
  compilerOpaqueTag,
1387
1407
  componentSlot,
1408
+ componentSlotFunction,
1388
1409
  componentSlotImpl,
1389
1410
  componentSlotVoid,
1390
1411
  ctxDirectChanged,
@@ -20,11 +20,13 @@ var deopt_exports = {};
20
20
  __export(deopt_exports, {
21
21
  DEOPT_DESC: () => DEOPT_DESC,
22
22
  DEOPT_REFS_STAMPED: () => DEOPT_REFS_STAMPED,
23
+ DESCRIPTOR_HOST_PROPS: () => DESCRIPTOR_HOST_PROPS,
23
24
  POSITIONAL_CHILDREN: () => POSITIONAL_CHILDREN,
24
25
  adoptsPureHost: () => adoptsPureHost,
25
26
  deoptItemBody: () => deoptItemBody,
26
27
  descNeedsBlocks: () => descNeedsBlocks,
27
28
  enableDescriptorFragmentRefs: () => enableDescriptorFragmentRefs,
29
+ enableHostDescriptors: () => enableHostDescriptors,
28
30
  getDeoptDesc: () => getDeoptDesc,
29
31
  hostComponent: () => hostComponent,
30
32
  hostElementBody: () => hostElementBody,
@@ -77,6 +79,10 @@ var import_templates = require("./templates.cjs");
77
79
  var import_events = require("./events.cjs");
78
80
  var import_forms = require("./forms.cjs");
79
81
  const __octaneDev = process.env.NODE_ENV !== "production";
82
+ let DESCRIPTOR_HOST_PROPS = null;
83
+ function enableHostDescriptors() {
84
+ DESCRIPTOR_HOST_PROPS = import_host_props.setHostProps;
85
+ }
80
86
  const DEOPT_KEY_WARNED_BLOCKS = /* @__PURE__ */ new WeakSet();
81
87
  let DEOPT_KEY_WARNED_WITHOUT_BLOCK = false;
82
88
  function warnMissingListKey(owner) {
@@ -553,7 +559,13 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
553
559
  pending = pendingDeoptOrder(el);
554
560
  desc = changedDeoptRecord(el, value, pending);
555
561
  } else {
556
- (0, import_host_props.setHostProps)(el, value.props, getDeoptDesc(el)?.props ?? null, ownerBlock, import_host_props.DESCRIPTOR_HOST);
562
+ DESCRIPTOR_HOST_PROPS(
563
+ el,
564
+ value.props,
565
+ getDeoptDesc(el)?.props ?? null,
566
+ ownerBlock,
567
+ import_host_props.DESCRIPTOR_HOST
568
+ );
557
569
  if (import_hydration_flag.hydrating && import_hydration.CURSOR !== null && import_render.ROOT_RENDER_TRANSACTION !== null) {
558
570
  defer = true;
559
571
  desc = deoptRecord(el, value);
@@ -565,7 +577,7 @@ function reconcileDeoptNode(prev, value, ownerBlock, ns) {
565
577
  if (hydration !== null)
566
578
  return hydration.suspend(() => reconcileDeoptNode(null, value, ownerBlock, ns));
567
579
  el = elNs !== void 0 ? document.createElementNS(elNs, value.type) : document.createElement(value.type);
568
- (0, import_host_props.setHostProps)(el, value.props, void 0, ownerBlock, import_host_props.DESCRIPTOR_HOST);
580
+ DESCRIPTOR_HOST_PROPS(el, value.props, void 0, ownerBlock, import_host_props.DESCRIPTOR_HOST);
569
581
  }
570
582
  if (desc === null) setDeoptDesc(el, value);
571
583
  const nodes = hasHostPropContent(value) ? null : reconcileDeoptChildren(
@@ -789,7 +801,7 @@ function applyDeoptOrder(order) {
789
801
  }
790
802
  function commitDeoptHost(el, record, owner) {
791
803
  const committed = el[DEOPT_DESC];
792
- (0, import_host_props.setHostProps)(el, record.props, committed?.props ?? null, owner, import_host_props.DESCRIPTOR_HOST);
804
+ DESCRIPTOR_HOST_PROPS(el, record.props, committed?.props ?? null, owner, import_host_props.DESCRIPTOR_HOST);
793
805
  stampDeoptDesc(el, record);
794
806
  }
795
807
  function placeDeoptChildren(el, result, skip, adopt) {
@@ -998,7 +1010,7 @@ function mappedDeoptItemBody(item, scope) {
998
1010
  }
999
1011
  }
1000
1012
  try {
1001
- (0, import_component_slots.componentSlot)(
1013
+ (0, import_component_slots.componentSlotFunction)(
1002
1014
  scope,
1003
1015
  0,
1004
1016
  parent,
@@ -1102,7 +1114,7 @@ function hostElementBody(d, block) {
1102
1114
  if (el === null && hydration !== null && hydration.node !== null && hydration.node.nodeType === 1 && (0, import_host_props.isHostElementOfType)(hydration.node, d.type) && (elNs === void 0 || hydration.node.namespaceURI === elNs)) {
1103
1115
  el = hydration.node;
1104
1116
  block.deoptNode = el;
1105
- (0, import_host_props.setHostProps)(el, d.props, void 0, block, import_host_props.DESCRIPTOR_HOST);
1117
+ DESCRIPTOR_HOST_PROPS(el, d.props, void 0, block, import_host_props.DESCRIPTOR_HOST);
1106
1118
  setDeoptDesc(el, d);
1107
1119
  const savedCursor = (0, import_templates.getNextSibling)(hydration.node);
1108
1120
  if (!hasHostPropContent(d)) {
@@ -1148,11 +1160,11 @@ function hostElementBody(d, block) {
1148
1160
  const frag = (0, import_commit.queueFrontier)(block, parent, block.endMarker);
1149
1161
  frag.appendChild(el);
1150
1162
  } else parent.insertBefore(el, block.endMarker);
1151
- (0, import_host_props.setHostProps)(el, d.props, void 0, block, import_host_props.DESCRIPTOR_HOST);
1163
+ DESCRIPTOR_HOST_PROPS(el, d.props, void 0, block, import_host_props.DESCRIPTOR_HOST);
1152
1164
  } else if ((0, import_commit.usesFrontier)(block, el)) {
1153
1165
  desc = changedDeoptRecord(el, d, pendingDeoptOrder(el));
1154
1166
  } else {
1155
- (0, import_host_props.setHostProps)(el, d.props, getDeoptDesc(el)?.props ?? null, block, import_host_props.DESCRIPTOR_HOST);
1167
+ DESCRIPTOR_HOST_PROPS(el, d.props, getDeoptDesc(el)?.props ?? null, block, import_host_props.DESCRIPTOR_HOST);
1156
1168
  }
1157
1169
  if (desc === null) setDeoptDesc(el, d);
1158
1170
  if (!hasHostPropContent(d)) deoptHostChildren(block, el, d, elNs);
@@ -1169,7 +1181,7 @@ function hostStringTagBody(d, block) {
1169
1181
  if (hydration !== null && hydration.node !== null && hydration.node.nodeType === 1 && (0, import_host_props.isHostElementOfType)(hydration.node, tag) && (elNs === void 0 || hydration.node.namespaceURI === elNs)) {
1170
1182
  el = hydration.node;
1171
1183
  block.deoptNode = el;
1172
- (0, import_host_props.setHostProps)(el, d.props, void 0, block, import_host_props.DESCRIPTOR_HOST);
1184
+ DESCRIPTOR_HOST_PROPS(el, d.props, void 0, block, import_host_props.DESCRIPTOR_HOST);
1173
1185
  setDeoptDesc(el, d);
1174
1186
  const savedCursor = (0, import_templates.getNextSibling)(hydration.node);
1175
1187
  if (!hasHostPropContent(d)) {
@@ -1190,11 +1202,11 @@ function hostStringTagBody(d, block) {
1190
1202
  block.deoptNode = el;
1191
1203
  const parent = block.parentNode;
1192
1204
  parent.insertBefore(el, block.endMarker);
1193
- (0, import_host_props.setHostProps)(el, d.props, void 0, block, import_host_props.DESCRIPTOR_HOST);
1205
+ DESCRIPTOR_HOST_PROPS(el, d.props, void 0, block, import_host_props.DESCRIPTOR_HOST);
1194
1206
  } else if ((0, import_commit.usesFrontier)(block, el)) {
1195
1207
  desc = changedDeoptRecord(el, d, pendingDeoptOrder(el));
1196
1208
  } else {
1197
- (0, import_host_props.setHostProps)(el, d.props, getDeoptDesc(el)?.props ?? null, block, import_host_props.DESCRIPTOR_HOST);
1209
+ DESCRIPTOR_HOST_PROPS(el, d.props, getDeoptDesc(el)?.props ?? null, block, import_host_props.DESCRIPTOR_HOST);
1198
1210
  }
1199
1211
  if (desc === null) setDeoptDesc(el, d);
1200
1212
  if (!hasHostPropContent(d)) renderHostTagChildren(d, block, el);
@@ -1576,11 +1588,13 @@ function renderPreparedChildList(state, parentBlock, domParent, preparedList, hy
1576
1588
  0 && (module.exports = {
1577
1589
  DEOPT_DESC,
1578
1590
  DEOPT_REFS_STAMPED,
1591
+ DESCRIPTOR_HOST_PROPS,
1579
1592
  POSITIONAL_CHILDREN,
1580
1593
  adoptsPureHost,
1581
1594
  deoptItemBody,
1582
1595
  descNeedsBlocks,
1583
1596
  enableDescriptorFragmentRefs,
1597
+ enableHostDescriptors,
1584
1598
  getDeoptDesc,
1585
1599
  hostComponent,
1586
1600
  hostElementBody,
@@ -172,6 +172,7 @@ function copyScopedElementConfig(type, config, resolve) {
172
172
  return props;
173
173
  }
174
174
  function scopedElementRecord(type, props, key, ref, resolve, invocationSite) {
175
+ if (typeof type === "string" && !import_deopt.DESCRIPTOR_HOST_PROPS) (0, import_deopt.enableHostDescriptors)();
175
176
  const descriptor = { $$kind: import_runtime_tags.ELEMENT_TAG, type, props, key, ref };
176
177
  if (invocationSite !== void 0) descriptor.__octaneInvocationSite = invocationSite;
177
178
  Object.defineProperty(descriptor, SCOPED_CHILDREN_RESOLVER, { value: resolve });
@@ -288,6 +289,7 @@ function createElement(type, props, ...children) {
288
289
  function enableDescriptorCapabilities() {
289
290
  (0, import_host_props.enableDescriptorFormActions)();
290
291
  (0, import_deopt.enableDescriptorFragmentRefs)();
292
+ (0, import_deopt.enableHostDescriptors)();
291
293
  }
292
294
  function createHostElement(type, props, ...children) {
293
295
  return createElementFromConfig(void 0, type, props, children);
@@ -322,7 +324,9 @@ function renderFragmentConfig(props) {
322
324
  return props.children;
323
325
  }
324
326
  function createElementFromConfig(invocationSite, type, props, children = import_events.EMPTY_ARGS) {
325
- if (typeof type === "function" && (0, import_renderer_bridge.isRendererContext)(type)) {
327
+ if (typeof type === "string") {
328
+ if (!import_deopt.DESCRIPTOR_HOST_PROPS) (0, import_deopt.enableHostDescriptors)();
329
+ } else if (typeof type === "function" && (0, import_renderer_bridge.isRendererContext)(type)) {
326
330
  (0, import_renderer_bridge.registerClientRendererBridge)(import_context.renderClientContextProvider, import_engine.flushSync);
327
331
  }
328
332
  const src = props ?? null;
@@ -104,7 +104,8 @@ function ensureHooks(scope) {
104
104
  }
105
105
  function registerHookCleanup(scope, cleanup) {
106
106
  if (__octaneDev) {
107
- if (scope.block.body?.[import_component_slots.HMR] !== void 0) {
107
+ const body = scope.block.body;
108
+ if (body?.[import_component_slots.HMR] !== void 0 || body?.type?.[import_component_slots.HMR] !== void 0) {
108
109
  cleanup[import_component_slots.HMR] = true;
109
110
  }
110
111
  }
@@ -1156,6 +1156,32 @@ let SKIP_SPREAD_KEY = null;
1156
1156
  function skipSpreadKey(el, k, flags) {
1157
1157
  return (flags & SKIP_RAW_HTML) !== 0 && k === "dangerouslySetInnerHTML" || (flags & SKIP_FORM_CONTROLS) !== 0 && isAggregatedFormControlProp(el, k);
1158
1158
  }
1159
+ const SPREAD_CLASS_VALUES = /* @__PURE__ */ new WeakMap();
1160
+ function previousSpreadClass(value) {
1161
+ if (value == null || value === false) return null;
1162
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
1163
+ return (0, import_css.normalizeClass)(value);
1164
+ if (typeof value === "object" && value !== null || typeof value === "function")
1165
+ return SPREAD_CLASS_VALUES.get(value);
1166
+ return void 0;
1167
+ }
1168
+ function setHostPropClassAttr(el, value, prevValue) {
1169
+ const prevCls = previousSpreadClass(prevValue);
1170
+ const cls = value == null || value === false ? null : (0, import_css.normalizeClass)(value);
1171
+ if (typeof value === "object" && value !== null || typeof value === "function")
1172
+ SPREAD_CLASS_VALUES.set(value, cls);
1173
+ if (import_hydration_flag.hydrating && import_hydration.CURSOR !== null) {
1174
+ import_hydration.CURSOR.adopts(el);
1175
+ if (__octaneDev) (0, import_dev_values.unpatchedClass)(import_hydration.CURSOR, el, cls, false);
1176
+ return;
1177
+ }
1178
+ if (import_render.TRANSITION_JOURNAL !== null) (0, import_commit.journalBag)();
1179
+ if (import_render.ROOT_RENDER_TRANSACTION === null || (0, import_signal_bindings.pendingWrites)(import_render.CURRENT_BLOCK) === null) {
1180
+ if (prevCls !== void 0 && prevCls === cls && el.getAttribute("class") === cls) return;
1181
+ }
1182
+ if (cls === null) el.removeAttribute("class");
1183
+ else el.setAttribute("class", cls);
1184
+ }
1159
1185
  function setHostProps(el, value, prev, mountScope, flags) {
1160
1186
  const descriptor = (flags & DESCRIPTOR_HOST) !== 0;
1161
1187
  let needsCheckedInitialization = descriptor && prev === void 0 && el.localName === "input";
@@ -1213,7 +1239,8 @@ function setHostProps(el, value, prev, mountScope, flags) {
1213
1239
  continue;
1214
1240
  if (k === "class" || k === "className") {
1215
1241
  if (v === pv && !initialHydration) continue;
1216
- setClassAttr(el, v);
1242
+ if (descriptor) setClassAttr(el, v);
1243
+ else setHostPropClassAttr(el, v, pv);
1217
1244
  continue;
1218
1245
  }
1219
1246
  if (k === "style") {
@@ -112,6 +112,7 @@ __export(runtime_exports, {
112
112
  compilerOwnsContextProvider: () => import_context.compilerOwnsContextProvider,
113
113
  componentSlot: () => import_component_slots.componentSlot,
114
114
  componentSlotFromConfig: () => import_elements.componentSlotFromConfig,
115
+ componentSlotFunction: () => import_component_slots.componentSlotFunction,
115
116
  componentSlotLite: () => import_render.componentSlotLite,
116
117
  componentSlotVoid: () => import_component_slots.componentSlotVoid,
117
118
  createCompiledContext: () => import_context.createCompiledContext,
@@ -547,6 +548,7 @@ var import_css2 = require("./css.cjs");
547
548
  compilerOwnsContextProvider,
548
549
  componentSlot,
549
550
  componentSlotFromConfig,
551
+ componentSlotFunction,
550
552
  componentSlotLite,
551
553
  componentSlotVoid,
552
554
  createCompiledContext,
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var universal_children_exports = {};
20
+ __export(universal_children_exports, {
21
+ createUniversalChildren: () => createUniversalChildren,
22
+ descriptorChildren: () => descriptorChildren
23
+ });
24
+ module.exports = __toCommonJS(universal_children_exports);
25
+ const UNIVERSAL_VALUE = /* @__PURE__ */ Symbol.for("octane.universal.value");
26
+ const UNIVERSAL_LIST = /* @__PURE__ */ Symbol.for("octane.universal.list");
27
+ const UNIVERSAL_CHILDREN = /* @__PURE__ */ Symbol.for("octane.universal.children");
28
+ const UNIVERSAL_KEYED = /* @__PURE__ */ Symbol.for("octane.universal.keyed");
29
+ const UNIVERSAL_COMPONENT_VALUE = /* @__PURE__ */ Symbol.for("octane.universal.component-value");
30
+ function renderableKey(value) {
31
+ if (value?.$$kind === UNIVERSAL_VALUE) {
32
+ return value.key;
33
+ }
34
+ if (value?.$$kind === UNIVERSAL_KEYED) {
35
+ return value.key;
36
+ }
37
+ if (value?.$$kind === UNIVERSAL_COMPONENT_VALUE) {
38
+ const component = value;
39
+ return component.hasKey ? component.key : null;
40
+ }
41
+ return null;
42
+ }
43
+ function normalizeUniversalKey(value) {
44
+ if (value == null) return null;
45
+ if (typeof value === "string" || typeof value === "number" || typeof value === "symbol" || typeof value === "bigint") {
46
+ return value;
47
+ }
48
+ throw new TypeError(`Universal keys must be strings, numbers, symbols, or bigints.`);
49
+ }
50
+ const CHILD_KEY_SYMBOL_IDS = /* @__PURE__ */ new Map();
51
+ function encodeChildKeySegment(segment) {
52
+ if (typeof segment === "string") return JSON.stringify(segment);
53
+ if (typeof segment === "bigint") return `${segment}n`;
54
+ if (typeof segment === "symbol") {
55
+ let id = CHILD_KEY_SYMBOL_IDS.get(segment);
56
+ if (id === void 0) CHILD_KEY_SYMBOL_IDS.set(segment, id = CHILD_KEY_SYMBOL_IDS.size);
57
+ return `@${id}`;
58
+ }
59
+ return String(segment);
60
+ }
61
+ function encodeChildKey(path) {
62
+ return path.map(encodeChildKeySegment).join(",");
63
+ }
64
+ function createUniversalChildren(runtime) {
65
+ const { universalKey, universalPlan, universalValue, normalizeProps, checkRenderer } = runtime;
66
+ const NORMALIZED_CHILD_KEYS = /* @__PURE__ */ new WeakMap();
67
+ function universalChildEntries(children) {
68
+ const out = [];
69
+ const collectionKey = (child) => {
70
+ const key = renderableKey(child);
71
+ if (key !== null) return key;
72
+ if (child?.$$kind !== UNIVERSAL_VALUE) return null;
73
+ const { plan, values } = child;
74
+ let node = plan.root;
75
+ if (node.kind === "slot") return collectionKey(values[node.slot]);
76
+ if (node.kind !== "host" && node.kind !== "component") return null;
77
+ if (node.kind === "component" && node.keySlot !== void 0)
78
+ return normalizeUniversalKey(values[node.keySlot]);
79
+ return normalizeUniversalKey(
80
+ node.propsSlot === void 0 ? node.kind === "host" ? node.props?.["key"] : null : normalizeProps(values[node.propsSlot]).key
81
+ );
82
+ };
83
+ const visit = (child, path) => {
84
+ if (child == null || typeof child === "boolean") return;
85
+ if (typeof child === "object") {
86
+ const normalizedKey = NORMALIZED_CHILD_KEYS.get(child);
87
+ if (normalizedKey !== void 0) {
88
+ out.push({ child, key: normalizedKey });
89
+ return;
90
+ }
91
+ }
92
+ if (Array.isArray(child)) {
93
+ child.forEach((item, index) => {
94
+ const key2 = collectionKey(item);
95
+ visit(item, [...path, key2 === null ? "index" : "key", key2 ?? index]);
96
+ });
97
+ return;
98
+ }
99
+ if (child?.$$kind === UNIVERSAL_CHILDREN) {
100
+ const children2 = child;
101
+ checkRenderer(children2.renderer);
102
+ visit(children2.render(), path);
103
+ return;
104
+ }
105
+ if (child?.$$kind === UNIVERSAL_LIST) {
106
+ const list = child;
107
+ visit(list.values.length === 0 ? list.empty : list.values, path);
108
+ return;
109
+ }
110
+ if (child?.$$kind === UNIVERSAL_VALUE) {
111
+ const value = child;
112
+ checkRenderer(value.plan.renderer);
113
+ if (value.key !== null) {
114
+ out.push({ child, key: encodeChildKey([...path, "key", value.key]) });
115
+ return;
116
+ }
117
+ const visitNode = (node, nodePath) => {
118
+ if (node.kind === "range") {
119
+ node.children.forEach((item, index) => visitNode(item, [...nodePath, index]));
120
+ } else if (node.kind === "slot") {
121
+ visit(value.values[node.slot], nodePath);
122
+ } else if (node.kind === "text") {
123
+ visit(
124
+ node.slot === void 0 ? node.value : value.values[node.slot],
125
+ nodePath
126
+ );
127
+ } else {
128
+ const key2 = node.kind === "component" ? node.keySlot === void 0 ? node.propsSlot === void 0 ? null : normalizeProps(value.values[node.propsSlot]).key : value.values[node.keySlot] : node.kind === "host" ? node.propsSlot === void 0 ? node.props?.["key"] ?? null : normalizeProps(value.values[node.propsSlot]).key : null;
129
+ const item = universalValue(universalPlan(value.plan.renderer, node), value.values);
130
+ out.push({
131
+ child: item,
132
+ key: encodeChildKey(
133
+ key2 == null ? nodePath : [...node === value.plan.root ? path : nodePath.slice(0, -1), "key", key2]
134
+ )
135
+ });
136
+ }
137
+ };
138
+ visitNode(value.plan.root, path);
139
+ return;
140
+ }
141
+ const key = renderableKey(child);
142
+ out.push({ child, key: encodeChildKey(key === null ? path : [...path, "key", key]) });
143
+ };
144
+ visit(children, []);
145
+ return out;
146
+ }
147
+ function normalizedChild(key, child) {
148
+ const value = universalKey(key, child);
149
+ if (typeof value === "object" && value !== null) NORMALIZED_CHILD_KEYS.set(value, key);
150
+ return value;
151
+ }
152
+ return {
153
+ toArray(children) {
154
+ return universalChildEntries(children).map(
155
+ ({ child, key }) => typeof child === "object" && child !== null ? normalizedChild(key, child) : child
156
+ );
157
+ },
158
+ map(children, fn) {
159
+ if (children == null) return children;
160
+ const out = [];
161
+ universalChildEntries(children).forEach(({ child, key }, index) => {
162
+ const mapped = fn(child, index);
163
+ if (mapped == null || typeof mapped === "boolean") return;
164
+ if (Array.isArray(mapped)) {
165
+ for (const entry of universalChildEntries(mapped)) {
166
+ out.push(normalizedChild(encodeChildKey([key, entry.key]), entry.child));
167
+ }
168
+ } else {
169
+ out.push(normalizedChild(key, mapped));
170
+ }
171
+ });
172
+ return out;
173
+ }
174
+ };
175
+ }
176
+ function descriptorChildren(component) {
177
+ return component;
178
+ }
179
+ // Annotate the CommonJS export names for ESM import in node:
180
+ 0 && (module.exports = {
181
+ createUniversalChildren,
182
+ descriptorChildren
183
+ });
@@ -21,7 +21,7 @@ __export(version_exports, {
21
21
  version: () => version
22
22
  });
23
23
  module.exports = __toCommonJS(version_exports);
24
- const version = "0.14.3";
24
+ const version = "0.15.0";
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  version
@@ -242,6 +242,8 @@ const THREE_BUILTIN_CONSTRUCTORS = new Set([
242
242
 
243
243
  const UNIVERSAL_RUNTIME_IMPORTS = new Set([
244
244
  'Activity',
245
+ 'Children',
246
+ 'descriptorChildren',
245
247
  'createContext',
246
248
  'createPortal',
247
249
  'lazy',