@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,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { LOCAL_ANY_KIND } from '../spec/vocabulary.js';
|
|
1
|
+
import { declaredQueries as queriesOfTree, declaredSubscriptions as subscriptionsOfTree } from '../bsx/declared.js';
|
|
2
|
+
import { resolveLocals } from '../bsx/infer.js';
|
|
3
|
+
import { viewForTree } from '../bsx/references.js';
|
|
5
4
|
import { idleTaskRecord, normalizeBlokArgument, pendingReads, } from './runtime/index.js';
|
|
6
5
|
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
7
6
|
const variablesOf = (raw) => (Array.isArray(raw) ? raw : []).map(argument => normalizeBlokArgument(argument));
|
|
@@ -16,8 +15,15 @@ const localPort = (port) => ({
|
|
|
16
15
|
label: port.label ?? null,
|
|
17
16
|
description: port.description ?? null,
|
|
18
17
|
});
|
|
19
|
-
export const declaredLocals = (declarations) => declarations.resolvedLocals.map(local => ({ ...localPort(local), persist: local.persist === true }));
|
|
20
|
-
|
|
18
|
+
export const declaredLocals = (declarations) => declarations.resolvedLocals.map(local => ({ ...localPort(local), node: local.node, persist: local.persist === true }));
|
|
19
|
+
/** The one root of a tree as the wire spells it (a list of roots, or one), or null. */
|
|
20
|
+
const rootOf = (roots) => {
|
|
21
|
+
const list = Array.isArray(roots) ? roots : [roots];
|
|
22
|
+
const [root] = list;
|
|
23
|
+
return list.length === 1 && isRecord(root) && typeof root.component === 'string' ? root : null;
|
|
24
|
+
};
|
|
25
|
+
/** The reads a blok declares: its `<Blok>`'s `<query>` children. */
|
|
26
|
+
export const treeQueries = (roots) => queriesOfTree(rootOf(roots)).map(query => ({
|
|
21
27
|
key: query.key,
|
|
22
28
|
service: query.service,
|
|
23
29
|
document: query.document,
|
|
@@ -25,7 +31,8 @@ export const declaredQueries = (declarations) => (declarations.queries ?? []).ma
|
|
|
25
31
|
poll: query.poll ?? null,
|
|
26
32
|
more: query.more ?? null,
|
|
27
33
|
}));
|
|
28
|
-
|
|
34
|
+
/** The streams a blok declares: its `<Blok>`'s `<subscription>` children. */
|
|
35
|
+
export const treeSubscriptions = (roots) => subscriptionsOfTree(rootOf(roots)).map(subscription => ({
|
|
29
36
|
key: subscription.key,
|
|
30
37
|
service: subscription.service,
|
|
31
38
|
document: subscription.document,
|
|
@@ -33,8 +40,6 @@ export const declaredSubscriptions = (declarations) => (declarations.subscriptio
|
|
|
33
40
|
keep: subscription.keep ?? null,
|
|
34
41
|
history: subscription.history ?? null,
|
|
35
42
|
}));
|
|
36
|
-
/** Each declared local at its default. */
|
|
37
|
-
export const localsModel = (locals) => Object.fromEntries(locals.map(local => [local.key, local.default ?? null]));
|
|
38
43
|
/** The names `into` gives a task call's record, in the tree. */
|
|
39
44
|
export const intoNames = (roots) => {
|
|
40
45
|
const names = new Set();
|
|
@@ -53,34 +58,36 @@ export const intoNames = (roots) => {
|
|
|
53
58
|
};
|
|
54
59
|
/** Every `into` record before its call ran: idle. */
|
|
55
60
|
export const intoModel = (roots) => Object.fromEntries(intoNames(roots).map(name => [name, idleTaskRecord()]));
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
/**
|
|
62
|
+
* What a renderer shows live before anything synced: idle `into` records and
|
|
63
|
+
* pending reads. Locals read their defaults until written (`runtime/locals`).
|
|
64
|
+
*/
|
|
65
|
+
export const liveModel = (roots) => {
|
|
66
|
+
const reads = pendingReads(treeQueries(roots), treeSubscriptions(roots));
|
|
59
67
|
return {
|
|
60
|
-
data: { ...
|
|
68
|
+
data: { ...intoModel(roots), ...reads.data },
|
|
61
69
|
statuses: reads.statuses,
|
|
62
70
|
};
|
|
63
71
|
};
|
|
64
72
|
/**
|
|
65
73
|
* What a preview renders: the blok's `demo`, mirroring the roots
|
|
66
|
-
* (`{deps, args, task, queries, subscriptions}`), with every
|
|
67
|
-
* answered by its demo value. Nothing is pending in a preview.
|
|
74
|
+
* (`{deps, args, task, queries, subscriptions}`), with every read the tree
|
|
75
|
+
* declares answered by its demo value. Nothing is pending in a preview.
|
|
68
76
|
*/
|
|
69
77
|
export const demoModel = (roots, declarations) => {
|
|
70
78
|
const demo = isRecord(declarations.demo) ? declarations.demo : {};
|
|
71
79
|
const demoQueries = isRecord(demo.queries) ? demo.queries : {};
|
|
72
80
|
const demoSubscriptions = isRecord(demo.subscriptions) ? demo.subscriptions : {};
|
|
73
|
-
const queries = Object.fromEntries(
|
|
81
|
+
const queries = Object.fromEntries(treeQueries(roots).map(query => [
|
|
74
82
|
query.key,
|
|
75
83
|
{ status: 'ready', value: demoQueries[query.key] ?? null, error: null, refetching: false, fetching_more: false },
|
|
76
84
|
]));
|
|
77
|
-
const subscriptions = Object.fromEntries(
|
|
85
|
+
const subscriptions = Object.fromEntries(treeSubscriptions(roots).map(subscription => [
|
|
78
86
|
subscription.key,
|
|
79
87
|
{ status: 'ready', value: demoSubscriptions[subscription.key] ?? null, error: null },
|
|
80
88
|
]));
|
|
81
89
|
const task = isRecord(demo.task) ? { ...idleTaskRecord(), ...demo.task } : undefined;
|
|
82
90
|
return {
|
|
83
|
-
...localsModel(declaredLocals(declarations)),
|
|
84
91
|
...intoModel(roots),
|
|
85
92
|
deps: isRecord(demo.deps) ? demo.deps : {},
|
|
86
93
|
args: isRecord(demo.args) ? demo.args : {},
|
|
@@ -89,18 +96,15 @@ export const demoModel = (roots, declarations) => {
|
|
|
89
96
|
...(Object.keys(subscriptions).length ? { subscriptions } : {}),
|
|
90
97
|
};
|
|
91
98
|
};
|
|
92
|
-
const optionalNumber = (value) => (typeof value === 'number' ? value : null);
|
|
93
99
|
const optionalString = (value) => (typeof value === 'string' ? value : null);
|
|
94
100
|
const jsonChoices = (raw) => Array.isArray(raw)
|
|
95
101
|
? raw.filter(isRecord).map(choice => ({ value: choice.value ?? null, label: optionalString(choice.label), description: optionalString(choice.description) }))
|
|
96
102
|
: null;
|
|
97
|
-
/** A port from JSON;
|
|
98
|
-
const jsonLocalPort = (port) => typeof port.
|
|
99
|
-
/** A port from JSON with `kind` as given; null without a key. */
|
|
100
|
-
const jsonLocalWritten = (port, kind) => typeof port.key === 'string'
|
|
103
|
+
/** A port from JSON; one without a key or kind is dropped. */
|
|
104
|
+
const jsonLocalPort = (port) => typeof port.key === 'string' && typeof port.kind === 'string'
|
|
101
105
|
? {
|
|
102
106
|
key: port.key,
|
|
103
|
-
kind,
|
|
107
|
+
kind: port.kind,
|
|
104
108
|
identifier: optionalString(port.identifier),
|
|
105
109
|
nullable: port.nullable === true,
|
|
106
110
|
default: port.default ?? null,
|
|
@@ -115,45 +119,26 @@ const jsonLocalWritten = (port, kind) => typeof port.key === 'string'
|
|
|
115
119
|
description: optionalString(port.description),
|
|
116
120
|
}
|
|
117
121
|
: null;
|
|
118
|
-
/**
|
|
119
|
-
const
|
|
120
|
-
const port =
|
|
121
|
-
return port ? [{ ...port, persist: local.persist === true }] : [];
|
|
122
|
+
/** Resolved locals from JSON; one without a node, a key or a kind is dropped. */
|
|
123
|
+
const jsonResolvedLocals = (raw) => (Array.isArray(raw) ? raw : []).filter(isRecord).flatMap(local => {
|
|
124
|
+
const port = jsonLocalPort(local);
|
|
125
|
+
return port && typeof local.node === 'string' ? [{ ...port, node: local.node, persist: local.persist === true }] : [];
|
|
122
126
|
});
|
|
123
|
-
const jsonRoots = (raw) => (Array.isArray(raw) ? raw : [raw]).filter((node) => isRecord(node) && typeof node.component === 'string');
|
|
124
127
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
+
* The `<local>` nodes of a tree resolved the way the spec and the server
|
|
129
|
+
* resolve them (default, task argument, bind, else ANY), checked unmounted:
|
|
130
|
+
* what a host uses when the server sent no `resolvedLocals`.
|
|
128
131
|
*/
|
|
129
|
-
export const
|
|
130
|
-
|
|
132
|
+
export const resolveTreeLocals = (roots) => {
|
|
133
|
+
const root = rootOf(roots);
|
|
134
|
+
if (!root)
|
|
131
135
|
return [];
|
|
132
|
-
|
|
133
|
-
if (!root || roots.length !== 1)
|
|
134
|
-
return locals.map(local => ({ ...local, kind: local.kind ?? LOCAL_ANY_KIND }));
|
|
135
|
-
return resolveBlokScope(root, { ...emptyBlokScope(), locals }, defaultBlokView()).locals.map(local => ({ ...local }));
|
|
136
|
+
return [...resolveLocals(root, null, viewForTree(root))].map(([node, { local }]) => ({ ...local, node }));
|
|
136
137
|
};
|
|
137
|
-
|
|
138
|
-
? [
|
|
139
|
-
{
|
|
140
|
-
key: read.key,
|
|
141
|
-
service: read.service,
|
|
142
|
-
document: read.document,
|
|
143
|
-
variables: read.variables,
|
|
144
|
-
poll: optionalNumber(read.poll),
|
|
145
|
-
more: optionalString(read.more),
|
|
146
|
-
keep: optionalNumber(read.keep),
|
|
147
|
-
history: optionalString(read.history),
|
|
148
|
-
},
|
|
149
|
-
]
|
|
150
|
-
: []);
|
|
151
|
-
/** A blok's declarations from JSON a service serves, keeping only well-formed entries. */
|
|
138
|
+
/** A blok's declarations from JSON a service serves: its resolved locals as served, or resolved from its tree. */
|
|
152
139
|
export const parseBlokDeclarations = (raw) => ({
|
|
153
140
|
vocab: raw.vocab ?? null,
|
|
154
|
-
resolvedLocals:
|
|
141
|
+
resolvedLocals: raw.resolvedLocals !== undefined && raw.resolvedLocals !== null ? jsonResolvedLocals(raw.resolvedLocals) : resolveTreeLocals(raw.componentTree),
|
|
155
142
|
demo: raw.demo ?? null,
|
|
156
|
-
queries: jsonReads(raw.queries),
|
|
157
|
-
subscriptions: jsonReads(raw.subscriptions),
|
|
158
143
|
});
|
|
159
144
|
//# sourceMappingURL=declarations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declarations.js","sourceRoot":"","sources":["../../src/renderer/declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"declarations.js","sourceRoot":"","sources":["../../src/renderer/declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,IAAI,aAAa,EAAE,qBAAqB,IAAI,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAC/G,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,YAAY,GASb,MAAM,WAAW,CAAC;AAuEnB,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEvE,MAAM,WAAW,GAAG,CAAC,GAAY,EAAwB,EAAE,CACzD,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,qBAAqB,CAAC,QAAQ,CAAuB,CAAC,CAAC;AAEzG,MAAM,SAAS,GAAG,CAAC,IAA2B,EAAiB,EAAE,CAAC,CAAC;IACjE,GAAG,EAAE,IAAI,CAAC,GAAG;IACb,IAAI,EAAE,IAAI,CAAC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uC,EAAuB,EAAE;IAChG,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,OAAO,CAAC,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,EAAC,KAAK,EAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,KAAK,EAAE,IAAI,EAAC,CAAsB,CAAC,CAAC;AAC7H,CAAC,CAAC;AAEF,kHAAkH;AAClH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAyB,EAAoB,EAAE,CAAC,CAAC;IACrF,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI;IACxB,cAAc,EAAE,GAAG,CAAC,cAAc,KAAK,SAAS,IAAI,GAAG,CAAC,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,aAAa,CAAC;IAC/J,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,IAAI;CACvB,CAAC,CAAC"}
|
|
@@ -1,40 +1,52 @@
|
|
|
1
1
|
import { type BlokCatalog, type BlokCatalogImplementation, type BlokComponentDefinition, type SpecCatalogJson } from './runtime';
|
|
2
|
+
import type { BlokContextName } from '../spec/vocabulary';
|
|
2
3
|
/**
|
|
3
|
-
* A UI's catalog, declared:
|
|
4
|
+
* A UI's catalog, declared: what it draws, and nothing inferred.
|
|
4
5
|
*
|
|
5
|
-
* - `catalog` is what its renderers draw:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
6
|
+
* - `catalog` is what its renderers draw: the language's own elements and every
|
|
7
|
+
* implementation.
|
|
8
|
+
* - `contexts` are the contexts in which it draws the base catalog whole
|
|
9
|
+
* (`HTML`, `SCENE`, `LOGO`): a blok written for the base catalog and drawn in
|
|
10
|
+
* one of them is known to render here.
|
|
11
|
+
* - `claims` are the catalogs it speaks: the base catalog when it draws it
|
|
12
|
+
* whole in at least one context, and each published catalog of its own.
|
|
13
|
+
* - Its own catalogs are part of `catalog`; what it publishes as its app
|
|
14
|
+
* catalog is `ownComponentsOf(catalog)`, which also counts what its modules
|
|
15
|
+
* add later (`addBlokComponents`).
|
|
14
16
|
*/
|
|
15
17
|
export type BlokUi = {
|
|
16
18
|
name: string;
|
|
17
19
|
description: string | null;
|
|
18
20
|
catalog: BlokCatalog;
|
|
19
21
|
implementations: readonly BlokCatalogImplementation[];
|
|
22
|
+
contexts: readonly BlokContextName[];
|
|
20
23
|
claims: readonly string[];
|
|
21
24
|
};
|
|
25
|
+
/** The contexts in which `catalog` draws every component of the base catalog. */
|
|
26
|
+
export declare const baseContextsOf: (catalog: BlokCatalog) => BlokContextName[];
|
|
22
27
|
export declare const declareBlokUi: (declaration: {
|
|
23
28
|
name: string;
|
|
24
29
|
description?: string;
|
|
25
30
|
implements: readonly BlokCatalogImplementation[];
|
|
26
31
|
}) => BlokUi;
|
|
27
32
|
/**
|
|
28
|
-
* What a UI
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* and a global component a module drew over (it is the module's now).
|
|
33
|
+
* What a UI draws beyond the base catalog: every component of its catalog
|
|
34
|
+
* that is neither the language's own nor one of the base catalog's. Its own
|
|
35
|
+
* catalogs' components, and what its modules added since (`addBlokComponents`).
|
|
32
36
|
*/
|
|
33
|
-
export declare const
|
|
37
|
+
export declare const ownComponentsOf: (catalog: BlokCatalog) => BlokComponentDefinition[];
|
|
34
38
|
/**
|
|
35
|
-
* A UI's
|
|
36
|
-
*
|
|
37
|
-
*
|
|
39
|
+
* A UI's app catalog as the spec writes one (`{id, name, version, minor,
|
|
40
|
+
* extends, components}`): what it publishes at `id`, registers with the
|
|
41
|
+
* server, and hands the language (`setAppBlokCatalog(parseSpecCatalog(...))`)
|
|
42
|
+
* so its own parser, checks and editor know the components only it draws.
|
|
38
43
|
*/
|
|
39
|
-
export declare const
|
|
44
|
+
export declare const blokCatalogSpec: (meta: {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
version: number;
|
|
48
|
+
minor?: number;
|
|
49
|
+
extends?: string;
|
|
50
|
+
description: string;
|
|
51
|
+
}, catalog: BlokCatalog) => SpecCatalogJson;
|
|
40
52
|
//# sourceMappingURL=declare.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declare.d.ts","sourceRoot":"","sources":["../../src/renderer/declare.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"declare.d.ts","sourceRoot":"","sources":["../../src/renderer/declare.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACrB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,WAAW,CAAC;IACrB,eAAe,EAAE,SAAS,yBAAyB,EAAE,CAAC;IACtD,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;IACrC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B,CAAC;AAYF,iFAAiF;AACjF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,KAAG,eAAe,EAMpE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,aAAa;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,SAAS,yBAAyB,EAAE,CAAC;CAClD,KAAG,MA2BH,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,WAAW,KAAG,uBAAuB,EAG3E,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,MAAM;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAC,EACxG,SAAS,WAAW,KACnB,eAUD,CAAC"}
|
package/dist/renderer/declare.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { baseBlokCatalog } from './baseCatalog.js';
|
|
2
|
-
import { catalogRef, describeBlokComponent, extendBlokCatalog, } from './runtime/index.js';
|
|
2
|
+
import { BASE_CATALOG_ADDRESS, BASE_CATALOG_REF, catalogRef, describeBlokComponent, extendBlokCatalog, } from './runtime/index.js';
|
|
3
|
+
import { baseCatalog } from '../spec/catalogs.js';
|
|
4
|
+
const CONTEXTS = ['PANEL', 'SCENE', 'LOGO'];
|
|
5
|
+
/**
|
|
6
|
+
* The context a base component counts towards: its own, and for one that
|
|
7
|
+
* bridges a panel and another context (`Scene` opens a scene inside a panel),
|
|
8
|
+
* the other one: a renderer that draws no 3D still draws panels whole.
|
|
9
|
+
*/
|
|
10
|
+
const contextOf = (component) => component.context !== 'PANEL' ? component.context : (component.childrenContext ?? 'PANEL');
|
|
11
|
+
/** The contexts in which `catalog` draws every component of the base catalog. */
|
|
12
|
+
export const baseContextsOf = (catalog) => {
|
|
13
|
+
const components = baseCatalog().components;
|
|
14
|
+
return CONTEXTS.filter(context => {
|
|
15
|
+
const drawn = components.filter(component => !component.inheritsContext && contextOf(component) === context);
|
|
16
|
+
return drawn.length > 0 && drawn.every(component => catalog.components.has(component.name));
|
|
17
|
+
});
|
|
18
|
+
};
|
|
3
19
|
export const declareBlokUi = (declaration) => {
|
|
4
20
|
const implementations = declaration.implements;
|
|
5
21
|
const refs = implementations.map(implementation => catalogRef(implementation.contract));
|
|
@@ -7,33 +23,43 @@ export const declareBlokUi = (declaration) => {
|
|
|
7
23
|
if (twice.length > 0) {
|
|
8
24
|
throw new Error(`${declaration.name} implements ${[...new Set(twice)].join(', ')} twice`);
|
|
9
25
|
}
|
|
26
|
+
const catalog = extendBlokCatalog(baseBlokCatalog, declaration.name, implementations.flatMap(implementation => implementation.components));
|
|
27
|
+
const contexts = baseContextsOf(catalog);
|
|
10
28
|
return {
|
|
11
29
|
name: declaration.name,
|
|
12
30
|
description: declaration.description ?? null,
|
|
13
|
-
catalog
|
|
31
|
+
catalog,
|
|
14
32
|
implementations,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.
|
|
18
|
-
|
|
33
|
+
contexts,
|
|
34
|
+
claims: [
|
|
35
|
+
...(contexts.length > 0 ? [BASE_CATALOG_REF] : []),
|
|
36
|
+
...implementations
|
|
37
|
+
.filter(implementation => implementation.contract.partOf === null && implementation.contract.version !== null && implementation.whole)
|
|
38
|
+
.map(implementation => catalogRef(implementation.contract))
|
|
39
|
+
.sort(),
|
|
40
|
+
],
|
|
19
41
|
};
|
|
20
42
|
};
|
|
21
43
|
/**
|
|
22
|
-
* What a UI
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* and a global component a module drew over (it is the module's now).
|
|
44
|
+
* What a UI draws beyond the base catalog: every component of its catalog
|
|
45
|
+
* that is neither the language's own nor one of the base catalog's. Its own
|
|
46
|
+
* catalogs' components, and what its modules added since (`addBlokComponents`).
|
|
26
47
|
*/
|
|
27
|
-
export const
|
|
48
|
+
export const ownComponentsOf = (catalog) => [...catalog.components.values()].filter(component => catalog.base?.components.get(component.name) !== component && component.origin !== BASE_CATALOG_REF);
|
|
28
49
|
/**
|
|
29
|
-
* A UI's
|
|
30
|
-
*
|
|
31
|
-
*
|
|
50
|
+
* A UI's app catalog as the spec writes one (`{id, name, version, minor,
|
|
51
|
+
* extends, components}`): what it publishes at `id`, registers with the
|
|
52
|
+
* server, and hands the language (`setAppBlokCatalog(parseSpecCatalog(...))`)
|
|
53
|
+
* so its own parser, checks and editor know the components only it draws.
|
|
32
54
|
*/
|
|
33
|
-
export const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
55
|
+
export const blokCatalogSpec = (meta, catalog) => ({
|
|
56
|
+
id: meta.id,
|
|
57
|
+
name: meta.name,
|
|
58
|
+
version: meta.version,
|
|
59
|
+
minor: meta.minor ?? 0,
|
|
60
|
+
extends: meta.extends ?? BASE_CATALOG_ADDRESS,
|
|
61
|
+
description: meta.description,
|
|
62
|
+
components: ownComponentsOf(catalog)
|
|
37
63
|
.map(component => describeBlokComponent(component.name, component))
|
|
38
64
|
.sort((left, right) => (left.name < right.name ? -1 : left.name > right.name ? 1 : 0)),
|
|
39
65
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declare.js","sourceRoot":"","sources":["../../src/renderer/declare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,iBAAiB,GAKlB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"declare.js","sourceRoot":"","sources":["../../src/renderer/declare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,UAAU,EACV,qBAAqB,EACrB,iBAAiB,GAKlB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AA0B7C,MAAM,QAAQ,GAA+B,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAExE;;;;GAIG;AACH,MAAM,SAAS,GAAG,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M,CAAC,MAAM,eAAe,GAAG,CAC7B,IAAwG,EACxG,OAAoB,EACH,EAAE,CAAC,CAAC;IACrB,EAAE,EAAE,IAAI,CAAC,EAAE;IACX,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;IACtB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,oBAAoB;IAC7C,WAAW,EAAE,IAAI,CAAC,WAAW;IAC7B,UAAU,EAAE,eAAe,CAAC,OAAO,CAAC;SACjC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,qBAAqB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;SAClE,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACzF,CAAC,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { KeyedStore } from '../cache/keyedStore';
|
|
3
|
-
import type
|
|
3
|
+
import { type BlokRuntimeStore } from './runtime';
|
|
4
4
|
/**
|
|
5
5
|
* What a blok keeps between openings, on this device only (blok language v2):
|
|
6
6
|
*
|
|
7
|
-
* - **form inputs**: a local declared
|
|
8
|
-
*
|
|
7
|
+
* - **form inputs**: a local declared `<local name="x" default={...} persist />`
|
|
8
|
+
* remembers the viewer's last input, by its runtime id: the `<local>`'s node
|
|
9
|
+
* id, plus `@<item key>` per enclosing foreach (one value per item). An
|
|
10
|
+
* explicit `id=` on the `<local>` keeps it across edits of the tree;
|
|
9
11
|
* - **component state**: a component that offers it as its own BOOL prop
|
|
10
12
|
* (`<Scene id="main" persist>`, `<Transform id="arm-pose" persist>`) keeps
|
|
11
13
|
* its interaction state (the camera, the pose) by its id. The language
|
|
@@ -13,10 +15,10 @@ import type { BlokRuntimeStore } from './runtime';
|
|
|
13
15
|
*
|
|
14
16
|
* Nothing reaches a server, so keeping cannot become a channel between
|
|
15
17
|
* clients. Values live in IndexedDB keyed by (hub, user, materialized blok)
|
|
16
|
-
* for the locals
|
|
17
|
-
* component, and are written a
|
|
18
|
-
*
|
|
19
|
-
* dropped when the blok opens.
|
|
18
|
+
* for the locals (one record, values by runtime id) and (hub, user,
|
|
19
|
+
* materialized blok, component id) for each component, and are written a
|
|
20
|
+
* moment after the last change. A local the blok no longer persists, or a
|
|
21
|
+
* value that no longer fits its port, is dropped when the blok opens.
|
|
20
22
|
*/
|
|
21
23
|
/** A choice a local's port offers (`ChoiceInput`). */
|
|
22
24
|
export type BlokLocalChoice = {
|
|
@@ -41,11 +43,16 @@ export type BlokLocalPort = {
|
|
|
41
43
|
label?: string | null;
|
|
42
44
|
description?: string | null;
|
|
43
45
|
};
|
|
44
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* A `<local>` (vocabulary `locals`): an arg port plus `persist`, remembering
|
|
48
|
+
* the last input on this device, and `node`, the id of the `<local>` node
|
|
49
|
+
* that declares it.
|
|
50
|
+
*/
|
|
45
51
|
export type BlokLocal = BlokLocalPort & {
|
|
52
|
+
node: string;
|
|
46
53
|
persist?: boolean | null;
|
|
47
54
|
};
|
|
48
|
-
/** What is kept for one materialization's locals: values by local
|
|
55
|
+
/** What is kept for one materialization's locals: values by the local's runtime id (`runtimeIdOf`). */
|
|
49
56
|
export type KeptLocals = Record<string, unknown>;
|
|
50
57
|
/** Whose a kept record is: the hub and user it was set under, and the materialization. */
|
|
51
58
|
export type BlokPersistScope = {
|
|
@@ -53,6 +60,7 @@ export type BlokPersistScope = {
|
|
|
53
60
|
user: string;
|
|
54
61
|
materializedBlok: string;
|
|
55
62
|
};
|
|
63
|
+
/** Version 2: kept values by runtime id (version 1 kept them by top-level key, and is dropped). */
|
|
56
64
|
export declare const keptLocalsStore: KeyedStore<KeptLocals>;
|
|
57
65
|
/** One component's kept state, wrapped so any JSON value fits the store. */
|
|
58
66
|
export type KeptComponentState = {
|
|
@@ -63,6 +71,7 @@ export declare const keptLocalsId: (scope: BlokPersistScope) => string;
|
|
|
63
71
|
export declare const keptComponentId: (scope: BlokPersistScope, componentId: string) => string;
|
|
64
72
|
/** Whether a kept value can stand for a local: it fits the local's port (a kept value that no longer does is dropped). */
|
|
65
73
|
export declare const fitsLocal: (kept: unknown, local: BlokLocal) => boolean;
|
|
74
|
+
/** What of `record` still stands: the values of persisted locals (by their node) that still fit their port. */
|
|
66
75
|
export declare const keptValuesOf: (record: KeptLocals | null, locals: readonly BlokLocal[]) => {
|
|
67
76
|
values: KeptLocals;
|
|
68
77
|
dropped: boolean;
|
|
@@ -72,9 +81,9 @@ export declare const keptValuesOf: (record: KeptLocals | null, locals: readonly
|
|
|
72
81
|
* seed the renderer with, and what writes changes back.
|
|
73
82
|
*/
|
|
74
83
|
export type BlokPersistence = {
|
|
75
|
-
/** The
|
|
76
|
-
|
|
77
|
-
/** The kept
|
|
84
|
+
/** The `<local>` node ids kept on this device (those declared with `persist`): `BlokRenderer`'s `keptLocals`. */
|
|
85
|
+
locals: ReadonlySet<string>;
|
|
86
|
+
/** The kept values to seed the runtime with, before the first render, by runtime id: `BlokRenderer`'s `keptValues`. */
|
|
78
87
|
initial: KeptLocals;
|
|
79
88
|
/** Follows `store`: a change of a kept local is written after `delay`. Returns the detach, which flushes. */
|
|
80
89
|
attach: (store: BlokRuntimeStore) => () => void;
|
|
@@ -95,7 +104,7 @@ export type BlokComponentStateStore = {
|
|
|
95
104
|
export declare const componentStateStore: (scope: BlokPersistScope, store?: KeyedStore<KeptComponentState>, delay?: number) => BlokComponentStateStore;
|
|
96
105
|
export declare const openBlokPersistence: (options: {
|
|
97
106
|
scope: BlokPersistScope;
|
|
98
|
-
/** The blok's
|
|
107
|
+
/** The blok's resolved locals (by node); those with `persist` are kept. */
|
|
99
108
|
locals: readonly BlokLocal[];
|
|
100
109
|
store?: KeyedStore<KeptLocals>;
|
|
101
110
|
componentStore?: KeyedStore<KeptComponentState>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../src/renderer/persist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAC,UAAU,EAAoB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../src/renderer/persist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAC,UAAU,EAAoB,MAAM,qBAAqB,CAAC;AAKvE,OAAO,EAAgD,KAAK,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAE/F;;;;;;;;;;;;;;;;;;GAkBG;AAEH,sDAAsD;AACtD,MAAM,MAAM,eAAe,GAAG;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAC,CAAC;AAEnG;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAAC;IAC3C,OAAO,CAAC,EAAE,SAAS,eAAe,EAAE,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,G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