@velarscript/web 0.31.0 → 0.32.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 +12 -0
- package/dist/analysis/calls/intrinsics/storage.d.ts.map +1 -0
- package/dist/analysis/calls/intrinsics/storage.js +86 -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 +67 -0
- package/dist/analysis/inference.d.ts.map +1 -0
- package/dist/analysis/inference.js +236 -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 +168 -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 +25 -0
- package/dist/analysis/look/edits.d.ts.map +1 -0
- package/dist/analysis/look/edits.js +57 -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 +151 -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 +54 -0
- package/dist/analysis/look-sites.d.ts.map +1 -0
- package/dist/analysis/look-sites.js +104 -0
- package/dist/analysis/look-sites.js.map +1 -0
- 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 +208 -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 +29 -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 +184 -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/package.json +2 -2
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a function body holds, read from its statements: the first reactive
|
|
3
|
+
* declaration a 'def' answering WebNode may not carry, whether the body returns
|
|
4
|
+
* JSX, and the markup roots it returns.
|
|
5
|
+
*
|
|
6
|
+
* D115 P4 R3a: these are readings of an AST subtree, not of the analyzer, so
|
|
7
|
+
* they read as a module.
|
|
8
|
+
*/
|
|
9
|
+
import { type Span } from "@velarscript/compiler";
|
|
10
|
+
import { type Expression, type Statement, type ValueType } from "@velarscript/compiler/extension";
|
|
11
|
+
import { type WebJsxElementExpression as JSXElementExpression } from "../ast.ts";
|
|
12
|
+
/**
|
|
13
|
+
* The first reactive declaration a body holds, in source order. A nested `def`
|
|
14
|
+
* or `component` owns its own declarations, so the walk stops at one.
|
|
15
|
+
*/
|
|
16
|
+
export declare function firstReactiveDeclaration(body: readonly Statement[]): {
|
|
17
|
+
readonly label: string;
|
|
18
|
+
readonly span: Span;
|
|
19
|
+
} | null;
|
|
20
|
+
/**
|
|
21
|
+
* Whether a type answers markup. `WebNode` is the value, and `WebNode?` and
|
|
22
|
+
* `List<WebNode>` are the two shapes markup legitimately travels in — a helper
|
|
23
|
+
* that answers "this row, or nothing" and one that answers a row per item.
|
|
24
|
+
* Reading only the bare annotation closed the spelling instead of the sink:
|
|
25
|
+
* the identical body under `-> WebNode?` reached the same defect unreported.
|
|
26
|
+
*/
|
|
27
|
+
export declare function carriesWebNode(type: ValueType): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a body's own `return`s carry JSX. A return type is optional on a
|
|
30
|
+
* `def`, and an omitted one left the same defective helper unreported, so the
|
|
31
|
+
* markup the body returns answers for the annotation that was never written.
|
|
32
|
+
* A nested `def` or `component` owns its own returns, exactly as it owns its
|
|
33
|
+
* own declarations.
|
|
34
|
+
*/
|
|
35
|
+
export declare function bodyReturnsJsx(body: readonly Statement[]): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* VEL5075: the JSX elements a body's own `return`s *start* with — the roots of
|
|
38
|
+
* the returned markup, which is where the emitter decides between an instance
|
|
39
|
+
* and a child. The walk descends through ordinary expression nodes, `.map(...)`
|
|
40
|
+
* callbacks included, and stops at the first JSX element on every path: inside
|
|
41
|
+
* one, every JSX position is a child position and needs no verdict. A nested
|
|
42
|
+
* `def` or `component` owns its own returns, exactly as it does elsewhere here.
|
|
43
|
+
*/
|
|
44
|
+
export declare function returnedMarkupRoots(body: readonly Statement[]): readonly JSXElementExpression[];
|
|
45
|
+
/** The component spelling of a helper's name: components render as a PascalCase tag. */
|
|
46
|
+
export declare function componentSpelling(name: string): string;
|
|
47
|
+
/** `{ id: item.id }` in a callback over `item`: the field carries its own value over unchanged. */
|
|
48
|
+
export declare function rowFieldPassthrough(value: Expression, row: string, name: string): boolean;
|
|
49
|
+
//# sourceMappingURL=jsx-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-detection.d.ts","sourceRoot":"","sources":["../../src/analysis/jsx-detection.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAClG,OAAO,EAAE,KAAK,uBAAuB,IAAI,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAkBjF;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAsB3H;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAKvD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,GAAG,OAAO,CAmBlE;AA0BD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,oBAAoB,EAAE,CAqC/F;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,mGAAmG;AACnG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGzF"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a function body holds, read from its statements: the first reactive
|
|
3
|
+
* declaration a 'def' answering WebNode may not carry, whether the body returns
|
|
4
|
+
* JSX, and the markup roots it returns.
|
|
5
|
+
*
|
|
6
|
+
* D115 P4 R3a: these are readings of an AST subtree, not of the analyzer, so
|
|
7
|
+
* they read as a module.
|
|
8
|
+
*/
|
|
9
|
+
import {} from "@velarscript/compiler";
|
|
10
|
+
import {} from "@velarscript/compiler/extension";
|
|
11
|
+
import {} from "../ast.js";
|
|
12
|
+
import { isWebNodeType } from "../types.js";
|
|
13
|
+
/**
|
|
14
|
+
* The reactive declarations a `def` body may not hold when the `def` answers
|
|
15
|
+
* `WebNode`. `watch`, `resource` and `action` are already refused outside a
|
|
16
|
+
* module or component scope (VEL3010/VEL3012/VEL3013); they stay listed because
|
|
17
|
+
* the defect is the declaration, not which of them the author reached for.
|
|
18
|
+
*/
|
|
19
|
+
const WEB_REACTIVE_DECLARATION_LABELS = new Map([
|
|
20
|
+
["ExtensionStatement:web:state", "'state'"],
|
|
21
|
+
["ExtensionStatement:web:computed", "'computed'"],
|
|
22
|
+
["ExtensionStatement:web:resource", "'resource'"],
|
|
23
|
+
["ExtensionStatement:web:watch", "'watch'"],
|
|
24
|
+
["ExtensionStatement:web:mounted", "'@mounted'"],
|
|
25
|
+
["ExtensionStatement:web:cleanup", "'@cleanup'"],
|
|
26
|
+
]);
|
|
27
|
+
/**
|
|
28
|
+
* The first reactive declaration a body holds, in source order. A nested `def`
|
|
29
|
+
* or `component` owns its own declarations, so the walk stops at one.
|
|
30
|
+
*/
|
|
31
|
+
export function firstReactiveDeclaration(body) {
|
|
32
|
+
let found = null;
|
|
33
|
+
const pending = [...body];
|
|
34
|
+
while (pending.length > 0) {
|
|
35
|
+
const value = pending.pop();
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
for (const entry of value)
|
|
38
|
+
pending.push(entry);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (value === null || typeof value !== "object")
|
|
42
|
+
continue;
|
|
43
|
+
const node = value;
|
|
44
|
+
const kind = typeof node.kind === "string" ? node.kind : null;
|
|
45
|
+
if (kind === "FunctionDeclaration" || kind === "ExtensionStatement:web:component")
|
|
46
|
+
continue;
|
|
47
|
+
const label = kind === null ? undefined : WEB_REACTIVE_DECLARATION_LABELS.get(kind);
|
|
48
|
+
if (label !== undefined) {
|
|
49
|
+
const span = node.span;
|
|
50
|
+
if (found === null || span.start < found.span.start)
|
|
51
|
+
found = { label, span };
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
for (const key of Object.keys(node))
|
|
55
|
+
pending.push(node[key]);
|
|
56
|
+
}
|
|
57
|
+
return found;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Whether a type answers markup. `WebNode` is the value, and `WebNode?` and
|
|
61
|
+
* `List<WebNode>` are the two shapes markup legitimately travels in — a helper
|
|
62
|
+
* that answers "this row, or nothing" and one that answers a row per item.
|
|
63
|
+
* Reading only the bare annotation closed the spelling instead of the sink:
|
|
64
|
+
* the identical body under `-> WebNode?` reached the same defect unreported.
|
|
65
|
+
*/
|
|
66
|
+
export function carriesWebNode(type) {
|
|
67
|
+
if (isWebNodeType(type))
|
|
68
|
+
return true;
|
|
69
|
+
if (type.kind === "optional")
|
|
70
|
+
return carriesWebNode(type.inner);
|
|
71
|
+
if (type.kind === "list")
|
|
72
|
+
return carriesWebNode(type.element);
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Whether a body's own `return`s carry JSX. A return type is optional on a
|
|
77
|
+
* `def`, and an omitted one left the same defective helper unreported, so the
|
|
78
|
+
* markup the body returns answers for the annotation that was never written.
|
|
79
|
+
* A nested `def` or `component` owns its own returns, exactly as it owns its
|
|
80
|
+
* own declarations.
|
|
81
|
+
*/
|
|
82
|
+
export function bodyReturnsJsx(body) {
|
|
83
|
+
const pending = [...body];
|
|
84
|
+
while (pending.length > 0) {
|
|
85
|
+
const value = pending.pop();
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
for (const entry of value)
|
|
88
|
+
pending.push(entry);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (value === null || typeof value !== "object")
|
|
92
|
+
continue;
|
|
93
|
+
const node = value;
|
|
94
|
+
const kind = typeof node.kind === "string" ? node.kind : null;
|
|
95
|
+
if (kind === "FunctionDeclaration" || kind === "ExtensionStatement:web:component")
|
|
96
|
+
continue;
|
|
97
|
+
if (kind === "ReturnStatement") {
|
|
98
|
+
if (subtreeHoldsJsx(node.value))
|
|
99
|
+
return true;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
for (const key of Object.keys(node))
|
|
103
|
+
pending.push(node[key]);
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A returned expression that builds markup anywhere inside it — bare, inside a
|
|
109
|
+
* List, behind a condition, or built by the callback of a `.map(...)` that
|
|
110
|
+
* answers a row per item. The arrow is walked rather than skipped for the same
|
|
111
|
+
* reason the optional and List annotations are unwrapped: `rows()` returning
|
|
112
|
+
* `items.map(item => <li>…</li>)` is a markup helper by every measure except
|
|
113
|
+
* the one spelling that was being read.
|
|
114
|
+
*/
|
|
115
|
+
function subtreeHoldsJsx(value) {
|
|
116
|
+
const pending = [value];
|
|
117
|
+
while (pending.length > 0) {
|
|
118
|
+
const entry = pending.pop();
|
|
119
|
+
if (Array.isArray(entry)) {
|
|
120
|
+
for (const item of entry)
|
|
121
|
+
pending.push(item);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (entry === null || typeof entry !== "object")
|
|
125
|
+
continue;
|
|
126
|
+
const node = entry;
|
|
127
|
+
if (node.kind === "ExtensionExpression:web:jsx")
|
|
128
|
+
return true;
|
|
129
|
+
for (const key of Object.keys(node))
|
|
130
|
+
pending.push(node[key]);
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* VEL5075: the JSX elements a body's own `return`s *start* with — the roots of
|
|
136
|
+
* the returned markup, which is where the emitter decides between an instance
|
|
137
|
+
* and a child. The walk descends through ordinary expression nodes, `.map(...)`
|
|
138
|
+
* callbacks included, and stops at the first JSX element on every path: inside
|
|
139
|
+
* one, every JSX position is a child position and needs no verdict. A nested
|
|
140
|
+
* `def` or `component` owns its own returns, exactly as it does elsewhere here.
|
|
141
|
+
*/
|
|
142
|
+
export function returnedMarkupRoots(body) {
|
|
143
|
+
const roots = [];
|
|
144
|
+
const collect = (value) => {
|
|
145
|
+
const pending = [value];
|
|
146
|
+
while (pending.length > 0) {
|
|
147
|
+
const entry = pending.pop();
|
|
148
|
+
if (Array.isArray(entry)) {
|
|
149
|
+
for (const item of entry)
|
|
150
|
+
pending.push(item);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (entry === null || typeof entry !== "object")
|
|
154
|
+
continue;
|
|
155
|
+
const node = entry;
|
|
156
|
+
if (node.kind === "ExtensionExpression:web:jsx") {
|
|
157
|
+
roots.push(node);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
for (const key of Object.keys(node))
|
|
161
|
+
pending.push(node[key]);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const pending = [...body];
|
|
165
|
+
while (pending.length > 0) {
|
|
166
|
+
const value = pending.pop();
|
|
167
|
+
if (Array.isArray(value)) {
|
|
168
|
+
for (const entry of value)
|
|
169
|
+
pending.push(entry);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (value === null || typeof value !== "object")
|
|
173
|
+
continue;
|
|
174
|
+
const node = value;
|
|
175
|
+
const kind = typeof node.kind === "string" ? node.kind : null;
|
|
176
|
+
if (kind === "FunctionDeclaration" || kind === "ExtensionStatement:web:component")
|
|
177
|
+
continue;
|
|
178
|
+
if (kind === "ReturnStatement") {
|
|
179
|
+
collect(node.value);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
for (const key of Object.keys(node))
|
|
183
|
+
pending.push(node[key]);
|
|
184
|
+
}
|
|
185
|
+
return roots;
|
|
186
|
+
}
|
|
187
|
+
/** The component spelling of a helper's name: components render as a PascalCase tag. */
|
|
188
|
+
export function componentSpelling(name) {
|
|
189
|
+
return name.length === 0 ? name : `${name[0].toUpperCase()}${name.slice(1)}`;
|
|
190
|
+
}
|
|
191
|
+
/** `{ id: item.id }` in a callback over `item`: the field carries its own value over unchanged. */
|
|
192
|
+
export function rowFieldPassthrough(value, row, name) {
|
|
193
|
+
return value.kind === "MemberExpression" && value.property === name
|
|
194
|
+
&& value.object.kind === "IdentifierExpression" && value.object.name === row;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=jsx-detection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-detection.js","sourceRoot":"","sources":["../../src/analysis/jsx-detection.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAa,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAmD,MAA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C;AACjF,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D89 A4: a 'map' callback that rebuilds its rows instead of carrying them
|
|
3
|
+
* over, which is what a keyed list stops recognising — what one rebuild records,
|
|
4
|
+
* and the module reading that decides whether a helper builds fresh records at
|
|
5
|
+
* all.
|
|
6
|
+
*
|
|
7
|
+
* D115 P4 R3a: the advisory is raised from the analyzer's JSX pass, but every
|
|
8
|
+
* reading it rests on is a reading of the program, so they read as a module.
|
|
9
|
+
*
|
|
10
|
+
* D115 P4 R3c: the four rules that record a rebuild and raise the advisory join
|
|
11
|
+
* them, over a `KeyedRebuildHost`.
|
|
12
|
+
*/
|
|
13
|
+
import { type DiagnosticFix, type Span } from "@velarscript/compiler";
|
|
14
|
+
import { type Expression, type Program, type Statement, type ValueType } from "@velarscript/compiler/extension";
|
|
15
|
+
import { type WebComputedDeclaration as ComputedDeclaration } from "../ast.ts";
|
|
16
|
+
/**
|
|
17
|
+
* D89 A4: what a `map` callback rebuilds, when it returns a newly built record
|
|
18
|
+
* instead of the row it was handed. Null is the non-trigger answer the ruling
|
|
19
|
+
* names — a callback that returns its parameter, or anything else that is not a
|
|
20
|
+
* record literal, builds nothing and moves no identity. A record is reported
|
|
21
|
+
* even when no field can be named, because it is the rebuilt row's own identity
|
|
22
|
+
* that the keyed list stops recognising, not any one field it carries.
|
|
23
|
+
*
|
|
24
|
+
* A conditional is read through because the React spelling nearly always
|
|
25
|
+
* carries one, `t.id == id ? {...t, done: true} : t`, and its `else` branch is
|
|
26
|
+
* the returns-the-original case rather than a second shape. A branch that names
|
|
27
|
+
* a field is preferred, since a suggestion that names one is the whole product.
|
|
28
|
+
*/
|
|
29
|
+
export declare function keyedRebuiltRecord(body: Expression, row: string): {
|
|
30
|
+
readonly field: string | null;
|
|
31
|
+
} | null;
|
|
32
|
+
export type FunctionDeclarationStatement = Extract<Statement, {
|
|
33
|
+
readonly kind: "FunctionDeclaration";
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* D89 A4, the wider proven shape: every `def` of the module by name, so a
|
|
37
|
+
* `computed` whose initializer calls one can be read through to what that call
|
|
38
|
+
* builds. A name declared twice maps to null — two bodies under one name make
|
|
39
|
+
* the question unanswerable, and an advisory that cannot prove which body runs
|
|
40
|
+
* stays silent rather than guessing.
|
|
41
|
+
*/
|
|
42
|
+
export declare function collectModuleFunctions(program: Program): ReadonlyMap<string, FunctionDeclarationStatement | null>;
|
|
43
|
+
/**
|
|
44
|
+
* D89 A4, the wider proven shape: whether a `def` answers a list it filled with
|
|
45
|
+
* freshly constructed records — the `for`/`append` builder that spells the same
|
|
46
|
+
* churn `list = list.map(item => {…})` spells with `map`, and the spelling the
|
|
47
|
+
* P2b consumer actually wrote.
|
|
48
|
+
*
|
|
49
|
+
* Four things are proven, and any one of them missing leaves the advisory
|
|
50
|
+
* silent, because the whole product is naming a rebuild that really happens:
|
|
51
|
+
*
|
|
52
|
+
* 1. the body's last statement returns a name it declared here, initialized to
|
|
53
|
+
* an empty list literal — so the list is the `def`'s own, not one handed in;
|
|
54
|
+
* 2. every value appended to that list is a record literal, so every element is
|
|
55
|
+
* a new value on every call. One `append(row)` of a source record is the
|
|
56
|
+
* identity-preserving spelling this advisory teaches, and one member call
|
|
57
|
+
* the proof cannot read leaves the whole answer unproven;
|
|
58
|
+
* 3. at least one such record reads a parameter of the `def` or the binding of
|
|
59
|
+
* the `for` that appends it. A builder whose records are constant answers
|
|
60
|
+
* the same content every call, so nothing it is derived from can move and
|
|
61
|
+
* the `computed` over it never recomputes;
|
|
62
|
+
* 4. nothing else touches the list — it is built and answered, nothing more.
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildsFreshRecords(declaration: FunctionDeclarationStatement): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* D89 A4: one rebuild of a list's rows, held until the module's JSX is analyzed
|
|
67
|
+
* so the advisory is raised only where that same list is what a keyed list
|
|
68
|
+
* renders.
|
|
69
|
+
*
|
|
70
|
+
* `kind` names which spelling wrote it, and the two differ only in the remedy
|
|
71
|
+
* the message ends with. An `assignment` — `list = list.map(item => {…})` — owns
|
|
72
|
+
* the list it rewrote, so the preserving alternative is the field write next to
|
|
73
|
+
* it. A `derived` rebuild is a `computed` that builds its rows, and a derived
|
|
74
|
+
* value owns nothing it could write, so the alternative names the source rows
|
|
75
|
+
* instead.
|
|
76
|
+
*/
|
|
77
|
+
export interface KeyedListRebuild {
|
|
78
|
+
readonly kind: "assignment" | "derived";
|
|
79
|
+
readonly source: string;
|
|
80
|
+
readonly name: string;
|
|
81
|
+
/** The rewritten field, or null when the rebuild names none. */
|
|
82
|
+
readonly field: string | null;
|
|
83
|
+
readonly span: Span;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* What the rebuild rules ask of the analyzer that hosts them: the two module
|
|
87
|
+
* tables the walk fills, the module's `def` bodies, and the two analyzer
|
|
88
|
+
* operations a rebuild is recorded and advised through.
|
|
89
|
+
*
|
|
90
|
+
* D115 P4 R3c. `moduleFunctions` is replaced once per program, so it arrives
|
|
91
|
+
* through a getter and a collaborator reading it mid-walk reads the live one.
|
|
92
|
+
*/
|
|
93
|
+
export interface KeyedRebuildHost {
|
|
94
|
+
/** D89 A4: every row rebuild of this module — assigned or derived — in source order. */
|
|
95
|
+
readonly keyedListRebuilds: KeyedListRebuild[];
|
|
96
|
+
/** D89 A4: the binding identity of every list a keyed `.map(...)` interpolation renders. */
|
|
97
|
+
readonly keyedListSources: ReadonlySet<string>;
|
|
98
|
+
/** D89 A4: this module's `def` bodies by name, so a `computed` that calls one can be read through. Replaced per program. */
|
|
99
|
+
readonly moduleFunctions: ReadonlyMap<string, FunctionDeclarationStatement | null>;
|
|
100
|
+
advise(code: string, message: string, adviceSpan: Span, fix?: DiagnosticFix): void;
|
|
101
|
+
lookup(name: string): {
|
|
102
|
+
readonly span: Span;
|
|
103
|
+
readonly type: ValueType;
|
|
104
|
+
} | null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* D89 A4: records `list = list.map(item => {…})`, React's immutable update,
|
|
108
|
+
* where the callback builds a new record rather than changing a field.
|
|
109
|
+
*
|
|
110
|
+
* D90 R2 stands — `__velarKeyed` compares identity and that does not move,
|
|
111
|
+
* and the framework does not accommodate the idiom. This channel is not the
|
|
112
|
+
* framework taking responsibility; it is the compiler telling the author that
|
|
113
|
+
* the row he is typing into is about to be destroyed. Nothing is reported
|
|
114
|
+
* yet: the advisory is owed only if the rewritten list is what a keyed list
|
|
115
|
+
* renders, and the render usually sits below the update.
|
|
116
|
+
*/
|
|
117
|
+
export declare function recordKeyedListRebuild(host: KeyedRebuildHost, statement: Statement): void;
|
|
118
|
+
/**
|
|
119
|
+
* D89 A4, the wider proven shape: the same churn written as a derived value.
|
|
120
|
+
* `computed rows = source.map(item => {…})` and `computed rows = build(...)`
|
|
121
|
+
* over a `for`/`append` builder both hand a keyed position a fresh record for
|
|
122
|
+
* every row on every recompute, which is exactly what the assignment shape
|
|
123
|
+
* does — the reconciliation wave compiled both and found only one of them
|
|
124
|
+
* named. It is one advisory with a wider proof, not a second code: the defect,
|
|
125
|
+
* the consequence, and the suppression are the same.
|
|
126
|
+
*
|
|
127
|
+
* A `const` in a component body is deliberately not here. It is constructed
|
|
128
|
+
* once, so its records never move, and advising it would be a guess rather
|
|
129
|
+
* than a proof.
|
|
130
|
+
*/
|
|
131
|
+
export declare function recordDerivedKeyedListRebuild(host: KeyedRebuildHost, statement: ComputedDeclaration): void;
|
|
132
|
+
/**
|
|
133
|
+
* Whether a derived initializer constructs one fresh record per source
|
|
134
|
+
* element. Two spellings are proven and everything else is silent: a `map`
|
|
135
|
+
* whose callback answers a record literal — the same recognizer the
|
|
136
|
+
* assignment shape uses — and a call to a `def` this module declares whose
|
|
137
|
+
* whole answer is a list it filled with record literals.
|
|
138
|
+
*/
|
|
139
|
+
export declare function rebuildsRecordsPerElement(host: KeyedRebuildHost, value: Expression): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* D89 A4: raises the advisory for the rebuilds whose list a keyed position
|
|
142
|
+
* really renders. The advisory channel cannot reach `this.diagnostics`, so
|
|
143
|
+
* nothing here fails a build, changes an emitted byte, or moves a semantic
|
|
144
|
+
* rule; `// velar-allow A4: <reason>` suppresses it where building the rows is
|
|
145
|
+
* the only spelling, which a `readonly` list or one API response makes it.
|
|
146
|
+
*/
|
|
147
|
+
export declare function adviseKeyedListRebuilds(host: KeyedRebuildHost): void;
|
|
148
|
+
//# sourceMappingURL=keyed-rebuild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyed-rebuild.d.ts","sourceRoot":"","sources":["../../src/analysis/keyed-rebuild.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC9H,OAAO,EAAkB,KAAK,sBAAsB,IAAI,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAG/F;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAuB1G;AAED,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,SAAS,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAA;CAAE,CAAC,CAAC;AAExG;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAAC,MAAM,EAAE,4BAA4B,GAAG,IAAI,CAAC,CAgBjH;AA2BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,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