octane 0.6.0 → 0.6.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.
Files changed (83) hide show
  1. package/dist/cjs/dom-binding-handoff.cjs +2 -2
  2. package/dist/cjs/dom-binding-protocol.cjs +4 -3
  3. package/dist/cjs/dom-binding-styles.cjs +3 -4
  4. package/dist/cjs/dom-bindings.cjs +24 -32
  5. package/dist/cjs/error-codes.client.generated.cjs +829 -0
  6. package/dist/cjs/error-codes.server.generated.cjs +565 -0
  7. package/dist/cjs/hydration/event-capture.cjs +2 -1
  8. package/dist/cjs/independent-hydration-protocol.cjs +3 -2
  9. package/dist/cjs/runtime.cjs +222 -52
  10. package/dist/cjs/runtime.server.cjs +45 -1
  11. package/dist/cjs/server/streamed-signals.cjs +2 -4
  12. package/dist/cjs/signals/actions.cjs +31 -34
  13. package/dist/cjs/signals/computations.cjs +10 -13
  14. package/dist/cjs/signals/control-binding.cjs +7 -14
  15. package/dist/cjs/signals/derived-facade.cjs +2 -1
  16. package/dist/cjs/signals/document-owner.cjs +2 -2
  17. package/dist/cjs/signals/engine.cjs +29 -42
  18. package/dist/cjs/signals/errors.cjs +6 -5
  19. package/dist/cjs/signals/facade.cjs +10 -16
  20. package/dist/cjs/signals/graph.cjs +5 -5
  21. package/dist/cjs/signals/native-read-client.cjs +4 -4
  22. package/dist/cjs/signals/native-read-seeds.cjs +21 -28
  23. package/dist/cjs/signals/owner-context.cjs +4 -4
  24. package/dist/cjs/signals/query-attempt-observer.cjs +2 -1
  25. package/dist/cjs/signals/query-facade.cjs +2 -1
  26. package/dist/cjs/signals/read-protocol.cjs +2 -1
  27. package/dist/cjs/signals/requests.cjs +13 -18
  28. package/dist/cjs/signals/scalar-computations.cjs +2 -1
  29. package/dist/cjs/signals/transition-action.cjs +10 -10
  30. package/dist/cjs/signals/transition-candidate.cjs +2 -1
  31. package/dist/cjs/version.cjs +1 -1
  32. package/dist/compiler/native-read-codegen.js +4 -0
  33. package/dist/dom-binding-classes.js +8 -9
  34. package/dist/dom-binding-handoff.js +2 -2
  35. package/dist/dom-binding-program.js +28 -48
  36. package/dist/dom-binding-projections.js +4 -6
  37. package/dist/dom-binding-protocol.js +4 -3
  38. package/dist/dom-binding-signals.js +4 -9
  39. package/dist/dom-binding-styles.js +3 -4
  40. package/dist/dom-bindings.js +24 -32
  41. package/dist/error-codes.client.generated.d.ts +251 -0
  42. package/dist/error-codes.client.generated.js +829 -0
  43. package/dist/error-codes.server.generated.d.ts +191 -0
  44. package/dist/error-codes.server.generated.js +565 -0
  45. package/dist/hydration/document-lifecycle.js +2 -1
  46. package/dist/hydration/event-capture.js +2 -1
  47. package/dist/hydration/independent-island.js +8 -8
  48. package/dist/hydration/stream-delivery.js +21 -35
  49. package/dist/hydration/stream-receiver.js +12 -26
  50. package/dist/hydration/stream-result-receiver.js +17 -22
  51. package/dist/hydration/streamed-signals.js +6 -6
  52. package/dist/independent-hydration-protocol.js +3 -2
  53. package/dist/index.d.ts +1 -1
  54. package/dist/react/react-compat-server.js +1 -0
  55. package/dist/react/react-compat.js +1 -0
  56. package/dist/runtime.d.ts +30 -9
  57. package/dist/runtime.js +222 -52
  58. package/dist/runtime.server.d.ts +2 -1
  59. package/dist/runtime.server.js +45 -1
  60. package/dist/server/streamed-signals.js +2 -4
  61. package/dist/signals/actions.js +31 -34
  62. package/dist/signals/computations.js +10 -13
  63. package/dist/signals/control-binding.js +7 -14
  64. package/dist/signals/derived-facade.js +2 -1
  65. package/dist/signals/document-owner.js +2 -2
  66. package/dist/signals/engine.js +29 -42
  67. package/dist/signals/errors.js +6 -5
  68. package/dist/signals/facade.js +10 -16
  69. package/dist/signals/graph.js +5 -5
  70. package/dist/signals/native-read-client.js +4 -4
  71. package/dist/signals/native-read-seeds.js +21 -28
  72. package/dist/signals/owner-context.js +4 -4
  73. package/dist/signals/query-attempt-observer.js +2 -1
  74. package/dist/signals/query-facade.js +2 -1
  75. package/dist/signals/read-protocol.js +2 -1
  76. package/dist/signals/requests.js +13 -18
  77. package/dist/signals/scalar-computations.js +2 -1
  78. package/dist/signals/transition-action.js +10 -10
  79. package/dist/signals/transition-candidate.js +2 -1
  80. package/dist/universal-core.d.ts +1 -1
  81. package/dist/universal-core.js +2 -0
  82. package/dist/version.js +1 -1
  83. package/package.json +1 -1
