octane 0.1.48 → 0.1.49

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 (93) hide show
  1. package/dist/cjs/devtools-hook.cjs +92 -23
  2. package/dist/cjs/error-codes.client.generated.cjs +2 -0
  3. package/dist/cjs/error-codes.server.generated.cjs +4 -0
  4. package/dist/cjs/internal/client.cjs +31 -0
  5. package/dist/cjs/internal/server.cjs +22 -0
  6. package/dist/cjs/profiling.cjs +5 -0
  7. package/dist/cjs/runtime.cjs +1054 -132
  8. package/dist/cjs/runtime.server.cjs +396 -46
  9. package/dist/cjs/signals/client.cjs +45 -0
  10. package/dist/cjs/signals/encoding.cjs +121 -0
  11. package/dist/cjs/signals/engine.cjs +517 -0
  12. package/dist/cjs/signals/errors.cjs +65 -0
  13. package/dist/cjs/signals/graph.cjs +650 -0
  14. package/dist/cjs/signals/index.cjs +42 -0
  15. package/dist/cjs/signals/native-read-client.cjs +292 -0
  16. package/dist/cjs/signals/native-read-collector.cjs +151 -0
  17. package/dist/cjs/signals/native-read-events.cjs +70 -0
  18. package/dist/cjs/signals/native-read-inspection.cjs +45 -0
  19. package/dist/cjs/signals/native-read-retry.cjs +54 -0
  20. package/dist/cjs/signals/native-read-seeds.cjs +161 -0
  21. package/dist/cjs/signals/native-read-server.cjs +119 -0
  22. package/dist/cjs/signals/read-protocol.cjs +116 -0
  23. package/dist/cjs/signals/requests.cjs +451 -0
  24. package/dist/cjs/signals/server.cjs +45 -0
  25. package/dist/cjs/version.cjs +1 -1
  26. package/dist/compiler/bundler.js +34 -6
  27. package/dist/compiler/compile.js +594 -65
  28. package/dist/compiler/hook-deps.js +9 -6
  29. package/dist/compiler/hook-names.js +4 -0
  30. package/dist/compiler/index.d.ts +3 -1
  31. package/dist/compiler/inline-hook-memo.js +3 -0
  32. package/dist/compiler/native-change-diagnostics.js +7 -0
  33. package/dist/compiler/native-read-codegen.js +84 -0
  34. package/dist/compiler/native-read-diagnostics.js +581 -0
  35. package/dist/compiler/native-read-facts.js +26 -0
  36. package/dist/compiler/native-read-types.js +323 -0
  37. package/dist/compiler/plain-hook-memo.js +29 -2
  38. package/dist/compiler/runtime-requests.js +9 -3
  39. package/dist/compiler/slot-hooks.js +111 -34
  40. package/dist/compiler/typescript.d.ts +12 -0
  41. package/dist/compiler/typescript.js +1 -0
  42. package/dist/compiler/vite.d.ts +2 -0
  43. package/dist/compiler/vite.js +5 -0
  44. package/dist/compiler/volar.d.ts +1 -1
  45. package/dist/compiler/volar.js +31 -4
  46. package/dist/devtools-hook.d.ts +19 -1
  47. package/dist/devtools-hook.js +90 -23
  48. package/dist/error-codes.client.generated.d.ts +1 -0
  49. package/dist/error-codes.client.generated.js +2 -0
  50. package/dist/error-codes.server.generated.d.ts +2 -0
  51. package/dist/error-codes.server.generated.js +4 -0
  52. package/dist/profiling.d.ts +2 -0
  53. package/dist/profiling.js +4 -0
  54. package/dist/runtime.d.ts +57 -1
  55. package/dist/runtime.js +1051 -133
  56. package/dist/runtime.server.d.ts +55 -13
  57. package/dist/runtime.server.js +390 -46
  58. package/dist/signals/client.d.ts +3 -0
  59. package/dist/signals/client.js +21 -0
  60. package/dist/signals/encoding.d.ts +3 -0
  61. package/dist/signals/encoding.js +96 -0
  62. package/dist/signals/engine.d.ts +73 -0
  63. package/dist/signals/engine.js +515 -0
  64. package/dist/signals/errors.d.ts +15 -0
  65. package/dist/signals/errors.js +37 -0
  66. package/dist/signals/graph.d.ts +109 -0
  67. package/dist/signals/graph.js +616 -0
  68. package/dist/signals/index.d.ts +5 -0
  69. package/dist/signals/index.js +18 -0
  70. package/dist/signals/native-read-client.d.ts +57 -0
  71. package/dist/signals/native-read-client.js +271 -0
  72. package/dist/signals/native-read-collector.d.ts +27 -0
  73. package/dist/signals/native-read-collector.js +132 -0
  74. package/dist/signals/native-read-events.d.ts +10 -0
  75. package/dist/signals/native-read-events.js +45 -0
  76. package/dist/signals/native-read-inspection.d.ts +15 -0
  77. package/dist/signals/native-read-inspection.js +20 -0
  78. package/dist/signals/native-read-retry.d.ts +14 -0
  79. package/dist/signals/native-read-retry.js +30 -0
  80. package/dist/signals/native-read-seeds.d.ts +30 -0
  81. package/dist/signals/native-read-seeds.js +131 -0
  82. package/dist/signals/native-read-server.d.ts +39 -0
  83. package/dist/signals/native-read-server.js +99 -0
  84. package/dist/signals/read-protocol.d.ts +86 -0
  85. package/dist/signals/read-protocol.js +80 -0
  86. package/dist/signals/requests.d.ts +88 -0
  87. package/dist/signals/requests.js +438 -0
  88. package/dist/signals/server.d.ts +3 -0
  89. package/dist/signals/server.js +21 -0
  90. package/dist/signals/types.d.ts +141 -0
  91. package/dist/signals/types.js +0 -0
  92. package/dist/version.js +1 -1
  93. package/package.json +22 -1
