@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,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `component Name(props) exposes Handle:` — its prop list, its lifecycle hook
|
|
3
|
+
* names, and the item loop that reads its body.
|
|
4
|
+
*
|
|
5
|
+
* The prop list is the only place `insideComponentProps` is read, and the body
|
|
6
|
+
* loop is the only writer of it, so the depth counter is the one piece of
|
|
7
|
+
* parser state this face declares.
|
|
8
|
+
*/
|
|
9
|
+
import { typeParameterDeclarationFormsPhrase } from "@velarscript/compiler";
|
|
10
|
+
import {} from "@velarscript/compiler/extension";
|
|
11
|
+
import {} from "../../ast.js";
|
|
12
|
+
import { diagnostic, recoveredDiagnostic, span } from "../spans.js";
|
|
13
|
+
import { actionHeaderShapes, blockHeaderAhead, exposeItemAhead, namedDeclarationAhead, reactiveBindingShapes, } from "./heads.js";
|
|
14
|
+
import { parseActionDeclaration, parseComputedDeclaration, parseResourceDeclaration, parseStateDeclaration, parseWatchDeclaration, } from "./reactive.js";
|
|
15
|
+
const renderBlockSpellings = new Set(["render", "show", "view"]);
|
|
16
|
+
const lifecycleHookSpellings = new Set(["mounted", "cleanup"]);
|
|
17
|
+
/**
|
|
18
|
+
* WEB-N4: a component prop list is where a Web author reaches for the HTML
|
|
19
|
+
* names, and `class`, `look`, and the Core keywords are all tokens rather than
|
|
20
|
+
* identifiers. Recovering the keyword as the prop name turns an eleven-message
|
|
21
|
+
* parser cascade into one directed message, and a declaration-position `?`
|
|
22
|
+
* teaches the default value that actually makes a prop omittable.
|
|
23
|
+
*/
|
|
24
|
+
export function parseComponentProps(host) {
|
|
25
|
+
host.expect("leftParen", "Expected '('");
|
|
26
|
+
const parameters = [];
|
|
27
|
+
if (!host.check("rightParen")) {
|
|
28
|
+
do {
|
|
29
|
+
if (host.match("ellipsis"))
|
|
30
|
+
host.diagnostics.push(diagnostic("VEL2016", "Components use named props and do not support rest parameters", host.previous().span));
|
|
31
|
+
// 'class' and 'look' are the props every component already carries, so
|
|
32
|
+
// the same message answers both the keyword token and the now-ordinary
|
|
33
|
+
// name.
|
|
34
|
+
const universalProp = host.checkWord("look") || host.check("class");
|
|
35
|
+
if (universalProp) {
|
|
36
|
+
const token = host.advance();
|
|
37
|
+
host.diagnostics.push(diagnostic("VEL2016", `Every component already accepts '${token.value}'; remove it from the prop list and pass it at the call site with ${token.value}={...}`, token.span));
|
|
38
|
+
}
|
|
39
|
+
const nameToken = universalProp ? host.previous() : host.check("identifier") ? host.advance() : componentPropKeyword(host);
|
|
40
|
+
if (!nameToken) {
|
|
41
|
+
host.diagnostics.push(diagnostic("VEL2016", "A component prop list holds 'name: Type' props separated by commas", host.current().span));
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
let optionalMarker = false;
|
|
45
|
+
if (host.check("question")) {
|
|
46
|
+
host.advance();
|
|
47
|
+
optionalMarker = true;
|
|
48
|
+
}
|
|
49
|
+
const type = host.match("colon") ? host.parseTypeReference() : null;
|
|
50
|
+
let defaultValue = host.match("assign") ? host.parseExpression() : null;
|
|
51
|
+
if (optionalMarker) {
|
|
52
|
+
host.diagnostics.push(diagnostic("VEL2016", `A component prop becomes omittable through its default value, not through '?': write '${nameToken.value}: Type = default' for a real default, or '${nameToken.value}: Type? = null' when absence is the value`, span(nameToken.span.start, (defaultValue ?? type ?? nameToken).span.end)));
|
|
53
|
+
defaultValue ??= { kind: "LiteralExpression", value: null, raw: "null", span: nameToken.span };
|
|
54
|
+
}
|
|
55
|
+
parameters.push({
|
|
56
|
+
name: nameToken.value,
|
|
57
|
+
type: optionalMarker && type ? { syntax: { kind: "OptionalTypeSyntax", inner: type.syntax, span: type.span }, span: type.span } : type,
|
|
58
|
+
defaultValue,
|
|
59
|
+
rest: false,
|
|
60
|
+
span: span(nameToken.span.start, (defaultValue ?? type ?? nameToken).span.end),
|
|
61
|
+
});
|
|
62
|
+
} while (host.match("comma") && !host.check("rightParen"));
|
|
63
|
+
}
|
|
64
|
+
host.expect("rightParen", "Expected ')' after parameters");
|
|
65
|
+
return parameters;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Consumes a keyword standing where a prop name belongs and reports the one
|
|
69
|
+
* message that names it, or returns null when the token cannot be a name.
|
|
70
|
+
*/
|
|
71
|
+
function componentPropKeyword(host) {
|
|
72
|
+
const token = host.current();
|
|
73
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(token.value))
|
|
74
|
+
return null;
|
|
75
|
+
if (token.kind === "identifier" || token.kind === "eof" || token.kind === "newline")
|
|
76
|
+
return null;
|
|
77
|
+
host.advance();
|
|
78
|
+
host.diagnostics.push(diagnostic("VEL2016", `'${token.value}' is a VelarScript keyword and cannot name a component prop; choose another name`, token.span));
|
|
79
|
+
return token;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* `@` selects the component's closed compiler namespace. The role names are
|
|
83
|
+
* `mounted` and `cleanup`; neither is found through author-name lookup.
|
|
84
|
+
*/
|
|
85
|
+
function matchLifecycleHook(host, name) {
|
|
86
|
+
if (!host.check("at") || host.peekKind(1) !== "identifier" || host.peekValue(1) !== name)
|
|
87
|
+
return false;
|
|
88
|
+
host.advance();
|
|
89
|
+
host.advance();
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
export function parseComponent(host, start, exported) {
|
|
93
|
+
const name = host.expect("identifier", "Expected a component name");
|
|
94
|
+
if (host.check("less")) {
|
|
95
|
+
host.parseTypeParameters();
|
|
96
|
+
host.diagnostics.push(diagnostic("VEL2025", `Component '${name.value}' cannot declare type parameters; ${typeParameterDeclarationFormsPhrase()} take '<T>'`, name.span));
|
|
97
|
+
}
|
|
98
|
+
host.insideComponentProps += 1;
|
|
99
|
+
const parameters = host.check("leftParen") ? host.parseParameters() : [];
|
|
100
|
+
host.insideComponentProps -= 1;
|
|
101
|
+
for (const parameter of parameters) {
|
|
102
|
+
if (parameter.rest) {
|
|
103
|
+
host.diagnostics.push(diagnostic("VEL2016", "Components use named props and do not support rest parameters", parameter.span));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const handleType = host.matchExtensionKeyword("exposes") ? host.parseTypeReference() : null;
|
|
107
|
+
host.expect("colon", "Expected ':' before component body");
|
|
108
|
+
host.expect("newline", "Expected a newline before component body");
|
|
109
|
+
host.consumeNewlines();
|
|
110
|
+
host.expect("indent", "Expected an indented component body");
|
|
111
|
+
const body = [];
|
|
112
|
+
host.consumeNewlines();
|
|
113
|
+
while (!host.check("dedent") && !host.check("eof")) {
|
|
114
|
+
const itemStart = host.current().span.start;
|
|
115
|
+
let item = null;
|
|
116
|
+
if (exposeItemAhead(host)) {
|
|
117
|
+
host.advance();
|
|
118
|
+
const value = host.parseExpression();
|
|
119
|
+
item = { kind: "ExtensionStatement:web:expose", value, span: span(itemStart, value.span.end) };
|
|
120
|
+
}
|
|
121
|
+
else if (namedDeclarationAhead(host, "state", reactiveBindingShapes)) {
|
|
122
|
+
host.advance();
|
|
123
|
+
item = parseStateDeclaration(host, itemStart, false);
|
|
124
|
+
}
|
|
125
|
+
else if (namedDeclarationAhead(host, "computed", reactiveBindingShapes)) {
|
|
126
|
+
host.advance();
|
|
127
|
+
item = parseComputedDeclaration(host, itemStart, false);
|
|
128
|
+
}
|
|
129
|
+
else if (namedDeclarationAhead(host, "resource", reactiveBindingShapes)) {
|
|
130
|
+
host.advance();
|
|
131
|
+
item = parseResourceDeclaration(host, itemStart, false);
|
|
132
|
+
}
|
|
133
|
+
else if (namedDeclarationAhead(host, "action", actionHeaderShapes)) {
|
|
134
|
+
host.advance();
|
|
135
|
+
item = parseActionDeclaration(host, itemStart, false);
|
|
136
|
+
}
|
|
137
|
+
else if (blockHeaderAhead(host, "watch")) {
|
|
138
|
+
host.advance();
|
|
139
|
+
item = parseWatchDeclaration(host, itemStart);
|
|
140
|
+
}
|
|
141
|
+
else if (matchLifecycleHook(host, "mounted")) {
|
|
142
|
+
const body = host.parseBlock();
|
|
143
|
+
item = { kind: "ExtensionStatement:web:mounted", body, span: span(itemStart, body.at(-1)?.span.end ?? itemStart) };
|
|
144
|
+
}
|
|
145
|
+
else if (matchLifecycleHook(host, "cleanup")) {
|
|
146
|
+
const body = host.parseBlock();
|
|
147
|
+
item = { kind: "ExtensionStatement:web:cleanup", body, span: span(itemStart, body.at(-1)?.span.end ?? itemStart) };
|
|
148
|
+
}
|
|
149
|
+
else if (host.check("at")) {
|
|
150
|
+
const marker = host.advance();
|
|
151
|
+
const name = host.check("identifier") ? host.advance() : null;
|
|
152
|
+
host.diagnostics.push(diagnostic("VEL5061", name
|
|
153
|
+
? `Unknown compiler-owned name '@${name.value}' in a component; the component namespace contains only '@mounted:' and '@cleanup:'`
|
|
154
|
+
: "Expected a compiler-owned component name after '@'; the component namespace contains only '@mounted:' and '@cleanup:'", span(marker.span.start, (name ?? marker).span.end)));
|
|
155
|
+
host.skipMistypedDeclaration();
|
|
156
|
+
}
|
|
157
|
+
else if (host.check("identifier") && lifecycleHookSpellings.has(host.current().value) && host.peekKind(1) === "colon") {
|
|
158
|
+
// The bare words are ordinary author names. Recover as the one accepted
|
|
159
|
+
// compiler-owned spelling so the body keeps analyzing, while retaining
|
|
160
|
+
// a diagnostic: recovery is not a second alias.
|
|
161
|
+
const keyword = host.advance();
|
|
162
|
+
host.diagnostics.push(recoveredDiagnostic("VEL5061", `Use '@${keyword.value}:'; it is a compiler-owned component name, which leaves '${keyword.value}' free for your own method`, keyword.span));
|
|
163
|
+
const body = host.parseBlock();
|
|
164
|
+
item = keyword.value === "mounted"
|
|
165
|
+
? { kind: "ExtensionStatement:web:mounted", body, span: span(itemStart, body.at(-1)?.span.end ?? itemStart) }
|
|
166
|
+
: { kind: "ExtensionStatement:web:cleanup", body, span: span(itemStart, body.at(-1)?.span.end ?? itemStart) };
|
|
167
|
+
}
|
|
168
|
+
else if (host.check("identifier") && renderBlockSpellings.has(host.current().value) && host.peekKind(1) === "colon") {
|
|
169
|
+
const keyword = host.advance();
|
|
170
|
+
host.diagnostics.push(diagnostic("VEL5048", `Use 'return <...>'; a component returns its JSX directly and has no '${keyword.value}:' block`, keyword.span));
|
|
171
|
+
host.skipMistypedDeclaration();
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
item = host.parseStatement();
|
|
175
|
+
}
|
|
176
|
+
if (item)
|
|
177
|
+
body.push(item);
|
|
178
|
+
if (host.previous().kind !== "dedent")
|
|
179
|
+
host.expectStatementBoundary();
|
|
180
|
+
host.consumeNewlines();
|
|
181
|
+
}
|
|
182
|
+
const close = host.expect("dedent", "Expected the end of component body");
|
|
183
|
+
return { kind: "ExtensionStatement:web:component", exported, name: name.value, parameters, handleType, body, span: span(start, body.at(-1)?.span.end ?? close.span.end) };
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/parser/statements/components.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,mCAAmC,EAAmB,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAKN,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAIN,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,qBAA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AAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,oCAAoC,CAAC,CAAC;IAC1E,OAAO,EAAE,IAAI,EAAE,kCAAkC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC5K,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a contextual Web word standing at the start of a line is a
|
|
3
|
+
* declaration head at all, and the token shapes each head is claimed by.
|
|
4
|
+
*
|
|
5
|
+
* D30 item 16 is one rule with three readings — a name and a shape token, a
|
|
6
|
+
* header line ending in ':', a word followed by a fresh value — and both the
|
|
7
|
+
* module-level dispatcher in `parser.ts` and `parseComponent` ask all three, so
|
|
8
|
+
* the lookaheads are a shared module rather than a copy on each side.
|
|
9
|
+
*/
|
|
10
|
+
import type { TokenKind } from "@velarscript/compiler/extension";
|
|
11
|
+
export interface StatementHeadParserHost {
|
|
12
|
+
checkWord(value: string): boolean;
|
|
13
|
+
peekKind(distance: number): TokenKind;
|
|
14
|
+
}
|
|
15
|
+
export declare const componentHeaderShapes: Set<string>;
|
|
16
|
+
export declare const reactiveBindingShapes: Set<string>;
|
|
17
|
+
export declare const actionHeaderShapes: Set<string>;
|
|
18
|
+
/**
|
|
19
|
+
* D30 item 16: a Web declaration head is claimed only in its own declaration
|
|
20
|
+
* shape — the word, a name, and one of the tokens that can follow it there.
|
|
21
|
+
* `state = 1`, `state(x)`, and `state.field` all keep the identifier reading.
|
|
22
|
+
*/
|
|
23
|
+
export declare function namedDeclarationAhead(host: StatementHeadParserHost, word: string, shapes: ReadonlySet<string>): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* `watch` opens a block: its header line ends in ':' and an indented body
|
|
26
|
+
* follows. No expression statement can end in ':', so the lookahead is exact
|
|
27
|
+
* and `watch = 1` / `watch(value)` stay ordinary code.
|
|
28
|
+
*/
|
|
29
|
+
export declare function blockHeaderAhead(host: StatementHeadParserHost, word: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* `expose value` is the one Web statement head followed by a bare expression
|
|
32
|
+
* rather than by a name and a shape token. It is claimed only when the next
|
|
33
|
+
* token opens a fresh value, so `expose(handle)` reads as a call and
|
|
34
|
+
* `expose = handle` as an assignment — the identifier reading wins wherever
|
|
35
|
+
* the two could compete.
|
|
36
|
+
*/
|
|
37
|
+
export declare function exposeItemAhead(host: StatementHeadParserHost): boolean;
|
|
38
|
+
//# sourceMappingURL=heads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heads.d.ts","sourceRoot":"","sources":["../../../src/parser/statements/heads.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,MAAM,WAAW,uBAAuB;IACtC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAGD,eAAO,MAAM,qBAAqB,aAAwD,CAAC;AAC3F,eAAO,MAAM,qBAAqB,aAA+B,CAAC;AAClE,eAAO,MAAM,kBAAkB,aAAyB,CAAC;AAOzD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAEvH;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAcrF;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAEtE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// The tokens that may follow the declared name in each Web declaration head.
|
|
2
|
+
export const componentHeaderShapes = new Set(["leftParen", "colon", "less", "identifier"]);
|
|
3
|
+
export const reactiveBindingShapes = new Set(["assign", "colon"]);
|
|
4
|
+
export const actionHeaderShapes = new Set(["leftParen"]);
|
|
5
|
+
// Tokens that open a fresh value rather than continuing the expression before
|
|
6
|
+
// them; only these make `expose` the component's expose item.
|
|
7
|
+
const exposeValueStartKinds = new Set([
|
|
8
|
+
"identifier", "string", "fstring", "number", "unitNumber", "true", "false", "null", "super", "leftBrace", "extensionToken",
|
|
9
|
+
]);
|
|
10
|
+
/**
|
|
11
|
+
* D30 item 16: a Web declaration head is claimed only in its own declaration
|
|
12
|
+
* shape — the word, a name, and one of the tokens that can follow it there.
|
|
13
|
+
* `state = 1`, `state(x)`, and `state.field` all keep the identifier reading.
|
|
14
|
+
*/
|
|
15
|
+
export function namedDeclarationAhead(host, word, shapes) {
|
|
16
|
+
return host.checkWord(word) && host.peekKind(1) === "identifier" && shapes.has(host.peekKind(2));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `watch` opens a block: its header line ends in ':' and an indented body
|
|
20
|
+
* follows. No expression statement can end in ':', so the lookahead is exact
|
|
21
|
+
* and `watch = 1` / `watch(value)` stay ordinary code.
|
|
22
|
+
*/
|
|
23
|
+
export function blockHeaderAhead(host, word) {
|
|
24
|
+
if (!host.checkWord(word))
|
|
25
|
+
return false;
|
|
26
|
+
let depth = 0;
|
|
27
|
+
let offset = 1;
|
|
28
|
+
for (;; offset += 1) {
|
|
29
|
+
const kind = host.peekKind(offset);
|
|
30
|
+
if (kind === "leftParen" || kind === "leftBracket" || kind === "leftBrace")
|
|
31
|
+
depth += 1;
|
|
32
|
+
else if (kind === "rightParen" || kind === "rightBracket" || kind === "rightBrace")
|
|
33
|
+
depth -= 1;
|
|
34
|
+
else if (kind === "eof")
|
|
35
|
+
return false;
|
|
36
|
+
else if (depth === 0 && (kind === "newline" || kind === "dedent"))
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
if (offset < 3 || host.peekKind(offset - 1) !== "colon")
|
|
40
|
+
return false;
|
|
41
|
+
while (host.peekKind(offset) === "newline")
|
|
42
|
+
offset += 1;
|
|
43
|
+
return host.peekKind(offset) === "indent";
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `expose value` is the one Web statement head followed by a bare expression
|
|
47
|
+
* rather than by a name and a shape token. It is claimed only when the next
|
|
48
|
+
* token opens a fresh value, so `expose(handle)` reads as a call and
|
|
49
|
+
* `expose = handle` as an assignment — the identifier reading wins wherever
|
|
50
|
+
* the two could compete.
|
|
51
|
+
*/
|
|
52
|
+
export function exposeItemAhead(host) {
|
|
53
|
+
return host.checkWord("expose") && exposeValueStartKinds.has(host.peekKind(1));
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=heads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heads.js","sourceRoot":"","sources":["../../../src/parser/statements/heads.ts"],"names":[],"mappings":"AAgBA,6EAA6E;AAC7E,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAC3F,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAClE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;AACzD,8EAA8E;AAC9E,8DAA8D;AAC9D,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE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S;QAAE,MAAM,IAAI,CAAC,CAAC;IACxD,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,IAA6B;IAC3D,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one import form the Web extension adds: `import css unsafe "./file.css"`,
|
|
3
|
+
* with the same stated placement its inline sibling carries.
|
|
4
|
+
*/
|
|
5
|
+
import { type Statement } from "@velarscript/compiler/extension";
|
|
6
|
+
import { type UnsafeCssParserHost } from "./unsafe-css.ts";
|
|
7
|
+
export type ImportParserHost = UnsafeCssParserHost;
|
|
8
|
+
export declare function parseCssImport(host: ImportParserHost, start: number): Statement | null | undefined;
|
|
9
|
+
//# sourceMappingURL=imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../../src/parser/statements/imports.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,EAA2B,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEpF,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAEnD,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CAoBlG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one import form the Web extension adds: `import css unsafe "./file.css"`,
|
|
3
|
+
* with the same stated placement its inline sibling carries.
|
|
4
|
+
*/
|
|
5
|
+
import {} from "@velarscript/compiler/extension";
|
|
6
|
+
import {} from "../../ast.js";
|
|
7
|
+
import { diagnostic, span } from "../spans.js";
|
|
8
|
+
import { parseUnsafeCssPlacement } from "./unsafe-css.js";
|
|
9
|
+
export function parseCssImport(host, start) {
|
|
10
|
+
// `import css unsafe "./file.css"` against `import css from "./module.vel"`:
|
|
11
|
+
// the CSS boundary is claimed only when the word is followed by the
|
|
12
|
+
// boundary marker or by the path itself, so a module named `css` still
|
|
13
|
+
// imports by name.
|
|
14
|
+
if (!host.checkWord("css") || !(host.peekKind(1) === "unsafe" || host.peekKind(1) === "string"))
|
|
15
|
+
return undefined;
|
|
16
|
+
host.advance();
|
|
17
|
+
host.expect("unsafe", "Native CSS is an unsafe boundary; write 'import css unsafe'");
|
|
18
|
+
const source = host.expect("string", "Expected a relative .css path after 'import css unsafe'");
|
|
19
|
+
const placement = parseUnsafeCssPlacement(host);
|
|
20
|
+
if ((!source.value.startsWith("./") && !source.value.startsWith("../")) || !source.value.endsWith(".css")) {
|
|
21
|
+
host.diagnostics.push(diagnostic("VEL5037", "Unsafe CSS imports require an explicit relative path ending in '.css'", source.span));
|
|
22
|
+
}
|
|
23
|
+
const declaration = {
|
|
24
|
+
kind: "ExtensionStatement:web:unsafe-css",
|
|
25
|
+
source: { kind: "external", path: source.value, span: source.span },
|
|
26
|
+
placement,
|
|
27
|
+
span: span(start, host.previous().span.end),
|
|
28
|
+
};
|
|
29
|
+
return declaration;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.js","sourceRoot":"","sources":["../../../src/parser/statements/imports.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAkB,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAwD,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAA4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AC;AACrB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The five reactive declarations — `state`, `computed`, `resource`, `action`
|
|
3
|
+
* and `watch` — read after their head has already been claimed.
|
|
4
|
+
*
|
|
5
|
+
* Each is a module-level statement and a component item both, so the dispatcher
|
|
6
|
+
* in `parser.ts` and `parseComponent` call the same five readers.
|
|
7
|
+
*/
|
|
8
|
+
import { type Parameter, type Statement, type Token, type TokenKind, type TypeReference } from "@velarscript/compiler/extension";
|
|
9
|
+
import { type WebActionDeclaration as ActionDeclaration, type WebComputedDeclaration as ComputedDeclaration, type WebResourceDeclaration as ResourceDeclaration, type WebStateDeclaration as StateDeclaration, type WebWatchDeclaration as WatchDeclaration } from "../../ast.ts";
|
|
10
|
+
import type { Expression } from "@velarscript/compiler/extension";
|
|
11
|
+
export interface ReactiveParserHost {
|
|
12
|
+
expect(kind: TokenKind, message: string): Token;
|
|
13
|
+
match(kind: TokenKind): boolean;
|
|
14
|
+
matchWord(value: string): boolean;
|
|
15
|
+
parseBlock(): readonly Statement[];
|
|
16
|
+
parseExpression(minimumPrecedence?: number): Expression;
|
|
17
|
+
parseParameters(): readonly Parameter[];
|
|
18
|
+
parseTypeReference(allowTrailingOptional?: boolean): TypeReference;
|
|
19
|
+
previous(): Token;
|
|
20
|
+
}
|
|
21
|
+
export declare function parseStateDeclaration(host: ReactiveParserHost, start: number, exported: boolean): StateDeclaration;
|
|
22
|
+
/**
|
|
23
|
+
* D71 rule 182: `computed` parses exactly where `state` parses, through the
|
|
24
|
+
* same shape lookahead — the two halves of the reactive row differ in what
|
|
25
|
+
* they mean, not in how they are written.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseComputedDeclaration(host: ReactiveParserHost, start: number, exported: boolean): ComputedDeclaration;
|
|
28
|
+
export declare function parseResourceDeclaration(host: ReactiveParserHost, start: number, exported: boolean): ResourceDeclaration;
|
|
29
|
+
export declare function parseActionDeclaration(host: ReactiveParserHost, start: number, exported: boolean): ActionDeclaration;
|
|
30
|
+
export declare function parseWatchDeclaration(host: ReactiveParserHost, start: number): WatchDeclaration;
|
|
31
|
+
//# sourceMappingURL=reactive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive.d.ts","sourceRoot":"","sources":["../../../src/parser/statements/reactive.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACjI,OAAO,EACL,KAAK,oBAAoB,IAAI,iBAAiB,EAC9C,KAAK,sBAAsB,IAAI,mBAAmB,EAClD,KAAK,sBAAsB,IAAI,mBAAmB,EAClD,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,mBAAmB,IAAI,gBAAgB,EAC7C,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;IAChD,KAAK,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,UAAU,IAAI,SAAS,SAAS,EAAE,CAAC;IACnC,eAAe,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACxD,eAAe,IAAI,SAAS,SAAS,EAAE,CAAC;IACxC,kBAAkB,CAAC,qBAAqB,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IACnE,QAAQ,IAAI,KAAK,CAAC;CACnB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,gBAAgB,CAMlH;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,mBAAmB,CAMxH;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,mBAAmB,CAMxH;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,iBAAiB,CAkBpH;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAW/F"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The five reactive declarations — `state`, `computed`, `resource`, `action`
|
|
3
|
+
* and `watch` — read after their head has already been claimed.
|
|
4
|
+
*
|
|
5
|
+
* Each is a module-level statement and a component item both, so the dispatcher
|
|
6
|
+
* in `parser.ts` and `parseComponent` call the same five readers.
|
|
7
|
+
*/
|
|
8
|
+
import {} from "@velarscript/compiler/extension";
|
|
9
|
+
import {} from "../../ast.js";
|
|
10
|
+
import { span } from "../spans.js";
|
|
11
|
+
export function parseStateDeclaration(host, start, exported) {
|
|
12
|
+
const name = host.expect("identifier", "Expected a state name");
|
|
13
|
+
const type = host.match("colon") ? host.parseTypeReference() : null;
|
|
14
|
+
host.expect("assign", "Expected '=' after state name");
|
|
15
|
+
const initializer = host.parseExpression();
|
|
16
|
+
return { kind: "ExtensionStatement:web:state", exported, name: name.value, type, initializer, span: span(start, initializer.span.end) };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* D71 rule 182: `computed` parses exactly where `state` parses, through the
|
|
20
|
+
* same shape lookahead — the two halves of the reactive row differ in what
|
|
21
|
+
* they mean, not in how they are written.
|
|
22
|
+
*/
|
|
23
|
+
export function parseComputedDeclaration(host, start, exported) {
|
|
24
|
+
const name = host.expect("identifier", "Expected a computed name");
|
|
25
|
+
const type = host.match("colon") ? host.parseTypeReference() : null;
|
|
26
|
+
host.expect("assign", "Expected '=' after computed name");
|
|
27
|
+
const initializer = host.parseExpression();
|
|
28
|
+
return { kind: "ExtensionStatement:web:computed", exported, name: name.value, type, initializer, span: span(start, initializer.span.end) };
|
|
29
|
+
}
|
|
30
|
+
export function parseResourceDeclaration(host, start, exported) {
|
|
31
|
+
const name = host.expect("identifier", "Expected a resource name");
|
|
32
|
+
const type = host.match("colon") ? host.parseTypeReference() : null;
|
|
33
|
+
host.expect("assign", "Expected '=' after resource name");
|
|
34
|
+
const initializer = host.parseExpression();
|
|
35
|
+
return { kind: "ExtensionStatement:web:resource", exported, name: name.value, type, initializer, span: span(start, initializer.span.end) };
|
|
36
|
+
}
|
|
37
|
+
export function parseActionDeclaration(host, start, exported) {
|
|
38
|
+
const name = host.expect("identifier", "Expected an action name");
|
|
39
|
+
const parameters = host.parseParameters();
|
|
40
|
+
const parameterListEnd = host.previous().span.end;
|
|
41
|
+
const returnType = host.match("arrow") ? host.parseTypeReference() : null;
|
|
42
|
+
const body = host.parseBlock();
|
|
43
|
+
const end = body.at(-1)?.span.end ?? returnType?.span.end ?? name.span.end;
|
|
44
|
+
return {
|
|
45
|
+
kind: "ExtensionStatement:web:action",
|
|
46
|
+
exported,
|
|
47
|
+
name: name.value,
|
|
48
|
+
parameters,
|
|
49
|
+
returnType,
|
|
50
|
+
...(returnType ? { resultAnnotationSpan: span(parameterListEnd, returnType.span.end) } : {}),
|
|
51
|
+
signatureSpan: span(start, returnType?.span.end ?? parameterListEnd),
|
|
52
|
+
body,
|
|
53
|
+
span: span(start, end),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function parseWatchDeclaration(host, start) {
|
|
57
|
+
const expression = host.parseExpression();
|
|
58
|
+
let currentName = null;
|
|
59
|
+
let previousName = null;
|
|
60
|
+
if (host.matchWord("as")) {
|
|
61
|
+
currentName = host.expect("identifier", "Expected the current watch value name").value;
|
|
62
|
+
host.expect("comma", "Expected ',' between watch value names");
|
|
63
|
+
previousName = host.expect("identifier", "Expected the previous watch value name").value;
|
|
64
|
+
}
|
|
65
|
+
const body = host.parseBlock();
|
|
66
|
+
return { kind: "ExtensionStatement:web:watch", expression, currentName, previousName, body, span: span(start, body.at(-1)?.span.end ?? expression.span.end) };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=reactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive.js","sourceRoot":"","sources":["../../../src/parser/statements/reactive.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAkF,MAAM,iCAAiC,CAAC;AACjI,OAAO,EAMN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAanC,MAAM,UAAU,qBAAqB,CAAC,IAAwB,EAAE,KAAa,EAAE,QAAiB;IAC9F,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAAC;IAChE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,+BAA+B,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;IAC3C,OAAO,EAAE,IAAI,EAAE,8BAA8B,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC1I,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAwB,EAAE,KAAa,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AAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,uCAAuC,CAAC,CAAC,KAAK,CAAC;QACvF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,wCAAwC,CAAC,CAAC;QAC/D,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,wCAAwC,CAAC,CAAC,KAAK,CAAC;IAC3F,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;IAC/B,OAAO,EAAE,IAAI,EAAE,8BAA8B,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAChK,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The explicit native-CSS boundary: the inline `unsafe css` block, and the
|
|
3
|
+
* `before look` / `after look` placement both it and `import css unsafe` must
|
|
4
|
+
* state in source.
|
|
5
|
+
*/
|
|
6
|
+
import type { Diagnostic } from "@velarscript/compiler";
|
|
7
|
+
import { type Statement, type Token, type TokenKind } from "@velarscript/compiler/extension";
|
|
8
|
+
export interface UnsafeCssParserHost {
|
|
9
|
+
advance(): Token;
|
|
10
|
+
checkWord(value: string): boolean;
|
|
11
|
+
current(): Token;
|
|
12
|
+
readonly diagnostics: Diagnostic[];
|
|
13
|
+
expect(kind: TokenKind, message: string): Token;
|
|
14
|
+
matchExtensionKeyword(value: string): boolean;
|
|
15
|
+
peekKind(distance: number): TokenKind;
|
|
16
|
+
peekValue(distance: number): string;
|
|
17
|
+
previous(): Token;
|
|
18
|
+
}
|
|
19
|
+
export declare function parseUnsafeCssStatement(host: UnsafeCssParserHost, start: number): Statement | null | undefined;
|
|
20
|
+
export declare function parseUnsafeCssPlacement(host: UnsafeCssParserHost): "before" | "after";
|
|
21
|
+
//# sourceMappingURL=unsafe-css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsafe-css.d.ts","sourceRoot":"","sources":["../../../src/parser/statements/unsafe-css.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAK7F,MAAM,WAAW,mBAAmB;IAClC,OAAO,IAAI,KAAK,CAAC;IACjB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,OAAO,IAAI,KAAK,CAAC;IACjB,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAC;IACnC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;IAChD,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,QAAQ,IAAI,KAAK,CAAC;CACnB;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,CAkB9G;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,GAAG,QAAQ,GAAG,OAAO,CAarF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {} from "@velarscript/compiler/extension";
|
|
2
|
+
import {} from "../../ast.js";
|
|
3
|
+
import { WEB_UNSAFE_CSS_TOKEN } from "../../lexer.js";
|
|
4
|
+
import { diagnostic, span } from "../spans.js";
|
|
5
|
+
export function parseUnsafeCssStatement(host, start) {
|
|
6
|
+
if (!host.checkWord("css") || host.peekKind(1) !== "extensionToken"
|
|
7
|
+
|| host.peekValue(1) !== WEB_UNSAFE_CSS_TOKEN)
|
|
8
|
+
return undefined;
|
|
9
|
+
host.advance();
|
|
10
|
+
const token = host.advance();
|
|
11
|
+
const payload = token.payload;
|
|
12
|
+
if (!payload || payload.kind !== "WebUnsafeCssBlockSyntax") {
|
|
13
|
+
host.diagnostics.push(diagnostic("VEL5037", "The inline unsafe CSS token is missing its raw source", token.span));
|
|
14
|
+
return { kind: "PassStatement", span: token.span };
|
|
15
|
+
}
|
|
16
|
+
const placement = parseUnsafeCssPlacement(host);
|
|
17
|
+
const declaration = {
|
|
18
|
+
kind: "ExtensionStatement:web:unsafe-css",
|
|
19
|
+
source: { kind: "inline", css: payload.css, span: payload.contentSpan },
|
|
20
|
+
placement,
|
|
21
|
+
span: span(start, host.previous().span.end),
|
|
22
|
+
};
|
|
23
|
+
return declaration;
|
|
24
|
+
}
|
|
25
|
+
export function parseUnsafeCssPlacement(host) {
|
|
26
|
+
let placement = "before";
|
|
27
|
+
if (host.current().kind === "identifier" && host.current().value === "before") {
|
|
28
|
+
host.expect("identifier", "Expected 'before'");
|
|
29
|
+
placement = "before";
|
|
30
|
+
}
|
|
31
|
+
else if (host.current().kind === "identifier" && host.current().value === "after") {
|
|
32
|
+
host.expect("identifier", "Expected 'after'");
|
|
33
|
+
placement = "after";
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
host.diagnostics.push(diagnostic("VEL5037", "Unsafe CSS must explicitly declare 'before look' or 'after look'", host.current().span));
|
|
37
|
+
if (!host.matchExtensionKeyword("look")) {
|
|
38
|
+
host.diagnostics.push(diagnostic("VEL5037", "Unsafe CSS order must end with 'look'", host.current().span));
|
|
39
|
+
}
|
|
40
|
+
return placement;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=unsafe-css.js.map
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