octane 0.2.15 → 0.2.16

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 (36) hide show
  1. package/dist/cjs/method-dep.cjs +15 -1
  2. package/dist/cjs/runtime.cjs +52 -19
  3. package/dist/cjs/signals/graph.cjs +2 -0
  4. package/dist/cjs/signals/transition-action.cjs +508 -0
  5. package/dist/cjs/signals/transition-candidate.cjs +26 -482
  6. package/dist/cjs/signals/transition-state.cjs +8 -0
  7. package/dist/cjs/stream-protocol.cjs +29 -0
  8. package/dist/cjs/version.cjs +1 -1
  9. package/dist/compiler/compile-universal.js +1 -1
  10. package/dist/compiler/compile.js +229 -54
  11. package/dist/compiler/dom-binding-program.js +4 -1
  12. package/dist/compiler/dom-bindings.js +26 -4
  13. package/dist/compiler/hook-deps.js +118 -12
  14. package/dist/compiler/hydrate-boundaries.js +141 -40
  15. package/dist/compiler/plain-hook-memo.js +1 -0
  16. package/dist/compiler/slot-hooks.js +1 -1
  17. package/dist/dom-binding-program.d.ts +8 -0
  18. package/dist/dom-binding-program.js +9 -3
  19. package/dist/hydration/independent-island.js +4 -2
  20. package/dist/hydration/index.d.ts +1 -0
  21. package/dist/hydration/index.js +2 -0
  22. package/dist/method-dep.d.ts +1 -1
  23. package/dist/method-dep.js +15 -1
  24. package/dist/runtime.d.ts +4 -4
  25. package/dist/runtime.js +54 -20
  26. package/dist/signals/graph.js +3 -0
  27. package/dist/signals/transition-action.d.ts +98 -0
  28. package/dist/signals/transition-action.js +497 -0
  29. package/dist/signals/transition-candidate.d.ts +5 -71
  30. package/dist/signals/transition-candidate.js +27 -495
  31. package/dist/signals/transition-state.d.ts +11 -9
  32. package/dist/signals/transition-state.js +6 -0
  33. package/dist/stream-protocol.d.ts +9 -0
  34. package/dist/stream-protocol.js +28 -0
  35. package/dist/version.js +1 -1
  36. package/package.json +1 -1