@@ -23,19 +23,23 @@ __export(devtools_hook_exports, {
23
23
  __devtoolsNotifyFlush: () => __devtoolsNotifyFlush,
24
24
  __devtoolsRegisterRoot: () => __devtoolsRegisterRoot,
25
25
  __devtoolsSetBoundaryState: () => __devtoolsSetBoundaryState,
26
+ __devtoolsSetChildWalker: () => __devtoolsSetChildWalker,
26
27
  __devtoolsSetNameResolver: () => __devtoolsSetNameResolver,
28
+ __devtoolsSetNativeReadInspector: () => __devtoolsSetNativeReadInspector,
27
29
  __devtoolsSetTransitionCount: () => __devtoolsSetTransitionCount,
28
30
  __devtoolsUnregisterRoot: () => __devtoolsUnregisterRoot,
29
31
  installDevtoolsGlobal: () => installDevtoolsGlobal
30
32
  });
31
33
  module.exports = __toCommonJS(devtools_hook_exports);
32
- const DEVTOOLS_HOOK_VERSION = 2;
34
+ const DEVTOOLS_HOOK_VERSION = 3;
33
35
  const roots = /* @__PURE__ */ new Set();
34
36
  const subscribers = /* @__PURE__ */ new Set();
35
37
  const ids = /* @__PURE__ */ new WeakMap();
36
38
  let nextId = 1;
37
39
  let idIndex = /* @__PURE__ */ new Map();
38
40
  let nameResolver = (b) => b && b.body && (b.body.displayName || b.body.name) || "Unknown";
41
+ let childWalker = null;
42
+ let nativeReadInspector = null;
39
43
  let transitionPendingCount = 0;
40
44
  const boundaries = /* @__PURE__ */ new Map();
