@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,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D103 — the design-token reference: what `token()` has to be at the site that
|
|
3
|
+
* writes it, and the migration off the `color("var(--x)")` passthrough that
|
|
4
|
+
* used to be the only spelling a Look value let through unchecked.
|
|
5
|
+
*
|
|
6
|
+
* D115 P4 R3b. The compiler cannot see a design system's values, so the
|
|
7
|
+
* reference itself is the whole of what there is to check; every rule here is
|
|
8
|
+
* about the written name.
|
|
9
|
+
*/
|
|
10
|
+
import { type DiagnosticEdit } from "@velarscript/compiler";
|
|
11
|
+
import { type Expression } from "@velarscript/compiler/extension";
|
|
12
|
+
import { type LookValueSite } from "../look-sites.ts";
|
|
13
|
+
import { type LookAnalysisHost } from "./host.ts";
|
|
14
|
+
/**
|
|
15
|
+
* D103 rules 1 and 5 — what a checked token reference has to be at the site
|
|
16
|
+
* that writes it.
|
|
17
|
+
*
|
|
18
|
+
* The compiler cannot see a design system's values: no token stylesheet is an
|
|
19
|
+
* input to this compile, and the whole point of the contract is that the
|
|
20
|
+
* theme swaps values under the same names. So the reference itself is the
|
|
21
|
+
* only thing there is to check, and it is checked completely — a literal
|
|
22
|
+
* name, spelled as a CSS custom property identifier, and nothing else in the
|
|
23
|
+
* call. A computed name would leave a Look value with no checked part at all,
|
|
24
|
+
* which is the surface D50 rule 92 says is worse than none.
|
|
25
|
+
*/
|
|
26
|
+
export declare function checkLookTokenCall(host: LookAnalysisHost, expression: Extract<Expression, {
|
|
27
|
+
kind: "CallExpression";
|
|
28
|
+
}>): void;
|
|
29
|
+
/**
|
|
30
|
+
* D103 rule 4 — the migration off the one passthrough that used to work.
|
|
31
|
+
*
|
|
32
|
+
* The rewrite carries the `token` import when the module does not already
|
|
33
|
+
* have one, because a fix that leaves a module naming an unimported builder
|
|
34
|
+
* is not mechanical. A `var(--x, fallback)` reference has no rewrite: rule 5
|
|
35
|
+
* closed the contract against per-site fallbacks, so the message says that
|
|
36
|
+
* rather than offering a migration that would silently drop the fallback.
|
|
37
|
+
*/
|
|
38
|
+
export declare function reportLookColorVarReference(host: LookAnalysisHost, expression: Extract<Expression, {
|
|
39
|
+
kind: "CallExpression";
|
|
40
|
+
}>, argument: Expression): void;
|
|
41
|
+
/** The import edit that gives this module a `token` import and takes back what the rewrite retired. */
|
|
42
|
+
export declare function lookTokenImportEdit(host: LookAnalysisHost, retiring?: readonly string[]): readonly DiagnosticEdit[];
|
|
43
|
+
/** Whether this value is written as a call to the module's `token` builder, alias included. */
|
|
44
|
+
export declare function isLookTokenCall(host: LookAnalysisHost, value: Expression): boolean;
|
|
45
|
+
/** How this module spells a call to the token builder, honouring an aliased import. */
|
|
46
|
+
export declare function lookTokenCallText(host: LookAnalysisHost, referenced: string): {
|
|
47
|
+
readonly call: string;
|
|
48
|
+
readonly imported: boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The edits that replace one written Look value with the checked token call,
|
|
52
|
+
* in the spelling of the site that wrote it.
|
|
53
|
+
*
|
|
54
|
+
* A `look:property="text"` directive is analyzed through a synthetic literal
|
|
55
|
+
* standing for the whole attribute, so the rewrite replaces the attribute:
|
|
56
|
+
* splicing a call between an attribute's quotes is not JSX, and a fix that
|
|
57
|
+
* produces a parse error is not a mechanical fix. The `look:property={...}`
|
|
58
|
+
* spelling carries a real expression whose span is the value alone, and is
|
|
59
|
+
* rewritten in place like a block entry.
|
|
60
|
+
*/
|
|
61
|
+
export declare function lookTokenRewrite(host: LookAnalysisHost, value: Expression, referenced: string, site: LookValueSite): readonly DiagnosticEdit[];
|
|
62
|
+
/**
|
|
63
|
+
* D103 rule 4, free-text half — an advisory rather than a refusal.
|
|
64
|
+
*
|
|
65
|
+
* `fontFamily`, `backdropFilter` and the other free-text kinds accept
|
|
66
|
+
* arbitrary CSS text by construction, and a `var()` inside a larger value is
|
|
67
|
+
* a legitimate spelling with no single token to rewrite it to: the tail of a
|
|
68
|
+
* font stack, one layer of a filter list. Refusing there would refuse real
|
|
69
|
+
* CSS. What is advised is the narrow case where the *whole* value is one
|
|
70
|
+
* reference, because there `token("--name")` is the checked spelling of the
|
|
71
|
+
* same thing and the rewrite is unambiguous — which is the bar the `A`
|
|
72
|
+
* roster is written to.
|
|
73
|
+
*/
|
|
74
|
+
export declare function adviseLookTokenSpelling(host: LookAnalysisHost, name: string, value: Expression, site: LookValueSite): void;
|
|
75
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/analysis/look/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,KAAK,cAAc,EAAkC,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GAAG,IAAI,CA8C5H;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,EAC3D,QAAQ,EAAE,UAAU,GACnB,IAAI,CAyBN;AAED,uGAAuG;AACvG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,GAAE,SAAS,MAAM,EAAO,GAAG,SAAS,cAAc,EAAE,CAEvH;AAED,+FAA+F;AAC/F,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAGlF;AAED,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAGnI;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,SAAS,cAAc,EAAE,CAS9I;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAa1H"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D103 — the design-token reference: what `token()` has to be at the site that
|
|
3
|
+
* writes it, and the migration off the `color("var(--x)")` passthrough that
|
|
4
|
+
* used to be the only spelling a Look value let through unchecked.
|
|
5
|
+
*
|
|
6
|
+
* D115 P4 R3b. The compiler cannot see a design system's values, so the
|
|
7
|
+
* reference itself is the whole of what there is to check; every rule here is
|
|
8
|
+
* about the written name.
|
|
9
|
+
*/
|
|
10
|
+
import { mechanicalEdits, mechanicalFix } from "@velarscript/compiler";
|
|
11
|
+
import { spanIdentity } from "@velarscript/compiler/extension";
|
|
12
|
+
import { isLookTokenName, isLookVarReference, LOOK_PROPERTY_VALUE_KINDS, LOOK_TOKEN_NAME_RULE, LOOK_TOKEN_NO_FALLBACK_GUIDANCE, lookTokenReference, lookVarReferenceName } from "../../look.js";
|
|
13
|
+
import {} from "../look-sites.js";
|
|
14
|
+
import { diagnostic } from "../web-types.js";
|
|
15
|
+
import { lookImportEdits } from "./edits.js";
|
|
16
|
+
import {} from "./host.js";
|
|
17
|
+
/**
|
|
18
|
+
* D103 rules 1 and 5 — what a checked token reference has to be at the site
|
|
19
|
+
* that writes it.
|
|
20
|
+
*
|
|
21
|
+
* The compiler cannot see a design system's values: no token stylesheet is an
|
|
22
|
+
* input to this compile, and the whole point of the contract is that the
|
|
23
|
+
* theme swaps values under the same names. So the reference itself is the
|
|
24
|
+
* only thing there is to check, and it is checked completely — a literal
|
|
25
|
+
* name, spelled as a CSS custom property identifier, and nothing else in the
|
|
26
|
+
* call. A computed name would leave a Look value with no checked part at all,
|
|
27
|
+
* which is the surface D50 rule 92 says is worse than none.
|
|
28
|
+
*/
|
|
29
|
+
export function checkLookTokenCall(host, expression) {
|
|
30
|
+
const names = expression.argumentNames;
|
|
31
|
+
// `token(name="--x")` writes the same one argument the positional spelling
|
|
32
|
+
// does, so the name position is read from the signature the way every other
|
|
33
|
+
// builder's is rather than assumed to be index 0.
|
|
34
|
+
const position = names?.findIndex((entry) => entry === "name") ?? -1;
|
|
35
|
+
const nameIndex = position >= 0 ? position : names?.[0] === undefined || names[0] === null ? 0 : -1;
|
|
36
|
+
for (const [index, argument] of expression.arguments.entries()) {
|
|
37
|
+
if (index === nameIndex)
|
|
38
|
+
continue;
|
|
39
|
+
host.diagnostics.push(diagnostic("VEL5042", LOOK_TOKEN_NO_FALLBACK_GUIDANCE, argument.span));
|
|
40
|
+
}
|
|
41
|
+
const written = nameIndex >= 0 ? expression.arguments[nameIndex] : undefined;
|
|
42
|
+
if (!written)
|
|
43
|
+
return;
|
|
44
|
+
if (written.kind !== "LiteralExpression" || typeof written.value !== "string") {
|
|
45
|
+
host.diagnostics.push(diagnostic("VEL5042", `A design token reference names its custom property in the call: ${LOOK_TOKEN_NAME_RULE}. The compiler cannot see a design system's values, so the name is the whole of what it can check — a computed name, an interpolation, or a binding would leave the reference unchecked`, written.span));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (isLookTokenName(written.value)) {
|
|
49
|
+
// D103 rule 2: the reference is compile-time text, so it is folded here
|
|
50
|
+
// rather than left as a call the browser makes on every module load. The
|
|
51
|
+
// fold is stamped only on a call this check has just proved, which is
|
|
52
|
+
// what keeps the emitter structurally unable to write a name nothing
|
|
53
|
+
// validated. An aliased builder (`const t = token`) is not resolved here
|
|
54
|
+
// and keeps the runtime implementation, exactly as every other builder
|
|
55
|
+
// passed around as a value does.
|
|
56
|
+
if (expression.arguments.length === 1) {
|
|
57
|
+
host.extensionLiterals.set(spanIdentity(expression.span), lookTokenReference(written.value));
|
|
58
|
+
}
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// A name written without the `--` that makes it a custom property is the
|
|
62
|
+
// one near miss with a single spelling behind it, so it is migrated rather
|
|
63
|
+
// than only refused.
|
|
64
|
+
const prefixed = `--${written.value}`;
|
|
65
|
+
host.diagnostics.push(diagnostic("VEL5042", `Design token name '${written.value}' is not a CSS custom property identifier; ${LOOK_TOKEN_NAME_RULE}`, written.span, isLookTokenName(prefixed)
|
|
66
|
+
? mechanicalFix(written.span, JSON.stringify(prefixed), `Use "${prefixed}"`)
|
|
67
|
+
: undefined));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* D103 rule 4 — the migration off the one passthrough that used to work.
|
|
71
|
+
*
|
|
72
|
+
* The rewrite carries the `token` import when the module does not already
|
|
73
|
+
* have one, because a fix that leaves a module naming an unimported builder
|
|
74
|
+
* is not mechanical. A `var(--x, fallback)` reference has no rewrite: rule 5
|
|
75
|
+
* closed the contract against per-site fallbacks, so the message says that
|
|
76
|
+
* rather than offering a migration that would silently drop the fallback.
|
|
77
|
+
*/
|
|
78
|
+
export function reportLookColorVarReference(host, expression, argument) {
|
|
79
|
+
if (argument.kind !== "LiteralExpression" || typeof argument.value !== "string")
|
|
80
|
+
return;
|
|
81
|
+
if (!isLookVarReference(argument.value))
|
|
82
|
+
return;
|
|
83
|
+
const referenced = lookVarReferenceName(argument.value);
|
|
84
|
+
if (referenced === null) {
|
|
85
|
+
host.diagnostics.push(diagnostic("VEL5042", `A design token reference is written token("--name"), and it carries no fallback: ${LOOK_TOKEN_NO_FALLBACK_GUIDANCE}`, argument.span));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const { call } = lookTokenCallText(host, referenced);
|
|
89
|
+
const rewrite = { span: expression.span, text: call };
|
|
90
|
+
// WB-I2: the rewrite replaces this whole call, so the builder it was written
|
|
91
|
+
// through loses a read. When it was the last one, the specifier goes with it
|
|
92
|
+
// in the same edit — `velar fix` used to leave the module importing a `color`
|
|
93
|
+
// it no longer calls.
|
|
94
|
+
const retiring = expression.callee.kind === "IdentifierExpression" ? [expression.callee.name] : [];
|
|
95
|
+
host.diagnostics.push(diagnostic("VEL5042", `Write a design token reference as ${call}; color("var(...)") passed the reference through as text nothing checked, and token() is the one checked spelling — legal in every Look property, not only the colour ones`, expression.span, mechanicalEdits([...lookTokenImportEdit(host, retiring), rewrite], `Use ${call}`)));
|
|
96
|
+
}
|
|
97
|
+
/** The import edit that gives this module a `token` import and takes back what the rewrite retired. */
|
|
98
|
+
export function lookTokenImportEdit(host, retiring = []) {
|
|
99
|
+
return lookImportEdits(host, ["token"], retiring);
|
|
100
|
+
}
|
|
101
|
+
/** Whether this value is written as a call to the module's `token` builder, alias included. */
|
|
102
|
+
export function isLookTokenCall(host, value) {
|
|
103
|
+
return value.kind === "CallExpression" && value.callee.kind === "IdentifierExpression"
|
|
104
|
+
&& host.lookBuilderNames.get(value.callee.name) === "token";
|
|
105
|
+
}
|
|
106
|
+
/** How this module spells a call to the token builder, honouring an aliased import. */
|
|
107
|
+
export function lookTokenCallText(host, referenced) {
|
|
108
|
+
const local = [...host.lookBuilderNames].find(([, builder]) => builder === "token")?.[0] ?? null;
|
|
109
|
+
return { call: `${local ?? "token"}(${JSON.stringify(referenced)})`, imported: local !== null };
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The edits that replace one written Look value with the checked token call,
|
|
113
|
+
* in the spelling of the site that wrote it.
|
|
114
|
+
*
|
|
115
|
+
* A `look:property="text"` directive is analyzed through a synthetic literal
|
|
116
|
+
* standing for the whole attribute, so the rewrite replaces the attribute:
|
|
117
|
+
* splicing a call between an attribute's quotes is not JSX, and a fix that
|
|
118
|
+
* produces a parse error is not a mechanical fix. The `look:property={...}`
|
|
119
|
+
* spelling carries a real expression whose span is the value alone, and is
|
|
120
|
+
* rewritten in place like a block entry.
|
|
121
|
+
*/
|
|
122
|
+
export function lookTokenRewrite(host, value, referenced, site) {
|
|
123
|
+
const { call } = lookTokenCallText(host, referenced);
|
|
124
|
+
const wholeAttribute = site.directive !== null
|
|
125
|
+
&& value.span.start === site.entrySpan.start && value.span.end === site.entrySpan.end;
|
|
126
|
+
const edit = {
|
|
127
|
+
span: value.span,
|
|
128
|
+
text: wholeAttribute ? `${site.directive}:${site.property}={${call}}` : call,
|
|
129
|
+
};
|
|
130
|
+
return [...lookTokenImportEdit(host), edit];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* D103 rule 4, free-text half — an advisory rather than a refusal.
|
|
134
|
+
*
|
|
135
|
+
* `fontFamily`, `backdropFilter` and the other free-text kinds accept
|
|
136
|
+
* arbitrary CSS text by construction, and a `var()` inside a larger value is
|
|
137
|
+
* a legitimate spelling with no single token to rewrite it to: the tail of a
|
|
138
|
+
* font stack, one layer of a filter list. Refusing there would refuse real
|
|
139
|
+
* CSS. What is advised is the narrow case where the *whole* value is one
|
|
140
|
+
* reference, because there `token("--name")` is the checked spelling of the
|
|
141
|
+
* same thing and the rewrite is unambiguous — which is the bar the `A`
|
|
142
|
+
* roster is written to.
|
|
143
|
+
*/
|
|
144
|
+
export function adviseLookTokenSpelling(host, name, value, site) {
|
|
145
|
+
const kind = LOOK_PROPERTY_VALUE_KINDS.get(name);
|
|
146
|
+
if (kind !== "text" && kind !== "filter" && kind !== "transform")
|
|
147
|
+
return;
|
|
148
|
+
if (value.kind !== "LiteralExpression" || typeof value.value !== "string")
|
|
149
|
+
return;
|
|
150
|
+
const referenced = lookVarReferenceName(value.value);
|
|
151
|
+
if (referenced === null)
|
|
152
|
+
return;
|
|
153
|
+
const { call } = lookTokenCallText(host, referenced);
|
|
154
|
+
host.advise("A12", `Look property '${name}' accepts free text, so this design token reference compiles — as text nothing checks. ${call} is the checked spelling of the same reference, and it is legal in every Look property. A var() inside a larger value, such as a font stack's fallback, has no single token to stand for it and is not advised`, value.span, mechanicalEdits(lookTokenRewrite(host, value, referenced, site), `Use ${call}`));
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/analysis/look/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAuB,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EAAmB,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAChM,OAAO,EAAsB,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OA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AmB;IAClH,MAAM,IAAI,GAAG,yBAAyB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,WAAW;QAAE,OAAO;IACzE,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO;IAClF,MAAM,UAAU,GAAG,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrD,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO;IAChC,MAAM,EAAE,IAAI,EAAE,GAAG,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM,CACT,KAAK,EACL,kBAAkB,IAAI,0FAA0F,IAAI,gNAAgN,EACpU,KAAK,CAAC,IAAI,EACV,eAAe,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,OAAO,IAAI,EAAE,CAAC,CAChF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a Look property's value is allowed to be: the string vocabulary each
|
|
3
|
+
* property publishes, the compile-time fold that answers for a `const`
|
|
4
|
+
* keyword, the unit a bare number is missing, and the filter spelling that has
|
|
5
|
+
* a builder behind it.
|
|
6
|
+
*
|
|
7
|
+
* D115 P4 R3b. `entries.ts` asks these questions of every entry it walks and
|
|
8
|
+
* `builders.ts` routes the transition builder's property argument through the
|
|
9
|
+
* same vocabulary, so one property has one answer wherever it is written.
|
|
10
|
+
*/
|
|
11
|
+
import { type Span } from "@velarscript/compiler";
|
|
12
|
+
import { type Expression, type ValueType } from "@velarscript/compiler/extension";
|
|
13
|
+
import { type LookValueSite } from "../look-sites.ts";
|
|
14
|
+
import { type LookAnalysisHost } from "./host.ts";
|
|
15
|
+
/**
|
|
16
|
+
* `subject` names the position in the message. It is the property itself
|
|
17
|
+
* everywhere except the `transition(...)` builder, whose first argument takes
|
|
18
|
+
* `transitionProperty`'s vocabulary but is not written as that property — a
|
|
19
|
+
* refusal that named the longhand there would name a spelling the author
|
|
20
|
+
* never wrote.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateLookStringVocabulary(host: LookAnalysisHost, name: string, value: Expression, subject?: string, site?: LookValueSite): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* D65 rule 168 closed the closed sets against misspelled literals, and D65
|
|
25
|
+
* item 3 makes a `const` string a first-class design token — so the two have
|
|
26
|
+
* to agree. A name or a record field that folds to a bare CSS keyword is
|
|
27
|
+
* checked exactly as the literal spelling of it is; anything that folds to
|
|
28
|
+
* composed CSS text (a builder result, a unit, a gradient) is not a keyword
|
|
29
|
+
* and is left to the type and to the builder's own checks.
|
|
30
|
+
*/
|
|
31
|
+
export declare function foldedLookKeyword(host: LookAnalysisHost, value: Expression): readonly string[] | null;
|
|
32
|
+
/**
|
|
33
|
+
* LOK-D3: a bare number on a length property reaches CSS as a declaration the
|
|
34
|
+
* browser discards. The union already rejects it; this diagnostic replaces the
|
|
35
|
+
* union dump with the unit the author meant to write.
|
|
36
|
+
*/
|
|
37
|
+
export declare function reportLookNumberWithoutUnit(host: LookAnalysisHost, name: string, actual: ValueType, expected: ValueType, valueSpan: Span): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* A complete CSS filter function whose arguments fit the checked Look
|
|
40
|
+
* builders has one equivalent source spelling. The parser deliberately
|
|
41
|
+
* stops at the first function or argument grammar it cannot prove, leaving
|
|
42
|
+
* arbitrary CSS and externally defined filter functions as ordinary text.
|
|
43
|
+
*/
|
|
44
|
+
export declare function adviseLookFilterSpelling(host: LookAnalysisHost, name: string, value: Expression, site: LookValueSite): void;
|
|
45
|
+
//# sourceMappingURL=values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../../src/analysis/look/values.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAmB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGlF,OAAO,EAAE,KAAK,aAAa,EAAwB,MAAM,kBAAkB,CAAC;AAI5E,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGlD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,SAA4B,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CA8ExK;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAKrG;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,GAAG,OAAO,CASlJ;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAe3H"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a Look property's value is allowed to be: the string vocabulary each
|
|
3
|
+
* property publishes, the compile-time fold that answers for a `const`
|
|
4
|
+
* keyword, the unit a bare number is missing, and the filter spelling that has
|
|
5
|
+
* a builder behind it.
|
|
6
|
+
*
|
|
7
|
+
* D115 P4 R3b. `entries.ts` asks these questions of every entry it walks and
|
|
8
|
+
* `builders.ts` routes the transition builder's property argument through the
|
|
9
|
+
* same vocabulary, so one property has one answer wherever it is written.
|
|
10
|
+
*/
|
|
11
|
+
import { mechanicalEdits } from "@velarscript/compiler";
|
|
12
|
+
import {} from "@velarscript/compiler/extension";
|
|
13
|
+
import { evaluateLookStaticExpression } from "../../look-static.js";
|
|
14
|
+
import { LOOK_PARTIAL_KEYWORD_PROPERTIES, LOOK_PROPERTY_KEYWORDS, LOOK_PROPERTY_VALUE_KINDS, LOOK_SHARED_METRIC_KEYWORDS, LOOK_UNITLESS_PROPERTIES, lookOwnKeywords, lookVarReferenceName } from "../../look.js";
|
|
15
|
+
import { mentionsLookUnitType } from "../look-sites.js";
|
|
16
|
+
import { literalStringValues, lookColorKeywords, lookCssWideKeywords, lookFilterRewrite, lookMetricKeywords, lookVocabularyGuidance, lookVocabularyLead } from "../look-vocabulary-guidance.js";
|
|
17
|
+
import { diagnostic } from "../web-types.js";
|
|
18
|
+
import { localizeLookBuilderCall, lookBuilderRewrite } from "./edits.js";
|
|
19
|
+
import {} from "./host.js";
|
|
20
|
+
import { lookTokenCallText, lookTokenRewrite } from "./tokens.js";
|
|
21
|
+
/**
|
|
22
|
+
* `subject` names the position in the message. It is the property itself
|
|
23
|
+
* everywhere except the `transition(...)` builder, whose first argument takes
|
|
24
|
+
* `transitionProperty`'s vocabulary but is not written as that property — a
|
|
25
|
+
* refusal that named the longhand there would name a spelling the author
|
|
26
|
+
* never wrote.
|
|
27
|
+
*/
|
|
28
|
+
export function validateLookStringVocabulary(host, name, value, subject = `Look property '${name}'`, site) {
|
|
29
|
+
const kind = LOOK_PROPERTY_VALUE_KINDS.get(name);
|
|
30
|
+
if (!kind || kind === "text" || kind === "filter" || kind === "transform" || kind === "animation")
|
|
31
|
+
return true;
|
|
32
|
+
const values = literalStringValues(value) ?? foldedLookKeyword(host, value);
|
|
33
|
+
if (values === null)
|
|
34
|
+
return true;
|
|
35
|
+
for (const text of values) {
|
|
36
|
+
const normalized = text.trim();
|
|
37
|
+
// D103 rule 4: this is the refusal the shell wave met — every metric,
|
|
38
|
+
// shadow and transition property turned a design token reference away and
|
|
39
|
+
// named `import css unsafe` as the only way out, which is how a product's
|
|
40
|
+
// whole visual layer ended up outside Look. The reference is still
|
|
41
|
+
// refused as free text, because free text is what it was; what changed is
|
|
42
|
+
// that the refusal now names the checked spelling of the same reference
|
|
43
|
+
// and rewrites to it.
|
|
44
|
+
const referenced = site && lookVarReferenceName(normalized);
|
|
45
|
+
if (referenced) {
|
|
46
|
+
const { call } = lookTokenCallText(host, referenced);
|
|
47
|
+
host.diagnostics.push(diagnostic("VEL5038", `${subject} does not accept the text '${normalized}'; write the design token reference as ${call}, which is checked and legal in every Look property`, value.span, mechanicalEdits(lookTokenRewrite(host, value, referenced, site), `Use ${call}`)));
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (kind === "metric" && /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem|em|vw|vh|vmin|vmax|%|fr|ms|s|deg|turn)$/u.test(normalized)) {
|
|
51
|
+
host.diagnostics.push(diagnostic("VEL5038", `Use the unit literal ${normalized}; quoted unit values are not part of Look`, value.span));
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
let accepted;
|
|
55
|
+
// A metric property is a unit value plus a keyword half: its own CSS
|
|
56
|
+
// keywords when it has a table -- `backgroundSize` takes lengths *and*
|
|
57
|
+
// cover and contain, the `<position>` properties take the placement words
|
|
58
|
+
// (D60 rule 150, D67 rule 172) -- and the shared sizing words when it has
|
|
59
|
+
// none. The two are alternatives rather than a union, for the reason D65
|
|
60
|
+
// rule 168 gave for the keyword kind: a shared list added on top of a
|
|
61
|
+
// real table decides values for a property it has never heard of, so
|
|
62
|
+
// `objectPosition = "min-content"` would compile and reach the browser as
|
|
63
|
+
// a declaration it discards.
|
|
64
|
+
const metricKeywords = LOOK_PROPERTY_KEYWORDS.get(name);
|
|
65
|
+
if (kind === "metric")
|
|
66
|
+
accepted = metricKeywords === undefined ? lookMetricKeywords.has(normalized) : metricKeywords.has(normalized);
|
|
67
|
+
else if (kind === "color" || kind === "background")
|
|
68
|
+
accepted = lookColorKeywords.has(normalized) || /^#[0-9a-f]{3,8}$/iu.test(normalized);
|
|
69
|
+
else if (kind === "image")
|
|
70
|
+
accepted = lookCssWideKeywords.has(normalized) || normalized === "none";
|
|
71
|
+
// D73 rule 187: every kind that decides a string keyword reads the
|
|
72
|
+
// property's own closed set, and look.ts refuses to load if one is
|
|
73
|
+
// missing. The 46-word shared list this replaces both admitted values the
|
|
74
|
+
// property never had and made the refusal describe a table that did not
|
|
75
|
+
// exist.
|
|
76
|
+
else
|
|
77
|
+
accepted = LOOK_PROPERTY_KEYWORDS.get(name)?.has(normalized) === true;
|
|
78
|
+
if (!accepted) {
|
|
79
|
+
// D67 rule 174, widened by D73 rule 187: every refusal now names the
|
|
80
|
+
// property's own values, because every one of these kinds has them. The
|
|
81
|
+
// lead says what the non-keyword half of the property is, so a reader
|
|
82
|
+
// who wanted a length, an angle or a builder is not sent looking through
|
|
83
|
+
// a keyword list for it.
|
|
84
|
+
const expected = kind === "metric"
|
|
85
|
+
? lookVocabularyGuidance(name, normalized, metricKeywords === undefined ? LOOK_SHARED_METRIC_KEYWORDS : lookOwnKeywords(name), "write a unit value such as 16px, 1rem or 50%, or one of")
|
|
86
|
+
: kind === "color" || kind === "background"
|
|
87
|
+
? { text: "use a checked color() or color keyword", named: false }
|
|
88
|
+
: kind === "image"
|
|
89
|
+
? { text: "use a checked image builder such as linearGradient() or asset()", named: false }
|
|
90
|
+
: lookVocabularyGuidance(name, normalized, lookOwnKeywords(name), lookVocabularyLead(kind));
|
|
91
|
+
// D65 rule 169: a property whose CSS value space no set can hold says
|
|
92
|
+
// what it left out, so the boundary is legible where it is met.
|
|
93
|
+
const partial = expected.named ? undefined : LOOK_PARTIAL_KEYWORD_PROPERTIES.get(name);
|
|
94
|
+
host.diagnostics.push(diagnostic("VEL5038", `${subject} does not accept '${normalized}'; ${expected.text}${partial
|
|
95
|
+
? `. ${partial}; use a module-level 'import css unsafe "./styles.css" before look' when that boundary is intentional`
|
|
96
|
+
: ""}`, value.span));
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* D65 rule 168 closed the closed sets against misspelled literals, and D65
|
|
104
|
+
* item 3 makes a `const` string a first-class design token — so the two have
|
|
105
|
+
* to agree. A name or a record field that folds to a bare CSS keyword is
|
|
106
|
+
* checked exactly as the literal spelling of it is; anything that folds to
|
|
107
|
+
* composed CSS text (a builder result, a unit, a gradient) is not a keyword
|
|
108
|
+
* and is left to the type and to the builder's own checks.
|
|
109
|
+
*/
|
|
110
|
+
export function foldedLookKeyword(host, value) {
|
|
111
|
+
if (value.kind !== "IdentifierExpression" && value.kind !== "MemberExpression")
|
|
112
|
+
return null;
|
|
113
|
+
const folded = evaluateLookStaticExpression(value, host.lookStatic.values);
|
|
114
|
+
if (folded?.kind !== "css" || !/^[A-Za-z][A-Za-z0-9-]*$/u.test(folded.value))
|
|
115
|
+
return null;
|
|
116
|
+
return [folded.value];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* LOK-D3: a bare number on a length property reaches CSS as a declaration the
|
|
120
|
+
* browser discards. The union already rejects it; this diagnostic replaces the
|
|
121
|
+
* union dump with the unit the author meant to write.
|
|
122
|
+
*/
|
|
123
|
+
export function reportLookNumberWithoutUnit(host, name, actual, expected, valueSpan) {
|
|
124
|
+
if (host.expandAliases(actual).kind !== "number" || LOOK_UNITLESS_PROPERTIES.has(name))
|
|
125
|
+
return false;
|
|
126
|
+
if (!mentionsLookUnitType(expected))
|
|
127
|
+
return false;
|
|
128
|
+
host.diagnostics.push(diagnostic("VEL5038", `Look property '${name}' is a CSS length and requires a unit; write a unit value such as 16px, 1rem, or 50%`, valueSpan));
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A complete CSS filter function whose arguments fit the checked Look
|
|
133
|
+
* builders has one equivalent source spelling. The parser deliberately
|
|
134
|
+
* stops at the first function or argument grammar it cannot prove, leaving
|
|
135
|
+
* arbitrary CSS and externally defined filter functions as ordinary text.
|
|
136
|
+
*/
|
|
137
|
+
export function adviseLookFilterSpelling(host, name, value, site) {
|
|
138
|
+
if (LOOK_PROPERTY_VALUE_KINDS.get(name) !== "filter")
|
|
139
|
+
return;
|
|
140
|
+
if (value.kind !== "LiteralExpression" || typeof value.value !== "string")
|
|
141
|
+
return;
|
|
142
|
+
const rewrite = lookFilterRewrite(value.value);
|
|
143
|
+
if (!rewrite)
|
|
144
|
+
return;
|
|
145
|
+
const localized = localizeLookBuilderCall(host, rewrite);
|
|
146
|
+
host.advise("A16", `Look property '${name}' accepts CSS filter text, but this complete filter list has the checked equivalent ${localized.call}`, value.span, mechanicalEdits(lookBuilderRewrite(host, value, localized.call, site, localized.missingImports), `Use ${localized.call}`));
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../../src/analysis/look/values.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,eAAe,EAAa,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAmC,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACjN,OAAO,EAAsB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAA0B,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACxN,OAA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GAAG,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,MAAM,SAAS,GAAG,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM,CACT,KAAK,EACL,kBAAkB,IAAI,uFAAuF,SAAS,CAAC,IAAI,EAAE,EAC7H,KAAK,CAAC,IAAI,EACV,eAAe,CACb,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,cAAc,CAAC,EAC/E,OAAO,SAAS,CAAC,IAAI,EAAE,CACxB,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Look condition as the emitter will key it: the lowered atom each term
|
|
3
|
+
* becomes, the scope key a whole condition folds to, and what a module's Look
|
|
4
|
+
* declarations contribute to a property once every branch is read.
|
|
5
|
+
*
|
|
6
|
+
* D115 P4 R3a: the duplicate-property scope and the cascade both ask this, and
|
|
7
|
+
* neither asks it of the analyzer's state, so it is written once here.
|
|
8
|
+
*/
|
|
9
|
+
import { type Expression, type Program } from "@velarscript/compiler/extension";
|
|
10
|
+
import { type WebLookExpression } from "../ast.ts";
|
|
11
|
+
import { type LookStaticValue } from "../look-static.ts";
|
|
12
|
+
/**
|
|
13
|
+
* VEL5045: the selector/runtime terms one Look condition may expand to. A
|
|
14
|
+
* conjunction multiplies its two sides, so nesting is what the cap is against.
|
|
15
|
+
* Both readings of a condition stop there — the terms folded below, and the
|
|
16
|
+
* count `look-sites.ts` takes — so neither can run away on a written nesting.
|
|
17
|
+
*/
|
|
18
|
+
export declare const LOOK_CONDITION_TERM_LIMIT = 32;
|
|
19
|
+
/**
|
|
20
|
+
* One Look condition as the set of alternatives it lowers to, each alternative
|
|
21
|
+
* being the sorted atoms that must hold together. Two conditions share a
|
|
22
|
+
* duplicate-detection scope exactly when this rendering matches, so a condition
|
|
23
|
+
* written the other way round, negated into its complement, or spelled with its
|
|
24
|
+
* operands swapped lands in the scope its rule will actually occupy.
|
|
25
|
+
*/
|
|
26
|
+
export declare function lookConditionKey(expression: Expression, negated: boolean, staticValues: ReadonlyMap<string, LookStaticValue>): string;
|
|
27
|
+
/**
|
|
28
|
+
* Every `const name = look:` in the module, wherever it is written. A name
|
|
29
|
+
* declared twice maps to null: two different Look literals under one name make
|
|
30
|
+
* the composition question unanswerable, so the check that reads this map
|
|
31
|
+
* declines rather than guessing which one an element received.
|
|
32
|
+
*/
|
|
33
|
+
export declare function collectLookDeclarations(program: Program): ReadonlyMap<string, WebLookExpression | null>;
|
|
34
|
+
/**
|
|
35
|
+
* The properties one Look sets, each keyed by the target it sets them on so a
|
|
36
|
+
* `@before:` colour and an element colour stay two different decisions. The
|
|
37
|
+
* condition is deliberately not part of the key: two looks that set one
|
|
38
|
+
* property under conditions that can both hold are exactly the ambiguity this
|
|
39
|
+
* serves. A `...spread` of another look is followed, and the names followed are
|
|
40
|
+
* reported back, because composing is what makes two looks ordered rather than
|
|
41
|
+
* independent.
|
|
42
|
+
*/
|
|
43
|
+
export declare function lookContributions(look: WebLookExpression, looks: ReadonlyMap<string, WebLookExpression | null>, visited?: ReadonlySet<string>): {
|
|
44
|
+
readonly properties: ReadonlySet<string>;
|
|
45
|
+
readonly composed: ReadonlySet<string>;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=look-conditions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"look-conditions.d.ts","sourceRoot":"","sources":["../../src/analysis/look-conditions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO,EAAkB,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAA+C,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAItG;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAwC5C;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,GACjD,MAAM,CAGR;AA4BD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC,CAmBvG;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,iBAAiB,EACvB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC,EACpD,OAAO,GAAE,WAAW,CAAC,MAAM,CAAa,GACvC;IAAE,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,CAsBtF"}
|