@@ -22,10 +22,24 @@ __export(method_dep_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(method_dep_exports);
24
24
  var import_has_own = require("./has-own.cjs");
25
- function __methodDep(receiver, name) {
25
+ const guardedNullReceiver = /* @__PURE__ */ Symbol();
26
+ const guardedUndefinedReceiver = /* @__PURE__ */ Symbol();
27
+ function __methodDep(receiver, name, guarded = false) {
28
+ if (guarded && receiver == null) {
29
+ return receiver === null ? guardedNullReceiver : guardedUndefinedReceiver;
30
+ }
26
31
  if ((typeof receiver !== "object" || receiver === null) && typeof receiver !== "function") {
27
32
  return receiver;
28
33
  }
34
+ if (guarded) {
35
+ try {
36
+ const descriptor = Object.getOwnPropertyDescriptor(receiver, name);
37
+ if (descriptor) return "value" in descriptor ? descriptor.value : receiver;
38
+ return name in receiver ? receiver : void 0;
39
+ } catch {
40
+ return receiver;
41
+ }
42
+ }
29
43
  if (import_has_own.hasOwnProp.call(receiver, name)) return receiver[name];
30
44
  return name in receiver ? receiver : void 0;
31
45
  }
@@ -840,6 +840,7 @@ function scheduleNativeRead(target) {
840
840
  }
841
841
  function ensureNativeReadDriver() {
842
842
  if (NATIVE_READ_DRIVER !== null) return NATIVE_READ_DRIVER;
843
+ (0, import_transition_candidate.installNativeSignalActionExtension)();
843
844
  NATIVE_READ_DRIVER = (0, import_native_read_client.createNativeReadDriver)({
844
845
  capture: () => WIP_CAPTURE,
845
846
  cleanup: registerHookCleanup,
@@ -1457,7 +1458,7 @@ function nativeCandidateForAction(batch) {
1457
1458
  candidate = void 0;
1458
1459
  }
1459
1460
  }
1460
- return candidate ?? (batch.native = new import_transition_candidate.SignalCandidateFrame());
1461
+ return candidate ?? (batch.native = (0, import_transition_state.createSignalActionFrame)?.());
1461
1462
  }
1462
1463
  function ensureNativeActionResolver() {
1463
1464
  if (nativeActionResolverInstalled) return;
@@ -12457,7 +12458,8 @@ function presentationWrite(writer, kind, ...args) {
12457
12458
  const keys = kind === "nativeProjectionBinding" ? args[4].map((field) => field === "className" ? "class" : field) : kind === "setStyleProperties" ? args[1].filter((_, index) => index % 2 === 0).map((key2) => "style:" + key2) : [
12458
12459
  kind === "nativeStyleBinding" || kind === "setStyle" ? "style" : kind === "setStyleProperty" ? "style:" + args[1] : kind.includes("Class") ? "class" : kind === "bindSignalAttribute" ? args[3] : args[changed2 ? 3 : 1]
12459
12460
  ];
12460
- if (element2 !== frame.lease.root || keys.some((key2) => !channels.has(key2)) || kind === "bindSignalValue" || kind === "setEventHandler" || kind === "bindSignalText" || kind === "setText" || kind === "markDangerouslySetInnerHTMLChildren")
12461
+ if (element2 !== frame.lease.root || // Preserve authored names for diagnostics; receipts use native field names.
12462
+ keys.some((key2) => !channels.has(import_constants.ATTRIBUTE_ALIASES.get(key2) ?? key2)) || kind === "bindSignalValue" || kind === "setEventHandler" || kind === "bindSignalText" || kind === "setText" || kind === "markDangerouslySetInnerHTMLChildren")
12461
12463
  presentationMiss(false);
12462
12464
  }
12463
12465
  if (kind === "queueNativeChangeDiagnostic") {
@@ -12768,8 +12770,9 @@ function writeDirectSignalBinding(binding, value) {
12768
12770
  }
12769
12771
  } else if (binding.kind === "value") {
12770
12772
  const element = binding.target;
12771
- if (element.localName === "select") setSelectValue(element, value);
12772
- else setValue(element, value);
12773
+ const tag = element.localName;
12774
+ if (tag === "select") setSelectValue(element, value);
12775
+ else setValue(element, value, tag === "textarea" && isWritableSignal(binding.handle));
12773
12776
  } else {
12774
12777
  setChecked(binding.target, value);
12775
12778
  }
@@ -14514,7 +14517,7 @@ function resolveHostPropSources(el, sources, props, readStyle) {
14514
14517
  if (readStyle !== void 0 && "style" in resolved) resolved.style = readStyle(resolved.style);
14515
14518
  return resolved;
14516
14519
  }
14517
- function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false, readStyle, deferControl = false) {
14520
+ function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false, readStyle, deferControl = false, writableTextareaValue = false) {
14518
14521
  const props = /* @__PURE__ */ new Map();
14519
14522
  const resolved = resolveHostPropSources(el, sources, props, readStyle);
14520
14523
  const tag = el.localName;
@@ -14529,7 +14532,8 @@ function setHostPropSources(el, sources, prev, scope, hasNestedChildren = false,
14529
14532
  props.get("defaultValue")?.value,
14530
14533
  props.get("checked")?.value,
14531
14534
  props.get("defaultChecked")?.value,
14532
- props.get("multiple")?.value
14535
+ props.get("multiple")?.value,
14536
+ writableTextareaValue
14533
14537
  );
14534
14538
  return resolved;
14535
14539
  }
@@ -14550,12 +14554,14 @@ function resolveSignalStyle(value, handles, read) {
14550
14554
  }
14551
14555
  return copy ?? value;
14552
14556
  }
14553
- function resolveSignalHostPropSources(sources, readStyle, read = readSignalBinding) {
14557
+ function resolveSignalHostPropSources(sources, readStyle, read = readSignalBinding, textarea = false) {
14554
14558
  const handles = /* @__PURE__ */ new Set();
14555
14559
  let rows;
14560
+ let writableTextareaValue = false;
14556
14561
  for (let i = 0; i < sources.length; i++) {
14557
14562
  const source = sources[i];
14558
14563
  if (!source[0]) {
14564
+ if (textarea && source[1] === "value") writableTextareaValue = isWritableSignal(source[2]);
14559
14565
  const value = source[1] === "children" || source[1] === "style" && readStyle !== void 0 ? source[2] : source[1] === "style" ? resolveSignalStyle(source[2], handles, read) : isSignalHandle(source[2]) ? (handles.add(source[2]), read(source[2])) : source[2];
14560
14566
  if (value !== source[2]) {
14561
14567
  rows ??= sources.slice();
@@ -14568,6 +14574,7 @@ function resolveSignalHostPropSources(sources, readStyle, read = readSignalBindi
14568
14574
  let copy;
14569
14575
  for (const name of Object.keys(spread)) {
14570
14576
  const current = spread[name];
14577
+ if (textarea && name === "value") writableTextareaValue = isWritableSignal(current);
14571
14578
  const value = name === "children" || name === "style" && readStyle !== void 0 ? current : name === "style" ? resolveSignalStyle(current, handles, read) : isSignalHandle(current) ? (handles.add(current), read(current)) : current;
14572
14579
  if (value !== current) {
14573
14580
  copy ??= { ...spread };
@@ -14579,7 +14586,7 @@ function resolveSignalHostPropSources(sources, readStyle, read = readSignalBindi
14579
14586
  rows[i] = [true, copy];
14580
14587
  }
14581
14588
  }
14582
- return { sources: rows ?? sources, handles };
14589
+ return textarea ? { sources: rows ?? sources, handles, writableTextareaValue } : { sources: rows ?? sources, handles };
14583
14590
  }
14584
14591
  function winningSignalHostControl(sources, name) {
14585
14592
  let winner;
@@ -14599,14 +14606,21 @@ function updateSignalHostPropSources(binding) {
14599
14606
  if (binding.disposed || binding.pendingControl || binding.scope.block.disposed) return;
14600
14607
  try {
14601
14608
  runWithBlockSignalOwner(binding.scope, () => {
14602
- const next = resolveSignalHostPropSources(binding.sources, binding.readStyle);
14609
+ const next = resolveSignalHostPropSources(
14610
+ binding.sources,
14611
+ binding.readStyle,
14612
+ void 0,
14613
+ binding.element.localName === "textarea"
14614
+ );
14603
14615
  binding.resolved = setHostPropSources(
14604
14616
  binding.element,
14605
14617
  next.sources,
14606
14618
  binding.resolved,
14607
14619
  binding.scope,
14608
14620
  binding.hasNestedChildren,
14609
- binding.readStyle
14621
+ binding.readStyle,
14622
+ false,
14623
+ next.writableTextareaValue
14610
14624
  );
14611
14625
  if (process.env.NODE_ENV !== "production" && STAGED_DOM === null)
14612
14626
  drainDevFormDiagnostics(binding.element);
@@ -14873,7 +14887,12 @@ function bindSignalHostPropSources(scope, previous, element, sources, site, hasN
14873
14887
  validateDirectSignalControl(element, site);
14874
14888
  binding.pendingControl ||= activeHydration() !== null && controlSnapshot.editRevision > 0;
14875
14889
  }
14876
- const next = resolveSignalHostPropSources(sources, readStyle);
14890
+ const next = resolveSignalHostPropSources(
14891
+ sources,
14892
+ readStyle,
14893
+ void 0,
14894
+ element.localName === "textarea"
14895
+ );
14877
14896
  binding.resolved = setHostPropSources(
14878
14897
  element,
14879
14898
  next.sources,
@@ -14881,7 +14900,8 @@ function bindSignalHostPropSources(scope, previous, element, sources, site, hasN
14881
14900
  scope,
14882
14901
  hasNestedChildren,
14883
14902
  readStyle,
14884
- binding.pendingControl
14903
+ binding.pendingControl,
14904
+ next.writableTextareaValue
14885
14905
  );
14886
14906
  if (STAGED_COMMIT_CAPTURE !== null) {
14887
14907
  DEFERRED_LAYOUT_DRIVER.stageAction(() => {
@@ -16518,7 +16538,7 @@ function setNativeChangeDiagnosticMetadata(el, value) {
16518
16538
  if (state !== void 0) state.staticNativeChange = false;
16519
16539
  if (value === "runtime") queueDevFormDiagnostic(el, CURRENT_SCOPE ?? void 0, true);
16520
16540
  }
16521
- function setValue(el, value) {
16541
+ function setValue(el, value, writableTextareaEcho = false) {
16522
16542
  if (CURRENT_SCOPE?.block.idState.renderOwner?.controlLeases?.has(el)) presentationMiss(false);
16523
16543
  const input = el;
16524
16544
  const ctrl = armControlled(el);
@@ -16550,6 +16570,13 @@ function setValue(el, value) {
16550
16570
  const prev = ctrl.v;
16551
16571
  ctrl.v = value;
16552
16572
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, CURRENT_SCOPE ?? void 0);
16573
+ if (writableTextareaEcho) {
16574
+ if ((STAGED_DOM?.view(input) ?? input).value === s) return;
16575
+ if (!(ctrl.composing && Object.is(prev, value))) (STAGED_DOM?.view(input) ?? input).value = s;
16576
+ if ((STAGED_DOM?.view(input) ?? input).defaultValue !== s)
16577
+ (STAGED_DOM?.view(input) ?? input).defaultValue = s;
16578
+ return;
16579
+ }
16553
16580
  if (!(ctrl.composing && Object.is(prev, value)) && valueNeedsWrite(input, value))
16554
16581
  (STAGED_DOM?.view(input) ?? input).value = s;
16555
16582
  if ((STAGED_DOM?.view(input) ?? input).defaultValue !== s)
@@ -16854,7 +16881,7 @@ function setFormControlSources(el, sources) {
16854
16881
  }
16855
16882
  applyFormControlValues(el, tag, value, defaultValue, checked, defaultChecked, multiple);
16856
16883
  }
16857
- function applyFormControlValues(el, tag, value, defaultValue, checked, defaultChecked, multiple) {
16884
+ function applyFormControlValues(el, tag, value, defaultValue, checked, defaultChecked, multiple, writableTextareaValue = false) {
16858
16885
  const ctrl = armControlled(el);
16859
16886
  const first = !ctrl.formSeen;
16860
16887
  const previousMultiple = ctrl.formMultiple;
@@ -16884,7 +16911,7 @@ function applyFormControlValues(el, tag, value, defaultValue, checked, defaultCh
16884
16911
  }
16885
16912
  if (tag === "textarea") {
16886
16913
  const textarea = el;
16887
- setValue(textarea, value);
16914
+ setValue(textarea, value, writableTextareaValue);
16888
16915
  if (value == null) {
16889
16916
  if (defaultValue != null) setDefaultValue(textarea, defaultValue, first);
16890
16917
  else if (!first && (STAGED_DOM?.view(textarea) ?? textarea).defaultValue !== "")
@@ -19211,19 +19238,25 @@ function flattenDeoptChildrenKeyed(outVals, outKeys, v, prefix) {
19211
19238
  for (let i = 0; i < v.length; i++) {
19212
19239
  const item = v[i];
19213
19240
  if (Array.isArray(item)) {
19214
- flattenDeoptChildrenKeyed(outVals, outKeys, item, prefix + i + ":");
19241
+ flattenDeoptChildrenKeyed(outVals, outKeys, item, prefix + ":" + i);
19215
19242
  } else if (item == null || item === false || item === true || item === "") {
19216
19243
  } else {
19217
19244
  outVals.push(item);
19218
- const k = keyForItem(item, i);
19219
- outKeys.push(prefix === "" ? k : prefix + String(k));
19245
+ const k2 = keyForItem(item, i);
19246
+ if (prefix === "") {
19247
+ outKeys.push(typeof k2 === "string" && k2[0] === ":" ? ":" + k2 : k2);
19248
+ } else {
19249
+ const explicit = item?.$$kind === ELEMENT_TAG && item.key != null;
19250
+ outKeys.push(prefix + ":" + (explicit ? "k" : "i") + String(k2));
19251
+ }
19220
19252
  }
19221
19253
  }
19222
19254
  return;
19223
19255
  }
19224
19256
  outVals.push(v);
19257
+ const k = v?.$$kind === ELEMENT_TAG && v.key != null ? v.key : 0;
19225
19258
  outKeys.push(
19226
- prefix === "" ? v?.$$kind === ELEMENT_TAG && v.key != null ? v.key : 0 : prefix + "0"
19259
+ prefix === "" ? typeof k === "string" && k[0] === ":" ? ":" + k : k : prefix + ":i0"
19227
19260
  );
19228
19261
  }
19229
19262
  function reconcileDeoptNode(prev, value, ownerBlock, ns) {
@@ -53,6 +53,7 @@ __export(graph_exports, {
53
53
  });
54
54
  module.exports = __toCommonJS(graph_exports);
55
55
  var import_transition_state = require("./transition-state.cjs");
56
+ var import_transition_action = require("./transition-action.cjs");
56
57
  var import_system = require("alien-signals/system");
57
58
  var import_errors = require("./errors.cjs");
58
59
  var import_read_protocol = require("./read-protocol.cjs");
@@ -759,6 +760,7 @@ function retireGraph(owner, nodes) {
759
760
  createNativeSource,
760
761
  attachObserver
761
762
  });
763
+ (0, import_transition_state.registerSignalActionFrameFactory)(() => new import_transition_action.SignalActionFrame());
762
764
  // Annotate the CommonJS export names for ESM import in node:
763
765
  0 && (module.exports = {
764
766
  CandidateUnsupportedError,