octane 0.9.1 → 0.10.2

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 (97) hide show
  1. package/README.md +9 -0
  2. package/dist/cjs/component-flags.cjs +6 -0
  3. package/dist/cjs/dom-bindings.cjs +8 -3
  4. package/dist/cjs/error-codes.client.generated.cjs +30 -40
  5. package/dist/cjs/hydration-flag.cjs +42 -0
  6. package/dist/cjs/hydration-markers.cjs +3 -0
  7. package/dist/cjs/method-dep.cjs +18 -3
  8. package/dist/cjs/runtime.cjs +2389 -2023
  9. package/dist/cjs/runtime.server.cjs +56 -32
  10. package/dist/cjs/server/early-signals.cjs +1 -1
  11. package/dist/cjs/signals/document-owner.cjs +1 -1
  12. package/dist/cjs/signals/early-values.cjs +13 -2
  13. package/dist/cjs/signals/engine.cjs +3 -3
  14. package/dist/cjs/signals/facade.cjs +30 -4
  15. package/dist/cjs/signals/graph.cjs +92 -14
  16. package/dist/cjs/signals/native-read-events.cjs +1 -3
  17. package/dist/cjs/signals/query-attempt-observer.cjs +6 -0
  18. package/dist/cjs/signals/read-protocol.cjs +26 -2
  19. package/dist/cjs/signals/redeclaration.cjs +7 -4
  20. package/dist/cjs/signals/transition-action.cjs +3 -1
  21. package/dist/cjs/version.cjs +1 -1
  22. package/dist/compiler/bundler.js +230 -5
  23. package/dist/compiler/compile-universal.js +47 -4
  24. package/dist/compiler/compile.js +450 -89
  25. package/dist/compiler/dom-binding-program.js +7 -1
  26. package/dist/compiler/hook-deps.js +45 -10
  27. package/dist/compiler/index.d.ts +10 -0
  28. package/dist/compiler/native-read-diagnostics.js +14 -1
  29. package/dist/compiler/plain-hook-memo.js +2 -2
  30. package/dist/compiler/signal-declarations.js +277 -48
  31. package/dist/compiler/slot-hooks.js +123 -289
  32. package/dist/compiler/strong-diagnostics.js +2 -2
  33. package/dist/compiler/strong-effects.js +13 -90
  34. package/dist/compiler/strong-mode.js +15 -46
  35. package/dist/compiler/vite.d.ts +9 -0
  36. package/dist/compiler/vite.js +136 -9
  37. package/dist/compiler/void-roots.js +12 -5
  38. package/dist/compiler/volar.js +25 -0
  39. package/dist/component-flags.d.ts +10 -0
  40. package/dist/component-flags.js +4 -0
  41. package/dist/dom-binding-handoff.d.ts +2 -0
  42. package/dist/dom-bindings.js +8 -3
  43. package/dist/error-codes.client.generated.d.ts +6 -8
  44. package/dist/error-codes.client.generated.js +30 -40
  45. package/dist/hydration/independent-island.js +9 -8
  46. package/dist/hydration-flag.d.ts +18 -0
  47. package/dist/hydration-flag.js +15 -0
  48. package/dist/hydration-markers.d.ts +9 -0
  49. package/dist/hydration-markers.js +2 -0
  50. package/dist/method-dep.d.ts +1 -1
  51. package/dist/method-dep.js +18 -3
  52. package/dist/node/component-flags.js +4 -0
  53. package/dist/node/dom-bindings.js +8 -3
  54. package/dist/node/error-codes.client.generated.js +30 -40
  55. package/dist/node/hydration/independent-island.js +9 -8
  56. package/dist/node/hydration-flag.js +15 -0
  57. package/dist/node/hydration-markers.js +2 -0
  58. package/dist/node/method-dep.js +18 -3
  59. package/dist/node/runtime.js +2393 -2026
  60. package/dist/node/runtime.server.js +59 -32
  61. package/dist/node/server/early-signals.js +1 -1
  62. package/dist/node/signals/document-owner.js +2 -2
  63. package/dist/node/signals/early-values.js +11 -2
  64. package/dist/node/signals/engine.js +5 -4
  65. package/dist/node/signals/facade.js +31 -5
  66. package/dist/node/signals/graph.js +93 -15
  67. package/dist/node/signals/native-read-events.js +1 -3
  68. package/dist/node/signals/query-attempt-observer.js +5 -0
  69. package/dist/node/signals/read-protocol.js +20 -1
  70. package/dist/node/signals/redeclaration.js +8 -4
  71. package/dist/node/signals/transition-action.js +4 -2
  72. package/dist/node/universal-core.js +2 -2
  73. package/dist/node/version.js +1 -1
  74. package/dist/runtime.d.ts +642 -582
  75. package/dist/runtime.js +2393 -2026
  76. package/dist/runtime.server.d.ts +13 -2
  77. package/dist/runtime.server.js +59 -32
  78. package/dist/server/early-signals.js +1 -1
  79. package/dist/signals/document-owner.js +2 -2
  80. package/dist/signals/early-values.d.ts +23 -1
  81. package/dist/signals/early-values.js +11 -2
  82. package/dist/signals/engine.js +5 -4
  83. package/dist/signals/facade.d.ts +11 -1
  84. package/dist/signals/facade.js +31 -5
  85. package/dist/signals/graph.d.ts +5 -0
  86. package/dist/signals/graph.js +93 -15
  87. package/dist/signals/native-read-events.js +1 -3
  88. package/dist/signals/query-attempt-observer.d.ts +9 -0
  89. package/dist/signals/query-attempt-observer.js +5 -0
  90. package/dist/signals/read-protocol.d.ts +34 -0
  91. package/dist/signals/read-protocol.js +20 -1
  92. package/dist/signals/redeclaration.js +8 -4
  93. package/dist/signals/transition-action.js +4 -2
  94. package/dist/universal-core.d.ts +8 -2
  95. package/dist/universal-core.js +2 -2
  96. package/dist/version.js +1 -1
  97. package/package.json +7 -3