@@ -28,6 +28,7 @@ __export(dom_binding_handoff_exports, {
28
28
  releaseBindingHandoff: () => releaseBindingHandoff
29
29
  });
30
30
  module.exports = __toCommonJS(dom_binding_handoff_exports);
31
+ var import_error_codes_client_generated = require("./error-codes.client.generated.cjs");
31
32
  var import_control_handoff = require("./signals/control-handoff.cjs");
32
33
  const events = /* @__PURE__ */ new WeakMap();
33
34
  const delivered = /* @__PURE__ */ new WeakMap();
@@ -43,8 +44,7 @@ function registerBindingEvent(node, type) {
43
44
  };
44
45
  }
45
46
  function claimBindingHandoff(lease, owner) {
46
- if (!lease.active() || lease.owner !== void 0)
47
- throw new Error("A DOM binding hydration lease must be active and have only one root owner.");
47
+ if (!lease.active() || lease.owner !== void 0) throw new Error((0, import_error_codes_client_generated.formatClientError)(277));
48
48
  lease.owner = owner;
49
49
  }
50
50
  function releaseBindingHandoff(lease) {
@@ -27,6 +27,7 @@ __export(dom_binding_protocol_exports, {
27
27
  parseBindingMarker: () => parseBindingMarker
28
28
  });
29
29
  module.exports = __toCommonJS(dom_binding_protocol_exports);
30
+ var import_error_codes_client_generated = require("./error-codes.client.generated.cjs");
30
31
  var import_hydration_markers = require("./hydration-markers.cjs");
31
32
  const BINDING_OPEN_PREFIX = import_hydration_markers.HYDRATION_START + "b;";
32
33
  const BINDING_RECEIPT = ";b;";
@@ -43,19 +44,19 @@ function encodeBindingKey(key) {
43
44
  if (typeof key === "string")
44
45
  return "s:" + JSON.stringify(key).replace(/-/g, "\\u002d").replace(/</g, "\\u003c");
45
46
  if (typeof key === "number" && Number.isFinite(key)) return "n:" + String(key);
46
- throw new TypeError("A DOM presentation key must be a string or finite number.");
47
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(306));
47
48
  }
48
49
  function decodeBindingKey(encoded) {
49
50
  let key;
50
51
  try {
51
52
  key = JSON.parse(encoded.slice(2));
52
53
  } catch {
53
- throw new TypeError("A DOM presentation key has invalid serialized identity.");
54
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(307));
54
55
  }
55
56
  if (encoded.startsWith("s:") && typeof key === "string" || encoded.startsWith("n:") && typeof key === "number" && Number.isFinite(key)) {
56
57
  if (encodeBindingKey(key) === encoded) return key;
57
58
  }
58
- throw new TypeError("A DOM presentation key has invalid serialized identity.");
59
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(307));
59
60
  }
