@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
|
@@ -1,28 +1,60 @@
|
|
|
1
|
-
import {readFileSync} from 'node:fs';
|
|
2
1
|
import {describe, expect, it} from 'vitest';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import {controlBlokComponents} from '../renderer/bloks/control';
|
|
3
|
+
import {BASE_CATALOG_REF, describeBlokContract, type SpecComponentJson} from '../renderer/runtime';
|
|
4
|
+
import baseCatalogJson from '../spec/catalogs/base@4.json';
|
|
5
|
+
import {baseFamilies} from './index';
|
|
5
6
|
import {parts} from './parts';
|
|
6
|
-
import baseCatalogJson from '../spec/catalogs/base@2.json';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/** What the spec adds to an entry beside what its contract says: where it is listed, and what the spec alone knows of it. */
|
|
9
|
+
const SPEC_OWNED = ['group', 'kinds', 'touch', 'since', 'service'] as const;
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
type BaseEntry = SpecComponentJson & {group: string};
|
|
12
|
+
|
|
13
|
+
const shipped = new Map((baseCatalogJson.components as unknown as BaseEntry[]).map(component => [component.name, component]));
|
|
14
|
+
|
|
15
|
+
const asContract = (entry: BaseEntry): SpecComponentJson =>
|
|
16
|
+
Object.fromEntries(Object.entries(entry).filter(([key]) => !(SPEC_OWNED as readonly string[]).includes(key))) as SpecComponentJson;
|
|
17
|
+
|
|
18
|
+
describe('the families of the base catalog', () => {
|
|
19
|
+
it('are what the spec\'s base catalog says, component for component', () => {
|
|
20
|
+
for (const family of baseFamilies) {
|
|
21
|
+
expect(family.partOf, family.name).toBe(BASE_CATALOG_REF);
|
|
22
|
+
for (const described of describeBlokContract(family).components) {
|
|
23
|
+
const entry = shipped.get(described.name);
|
|
24
|
+
expect(entry, `<${described.name}> is not in the base catalog: rebuild it from \`pnpm spec:export\``).toBeDefined();
|
|
25
|
+
if (!entry) continue;
|
|
26
|
+
expect(entry.group, described.name).toBe(family.name);
|
|
27
|
+
expect(asContract(entry), described.name).toEqual(described);
|
|
28
|
+
}
|
|
14
29
|
}
|
|
15
30
|
});
|
|
16
31
|
|
|
17
|
-
it('hold each component once, and never one
|
|
18
|
-
const
|
|
19
|
-
const names =
|
|
32
|
+
it('hold each component once, and never one the renderer draws itself', () => {
|
|
33
|
+
const own = new Set(controlBlokComponents.map(component => component.name));
|
|
34
|
+
const names = baseFamilies.flatMap(family => Object.keys(family.components));
|
|
20
35
|
expect(names.filter((name, index) => names.indexOf(name) !== index)).toEqual([]);
|
|
21
|
-
expect(names.filter(name =>
|
|
36
|
+
expect(names.filter(name => own.has(name))).toEqual([]);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('are, with what the renderer draws itself, the whole base catalog', () => {
|
|
40
|
+
const drawn = new Set([...baseFamilies.flatMap(family => Object.keys(family.components)), ...controlBlokComponents.map(component => component.name)]);
|
|
41
|
+
expect([...shipped.keys()].filter(name => !drawn.has(name))).toEqual([]);
|
|
42
|
+
expect([...drawn].filter(name => !shipped.has(name))).toEqual([]);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('take, where the renderer draws a component itself, the props the base catalog lists', () => {
|
|
46
|
+
for (const component of controlBlokComponents) {
|
|
47
|
+
const entry = shipped.get(component.name);
|
|
48
|
+
expect(entry, component.name).toBeDefined();
|
|
49
|
+
expect(entry?.group === 'language' || entry?.group === 'run', component.name).toBe(true);
|
|
50
|
+
// `children` is a slot where a component takes children; a `<local>`'s is a prop (its child ports).
|
|
51
|
+
const props = Object.keys(component.schema.shape).filter(key => key !== 'children' || !component.acceptsChildren).sort();
|
|
52
|
+
expect(props, component.name).toEqual((entry?.props ?? []).map(prop => prop.key).sort());
|
|
53
|
+
}
|
|
22
54
|
});
|
|
23
55
|
|
|
24
56
|
it('use every contract the package defines', () => {
|
|
25
|
-
const used = new Set(
|
|
57
|
+
const used = new Set(baseFamilies.flatMap(family => Object.keys(family.components)));
|
|
26
58
|
expect(Object.keys(parts).filter(name => !used.has(name))).toEqual([]);
|
|
27
59
|
});
|
|
28
60
|
});
|
package/src/catalogs/html.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
1
|
+
import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
2
2
|
import {parts} from './parts';
|
|
3
3
|
|
|
4
|
-
/** `html
|
|
4
|
+
/** The `html` family of the base catalog. */
|
|
5
5
|
export const htmlCatalog = defineBlokCatalog({
|
|
6
6
|
name: "html",
|
|
7
|
-
|
|
7
|
+
partOf: BASE_CATALOG_REF,
|
|
8
8
|
description: "Plain containers that translate directly to React Native: div (View), p and span (Text).",
|
|
9
9
|
components: {
|
|
10
10
|
div: parts.div,
|
package/src/catalogs/index.ts
CHANGED
|
@@ -8,5 +8,9 @@ import {uiCatalog} from './ui';
|
|
|
8
8
|
export {htmlCatalog, logoCatalog, sceneCatalog, shadcnCatalog, structureCatalog, uiCatalog};
|
|
9
9
|
export * from './props';
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The families of the base catalog this package holds contracts for: every
|
|
13
|
+
* component of it that is not the language's own (`renderer/bloks/control`).
|
|
14
|
+
* The spec's `catalogs/base@4.json` is what they say (`catalogs.test.ts`).
|
|
15
|
+
*/
|
|
16
|
+
export const baseFamilies = [uiCatalog, htmlCatalog, logoCatalog, sceneCatalog, structureCatalog, shadcnCatalog] as const;
|
package/src/catalogs/logo.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
1
|
+
import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
2
2
|
import {parts} from './parts';
|
|
3
3
|
|
|
4
|
-
/** `logo
|
|
4
|
+
/** The `logo` family of the base catalog. */
|
|
5
5
|
export const logoCatalog = defineBlokCatalog({
|
|
6
6
|
name: "logo",
|
|
7
|
-
|
|
7
|
+
partOf: BASE_CATALOG_REF,
|
|
8
8
|
description: "SVG drawing for logos and action logos; the palette is restricted to the logo pens.",
|
|
9
9
|
components: {
|
|
10
|
-
ActionLogo: parts.ActionLogo,
|
|
11
|
-
AgentLogo: parts.AgentLogo,
|
|
12
10
|
Circle: parts.Circle,
|
|
13
11
|
ClipPath: parts.ClipPath,
|
|
14
12
|
Defs: parts.Defs,
|
|
@@ -16,6 +14,7 @@ export const logoCatalog = defineBlokCatalog({
|
|
|
16
14
|
G: parts.G,
|
|
17
15
|
Line: parts.Line,
|
|
18
16
|
LinearGradient: parts.LinearGradient,
|
|
17
|
+
Logo: parts.Logo,
|
|
19
18
|
Path: parts.Path,
|
|
20
19
|
Polygon: parts.Polygon,
|
|
21
20
|
Polyline: parts.Polyline,
|
|
@@ -3,7 +3,7 @@ import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
|
3
3
|
import {BlokPropSchemas} from '../../renderer/runtime/schemas';
|
|
4
4
|
import {actionProp, boolSchema, classNameSchema, contentSchema, layoutFields, textFields} from '../props';
|
|
5
5
|
|
|
6
|
-
/** ui
|
|
6
|
+
/** the ui family's links and media: `Link`, `Image` and `Code`. */
|
|
7
7
|
|
|
8
8
|
export const htmlContracts = {
|
|
9
9
|
Link: {
|
|
@@ -3,7 +3,7 @@ import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
|
3
3
|
import {classNameSchema, numberSchema} from '../props';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* The icons a blok payload may name, and `Icon` (ui
|
|
6
|
+
* The icons a blok payload may name, and `Icon` (the ui family).
|
|
7
7
|
*
|
|
8
8
|
* The names are spelled out here so the contract carries no icon set: the
|
|
9
9
|
* renderer's `BLOK_ICONS` map is typed against this tuple, so a name without a
|
|
@@ -152,6 +152,17 @@ export const layoutContracts = {
|
|
|
152
152
|
})
|
|
153
153
|
.describe('A scrollable region with styled scrollbars.'),
|
|
154
154
|
},
|
|
155
|
+
List: {
|
|
156
|
+
schema: z
|
|
157
|
+
.object({
|
|
158
|
+
children: childListSchema,
|
|
159
|
+
className: classNameSchema,
|
|
160
|
+
height: sizeSchema.describe('CSS height of the list; it scrolls inside it. Fills its parent when left out.'),
|
|
161
|
+
})
|
|
162
|
+
.describe(
|
|
163
|
+
'A long list: a `<foreach>` placed directly inside it is drawn row by row as it scrolls into view, so thousands of items cost what a screenful does. Anything else inside it is drawn as a Column would.',
|
|
164
|
+
),
|
|
165
|
+
},
|
|
155
166
|
Resizable: {
|
|
156
167
|
schema: z
|
|
157
168
|
.object({
|
|
@@ -5,14 +5,14 @@ import {loadVocabulary} from '../../spec/vocabulary';
|
|
|
5
5
|
import {actionProp, describedString} from '../props';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* The `logo
|
|
9
|
-
*
|
|
8
|
+
* The `logo` family of the blok language: the `Logo` drawing and the classic
|
|
9
|
+
* SVG elements as components.
|
|
10
10
|
*
|
|
11
|
-
* A
|
|
12
|
-
* `Path` or a `Circle` is only ever placed inside one.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* A `Logo` sits in a panel like `Scene` does and opens the `logo` context, so
|
|
12
|
+
* a `Path` or a `Circle` is only ever placed inside one. It is the one element
|
|
13
|
+
* of a logo blok (`<Blok kind="agent" context="logo"><Logo>`); an action's
|
|
14
|
+
* logo is `<Blok kind="action" context="logo">` and reads only `task`, the
|
|
15
|
+
* viewer's last task of the action. Any panel may draw a `Logo` too.
|
|
16
16
|
*
|
|
17
17
|
* A logo paints with the viewer's pens only (vocabulary `theme.logo_pens`:
|
|
18
18
|
* `ink`, `brand`, ..., the status roles `success`, `warning`, `info`), drawn
|
|
@@ -39,11 +39,10 @@ export const LOGO_ANIMATIONS = ['spin', 'pulse', 'float', 'draw', 'march', 'blin
|
|
|
39
39
|
const length = (description: string) =>
|
|
40
40
|
z.union([z.number(), z.string()]).optional().describe(description);
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
export const
|
|
44
|
-
export const LOGO_ROOTS = [AGENT_LOGO_ROOT, ACTION_LOGO_ROOT];
|
|
42
|
+
/** A logo's drawing: the one element of a logo blok. */
|
|
43
|
+
export const LOGO_ROOT = 'Logo';
|
|
45
44
|
|
|
46
|
-
const IN_SVG: BlokComponentPlacement = {context: 'logo', downstreamOf:
|
|
45
|
+
const IN_SVG: BlokComponentPlacement = {context: 'logo', downstreamOf: [LOGO_ROOT]};
|
|
47
46
|
|
|
48
47
|
/* -------------------------------------------------------------------------- */
|
|
49
48
|
/* Presentation: what every shape and group may set */
|
|
@@ -143,7 +142,7 @@ const rootSchema = (description: string) =>
|
|
|
143
142
|
/** A drawing's root: an `<svg>` whose shapes paint with the pens. */
|
|
144
143
|
const logoRoot = (description: string) => ({
|
|
145
144
|
acceptsChildren: true,
|
|
146
|
-
placement: {childrenContext: 'logo', notDownstreamOf:
|
|
145
|
+
placement: {childrenContext: 'logo', notDownstreamOf: [LOGO_ROOT]} satisfies BlokComponentPlacement,
|
|
147
146
|
schema: rootSchema(description),
|
|
148
147
|
});
|
|
149
148
|
|
|
@@ -156,13 +155,10 @@ const gradientUnits = z
|
|
|
156
155
|
.optional()
|
|
157
156
|
.describe('Whether the coordinates are fractions of the shape (the default) or user units.');
|
|
158
157
|
|
|
159
|
-
/** The `logo
|
|
158
|
+
/** The `logo` family: the root, seven shapes, text, and what shapes reference. */
|
|
160
159
|
export const logoContracts = {
|
|
161
|
-
[
|
|
162
|
-
"
|
|
163
|
-
),
|
|
164
|
-
[ACTION_LOGO_ROOT]: logoRoot(
|
|
165
|
-
"The root of an action's logo: a drawing in the viewer's pens that reads task (the viewer's last task of the action, idle until they run it). Its children are SVG shapes.",
|
|
160
|
+
[LOGO_ROOT]: logoRoot(
|
|
161
|
+
"A logo's drawing, the one element of a logo blok: an SVG in the viewer's pens (an action's paints with the pens only). Its children are SVG shapes.",
|
|
166
162
|
),
|
|
167
163
|
Path: shape('An SVG path.', shapeGeometry.Path),
|
|
168
164
|
Circle: shape('An SVG circle.', shapeGeometry.Circle),
|
|
@@ -4,7 +4,7 @@ import {describedString} from '../props';
|
|
|
4
4
|
import {sceneSchema} from './scene';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* The components that place an action's dependencies in 3D (scene
|
|
7
|
+
* The components that place an action's dependencies in 3D (the scene family). `Space`
|
|
8
8
|
* is a scene whose layout is shared: a room the whole organization arranges,
|
|
9
9
|
* found again by its `room` (not `id`: that is every node's own explicit id). `Placed` draws the agent a dependency is bound to
|
|
10
10
|
* with that agent's own scene blok, where the room keeps it, and `Route` draws
|
|
@@ -19,12 +19,6 @@ import {actionProp, bindSchema, describedString} from '../props';
|
|
|
19
19
|
|
|
20
20
|
export const sceneSchema = z
|
|
21
21
|
.object({
|
|
22
|
-
chrome: z
|
|
23
|
-
.enum(['auto', 'none'])
|
|
24
|
-
.optional()
|
|
25
|
-
.describe(
|
|
26
|
-
"What the host draws around the blok of its own: `auto` (the default) adds what the blok does not place (the time slider, the open ask, the rest of the argument form, its buttons); `none` adds nothing, the blok places what it wants.",
|
|
27
|
-
),
|
|
28
22
|
camera: z
|
|
29
23
|
.enum(['iso', 'front', 'side', 'top'])
|
|
30
24
|
.optional()
|
|
@@ -292,7 +286,7 @@ export const sceneContracts = {
|
|
|
292
286
|
OnClick: {placement: IN_MODEL_OR_AT, schema: onClickSchema},
|
|
293
287
|
Popout: {
|
|
294
288
|
acceptsChildren: true,
|
|
295
|
-
placement: {...IN_MODEL_OR_AT, childrenContext: '
|
|
289
|
+
placement: {...IN_MODEL_OR_AT, childrenContext: 'panel'},
|
|
296
290
|
schema: popoutSchema,
|
|
297
291
|
},
|
|
298
292
|
} satisfies BlokComponentContracts;
|
|
@@ -4,9 +4,9 @@ import {BlokPropSchemas} from '../../renderer/runtime/schemas';
|
|
|
4
4
|
import {actionProp, bindSchema, boolSchema, classNameSchema, disabledSchema, sizeSchema, structureValueSchema} from '../props';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* structure
|
|
7
|
+
* the structure family: bloks over other modules' objects, by structure identifier. The
|
|
8
8
|
* contract only: drawing one needs the app's smart system (its option sources,
|
|
9
|
-
* displays and viewers), so every app that claims structure
|
|
9
|
+
* displays and viewers), so every app that claims the structure family draws it itself.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
const emptyTextSchema = BlokPropSchemas.DynamicString.optional().describe(
|
|
@@ -2,7 +2,7 @@ import * as z from 'zod';
|
|
|
2
2
|
import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
3
3
|
import {BlokPropSchemas} from '../../renderer/runtime/schemas';
|
|
4
4
|
|
|
5
|
-
/** `<Toast task={move}>` (ui
|
|
5
|
+
/** `<Toast task={move}>` (the ui family) and its outcome slots `done`, `failed`, `cancelled`. */
|
|
6
6
|
|
|
7
7
|
const toastSchema = z
|
|
8
8
|
.object({
|
|
@@ -3,7 +3,7 @@ import type {BlokComponentContracts} from '../../renderer/runtime/catalog';
|
|
|
3
3
|
import {BlokPropSchemas} from '../../renderer/runtime/schemas';
|
|
4
4
|
import {classNameSchema, contentSchema, headingLevelSchema, textAlignSchema, textFields} from '../props';
|
|
5
5
|
|
|
6
|
-
/** Text-bearing components: `Text` (ui
|
|
6
|
+
/** Text-bearing components: `Text` (the ui family), `p` and `span` (the html family), `Heading`, `Kbd`, `Markdown`, `Time`. */
|
|
7
7
|
|
|
8
8
|
/** `Text` and `p`/`span` differ only in the element they render: one schema. */
|
|
9
9
|
const textComponentSchema = z
|
package/src/catalogs/scene.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
1
|
+
import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
2
2
|
import {parts} from './parts';
|
|
3
3
|
|
|
4
|
-
/** `scene
|
|
4
|
+
/** The `scene` family of the base catalog. */
|
|
5
5
|
export const sceneCatalog = defineBlokCatalog({
|
|
6
6
|
name: "scene",
|
|
7
|
-
|
|
7
|
+
partOf: BASE_CATALOG_REF,
|
|
8
8
|
description: "3D components: the Scene and Space roots, models, verb modifiers on a model's nodes, the HTML bridge (Popout), and the placed dependencies of a Space.",
|
|
9
9
|
components: {
|
|
10
10
|
Animate: parts.Animate,
|
package/src/catalogs/shadcn.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
1
|
+
import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
2
2
|
import {parts} from './parts';
|
|
3
3
|
|
|
4
|
-
/** `shadcn
|
|
4
|
+
/** The `shadcn` family of the base catalog. */
|
|
5
5
|
export const shadcnCatalog = defineBlokCatalog({
|
|
6
6
|
name: "shadcn",
|
|
7
|
-
|
|
8
|
-
description: "The shadcn families beyond ui
|
|
7
|
+
partOf: BASE_CATALOG_REF,
|
|
8
|
+
description: "The shadcn families beyond the ui family (alert dialogs, sheets, drawers, menus, calendars, carousels, resizable panels, bento grids ...), charts and the raw inspector.",
|
|
9
9
|
components: {
|
|
10
10
|
AlertDialog: {...parts.AlertDialog, events: {onOpenChange: [{key: "value", kind: "BOOL", description: "Whether it is open now."}]}},
|
|
11
11
|
AlertDialogAction: parts.AlertDialogAction,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
1
|
+
import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
2
2
|
import {parts} from './parts';
|
|
3
3
|
|
|
4
|
-
/** `structure
|
|
4
|
+
/** The `structure` family of the base catalog. */
|
|
5
5
|
export const structureCatalog = defineBlokCatalog({
|
|
6
6
|
name: "structure",
|
|
7
|
-
|
|
7
|
+
partOf: BASE_CATALOG_REF,
|
|
8
8
|
description: "Pick, show and view structures, typed by `\"@package/key\"`.",
|
|
9
9
|
components: {
|
|
10
10
|
StructureDisplay: parts.StructureDisplay,
|
package/src/catalogs/ui.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
1
|
+
import {BASE_CATALOG_REF, defineBlokCatalog} from '../renderer/runtime/catalog';
|
|
2
2
|
import {parts} from './parts';
|
|
3
3
|
|
|
4
|
-
/** `ui
|
|
4
|
+
/** The `ui` family of the base catalog. */
|
|
5
5
|
export const uiCatalog = defineBlokCatalog({
|
|
6
6
|
name: "ui",
|
|
7
|
-
|
|
7
|
+
partOf: BASE_CATALOG_REF,
|
|
8
8
|
description: "Standard HTML components: layout, text, feedback, forms, data and overlays (shadcn-based).",
|
|
9
9
|
components: {
|
|
10
10
|
Accordion: {...parts.Accordion, events: {onChange: [{key: "value", kind: "ANY", description: "The open/pressed value(s): a string, or a list when multiple."}]}},
|
|
@@ -50,6 +50,7 @@ export const uiCatalog = defineBlokCatalog({
|
|
|
50
50
|
RadioGroup: {...parts.RadioGroup, events: {onChange: [{key: "value", kind: "STRING", description: "The value now chosen."}]}, bindKinds: {bind: "STRING"}},
|
|
51
51
|
RadioGroupItem: {...parts.RadioGroupItem, textProp: "label"},
|
|
52
52
|
Row: parts.Row,
|
|
53
|
+
List: parts.List,
|
|
53
54
|
ScrollArea: parts.ScrollArea,
|
|
54
55
|
Select: {...parts.Select, events: {onChange: [{key: "value", kind: "STRING", description: "The value now chosen."}]}, bindKinds: {bind: "STRING"}},
|
|
55
56
|
SelectContent: parts.SelectContent,
|
package/src/catalogs.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
// @arkitektio/bsx/catalogs: the
|
|
1
|
+
// @arkitektio/bsx/catalogs: the contracts of the base catalog's families (ui, html, logo, scene, structure, shadcn)
|
|
2
2
|
// and the prop-schema vocabulary to define a UI's own. zod only: no React, no DOM.
|
|
3
3
|
export * from './catalogs/index';
|
|
4
|
-
export {
|
|
4
|
+
export {
|
|
5
|
+
BASE_CATALOG_ADDRESS,
|
|
6
|
+
BASE_CATALOG_REF,
|
|
7
|
+
catalogRef,
|
|
8
|
+
defineBlokCatalog,
|
|
9
|
+
type BlokCatalogContract,
|
|
10
|
+
type BlokComponentContracts,
|
|
11
|
+
} from './renderer/runtime/catalog';
|
|
5
12
|
export type {BlokComponentContract} from './renderer/runtime/components';
|
|
6
13
|
export {describeBlokContract, specJsonText, type SpecCatalogJson} from './renderer/runtime/describe';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The pen this app draws its action logos with: logo bloks in v2 BSX
|
|
3
|
-
*
|
|
2
|
+
* The pen this app draws its action logos with: logo bloks in v2 BSX
|
|
3
|
+
* (`<Blok kind="action" context="logo"><Logo>`), on a 24 px grid, painted with the viewer's pens
|
|
4
4
|
* only (vocabulary `theme.logo_pens`: `ink muted brand brand-strong brand-soft
|
|
5
5
|
* surface none`, the status pens `success warning info` and the spectral pens
|
|
6
6
|
* `spectrum-violet` ... `spectrum-red`, for a logo of something that has a
|
|
@@ -19,6 +19,6 @@ export const ACTION_LOGO_PEN =
|
|
|
19
19
|
/** An attribute literal: in v2 BSX `"..."` is always a string, so only the markup needs escaping. */
|
|
20
20
|
const attribute = (value: string): string => value.replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');
|
|
21
21
|
|
|
22
|
-
/** An
|
|
22
|
+
/** An action's logo blok of `body`, drawn with the pen. */
|
|
23
23
|
export const actionLogoSource = (title: string, body: string): string =>
|
|
24
|
-
`<
|
|
24
|
+
`<Blok kind="action" context="logo"><Logo viewBox="0 0 24 24" title="${attribute(title)}"><G ${ACTION_LOGO_PEN}>${body}</G></Logo></Blok>`;
|
package/src/ports.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @arkitektio/bsx/ports: an action's form, the port engine and its widgets. What the app gives it is
|
|
2
|
-
// `configurePortHost`; `hostedStructure` draws structure
|
|
2
|
+
// `configurePortHost`; `hostedStructure` draws the structure family with the same host. A form needs the
|
|
3
3
|
// optional peers react-hook-form, @hookform/resolvers, cmdk and date-fns.
|
|
4
4
|
export * from './ports/engine/DependencyContext';
|
|
5
5
|
export * from './ports/engine/EffectWrapper';
|
|
@@ -7,21 +7,21 @@ import {BlokComponentHost} from './BlokComponentHost';
|
|
|
7
7
|
|
|
8
8
|
afterEach(cleanup);
|
|
9
9
|
|
|
10
|
-
/** `<
|
|
10
|
+
/** `<fragment><Card><Input bind={value} placeholder="scale" /><p>{limit}</p></Card></fragment>`, as the server sends it. */
|
|
11
11
|
const NODES = [
|
|
12
12
|
{
|
|
13
|
-
id: '
|
|
13
|
+
id: 'fragment[0]/Card[0]',
|
|
14
14
|
component: 'Card',
|
|
15
15
|
children: [
|
|
16
16
|
{
|
|
17
|
-
id: '
|
|
17
|
+
id: 'fragment[0]/Card[0]/Input[0]',
|
|
18
18
|
component: 'Input',
|
|
19
19
|
props: [
|
|
20
20
|
{key: 'bind', dynamic_value: {path: 'value'}},
|
|
21
21
|
{key: 'placeholder', static_value: 'scale'},
|
|
22
22
|
],
|
|
23
23
|
},
|
|
24
|
-
{id: '
|
|
24
|
+
{id: 'fragment[0]/Card[0]/p[0]', component: 'p', props: [{key: 'text', dynamic_value: {path: 'limit'}}]},
|
|
25
25
|
],
|
|
26
26
|
},
|
|
27
27
|
];
|
|
@@ -31,7 +31,7 @@ describe('BlokComponentHost with a tree', () => {
|
|
|
31
31
|
const onValue = vi.fn();
|
|
32
32
|
render(
|
|
33
33
|
<BlokComponentHost
|
|
34
|
-
component="
|
|
34
|
+
component="fragment"
|
|
35
35
|
props={[]}
|
|
36
36
|
nodes={NODES}
|
|
37
37
|
data={{value: 'a', limit: 'up to 9'}}
|
|
@@ -8,6 +8,8 @@ import {BlokSceneFillProvider} from './bloks/scene/host';
|
|
|
8
8
|
import {useBlokCatalog} from './catalog';
|
|
9
9
|
import {invokeBlokFunction} from './functions/v2/handler';
|
|
10
10
|
import {BlokComponentStateContext, type BlokComponentStateStore} from './persist';
|
|
11
|
+
import {drawnChildren} from './bloks/control';
|
|
12
|
+
import {treeQueries, treeSubscriptions} from './declarations';
|
|
11
13
|
import {
|
|
12
14
|
BlokNode,
|
|
13
15
|
BlokNodeErrorSurface,
|
|
@@ -15,10 +17,14 @@ import {
|
|
|
15
17
|
BlokTreeProvider,
|
|
16
18
|
createBlokRuntimeStore,
|
|
17
19
|
dependencyStatusPath,
|
|
20
|
+
BlokLocalsScope,
|
|
21
|
+
localChildren,
|
|
22
|
+
normalizeBlokComponentTree,
|
|
18
23
|
preflightBlokDocument,
|
|
19
24
|
unboundDependencyStatus,
|
|
20
25
|
unboundDependencyStatuses,
|
|
21
26
|
type BlokCatalog,
|
|
27
|
+
type BlokComponentNode,
|
|
22
28
|
type BlokNodeErrorProps,
|
|
23
29
|
type BlokDispatchActionHandler,
|
|
24
30
|
type BlokInvokeFunctionHandler,
|
|
@@ -65,19 +71,23 @@ type BlokRendererProps = {
|
|
|
65
71
|
/** Shows the floating runtime-state inspector. Off by default. */
|
|
66
72
|
debug?: boolean;
|
|
67
73
|
/**
|
|
68
|
-
* Locals kept from an earlier opening, by
|
|
69
|
-
* first render on (`./persist.ts`). Read once, when the renderer mounts.
|
|
74
|
+
* Locals kept from an earlier opening, by runtime id (`runtimeIdOf`), shown
|
|
75
|
+
* from the first render on (`./persist.ts`). Read once, when the renderer mounts.
|
|
70
76
|
*/
|
|
71
77
|
keptValues?: Record<string, unknown>;
|
|
72
|
-
/** The
|
|
73
|
-
|
|
78
|
+
/** The `<local>` node ids kept between openings: swapping the payload leaves their values alone. */
|
|
79
|
+
keptLocals?: ReadonlySet<string>;
|
|
74
80
|
/** Source statuses known before the first render, by data-model path (`deps.robot.arm`: pending). */
|
|
75
81
|
statuses?: Readonly<Record<string, BlokSourceStatus>>;
|
|
76
82
|
/** The moment the blok shows while travelling (ISO 8601): commands and toasts are off, inputs read-only. */
|
|
77
83
|
travelAt?: string | null;
|
|
78
84
|
/** Who is looking: `viewer`. */
|
|
79
85
|
viewer?: BlokViewer | null;
|
|
80
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* The blok's reads, and how they run; a preview runs none (it seeds
|
|
88
|
+
* `demo.queries`). Left out, the tree's `<query>` and `<subscription>`
|
|
89
|
+
* children (`treeQueries`).
|
|
90
|
+
*/
|
|
81
91
|
queries?: readonly BlokQuery[];
|
|
82
92
|
subscriptions?: readonly BlokSubscription[];
|
|
83
93
|
readExecutor?: BlokReadExecutor;
|
|
@@ -107,14 +117,21 @@ const EmbeddedNodeError = ({componentId, title, detail}: BlokNodeErrorProps) =>
|
|
|
107
117
|
<EmbeddedNotice title={title} detail={detail ? `${detail} (${componentId})` : componentId} />
|
|
108
118
|
);
|
|
109
119
|
|
|
110
|
-
/**
|
|
120
|
+
/** What a root draws: a `<Blok>`'s one element (its first drawn child), any other root itself. */
|
|
121
|
+
const drawnRoot = (tree: BlokTree, rootId: string): string | undefined => {
|
|
122
|
+
const node = tree.nodes.get(rootId)?.node;
|
|
123
|
+
if (node?.component !== 'Blok') return node?.component;
|
|
124
|
+
return drawnChildren(node)[0]?.component;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** The roots of a blok shown in a scene that is already open. Only a blok that opens a scene can stand in one. */
|
|
111
128
|
const EmbeddedRoots = ({tree, rootIds, errors}: {tree: BlokTree; rootIds: string[]; errors: string[]}) => (
|
|
112
129
|
<>
|
|
113
130
|
{errors.map(error => (
|
|
114
131
|
<EmbeddedNotice key={error} title="Blok payload could not be parsed" detail={error} />
|
|
115
132
|
))}
|
|
116
133
|
{rootIds.map(rootId => {
|
|
117
|
-
const component = tree
|
|
134
|
+
const component = drawnRoot(tree, rootId);
|
|
118
135
|
const opensScene =
|
|
119
136
|
!component || tree.catalog.components.get(component)?.placement?.childrenContext === 'scene';
|
|
120
137
|
return opensScene ? (
|
|
@@ -142,12 +159,12 @@ export default function BlokRenderer({
|
|
|
142
159
|
embedded = false,
|
|
143
160
|
debug = false,
|
|
144
161
|
keptValues,
|
|
145
|
-
|
|
162
|
+
keptLocals,
|
|
146
163
|
statuses,
|
|
147
164
|
travelAt = null,
|
|
148
165
|
viewer = null,
|
|
149
|
-
queries
|
|
150
|
-
subscriptions
|
|
166
|
+
queries: givenQueries,
|
|
167
|
+
subscriptions: givenSubscriptions,
|
|
151
168
|
readExecutor,
|
|
152
169
|
answerTask,
|
|
153
170
|
startRun,
|
|
@@ -162,6 +179,18 @@ export default function BlokRenderer({
|
|
|
162
179
|
[catalog, uiComponents],
|
|
163
180
|
);
|
|
164
181
|
|
|
182
|
+
const roots = useMemo(
|
|
183
|
+
() => normalizeBlokComponentTree(Array.isArray(uiComponents) ? uiComponents : uiComponents ? [uiComponents] : null).roots,
|
|
184
|
+
[uiComponents],
|
|
185
|
+
);
|
|
186
|
+
const queries = useMemo(() => givenQueries ?? (roots.length === 1 ? treeQueries(roots[0]) : NO_QUERIES), [givenQueries, roots]);
|
|
187
|
+
const subscriptions = useMemo(
|
|
188
|
+
() => givenSubscriptions ?? (roots.length === 1 ? treeSubscriptions(roots[0]) : NO_SUBSCRIPTIONS),
|
|
189
|
+
[givenSubscriptions, roots],
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const rootLocals = useMemo(() => (roots.length === 1 ? localChildren(roots[0] as BlokComponentNode) : []), [roots]);
|
|
193
|
+
|
|
165
194
|
const tree = useMemo<BlokTree>(
|
|
166
195
|
() => ({
|
|
167
196
|
catalog,
|
|
@@ -201,7 +230,7 @@ export default function BlokRenderer({
|
|
|
201
230
|
unavailableDependencies,
|
|
202
231
|
lockedActions,
|
|
203
232
|
keptValues,
|
|
204
|
-
|
|
233
|
+
keptLocals,
|
|
205
234
|
statuses: unboundDependencies?.length ? {...statuses, ...unboundDependencyStatuses(unboundDependencies)} : statuses,
|
|
206
235
|
travelAt,
|
|
207
236
|
answerTask,
|
|
@@ -239,8 +268,8 @@ export default function BlokRenderer({
|
|
|
239
268
|
}, [controlTask, runtimeStore]);
|
|
240
269
|
|
|
241
270
|
useEffect(() => {
|
|
242
|
-
if (
|
|
243
|
-
}, [
|
|
271
|
+
if (keptLocals) runtimeStore.getState().setKeptLocals(keptLocals);
|
|
272
|
+
}, [keptLocals, runtimeStore]);
|
|
244
273
|
|
|
245
274
|
useEffect(() => {
|
|
246
275
|
runtimeStore.getState().setInitialDataModel(initialState);
|
|
@@ -303,11 +332,14 @@ export default function BlokRenderer({
|
|
|
303
332
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
304
333
|
useBlokTailwind(preflight.nodes, embedded ? undefined : containerRef);
|
|
305
334
|
|
|
335
|
+
// A query's variables read the blok-level locals: the <Blok>'s own.
|
|
306
336
|
const syncs = (
|
|
307
337
|
<>
|
|
308
338
|
<BlokViewerSync viewer={viewer} />
|
|
309
339
|
{readExecutor && (queries.length > 0 || subscriptions.length > 0) ? (
|
|
310
|
-
<
|
|
340
|
+
<BlokLocalsScope locals={rootLocals}>
|
|
341
|
+
<BlokReads queries={queries} subscriptions={subscriptions} executor={readExecutor} />
|
|
342
|
+
</BlokLocalsScope>
|
|
311
343
|
) : null}
|
|
312
344
|
</>
|
|
313
345
|
);
|