package/README.md CHANGED
@@ -17,6 +17,15 @@ wrapper is narrower: the wrapper must be locally declared in a fully compiled
17
17
  parameter to a supported hook. This package ships both the runtime and compiler,
18
18
  with the compiler exposed at `octane/compiler`.
19
19
 
20
+ To use the compiler in Node, including through the Vite, Rspack, or Rsbuild
21
+ integrations, install its optional parser peer in your project:
22
+
23
+ ```bash
24
+ pnpm add @tsrx/oxc@0.16.0
25
+ ```
26
+
27
+ Applications that use only the Octane runtime do not need this peer.
28
+
20
29
  [Signals](https://octanejs.dev/docs/signals) are stable. Import `createScope` and
21
30
  `query` from `octane/signals`, or `useSignal$` from `octane/signals/client`, for
22
31
  scoped state, derived values, async resources, and native component reads.
@@ -18,6 +18,8 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var component_flags_exports = {};
20
20
  __export(component_flags_exports, {
21
+ COMPONENT_FLAGS_AUTHOR_BOUNDARY: () => COMPONENT_FLAGS_AUTHOR_BOUNDARY,
22
+ COMPONENT_FLAG_AUTHOR_CHILDREN: () => COMPONENT_FLAG_AUTHOR_CHILDREN,
21
23
  COMPONENT_FLAG_BOUNDARY: () => COMPONENT_FLAG_BOUNDARY,
22
24
  hasComponentFlags: () => hasComponentFlags,
23
25
  markComponentFlags: () => markComponentFlags
@@ -26,6 +28,8 @@ module.exports = __toCommonJS(component_flags_exports);
26
28
  var import_has_own = require("./has-own.cjs");
27
29
  const OCTANE_COMPONENT_FLAGS = /* @__PURE__ */ Symbol.for("octane.flags.component");
28
30
  const COMPONENT_FLAG_BOUNDARY = 1 << 0;
31
+ const COMPONENT_FLAG_AUTHOR_CHILDREN = 1 << 1;
32
+ const COMPONENT_FLAGS_AUTHOR_BOUNDARY = 1 << 0 | 1 << 1;
29
33
  function markComponentFlags(component, flags, name, kind) {
30
34
  Object.defineProperty(component, OCTANE_COMPONENT_FLAGS, { value: flags });
31
35
  Object.defineProperty(component, "name", { value: name, configurable: true });
@@ -43,6 +47,8 @@ function hasComponentFlags(component, flags) {
43
47
  }
44
48
  // Annotate the CommonJS export names for ESM import in node:
45
49
  0 && (module.exports = {
50
+ COMPONENT_FLAGS_AUTHOR_BOUNDARY,
51
+ COMPONENT_FLAG_AUTHOR_CHILDREN,
46
52
  COMPONENT_FLAG_BOUNDARY,
47
53
  hasComponentFlags,
48
54
  markComponentFlags
@@ -798,18 +798,20 @@ function __adoptBindings(root, descriptor, source, options) {
798
798
  const ancestry = [];
799
799
  for (let node = host; node !== null; node = node.parentNode)
800
800
  ancestry.push([node, node.parentNode]);
801
- const sibling = (node, previous2) => {
802
- let next = previous2 ? node.previousSibling : node.nextSibling;
801
+ const skip = (next, previous2) => {
803
802
  while (next?.nodeType === 1 && next.localName === "script" && (next.hasAttribute(import_native_read_seeds.NATIVE_SIGNAL_SEED_ATTR) || next.hasAttribute(import_stream_protocol.SUSPENSE_SCRIPT_ATTR) || next.hasAttribute(import_stream_protocol.STREAM_SCRIPT_ATTR)))
804
803
  next = previous2 ? next.previousSibling : next.nextSibling;
805
804
  return next;
806
805
  };
806
+ const sibling = (node, previous2) => skip(previous2 ? node.previousSibling : node.nextSibling, previous2);
807
+ const site = host.parentNode;
807
808
  const previousSibling = sibling(host, true);
808
809
  const nextSibling = sibling(host, false);
809
810
  let handoff;
810
811
  handle[import_control_handoff.BINDING_HANDOFF] = () => {
811
812
  if (handoff !== void 0)
812
813
  return handoff;
814
+ const adjacent = (recorded, previous2) => sibling(host, previous2) === recorded;
813
815
  return handoff = {
814
816
  id: descriptor.id,
815
817
  root: host,
@@ -820,7 +822,10 @@ function __adoptBindings(root, descriptor, source, options) {
820
822
  (publicationRetries ??= /* @__PURE__ */ new Set()).add(callback);
821
823
  return () => publicationRetries.delete(callback);
822
824
  },
823
- valid: () => host.parentNode !== null && host.ownerDocument === document && ancestry.every(([node, parent]) => node.parentNode === parent) && sibling(host, true) === previousSibling && sibling(host, false) === nextSibling && host.getAttribute("data-octane-bindings") === descriptor.id,
825
+ valid: () => host.parentNode !== null && host.ownerDocument === document && ancestry.every(([node, parent]) => node.parentNode === parent) && adjacent(previousSibling, true) && adjacent(nextSibling, false) && host.getAttribute("data-octane-bindings") === descriptor.id,
826
+ // The authored node before the host still marks its site after the
827
+ // host leaves, including when an external clone now stands there.
828
+ displaced: (parent, node) => parent === site && node !== host && (node === null || node.parentNode === parent) && (node === null ? skip(parent.lastChild, true) : sibling(node, true)) === previousSibling,
824
829
  active: () => !disposed,
825
830
  retire: (publish) => dispose(void 0, publish, true)
826
831
  };
@@ -163,48 +163,8 @@ function formatClientError(code, ...args) {
163
163
  );
164
164
  case 50:
165
165
  return (0, import_error_message.formatDevErrorMessage)("Unclosed server-rendered Fragment descriptor.", args);
166
- case 51:
167
- return (0, import_error_message.formatDevErrorMessage)(
168
- "Hydration mismatch: the server-rendered node did not match the client render; the mismatched subtree was rebuilt on the client.",
169
- args
170
- );
171
- case 52:
172
- return (0, import_error_message.formatDevErrorMessage)(
173
- "Hydration mismatch: root adoption was abandoned after a server/client shape divergence; the root was rebuilt on the client.",
174
- args
175
- );
176
- case 53:
177
- return (0, import_error_message.formatDevErrorMessage)(
178
- "Hydration mismatch: the server rendered more root content than the client; the stale remainder was discarded.",
179
- args
180
- );
181
- case 54:
182
- return (0, import_error_message.formatDevErrorMessage)(
183
- "Hydration mismatch: the client rendered text where the server rendered none; the client text was built fresh.",
184
- args
185
- );
186
- case 55:
187
- return (0, import_error_message.formatDevErrorMessage)(
188
- "Hydration mismatch: the server rendered a different child shape where the client renders a component; the stale range was discarded and the component was built on the client.",
189
- args
190
- );
191
- case 56:
192
- return (0, import_error_message.formatDevErrorMessage)(
193
- "Hydration mismatch: the server rendered more list items than the client; the extra server items were discarded.",
194
- args
195
- );
196
166
  case 58:
197
167
  return (0, import_error_message.formatDevErrorMessage)("Unsupported native-read compiler/runtime version.", args);
198
- case 61:
199
- return (0, import_error_message.formatDevErrorMessage)(
200
- "Hydration mismatch: the server-rendered text differed from the client; the text was updated to the client value.",
201
- args
202
- );
203
- case 62:
204
- return (0, import_error_message.formatDevErrorMessage)(
205
- "Hydration mismatch: the server rendered extra children in a text element; the stale children were discarded.",
206
- args
207
- );
208
168
  case 63:
209
169
  return (0, import_error_message.formatDevErrorMessage)(
210
170
  "Target container is not a DOM element. Pass an Element, Document, or DocumentFragment. If document.body is null after document hydration, update the existing document root or render a document shell containing <body>.",
@@ -1084,6 +1044,36 @@ function formatClientError(code, ...args) {
1084
1044
  "Structural hydration leases do not support @try regions.",
1085
1045
  args
1086
1046
  );
1047
+ case 338:
1048
+ return (0, import_error_message.formatDevErrorMessage)(
1049
+ "Hydration mismatch: a server-rendered range had no closing marker, so the client rendered the boundary or root that contains it instead. Something changed the server HTML after rendering, for example an HTML minifier or proxy that strips comments.",
1050
+ args
1051
+ );
1052
+ case 339:
1053
+ return (0, import_error_message.formatDevErrorMessage)(
1054
+ "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client.",
1055
+ args
1056
+ );
1057
+ case 340:
1058
+ return (0, import_error_message.formatDevErrorMessage)(
1059
+ "There was an error while hydrating, so the nearest Suspense boundary, Hydrate island, or the root rendered on the client instead.",
1060
+ args
1061
+ );
1062
+ case 341:
1063
+ return (0, import_error_message.formatDevErrorMessage)(
1064
+ "The server could not finish this Suspense boundary, because it suspended during a synchronous render such as renderToString, which cannot wait for data. Switched to client rendering.",
1065
+ args
1066
+ );
1067
+ case 342:
1068
+ return (0, import_error_message.formatDevErrorMessage)(
1069
+ "A descriptor carried a function form action, but no element factory installed form actions. This is a bug in the Octane compiler.",
1070
+ args
1071
+ );
1072
+ case 343:
1073
+ return (0, import_error_message.formatDevErrorMessage)(
1074
+ "A keyed list rollback record restored a different shape than it recorded. This is a bug in Octane.",
1075
+ args
1076
+ );
1087
1077
  default:
1088
1078
  return (0, import_error_message.formatUnknownDevErrorMessage)(code);
1089
1079
  }
@@ -0,0 +1,42 @@
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 hydration_flag_exports = {};
20
+ __export(hydration_flag_exports, {
21
+ hydrating: () => hydrating,
22
+ hydrationStarted: () => hydrationStarted,
23
+ setHydrating: () => setHydrating,
24
+ startHydration: () => startHydration
25
+ });
26
+ module.exports = __toCommonJS(hydration_flag_exports);
27
+ let hydrating = false;
28
+ let hydrationStarted = false;
29
+ function setHydrating(value) {
30
+ hydrating = value;
31
+ if (value) hydrationStarted = true;
32
+ }
33
+ function startHydration() {
34
+ hydrationStarted = true;
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ hydrating,
39
+ hydrationStarted,
40
+ setHydrating,
41
+ startHydration
42
+ });
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var hydration_markers_exports = {};
20
20
  __export(hydration_markers_exports, {
21
+ CLIENT_RENDER_ARM_COMMENT: () => CLIENT_RENDER_ARM_COMMENT,
21
22
  HYDRATE_ID_ATTR: () => HYDRATE_ID_ATTR,
22
23
  HYDRATE_ID_COUNT_ATTR: () => HYDRATE_ID_COUNT_ATTR,
23
24
  HYDRATE_INDEPENDENT_ATTR: () => HYDRATE_INDEPENDENT_ATTR,
@@ -59,11 +60,13 @@ const TRY_CATCH_COMMENT = "oct-catch:";
59
60
  const SUSPENSE_RESOLVED_COMMENT = "oct-suspense:";
60
61
  const STREAM_SEED_COMMENT = "oct-seed:";
61
62
  const NATIVE_SIGNAL_FRESH_COMMENT = "oct-native-fresh:";
63
+ const CLIENT_RENDER_ARM_COMMENT = "oct-client:";
62
64
  function formatUseId(prefix, ordinal) {
63
65
  return ":" + prefix + "in-" + ordinal.toString(36) + ":";
64
66
  }
65
67
  // Annotate the CommonJS export names for ESM import in node:
66
68
  0 && (module.exports = {
69
+ CLIENT_RENDER_ARM_COMMENT,
67
70
  HYDRATE_ID_ATTR,
68
71
  HYDRATE_ID_COUNT_ATTR,
69
72
  HYDRATE_INDEPENDENT_ATTR,
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(method_dep_exports);
24
24
  var import_has_own = require("./has-own.cjs");
25
25
  const guardedNullReceiver = /* @__PURE__ */ Symbol();
26
26
  const guardedUndefinedReceiver = /* @__PURE__ */ Symbol();
27
- function __methodDep(receiver, name, guarded = false) {
27
+ function __methodDep(receiver, name, guarded = false, read = false) {
28
28
  if (guarded && receiver == null) {
29
29
  return receiver === null ? guardedNullReceiver : guardedUndefinedReceiver;
30
30
  }
@@ -34,15 +34,30 @@ function __methodDep(receiver, name, guarded = false) {
34
34
  if (guarded) {
35
35
  try {
36
36
  const descriptor = Object.getOwnPropertyDescriptor(receiver, name);
37
- if (descriptor) return "value" in descriptor ? descriptor.value : receiver;
37
+ if (descriptor) {
38
+ if (!("value" in descriptor)) return receiver;
39
+ return read ? descriptor.value : ownMethodDep(receiver, descriptor.value);
40
+ }
38
41
  return name in receiver ? receiver : void 0;
39
42
  } catch {
40
43
  return receiver;
41
44
  }
42
45
  }
43
- if (import_has_own.hasOwnProp.call(receiver, name)) return receiver[name];
46
+ if (import_has_own.hasOwnProp.call(receiver, name)) {
47
+ return ownMethodDep(receiver, receiver[name]);
48
+ }
44
49
  return name in receiver ? receiver : void 0;
45
50
  }
51
+ const ARROW_HEAD = /^(?:async\s*)?(?:\(|[\w$]+\s*=>)/;
52
+ function ownMethodDep(receiver, method) {
53
+ if (typeof method !== "function") return method;
54
+ try {
55
+ const source = Function.prototype.toString.call(method);
56
+ return ARROW_HEAD.test(source) && (source[0] === "(" || method.name !== "async") ? method : receiver;
57
+ } catch {
58
+ return receiver;
59
+ }
60
+ }
46
61
  // Annotate the CommonJS export names for ESM import in node:
47
62
  0 && (module.exports = {
48
63
  __methodDep