octane 0.6.2 → 0.7.0
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/constants.cjs +3 -0
- package/dist/cjs/dom-binding-handoff.cjs +2 -1
- package/dist/cjs/dom-binding-protocol.cjs +4 -3
- package/dist/cjs/dom-binding-styles.cjs +3 -2
- package/dist/cjs/dom-bindings.cjs +24 -23
- package/dist/cjs/error-codes.client.generated.cjs +7 -1
- package/dist/cjs/error-codes.server.generated.cjs +27 -1
- package/dist/cjs/hydration/event-capture.cjs +2 -1
- package/dist/cjs/independent-hydration-protocol.cjs +3 -2
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/runtime.cjs +866 -370
- package/dist/cjs/runtime.server.cjs +250 -62
- package/dist/cjs/server/index.cjs +2 -0
- package/dist/cjs/server/rpc-stream.cjs +19 -12
- package/dist/cjs/server/streamed-signals.cjs +18 -1
- package/dist/cjs/shared-value-helpers.cjs +24 -2
- package/dist/cjs/signals/control-binding.cjs +7 -6
- package/dist/cjs/signals/derived-facade.cjs +2 -1
- package/dist/cjs/signals/document-owner.cjs +4 -3
- package/dist/cjs/signals/facade.cjs +10 -9
- package/dist/cjs/signals/graph.cjs +5 -4
- package/dist/cjs/signals/native-read-client.cjs +4 -3
- package/dist/cjs/signals/owner-context.cjs +4 -3
- package/dist/cjs/signals/query-attempt-observer.cjs +2 -1
- package/dist/cjs/signals/query-facade.cjs +2 -1
- package/dist/cjs/signals/scalar-computations.cjs +2 -1
- package/dist/cjs/signals/transition-action.cjs +10 -9
- package/dist/cjs/signals/transition-candidate.cjs +2 -1
- package/dist/cjs/version.cjs +1 -1
- package/dist/compiler/arm-exits.js +151 -0
- package/dist/compiler/compile-universal.js +262 -65
- package/dist/compiler/compile.js +1929 -306
- package/dist/compiler/deferred-snapshots.js +791 -0
- package/dist/compiler/strong-mode.js +59 -10
- package/dist/constants.d.ts +5 -1
- package/dist/constants.js +2 -0
- package/dist/error-codes.client.generated.d.ts +1 -0
- package/dist/error-codes.client.generated.js +5 -0
- package/dist/error-codes.server.generated.d.ts +5 -0
- package/dist/error-codes.server.generated.js +25 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/node/aria-diagnostics.js +92 -0
- package/dist/node/behavior-form-submissions.js +228 -0
- package/dist/node/behavior-root-types.js +0 -0
- package/dist/node/behavior-root.js +746 -0
- package/dist/node/class-names.js +25 -0
- package/dist/node/compatibility.js +10 -0
- package/dist/node/component-flags.js +23 -0
- package/dist/node/constants.js +115 -0
- package/dist/node/context-epoch.js +13 -0
- package/dist/node/context-identity.js +46 -0
- package/dist/node/css.js +80 -0
- package/dist/node/data-encoding.js +134 -0
- package/dist/node/devtools-hook.js +229 -0
- package/dist/node/dom-binding-claims.js +4 -0
- package/dist/node/dom-binding-classes.js +152 -0
- package/dist/node/dom-binding-controls.js +6 -0
- package/dist/node/dom-binding-handoff.js +77 -0
- package/dist/node/dom-binding-program.js +1617 -0
- package/dist/node/dom-binding-projections.js +204 -0
- package/dist/node/dom-binding-protocol.js +130 -0
- package/dist/node/dom-binding-signals.js +135 -0
- package/dist/node/dom-binding-styles.js +280 -0
- package/dist/node/dom-bindings.js +1087 -0
- package/dist/node/dom-focused-move.js +46 -0
- package/dist/node/dom-stage.js +878 -0
- package/dist/node/dom-tables.js +382 -0
- package/dist/node/error-codes.client.generated.js +1071 -0
- package/dist/node/error-codes.server.generated.js +761 -0
- package/dist/node/error-message.js +27 -0
- package/dist/node/event-names.js +15 -0
- package/dist/node/form-diagnostics.js +96 -0
- package/dist/node/form-submission.js +43 -0
- package/dist/node/has-own.js +4 -0
- package/dist/node/head-ownership.js +31 -0
- package/dist/node/hook-slot-cache.js +91 -0
- package/dist/node/host-property-diagnostics.js +189 -0
- package/dist/node/html-tree-validation.js +193 -0
- package/dist/node/hydration/condition.js +15 -0
- package/dist/node/hydration/control-capture.js +237 -0
- package/dist/node/hydration/document-lifecycle.js +89 -0
- package/dist/node/hydration/event-capture.js +362 -0
- package/dist/node/hydration/idle.js +23 -0
- package/dist/node/hydration/independent-island.js +317 -0
- package/dist/node/hydration/index.js +74 -0
- package/dist/node/hydration/interaction-config.js +61 -0
- package/dist/node/hydration/interaction.js +35 -0
- package/dist/node/hydration/load.js +15 -0
- package/dist/node/hydration/media.js +33 -0
- package/dist/node/hydration/native-intent.js +68 -0
- package/dist/node/hydration/never.js +12 -0
- package/dist/node/hydration/stream-delivery.js +345 -0
- package/dist/node/hydration/stream-receiver.js +190 -0
- package/dist/node/hydration/stream-result-receiver.js +276 -0
- package/dist/node/hydration/streamed-signals.js +186 -0
- package/dist/node/hydration/types.js +0 -0
- package/dist/node/hydration/visible.js +69 -0
- package/dist/node/hydration-markers.js +44 -0
- package/dist/node/independent-hydration-protocol.js +91 -0
- package/dist/node/index.js +463 -0
- package/dist/node/internal/client.js +7 -0
- package/dist/node/internal/context.js +5 -0
- package/dist/node/internal/server.js +5 -0
- package/dist/node/internal/signal-read.js +4 -0
- package/dist/node/method-dep.js +25 -0
- package/dist/node/profiling.js +432 -0
- package/dist/node/public-types.js +0 -0
- package/dist/node/react/fiber-adapter.js +57 -0
- package/dist/node/react/index.js +397 -0
- package/dist/node/react/react-compat-envelope.js +78 -0
- package/dist/node/react/react-compat-server.js +129 -0
- package/dist/node/react/react-compat-shared.js +104 -0
- package/dist/node/react/react-compat.js +223 -0
- package/dist/node/react/server.js +81 -0
- package/dist/node/react/shared.js +75 -0
- package/dist/node/renderer-bridge.js +35 -0
- package/dist/node/resize-observer.js +105 -0
- package/dist/node/resource-hint-diagnostics.js +67 -0
- package/dist/node/runtime-tags.js +22 -0
- package/dist/node/runtime.js +29364 -0
- package/dist/node/runtime.server.js +8200 -0
- package/dist/node/sanitize-url.js +34 -0
- package/dist/node/server/early-signals.js +54 -0
- package/dist/node/server/index.js +338 -0
- package/dist/node/server/rpc-batch.js +129 -0
- package/dist/node/server/rpc-stream.js +132 -0
- package/dist/node/server/rpc.js +48 -0
- package/dist/node/server/signal-query-observation.js +134 -0
- package/dist/node/server/streamed-region.js +31 -0
- package/dist/node/server/streamed-signals.js +574 -0
- package/dist/node/server-call.js +75 -0
- package/dist/node/server-rpc-batch-client.js +119 -0
- package/dist/node/server-rpc-client.js +108 -0
- package/dist/node/server-rpc-protocol.js +109 -0
- package/dist/node/server-rpc-stream-client.js +98 -0
- package/dist/node/shared-value-helpers.js +60 -0
- package/dist/node/signals/actions.js +463 -0
- package/dist/node/signals/client.js +22 -0
- package/dist/node/signals/computations.js +452 -0
- package/dist/node/signals/control-binding.js +388 -0
- package/dist/node/signals/control-handoff.js +12 -0
- package/dist/node/signals/derived-facade.js +25 -0
- package/dist/node/signals/document-owner.js +48 -0
- package/dist/node/signals/early-values.js +124 -0
- package/dist/node/signals/encoding.js +6 -0
- package/dist/node/signals/engine.js +668 -0
- package/dist/node/signals/errors.js +54 -0
- package/dist/node/signals/facade.js +441 -0
- package/dist/node/signals/graph.js +817 -0
- package/dist/node/signals/handle-protocol.js +11 -0
- package/dist/node/signals/index.js +87 -0
- package/dist/node/signals/native-read-client.js +319 -0
- package/dist/node/signals/native-read-collector.js +132 -0
- package/dist/node/signals/native-read-events.js +45 -0
- package/dist/node/signals/native-read-inspection.js +20 -0
- package/dist/node/signals/native-read-retry.js +30 -0
- package/dist/node/signals/native-read-seeds.js +243 -0
- package/dist/node/signals/native-read-server.js +99 -0
- package/dist/node/signals/owner-context.js +88 -0
- package/dist/node/signals/query-attempt-observer.js +42 -0
- package/dist/node/signals/query-facade.js +41 -0
- package/dist/node/signals/read-protocol.js +125 -0
- package/dist/node/signals/requests.js +716 -0
- package/dist/node/signals/scalar-computations.js +57 -0
- package/dist/node/signals/scope-streams.js +147 -0
- package/dist/node/signals/server.js +22 -0
- package/dist/node/signals/transition-action.js +555 -0
- package/dist/node/signals/transition-candidate.js +101 -0
- package/dist/node/signals/transition-coordinator.js +255 -0
- package/dist/node/signals/transition-state.js +82 -0
- package/dist/node/signals/types.js +20 -0
- package/dist/node/static/index.js +10 -0
- package/dist/node/stream-protocol.js +114 -0
- package/dist/node/streamed-signals-protocol.js +130 -0
- package/dist/node/style-values.js +96 -0
- package/dist/node/sub-slot.js +35 -0
- package/dist/node/testing.js +14 -0
- package/dist/node/trusted-html.js +6 -0
- package/dist/node/tsrx-iterable.js +5 -0
- package/dist/node/tsrx-spread.js +10 -0
- package/dist/node/universal-core.js +10138 -0
- package/dist/node/universal-dom-boundary.js +237 -0
- package/dist/node/universal-native.js +28 -0
- package/dist/node/universal.js +17 -0
- package/dist/node/version.js +4 -0
- package/dist/runtime.d.ts +219 -8
- package/dist/runtime.js +714 -220
- package/dist/runtime.server.d.ts +33 -2
- package/dist/runtime.server.js +217 -29
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/rpc-stream.js +19 -12
- package/dist/server/streamed-signals.js +18 -1
- package/dist/shared-value-helpers.d.ts +11 -0
- package/dist/shared-value-helpers.js +21 -1
- package/dist/universal-core.d.ts +3 -1
- package/dist/universal-core.js +178 -50
- package/dist/version.js +1 -1
- package/package.json +62 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The directive-arm exit contract, shared by the DOM and universal compilers so
|
|
3
|
+
* an arm means the same thing on every renderer.
|
|
4
|
+
*
|
|
5
|
+
* An arm (an @if/@else, @switch case, @try/@pending/@catch, or @for/@empty
|
|
6
|
+
* body) renders the node it ends with. `return;`, `return null;`, and a
|
|
7
|
+
* `continue;` that no inner loop owns end the arm early from anywhere in its
|
|
8
|
+
* setup. A value return has nothing to render in the node's place, and a
|
|
9
|
+
* `break` that targets the directive has no loop to leave in the compiled arm,
|
|
10
|
+
* so both are compile errors. Each compiler walks an arm's setup itself,
|
|
11
|
+
* stopping at nested functions, templates, and directives, which own their
|
|
12
|
+
* jumps, and lowers an exit to its own arm shape.
|
|
13
|
+
*
|
|
14
|
+
* A `@{ … }` child block is a nested template with its own render scope, not
|
|
15
|
+
* an arm, even as an arm's output: nothing ends it early, and the parser
|
|
16
|
+
* already rejects `return` in one. Every target compiles the block apart from
|
|
17
|
+
* the statements around it, so assertTemplateJumps rejects any `break` or
|
|
18
|
+
* `continue` that would leave a block, and a labeled one that would leave an
|
|
19
|
+
* arm, once on the authored module ahead of every compiler.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export const ARM_VALUE_RETURN_MESSAGE =
|
|
23
|
+
'A directive arm can only end early with `return;` or `return null;`. Its output is ' +
|
|
24
|
+
'the node it ends with, so a returned value has nothing to render in its place: ' +
|
|
25
|
+
'render the alternative from an `@if`/`@else` arm instead.';
|
|
26
|
+
|
|
27
|
+
export const ARM_BREAK_MESSAGE =
|
|
28
|
+
'`break` cannot leave the `@for` or `@switch` around a directive arm. End the arm ' +
|
|
29
|
+
'early with `return;` instead, or filter the `@for` items to stop the list early.';
|
|
30
|
+
|
|
31
|
+
export const ARM_LABEL_MESSAGE =
|
|
32
|
+
'A labeled `break` or `continue` cannot leave a directive arm: an arm can only jump to ' +
|
|
33
|
+
'a loop, `switch`, or label inside it. End the arm early with `return;` instead.';
|
|
34
|
+
|
|
35
|
+
export const BLOCK_JUMP_MESSAGE =
|
|
36
|
+
'`break` and `continue` cannot leave a `@{ … }` block. A block is a nested template, ' +
|
|
37
|
+
'not a directive arm, so it has no early exit: skip an `@for` row with `continue;` in ' +
|
|
38
|
+
"the row's setup before its output, or render the part to leave out from an `@if` arm.";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* How a jump statement relates to the arm whose setup holds it: 'exit' ends
|
|
42
|
+
* the arm, 'value' (a value return) and 'break' (one that targets the
|
|
43
|
+
* directive) have no arm meaning, and null stays JavaScript. `loop` and
|
|
44
|
+
* `breakable` say whether an unlabeled `continue`/`break` here targets a loop
|
|
45
|
+
* or `switch` inside the arm. A labeled jump targets a label inside it, since
|
|
46
|
+
* assertTemplateJumps rejects one that leaves the arm.
|
|
47
|
+
*/
|
|
48
|
+
export function armJump(node, loop, breakable) {
|
|
49
|
+
switch (node.type) {
|
|
50
|
+
case 'ReturnStatement':
|
|
51
|
+
return node.argument == null ||
|
|
52
|
+
(node.argument.type === 'Literal' && node.argument.value === null)
|
|
53
|
+
? 'exit'
|
|
54
|
+
: 'value';
|
|
55
|
+
case 'ContinueStatement':
|
|
56
|
+
return node.label == null && !loop ? 'exit' : null;
|
|
57
|
+
case 'BreakStatement':
|
|
58
|
+
return node.label == null && !breakable ? 'break' : null;
|
|
59
|
+
default:
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const WALK_SKIP_KEYS = new Set(['type', 'loc', 'start', 'end', 'range', 'metadata', 'parent']);
|
|
65
|
+
const DIRECTIVE_TYPES = new Set([
|
|
66
|
+
'JSXIfExpression',
|
|
67
|
+
'JSXForExpression',
|
|
68
|
+
'JSXSwitchExpression',
|
|
69
|
+
'JSXTryExpression',
|
|
70
|
+
]);
|
|
71
|
+
const FUNCTION_TYPES = new Set([
|
|
72
|
+
'FunctionDeclaration',
|
|
73
|
+
'FunctionExpression',
|
|
74
|
+
'ArrowFunctionExpression',
|
|
75
|
+
'StaticBlock',
|
|
76
|
+
]);
|
|
77
|
+
const LOOP_TYPES = new Set([
|
|
78
|
+
'ForStatement',
|
|
79
|
+
'ForOfStatement',
|
|
80
|
+
'ForInStatement',
|
|
81
|
+
'WhileStatement',
|
|
82
|
+
'DoWhileStatement',
|
|
83
|
+
]);
|
|
84
|
+
|
|
85
|
+
// The template region a statement sits in. Outside every template, jumps are
|
|
86
|
+
// ordinary JavaScript and the parser resolves them.
|
|
87
|
+
const OUTSIDE = 0;
|
|
88
|
+
const ARM = 1;
|
|
89
|
+
const BLOCK = 2;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Reject each `break` or `continue` that targets a statement outside the
|
|
93
|
+
* `@{ … }` block, or (when labeled) the directive arm, whose setup holds it.
|
|
94
|
+
* The parser resolves jumps lexically, so it accepts these, but every target
|
|
95
|
+
* compiles a block or arm apart from the statements around it and would emit
|
|
96
|
+
* a module that fails to load. An arm's unlabeled jumps are its exits, which
|
|
97
|
+
* each compiler lowers or rejects (see armJump). Runs once per module, on the
|
|
98
|
+
* authored AST, for every target.
|
|
99
|
+
*/
|
|
100
|
+
export function assertTemplateJumps(ast, source, filename) {
|
|
101
|
+
// A module without a jump, or without a block or directive, has nothing to check.
|
|
102
|
+
if (!/\b(?:break|continue)\b/.test(source) || !/@(?:\{|(?:if|for|switch|try)\b)/.test(source)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const file = filename.split(/[\\/]/).pop();
|
|
106
|
+
const visit = (node, region, loop, breakable, labels) => {
|
|
107
|
+
if (Array.isArray(node)) {
|
|
108
|
+
for (const child of node) {
|
|
109
|
+
if (child !== null && typeof child === 'object') {
|
|
110
|
+
visit(child, region, loop, breakable, labels);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const type = node.type;
|
|
116
|
+
if (type === 'JSXCodeBlock') {
|
|
117
|
+
if (node.body) visit(node.body, BLOCK, false, false, null);
|
|
118
|
+
if (node.render) visit(node.render, OUTSIDE, false, false, null);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if ((type === 'ContinueStatement' || type === 'BreakStatement') && region !== OUTSIDE) {
|
|
122
|
+
const leaves =
|
|
123
|
+
node.label != null
|
|
124
|
+
? !labels?.has(node.label.name)
|
|
125
|
+
: region === BLOCK && !(type === 'ContinueStatement' ? loop : breakable);
|
|
126
|
+
if (leaves) {
|
|
127
|
+
const at = node.loc ? ` (${file}:${node.loc.start.line}:${node.loc.start.column})` : '';
|
|
128
|
+
throw new Error((region === BLOCK ? BLOCK_JUMP_MESSAGE : ARM_LABEL_MESSAGE) + at);
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (FUNCTION_TYPES.has(type) || DIRECTIVE_TYPES.has(type)) {
|
|
133
|
+
region = DIRECTIVE_TYPES.has(type) ? ARM : OUTSIDE;
|
|
134
|
+
loop = breakable = false;
|
|
135
|
+
labels = null;
|
|
136
|
+
} else if (LOOP_TYPES.has(type)) {
|
|
137
|
+
loop = breakable = true;
|
|
138
|
+
} else if (type === 'SwitchStatement') {
|
|
139
|
+
breakable = true;
|
|
140
|
+
} else if (type === 'LabeledStatement') {
|
|
141
|
+
labels = new Set(labels).add(node.label.name);
|
|
142
|
+
}
|
|
143
|
+
for (const key in node) {
|
|
144
|
+
if (WALK_SKIP_KEYS.has(key)) continue;
|
|
145
|
+
const child = node[key];
|
|
146
|
+
if (child !== null && typeof child === 'object')
|
|
147
|
+
visit(child, region, loop, breakable, labels);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
visit(ast, OUTSIDE, false, false, null);
|
|
151
|
+
}
|