60
61
  function parseBindingMarker(data) {
61
62
  if (data.startsWith(BINDING_FOR_EMPTY_PREFIX) || data.startsWith(BINDING_FOR_ITEMS_PREFIX)) {
@@ -23,6 +23,7 @@ __export(dom_binding_styles_exports, {
23
23
  __prepareBindingSources: () => __prepareBindingSources
24
24
  });
25
25
  module.exports = __toCommonJS(dom_binding_styles_exports);
26
+ var import_error_codes_client_generated = require("./error-codes.client.generated.cjs");
26
27
  var import_style_values = require("./style-values.cjs");
27
28
  var import_dom_bindings = require("./dom-bindings.cjs");
28
29
  var import_owner_context = require("./signals/owner-context.cjs");
@@ -77,8 +78,7 @@ function __prepareBindingSources(reads, subscriptions, notify, active, run) {
77
78
  function __normalizeBindingStyle(value) {
78
79
  if (value == null || value === false || value === "") return null;
79
80
  if (typeof value === "string") return value;
80
- if (typeof value !== "object")
81
- throw new TypeError("A whole-style DOM binding requires a style object, CSS text or null.");
81
+ if (typeof value !== "object") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(311));
82
82
  const result = /* @__PURE__ */ Object.create(null);
83
83
  for (const name in value) {
84
84
  const property = value[name];
@@ -140,8 +140,7 @@ function __createBindingStyles() {
140
140
  })
141
141
  )
142
142
  );
143
- if (typeof stop !== "function")
144
- throw new TypeError("A DOM style subscription must return cleanup.");
143
+ if (typeof stop !== "function") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(312));
145
144
  const disposeSource = () => {
146
145
  active = false;
147
146
  stop();
@@ -31,6 +31,7 @@ __export(dom_bindings_exports, {
31
31
  unbound: () => unbound
32
32
  });
33
33
  module.exports = __toCommonJS(dom_bindings_exports);
34
+ var import_error_codes_client_generated = require("./error-codes.client.generated.cjs");
34
35
  var import_class_names = require("./class-names.cjs");
35
36
  var import_dom_binding_claims = require("./dom-binding-claims.cjs");
36
37
  var import_sanitize_url = require("./sanitize-url.cjs");
@@ -43,12 +44,10 @@ function unbound(value) {
43
44
  return value;
44
45
  }
45
46
  function adoptBindings(_root, _view, _source, _options) {
46
- throw new Error(
47
- "adoptBindings() requires an Octane-compiled .tsrx or .tsx call and a supported static view."
48
- );
47
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(313));
49
48
  }
50
49
  function mountBindings(_target, _view, _source, _options) {
51
- throw new Error("mountBindings() requires an Octane-compiled .tsrx or .tsx call.");
50
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(314));
52
51
  }
53
52
  function __mountBindings(target, descriptor, source, options) {
54
53
  return descriptor.mount(target, descriptor, source, options);
@@ -80,11 +79,11 @@ function conflicts(channels, binding, name) {
80
79
  }
81
80
  function __claimBinding(node, binding) {
82
81
  if (binding[1] === "classToken" && !/^\S+$/.test(binding[2]))
83
- throw new TypeError("A DOM class token binding requires one nonempty class token.");
82
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(315));
84
83
  const name = channel(binding);
85
84
  let channels = claims.get(node);
86
85
  if (channels !== void 0 && conflicts(channels, binding, name))
87
- throw new Error("This DOM property already has a binding. Dispose it before rebinding.");
86
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(316));
88
87
  if (channels === void 0) claims.set(node, channels = /* @__PURE__ */ new Set());
89
88
  channels.add(name);
90
89
  return name;
@@ -101,7 +100,7 @@ function __releaseBinding(node, name) {
101
100
  }
102
101
  function assertBindingRoot(root, descriptor) {
103
102
  if (root?.nodeType !== 1 || root.getAttribute("data-octane-bindings") !== descriptor.id || descriptor.nodes.length === 0) {
104
- throw new Error("DOM bindings require the matching compiler-stamped root.");
103
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(317));
105
104
  }
106
105
  return root;
107
106
  }
@@ -113,14 +112,14 @@ function resolveFixedNodes(root, descriptor) {
113
112
  const [parent, tag, namespace, children, , text] = descriptor.nodes[i];
114
113
  const node = i === 0 ? parent === -1 ? root : void 0 : parent >= 0 && parent < i && descriptor.nodes[parent][3] !== null ? nodes[parent]?.children[childIndices[parent]++] : void 0;
115
114
  if (node === void 0 || descriptor.nodes[i][4] === true || node.localName !== tag || node.namespaceURI !== namespaces[namespace] || (text ? node.childNodes.length > 1 || node.firstChild !== null && node.firstChild.nodeType !== 3 : children !== null && (node.childNodes.length !== children || node.children.length !== children))) {
116
- throw new Error("DOM bindings cannot adopt a mismatched static element topology.");
115
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(318));
117
116
  }
118
117
  nodes.push(node);
119
118
  childIndices.push(0);
120
119
  }
