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.
Files changed (200) hide show
  1. package/dist/cjs/constants.cjs +3 -0
  2. package/dist/cjs/dom-binding-handoff.cjs +2 -1
  3. package/dist/cjs/dom-binding-protocol.cjs +4 -3
  4. package/dist/cjs/dom-binding-styles.cjs +3 -2
  5. package/dist/cjs/dom-bindings.cjs +24 -23
  6. package/dist/cjs/error-codes.client.generated.cjs +7 -1
  7. package/dist/cjs/error-codes.server.generated.cjs +27 -1
  8. package/dist/cjs/hydration/event-capture.cjs +2 -1
  9. package/dist/cjs/independent-hydration-protocol.cjs +3 -2
  10. package/dist/cjs/index.cjs +2 -0
  11. package/dist/cjs/runtime.cjs +866 -370
  12. package/dist/cjs/runtime.server.cjs +250 -62
  13. package/dist/cjs/server/index.cjs +2 -0
  14. package/dist/cjs/server/rpc-stream.cjs +19 -12
  15. package/dist/cjs/server/streamed-signals.cjs +18 -1
  16. package/dist/cjs/shared-value-helpers.cjs +24 -2
  17. package/dist/cjs/signals/control-binding.cjs +7 -6
  18. package/dist/cjs/signals/derived-facade.cjs +2 -1
  19. package/dist/cjs/signals/document-owner.cjs +4 -3
  20. package/dist/cjs/signals/facade.cjs +10 -9
  21. package/dist/cjs/signals/graph.cjs +5 -4
  22. package/dist/cjs/signals/native-read-client.cjs +4 -3
  23. package/dist/cjs/signals/owner-context.cjs +4 -3
  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/scalar-computations.cjs +2 -1
  27. package/dist/cjs/signals/transition-action.cjs +10 -9
  28. package/dist/cjs/signals/transition-candidate.cjs +2 -1
  29. package/dist/cjs/version.cjs +1 -1
  30. package/dist/compiler/arm-exits.js +151 -0
  31. package/dist/compiler/compile-universal.js +262 -65
  32. package/dist/compiler/compile.js +1929 -306
  33. package/dist/compiler/deferred-snapshots.js +791 -0
  34. package/dist/compiler/strong-mode.js +59 -10
  35. package/dist/constants.d.ts +5 -1
  36. package/dist/constants.js +2 -0
  37. package/dist/error-codes.client.generated.d.ts +1 -0
  38. package/dist/error-codes.client.generated.js +5 -0
  39. package/dist/error-codes.server.generated.d.ts +5 -0
  40. package/dist/error-codes.server.generated.js +25 -0
  41. package/dist/index.d.ts +1 -1
  42. package/dist/index.js +2 -0
  43. package/dist/node/aria-diagnostics.js +92 -0
  44. package/dist/node/behavior-form-submissions.js +228 -0
  45. package/dist/node/behavior-root-types.js +0 -0
  46. package/dist/node/behavior-root.js +746 -0
  47. package/dist/node/class-names.js +25 -0
  48. package/dist/node/compatibility.js +10 -0
  49. package/dist/node/component-flags.js +23 -0
  50. package/dist/node/constants.js +115 -0
  51. package/dist/node/context-epoch.js +13 -0
  52. package/dist/node/context-identity.js +46 -0
  53. package/dist/node/css.js +80 -0
  54. package/dist/node/data-encoding.js +134 -0
  55. package/dist/node/devtools-hook.js +229 -0
  56. package/dist/node/dom-binding-claims.js +4 -0
  57. package/dist/node/dom-binding-classes.js +152 -0
  58. package/dist/node/dom-binding-controls.js +6 -0
  59. package/dist/node/dom-binding-handoff.js +77 -0
  60. package/dist/node/dom-binding-program.js +1617 -0
  61. package/dist/node/dom-binding-projections.js +204 -0
  62. package/dist/node/dom-binding-protocol.js +130 -0
  63. package/dist/node/dom-binding-signals.js +135 -0
  64. package/dist/node/dom-binding-styles.js +280 -0
  65. package/dist/node/dom-bindings.js +1087 -0
  66. package/dist/node/dom-focused-move.js +46 -0
  67. package/dist/node/dom-stage.js +878 -0
  68. package/dist/node/dom-tables.js +382 -0
  69. package/dist/node/error-codes.client.generated.js +1071 -0
  70. package/dist/node/error-codes.server.generated.js +761 -0
  71. package/dist/node/error-message.js +27 -0
  72. package/dist/node/event-names.js +15 -0
  73. package/dist/node/form-diagnostics.js +96 -0
  74. package/dist/node/form-submission.js +43 -0
  75. package/dist/node/has-own.js +4 -0
  76. package/dist/node/head-ownership.js +31 -0
  77. package/dist/node/hook-slot-cache.js +91 -0
  78. package/dist/node/host-property-diagnostics.js +189 -0
  79. package/dist/node/html-tree-validation.js +193 -0
  80. package/dist/node/hydration/condition.js +15 -0
  81. package/dist/node/hydration/control-capture.js +237 -0
  82. package/dist/node/hydration/document-lifecycle.js +89 -0
  83. package/dist/node/hydration/event-capture.js +362 -0
  84. package/dist/node/hydration/idle.js +23 -0
  85. package/dist/node/hydration/independent-island.js +317 -0
  86. package/dist/node/hydration/index.js +74 -0
  87. package/dist/node/hydration/interaction-config.js +61 -0
  88. package/dist/node/hydration/interaction.js +35 -0
  89. package/dist/node/hydration/load.js +15 -0
  90. package/dist/node/hydration/media.js +33 -0
  91. package/dist/node/hydration/native-intent.js +68 -0
  92. package/dist/node/hydration/never.js +12 -0
  93. package/dist/node/hydration/stream-delivery.js +345 -0
  94. package/dist/node/hydration/stream-receiver.js +190 -0
  95. package/dist/node/hydration/stream-result-receiver.js +276 -0
  96. package/dist/node/hydration/streamed-signals.js +186 -0
  97. package/dist/node/hydration/types.js +0 -0
  98. package/dist/node/hydration/visible.js +69 -0
  99. package/dist/node/hydration-markers.js +44 -0
  100. package/dist/node/independent-hydration-protocol.js +91 -0
  101. package/dist/node/index.js +463 -0
  102. package/dist/node/internal/client.js +7 -0
  103. package/dist/node/internal/context.js +5 -0
  104. package/dist/node/internal/server.js +5 -0
  105. package/dist/node/internal/signal-read.js +4 -0
  106. package/dist/node/method-dep.js +25 -0
  107. package/dist/node/profiling.js +432 -0
  108. package/dist/node/public-types.js +0 -0
  109. package/dist/node/react/fiber-adapter.js +57 -0
  110. package/dist/node/react/index.js +397 -0
  111. package/dist/node/react/react-compat-envelope.js +78 -0
  112. package/dist/node/react/react-compat-server.js +129 -0
  113. package/dist/node/react/react-compat-shared.js +104 -0
  114. package/dist/node/react/react-compat.js +223 -0
  115. package/dist/node/react/server.js +81 -0
  116. package/dist/node/react/shared.js +75 -0
  117. package/dist/node/renderer-bridge.js +35 -0
  118. package/dist/node/resize-observer.js +105 -0
  119. package/dist/node/resource-hint-diagnostics.js +67 -0
  120. package/dist/node/runtime-tags.js +22 -0
  121. package/dist/node/runtime.js +29364 -0
  122. package/dist/node/runtime.server.js +8200 -0
  123. package/dist/node/sanitize-url.js +34 -0
  124. package/dist/node/server/early-signals.js +54 -0
  125. package/dist/node/server/index.js +338 -0
  126. package/dist/node/server/rpc-batch.js +129 -0
  127. package/dist/node/server/rpc-stream.js +132 -0
  128. package/dist/node/server/rpc.js +48 -0
  129. package/dist/node/server/signal-query-observation.js +134 -0
  130. package/dist/node/server/streamed-region.js +31 -0
  131. package/dist/node/server/streamed-signals.js +574 -0
  132. package/dist/node/server-call.js +75 -0
  133. package/dist/node/server-rpc-batch-client.js +119 -0
  134. package/dist/node/server-rpc-client.js +108 -0
  135. package/dist/node/server-rpc-protocol.js +109 -0
  136. package/dist/node/server-rpc-stream-client.js +98 -0
  137. package/dist/node/shared-value-helpers.js +60 -0
  138. package/dist/node/signals/actions.js +463 -0
  139. package/dist/node/signals/client.js +22 -0
  140. package/dist/node/signals/computations.js +452 -0
  141. package/dist/node/signals/control-binding.js +388 -0
  142. package/dist/node/signals/control-handoff.js +12 -0
  143. package/dist/node/signals/derived-facade.js +25 -0
  144. package/dist/node/signals/document-owner.js +48 -0
  145. package/dist/node/signals/early-values.js +124 -0
  146. package/dist/node/signals/encoding.js +6 -0
  147. package/dist/node/signals/engine.js +668 -0
  148. package/dist/node/signals/errors.js +54 -0
  149. package/dist/node/signals/facade.js +441 -0
  150. package/dist/node/signals/graph.js +817 -0
  151. package/dist/node/signals/handle-protocol.js +11 -0
  152. package/dist/node/signals/index.js +87 -0
  153. package/dist/node/signals/native-read-client.js +319 -0
  154. package/dist/node/signals/native-read-collector.js +132 -0
  155. package/dist/node/signals/native-read-events.js +45 -0
  156. package/dist/node/signals/native-read-inspection.js +20 -0
  157. package/dist/node/signals/native-read-retry.js +30 -0
  158. package/dist/node/signals/native-read-seeds.js +243 -0
  159. package/dist/node/signals/native-read-server.js +99 -0
  160. package/dist/node/signals/owner-context.js +88 -0
  161. package/dist/node/signals/query-attempt-observer.js +42 -0
  162. package/dist/node/signals/query-facade.js +41 -0
  163. package/dist/node/signals/read-protocol.js +125 -0
  164. package/dist/node/signals/requests.js +716 -0
  165. package/dist/node/signals/scalar-computations.js +57 -0
  166. package/dist/node/signals/scope-streams.js +147 -0
  167. package/dist/node/signals/server.js +22 -0
  168. package/dist/node/signals/transition-action.js +555 -0
  169. package/dist/node/signals/transition-candidate.js +101 -0
  170. package/dist/node/signals/transition-coordinator.js +255 -0
  171. package/dist/node/signals/transition-state.js +82 -0
  172. package/dist/node/signals/types.js +20 -0
  173. package/dist/node/static/index.js +10 -0
  174. package/dist/node/stream-protocol.js +114 -0
  175. package/dist/node/streamed-signals-protocol.js +130 -0
  176. package/dist/node/style-values.js +96 -0
  177. package/dist/node/sub-slot.js +35 -0
  178. package/dist/node/testing.js +14 -0
  179. package/dist/node/trusted-html.js +6 -0
  180. package/dist/node/tsrx-iterable.js +5 -0
  181. package/dist/node/tsrx-spread.js +10 -0
  182. package/dist/node/universal-core.js +10138 -0
  183. package/dist/node/universal-dom-boundary.js +237 -0
  184. package/dist/node/universal-native.js +28 -0
  185. package/dist/node/universal.js +17 -0
  186. package/dist/node/version.js +4 -0
  187. package/dist/runtime.d.ts +219 -8
  188. package/dist/runtime.js +714 -220
  189. package/dist/runtime.server.d.ts +33 -2
  190. package/dist/runtime.server.js +217 -29
  191. package/dist/server/index.d.ts +1 -1
  192. package/dist/server/index.js +2 -0
  193. package/dist/server/rpc-stream.js +19 -12
  194. package/dist/server/streamed-signals.js +18 -1
  195. package/dist/shared-value-helpers.d.ts +11 -0
  196. package/dist/shared-value-helpers.js +21 -1
  197. package/dist/universal-core.d.ts +3 -1
  198. package/dist/universal-core.js +178 -50
  199. package/dist/version.js +1 -1
  200. 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
+ }