octane 0.4.2 → 0.4.3
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.
- package/dist/cjs/context-identity.cjs +29 -0
- package/dist/cjs/dom-stage.cjs +24 -18
- package/dist/cjs/error-codes.server.generated.cjs +5 -0
- package/dist/cjs/hydration-markers.cjs +12 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/runtime.cjs +253 -393
- package/dist/cjs/runtime.server.cjs +137 -35
- package/dist/cjs/server/index.cjs +2 -0
- package/dist/cjs/server/streamed-signals.cjs +41 -9
- package/dist/cjs/signals/client.cjs +1 -6
- package/dist/cjs/signals/engine.cjs +1 -12
- package/dist/cjs/version.cjs +1 -1
- package/dist/compiler/client-only-server.js +1 -28
- package/dist/compiler/compile-renderer-boundaries.js +1 -22
- package/dist/compiler/compile-universal.js +1 -22
- package/dist/compiler/compile.js +782 -359
- package/dist/compiler/dom-binding-fixed-props.js +11 -1
- package/dist/compiler/generated-origin.js +46 -0
- package/dist/compiler/hydrate-boundaries.js +88 -52
- package/dist/compiler/plain-hook-memo.js +5 -1
- package/dist/compiler/pure-factories.js +66 -0
- package/dist/compiler/register.js +4 -1
- package/dist/compiler/slot-hooks.js +113 -186
- package/dist/compiler/typescript-lowering.js +763 -0
- package/dist/compiler/void-roots.js +239 -0
- package/dist/compiler/volar.js +91 -38
- package/dist/context-identity.d.ts +14 -0
- package/dist/context-identity.js +28 -0
- package/dist/dom-stage.js +24 -18
- package/dist/error-codes.server.generated.d.ts +1 -0
- package/dist/error-codes.server.generated.js +5 -0
- package/dist/hydration/idle.js +1 -0
- package/dist/hydration/independent-island.js +53 -2
- package/dist/hydration/media.js +1 -0
- package/dist/hydration/types.d.ts +5 -0
- package/dist/hydration/visible.js +1 -0
- package/dist/hydration-markers.d.ts +8 -0
- package/dist/hydration-markers.js +8 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/runtime.d.ts +25 -40
- package/dist/runtime.js +254 -398
- package/dist/runtime.server.d.ts +23 -2
- package/dist/runtime.server.js +142 -36
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/streamed-signals.js +41 -9
- package/dist/signals/client.js +3 -8
- package/dist/signals/engine.d.ts +0 -2
- package/dist/signals/engine.js +1 -13
- package/dist/universal-core.js +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/signals/diagnostic-local-hook.cjs +0 -37
- package/dist/compiler/local-void-roots.js +0 -154
- package/dist/signals/diagnostic-local-hook.d.ts +0 -8
- package/dist/signals/diagnostic-local-hook.js +0 -12
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createLexicalAnalysis,
|
|
3
|
-
forEachRuntimeAstChild,
|
|
4
|
-
isIdentifierReference,
|
|
5
|
-
} from './compile-universal.js';
|
|
6
|
-
import { collectReassignedBindings } from './hook-deps.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Find factory callees whose entire local lifetime uses compiled-void bodies.
|
|
10
|
-
* Definition IDs come from the authored, exact shorthand declarations: arrow
|
|
11
|
-
* normalization and return-JSX lowering cannot manufacture this evidence.
|
|
12
|
-
* This pass only reads ASTs. Its caller owns the COW rewrite and helper import.
|
|
13
|
-
*/
|
|
14
|
-
export function findLocalVoidRootCallees(ast, definitions, components) {
|
|
15
|
-
const imports = new Map();
|
|
16
|
-
for (const statement of ast.body) {
|
|
17
|
-
if (
|
|
18
|
-
statement.type !== 'ImportDeclaration' ||
|
|
19
|
-
statement.source?.value !== 'octane' ||
|
|
20
|
-
statement.importKind === 'type'
|
|
21
|
-
)
|
|
22
|
-
continue;
|
|
23
|
-
for (const specifier of statement.specifiers) {
|
|
24
|
-
if (
|
|
25
|
-
specifier.type === 'ImportSpecifier' &&
|
|
26
|
-
specifier.importKind !== 'type' &&
|
|
27
|
-
['createRoot', 'hydrateRoot'].includes(specifier.imported.name ?? specifier.imported.value)
|
|
28
|
-
)
|
|
29
|
-
imports.set(specifier.local.name, specifier.imported.name ?? specifier.imported.value);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// Ordinary component modules pay no lexical-analysis cost.
|
|
33
|
-
if (imports.size === 0 || definitions.size === 0) return new Map();
|
|
34
|
-
const analysis = createLexicalAnalysis(ast);
|
|
35
|
-
const writes = collectReassignedBindings(ast);
|
|
36
|
-
const stableComponents = new Set();
|
|
37
|
-
for (const id of definitions) if (!writes.has(id)) stableComponents.add(id.name);
|
|
38
|
-
if (stableComponents.size === 0) return new Map();
|
|
39
|
-
const moduleBinding = (node, names) =>
|
|
40
|
-
node?.type === 'Identifier' &&
|
|
41
|
-
names.has(node.name) &&
|
|
42
|
-
analysis.resolveBinding(analysis.nodeScopes.get(node), node.name)?.scope === analysis.rootScope;
|
|
43
|
-
const functionScopes = new Set();
|
|
44
|
-
const roots = new Map();
|
|
45
|
-
let opaque = false;
|
|
46
|
-
const discover = (node, parent, key, component = false) => {
|
|
47
|
-
if (node === null || typeof node !== 'object') return;
|
|
48
|
-
if (node.type === 'JSXCodeBlock' || components.has(node)) component = true;
|
|
49
|
-
if (
|
|
50
|
-
!component &&
|
|
51
|
-
(node.type === 'FunctionDeclaration' ||
|
|
52
|
-
node.type === 'FunctionExpression' ||
|
|
53
|
-
node.type === 'ArrowFunctionExpression') &&
|
|
54
|
-
node.body?.type === 'BlockStatement'
|
|
55
|
-
)
|
|
56
|
-
functionScopes.add(analysis.nodeScopes.get(node.body)?.functionScope);
|
|
57
|
-
if (
|
|
58
|
-
node.type === 'WithStatement' ||
|
|
59
|
-
(node.type === 'Identifier' &&
|
|
60
|
-
node.name === 'eval' &&
|
|
61
|
-
isIdentifierReference(node, parent, key, analysis) &&
|
|
62
|
-
analysis.resolveBinding(analysis.nodeScopes.get(node), 'eval') === null)
|
|
63
|
-
)
|
|
64
|
-
opaque = true;
|
|
65
|
-
if (
|
|
66
|
-
!component &&
|
|
67
|
-
node.type === 'VariableDeclarator' &&
|
|
68
|
-
parent?.type === 'VariableDeclaration' &&
|
|
69
|
-
parent.kind === 'const' &&
|
|
70
|
-
node.id?.type === 'Identifier' &&
|
|
71
|
-
node.init?.type === 'CallExpression' &&
|
|
72
|
-
node.init.optional !== true &&
|
|
73
|
-
moduleBinding(node.init.callee, imports)
|
|
74
|
-
) {
|
|
75
|
-
const scope = analysis.resolveBinding(analysis.nodeScopes.get(node.id), node.id.name)?.scope;
|
|
76
|
-
// Namespace and class-static scopes are not ordinary function bodies.
|
|
77
|
-
if (scope && functionScopes.has(scope.functionScope)) {
|
|
78
|
-
const hydrated = imports.get(node.init.callee.name) === 'hydrateRoot';
|
|
79
|
-
// Hydration renders immediately: its bare initial target must satisfy
|
|
80
|
-
// the same definition and binding proof as every later render.
|
|
81
|
-
const validInitial =
|
|
82
|
-
!hydrated ||
|
|
83
|
-
(node.init.arguments.length >= 2 &&
|
|
84
|
-
node.init.arguments.length <= 4 &&
|
|
85
|
-
!node.init.arguments.some((argument) => argument.type === 'SpreadElement') &&
|
|
86
|
-
moduleBinding(node.init.arguments[1], stableComponents));
|
|
87
|
-
if (validInitial) {
|
|
88
|
-
let names = roots.get(scope);
|
|
89
|
-
if (names === undefined) roots.set(scope, (names = new Map()));
|
|
90
|
-
names.set(node.id.name, {
|
|
91
|
-
scope,
|
|
92
|
-
callee: node.init.callee,
|
|
93
|
-
helper: hydrated ? '__hydrateVoidRoot' : '__createVoidRoot',
|
|
94
|
-
valid: true,
|
|
95
|
-
// A proved hydration target counts even with cleanup-only later uses.
|
|
96
|
-
renders: hydrated ? 1 : 0,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
forEachRuntimeAstChild(node, (child, childKey) => discover(child, node, childKey, component));
|
|
102
|
-
};
|
|
103
|
-
discover(ast);
|
|
104
|
-
if (opaque || roots.size === 0) return new Map();
|
|
105
|
-
const inspect = (node, parent, key, grandparent) => {
|
|
106
|
-
if (node === null || typeof node !== 'object') return;
|
|
107
|
-
if (node.type === 'Identifier' && isIdentifierReference(node, parent, key, analysis)) {
|
|
108
|
-
const nodeScope = analysis.nodeScopes.get(node);
|
|
109
|
-
// Runtime traversal may see syntax the lexical analysis has not scoped.
|
|
110
|
-
// An unresolved possible root reference cannot certify a closed lifetime.
|
|
111
|
-
if (nodeScope === undefined) {
|
|
112
|
-
for (const names of roots.values()) {
|
|
113
|
-
const root = names.get(node.name);
|
|
114
|
-
if (root !== undefined) root.valid = false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const scope = analysis.resolveBinding(nodeScope, node.name)?.scope;
|
|
118
|
-
const root = roots.get(scope)?.get(node.name);
|
|
119
|
-
if (root !== undefined) {
|
|
120
|
-
const member = parent;
|
|
121
|
-
const call = grandparent;
|
|
122
|
-
const method =
|
|
123
|
-
analysis.nodeScopes.get(node) === root.scope &&
|
|
124
|
-
member?.type === 'MemberExpression' &&
|
|
125
|
-
key === 'object' &&
|
|
126
|
-
member.computed !== true &&
|
|
127
|
-
member.optional !== true &&
|
|
128
|
-
member.property?.type === 'Identifier' &&
|
|
129
|
-
call?.type === 'CallExpression' &&
|
|
130
|
-
call.callee === member &&
|
|
131
|
-
call.optional !== true;
|
|
132
|
-
if (method && member.property.name === 'unmount' && call.arguments.length === 0) {
|
|
133
|
-
// Cleanup does not widen the component return ABI.
|
|
134
|
-
} else if (
|
|
135
|
-
method &&
|
|
136
|
-
member.property.name === 'render' &&
|
|
137
|
-
call.arguments.length >= 1 &&
|
|
138
|
-
call.arguments.length <= 2 &&
|
|
139
|
-
!call.arguments.some((argument) => argument.type === 'SpreadElement') &&
|
|
140
|
-
moduleBinding(call.arguments[0], stableComponents)
|
|
141
|
-
)
|
|
142
|
-
root.renders++;
|
|
143
|
-
else root.valid = false;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
forEachRuntimeAstChild(node, (child, childKey) => inspect(child, node, childKey, parent));
|
|
147
|
-
};
|
|
148
|
-
inspect(ast);
|
|
149
|
-
const callees = new Map();
|
|
150
|
-
for (const names of roots.values())
|
|
151
|
-
for (const root of names.values())
|
|
152
|
-
if (root.valid && root.renders > 0) callees.set(root.callee, root.helper);
|
|
153
|
-
return callees;
|
|
154
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
declare const DIAGNOSTIC_SIGNAL_INITIALIZER: unique symbol;
|
|
2
|
-
export type DiagnosticSignalInitializer<T> = (() => T) & {
|
|
3
|
-
readonly [DIAGNOSTIC_SIGNAL_INITIALIZER]: true;
|
|
4
|
-
};
|
|
5
|
-
/** @internal Private built-in useSignal$ adapter; not a public native-hook resource factory. */
|
|
6
|
-
export declare function createNativeSignalDiagnosticInitializer<T>(initialize: () => T): DiagnosticSignalInitializer<T>;
|
|
7
|
-
export declare function isNativeSignalDiagnosticInitializer(value: () => unknown): boolean;
|
|
8
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const DIAGNOSTIC_SIGNAL_INITIALIZERS = /* @__PURE__ */ new WeakSet();
|
|
2
|
-
function createNativeSignalDiagnosticInitializer(initialize) {
|
|
3
|
-
DIAGNOSTIC_SIGNAL_INITIALIZERS.add(initialize);
|
|
4
|
-
return initialize;
|
|
5
|
-
}
|
|
6
|
-
function isNativeSignalDiagnosticInitializer(value) {
|
|
7
|
-
return DIAGNOSTIC_SIGNAL_INITIALIZERS.has(value);
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
createNativeSignalDiagnosticInitializer,
|
|
11
|
-
isNativeSignalDiagnosticInitializer
|
|
12
|
-
};
|