121
120
  for (let i = 0; i < nodes.length; i++) {
122
121
  if (childIndices[i] !== (descriptor.nodes[i][3] ?? 0)) {
123
- throw new Error("DOM bindings cannot adopt an incomplete static element topology.");
122
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(319));
124
123
  }
125
124
  }
126
125
  return nodes;
@@ -136,7 +135,7 @@ function resolveAddressedNodes(root, descriptor) {
136
135
  if (marker?.startsWith(prefix)) {
137
136
  const index = Number(marker.slice(prefix.length));
138
137
  if (!Number.isSafeInteger(index) || index < 0 || index >= descriptor.nodes.length || marker !== `${prefix}${index}` || nodes[index] !== void 0) {
139
- throw new Error("DOM bindings require unique compiler-issued target addresses.");
138
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(320));
140
139
  }
141
140
  nodes[index] = current;
142
141
  if (descriptor.nodes[index][3] === null) descend = false;
@@ -156,13 +155,13 @@ function resolveAddressedNodes(root, descriptor) {
156
155
  const [parent, tag, namespace, children, openChildren, text] = descriptor.nodes[i];
157
156
  const node = nodes[i];
158
157
  if (node === void 0 || node.localName !== tag || node.namespaceURI !== namespaces[namespace] || (i === 0 ? parent !== -1 || node !== root : parent < 0 || parent >= i || descriptor.nodes[parent][3] === null || node.parentElement !== nodes[parent] || descriptor.nodes[parent][4] !== true && nodes[parent].children[childCounts[parent]] !== node) || openChildren && children === null || (text ? node.childNodes.length > 1 || node.firstChild !== null && node.firstChild.nodeType !== 3 : children !== null && !openChildren && (node.childNodes.length !== children || node.children.length !== children))) {
159
- throw new Error("DOM bindings cannot adopt a mismatched addressed element topology.");
158
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(321));
160
159
  }
161
160
  if (parent !== -1) childCounts[parent]++;
162
161
  }
163
162
  for (let i = 0; i < descriptor.nodes.length; i++) {
164
163
  if (childCounts[i] !== (descriptor.nodes[i][3] ?? 0)) {
165
- throw new Error("DOM bindings cannot adopt an incomplete addressed element topology.");
164
+ throw new Error((0, import_error_codes_client_generated.formatClientError)(322));
166
165
  }
167
166
  }
168
167
  return nodes;
@@ -177,7 +176,7 @@ function normalizeFixedScalar(binding, value) {
177
176
  case "text":
178
177
  if (value == null || value === false) return "";
179
178
  if (type !== "string" && type !== "number" && type !== "bigint" && type !== "boolean")
180
- throw new TypeError("DOM binding text must be a synchronous scalar.");
179
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(323));
181
180
  return String(value);
182
181
  case "class":
183
182
  return value == null || value === false ? null : (0, import_class_names.normalizeClass)(value);
@@ -208,8 +207,7 @@ function normalize(binding, value) {
208
207
  return value == null || value === false ? "" : (0, import_class_names.normalizeClass)(value);
209
208
  case "styleAttribute":
210
209
  if (value == null || value === false || value === "") return null;
211
- if (type !== "string")
212
- throw new TypeError("A whole-style DOM binding requires serialized CSS text or null.");
210
+ if (type !== "string") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(324));
213
211
  return value;
214
212
  case "classToken":
215
213
  return value ? "" : null;
@@ -300,7 +298,7 @@ function __createBindingStyleRestoration(node, binding) {
300
298
  function __adoptBindings(root, descriptor, source, options) {
301
299
  if ("root" in descriptor) return descriptor.adopt(root, descriptor, source, options);
302
300
  if (!source || typeof source.getSnapshot !== "function" || typeof source.subscribe !== "function")
303
- throw new TypeError("DOM bindings require synchronous getSnapshot() and subscribe() methods.");
301
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(325));
304
302
  const nodes = descriptor.addressed ? resolveAddressedNodes(assertBindingRoot(root, descriptor), descriptor) : resolveFixedNodes(root, descriptor);
305
303
  const bindings = descriptor.bindings;
306
304
  const owned = [];
@@ -488,14 +486,12 @@ function __adoptBindings(root, descriptor, source, options) {
488
486
  const snapshot = source.getSnapshot();
489
487
  if (dirty || disposed) continue;
490
488
  if (snapshot !== null && (typeof snapshot === "object" || typeof snapshot === "function") && typeof snapshot.then === "function" && !dirty && !disposed)
491
- throw new TypeError("DOM bindings require a synchronous snapshot, not a thenable.");
489
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(326));
492
490
  if (dirty || disposed) continue;
493
491
  const values = descriptor.project(snapshot);
494
492
  if (dirty || disposed) continue;
495
493
  if (!Array.isArray(values) || values.length !== bindings.length)
496
- throw new TypeError(
497
- "A DOM binding projection must return its synchronous scalar values."
498
- );
494
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(327));
499
495
  let resolved = values;
