@arkitektio/bsx 4.3.0 → 6.0.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 +39 -18
- package/dist/bsx/analyze.d.ts +6 -5
- package/dist/bsx/analyze.d.ts.map +1 -1
- package/dist/bsx/analyze.js +12 -10
- package/dist/bsx/analyze.js.map +1 -1
- package/dist/bsx/declared.d.ts +111 -0
- package/dist/bsx/declared.d.ts.map +1 -0
- package/dist/bsx/declared.js +311 -0
- package/dist/bsx/declared.js.map +1 -0
- package/dist/bsx/index.d.ts +1 -0
- package/dist/bsx/index.d.ts.map +1 -1
- package/dist/bsx/index.js +1 -0
- package/dist/bsx/index.js.map +1 -1
- package/dist/bsx/infer.d.ts +40 -17
- package/dist/bsx/infer.d.ts.map +1 -1
- package/dist/bsx/infer.js +105 -49
- package/dist/bsx/infer.js.map +1 -1
- package/dist/bsx/language.d.ts +6 -2
- package/dist/bsx/language.d.ts.map +1 -1
- package/dist/bsx/language.js +65 -21
- package/dist/bsx/language.js.map +1 -1
- package/dist/bsx/parse.d.ts +19 -8
- package/dist/bsx/parse.d.ts.map +1 -1
- package/dist/bsx/parse.js +49 -59
- package/dist/bsx/parse.js.map +1 -1
- package/dist/bsx/print.d.ts.map +1 -1
- package/dist/bsx/print.js +25 -35
- package/dist/bsx/print.js.map +1 -1
- package/dist/bsx/references.d.ts +48 -54
- package/dist/bsx/references.d.ts.map +1 -1
- package/dist/bsx/references.js +359 -159
- package/dist/bsx/references.js.map +1 -1
- package/dist/catalogs/html.d.ts +3 -3
- package/dist/catalogs/html.d.ts.map +1 -1
- package/dist/catalogs/html.js +3 -3
- package/dist/catalogs/html.js.map +1 -1
- package/dist/catalogs/index.d.ts +172 -180
- package/dist/catalogs/index.d.ts.map +1 -1
- package/dist/catalogs/index.js +6 -2
- package/dist/catalogs/index.js.map +1 -1
- package/dist/catalogs/logo.d.ts +19 -33
- package/dist/catalogs/logo.d.ts.map +1 -1
- package/dist/catalogs/logo.js +4 -5
- package/dist/catalogs/logo.js.map +1 -1
- package/dist/catalogs/parts/data.d.ts +6 -6
- package/dist/catalogs/parts/feedback.d.ts +15 -15
- package/dist/catalogs/parts/forms.d.ts +24 -24
- package/dist/catalogs/parts/html.d.ts +3 -3
- package/dist/catalogs/parts/html.d.ts.map +1 -1
- package/dist/catalogs/parts/html.js +1 -1
- package/dist/catalogs/parts/html.js.map +1 -1
- package/dist/catalogs/parts/icons.d.ts +11 -11
- package/dist/catalogs/parts/icons.js +1 -1
- package/dist/catalogs/parts/index.d.ts +153 -165
- package/dist/catalogs/parts/index.d.ts.map +1 -1
- package/dist/catalogs/parts/layout.d.ts +11 -1
- package/dist/catalogs/parts/layout.d.ts.map +1 -1
- package/dist/catalogs/parts/layout.js +9 -0
- package/dist/catalogs/parts/layout.js.map +1 -1
- package/dist/catalogs/parts/logo.d.ts +17 -32
- package/dist/catalogs/parts/logo.d.ts.map +1 -1
- package/dist/catalogs/parts/logo.js +13 -15
- package/dist/catalogs/parts/logo.js.map +1 -1
- package/dist/catalogs/parts/navigation.d.ts +20 -20
- package/dist/catalogs/parts/overlays.d.ts +55 -55
- package/dist/catalogs/parts/run.d.ts +5 -13
- package/dist/catalogs/parts/run.d.ts.map +1 -1
- package/dist/catalogs/parts/run.js +1 -1
- package/dist/catalogs/parts/scene.d.ts +9 -17
- package/dist/catalogs/parts/scene.d.ts.map +1 -1
- package/dist/catalogs/parts/scene.js +1 -5
- package/dist/catalogs/parts/scene.js.map +1 -1
- package/dist/catalogs/parts/structure.js +2 -2
- package/dist/catalogs/parts/toast.js +1 -1
- package/dist/catalogs/parts/toast.js.map +1 -1
- package/dist/catalogs/parts/typography.d.ts +3 -3
- package/dist/catalogs/parts/typography.js +1 -1
- package/dist/catalogs/parts/typography.js.map +1 -1
- package/dist/catalogs/props.d.ts +4 -4
- package/dist/catalogs/scene.d.ts +8 -16
- package/dist/catalogs/scene.d.ts.map +1 -1
- package/dist/catalogs/scene.js +3 -3
- package/dist/catalogs/scene.js.map +1 -1
- package/dist/catalogs/shadcn.d.ts +58 -58
- package/dist/catalogs/shadcn.d.ts.map +1 -1
- package/dist/catalogs/shadcn.js +4 -4
- package/dist/catalogs/shadcn.js.map +1 -1
- package/dist/catalogs/structure.d.ts +1 -1
- package/dist/catalogs/structure.d.ts.map +1 -1
- package/dist/catalogs/structure.js +3 -3
- package/dist/catalogs/structure.js.map +1 -1
- package/dist/catalogs/ui.d.ts +83 -73
- package/dist/catalogs/ui.d.ts.map +1 -1
- package/dist/catalogs/ui.js +4 -3
- package/dist/catalogs/ui.js.map +1 -1
- package/dist/catalogs.d.ts +1 -1
- package/dist/catalogs.d.ts.map +1 -1
- package/dist/catalogs.js +2 -2
- package/dist/catalogs.js.map +1 -1
- package/dist/logo/actionLogoSource.d.ts +3 -3
- package/dist/logo/actionLogoSource.d.ts.map +1 -1
- package/dist/logo/actionLogoSource.js +4 -4
- package/dist/logo/actionLogoSource.js.map +1 -1
- package/dist/ports.js +1 -1
- package/dist/ports.js.map +1 -1
- package/dist/renderer/BlokRenderer.d.ts +10 -6
- package/dist/renderer/BlokRenderer.d.ts.map +1 -1
- package/dist/renderer/BlokRenderer.js +23 -9
- package/dist/renderer/BlokRenderer.js.map +1 -1
- package/dist/renderer/baseCatalog.d.ts +8 -6
- package/dist/renderer/baseCatalog.d.ts.map +1 -1
- package/dist/renderer/baseCatalog.js +7 -5
- package/dist/renderer/baseCatalog.js.map +1 -1
- package/dist/renderer/bloks/control.d.ts +20 -2
- package/dist/renderer/bloks/control.d.ts.map +1 -1
- package/dist/renderer/bloks/control.js +98 -15
- package/dist/renderer/bloks/control.js.map +1 -1
- package/dist/renderer/bloks/data.d.ts +6 -6
- package/dist/renderer/bloks/feedback.d.ts +15 -15
- package/dist/renderer/bloks/forms.d.ts +24 -24
- package/dist/renderer/bloks/html.d.ts +2 -2
- package/dist/renderer/bloks/html.js +2 -2
- package/dist/renderer/bloks/icons.d.ts +5 -5
- package/dist/renderer/bloks/index.d.ts +145 -144
- package/dist/renderer/bloks/index.d.ts.map +1 -1
- package/dist/renderer/bloks/index.js +1 -1
- package/dist/renderer/bloks/layout.d.ts +9 -1
- package/dist/renderer/bloks/layout.d.ts.map +1 -1
- package/dist/renderer/bloks/layout.js +15 -0
- package/dist/renderer/bloks/layout.js.map +1 -1
- package/dist/renderer/bloks/logo/index.d.ts +6 -13
- package/dist/renderer/bloks/logo/index.d.ts.map +1 -1
- package/dist/renderer/bloks/logo/index.js +3 -4
- package/dist/renderer/bloks/logo/index.js.map +1 -1
- package/dist/renderer/bloks/logo/logo.fixture.json +266 -250
- package/dist/renderer/bloks/navigation.d.ts +20 -20
- package/dist/renderer/bloks/overlays.d.ts +55 -55
- package/dist/renderer/bloks/run/components.d.ts +2 -6
- package/dist/renderer/bloks/run/components.d.ts.map +1 -1
- package/dist/renderer/bloks/run/components.js +1 -1
- package/dist/renderer/bloks/scene/index.d.ts +5 -9
- package/dist/renderer/bloks/scene/index.d.ts.map +1 -1
- package/dist/renderer/bloks/scene/interaction.d.ts.map +1 -1
- package/dist/renderer/bloks/scene/interaction.js +3 -2
- package/dist/renderer/bloks/scene/interaction.js.map +1 -1
- package/dist/renderer/bloks/shared/props.d.ts +2 -2
- package/dist/renderer/bloks/toast.d.ts +1 -1
- package/dist/renderer/bloks/typography.d.ts +3 -3
- package/dist/renderer/bloks/typography.js +1 -1
- package/dist/renderer/catalog.d.ts +4 -7
- package/dist/renderer/catalog.d.ts.map +1 -1
- package/dist/renderer/catalog.js +7 -31
- package/dist/renderer/catalog.js.map +1 -1
- package/dist/renderer/declarations.d.ts +40 -33
- package/dist/renderer/declarations.d.ts.map +1 -1
- package/dist/renderer/declarations.js +41 -56
- package/dist/renderer/declarations.js.map +1 -1
- package/dist/renderer/declare.d.ts +31 -19
- package/dist/renderer/declare.d.ts.map +1 -1
- package/dist/renderer/declare.js +44 -18
- package/dist/renderer/declare.js.map +1 -1
- package/dist/renderer/persist.d.ts +22 -13
- package/dist/renderer/persist.d.ts.map +1 -1
- package/dist/renderer/persist.js +40 -21
- package/dist/renderer/persist.js.map +1 -1
- package/dist/renderer/runtime/catalog.d.ts +27 -7
- package/dist/renderer/runtime/catalog.d.ts.map +1 -1
- package/dist/renderer/runtime/catalog.js +30 -3
- package/dist/renderer/runtime/catalog.js.map +1 -1
- package/dist/renderer/runtime/components.d.ts +10 -4
- package/dist/renderer/runtime/components.d.ts.map +1 -1
- package/dist/renderer/runtime/components.js +8 -5
- package/dist/renderer/runtime/components.js.map +1 -1
- package/dist/renderer/runtime/context.d.ts +5 -5
- package/dist/renderer/runtime/context.d.ts.map +1 -1
- package/dist/renderer/runtime/context.js +11 -5
- package/dist/renderer/runtime/context.js.map +1 -1
- package/dist/renderer/runtime/describe.d.ts +16 -6
- package/dist/renderer/runtime/describe.d.ts.map +1 -1
- package/dist/renderer/runtime/describe.js +5 -2
- package/dist/renderer/runtime/describe.js.map +1 -1
- package/dist/renderer/runtime/hooks.d.ts.map +1 -1
- package/dist/renderer/runtime/hooks.js +8 -4
- package/dist/renderer/runtime/hooks.js.map +1 -1
- package/dist/renderer/runtime/index.d.ts +2 -0
- package/dist/renderer/runtime/index.d.ts.map +1 -1
- package/dist/renderer/runtime/index.js +2 -0
- package/dist/renderer/runtime/index.js.map +1 -1
- package/dist/renderer/runtime/locals.d.ts +57 -0
- package/dist/renderer/runtime/locals.d.ts.map +1 -0
- package/dist/renderer/runtime/locals.js +87 -0
- package/dist/renderer/runtime/locals.js.map +1 -0
- package/dist/renderer/runtime/preflight.d.ts.map +1 -1
- package/dist/renderer/runtime/preflight.js +5 -2
- package/dist/renderer/runtime/preflight.js.map +1 -1
- package/dist/renderer/runtime/scope.d.ts +14 -0
- package/dist/renderer/runtime/scope.d.ts.map +1 -1
- package/dist/renderer/runtime/scope.js +25 -3
- package/dist/renderer/runtime/scope.js.map +1 -1
- package/dist/renderer/runtime/text.d.ts +28 -0
- package/dist/renderer/runtime/text.d.ts.map +1 -0
- package/dist/renderer/runtime/text.js +82 -0
- package/dist/renderer/runtime/text.js.map +1 -0
- package/dist/renderer/runtime/tree.d.ts.map +1 -1
- package/dist/renderer/runtime/tree.js +7 -1
- package/dist/renderer/runtime/tree.js.map +1 -1
- package/dist/renderer/runtime/types.d.ts +8 -3
- package/dist/renderer/runtime/types.d.ts.map +1 -1
- package/dist/runtime.d.ts +0 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +0 -1
- package/dist/runtime.js.map +1 -1
- package/dist/scene.d.ts +1 -1
- package/dist/scene.d.ts.map +1 -1
- package/dist/scene.js +2 -2
- package/dist/scene.js.map +1 -1
- package/dist/shadcn.d.ts +154 -153
- package/dist/shadcn.d.ts.map +1 -1
- package/dist/shadcn.js +7 -7
- package/dist/shadcn.js.map +1 -1
- package/dist/spec/bsx_v2.json +12324 -6934
- package/dist/spec/catalogs/base@4.json +13175 -0
- package/dist/spec/catalogs/base@4.json.js +13175 -0
- package/dist/spec/catalogs/orkestrator@1.json +489 -0
- package/dist/spec/catalogs/orkestrator@1.json.js +489 -0
- package/dist/spec/catalogs.d.ts +109 -46
- package/dist/spec/catalogs.d.ts.map +1 -1
- package/dist/spec/catalogs.js +243 -75
- package/dist/spec/catalogs.js.map +1 -1
- package/dist/spec/vocabulary.d.ts +44 -7
- package/dist/spec/vocabulary.d.ts.map +1 -1
- package/dist/spec/vocabulary.js +65 -7
- package/dist/spec/vocabulary.js.map +1 -1
- package/dist/spec/vocabulary.json +83 -43
- package/dist/spec/vocabulary.json.js +83 -43
- package/dist/vendor/core/ui/button-group.d.ts +1 -1
- package/dist/vendor/core/ui/button.d.ts +1 -1
- package/dist/vendor/core/ui/field.d.ts +1 -1
- package/package.json +1 -1
- package/src/bsx/analyze.ts +14 -12
- package/src/bsx/bsx.test.ts +4 -4
- package/src/bsx/declared.ts +346 -0
- package/src/bsx/index.ts +1 -0
- package/src/bsx/infer.test.ts +54 -52
- package/src/bsx/infer.ts +128 -71
- package/src/bsx/language.test.ts +37 -25
- package/src/bsx/language.ts +72 -25
- package/src/bsx/parse.ts +51 -64
- package/src/bsx/partial.test.ts +1 -1
- package/src/bsx/print.ts +27 -34
- package/src/bsx/references.test.ts +86 -83
- package/src/bsx/references.ts +391 -198
- package/src/catalogs/catalogs.test.ts +46 -14
- package/src/catalogs/html.ts +3 -3
- package/src/catalogs/index.ts +6 -2
- package/src/catalogs/logo.ts +4 -5
- package/src/catalogs/parts/html.ts +1 -1
- package/src/catalogs/parts/icons.ts +1 -1
- package/src/catalogs/parts/layout.ts +11 -0
- package/src/catalogs/parts/logo.ts +14 -18
- package/src/catalogs/parts/run.ts +1 -1
- package/src/catalogs/parts/scene.ts +1 -7
- package/src/catalogs/parts/structure.ts +2 -2
- package/src/catalogs/parts/toast.ts +1 -1
- package/src/catalogs/parts/typography.ts +1 -1
- package/src/catalogs/scene.ts +3 -3
- package/src/catalogs/shadcn.ts +4 -4
- package/src/catalogs/structure.ts +3 -3
- package/src/catalogs/ui.ts +4 -3
- package/src/catalogs.ts +9 -2
- package/src/logo/actionLogoSource.ts +4 -4
- package/src/ports.ts +1 -1
- package/src/renderer/BlokComponentHost.test.tsx +5 -5
- package/src/renderer/BlokRenderer.tsx +46 -14
- package/src/renderer/addBlokComponents.test.tsx +8 -22
- package/src/renderer/baseCatalog.ts +7 -5
- package/src/renderer/bloks/components.test.tsx +2 -2
- package/src/renderer/bloks/control.tsx +136 -17
- package/src/renderer/bloks/flow.test.tsx +1 -1
- package/src/renderer/bloks/html.tsx +2 -2
- package/src/renderer/bloks/index.ts +1 -1
- package/src/renderer/bloks/layout.tsx +28 -0
- package/src/renderer/bloks/logo/index.tsx +4 -5
- package/src/renderer/bloks/logo/logo.fixture.json +266 -250
- package/src/renderer/bloks/logo/logo.test.tsx +18 -7
- package/src/renderer/bloks/run/components.tsx +1 -1
- package/src/renderer/bloks/run/space.test.tsx +12 -4
- package/src/renderer/bloks/scene/interaction.tsx +11 -6
- package/src/renderer/bloks/scene/transform.test.ts +8 -7
- package/src/renderer/bloks/time.test.tsx +1 -1
- package/src/renderer/bloks/toast.tsx +1 -1
- package/src/renderer/bloks/typography.tsx +1 -1
- package/src/renderer/catalog.tsx +7 -31
- package/src/renderer/declarations.test.ts +38 -51
- package/src/renderer/declarations.ts +67 -88
- package/src/renderer/declare.test.ts +41 -0
- package/src/renderer/declare.ts +70 -32
- package/src/renderer/persist.test.ts +70 -49
- package/src/renderer/persist.ts +57 -34
- package/src/renderer/runtime/catalog.test.ts +2 -2
- package/src/renderer/runtime/catalog.ts +35 -10
- package/src/renderer/runtime/components.tsx +17 -8
- package/src/renderer/runtime/context.tsx +17 -10
- package/src/renderer/runtime/describe.ts +21 -8
- package/src/renderer/runtime/hooks.ts +6 -4
- package/src/renderer/runtime/index.ts +2 -0
- package/src/renderer/runtime/locals.tsx +105 -0
- package/src/renderer/runtime/preflight.ts +5 -2
- package/src/renderer/runtime/scope.tsx +31 -3
- package/src/renderer/runtime/text.test.tsx +65 -0
- package/src/renderer/runtime/text.ts +88 -0
- package/src/renderer/runtime/tree.tsx +16 -4
- package/src/renderer/runtime/types.ts +8 -3
- package/src/runtime.ts +0 -1
- package/src/scene.ts +2 -2
- package/src/shadcn.ts +7 -7
- package/src/spec/bsx_v2.json +12324 -6934
- package/src/spec/catalogs/base@4.json +13175 -0
- package/src/spec/catalogs/orkestrator@1.json +489 -0
- package/src/spec/catalogs.ts +259 -103
- package/src/spec/spec.test.ts +93 -24
- package/src/spec/vocabulary.json +83 -43
- package/src/spec/vocabulary.ts +102 -17
- package/dist/renderer/modules.d.ts +0 -4
- package/dist/renderer/modules.d.ts.map +0 -1
- package/dist/renderer/modules.js +0 -11
- package/dist/renderer/modules.js.map +0 -1
- package/dist/spec/catalogs/base@2.json +0 -355
- package/dist/spec/catalogs/base@2.json.js +0 -355
- package/dist/spec/catalogs/html@1.json +0 -308
- package/dist/spec/catalogs/html@1.json.js +0 -308
- package/dist/spec/catalogs/logo@1.json +0 -1687
- package/dist/spec/catalogs/logo@1.json.js +0 -1687
- package/dist/spec/catalogs/scene@1.json +0 -878
- package/dist/spec/catalogs/scene@1.json.js +0 -878
- package/dist/spec/catalogs/shadcn@1.json +0 -4002
- package/dist/spec/catalogs/shadcn@1.json.js +0 -4002
- package/dist/spec/catalogs/structure@1.json +0 -185
- package/dist/spec/catalogs/structure@1.json.js +0 -185
- package/dist/spec/catalogs/ui@1.json +0 -5349
- package/dist/spec/catalogs/ui@1.json.js +0 -5349
- package/src/renderer/modules.ts +0 -12
- package/src/spec/catalogs/base@2.json +0 -355
- package/src/spec/catalogs/html@1.json +0 -308
- package/src/spec/catalogs/logo@1.json +0 -1687
- package/src/spec/catalogs/scene@1.json +0 -878
- package/src/spec/catalogs/shadcn@1.json +0 -4002
- package/src/spec/catalogs/structure@1.json +0 -185
- package/src/spec/catalogs/ui@1.json +0 -5349
package/src/bsx/references.ts
CHANGED
|
@@ -5,23 +5,47 @@ import type {
|
|
|
5
5
|
BlokComponentProp,
|
|
6
6
|
BlokUtilCall,
|
|
7
7
|
} from '../renderer/runtime/types';
|
|
8
|
-
import {defaultBlokView, type BlokView, type SpecComponent} from '../spec/catalogs';
|
|
8
|
+
import {blokViewFor, defaultBlokView, type BlokView, type SpecComponent} from '../spec/catalogs';
|
|
9
|
+
import {TEXT_NODE} from './parse';
|
|
9
10
|
import {valueFitsPort} from '../spec/locals';
|
|
10
|
-
import {LOCAL_ANY,
|
|
11
|
+
import {LOCAL_ANY, localDeclared, resolveLocals, type ResolvedLocal} from './infer';
|
|
12
|
+
import {
|
|
13
|
+
blokCatalog,
|
|
14
|
+
blokHeader,
|
|
15
|
+
content,
|
|
16
|
+
declarationProblem,
|
|
17
|
+
declaredQueries,
|
|
18
|
+
declaredSubscriptions,
|
|
19
|
+
headerProblem,
|
|
20
|
+
isDeclaration,
|
|
21
|
+
iterWithParents,
|
|
22
|
+
LIKE_PROP,
|
|
23
|
+
LOCAL_COMPONENT,
|
|
24
|
+
localName,
|
|
25
|
+
localProblem,
|
|
26
|
+
QUERY_COMPONENT,
|
|
27
|
+
SUBSCRIPTION_COMPONENT,
|
|
28
|
+
VAR_COMPONENT,
|
|
29
|
+
type BlokHeader,
|
|
30
|
+
type DeclaredQuery,
|
|
31
|
+
type DeclaredSubscription,
|
|
32
|
+
} from './declared';
|
|
11
33
|
import {
|
|
12
34
|
argFits,
|
|
13
35
|
finding,
|
|
36
|
+
kindIn,
|
|
14
37
|
loadVocabulary,
|
|
15
38
|
type BlokFinding,
|
|
16
39
|
type BlokKind,
|
|
17
40
|
type BlokVocabulary,
|
|
18
41
|
type DiagnosticFields,
|
|
42
|
+
type VocabKind,
|
|
19
43
|
type VocabRecordField,
|
|
20
44
|
} from '../spec/vocabulary';
|
|
21
45
|
|
|
22
46
|
/**
|
|
23
|
-
* The v2 validator: a blok's tree
|
|
24
|
-
* catalogs that draw it. The port of arkitekt-spec's
|
|
47
|
+
* The v2 validator: a blok's tree (its `<Blok>` header and its declarations),
|
|
48
|
+
* where it is mounted, and the catalogs that draw it. The port of arkitekt-spec's
|
|
25
49
|
* `declare/blok/validate.py` (with `walk.py`), held to the `checked` cases of
|
|
26
50
|
* the corpus (`core/blok/spec/bsx_v2.json`). The server runs the same rules on
|
|
27
51
|
* save; here they mark the source while the author types.
|
|
@@ -32,7 +56,7 @@ import {
|
|
|
32
56
|
*/
|
|
33
57
|
|
|
34
58
|
/* -------------------------------------------------------------------------- */
|
|
35
|
-
/* The scope: the corpus' `
|
|
59
|
+
/* The scope: where a blok is mounted (the corpus' `mount`) */
|
|
36
60
|
/* -------------------------------------------------------------------------- */
|
|
37
61
|
|
|
38
62
|
/** A port match, as the server's `PortMatchInput` spells it (snake_case, nulls allowed). */
|
|
@@ -78,50 +102,75 @@ export type BlokScopeLocalPort = {
|
|
|
78
102
|
};
|
|
79
103
|
|
|
80
104
|
/**
|
|
81
|
-
* A local (vocabulary `locals`)
|
|
82
|
-
* port kind or `ANY`; left out (absent or
|
|
83
|
-
* (`
|
|
105
|
+
* A local (vocabulary `locals`), as its `<local>` node declares it: an arg
|
|
106
|
+
* port plus `persist`. Its kind is a port kind or `ANY`; left out (absent or
|
|
107
|
+
* null), it is inferred from the tree (`resolveLocals`), and a given kind,
|
|
108
|
+
* `ANY` included, is kept.
|
|
84
109
|
*/
|
|
85
110
|
export type BlokScopeLocal = Omit<BlokScopeLocalPort, 'kind'> & {kind?: string | null; persist?: boolean | null};
|
|
86
111
|
|
|
87
112
|
/** A local after inference: its kind always said. */
|
|
88
113
|
export type ResolvedBlokLocal = BlokScopeLocalPort & {persist?: boolean | null};
|
|
89
114
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
115
|
+
/** A class at its variant colons, those inside brackets left alone (`[&>*]:p-2`). */
|
|
116
|
+
const splitClass = (token: string): string[] => {
|
|
117
|
+
const parts: string[] = [];
|
|
118
|
+
let depth = 0;
|
|
119
|
+
let current = '';
|
|
120
|
+
for (const character of token) {
|
|
121
|
+
if (character === '[') depth += 1;
|
|
122
|
+
else if (character === ']') depth = Math.max(0, depth - 1);
|
|
123
|
+
if (character === ':' && depth === 0) {
|
|
124
|
+
parts.push(current);
|
|
125
|
+
current = '';
|
|
126
|
+
} else current += character;
|
|
127
|
+
}
|
|
128
|
+
parts.push(current);
|
|
129
|
+
return parts;
|
|
99
130
|
};
|
|
100
131
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
132
|
+
/** What of the class `token` is outside the portable subset (`the before variant`), or null. */
|
|
133
|
+
export const unportableClass = (token: string, vocabulary: BlokVocabulary): string | null => {
|
|
134
|
+
const parts = splitClass(token);
|
|
135
|
+
const utility = (parts.pop() ?? '').replace(/^[!-]+/, '');
|
|
136
|
+
for (const variant of parts) {
|
|
137
|
+
if (variant.startsWith('[')) return 'an arbitrary variant';
|
|
138
|
+
const name = variant.split('/')[0];
|
|
139
|
+
if (vocabulary.unportableVariants.has(name) || vocabulary.unportableVariants.has(name.split('-[')[0])) return `the ${name} variant`;
|
|
140
|
+
}
|
|
141
|
+
if (utility.startsWith('[')) return 'an arbitrary property';
|
|
142
|
+
if (utility.includes('[')) {
|
|
143
|
+
const prefix = utility.split('-[')[0];
|
|
144
|
+
return vocabulary.arbitraryValues.has(prefix) ? null : `an arbitrary value of ${prefix}`;
|
|
145
|
+
}
|
|
146
|
+
for (const prefix of vocabulary.unportableUtilities) {
|
|
147
|
+
if (utility === prefix || utility.startsWith(`${prefix}-`)) return `the ${prefix} utility`;
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
108
150
|
};
|
|
109
151
|
|
|
110
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Where a blok is mounted: what its mount provides, which its reads and calls
|
|
154
|
+
* resolve against (the spec's `BlokScope`, the corpus' `mount`, the record
|
|
155
|
+
* `arkitekt check --json` hands the editor tooling). What the blok is (its kind
|
|
156
|
+
* and context) and what it owns (its locals, queries and subscriptions) are
|
|
157
|
+
* read off its tree, never from here.
|
|
158
|
+
*/
|
|
111
159
|
export type BlokCheckScope = {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
160
|
+
/** The kinds the mount takes (`app.blok`: agent; an action's `bloks=`: action or assign); empty or absent takes any. */
|
|
161
|
+
kinds?: readonly string[] | null;
|
|
162
|
+
/** What the mount is, for a message (`bloks= of process_slides`). */
|
|
163
|
+
mount?: string | null;
|
|
164
|
+
/**
|
|
165
|
+
* What `self` and `deps.<key>` resolve against; a `self` entry types `self`,
|
|
166
|
+
* which is open without one. Null: not mounted, every agent is taken as
|
|
167
|
+
* written (`deps.<key>`, `Placed`/`Route` keys and `like` are not checked).
|
|
168
|
+
*/
|
|
169
|
+
dependencies: readonly BlokScopeDependency[] | null;
|
|
119
170
|
/** The keys `args.<key>` may read; null reads any. */
|
|
120
171
|
args: readonly string[] | null;
|
|
121
|
-
/** The
|
|
122
|
-
|
|
123
|
-
/** The module (an app's own extras) the blok names, if any. */
|
|
124
|
-
module?: string | null;
|
|
172
|
+
/** The catalog the blok's `<Blok>` names, as the mount saw it; informational (the tree says it). */
|
|
173
|
+
catalog?: string | null;
|
|
125
174
|
/** Per declared query, the shape of its value when its service's schema is known. */
|
|
126
175
|
query_values?: Readonly<Record<string, BlokPortMatch>>;
|
|
127
176
|
/** The assets `self.assets.<name>` may name; null (or absent) names any. */
|
|
@@ -130,38 +179,22 @@ export type BlokCheckScope = {
|
|
|
130
179
|
demo?: {deps?: unknown; args?: unknown; task?: unknown} | null;
|
|
131
180
|
};
|
|
132
181
|
|
|
133
|
-
/** A
|
|
134
|
-
export
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
dependencies: [],
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
subscriptions: [],
|
|
143
|
-
args: null,
|
|
144
|
-
catalogs: [],
|
|
145
|
-
});
|
|
182
|
+
/** A blok checked on its own, mounted nowhere: what an editor checks from the source alone. */
|
|
183
|
+
export const unmountedBlokScope = (): BlokCheckScope => ({kinds: [], dependencies: null, args: null});
|
|
184
|
+
|
|
185
|
+
/** A blok mounted where `kinds` go, with `dependencies` (none by default): every agent it reads must be one of them. */
|
|
186
|
+
export const mountedBlokScope = (
|
|
187
|
+
kinds: readonly string[] = [],
|
|
188
|
+
dependencies: readonly BlokScopeDependency[] = [],
|
|
189
|
+
args: readonly string[] | null = null,
|
|
190
|
+
): BlokCheckScope => ({kinds, dependencies, args});
|
|
146
191
|
|
|
147
|
-
const ACTION_LOGO = 'ACTION_LOGO';
|
|
148
192
|
const LOGO = 'LOGO';
|
|
149
193
|
const SCENE = 'SCENE';
|
|
194
|
+
const PANEL = 'PANEL';
|
|
150
195
|
|
|
151
|
-
/**
|
|
152
|
-
export const
|
|
153
|
-
|
|
154
|
-
/** The root components a blok of ``context`` may start with (`HTML` → `Html`; `SCENE` → `Scene`, `Space`): a blok's root names its context. */
|
|
155
|
-
export const blokRootsOf = (context: string): string[] =>
|
|
156
|
-
Object.entries(loadVocabulary().blokRoots)
|
|
157
|
-
.filter(([, named]) => named === context)
|
|
158
|
-
.map(([root]) => root);
|
|
159
|
-
|
|
160
|
-
/** The root a new blok of ``context`` starts with: the first it may start with (`SCENE` → `Scene`). */
|
|
161
|
-
export const blokRootOf = (context: string): string | null => blokRootsOf(context)[0] ?? null;
|
|
162
|
-
|
|
163
|
-
/** The blok context a root component names (`Space` → `SCENE`), or null when it names none. */
|
|
164
|
-
export const blokContextOf = (component: string): string | null => loadVocabulary().blokRoots[component] ?? null;
|
|
196
|
+
/** A context as a `<Blok context>` spells it (`PANEL` → `panel`). */
|
|
197
|
+
export const spelledContext = (context: string): string => context.toLowerCase();
|
|
165
198
|
|
|
166
199
|
/* -------------------------------------------------------------------------- */
|
|
167
200
|
/* Matches */
|
|
@@ -173,10 +206,10 @@ const DEPENDENCY_KEY_PROPS = new Set(['Placed.dep', 'Route.through']);
|
|
|
173
206
|
/** The kinds that have a run's dependencies: an action's own bloks, for a run and for starting one. */
|
|
174
207
|
const RUN_KINDS: readonly string[] = ['action', 'assign'];
|
|
175
208
|
const ASSIGN_KIND = 'assign';
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
/**
|
|
179
|
-
const
|
|
209
|
+
const ASK_COMPONENT = 'ask';
|
|
210
|
+
const CHROME_NONE = 'none';
|
|
211
|
+
/** The language's elements whose children do not always show: a host part inside one still claims its slot. */
|
|
212
|
+
const CONDITIONAL_COMPONENTS: ReadonlySet<string> = new Set(['if', 'else', 'match', 'case', 'default', 'foreach', 'suspense', 'fallback', 'error']);
|
|
180
213
|
/** The one field of an agent that is not text. */
|
|
181
214
|
const AGENT_CONNECTED = 'connected';
|
|
182
215
|
/** Where an assign blok reads which arguments the caller decided. */
|
|
@@ -288,21 +321,31 @@ export const foreachLet = (node: BlokComponentNode): string | null => {
|
|
|
288
321
|
return node.props?.find(prop => prop.key === FOREACH_LET && prop.declares_value)?.declares_value ?? null;
|
|
289
322
|
};
|
|
290
323
|
|
|
291
|
-
const iterNodes = (node: BlokComponentNode): BlokComponentNode[] => [node, ...(node.children ?? []).flatMap(iterNodes)];
|
|
292
324
|
|
|
293
|
-
/**
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
325
|
+
/** A `<local>` in scope: its node and the port it resolved to. */
|
|
326
|
+
type LocalBinding = {local: true; node: string; name: string; port: ResolvedBlokLocal};
|
|
327
|
+
type Binding = Match | LocalBinding;
|
|
328
|
+
const isLocalBinding = (binding: Binding | undefined): binding is LocalBinding =>
|
|
329
|
+
binding !== null && binding !== undefined && (binding as LocalBinding).local === true;
|
|
330
|
+
|
|
331
|
+
type Scope = ReadonlyMap<string, Binding>;
|
|
332
|
+
|
|
333
|
+
/** What a name in scope is, for `roots.shadow`. */
|
|
334
|
+
const bindingWhat = (name: string, binding: Binding | undefined, into: ReadonlySet<string>): string => {
|
|
335
|
+
if (isLocalBinding(binding)) return `the local ${binding.node}`;
|
|
336
|
+
if (into.has(name)) return "a call's record";
|
|
337
|
+
return 'a let';
|
|
303
338
|
};
|
|
304
339
|
|
|
305
|
-
|
|
340
|
+
const LOCAL_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
341
|
+
const FIELD_PATH = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/;
|
|
342
|
+
|
|
343
|
+
/** The kind of a GraphQL document's first operation: `query` (also for `{ ... }`), `mutation`, `subscription`, `fragment`. */
|
|
344
|
+
export const operationKeyword = (document: string): string => {
|
|
345
|
+
const text = document.replace(/#[^\n]*/g, '').trimStart();
|
|
346
|
+
if (text.startsWith('{')) return 'query';
|
|
347
|
+
return /^[A-Za-z_]+/.exec(text)?.[0] ?? '';
|
|
348
|
+
};
|
|
306
349
|
|
|
307
350
|
/* -------------------------------------------------------------------------- */
|
|
308
351
|
/* The checker */
|
|
@@ -327,7 +370,7 @@ const DIGITS = /^[0-9]+$/;
|
|
|
327
370
|
* - an agent blok has none: ``agent bloks read only `self` ``.
|
|
328
371
|
*/
|
|
329
372
|
export const dependencyHint = (key: string, kind: BlokKind): string => {
|
|
330
|
-
if (kind === 'action' || kind === 'assign'
|
|
373
|
+
if (kind === 'action' || kind === 'assign') return `add a dependency parameter \`${key}\` to the action`;
|
|
331
374
|
if (kind === 'agent') return 'agent bloks read only `self`';
|
|
332
375
|
return `dependencies=[AgentDependencyInput(key="${key}")]`;
|
|
333
376
|
};
|
|
@@ -402,30 +445,39 @@ const argumentWhat = (argument: BlokActionArgument): string => {
|
|
|
402
445
|
class Checker {
|
|
403
446
|
readonly findings: BlokFinding[] = [];
|
|
404
447
|
private readonly vocabulary = loadVocabulary();
|
|
405
|
-
|
|
448
|
+
/** The kind's row in the blok's context (an action's logo reads only `task`). */
|
|
449
|
+
private readonly kind: VocabKind;
|
|
450
|
+
private readonly kindName: BlokKind;
|
|
451
|
+
private readonly context: string;
|
|
452
|
+
private readonly mounted: boolean;
|
|
406
453
|
private readonly dependencies: Map<string, BlokScopeDependency>;
|
|
407
|
-
|
|
408
|
-
private readonly
|
|
409
|
-
private
|
|
454
|
+
/** Per `<local>` node id, its port with its kind resolved. */
|
|
455
|
+
private readonly resolved: ReadonlyMap<string, ResolvedLocal>;
|
|
456
|
+
private queries = new Map<string, DeclaredQuery>();
|
|
457
|
+
private subscriptions = new Map<string, DeclaredSubscription>();
|
|
458
|
+
/** The node ids of the locals a control binds. */
|
|
410
459
|
private readonly boundLocals = new Set<string>();
|
|
411
460
|
private readonly into = new Set<string>();
|
|
412
|
-
private
|
|
461
|
+
private asks = false;
|
|
462
|
+
/** The id of the root that says `chrome="none"`, when it does. */
|
|
463
|
+
private readonly chromeless: string | null;
|
|
413
464
|
private readonly colour: RegExp;
|
|
414
465
|
|
|
415
|
-
readonly
|
|
466
|
+
readonly header: BlokHeader;
|
|
467
|
+
readonly scope: BlokCheckScope;
|
|
416
468
|
readonly view: BlokView | null;
|
|
417
469
|
|
|
418
|
-
constructor(
|
|
419
|
-
|
|
420
|
-
view: BlokView | null,
|
|
421
|
-
) {
|
|
470
|
+
constructor(header: BlokHeader, scope: BlokCheckScope, view: BlokView | null, resolved: ReadonlyMap<string, ResolvedLocal>) {
|
|
471
|
+
this.header = header;
|
|
422
472
|
this.scope = scope;
|
|
423
473
|
this.view = view;
|
|
424
|
-
this.
|
|
425
|
-
this.
|
|
426
|
-
this.
|
|
427
|
-
this.
|
|
428
|
-
this.
|
|
474
|
+
this.kindName = header.kind;
|
|
475
|
+
this.context = header.context;
|
|
476
|
+
this.kind = kindIn(this.vocabulary.kinds[header.kind], header.context);
|
|
477
|
+
this.mounted = scope.dependencies !== null;
|
|
478
|
+
this.dependencies = new Map((scope.dependencies ?? []).map(dependency => [dependency.key, dependency]));
|
|
479
|
+
this.resolved = resolved;
|
|
480
|
+
this.chromeless = header.chrome === CHROME_NONE ? header.node : null;
|
|
429
481
|
this.colour = colourPattern(this.vocabulary);
|
|
430
482
|
}
|
|
431
483
|
|
|
@@ -438,51 +490,136 @@ class Checker {
|
|
|
438
490
|
}
|
|
439
491
|
|
|
440
492
|
private notInKind(nodeId: string | null, path: string, root: string, propKey?: string): void {
|
|
441
|
-
this.add('roots.not_in_kind', nodeId, {path, n: article(this.
|
|
493
|
+
this.add('roots.not_in_kind', nodeId, {path, n: article(this.kindName), kind: this.kindName, root, roots: this.rootsText()}, propKey);
|
|
442
494
|
}
|
|
443
495
|
|
|
444
496
|
/* -- declarations -- */
|
|
445
497
|
|
|
446
498
|
checkDeclarations(tree: BlokComponentNode): void {
|
|
447
|
-
const {vocabulary,
|
|
448
|
-
const
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
this.add('
|
|
457
|
-
}
|
|
458
|
-
if (
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
499
|
+
const {vocabulary, header} = this;
|
|
500
|
+
const kind = this.kindName;
|
|
501
|
+
const row = vocabulary.kinds[kind];
|
|
502
|
+
const contextName = spelledContext(header.context);
|
|
503
|
+
if (!row.contexts.includes(header.context)) {
|
|
504
|
+
this.add('context.kind', tree.id, {n: article(kind), kind, contexts: row.contexts.map(spelledContext).join(', '), context: contextName});
|
|
505
|
+
}
|
|
506
|
+
const kinds = this.scope.kinds ?? [];
|
|
507
|
+
if (kinds.length && !kinds.includes(kind)) {
|
|
508
|
+
this.add('kind.placement', tree.id, {n: article(kind), kind, m: article(kinds[0]), expected: kinds.join(' or '), where: this.scope.mount || 'here'});
|
|
509
|
+
}
|
|
510
|
+
if (header.chrome !== null && !vocabulary.blok.chrome.includes(header.context)) this.add('chrome.context', tree.id, {context: contextName});
|
|
511
|
+
const allowed = vocabulary.blok.content[header.context];
|
|
512
|
+
if (allowed) {
|
|
513
|
+
const drawn = content(tree);
|
|
514
|
+
if (drawn.length !== 1 || !allowed.includes(drawn[0].component)) {
|
|
515
|
+
const found = drawn.map(node => (node.component === TEXT_NODE ? 'text' : `<${node.component}>`)).join(', ') || 'nothing';
|
|
516
|
+
this.add('blok.content', tree.id, {context: contextName, expected: allowed.map(name => `one <${name}>`).join(' or '), found});
|
|
517
|
+
}
|
|
462
518
|
}
|
|
519
|
+
this.checkLocalPositions(tree);
|
|
520
|
+
this.checkQueries(tree);
|
|
463
521
|
for (const [name, sites] of intoSites(tree)) {
|
|
464
522
|
this.into.add(name);
|
|
465
523
|
if (vocabulary.reserved.has(name)) this.add('roots.reserved', sites[0].site, {name});
|
|
466
|
-
if (this.locals.has(name)) this.add('roots.shadow', sites[0].site, {name, first: 'a local', second: `the record of ${sites[0].site}`});
|
|
467
524
|
if (sites.length > 1) this.add('into.twice', sites[1].site, {name, first: sites[0].site, second: sites[1].site});
|
|
468
525
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Each `<local>` reads, comes first among its parent's children, inside an
|
|
530
|
+
* element that takes children, in a kind that has locals; a persisted one
|
|
531
|
+
* inside a keyless foreach is a warning.
|
|
532
|
+
*/
|
|
533
|
+
private checkLocalPositions(tree: BlokComponentNode): void {
|
|
534
|
+
for (const [node, ancestors] of iterWithParents(tree)) {
|
|
535
|
+
const parent = ancestors.length ? ancestors[ancestors.length - 1] : null;
|
|
536
|
+
if (node.component === VAR_COMPONENT && (parent === null || (parent.component !== QUERY_COMPONENT && parent.component !== SUBSCRIPTION_COMPONENT))) {
|
|
537
|
+
this.add('query.declaration', node.id, {component: 'var', problem: 'belongs inside a <query> or <subscription>'});
|
|
538
|
+
}
|
|
539
|
+
if (node.component !== LOCAL_COMPONENT) continue;
|
|
540
|
+
const name = localName(node) ?? '?';
|
|
541
|
+
const problem = localProblem(node);
|
|
542
|
+
if (problem !== null) {
|
|
543
|
+
this.findings.push(problem);
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
546
|
+
if (!this.kind.locals) this.notInKind(node.id, `<local name='${name}'>`, 'locals');
|
|
547
|
+
if (this.vocabulary.reserved.has(name)) this.add('roots.reserved', node.id, {name});
|
|
548
|
+
if (parent === null) {
|
|
549
|
+
this.add('local.position', node.id, {name, problem: "is a blok's root; a blok is a <Blok>"});
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
const siblings = parent.children ?? [];
|
|
553
|
+
const other = siblings.slice(0, siblings.indexOf(node)).find(sibling => sibling.component !== LOCAL_COMPONENT);
|
|
554
|
+
if (other) {
|
|
555
|
+
const shown = other.component === TEXT_NODE ? 'text' : `<${other.component}>`;
|
|
556
|
+
this.add('local.position', node.id, {name, problem: `comes after ${shown} (${other.id}); locals come first among their parent's children`});
|
|
557
|
+
}
|
|
558
|
+
if ([QUERY_COMPONENT, SUBSCRIPTION_COMPONENT, LOCAL_COMPONENT, VAR_COMPONENT].includes(parent.component)) {
|
|
559
|
+
this.add('local.position', node.id, {name, problem: `is inside <${parent.component}>, which declares, and draws nothing`});
|
|
560
|
+
} else if (this.view) {
|
|
561
|
+
const spec = this.view.components.get(parent.component);
|
|
562
|
+
if (spec && !spec.acceptsChildren) this.add('local.position', node.id, {name, problem: `is inside <${parent.component}>, which takes no children`});
|
|
563
|
+
}
|
|
564
|
+
const resolved = this.resolved.get(node.id);
|
|
565
|
+
if (!resolved) continue;
|
|
566
|
+
if (resolved.likeProblem !== null) {
|
|
567
|
+
const like = node.props?.find(prop => prop.key === LIKE_PROP)?.static_value ?? null;
|
|
568
|
+
this.add('local.like', node.id, {name, like, problem: resolved.likeProblem});
|
|
569
|
+
}
|
|
570
|
+
this.checkLocalDefault(node.id, resolved.local);
|
|
571
|
+
if (resolved.local.persist) {
|
|
572
|
+
const loop = [...ancestors].reverse().find(ancestor => ancestor.component === FOREACH);
|
|
573
|
+
if (loop && !(loop.props ?? []).some(prop => prop.key === FOREACH_KEY)) this.add('local.persist_id', node.id, {name});
|
|
479
574
|
}
|
|
480
575
|
}
|
|
481
|
-
|
|
482
|
-
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/** Queries and subscriptions are children of the `<Blok>`, each declared once and readable. */
|
|
579
|
+
private checkQueries(tree: BlokComponentNode): void {
|
|
580
|
+
const first = new Map<string, string>();
|
|
581
|
+
for (const [node, ancestors] of iterWithParents(tree)) {
|
|
582
|
+
if (node.component !== QUERY_COMPONENT && node.component !== SUBSCRIPTION_COMPONENT) continue;
|
|
583
|
+
const named = node.props?.find(prop => prop.key === 'name')?.static_value;
|
|
584
|
+
const name = typeof named === 'string' ? named : '?';
|
|
585
|
+
if (ancestors.length !== 1) {
|
|
586
|
+
const at = ancestors.length ? ancestors[ancestors.length - 1].id : 'the root';
|
|
587
|
+
this.add('query.position', node.id, {component: node.component, name, at});
|
|
588
|
+
}
|
|
589
|
+
const problem = declarationProblem(node);
|
|
590
|
+
if (problem !== null) {
|
|
591
|
+
this.findings.push(problem);
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
const key = `${node.component}\u0000${name}`;
|
|
595
|
+
const seen = first.get(key);
|
|
596
|
+
if (seen !== undefined) this.add('query.duplicate', node.id, {what: node.component, name, first: seen, second: node.id});
|
|
597
|
+
else first.set(key, node.id);
|
|
598
|
+
}
|
|
599
|
+
this.queries = new Map(declaredQueries(tree).map(query => [query.key, query]));
|
|
600
|
+
this.subscriptions = new Map(declaredSubscriptions(tree).map(subscription => [subscription.key, subscription]));
|
|
601
|
+
const declared: Array<[string, DeclaredQuery | DeclaredSubscription]> = [
|
|
602
|
+
...[...this.queries.values()].map(query => ['query', query] as [string, DeclaredQuery]),
|
|
603
|
+
...[...this.subscriptions.values()].map(subscription => ['subscription', subscription] as [string, DeclaredSubscription]),
|
|
604
|
+
];
|
|
605
|
+
for (const [what, each] of declared) {
|
|
606
|
+
const at = `${what === 'query' ? 'queries' : 'subscriptions'}.${each.key}`;
|
|
607
|
+
if (!LOCAL_NAME.test(each.key)) this.add('manifest.name', at, {what, key: each.key});
|
|
608
|
+
if (this.vocabulary.reserved.has(each.key)) this.add('roots.reserved', at, {name: each.key});
|
|
609
|
+
const operation = operationKeyword(each.document);
|
|
610
|
+
if (operation === 'mutation') {
|
|
611
|
+
this.add('query.read_only', at, {kind: what, name: each.key, problem: 'is a mutation: a blok reads, and writes only through a task'});
|
|
612
|
+
} else if (operation !== what) {
|
|
613
|
+
this.add('query.kind', at, {kind: what, name: each.key, operation: operation || 'document without an operation'});
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
for (const query of this.queries.values()) {
|
|
617
|
+
if (query.more != null && !FIELD_PATH.test(query.more)) {
|
|
618
|
+
this.add('query.more', `queries.${query.key}`, {name: query.key, more: query.more, problem: 'is not a field path into its data (positions, images.items)'});
|
|
619
|
+
}
|
|
483
620
|
}
|
|
484
|
-
|
|
485
|
-
|
|
621
|
+
if (this.kindName === 'action' && this.context === LOGO && this.dependencies.size) this.add('manifest.action_logo', this.header.node);
|
|
622
|
+
for (const subscription of this.subscriptions.values()) {
|
|
486
623
|
if (subscription.history != null && !this.queries.has(subscription.history)) {
|
|
487
624
|
this.add('query.history', `subscriptions.${subscription.key}`, {name: subscription.key, history: subscription.history});
|
|
488
625
|
}
|
|
@@ -490,18 +627,17 @@ class Checker {
|
|
|
490
627
|
}
|
|
491
628
|
|
|
492
629
|
/** A local's default fits its port: a number for a number, a list for a list, one of its choices. */
|
|
493
|
-
private checkLocalDefault(local: ResolvedBlokLocal): void {
|
|
630
|
+
private checkLocalDefault(nodeId: string, local: ResolvedBlokLocal): void {
|
|
494
631
|
if (local.kind === LOCAL_ANY) return;
|
|
495
632
|
if (!valueFitsPort(local.default, local)) {
|
|
496
|
-
this.add('local.default',
|
|
633
|
+
this.add('local.default', nodeId, {name: local.key, default: local.default, kind: local.kind});
|
|
497
634
|
}
|
|
498
635
|
}
|
|
499
636
|
|
|
500
637
|
/** The port a path into a local names (the local, or a field of it), or null when its shape does not say (an ANY local). */
|
|
501
|
-
private localPort(path: string): BlokScopeLocalPort | null {
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
let port: BlokScopeLocalPort | null = local !== null && local.kind !== LOCAL_ANY ? local : null;
|
|
638
|
+
private localPort(binding: LocalBinding, path: string): BlokScopeLocalPort | null {
|
|
639
|
+
const rest = path.split('.').slice(1);
|
|
640
|
+
let port: BlokScopeLocalPort | null = binding.port.kind !== LOCAL_ANY ? binding.port : null;
|
|
505
641
|
for (const part of rest) {
|
|
506
642
|
if (port === null) return null;
|
|
507
643
|
const children: readonly BlokScopeLocalPort[] = port.children ?? [];
|
|
@@ -513,21 +649,22 @@ class Checker {
|
|
|
513
649
|
}
|
|
514
650
|
|
|
515
651
|
finish(): void {
|
|
516
|
-
for (const
|
|
517
|
-
if (local.persist && !this.boundLocals.has(
|
|
652
|
+
for (const [nodeId, resolved] of this.resolved) {
|
|
653
|
+
if (resolved.local.persist && !this.boundLocals.has(nodeId)) this.add('local.unused_persist', nodeId, {name: resolved.local.key});
|
|
518
654
|
}
|
|
655
|
+
if (this.chromeless !== null && this.kind.roots.includes('task') && !this.asks) this.add('chrome.no_ask', this.chromeless);
|
|
519
656
|
}
|
|
520
657
|
|
|
521
658
|
/* -- the walk -- */
|
|
522
659
|
|
|
523
660
|
walk(tree: BlokComponentNode): void {
|
|
524
|
-
const scope = new Map<string,
|
|
661
|
+
const scope = new Map<string, Binding>();
|
|
525
662
|
for (const [name, sites] of intoSites(tree)) scope.set(name, this.bindInto(sites[0].call));
|
|
526
663
|
this.walkNode(tree, scope, [], false);
|
|
527
664
|
}
|
|
528
665
|
|
|
529
666
|
private walkNode(node: BlokComponentNode, scope: Scope, ancestors: readonly BlokComponentNode[], inError: boolean): void {
|
|
530
|
-
this.visitComponent(node, ancestors);
|
|
667
|
+
this.visitComponent(node, ancestors, scope);
|
|
531
668
|
const inner = new Map(scope);
|
|
532
669
|
const declared = foreachLet(node);
|
|
533
670
|
if (declared !== null) {
|
|
@@ -540,7 +677,13 @@ class Checker {
|
|
|
540
677
|
this.walkProp(node, prop, propScope, inError);
|
|
541
678
|
}
|
|
542
679
|
const inSlot = inError || (node.component === ERROR_SLOT && ancestors.length > 0 && ancestors[ancestors.length - 1].component === SUSPENSE);
|
|
543
|
-
|
|
680
|
+
// Every local of a node is bound before any of its children is walked, in order: a second local of one name sees the first.
|
|
681
|
+
const children = node.children ?? [];
|
|
682
|
+
for (const child of children) {
|
|
683
|
+
const name = localDeclared(child);
|
|
684
|
+
if (name !== null) inner.set(name, this.bindLocal(name, child, new Map(inner)));
|
|
685
|
+
}
|
|
686
|
+
for (const child of children) this.walkNode(child, inner, [...ancestors, node], inSlot);
|
|
544
687
|
}
|
|
545
688
|
|
|
546
689
|
private walkProp(node: BlokComponentNode, prop: BlokComponentProp, scope: Scope, inError: boolean): void {
|
|
@@ -570,37 +713,45 @@ class Checker {
|
|
|
570
713
|
|
|
571
714
|
/* -- components and props -- */
|
|
572
715
|
|
|
573
|
-
private visitComponent(node: BlokComponentNode, ancestors: readonly BlokComponentNode[]): void {
|
|
716
|
+
private visitComponent(node: BlokComponentNode, ancestors: readonly BlokComponentNode[], scope: Scope): void {
|
|
574
717
|
const spec = this.view?.components.get(node.component);
|
|
575
|
-
if (this.view && !spec
|
|
576
|
-
this.
|
|
718
|
+
if (this.view && !spec) {
|
|
719
|
+
const foreign = this.view.foreign.get(node.component);
|
|
720
|
+
if (foreign !== undefined) {
|
|
721
|
+
this.add('catalog.target', node.id, {component: node.component, catalog: foreign, target: this.view.target ?? this.view.label});
|
|
722
|
+
} else if (this.view.complete) {
|
|
723
|
+
this.add('catalog.unknown_component', node.id, {component: node.component, catalogs: this.view.label});
|
|
724
|
+
}
|
|
577
725
|
}
|
|
578
726
|
if (spec) this.checkCatalog(node, spec, ancestors);
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
this.shadowed.add(node.component);
|
|
582
|
-
this.add('catalog.shadow', node.id, {component: node.component, catalog: shadow.catalog, module: shadow.module, winner: shadow.winner});
|
|
583
|
-
}
|
|
584
|
-
if (TASK_COMPONENTS.has(node.component) && !this.kind.roots.includes('task')) {
|
|
585
|
-
this.notInKind(node.id, `<${node.component}>`, 'task');
|
|
586
|
-
}
|
|
587
|
-
if (ASSIGN_COMPONENTS.has(node.component) && this.scope.kind !== ASSIGN_KIND) {
|
|
588
|
-
this.add('assign.kind', node.id, {what: `<${node.component}>`, n: article(this.scope.kind), kind: this.scope.kind});
|
|
589
|
-
}
|
|
590
|
-
for (const prop of node.props ?? []) this.checkProp(node, prop, spec);
|
|
727
|
+
this.checkHostPart(node, ancestors);
|
|
728
|
+
for (const prop of node.props ?? []) this.checkProp(node, prop, spec, scope);
|
|
591
729
|
}
|
|
592
730
|
|
|
593
731
|
private checkCatalog(node: BlokComponentNode, spec: SpecComponent, ancestors: readonly BlokComponentNode[]): void {
|
|
594
732
|
const view = this.view;
|
|
595
733
|
if (!view) return;
|
|
596
|
-
|
|
734
|
+
const texts = (node.children ?? []).filter(child => child.component === TEXT_NODE);
|
|
735
|
+
const elements = (node.children ?? []).filter(child => child.component !== TEXT_NODE && !isDeclaration(child)).length;
|
|
736
|
+
if (elements && !spec.acceptsChildren) this.add('catalog.children', node.id, {component: node.component});
|
|
737
|
+
if (texts.length) {
|
|
738
|
+
// Text is a child like any other; what takes it is the catalog's to say.
|
|
739
|
+
const textProp = spec.textProp;
|
|
740
|
+
if (textProp === null && !spec.acceptsChildren) {
|
|
741
|
+
this.add('catalog.text', node.id, {component: node.component, detail: 'takes no text'});
|
|
742
|
+
} else if (textProp !== null && (node.props ?? []).some(prop => prop.key === textProp)) {
|
|
743
|
+
this.add('catalog.text', node.id, {component: node.component, detail: `sets ${textProp} as an attribute and as its text`});
|
|
744
|
+
} else if (textProp !== null && !spec.acceptsChildren && (elements || texts.length > 1)) {
|
|
745
|
+
this.add('catalog.text', node.id, {component: node.component, detail: `takes one run of text as its ${textProp}, and no elements beside it`});
|
|
746
|
+
}
|
|
747
|
+
}
|
|
597
748
|
const present = new Set((node.props ?? []).map(prop => prop.key));
|
|
598
749
|
const known = new Set([...spec.props.map(prop => prop.key), WHEN_PROP]);
|
|
599
750
|
const unknown = [...present].filter(key => !known.has(key)).sort();
|
|
600
751
|
if (unknown.length) this.add('catalog.props', node.id, {component: node.component, detail: `has no props [${unknown.map(pythonRepr).join(', ')}]`});
|
|
601
752
|
const missing = spec.props.filter(prop => prop.required && !present.has(prop.key)).map(prop => prop.key).sort();
|
|
602
753
|
if (missing.length) this.add('catalog.props', node.id, {component: node.component, detail: `requires props [${missing.map(pythonRepr).join(', ')}]`});
|
|
603
|
-
let context =
|
|
754
|
+
let context = PANEL;
|
|
604
755
|
for (const ancestor of ancestors) {
|
|
605
756
|
const above = view.components.get(ancestor.component);
|
|
606
757
|
if (above && !above.inheritsContext) context = above.childrenContext ?? above.context;
|
|
@@ -619,20 +770,28 @@ class Checker {
|
|
|
619
770
|
if (forbidden.length) {
|
|
620
771
|
this.add('catalog.placement', node.id, {component: node.component, detail: `must not be inside [${forbidden.map(pythonRepr).join(', ')}]`});
|
|
621
772
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
773
|
+
if (spec.kinds.length && !spec.kinds.includes(this.kindName)) {
|
|
774
|
+
this.add('catalog.kind', node.id, {component: node.component, kinds: spec.kinds.join(' and '), n: article(this.kindName), kind: this.kindName});
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* What the language itself says of the host's parts, whatever catalog draws
|
|
780
|
+
* them: a part placed anywhere claims its slot (a blok without chrome
|
|
781
|
+
* leaves the asks to itself: `finish`).
|
|
782
|
+
*/
|
|
783
|
+
private checkHostPart(node: BlokComponentNode, ancestors: readonly BlokComponentNode[]): void {
|
|
784
|
+
if (node.component === ASK_COMPONENT) this.asks = true;
|
|
785
|
+
if (this.vocabulary.hostParts.includes(node.component)) {
|
|
786
|
+
const inside = [...ancestors].reverse().find(ancestor => CONDITIONAL_COMPONENTS.has(ancestor.component));
|
|
787
|
+
if (inside) this.add('part.conditional', node.id, {component: node.component, inside: inside.component});
|
|
627
788
|
}
|
|
628
789
|
}
|
|
629
790
|
|
|
630
791
|
/** A ``Placed dep`` or ``Route through`` names dependencies of the blok, written out as keys. */
|
|
631
792
|
private checkDependencyKeys(node: BlokComponentNode, prop: BlokComponentProp): void {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
793
|
+
// catalog.kind says it: a Space and its parts belong to an action's own blok. Unmounted, its keys are taken as written.
|
|
794
|
+
if (!RUN_KINDS.includes(this.kindName) || !this.mounted) return;
|
|
636
795
|
const path = `${node.component}.${prop.key}`;
|
|
637
796
|
const value = prop.static_value;
|
|
638
797
|
const keys = typeof value === 'string' ? [value] : Array.isArray(value) ? value.filter((key): key is string => typeof key === 'string') : [];
|
|
@@ -641,14 +800,14 @@ class Checker {
|
|
|
641
800
|
this.add(
|
|
642
801
|
'deps.unknown',
|
|
643
802
|
node.id,
|
|
644
|
-
{path, key, keys: [...this.dependencies.keys()].sort().join(', ') || 'none', hint: dependencyHint(key, this.
|
|
803
|
+
{path, key, keys: [...this.dependencies.keys()].sort().join(', ') || 'none', hint: dependencyHint(key, this.kindName)},
|
|
645
804
|
prop.key,
|
|
646
805
|
);
|
|
647
806
|
}
|
|
648
807
|
}
|
|
649
808
|
}
|
|
650
809
|
|
|
651
|
-
private checkProp(node: BlokComponentNode, prop: BlokComponentProp, spec: SpecComponent | undefined): void {
|
|
810
|
+
private checkProp(node: BlokComponentNode, prop: BlokComponentProp, spec: SpecComponent | undefined, scope: Scope): void {
|
|
652
811
|
const {vocabulary} = this;
|
|
653
812
|
const propSpec = spec?.props.find(candidate => candidate.key === prop.key);
|
|
654
813
|
const holds = isCallbackValue(prop);
|
|
@@ -678,7 +837,7 @@ class Checker {
|
|
|
678
837
|
}
|
|
679
838
|
// `task.answer(...)`, `task.cancel()` and their kin act on the task the blok is about.
|
|
680
839
|
const effect = prop.util_call?.operation;
|
|
681
|
-
if (effect
|
|
840
|
+
if (effect !== undefined && vocabulary.functions.get(effect)?.taskOperation && !this.kind.roots.includes('task')) {
|
|
682
841
|
this.notInKind(node.id, effect, 'task', prop.key);
|
|
683
842
|
}
|
|
684
843
|
if (prop.key === BIND_PROP) {
|
|
@@ -687,28 +846,25 @@ class Checker {
|
|
|
687
846
|
this.add('local.bind', node.id, {what: what(prop)}, prop.key);
|
|
688
847
|
} else {
|
|
689
848
|
const root = path.split('.')[0];
|
|
690
|
-
|
|
849
|
+
const binding = scope.get(root);
|
|
850
|
+
if (!isLocalBinding(binding)) this.add('local.unknown', node.id, {path, root}, prop.key);
|
|
691
851
|
else {
|
|
692
|
-
this.boundLocals.add(
|
|
693
|
-
if (propSpec) this.checkBindKind(node, propSpec.kind, path);
|
|
852
|
+
this.boundLocals.add(binding.node);
|
|
853
|
+
if (propSpec) this.checkBindKind(node, propSpec.kind, binding, path);
|
|
694
854
|
}
|
|
695
855
|
}
|
|
696
856
|
}
|
|
697
|
-
if (prop.util_call?.operation === START_EFFECT && this.
|
|
698
|
-
this.add('assign.kind', node.id, {what: 'assign.start()', n: article(this.
|
|
857
|
+
if (prop.util_call?.operation === START_EFFECT && this.kindName !== ASSIGN_KIND) {
|
|
858
|
+
this.add('assign.kind', node.id, {what: 'assign.start()', n: article(this.kindName), kind: this.kindName}, prop.key);
|
|
699
859
|
}
|
|
700
860
|
if (DEPENDENCY_KEY_PROPS.has(`${node.component}.${prop.key}`)) this.checkDependencyKeys(node, prop);
|
|
701
|
-
if (node.component === 'Space' && prop.key === 'room' && !RUN_KINDS.includes(this.scope.kind)) {
|
|
702
|
-
// A Space places the run's dependencies: only an action's own blok (for a run, or for starting one) has them.
|
|
703
|
-
this.add('space.kind', node.id, {component: node.component, n: article(this.scope.kind), kind: this.scope.kind}, prop.key);
|
|
704
|
-
}
|
|
705
861
|
if (node.component === TOAST_COMPONENT && prop.key === TOAST_TASK_PROP) {
|
|
706
862
|
const path = prop.dynamic_value?.path ?? null;
|
|
707
863
|
if (path === null || (path !== 'task' && !this.into.has(path))) this.add('toast.task', node.id, {what: path ?? what(prop)}, prop.key);
|
|
708
864
|
}
|
|
709
865
|
if (typeof prop.static_value === 'string') {
|
|
710
866
|
if (prop.key === CLASS_NAME) this.checkClasses(prop.static_value, node.id, prop.key);
|
|
711
|
-
if (
|
|
867
|
+
if (this.context === LOGO && vocabulary.theme.logoPaintProps.includes(prop.key)) this.checkPaint(node, prop.key, prop.static_value);
|
|
712
868
|
if (spec?.context === SCENE && vocabulary.theme.scenePaintProps.includes(prop.key)) this.checkSceneColour(node, prop.key, prop.static_value);
|
|
713
869
|
}
|
|
714
870
|
if (prop.key === CLASS_NAME && prop.util_call) {
|
|
@@ -717,9 +873,9 @@ class Checker {
|
|
|
717
873
|
}
|
|
718
874
|
|
|
719
875
|
/** The local a control writes is of a kind the control writes (`Slider`: FLOAT or INT). */
|
|
720
|
-
private checkBindKind(node: BlokComponentNode, propKind: string, path: string): void {
|
|
876
|
+
private checkBindKind(node: BlokComponentNode, propKind: string, binding: LocalBinding, path: string): void {
|
|
721
877
|
const allowed = this.vocabulary.locals.bindKinds[propKind];
|
|
722
|
-
const port = this.localPort(path);
|
|
878
|
+
const port = this.localPort(binding, path);
|
|
723
879
|
if (!allowed || port === null) return;
|
|
724
880
|
if (!allowed.includes(port.kind)) {
|
|
725
881
|
this.add(
|
|
@@ -749,7 +905,11 @@ class Checker {
|
|
|
749
905
|
{token, suggestion: `${arbitrary.groups.utility}-<role> (${this.vocabulary.theme.colourRoles.slice(0, 6).join(', ')}, ...)`},
|
|
750
906
|
propKey,
|
|
751
907
|
);
|
|
908
|
+
continue;
|
|
752
909
|
}
|
|
910
|
+
// A colour that is no role is told as that; anything else outside the portable subset as this.
|
|
911
|
+
const unportable = unportableClass(token, this.vocabulary);
|
|
912
|
+
if (unportable !== null) this.add('class.not_portable', owner, {token, what: unportable}, propKey);
|
|
753
913
|
}
|
|
754
914
|
}
|
|
755
915
|
|
|
@@ -782,11 +942,11 @@ class Checker {
|
|
|
782
942
|
}
|
|
783
943
|
const dependency = this.dependencies.get(call.dependency);
|
|
784
944
|
if (!dependency) {
|
|
785
|
-
if (call.dependency !== 'self') {
|
|
945
|
+
if (call.dependency !== 'self' && this.mounted) {
|
|
786
946
|
this.add(
|
|
787
947
|
'deps.unknown',
|
|
788
948
|
where.node.id,
|
|
789
|
-
{path: owner, key: call.dependency, keys: [...this.dependencies.keys()].sort().join(', ') || 'none', hint: dependencyHint(call.dependency, this.
|
|
949
|
+
{path: owner, key: call.dependency, keys: [...this.dependencies.keys()].sort().join(', ') || 'none', hint: dependencyHint(call.dependency, this.kindName)},
|
|
790
950
|
where.key,
|
|
791
951
|
);
|
|
792
952
|
}
|
|
@@ -814,9 +974,9 @@ class Checker {
|
|
|
814
974
|
const path = argument.value_path;
|
|
815
975
|
const match = ports.get(argument.key ?? '');
|
|
816
976
|
if (path == null || !match || match.kind == null) continue;
|
|
817
|
-
const
|
|
818
|
-
if (
|
|
819
|
-
const port = this.localPort(path);
|
|
977
|
+
const binding = scope.get(path.split('.')[0]);
|
|
978
|
+
if (!isLocalBinding(binding)) continue;
|
|
979
|
+
const port = this.localPort(binding, path);
|
|
820
980
|
if (port === null) continue;
|
|
821
981
|
const target = {kind: match.kind, identifier: match.identifier ?? null};
|
|
822
982
|
if (!argFits(port, target)) {
|
|
@@ -882,7 +1042,11 @@ class Checker {
|
|
|
882
1042
|
if (call.operation === FETCH_MORE_FUNCTION && query.more == null) this.add('query.fetch_more', where.node.id, {path, name}, where.key);
|
|
883
1043
|
}
|
|
884
1044
|
|
|
885
|
-
private bindLet(name: string, items: BlokComponentProp | null, where: Where, scope: Scope):
|
|
1045
|
+
private bindLet(name: string, items: BlokComponentProp | null, where: Where, scope: Scope): Binding {
|
|
1046
|
+
if (this.vocabulary.reserved.has(name)) this.add('roots.reserved', where.node.id, {name});
|
|
1047
|
+
else if (scope.has(name)) {
|
|
1048
|
+
this.add('roots.shadow', where.node.id, {name, first: bindingWhat(name, scope.get(name), this.into), second: `the let of <foreach> (${where.node.id})`});
|
|
1049
|
+
}
|
|
886
1050
|
const keyed = (where.node.props ?? []).some(prop => prop.key === FOREACH_KEY);
|
|
887
1051
|
const literal = items?.static_value;
|
|
888
1052
|
if (!keyed && Array.isArray(literal) && literal.some(item => typeof item === 'object' && item !== null)) {
|
|
@@ -905,6 +1069,15 @@ class Checker {
|
|
|
905
1069
|
return openMatch(name);
|
|
906
1070
|
}
|
|
907
1071
|
|
|
1072
|
+
private bindLocal(name: string, node: BlokComponentNode, scope: Scope): Binding {
|
|
1073
|
+
if (scope.has(name) && !this.vocabulary.reserved.has(name)) {
|
|
1074
|
+
this.add('roots.shadow', node.id, {name, first: bindingWhat(name, scope.get(name), this.into), second: `the local ${node.id}`});
|
|
1075
|
+
}
|
|
1076
|
+
const resolved = this.resolved.get(node.id);
|
|
1077
|
+
if (!resolved) return openMatch(name);
|
|
1078
|
+
return {local: true, node: node.id, name, port: resolved.local};
|
|
1079
|
+
}
|
|
1080
|
+
|
|
908
1081
|
private bindInto(call: BlokAgentCall): Match {
|
|
909
1082
|
const dependency = this.dependencies.get(call.dependency);
|
|
910
1083
|
const action = actionKeyFor(call);
|
|
@@ -931,13 +1104,14 @@ class Checker {
|
|
|
931
1104
|
const [root, ...rest] = parts;
|
|
932
1105
|
const report = (code: string, fields: DiagnosticFields) => this.add(code, nodeId, fields, propKey);
|
|
933
1106
|
if (scope.has(root)) {
|
|
1107
|
+
const binding = scope.get(root) ?? null;
|
|
1108
|
+
if (isLocalBinding(binding)) {
|
|
1109
|
+
const local = binding.port;
|
|
1110
|
+
if (local.kind === LOCAL_ANY || OPAQUE_KINDS.has(local.kind)) return openMatch(root);
|
|
1111
|
+
return this.descend({...portMatch(local), key: root}, rest, path, nodeId, propKey);
|
|
1112
|
+
}
|
|
934
1113
|
if (this.into.has(root)) this.checkReturns(path, rest, nodeId, propKey);
|
|
935
|
-
return this.descend(
|
|
936
|
-
}
|
|
937
|
-
const local = this.locals.get(root);
|
|
938
|
-
if (local) {
|
|
939
|
-
if (local.kind === LOCAL_ANY || OPAQUE_KINDS.has(local.kind)) return openMatch(root);
|
|
940
|
-
return this.descend({...portMatch(local), key: root}, rest, path, nodeId, propKey);
|
|
1114
|
+
return this.descend(binding, rest, path, nodeId, propKey);
|
|
941
1115
|
}
|
|
942
1116
|
if (root === 'event') {
|
|
943
1117
|
if (!where || !where.callback) {
|
|
@@ -975,7 +1149,8 @@ class Checker {
|
|
|
975
1149
|
}
|
|
976
1150
|
const dependency = this.dependencies.get(rest[0]);
|
|
977
1151
|
if (!dependency) {
|
|
978
|
-
|
|
1152
|
+
if (!this.mounted) return openMatch(path);
|
|
1153
|
+
report('deps.unknown', {path, key: rest[0], keys: [...this.dependencies.keys()].sort().join(', ') || 'none', hint: dependencyHint(rest[0], this.kindName)});
|
|
979
1154
|
return null;
|
|
980
1155
|
}
|
|
981
1156
|
return this.agent(dependency, rest[0], rest.slice(1), path, nodeId, propKey);
|
|
@@ -1211,15 +1386,33 @@ export const checkLogo = (tree: BlokComponentNode, demo?: BlokCheckScope['demo']
|
|
|
1211
1386
|
};
|
|
1212
1387
|
|
|
1213
1388
|
/**
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
1216
|
-
* and
|
|
1389
|
+
* The view a blok is checked with when none is given: that of the catalog its
|
|
1390
|
+
* `<Blok catalog>` names when it is known here, the app's own when it names
|
|
1391
|
+
* none, and an incomplete base view (nothing reported unknown) otherwise.
|
|
1392
|
+
*/
|
|
1393
|
+
export const viewForTree = (tree: BlokComponentNode): BlokView => {
|
|
1394
|
+
const catalog = blokCatalog(tree);
|
|
1395
|
+
return catalog === null ? defaultBlokView() : blokViewFor(catalog);
|
|
1396
|
+
};
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* Every finding of `tree` mounted as `scope` says (unmounted by default),
|
|
1400
|
+
* against `view`: errors and warnings, in tree order. A root that is no
|
|
1401
|
+
* readable `<Blok>` is the one finding. `view` defaults to that of the catalog
|
|
1402
|
+
* the blok names (`viewForTree`); `null` skips every catalog rule.
|
|
1217
1403
|
*/
|
|
1218
|
-
export const checkBlokTree = (
|
|
1219
|
-
|
|
1404
|
+
export const checkBlokTree = (
|
|
1405
|
+
tree: BlokComponentNode,
|
|
1406
|
+
scope: BlokCheckScope = unmountedBlokScope(),
|
|
1407
|
+
view: BlokView | null = viewForTree(tree),
|
|
1408
|
+
): BlokFinding[] => {
|
|
1409
|
+
const problem = headerProblem(tree);
|
|
1410
|
+
if (problem !== null) return [problem];
|
|
1411
|
+
const header = blokHeader(tree) as BlokHeader;
|
|
1412
|
+
const checker = new Checker(header, scope, view, resolveLocals(tree, scope.dependencies, view));
|
|
1220
1413
|
checker.checkDeclarations(tree);
|
|
1221
1414
|
checker.walk(tree);
|
|
1222
|
-
if (
|
|
1415
|
+
if (header.context === LOGO) checker.findings.push(...checkLogo(tree, scope.demo));
|
|
1223
1416
|
checker.finish();
|
|
1224
1417
|
return checker.findings;
|
|
1225
1418
|
};
|