@velarscript/web 0.31.0 → 0.33.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/README.md +1 -1
- package/dist/analysis/calls/intrinsics/config.d.ts +10 -0
- package/dist/analysis/calls/intrinsics/config.d.ts.map +1 -0
- package/dist/analysis/calls/intrinsics/config.js +19 -0
- package/dist/analysis/calls/intrinsics/config.js.map +1 -0
- package/dist/analysis/calls/intrinsics/forms.d.ts +10 -0
- package/dist/analysis/calls/intrinsics/forms.d.ts.map +1 -0
- package/dist/analysis/calls/intrinsics/forms.js +38 -0
- package/dist/analysis/calls/intrinsics/forms.js.map +1 -0
- package/dist/analysis/calls/intrinsics/http.d.ts +10 -0
- package/dist/analysis/calls/intrinsics/http.d.ts.map +1 -0
- package/dist/analysis/calls/intrinsics/http.js +37 -0
- package/dist/analysis/calls/intrinsics/http.js.map +1 -0
- package/dist/analysis/calls/intrinsics/reactive.d.ts +10 -0
- package/dist/analysis/calls/intrinsics/reactive.d.ts.map +1 -0
- package/dist/analysis/calls/intrinsics/reactive.js +30 -0
- package/dist/analysis/calls/intrinsics/reactive.js.map +1 -0
- package/dist/analysis/calls/intrinsics/storage.d.ts +16 -0
- package/dist/analysis/calls/intrinsics/storage.d.ts.map +1 -0
- package/dist/analysis/calls/intrinsics/storage.js +91 -0
- package/dist/analysis/calls/intrinsics/storage.js.map +1 -0
- package/dist/analysis/calls/intrinsics/web.d.ts +10 -0
- package/dist/analysis/calls/intrinsics/web.d.ts.map +1 -0
- package/dist/analysis/calls/intrinsics/web.js +100 -0
- package/dist/analysis/calls/intrinsics/web.js.map +1 -0
- package/dist/analysis/calls/intrinsics.d.ts +13 -0
- package/dist/analysis/calls/intrinsics.d.ts.map +1 -0
- package/dist/analysis/calls/intrinsics.js +31 -0
- package/dist/analysis/calls/intrinsics.js.map +1 -0
- package/dist/analysis/components/contracts.d.ts +19 -0
- package/dist/analysis/components/contracts.d.ts.map +1 -0
- package/dist/analysis/components/contracts.js +83 -0
- package/dist/analysis/components/contracts.js.map +1 -0
- package/dist/analysis/components/declaration.d.ts +4 -0
- package/dist/analysis/components/declaration.d.ts.map +1 -0
- package/dist/analysis/components/declaration.js +163 -0
- package/dist/analysis/components/declaration.js.map +1 -0
- package/dist/analysis/components/host.d.ts +61 -0
- package/dist/analysis/components/host.d.ts.map +1 -0
- package/dist/analysis/components/host.js +22 -0
- package/dist/analysis/components/host.js.map +1 -0
- package/dist/analysis/components/lifecycle.d.ts +22 -0
- package/dist/analysis/components/lifecycle.d.ts.map +1 -0
- package/dist/analysis/components/lifecycle.js +33 -0
- package/dist/analysis/components/lifecycle.js.map +1 -0
- package/dist/analysis/components/ownership.d.ts +74 -0
- package/dist/analysis/components/ownership.d.ts.map +1 -0
- package/dist/analysis/components/ownership.js +106 -0
- package/dist/analysis/components/ownership.js.map +1 -0
- package/dist/analysis/declarations.d.ts +99 -0
- package/dist/analysis/declarations.d.ts.map +1 -0
- package/dist/analysis/declarations.js +176 -0
- package/dist/analysis/declarations.js.map +1 -0
- package/dist/analysis/inference.d.ts +75 -0
- package/dist/analysis/inference.d.ts.map +1 -0
- package/dist/analysis/inference.js +257 -0
- package/dist/analysis/inference.js.map +1 -0
- package/dist/analysis/jsx/attributes.d.ts +103 -0
- package/dist/analysis/jsx/attributes.d.ts.map +1 -0
- package/dist/analysis/jsx/attributes.js +601 -0
- package/dist/analysis/jsx/attributes.js.map +1 -0
- package/dist/analysis/jsx/elements.d.ts +17 -0
- package/dist/analysis/jsx/elements.d.ts.map +1 -0
- package/dist/analysis/jsx/elements.js +213 -0
- package/dist/analysis/jsx/elements.js.map +1 -0
- package/dist/analysis/jsx/host.d.ts +61 -0
- package/dist/analysis/jsx/host.d.ts.map +1 -0
- package/dist/analysis/jsx/host.js +15 -0
- package/dist/analysis/jsx/host.js.map +1 -0
- package/dist/analysis/jsx/keys.d.ts +15 -0
- package/dist/analysis/jsx/keys.d.ts.map +1 -0
- package/dist/analysis/jsx/keys.js +67 -0
- package/dist/analysis/jsx/keys.js.map +1 -0
- package/dist/analysis/jsx/security.d.ts +29 -0
- package/dist/analysis/jsx/security.d.ts.map +1 -0
- package/dist/analysis/jsx/security.js +61 -0
- package/dist/analysis/jsx/security.js.map +1 -0
- package/dist/analysis/jsx-detection.d.ts +49 -0
- package/dist/analysis/jsx-detection.d.ts.map +1 -0
- package/dist/analysis/jsx-detection.js +196 -0
- package/dist/analysis/jsx-detection.js.map +1 -0
- package/dist/analysis/keyed-rebuild.d.ts +148 -0
- package/dist/analysis/keyed-rebuild.d.ts.map +1 -0
- package/dist/analysis/keyed-rebuild.js +299 -0
- package/dist/analysis/keyed-rebuild.js.map +1 -0
- package/dist/analysis/keyframes-analysis.d.ts +6 -0
- package/dist/analysis/keyframes-analysis.d.ts.map +1 -0
- package/dist/analysis/keyframes-analysis.js +79 -0
- package/dist/analysis/keyframes-analysis.js.map +1 -0
- package/dist/analysis/look/builders.d.ts +29 -0
- package/dist/analysis/look/builders.d.ts.map +1 -0
- package/dist/analysis/look/builders.js +174 -0
- package/dist/analysis/look/builders.js.map +1 -0
- package/dist/analysis/look/conditions.d.ts +13 -0
- package/dist/analysis/look/conditions.d.ts.map +1 -0
- package/dist/analysis/look/conditions.js +84 -0
- package/dist/analysis/look/conditions.js.map +1 -0
- package/dist/analysis/look/edits.d.ts +36 -0
- package/dist/analysis/look/edits.d.ts.map +1 -0
- package/dist/analysis/look/edits.js +80 -0
- package/dist/analysis/look/edits.js.map +1 -0
- package/dist/analysis/look/entries.d.ts +56 -0
- package/dist/analysis/look/entries.d.ts.map +1 -0
- package/dist/analysis/look/entries.js +223 -0
- package/dist/analysis/look/entries.js.map +1 -0
- package/dist/analysis/look/host.d.ts +47 -0
- package/dist/analysis/look/host.d.ts.map +1 -0
- package/dist/analysis/look/host.js +16 -0
- package/dist/analysis/look/host.js.map +1 -0
- package/dist/analysis/look/tokens.d.ts +75 -0
- package/dist/analysis/look/tokens.d.ts.map +1 -0
- package/dist/analysis/look/tokens.js +156 -0
- package/dist/analysis/look/tokens.js.map +1 -0
- package/dist/analysis/look/values.d.ts +45 -0
- package/dist/analysis/look/values.d.ts.map +1 -0
- package/dist/analysis/look/values.js +148 -0
- package/dist/analysis/look/values.js.map +1 -0
- package/dist/analysis/look-conditions.d.ts +47 -0
- package/dist/analysis/look-conditions.d.ts.map +1 -0
- package/dist/analysis/look-conditions.js +157 -0
- package/dist/analysis/look-conditions.js.map +1 -0
- package/dist/analysis/look-sites.d.ts +62 -0
- package/dist/analysis/look-sites.d.ts.map +1 -0
- package/dist/analysis/look-sites.js +121 -0
- package/dist/analysis/look-sites.js.map +1 -0
- package/dist/analysis/look-values.d.ts +19 -0
- package/dist/analysis/look-values.d.ts.map +1 -1
- package/dist/analysis/look-values.js +38 -0
- package/dist/analysis/look-values.js.map +1 -1
- package/dist/analysis/look-vocabulary-guidance.d.ts +76 -0
- package/dist/analysis/look-vocabulary-guidance.d.ts.map +1 -0
- package/dist/analysis/look-vocabulary-guidance.js +338 -0
- package/dist/analysis/look-vocabulary-guidance.js.map +1 -0
- package/dist/analysis/media-conditions.d.ts +33 -0
- package/dist/analysis/media-conditions.d.ts.map +1 -0
- package/dist/analysis/media-conditions.js +92 -0
- package/dist/analysis/media-conditions.js.map +1 -0
- package/dist/analysis/program-passes.d.ts +106 -0
- package/dist/analysis/program-passes.d.ts.map +1 -0
- package/dist/analysis/program-passes.js +149 -0
- package/dist/analysis/program-passes.js.map +1 -0
- package/dist/analysis/reactivity/bindings.d.ts +37 -0
- package/dist/analysis/reactivity/bindings.d.ts.map +1 -0
- package/dist/analysis/reactivity/bindings.js +88 -0
- package/dist/analysis/reactivity/bindings.js.map +1 -0
- package/dist/analysis/reactivity/derived.d.ts +39 -0
- package/dist/analysis/reactivity/derived.d.ts.map +1 -0
- package/dist/analysis/reactivity/derived.js +80 -0
- package/dist/analysis/reactivity/derived.js.map +1 -0
- package/dist/analysis/reactivity/host.d.ts +38 -0
- package/dist/analysis/reactivity/host.d.ts.map +1 -0
- package/dist/analysis/reactivity/host.js +14 -0
- package/dist/analysis/reactivity/host.js.map +1 -0
- package/dist/analysis/reactivity/retired-accessors.d.ts +82 -0
- package/dist/analysis/reactivity/retired-accessors.d.ts.map +1 -0
- package/dist/analysis/reactivity/retired-accessors.js +118 -0
- package/dist/analysis/reactivity/retired-accessors.js.map +1 -0
- package/dist/analysis/renderable.d.ts +47 -0
- package/dist/analysis/renderable.d.ts.map +1 -0
- package/dist/analysis/renderable.js +105 -0
- package/dist/analysis/renderable.js.map +1 -0
- package/dist/analysis/routes.d.ts +64 -0
- package/dist/analysis/routes.d.ts.map +1 -0
- package/dist/analysis/routes.js +182 -0
- package/dist/analysis/routes.js.map +1 -0
- package/dist/analysis/url-attributes.d.ts +12 -0
- package/dist/analysis/url-attributes.d.ts.map +1 -0
- package/dist/analysis/url-attributes.js +48 -0
- package/dist/analysis/url-attributes.js.map +1 -0
- package/dist/analysis/watch-cycles.d.ts +102 -0
- package/dist/analysis/watch-cycles.d.ts.map +1 -1
- package/dist/analysis/watch-cycles.js +240 -1
- package/dist/analysis/watch-cycles.js.map +1 -1
- package/dist/analysis/watch-subject.d.ts +45 -0
- package/dist/analysis/watch-subject.d.ts.map +1 -0
- package/dist/analysis/watch-subject.js +272 -0
- package/dist/analysis/watch-subject.js.map +1 -0
- package/dist/analysis/web-types.d.ts +27 -0
- package/dist/analysis/web-types.d.ts.map +1 -0
- package/dist/analysis/web-types.js +170 -0
- package/dist/analysis/web-types.js.map +1 -0
- package/dist/analyzer.d.ts +18 -617
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +211 -4853
- package/dist/analyzer.js.map +1 -1
- package/dist/compiler.d.ts +20 -0
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +31 -864
- package/dist/compiler.js.map +1 -1
- package/dist/documentation.d.ts +28 -0
- package/dist/documentation.d.ts.map +1 -0
- package/dist/documentation.js +67 -0
- package/dist/documentation.js.map +1 -0
- package/dist/editor/completions.d.ts +12 -0
- package/dist/editor/completions.d.ts.map +1 -0
- package/dist/editor/completions.js +6 -0
- package/dist/editor/completions.js.map +1 -0
- package/dist/editor/jsx-completion.d.ts +12 -0
- package/dist/editor/jsx-completion.d.ts.map +1 -0
- package/dist/editor/jsx-completion.js +137 -0
- package/dist/editor/jsx-completion.js.map +1 -0
- package/dist/editor/look-completion.d.ts +29 -0
- package/dist/editor/look-completion.d.ts.map +1 -0
- package/dist/editor/look-completion.js +159 -0
- package/dist/editor/look-completion.js.map +1 -0
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +12 -288
- package/dist/editor.js.map +1 -1
- package/dist/emit/components.d.ts +33 -0
- package/dist/emit/components.d.ts.map +1 -0
- package/dist/emit/components.js +135 -0
- package/dist/emit/components.js.map +1 -0
- package/dist/emit/jsx.d.ts +57 -0
- package/dist/emit/jsx.d.ts.map +1 -0
- package/dist/emit/jsx.js +384 -0
- package/dist/emit/jsx.js.map +1 -0
- package/dist/emit/look-css.d.ts +44 -0
- package/dist/emit/look-css.d.ts.map +1 -0
- package/dist/emit/look-css.js +177 -0
- package/dist/emit/look-css.js.map +1 -0
- package/dist/emit/look.d.ts +39 -0
- package/dist/emit/look.d.ts.map +1 -0
- package/dist/emit/look.js +218 -0
- package/dist/emit/look.js.map +1 -0
- package/dist/emit/runtime-imports.d.ts +40 -0
- package/dist/emit/runtime-imports.d.ts.map +1 -0
- package/dist/emit/runtime-imports.js +188 -0
- package/dist/emit/runtime-imports.js.map +1 -0
- package/dist/emitter.d.ts +15 -68
- package/dist/emitter.d.ts.map +1 -1
- package/dist/emitter.js +79 -1008
- package/dist/emitter.js.map +1 -1
- package/dist/look/animation.d.ts +7 -0
- package/dist/look/animation.d.ts.map +1 -0
- package/dist/look/animation.js +13 -0
- package/dist/look/animation.js.map +1 -0
- package/dist/look/builders.d.ts +35 -0
- package/dist/look/builders.d.ts.map +1 -0
- package/dist/look/builders.js +74 -0
- package/dist/look/builders.js.map +1 -0
- package/dist/look/css-functions.d.ts +28 -0
- package/dist/look/css-functions.d.ts.map +1 -0
- package/dist/look/css-functions.js +54 -0
- package/dist/look/css-functions.js.map +1 -0
- package/dist/look/keyword-sets.d.ts +41 -0
- package/dist/look/keyword-sets.d.ts.map +1 -0
- package/dist/look/keyword-sets.js +117 -0
- package/dist/look/keyword-sets.js.map +1 -0
- package/dist/look/keywords.d.ts +55 -0
- package/dist/look/keywords.d.ts.map +1 -0
- package/dist/look/keywords.js +387 -0
- package/dist/look/keywords.js.map +1 -0
- package/dist/look/media.d.ts +19 -0
- package/dist/look/media.d.ts.map +1 -0
- package/dist/look/media.js +27 -0
- package/dist/look/media.js.map +1 -0
- package/dist/look/naming.d.ts +9 -0
- package/dist/look/naming.d.ts.map +1 -0
- package/dist/look/naming.js +45 -0
- package/dist/look/naming.js.map +1 -0
- package/dist/look/properties.d.ts +16 -0
- package/dist/look/properties.d.ts.map +1 -0
- package/dist/look/properties.js +52 -0
- package/dist/look/properties.js.map +1 -0
- package/dist/look/shorthands.d.ts +25 -0
- package/dist/look/shorthands.d.ts.map +1 -0
- package/dist/look/shorthands.js +130 -0
- package/dist/look/shorthands.js.map +1 -0
- package/dist/look/tokens.d.ts +38 -0
- package/dist/look/tokens.d.ts.map +1 -0
- package/dist/look/tokens.js +59 -0
- package/dist/look/tokens.js.map +1 -0
- package/dist/look/units.d.ts +24 -0
- package/dist/look/units.d.ts.map +1 -0
- package/dist/look/units.js +33 -0
- package/dist/look/units.js.map +1 -0
- package/dist/look.d.ts +32 -227
- package/dist/look.d.ts.map +1 -1
- package/dist/look.js +28 -933
- package/dist/look.js.map +1 -1
- package/dist/module-roster.d.ts +16 -0
- package/dist/module-roster.d.ts.map +1 -0
- package/dist/module-roster.js +28 -0
- package/dist/module-roster.js.map +1 -0
- package/dist/modules/app.d.ts +9 -0
- package/dist/modules/app.d.ts.map +1 -0
- package/dist/modules/app.js +20 -0
- package/dist/modules/app.js.map +1 -0
- package/dist/modules/browser-test.d.ts +9 -0
- package/dist/modules/browser-test.d.ts.map +1 -0
- package/dist/modules/browser-test.js +67 -0
- package/dist/modules/browser-test.js.map +1 -0
- package/dist/modules/browser.d.ts +10 -0
- package/dist/modules/browser.d.ts.map +1 -0
- package/dist/modules/browser.js +89 -0
- package/dist/modules/browser.js.map +1 -0
- package/dist/modules/config.d.ts +9 -0
- package/dist/modules/config.d.ts.map +1 -0
- package/dist/modules/config.js +14 -0
- package/dist/modules/config.js.map +1 -0
- package/dist/modules/files.d.ts +9 -0
- package/dist/modules/files.d.ts.map +1 -0
- package/dist/modules/files.js +16 -0
- package/dist/modules/files.js.map +1 -0
- package/dist/modules/forms.d.ts +9 -0
- package/dist/modules/forms.d.ts.map +1 -0
- package/dist/modules/forms.js +26 -0
- package/dist/modules/forms.js.map +1 -0
- package/dist/modules/http.d.ts +9 -0
- package/dist/modules/http.d.ts.map +1 -0
- package/dist/modules/http.js +127 -0
- package/dist/modules/http.js.map +1 -0
- package/dist/modules/look.d.ts +9 -0
- package/dist/modules/look.d.ts.map +1 -0
- package/dist/modules/look.js +58 -0
- package/dist/modules/look.js.map +1 -0
- package/dist/modules/realtime.d.ts +9 -0
- package/dist/modules/realtime.d.ts.map +1 -0
- package/dist/modules/realtime.js +163 -0
- package/dist/modules/realtime.js.map +1 -0
- package/dist/modules/storage.d.ts +9 -0
- package/dist/modules/storage.d.ts.map +1 -0
- package/dist/modules/storage.js +59 -0
- package/dist/modules/storage.js.map +1 -0
- package/dist/modules/types.d.ts +78 -0
- package/dist/modules/types.d.ts.map +1 -0
- package/dist/modules/types.js +154 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/modules/web.d.ts +9 -0
- package/dist/modules/web.d.ts.map +1 -0
- package/dist/modules/web.js +63 -0
- package/dist/modules/web.js.map +1 -0
- package/dist/modules/websocket.d.ts +11 -0
- package/dist/modules/websocket.d.ts.map +1 -0
- package/dist/modules/websocket.js +75 -0
- package/dist/modules/websocket.js.map +1 -0
- package/dist/parser/expressions/jsx.d.ts +17 -0
- package/dist/parser/expressions/jsx.d.ts.map +1 -0
- package/dist/parser/expressions/jsx.js +43 -0
- package/dist/parser/expressions/jsx.js.map +1 -0
- package/dist/parser/expressions/keyframes.d.ts +15 -0
- package/dist/parser/expressions/keyframes.d.ts.map +1 -0
- package/dist/parser/expressions/keyframes.js +33 -0
- package/dist/parser/expressions/keyframes.js.map +1 -0
- package/dist/parser/expressions/look.d.ts +16 -0
- package/dist/parser/expressions/look.d.ts.map +1 -0
- package/dist/parser/expressions/look.js +37 -0
- package/dist/parser/expressions/look.js.map +1 -0
- package/dist/parser/expressions/visual-block.d.ts +17 -0
- package/dist/parser/expressions/visual-block.d.ts.map +1 -0
- package/dist/parser/expressions/visual-block.js +21 -0
- package/dist/parser/expressions/visual-block.js.map +1 -0
- package/dist/parser/keyframes-source.d.ts +24 -0
- package/dist/parser/keyframes-source.d.ts.map +1 -0
- package/dist/parser/keyframes-source.js +133 -0
- package/dist/parser/keyframes-source.js.map +1 -0
- package/dist/parser/look-source.d.ts +25 -0
- package/dist/parser/look-source.d.ts.map +1 -0
- package/dist/parser/look-source.js +189 -0
- package/dist/parser/look-source.js.map +1 -0
- package/dist/parser/spans.d.ts +24 -0
- package/dist/parser/spans.d.ts.map +1 -0
- package/dist/parser/spans.js +113 -0
- package/dist/parser/spans.js.map +1 -0
- package/dist/parser/statements/components.d.ts +37 -0
- package/dist/parser/statements/components.d.ts.map +1 -0
- package/dist/parser/statements/components.js +185 -0
- package/dist/parser/statements/components.js.map +1 -0
- package/dist/parser/statements/heads.d.ts +38 -0
- package/dist/parser/statements/heads.d.ts.map +1 -0
- package/dist/parser/statements/heads.js +55 -0
- package/dist/parser/statements/heads.js.map +1 -0
- package/dist/parser/statements/imports.d.ts +9 -0
- package/dist/parser/statements/imports.d.ts.map +1 -0
- package/dist/parser/statements/imports.js +31 -0
- package/dist/parser/statements/imports.js.map +1 -0
- package/dist/parser/statements/reactive.d.ts +31 -0
- package/dist/parser/statements/reactive.d.ts.map +1 -0
- package/dist/parser/statements/reactive.js +68 -0
- package/dist/parser/statements/reactive.js.map +1 -0
- package/dist/parser/statements/unsafe-css.d.ts +21 -0
- package/dist/parser/statements/unsafe-css.d.ts.map +1 -0
- package/dist/parser/statements/unsafe-css.js +42 -0
- package/dist/parser/statements/unsafe-css.js.map +1 -0
- package/dist/parser.d.ts +37 -50
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +98 -882
- package/dist/parser.js.map +1 -1
- package/dist/runtime-sources.generated.d.ts +1 -1
- package/dist/runtime-sources.generated.d.ts.map +1 -1
- package/dist/runtime-sources.generated.js +4 -4
- package/dist/runtime-sources.generated.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One Web module analyzed end to end: the tables the whole-program rules are
|
|
3
|
+
* read out of, the two refusals that are decided before the core walk starts,
|
|
4
|
+
* and the three reports that can only be written once it has ended.
|
|
5
|
+
*
|
|
6
|
+
* D115 P4 R3c. The sequence is one function because the *order* is the rule —
|
|
7
|
+
* the Look and reactive tables have to exist before any statement is walked, the
|
|
8
|
+
* two module-level refusals land at their declarations rather than at a later
|
|
9
|
+
* use, and each closing report needs the whole module's evidence. The core walk
|
|
10
|
+
* itself stays on the analyzer, which is the only thing that can reach it, and
|
|
11
|
+
* arrives here as `analyzeCore`.
|
|
12
|
+
*/
|
|
13
|
+
import {} from "@velarscript/compiler";
|
|
14
|
+
import {} from "@velarscript/compiler/extension";
|
|
15
|
+
import { BROWSER_TEST_MODULE, BROWSER_TEST_SOURCE_SUFFIX, browserTestImportGuidance } from "../browser-test.js";
|
|
16
|
+
import { collectLookStaticScope } from "../look-static.js";
|
|
17
|
+
import {} from "../ast.js";
|
|
18
|
+
import { WEB_OWNED_TYPE_NAMES } from "../types.js";
|
|
19
|
+
import { adviseKeyedListRebuilds, collectModuleFunctions } from "./keyed-rebuild.js";
|
|
20
|
+
import { collectLookDeclarations } from "./look-conditions.js";
|
|
21
|
+
import { collectLookBuilderNames, collectLookImportSite } from "./look-sites.js";
|
|
22
|
+
import { collectPublicConfigNames } from "./public-config.js";
|
|
23
|
+
import { collectDerivedReactiveNames, collectReactiveDerivations, collectReactiveStateNames } from "./reactive-names.js";
|
|
24
|
+
import { reportRetiredComputedFunction } from "./reactivity/retired-accessors.js";
|
|
25
|
+
import { collectReactiveWriters } from "./watch-cycles.js";
|
|
26
|
+
import { diagnostic } from "./web-types.js";
|
|
27
|
+
export function analyzeWebProgram(host, program, analyzeCore) {
|
|
28
|
+
host.lookStatic = collectLookStaticScope(program, host.importedLookStaticValues);
|
|
29
|
+
host.lookBuilderNames = collectLookBuilderNames(program);
|
|
30
|
+
host.publicConfigNames = collectPublicConfigNames(program);
|
|
31
|
+
host.lookImport = collectLookImportSite(program);
|
|
32
|
+
host.lookDeclarations = collectLookDeclarations(program);
|
|
33
|
+
for (const name of collectDerivedReactiveNames(program))
|
|
34
|
+
host.derivedReactiveNames.add(name);
|
|
35
|
+
reportBrowserTestImports(host, program);
|
|
36
|
+
rejectWebOwnedTypeNames(host, program);
|
|
37
|
+
host.keyedListSources.clear();
|
|
38
|
+
host.keyedListRebuilds.length = 0;
|
|
39
|
+
host.moduleFunctions = collectModuleFunctions(program);
|
|
40
|
+
host.reactiveWriters = collectReactiveWriters(program);
|
|
41
|
+
host.reactiveDerivations = collectReactiveDerivations(program);
|
|
42
|
+
host.reactiveStateNames = collectReactiveStateNames(program);
|
|
43
|
+
analyzeCore(program);
|
|
44
|
+
reportStaticJsxKeys(host);
|
|
45
|
+
reportRetiredComputedFunction(host);
|
|
46
|
+
adviseKeyedListRebuilds(host);
|
|
47
|
+
return host.diagnostics;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* D57 rule 138: `velar/web-test` only has a runtime under `velar test
|
|
51
|
+
* --browser`, so an import of it anywhere else compiles a call that cannot
|
|
52
|
+
* succeed. D51 rule 109 puts the refusal at the declaration rather than at the
|
|
53
|
+
* eventual use, so the error lands on the `import` line — including the
|
|
54
|
+
* JavaScript-bridge and re-export spellings, which reach the same runtime.
|
|
55
|
+
*/
|
|
56
|
+
export function reportBrowserTestImports(host, program) {
|
|
57
|
+
if ((host.webModulePath ?? "").endsWith(BROWSER_TEST_SOURCE_SUFFIX))
|
|
58
|
+
return;
|
|
59
|
+
for (const statement of program.body) {
|
|
60
|
+
if (statement.kind !== "ImportDeclaration" && statement.kind !== "ReExportDeclaration")
|
|
61
|
+
continue;
|
|
62
|
+
if (statement.source !== BROWSER_TEST_MODULE)
|
|
63
|
+
continue;
|
|
64
|
+
host.diagnostics.push(diagnostic("VEL5062", browserTestImportGuidance(), statement.sourceSpan));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* D72 rule 186: a Web module publishes its own type names, and a user
|
|
69
|
+
* declaration of one used to be accepted at the declaration and then lose at
|
|
70
|
+
* every use — `type Event:` compiled, and `describe({kind: "charge"})` was
|
|
71
|
+
* told it could not assign to `Event`, naming a type the author had just
|
|
72
|
+
* written. D51 rule 109 already settled where that refusal belongs: at the
|
|
73
|
+
* declaration, which is the only place a rename is cheap.
|
|
74
|
+
*
|
|
75
|
+
* The names come from the extension's own published table, so adding a type
|
|
76
|
+
* to `WEB_OWNED_TYPE_NAMES` extends this protection with it. The last time
|
|
77
|
+
* this family was repaired by listing names instead of deriving them, the
|
|
78
|
+
* list drifted; D57 rule 135 is the same repair on the Core roster.
|
|
79
|
+
*
|
|
80
|
+
* Core now says the same sentence about its own built-in type names —
|
|
81
|
+
* `builtinTypeNameDeclarationMessage` in packages/compiler/src/analyzer.ts,
|
|
82
|
+
* reported as VEL3007. The rosters differ; the wording is meant to read
|
|
83
|
+
* alike, so a change to either sentence belongs in both.
|
|
84
|
+
*
|
|
85
|
+
* `Duration` is on both rosters — Core owns it as a primitive and
|
|
86
|
+
* `velar/look` republishes it — so a Web module used to report it twice. This
|
|
87
|
+
* refusal is the more specific of the two, because it names the surface the
|
|
88
|
+
* author is writing against, so it marks the name refused and Core's stays
|
|
89
|
+
* unsaid. The mark is Core's own hook, which is what lets this pass take
|
|
90
|
+
* precedence without either side learning the other's roster.
|
|
91
|
+
*/
|
|
92
|
+
export function rejectWebOwnedTypeNames(host, program) {
|
|
93
|
+
const reject = (name, errorSpan, noun) => {
|
|
94
|
+
if (!WEB_OWNED_TYPE_NAMES.has(name))
|
|
95
|
+
return;
|
|
96
|
+
host.markTypeNameRefused(name);
|
|
97
|
+
host.diagnostics.push(diagnostic("VEL5065", `'${name}' is a Web type name, so it cannot also name ${/^[aeiou]/iu.test(noun) ? "an" : "a"} ${noun}; every use of it in a Web module resolves to the built-in. Rename this declaration`, errorSpan));
|
|
98
|
+
};
|
|
99
|
+
for (const statement of program.body) {
|
|
100
|
+
switch (statement.kind) {
|
|
101
|
+
case "TypeDeclaration":
|
|
102
|
+
case "TypeAliasDeclaration":
|
|
103
|
+
reject(statement.name, statement.span, "type");
|
|
104
|
+
break;
|
|
105
|
+
case "ClassDeclaration":
|
|
106
|
+
reject(statement.name, statement.span, "class");
|
|
107
|
+
break;
|
|
108
|
+
case "EnumDeclaration":
|
|
109
|
+
reject(statement.name, statement.span, "enum");
|
|
110
|
+
break;
|
|
111
|
+
case "ExternModuleDeclaration":
|
|
112
|
+
for (const declaration of statement.classes)
|
|
113
|
+
reject(declaration.name, declaration.span, "extern class");
|
|
114
|
+
break;
|
|
115
|
+
case "ImportDeclaration":
|
|
116
|
+
// A standard-module import of the name under itself *is* the built-in
|
|
117
|
+
// — `import {Color, Length} from "velar/look"` is how a module names
|
|
118
|
+
// the published types — so only a binding that would make the name
|
|
119
|
+
// mean something else is refused.
|
|
120
|
+
if (statement.source.startsWith("velar/")) {
|
|
121
|
+
for (const specifier of statement.specifiers) {
|
|
122
|
+
if (specifier.local !== specifier.imported)
|
|
123
|
+
reject(specifier.local, statement.span, "import alias");
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
for (const specifier of statement.specifiers) {
|
|
128
|
+
reject(specifier.local, statement.span, specifier.local === specifier.imported ? "imported name" : "import alias");
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
default:
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* WEB-C1: charter §14 promises that a key outside a keyed shape is a
|
|
138
|
+
* diagnostic rather than a silent no-op. Interpolated positions report while
|
|
139
|
+
* their interpolation is walked; static positions are collected during JSX
|
|
140
|
+
* inference and reported once every keyed interpolation is known.
|
|
141
|
+
*/
|
|
142
|
+
export function reportStaticJsxKeys(host) {
|
|
143
|
+
for (const { element, attribute } of host.staticJsxKeys) {
|
|
144
|
+
if (host.honoredJsxKeys.has(element) || host.reportedJsxKeys.has(element))
|
|
145
|
+
continue;
|
|
146
|
+
host.diagnostics.push(diagnostic("VEL5050", `This JSX key has no effect: '<${element.tag}>' is rendered in a fixed position, and keys reuse children by identity only inside 'items.map(item => <Row key={item.id} />)' — remove the key, or render this element from a keyed .map()`, attribute.span));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=program-passes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program-passes.js","sourceRoot":"","sources":["../../src/analysis/program-passes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAA8B,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAgB,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAChH,OAAO,EAAE,sBAAsB,EAA8C,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAsH,MAAM,WAAW,CAAC;AAC/I,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAA4D,MAAM,oBAAoB,CAAC;AAC/I,OAAO,EAAE,uBAAuB,EAAE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CAAC;gBACD,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;oBAC7C,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;gBACrH,CAAC;gBACD,MAAM;YACR;gBACE,MAAM;QACV,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAqB;IACvD,KAAK,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACxD,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,SAAS;QACpF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAC9B,SAAS,EACT,iCAAiC,OAAO,CAAC,GAAG,6LAA6L,EACzO,SAAS,CAAC,IAAI,CACf,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which declaration a name resolves to, and what follows from the answer: the
|
|
3
|
+
* three binding-identity questions, the root a mutation lands on, and the
|
|
4
|
+
* prop-specific wording a mutation of an explicitly readonly prop earns.
|
|
5
|
+
*
|
|
6
|
+
* D115 P4 R3c. Every question here is asked of the *binding* a name resolves
|
|
7
|
+
* to, never of the spelling, which is why they all start at `lookup` — a local
|
|
8
|
+
* `state` may shadow a derived or imported name, and the shadow is ordinary
|
|
9
|
+
* writable state.
|
|
10
|
+
*/
|
|
11
|
+
import { type Expression, type Statement } from "@velarscript/compiler/extension";
|
|
12
|
+
import { type ReactiveNamesHost } from "./host.ts";
|
|
13
|
+
/**
|
|
14
|
+
* True when `name` resolves to a `computed` declaration or to an imported one.
|
|
15
|
+
* The question is asked of the *binding* the name resolves to, never of the
|
|
16
|
+
* spelling: a local `state` may shadow an imported derived name, and that
|
|
17
|
+
* shadow is writable state.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isComputedBinding(host: ReactiveNamesHost, name: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* True when `name` resolves to a `resource` declaration. Asked of the binding
|
|
22
|
+
* rather than of the spelling, for the reason `isComputedBinding` is: a local
|
|
23
|
+
* `state` may shadow a resource's name, and the shadow is not a resource.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isResourceBinding(host: ReactiveNamesHost, name: string): boolean;
|
|
26
|
+
export declare function isImportedComputedBinding(host: ReactiveNamesHost, name: string): boolean;
|
|
27
|
+
export declare function writableStateName(host: ReactiveNamesHost, name: string): boolean;
|
|
28
|
+
export declare function directReadonlyPropMutation(host: ReactiveNamesHost, statement: Statement): string | null;
|
|
29
|
+
export declare function rootBindingName(expression: Expression): string | null;
|
|
30
|
+
/**
|
|
31
|
+
* D74: the readonly refusals the core raised while this statement was analyzed,
|
|
32
|
+
* restated so they name the prop and the author's own contract. The cursor is
|
|
33
|
+
* the diagnostic count taken before the core walked the statement, so only what
|
|
34
|
+
* this statement earned is rewritten.
|
|
35
|
+
*/
|
|
36
|
+
export declare function restateReadonlyPropMutation(host: ReactiveNamesHost, firstDiagnostic: number, readonlyProp: string | null): void;
|
|
37
|
+
//# sourceMappingURL=bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../../../src/analysis/reactivity/bindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGhF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGhF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGxF;AAID,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhF;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAavG;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CASrE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAU/H"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which declaration a name resolves to, and what follows from the answer: the
|
|
3
|
+
* three binding-identity questions, the root a mutation lands on, and the
|
|
4
|
+
* prop-specific wording a mutation of an explicitly readonly prop earns.
|
|
5
|
+
*
|
|
6
|
+
* D115 P4 R3c. Every question here is asked of the *binding* a name resolves
|
|
7
|
+
* to, never of the spelling, which is why they all start at `lookup` — a local
|
|
8
|
+
* `state` may shadow a derived or imported name, and the shadow is ordinary
|
|
9
|
+
* writable state.
|
|
10
|
+
*/
|
|
11
|
+
import { spanIdentity } from "@velarscript/compiler/extension";
|
|
12
|
+
import {} from "./host.js";
|
|
13
|
+
/**
|
|
14
|
+
* True when `name` resolves to a `computed` declaration or to an imported one.
|
|
15
|
+
* The question is asked of the *binding* the name resolves to, never of the
|
|
16
|
+
* spelling: a local `state` may shadow an imported derived name, and that
|
|
17
|
+
* shadow is writable state.
|
|
18
|
+
*/
|
|
19
|
+
export function isComputedBinding(host, name) {
|
|
20
|
+
const binding = host.lookup(name);
|
|
21
|
+
return binding !== null && host.computedBindingSpans.has(spanIdentity(binding.span));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* True when `name` resolves to a `resource` declaration. Asked of the binding
|
|
25
|
+
* rather than of the spelling, for the reason `isComputedBinding` is: a local
|
|
26
|
+
* `state` may shadow a resource's name, and the shadow is not a resource.
|
|
27
|
+
*/
|
|
28
|
+
export function isResourceBinding(host, name) {
|
|
29
|
+
const binding = host.lookup(name);
|
|
30
|
+
return binding !== null && host.resourceBindingSpans.has(spanIdentity(binding.span));
|
|
31
|
+
}
|
|
32
|
+
export function isImportedComputedBinding(host, name) {
|
|
33
|
+
const binding = host.lookup(name);
|
|
34
|
+
return binding !== null && host.importedComputedSpans.has(spanIdentity(binding.span));
|
|
35
|
+
}
|
|
36
|
+
// A name refers to writable reactive state only when ordinary lexical lookup
|
|
37
|
+
// still resolves it to the state binding; a shadowing local wins instead.
|
|
38
|
+
export function writableStateName(host, name) {
|
|
39
|
+
return host.reactiveBindingKind(name) === "state";
|
|
40
|
+
}
|
|
41
|
+
export function directReadonlyPropMutation(host, statement) {
|
|
42
|
+
let target = null;
|
|
43
|
+
if (statement.kind === "AssignmentStatement" && statement.target.kind !== "IdentifierExpression") {
|
|
44
|
+
target = statement.target;
|
|
45
|
+
}
|
|
46
|
+
else if (statement.kind === "ExpressionStatement" && statement.expression.kind === "CallExpression"
|
|
47
|
+
&& statement.expression.callee.kind === "MemberExpression") {
|
|
48
|
+
target = statement.expression.callee.object;
|
|
49
|
+
}
|
|
50
|
+
if (!target)
|
|
51
|
+
return null;
|
|
52
|
+
const name = rootBindingName(target);
|
|
53
|
+
if (!name)
|
|
54
|
+
return null;
|
|
55
|
+
const binding = host.lookup(name);
|
|
56
|
+
return binding && host.explicitReadonlyPropBindings.get(name) === binding.span.start ? name : null;
|
|
57
|
+
}
|
|
58
|
+
export function rootBindingName(expression) {
|
|
59
|
+
if (expression.kind === "IdentifierExpression")
|
|
60
|
+
return expression.name;
|
|
61
|
+
if (expression.kind === "MemberExpression" || expression.kind === "IndexExpression") {
|
|
62
|
+
return rootBindingName(expression.object);
|
|
63
|
+
}
|
|
64
|
+
if (expression.kind === "CallExpression" && expression.callee.kind === "MemberExpression") {
|
|
65
|
+
return rootBindingName(expression.callee.object);
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* D74: the readonly refusals the core raised while this statement was analyzed,
|
|
71
|
+
* restated so they name the prop and the author's own contract. The cursor is
|
|
72
|
+
* the diagnostic count taken before the core walked the statement, so only what
|
|
73
|
+
* this statement earned is rewritten.
|
|
74
|
+
*/
|
|
75
|
+
export function restateReadonlyPropMutation(host, firstDiagnostic, readonlyProp) {
|
|
76
|
+
if (!readonlyProp)
|
|
77
|
+
return;
|
|
78
|
+
for (let index = firstDiagnostic; index < host.diagnostics.length; index += 1) {
|
|
79
|
+
const item = host.diagnostics[index];
|
|
80
|
+
if ((item.code !== "VEL3002" && item.code !== "VEL4001") || !/read-?only|readonly/iu.test(item.message))
|
|
81
|
+
continue;
|
|
82
|
+
host.diagnostics[index] = {
|
|
83
|
+
...item,
|
|
84
|
+
message: `Cannot mutate prop '${readonlyProp}': this component's author explicitly declared it 'readonly'. ${item.message}`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../../src/analysis/reactivity/bindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,YAAY,EAAmC,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAA0B,MAAM,WAAW,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAuB,EAAE,IAA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W,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC9E,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAE,CAAC;QACtC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;YAAE,SAAS;QAClH,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG;YACxB,GAAG,IAAI;YACP,OAAO,EAAE,uBAAuB,YAAY,iEAAiE,IAAI,CAAC,OAAO,EAAE;SAC5H,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a derived value refuses and what a derived read is: the call that should
|
|
3
|
+
* have been a bare read, the assignment that has no location to land on, and the
|
|
4
|
+
* reading that decides whether a name really resolves to a reactive derivation
|
|
5
|
+
* here.
|
|
6
|
+
*
|
|
7
|
+
* D115 P4 R3c. The three sit above `bindings.ts` because each of them starts by
|
|
8
|
+
* asking which declaration a name resolves to and then says what follows.
|
|
9
|
+
*/
|
|
10
|
+
import { type Expression, type Statement, type ValueType } from "@velarscript/compiler/extension";
|
|
11
|
+
import { type ReactiveNamesHost } from "./host.ts";
|
|
12
|
+
/**
|
|
13
|
+
* D71 rule 182: a declared derived value is read bare, exactly like state.
|
|
14
|
+
* Calling one is the habit the retired `computed(...)` accessor taught, and it
|
|
15
|
+
* is also what a half-migrated project looks like from the importing side — so
|
|
16
|
+
* the answer names the one spelling and carries the edit that reaches it,
|
|
17
|
+
* which is what lets `velar fix` finish a migration that crosses modules.
|
|
18
|
+
*/
|
|
19
|
+
export declare function calledComputedBinding(host: ReactiveNamesHost, expression: Extract<Expression, {
|
|
20
|
+
readonly kind: "CallExpression";
|
|
21
|
+
}>): ValueType | null;
|
|
22
|
+
/**
|
|
23
|
+
* D71 rule 182: a derived value has no writable location behind it, so the
|
|
24
|
+
* const message ("cannot assign to const binding") would name the wrong
|
|
25
|
+
* reason. Answering here means the reader is told what a derived value is and
|
|
26
|
+
* which spelling holds a value that is written.
|
|
27
|
+
*/
|
|
28
|
+
export declare function rejectComputedAssignment(host: ReactiveNamesHost, statement: Extract<Statement, {
|
|
29
|
+
readonly kind: "AssignmentStatement";
|
|
30
|
+
}>): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* True when a name both belongs to a derived reactive declaration and still
|
|
33
|
+
* resolves to one here: a computed accessor is a zero-argument function, and a
|
|
34
|
+
* resource or action handle is a record with its reactive fields. An ordinary
|
|
35
|
+
* binding that happens to share the name — a function parameter, a local — is
|
|
36
|
+
* not a reactive read.
|
|
37
|
+
*/
|
|
38
|
+
export declare function derivedReactiveRead(host: ReactiveNamesHost, name: string): boolean;
|
|
39
|
+
//# sourceMappingURL=derived.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derived.d.ts","sourceRoot":"","sources":["../../../src/analysis/reactivity/derived.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAiB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjH,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,iBAAiB,EACvB,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GACnE,SAAS,GAAG,IAAI,CAmBlB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,iBAAiB,EACvB,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAA;CAAE,CAAC,GACtE,OAAO,CAaT;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAOlF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a derived value refuses and what a derived read is: the call that should
|
|
3
|
+
* have been a bare read, the assignment that has no location to land on, and the
|
|
4
|
+
* reading that decides whether a name really resolves to a reactive derivation
|
|
5
|
+
* here.
|
|
6
|
+
*
|
|
7
|
+
* D115 P4 R3c. The three sit above `bindings.ts` because each of them starts by
|
|
8
|
+
* asking which declaration a name resolves to and then says what follows.
|
|
9
|
+
*/
|
|
10
|
+
import { isInvalidType } from "@velarscript/compiler/extension";
|
|
11
|
+
import { diagnostic } from "../web-types.js";
|
|
12
|
+
import { isComputedBinding, isImportedComputedBinding } from "./bindings.js";
|
|
13
|
+
import {} from "./host.js";
|
|
14
|
+
/**
|
|
15
|
+
* D71 rule 182: a declared derived value is read bare, exactly like state.
|
|
16
|
+
* Calling one is the habit the retired `computed(...)` accessor taught, and it
|
|
17
|
+
* is also what a half-migrated project looks like from the importing side — so
|
|
18
|
+
* the answer names the one spelling and carries the edit that reaches it,
|
|
19
|
+
* which is what lets `velar fix` finish a migration that crosses modules.
|
|
20
|
+
*/
|
|
21
|
+
export function calledComputedBinding(host, expression) {
|
|
22
|
+
if (expression.callee.kind !== "IdentifierExpression")
|
|
23
|
+
return null;
|
|
24
|
+
const name = expression.callee.name;
|
|
25
|
+
if (!isComputedBinding(host, name))
|
|
26
|
+
return null;
|
|
27
|
+
const type = host.inferExpression(expression.callee);
|
|
28
|
+
// A derived value that *is* a function is called on purpose; only a
|
|
29
|
+
// non-callable one makes the parentheses a mistake.
|
|
30
|
+
const expanded = host.expandAliases(type);
|
|
31
|
+
if (expanded.kind === "function" || expanded.kind === "intrinsic" || expanded.kind === "any" || isInvalidType(expanded))
|
|
32
|
+
return null;
|
|
33
|
+
host.diagnostics.push({
|
|
34
|
+
code: "VEL5063",
|
|
35
|
+
message: `'${name}' is a computed value, not a reader: it is read bare like state, so write '${name}' rather than '${name}()'`,
|
|
36
|
+
span: expression.span,
|
|
37
|
+
fix: {
|
|
38
|
+
title: `Read '${name}' bare`,
|
|
39
|
+
edits: [{ span: { start: expression.callee.span.end, end: expression.span.end }, text: "" }],
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
return type;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* D71 rule 182: a derived value has no writable location behind it, so the
|
|
46
|
+
* const message ("cannot assign to const binding") would name the wrong
|
|
47
|
+
* reason. Answering here means the reader is told what a derived value is and
|
|
48
|
+
* which spelling holds a value that is written.
|
|
49
|
+
*/
|
|
50
|
+
export function rejectComputedAssignment(host, statement) {
|
|
51
|
+
if (statement.target.kind !== "IdentifierExpression")
|
|
52
|
+
return false;
|
|
53
|
+
const name = statement.target.name;
|
|
54
|
+
if (!isComputedBinding(host, name))
|
|
55
|
+
return false;
|
|
56
|
+
host.diagnostics.push(diagnostic("VEL5063", isImportedComputedBinding(host, name)
|
|
57
|
+
? `'${name}' is a computed value derived in the module it comes from, so it has no location here to assign. Export a 'state' — or an action that writes one — and change that instead`
|
|
58
|
+
: `'${name}' is a computed value: it is recomputed from what it reads and is never assigned. Assign the state it reads, or declare it 'state ${name} = ...' if this value is written directly`, statement.target.span));
|
|
59
|
+
host.inferExpression(statement.value);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* True when a name both belongs to a derived reactive declaration and still
|
|
64
|
+
* resolves to one here: a computed accessor is a zero-argument function, and a
|
|
65
|
+
* resource or action handle is a record with its reactive fields. An ordinary
|
|
66
|
+
* binding that happens to share the name — a function parameter, a local — is
|
|
67
|
+
* not a reactive read.
|
|
68
|
+
*/
|
|
69
|
+
export function derivedReactiveRead(host, name) {
|
|
70
|
+
if (!host.derivedReactiveNames.has(name))
|
|
71
|
+
return false;
|
|
72
|
+
const binding = host.lookup(name);
|
|
73
|
+
if (!binding)
|
|
74
|
+
return false;
|
|
75
|
+
const type = host.expandAliases(binding.type);
|
|
76
|
+
if (type.kind === "function" || type.kind === "action")
|
|
77
|
+
return type.parameters.length === 0 && !type.rest;
|
|
78
|
+
return type.kind === "object" && (type.fields.has("reload") || type.fields.has("pending"));
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=derived.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derived.js","sourceRoot":"","sources":["../../../src/analysis/reactivity/derived.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAmD,MAAM,iCAAiC,CAAC;AACjH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAA0B,MAAM,WAAW,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,IAAuB,EACvB,UAAoE;IAEpE,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAsB;QAAE,OAAO,IAAI,CAAC;IACnE,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC;IACpC,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAChD,MAAM,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACrD,oEAAoE;IACpE,oDAAoD;IACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,QAAQ,CAAC,IAAI,KAAK,UAAU,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,IAAI,QAAQ,CAAC,IAAI,KAAK,KAAK,IAAI,aAAa,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IACrI,IAAI,CAAC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OAAO,KAAK,CAAC;IACvD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAC1G,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the reactive-name rules ask of the analyzer that hosts them: the span
|
|
3
|
+
* tables that say which declaration a name resolves to, and the analyzer
|
|
4
|
+
* operations those rules perform.
|
|
5
|
+
*
|
|
6
|
+
* D115 P4 R3c. The tables are `private` on the analyzer, so the object
|
|
7
|
+
* satisfying this interface is built inside that class and nowhere else
|
|
8
|
+
* (TS2341, D114 line 512). The retired-accessor migration declares its own
|
|
9
|
+
* `RetiredAccessorHost` beside its rules, because the tables it reads are the
|
|
10
|
+
* ones it fills itself and it shares none of these.
|
|
11
|
+
*/
|
|
12
|
+
import { type Diagnostic, type Span } from "@velarscript/compiler";
|
|
13
|
+
import { type Expression, type ValueType } from "@velarscript/compiler/extension";
|
|
14
|
+
export interface ReactiveNamesHost {
|
|
15
|
+
/**
|
|
16
|
+
* D71 rule 182: the declaration spans of every `computed` binding in scope.
|
|
17
|
+
* A binding's span survives narrowing, so it identifies the declaration a
|
|
18
|
+
* name resolves to even where a narrowed copy answers the lookup.
|
|
19
|
+
*/
|
|
20
|
+
readonly computedBindingSpans: ReadonlySet<string>;
|
|
21
|
+
/** Every name in this module whose read is reactive without the binding being a state/prop reference. */
|
|
22
|
+
readonly derivedReactiveNames: ReadonlySet<string>;
|
|
23
|
+
/** D74: only props whose authors wrote a readonly contract receive prop-specific guidance. Replaced per component. */
|
|
24
|
+
readonly explicitReadonlyPropBindings: ReadonlyMap<string, number>;
|
|
25
|
+
/** The resolved spans of imported `export computed` bindings, so a local shadow of the name is not one. */
|
|
26
|
+
readonly importedComputedSpans: ReadonlySet<string>;
|
|
27
|
+
/** D114 W: the declaration spans of every `resource` in scope, kept the way `computedBindingSpans` is. */
|
|
28
|
+
readonly resourceBindingSpans: ReadonlySet<string>;
|
|
29
|
+
readonly diagnostics: Diagnostic[];
|
|
30
|
+
expandAliases(type: ValueType): ValueType;
|
|
31
|
+
inferExpression(expression: Expression, contextualType?: ValueType): ValueType;
|
|
32
|
+
lookup(name: string): {
|
|
33
|
+
readonly span: Span;
|
|
34
|
+
readonly type: ValueType;
|
|
35
|
+
} | null;
|
|
36
|
+
reactiveBindingKind(name: string): "state" | "prop" | null;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../src/analysis/reactivity/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAElF,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,QAAQ,CAAC,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnD,yGAAyG;IACzG,QAAQ,CAAC,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnD,sHAAsH;IACtH,QAAQ,CAAC,4BAA4B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnE,2GAA2G;IAC3G,QAAQ,CAAC,qBAAqB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpD,0GAA0G;IAC1G,QAAQ,CAAC,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAEnD,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAC;IACnC,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC1C,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,cAAc,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/E,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;KAAE,GAAG,IAAI,CAAC;IAC/E,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the reactive-name rules ask of the analyzer that hosts them: the span
|
|
3
|
+
* tables that say which declaration a name resolves to, and the analyzer
|
|
4
|
+
* operations those rules perform.
|
|
5
|
+
*
|
|
6
|
+
* D115 P4 R3c. The tables are `private` on the analyzer, so the object
|
|
7
|
+
* satisfying this interface is built inside that class and nowhere else
|
|
8
|
+
* (TS2341, D114 line 512). The retired-accessor migration declares its own
|
|
9
|
+
* `RetiredAccessorHost` beside its rules, because the tables it reads are the
|
|
10
|
+
* ones it fills itself and it shares none of these.
|
|
11
|
+
*/
|
|
12
|
+
import {} from "@velarscript/compiler";
|
|
13
|
+
import {} from "@velarscript/compiler/extension";
|
|
14
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../../src/analysis/reactivity/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAA8B,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAmC,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The retired 'computed(...)' accessor: the intrinsic a call around it is still
|
|
3
|
+
* typed by, and the shape of one declaration held for the migration message.
|
|
4
|
+
*
|
|
5
|
+
* D115 P4 R3a: a frozen table and a record shape, read by the analyzer and by
|
|
6
|
+
* the intrinsic that types the call, so they read as a module.
|
|
7
|
+
*
|
|
8
|
+
* D115 P4 R3c: the migration pass itself joins them — what one declaration
|
|
9
|
+
* records, what one read records, and the one message per site the whole-program
|
|
10
|
+
* report writes — over a `RetiredAccessorHost`.
|
|
11
|
+
*/
|
|
12
|
+
import { type Diagnostic, type Span } from "@velarscript/compiler";
|
|
13
|
+
import { type Expression, type Statement, type ValueType } from "@velarscript/compiler/extension";
|
|
14
|
+
/**
|
|
15
|
+
* `computed(...)` the function is answered with the signature it always had, so
|
|
16
|
+
* a call written around it still type-checks instead of collapsing into an
|
|
17
|
+
* unknown one — that is what keeps the one message about the declaration form
|
|
18
|
+
* the only thing the author reads. `reactive.computed` itself is gone; this one
|
|
19
|
+
* derives no reactivity and is never emitted, because every site that produces
|
|
20
|
+
* it also produces an error. It stays an intrinsic only so the reader it
|
|
21
|
+
* returns carries the callback's own result: an annotated declaration —
|
|
22
|
+
* `const one: () -> number = computed(() => 1)` — would otherwise read a
|
|
23
|
+
* second, spurious assignability error on top of it.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* What the D71 migration off `computed(...)` the function asks: the four tables
|
|
27
|
+
* it fills while the module is walked and reads once the walk has ended, and
|
|
28
|
+
* the lookup that tells a global accessor apart from a binding of the name.
|
|
29
|
+
*/
|
|
30
|
+
export interface RetiredAccessorHost {
|
|
31
|
+
/** Callee spans already claimed by a recognised `const x = computed(...)` declaration. */
|
|
32
|
+
readonly migratedComputedCallees: Set<string>;
|
|
33
|
+
/** Callee span identity -> call span, for every zero-argument call of a plain name. */
|
|
34
|
+
readonly plainCallSpans: Map<string, Span>;
|
|
35
|
+
readonly retiredAccessorDeclarations: Map<string, RetiredAccessorDeclaration>;
|
|
36
|
+
readonly retiredAccessorReads: Map<string, Span[]>;
|
|
37
|
+
readonly retiredComputedReferences: Map<string, {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly span: Span;
|
|
40
|
+
}>;
|
|
41
|
+
readonly diagnostics: Diagnostic[];
|
|
42
|
+
lookup(name: string): {
|
|
43
|
+
readonly span: Span;
|
|
44
|
+
readonly type: ValueType;
|
|
45
|
+
} | null;
|
|
46
|
+
}
|
|
47
|
+
export declare const RETIRED_ACCESSOR_INTRINSIC = "reactive.retired-accessor";
|
|
48
|
+
export declare const RETIRED_ACCESSOR_TYPE: ValueType;
|
|
49
|
+
export interface RetiredAccessorDeclaration {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly exported: boolean;
|
|
52
|
+
/** The named function the argument reads through, when it is one — `computed(readA)`. */
|
|
53
|
+
readonly readName: string | null;
|
|
54
|
+
readonly declarationSpan: Span;
|
|
55
|
+
readonly callSpan: Span;
|
|
56
|
+
/** The `() => E` body span, or null when the argument is not that shape. */
|
|
57
|
+
readonly bodySpan: Span | null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* D71 rule 183: `computed(...)` the function — the shape Vue and the signals
|
|
61
|
+
* libraries teach — is not how a derived value is written here; the `computed`
|
|
62
|
+
* declaration is. The declaration is recorded before the core walks the module
|
|
63
|
+
* so its reads can be matched against it — the rewrite that removes the call
|
|
64
|
+
* parentheses is only offered when every read is a plain `x()`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function recordRetiredAccessorDeclaration(host: RetiredAccessorHost, statement: Extract<Statement, {
|
|
67
|
+
readonly kind: "VariableDeclaration";
|
|
68
|
+
}>): void;
|
|
69
|
+
/** Returns true when the name is one of the retired accessor globals this pass owns. */
|
|
70
|
+
export declare function recordRetiredAccessorRead(host: RetiredAccessorHost, expression: Extract<Expression, {
|
|
71
|
+
readonly kind: "IdentifierExpression";
|
|
72
|
+
}>): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* D71 migration: one message per site, and a mechanical rewrite only where
|
|
75
|
+
* the compile can prove the rewrite. Where the
|
|
76
|
+
* accessor is used as a value there is no second spelling left to offer, so
|
|
77
|
+
* that site is told to declare the value and write an ordinary `def` where a
|
|
78
|
+
* callable is what the caller wants — and it gets no edit, because moving a
|
|
79
|
+
* reader out of a value position is the author's decision.
|
|
80
|
+
*/
|
|
81
|
+
export declare function reportRetiredComputedFunction(host: RetiredAccessorHost): void;
|
|
82
|
+
//# sourceMappingURL=retired-accessors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retired-accessors.d.ts","sourceRoot":"","sources":["../../../src/analysis/reactivity/retired-accessors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAA6B,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAI7H;;;;;;;;;;GAUG;AACH;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,0FAA0F;IAC1F,QAAQ,CAAC,uBAAuB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9C,uFAAuF;IACvF,QAAQ,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3C,QAAQ,CAAC,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IAC9E,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,QAAQ,CAAC,yBAAyB,EAAE,GAAG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