41
45
  function branchToState(branch) {
@@ -60,52 +64,98 @@ function safePreview(value, depth = 0) {
60
64
  if (t === "bigint") return `${value}n`;
61
65
  if (t === "function") return "[Function]";
62
66
  if (t === "symbol") return String(value);
63
- if (depth >= 2) return Array.isArray(value) ? "[Array]" : "[Object]";
64
- if (typeof Node !== "undefined" && value instanceof Node) return `[${value.nodeName}]`;
65
- if (Array.isArray(value)) return value.slice(0, 20).map((v) => safePreview(v, depth + 1));
66
- const out = {};
67
- let n = 0;
68
- for (const key of Object.keys(value)) {
69
- if (n++ >= 20) break;
70
- out[key] = safePreview(value[key], depth + 1);
67
+ try {
68
+ if (depth >= 2) return Array.isArray(value) ? "[Array]" : "[Object]";
69
+ if (typeof Node !== "undefined" && value instanceof Node) return "[Node]";
70
+ const fields = Object.getOwnPropertyDescriptors(value);
71
+ if (Array.isArray(value)) {
72
+ const length = Math.min(Number(fields.length?.value) || 0, 20);
73
+ return Array.from({ length }, (_, index) => previewField(fields[index], depth));
74
+ }
75
+ const out = {};
76
+ let n = 0;
77
+ for (const key of Object.keys(fields)) {
78
+ const field = fields[key];
79
+ if (!field.enumerable) continue;
80
+ if (n++ >= 20) break;
81
+ Object.defineProperty(out, key, {
82
+ value: previewField(field, depth),
83
+ enumerable: true,
84
+ configurable: true,
85
+ writable: true
86
+ });
87
+ }
88
+ return out;
89
+ } catch {
90
+ return "[Unavailable]";
71
91
  }
72
- return out;
92
+ }
93
+ function previewField(field, depth) {
94
+ if (field === void 0) return void 0;
95
+ return "value" in field ? safePreview(field.value, depth + 1) : "[Getter]";
73
96
  }
74
97
  function classifyCell(cell) {
75
98
  if (cell === null || typeof cell !== "object") return null;
76
- if (cell.effect === true) return null;
77
- if ("setter" in cell) return { kind: "state", value: safePreview(cell.value) };
78
- if ("dispatch" in cell && "reducer" in cell)
79
- return { kind: "reducer", value: safePreview(cell.value) };
80
- if ("current" in cell && !("deps" in cell))
81
- return { kind: "ref", value: safePreview(cell.current) };
82
- if ("deps" in cell && "value" in cell)
83
- return { kind: "memo-or-callback", value: safePreview(cell.value) };
99
+ let fields;
100
+ try {
101
+ fields = Object.getOwnPropertyDescriptors(cell);
102
+ } catch {
103
+ return { kind: "other", value: "[Unavailable]" };
104
+ }
105
+ if (fields.effect?.value === true) return null;
106
+ if ("setter" in fields) return { kind: "state", value: previewField(fields.value, -1) };
107
+ if ("dispatch" in fields && "reducer" in fields)
108
+ return { kind: "reducer", value: previewField(fields.value, -1) };
109
+ if ("current" in fields && !("deps" in fields))
110
+ return { kind: "ref", value: previewField(fields.current, -1) };
111
+ if ("deps" in fields && "value" in fields)
112
+ return { kind: "memo-or-callback", value: previewField(fields.value, -1) };
84
113
  return { kind: "other", value: safePreview(cell) };
85
114
  }
86
115
  function nameOf(scope, key) {
87
116
  if (scope.body != null || scope.kind != null) return nameResolver(scope);
117
+ const component = nameResolver(scope);
118
+ if (component !== "Unknown") return component;
88
119
  return key === void 0 ? "scope" : String(key);
89
120
  }
90
- function buildNode(scope, key) {
121
+ function buildNode(scope, key, seen) {
122
+ if (scope.disposed || seen.has(scope)) return null;
123
+ seen.add(scope);
91
124
  const id = idOf(scope);
92
125
  idIndex.set(id, scope);
126
+ const children = [];
127
+ if (scope.children !== null) {
128
+ for (const child of scope.children) {
129
+ const node = buildNode(child.scope, child.key, seen);
130
+ if (node !== null) children.push(node);
131
+ }
132
+ }
133
+ childWalker?.(scope, (child) => {
134
+ const node = buildNode(child, void 0, seen);
135
+ if (node !== null) children.push(node);
136
+ });
93
137
  return {
94
138
  id,
95
139
  name: nameOf(scope, key),
96
140
  kind: scope.kind ?? "component",
97
- children: scope.children === null ? [] : scope.children.map((c) => buildNode(c.scope, c.key))
141
+ children
98
142
  };
99
143
  }
100
144
  const hook = {
101
145
  version: DEVTOOLS_HOOK_VERSION,
102
146
  getTree() {
103
147
  idIndex = /* @__PURE__ */ new Map();
104
- return [...roots].map((r) => buildNode(r, void 0));
148
+ const seen = /* @__PURE__ */ new Set();
149
+ const nodes = [];
150
+ for (const root of roots) {
151
+ const node = buildNode(root, void 0, seen);
152
+ if (node !== null) nodes.push(node);
153
+ }
154
+ return nodes;
105
155
  },
106
156
  inspect(id) {
107
157
  const scope = idIndex.get(id);
108
- if (scope === void 0) return null;
158
+ if (scope === void 0 || scope.disposed) return null;
109
159
  const hooks = [];
110
160
  if (scope.hooks) {
111
161
  for (const cell of scope.hooks.values()) {
@@ -122,13 +172,23 @@ const hook = {
122
172
  });
123
173
  }
124
174
  }
125
- return {
175
+ const detail = {
126
176
  id,
127
177
  name: nameOf(scope, void 0),
128
178
  hooks,
129
179
  context,
130
180
  effectCount: scope.effectSlots ? scope.effectSlots.length : 0
131
181
  };
182
+ const native = nativeReadInspector?.(scope);
183
+ if (native !== void 0 && native !== null) {
184
+ detail.nativeReads = {
185
+ ownerId: idOf(native.block),
186
+ committed: native.committed,
187
+ pending: native.pending,
188
+ retry: native.retry
189
+ };
190
+ }
191
+ return detail;
132
192
  },
133
193
  subscribe(listener) {
134
194
  subscribers.add(listener);
@@ -153,12 +213,19 @@ function installDevtoolsGlobal() {
153
213
  function __devtoolsSetNameResolver(fn) {
154
214
  nameResolver = fn;
155
215
  }
216
+ function __devtoolsSetChildWalker(walk) {
217
+ childWalker = walk;
218
+ }
219
+ function __devtoolsSetNativeReadInspector(inspect) {
220
+ nativeReadInspector = inspect;
221
+ }
156
222
  function __devtoolsRegisterRoot(root) {
157
223
  roots.add(root);
158
224
  installDevtoolsGlobal();
159
225
  }
160
226
  function __devtoolsUnregisterRoot(root) {
161
227
  roots.delete(root);
228
+ hook.getTree();
162
229
  }
163
230
  function __devtoolsNotifyFlush() {
164
231
  if (subscribers.size === 0) return;
@@ -187,7 +254,9 @@ function __devtoolsClearBoundary(slot) {
187
254
  __devtoolsNotifyFlush,
188
255
  __devtoolsRegisterRoot,
189
256
  __devtoolsSetBoundaryState,
257
+ __devtoolsSetChildWalker,
190
258
  __devtoolsSetNameResolver,
259
+ __devtoolsSetNativeReadInspector,
191
260
  __devtoolsSetTransitionCount,
192
261
  __devtoolsUnregisterRoot,
193
262
  installDevtoolsGlobal
@@ -194,6 +194,8 @@ function formatClientError(code, ...args) {
194
194
  "Hydration mismatch: the server rendered more list items than the client; the extra server items were discarded.",
195
195
  args
196
196
  );
197
+ case 58:
198
+ return (0, import_error_message.formatDevErrorMessage)("Unsupported native-read compiler/runtime version.", args);
197
199
  default:
198
200
  return (0, import_error_message.formatUnknownDevErrorMessage)(code);
199
201
  }
@@ -140,6 +140,10 @@ function formatServerError(code, ...args) {
140
140
  "prerenderToNodeStream requires a Node.js runtime with process.getBuiltinModule; use prerender() in non-Node environments.",
141
141
  args
142
142
  );
143
+ case 58:
144
+ return (0, import_error_message.formatDevErrorMessage)("Unsupported native-read compiler/runtime version.", args);
145
+ case 59:
146
+ return (0, import_error_message.formatDevErrorMessage)("%s requires an active server component.", args);
143
147
  default:
144
148
  return (0, import_error_message.formatUnknownDevErrorMessage)(code);
145
149
  }
@@ -0,0 +1,31 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var client_exports = {};
21
+ __export(client_exports, {
22
+ __s: () => import_runtime.markSingleRoot
23
+ });
24
+ module.exports = __toCommonJS(client_exports);
25
+ __reExport(client_exports, require("../runtime.cjs"), module.exports);
26
+ var import_runtime = require("../runtime.cjs");
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ __s,
30
+ ...require("../runtime.cjs")
31
+ });
@@ -0,0 +1,22 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var server_exports = {};
17
+ module.exports = __toCommonJS(server_exports);
18
+ __reExport(server_exports, require("../runtime.server.cjs"), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require("../runtime.server.cjs")
22
+ });
@@ -23,6 +23,7 @@ __export(profiling_exports, {
23
23
  __profileComponent: () => __profileComponent,
24
24
  __profileComponentSource: () => __profileComponentSource,
25
25
  __profileEndRender: () => __profileEndRender,
26
+ __profileGetComponent: () => __profileGetComponent,
26
27
  __profileHasComponentMetadata: () => __profileHasComponentMetadata,
27
28
  __profileHook: () => __profileHook,
28
29
  __profileResolveHook: () => __profileResolveHook,
@@ -211,6 +212,9 @@ function __profileTrackComponent(subject, component) {
211
212
  if (component === null) trackedComponents.delete(subject);
212
213
  else trackedComponents.set(subject, component);
213
214
  }
215
+ function __profileGetComponent(subject) {
216
+ return trackedComponents.get(subject);
217
+ }
214
218
  function __profileSchedule(subject, type, slot) {
215
219
  if (!active) return;
216
220
  let entry = pending.get(subject);
@@ -453,6 +457,7 @@ const profiler = {
453
457
  __profileComponent,
454
458
  __profileComponentSource,
455
459
  __profileEndRender,
460
+ __profileGetComponent,
456
461
  __profileHasComponentMetadata,
457
462
  __profileHook,
458
463
  __profileResolveHook,