500
496
  if (projectionFactory && descriptor.projectionGroups) {
501
497
  for (const group of descriptor.projectionGroups) {
@@ -756,7 +752,7 @@ function __adoptBindings(root, descriptor, source, options) {
756
752
  for (let index = 0; index < bindings.length; index++) {
757
753
  const binding = bindings[index];
758
754
  const node = nodes[binding[0]];
759
- if (node === void 0) throw new TypeError("A DOM binding targets an unknown element.");
755
+ if (node === void 0) throw new TypeError((0, import_error_codes_client_generated.formatClientError)(328));
760
756
  owned.push([node, __claimBinding(node, binding)]);
761
757
  if (binding[1] === "control") {
762
758
  controls.set(
@@ -781,8 +777,7 @@ function __adoptBindings(root, descriptor, source, options) {
781
777
  }
782
778
  signal?.addEventListener("abort", dispose, { once: true });
783
779
  const stop = source.subscribe(refresh);
784
- if (typeof stop !== "function")
785
- throw new TypeError("A DOM binding subscription must return a cleanup function.");
780
+ if (typeof stop !== "function") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(329));
786
781
  if (disposed) stop();
787
782
  else unsubscribe = stop;
788
783
  busy = false;
@@ -798,9 +793,9 @@ function __adoptBindings(root, descriptor, source, options) {
798
793
  }
799
794
  function __adoptScalarBindings(root, descriptor, source, options) {
800
795
  if (descriptor.addressed || descriptor.handoff || descriptor.connectProjection || !descriptor.bindings.every(isFixedScalarChannel))
801
- throw new TypeError("This DOM binding view requires the general adopter.");
796
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(330));
802
797
  if (!source || typeof source.getSnapshot !== "function" || typeof source.subscribe !== "function")
803
- throw new TypeError("DOM bindings require synchronous getSnapshot() and subscribe() methods.");
798
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(325));
804
799
  const nodes = resolveFixedNodes(root, descriptor);
805
800
  const bindings = descriptor.bindings;
806
801
  const owned = [];
@@ -889,14 +884,12 @@ function __adoptScalarBindings(root, descriptor, source, options) {
889
884
  const snapshot = source.getSnapshot();
890
885
  if (dirty || disposed) continue;
891
886
  if (snapshot !== null && (typeof snapshot === "object" || typeof snapshot === "function") && typeof snapshot.then === "function" && !dirty && !disposed)
892
- throw new TypeError("DOM bindings require a synchronous snapshot, not a thenable.");
887
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(326));
893
888
  if (dirty || disposed) continue;
894
889
  const values = descriptor.project(snapshot);
895
890
  if (dirty || disposed) continue;
896
891
  if (!Array.isArray(values) || values.length !== bindings.length)
897
- throw new TypeError(
898
- "A DOM binding projection must return its synchronous scalar values."
899
- );
892
+ throw new TypeError((0, import_error_codes_client_generated.formatClientError)(327));
900
893
  let resolved = values;
901
894
  if (signalFactory && descriptor.signalIndices) {
902
895
  for (const index of descriptor.signalIndices) {
@@ -1003,13 +996,12 @@ function __adoptScalarBindings(root, descriptor, source, options) {
1003
996
  try {
1004
997
  for (let index = 0; index < bindings.length; index++) {
1005
998
  const node = nodes[bindings[index][0]];
1006
- if (node === void 0) throw new TypeError("A DOM binding targets an unknown element.");
999
+ if (node === void 0) throw new TypeError((0, import_error_codes_client_generated.formatClientError)(328));
1007
1000
  owned.push([node, __claimBinding(node, bindings[index])]);
1008
1001
  }
1009
1002
  signal?.addEventListener("abort", dispose, { once: true });
1010
1003
  const stop = source.subscribe(refresh);
1011
- if (typeof stop !== "function")
1012
- throw new TypeError("A DOM binding subscription must return a cleanup function.");
1004
+ if (typeof stop !== "function") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(329));
1013
1005
  if (disposed) stop();
1014
1006
  else unsubscribe = stop;
1015
1007
  busy = false;