@arkitektio/bsx 0.0.0-stage → 0.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 +36 -2
- package/dist/bsx/analyze.d.ts +30 -0
- package/dist/bsx/analyze.d.ts.map +1 -0
- package/dist/bsx/analyze.js +47 -0
- package/dist/bsx/analyze.js.map +1 -0
- package/dist/bsx/expr.d.ts +116 -0
- package/dist/bsx/expr.d.ts.map +1 -0
- package/dist/bsx/expr.js +476 -0
- package/dist/bsx/expr.js.map +1 -0
- package/dist/bsx/index.d.ts +9 -0
- package/dist/bsx/index.d.ts.map +1 -0
- package/dist/bsx/index.js +9 -0
- package/dist/bsx/index.js.map +1 -0
- package/dist/bsx/infer.d.ts +77 -0
- package/dist/bsx/infer.d.ts.map +1 -0
- package/dist/bsx/infer.js +279 -0
- package/dist/bsx/infer.js.map +1 -0
- package/dist/bsx/language.d.ts +106 -0
- package/dist/bsx/language.d.ts.map +1 -0
- package/dist/bsx/language.js +717 -0
- package/dist/bsx/language.js.map +1 -0
- package/dist/bsx/parse.d.ts +77 -0
- package/dist/bsx/parse.d.ts.map +1 -0
- package/dist/bsx/parse.js +801 -0
- package/dist/bsx/parse.js.map +1 -0
- package/dist/bsx/partial.d.ts +37 -0
- package/dist/bsx/partial.d.ts.map +1 -0
- package/dist/bsx/partial.js +184 -0
- package/dist/bsx/partial.js.map +1 -0
- package/dist/bsx/print.d.ts +21 -0
- package/dist/bsx/print.d.ts.map +1 -0
- package/dist/bsx/print.js +407 -0
- package/dist/bsx/print.js.map +1 -0
- package/dist/bsx/references.d.ts +155 -0
- package/dist/bsx/references.d.ts.map +1 -0
- package/dist/bsx/references.js +971 -0
- package/dist/bsx/references.js.map +1 -0
- package/dist/bsx/source.d.ts +34 -0
- package/dist/bsx/source.d.ts.map +1 -0
- package/dist/bsx/source.js +53 -0
- package/dist/bsx/source.js.map +1 -0
- package/dist/cache/keyedStore.d.ts +44 -0
- package/dist/cache/keyedStore.d.ts.map +1 -0
- package/dist/cache/keyedStore.js +84 -0
- package/dist/cache/keyedStore.js.map +1 -0
- package/dist/editor/BsxEditor.d.ts +19 -0
- package/dist/editor/BsxEditor.d.ts.map +1 -0
- package/dist/editor/BsxEditor.js +214 -0
- package/dist/editor/BsxEditor.js.map +1 -0
- package/dist/editor.d.ts +2 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +3 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/logo/CachedBlokLogo.d.ts +38 -0
- package/dist/logo/CachedBlokLogo.d.ts.map +1 -0
- package/dist/logo/CachedBlokLogo.js +84 -0
- package/dist/logo/CachedBlokLogo.js.map +1 -0
- package/dist/logo/SourceLogo.d.ts +8 -0
- package/dist/logo/SourceLogo.d.ts.map +1 -0
- package/dist/logo/SourceLogo.js +40 -0
- package/dist/logo/SourceLogo.js.map +1 -0
- package/dist/logo/actionLogoSource.d.ts +18 -0
- package/dist/logo/actionLogoSource.d.ts.map +1 -0
- package/dist/logo/actionLogoSource.js +20 -0
- package/dist/logo/actionLogoSource.js.map +1 -0
- package/dist/logo/demo.d.ts +8 -0
- package/dist/logo/demo.d.ts.map +1 -0
- package/dist/logo/demo.js +20 -0
- package/dist/logo/demo.js.map +1 -0
- package/dist/logo/logoCache.d.ts +44 -0
- package/dist/logo/logoCache.d.ts.map +1 -0
- package/dist/logo/logoCache.js +121 -0
- package/dist/logo/logoCache.js.map +1 -0
- package/dist/platform.d.ts +83 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +52 -0
- package/dist/platform.js.map +1 -0
- package/dist/preview/CachedBlokPreview.d.ts +49 -0
- package/dist/preview/CachedBlokPreview.d.ts.map +1 -0
- package/dist/preview/CachedBlokPreview.js +200 -0
- package/dist/preview/CachedBlokPreview.js.map +1 -0
- package/dist/preview/previewCache.d.ts +18 -0
- package/dist/preview/previewCache.d.ts.map +1 -0
- package/dist/preview/previewCache.js +50 -0
- package/dist/preview/previewCache.js.map +1 -0
- package/dist/preview/queue.d.ts +17 -0
- package/dist/preview/queue.d.ts.map +1 -0
- package/dist/preview/queue.js +67 -0
- package/dist/preview/queue.js.map +1 -0
- package/dist/preview/snapshot.d.ts +40 -0
- package/dist/preview/snapshot.d.ts.map +1 -0
- package/dist/preview/snapshot.js +211 -0
- package/dist/preview/snapshot.js.map +1 -0
- package/dist/preview/snapshotMode.d.ts +31 -0
- package/dist/preview/snapshotMode.d.ts.map +1 -0
- package/dist/preview/snapshotMode.js +19 -0
- package/dist/preview/snapshotMode.js.map +1 -0
- package/dist/renderer/BlokComponentHost.d.ts +46 -0
- package/dist/renderer/BlokComponentHost.d.ts.map +1 -0
- package/dist/renderer/BlokComponentHost.js +83 -0
- package/dist/renderer/BlokComponentHost.js.map +1 -0
- package/dist/renderer/BlokDebugState.d.ts +7 -0
- package/dist/renderer/BlokDebugState.d.ts.map +1 -0
- package/dist/renderer/BlokDebugState.js +19 -0
- package/dist/renderer/BlokDebugState.js.map +1 -0
- package/dist/renderer/BlokRenderer.d.ts +57 -0
- package/dist/renderer/BlokRenderer.d.ts.map +1 -0
- package/dist/renderer/BlokRenderer.js +136 -0
- package/dist/renderer/BlokRenderer.js.map +1 -0
- package/dist/renderer/assets.d.ts +85 -0
- package/dist/renderer/assets.d.ts.map +1 -0
- package/dist/renderer/assets.js +99 -0
- package/dist/renderer/assets.js.map +1 -0
- package/dist/renderer/baseCatalog.d.ts +12 -0
- package/dist/renderer/baseCatalog.d.ts.map +1 -0
- package/dist/renderer/baseCatalog.js +13 -0
- package/dist/renderer/baseCatalog.js.map +1 -0
- package/dist/renderer/base_v1.json +1541 -0
- package/dist/renderer/bloks/control.d.ts +25 -0
- package/dist/renderer/bloks/control.d.ts.map +1 -0
- package/dist/renderer/bloks/control.js +294 -0
- package/dist/renderer/bloks/control.js.map +1 -0
- package/dist/renderer/bloks/data.d.ts +28 -0
- package/dist/renderer/bloks/data.d.ts.map +1 -0
- package/dist/renderer/bloks/data.js +409 -0
- package/dist/renderer/bloks/data.js.map +1 -0
- package/dist/renderer/bloks/feedback.d.ts +9 -0
- package/dist/renderer/bloks/feedback.d.ts.map +1 -0
- package/dist/renderer/bloks/feedback.js +128 -0
- package/dist/renderer/bloks/feedback.js.map +1 -0
- package/dist/renderer/bloks/forms.d.ts +43 -0
- package/dist/renderer/bloks/forms.d.ts.map +1 -0
- package/dist/renderer/bloks/forms.js +777 -0
- package/dist/renderer/bloks/forms.js.map +1 -0
- package/dist/renderer/bloks/html.d.ts +10 -0
- package/dist/renderer/bloks/html.d.ts.map +1 -0
- package/dist/renderer/bloks/html.js +99 -0
- package/dist/renderer/bloks/html.js.map +1 -0
- package/dist/renderer/bloks/icons.d.ts +263 -0
- package/dist/renderer/bloks/icons.d.ts.map +1 -0
- package/dist/renderer/bloks/icons.js +173 -0
- package/dist/renderer/bloks/icons.js.map +1 -0
- package/dist/renderer/bloks/index.d.ts +19 -0
- package/dist/renderer/bloks/index.d.ts.map +1 -0
- package/dist/renderer/bloks/index.js +30 -0
- package/dist/renderer/bloks/index.js.map +1 -0
- package/dist/renderer/bloks/inspector/Inspector.d.ts +2 -0
- package/dist/renderer/bloks/inspector/Inspector.d.ts.map +1 -0
- package/dist/renderer/bloks/inspector/Inspector.js +14 -0
- package/dist/renderer/bloks/inspector/Inspector.js.map +1 -0
- package/dist/renderer/bloks/layout.d.ts +16 -0
- package/dist/renderer/bloks/layout.d.ts.map +1 -0
- package/dist/renderer/bloks/layout.js +345 -0
- package/dist/renderer/bloks/layout.js.map +1 -0
- package/dist/renderer/bloks/logo/index.d.ts +26 -0
- package/dist/renderer/bloks/logo/index.d.ts.map +1 -0
- package/dist/renderer/bloks/logo/index.js +361 -0
- package/dist/renderer/bloks/logo/index.js.map +1 -0
- package/dist/renderer/bloks/logo/logo.fixture.json +323 -0
- package/dist/renderer/bloks/navigation.d.ts +29 -0
- package/dist/renderer/bloks/navigation.d.ts.map +1 -0
- package/dist/renderer/bloks/navigation.js +421 -0
- package/dist/renderer/bloks/navigation.js.map +1 -0
- package/dist/renderer/bloks/overlays.d.ts +56 -0
- package/dist/renderer/bloks/overlays.d.ts.map +1 -0
- package/dist/renderer/bloks/overlays.js +391 -0
- package/dist/renderer/bloks/overlays.js.map +1 -0
- package/dist/renderer/bloks/run/components.d.ts +5 -0
- package/dist/renderer/bloks/run/components.d.ts.map +1 -0
- package/dist/renderer/bloks/run/components.js +121 -0
- package/dist/renderer/bloks/run/components.js.map +1 -0
- package/dist/renderer/bloks/run/host.d.ts +38 -0
- package/dist/renderer/bloks/run/host.d.ts.map +1 -0
- package/dist/renderer/bloks/run/host.js +21 -0
- package/dist/renderer/bloks/run/host.js.map +1 -0
- package/dist/renderer/bloks/run/index.d.ts +4 -0
- package/dist/renderer/bloks/run/index.d.ts.map +1 -0
- package/dist/renderer/bloks/run/index.js +4 -0
- package/dist/renderer/bloks/run/index.js.map +1 -0
- package/dist/renderer/bloks/run/math.d.ts +50 -0
- package/dist/renderer/bloks/run/math.d.ts.map +1 -0
- package/dist/renderer/bloks/run/math.js +79 -0
- package/dist/renderer/bloks/run/math.js.map +1 -0
- package/dist/renderer/bloks/scene/Model.d.ts +3 -0
- package/dist/renderer/bloks/scene/Model.d.ts.map +1 -0
- package/dist/renderer/bloks/scene/Model.js +367 -0
- package/dist/renderer/bloks/scene/Model.js.map +1 -0
- package/dist/renderer/bloks/scene/Scene.d.ts +46 -0
- package/dist/renderer/bloks/scene/Scene.d.ts.map +1 -0
- package/dist/renderer/bloks/scene/Scene.js +467 -0
- package/dist/renderer/bloks/scene/Scene.js.map +1 -0
- package/dist/renderer/bloks/scene/Transform.d.ts +2 -0
- package/dist/renderer/bloks/scene/Transform.d.ts.map +1 -0
- package/dist/renderer/bloks/scene/Transform.js +83 -0
- package/dist/renderer/bloks/scene/Transform.js.map +1 -0
- package/dist/renderer/bloks/scene/bindings.d.ts +9 -0
- package/dist/renderer/bloks/scene/bindings.d.ts.map +1 -0
- package/dist/renderer/bloks/scene/bindings.js +387 -0
- package/dist/renderer/bloks/scene/bindings.js.map +1 -0
- package/dist/renderer/bloks/scene/colour.d.ts +23 -0
- package/dist/renderer/bloks/scene/colour.d.ts.map +1 -0
- package/dist/renderer/bloks/scene/colour.js +45 -0
- package/dist/renderer/bloks/scene/colour.js.map +1 -0
- package/dist/renderer/bloks/scene/context.d.ts +115 -0
- package/dist/renderer/bloks/scene/context.d.ts.map +1 -0
- package/dist/renderer/bloks/scene/context.js +120 -0
- package/dist/renderer/bloks/scene/context.js.map +1 -0
- package/dist/renderer/bloks/scene/host.d.ts +36 -0
- package/dist/renderer/bloks/scene/host.d.ts.map +1 -0
- package/dist/renderer/bloks/scene/host.js +41 -0
- package/dist/renderer/bloks/scene/host.js.map +1 -0
- package/dist/renderer/bloks/scene/index.d.ts +10 -0
- package/dist/renderer/bloks/scene/index.d.ts.map +1 -0
- package/dist/renderer/bloks/scene/index.js +30 -0
- package/dist/renderer/bloks/scene/index.js.map +1 -0
- package/dist/renderer/bloks/scene/interaction.d.ts +3 -0
- package/dist/renderer/bloks/scene/interaction.d.ts.map +1 -0
- package/dist/renderer/bloks/scene/interaction.js +166 -0
- package/dist/renderer/bloks/scene/interaction.js.map +1 -0
- package/dist/renderer/bloks/scene/loadModel.d.ts +35 -0
- package/dist/renderer/bloks/scene/loadModel.d.ts.map +1 -0
- package/dist/renderer/bloks/scene/loadModel.js +106 -0
- package/dist/renderer/bloks/scene/loadModel.js.map +1 -0
- package/dist/renderer/bloks/scene/scene.fixture.json +203 -0
- package/dist/renderer/bloks/scene/scope.fixture.glb +0 -0
- package/dist/renderer/bloks/shared/index.d.ts +6 -0
- package/dist/renderer/bloks/shared/index.d.ts.map +1 -0
- package/dist/renderer/bloks/shared/index.js +6 -0
- package/dist/renderer/bloks/shared/index.js.map +1 -0
- package/dist/renderer/bloks/shared/props.d.ts +72 -0
- package/dist/renderer/bloks/shared/props.d.ts.map +1 -0
- package/dist/renderer/bloks/shared/props.js +152 -0
- package/dist/renderer/bloks/shared/props.js.map +1 -0
- package/dist/renderer/bloks/shared/render.d.ts +20 -0
- package/dist/renderer/bloks/shared/render.d.ts.map +1 -0
- package/dist/renderer/bloks/shared/render.js +42 -0
- package/dist/renderer/bloks/shared/render.js.map +1 -0
- package/dist/renderer/bloks/shared/schemas.d.ts +226 -0
- package/dist/renderer/bloks/shared/schemas.d.ts.map +1 -0
- package/dist/renderer/bloks/shared/schemas.js +174 -0
- package/dist/renderer/bloks/shared/schemas.js.map +1 -0
- package/dist/renderer/bloks/shared/state.d.ts +40 -0
- package/dist/renderer/bloks/shared/state.d.ts.map +1 -0
- package/dist/renderer/bloks/shared/state.js +49 -0
- package/dist/renderer/bloks/shared/state.js.map +1 -0
- package/dist/renderer/bloks/shared/throttle.d.ts +17 -0
- package/dist/renderer/bloks/shared/throttle.d.ts.map +1 -0
- package/dist/renderer/bloks/shared/throttle.js +38 -0
- package/dist/renderer/bloks/shared/throttle.js.map +1 -0
- package/dist/renderer/bloks/testing.d.ts +29 -0
- package/dist/renderer/bloks/testing.d.ts.map +1 -0
- package/dist/renderer/bloks/testing.js +32 -0
- package/dist/renderer/bloks/testing.js.map +1 -0
- package/dist/renderer/bloks/toast.d.ts +32 -0
- package/dist/renderer/bloks/toast.d.ts.map +1 -0
- package/dist/renderer/bloks/toast.js +89 -0
- package/dist/renderer/bloks/toast.js.map +1 -0
- package/dist/renderer/bloks/typography.d.ts +25 -0
- package/dist/renderer/bloks/typography.d.ts.map +1 -0
- package/dist/renderer/bloks/typography.js +188 -0
- package/dist/renderer/bloks/typography.js.map +1 -0
- package/dist/renderer/catalog.d.ts +42 -0
- package/dist/renderer/catalog.d.ts.map +1 -0
- package/dist/renderer/catalog.js +83 -0
- package/dist/renderer/catalog.js.map +1 -0
- package/dist/renderer/declarations.d.ts +102 -0
- package/dist/renderer/declarations.d.ts.map +1 -0
- package/dist/renderer/declarations.js +159 -0
- package/dist/renderer/declarations.js.map +1 -0
- package/dist/renderer/functions/argumentSchemas.d.ts +19 -0
- package/dist/renderer/functions/argumentSchemas.d.ts.map +1 -0
- package/dist/renderer/functions/argumentSchemas.js +35 -0
- package/dist/renderer/functions/argumentSchemas.js.map +1 -0
- package/dist/renderer/functions/base.d.ts +3 -0
- package/dist/renderer/functions/base.d.ts.map +1 -0
- package/dist/renderer/functions/base.js +159 -0
- package/dist/renderer/functions/base.js.map +1 -0
- package/dist/renderer/functions/coerce.d.ts +2 -0
- package/dist/renderer/functions/coerce.d.ts.map +1 -0
- package/dist/renderer/functions/coerce.js +73 -0
- package/dist/renderer/functions/coerce.js.map +1 -0
- package/dist/renderer/functions/effects.d.ts +4 -0
- package/dist/renderer/functions/effects.d.ts.map +1 -0
- package/dist/renderer/functions/effects.js +102 -0
- package/dist/renderer/functions/effects.js.map +1 -0
- package/dist/renderer/functions/format.d.ts +2 -0
- package/dist/renderer/functions/format.d.ts.map +1 -0
- package/dist/renderer/functions/format.js +134 -0
- package/dist/renderer/functions/format.js.map +1 -0
- package/dist/renderer/functions/index.d.ts +3 -0
- package/dist/renderer/functions/index.d.ts.map +1 -0
- package/dist/renderer/functions/index.js +4 -0
- package/dist/renderer/functions/index.js.map +1 -0
- package/dist/renderer/functions/lists.d.ts +2 -0
- package/dist/renderer/functions/lists.d.ts.map +1 -0
- package/dist/renderer/functions/lists.js +139 -0
- package/dist/renderer/functions/lists.js.map +1 -0
- package/dist/renderer/functions/logic.d.ts +3 -0
- package/dist/renderer/functions/logic.d.ts.map +1 -0
- package/dist/renderer/functions/logic.js +37 -0
- package/dist/renderer/functions/logic.js.map +1 -0
- package/dist/renderer/functions/math.d.ts +4 -0
- package/dist/renderer/functions/math.d.ts.map +1 -0
- package/dist/renderer/functions/math.js +61 -0
- package/dist/renderer/functions/math.js.map +1 -0
- package/dist/renderer/functions/objects.d.ts +2 -0
- package/dist/renderer/functions/objects.d.ts.map +1 -0
- package/dist/renderer/functions/objects.js +42 -0
- package/dist/renderer/functions/objects.js.map +1 -0
- package/dist/renderer/functions/strings.d.ts +4 -0
- package/dist/renderer/functions/strings.d.ts.map +1 -0
- package/dist/renderer/functions/strings.js +115 -0
- package/dist/renderer/functions/strings.js.map +1 -0
- package/dist/renderer/functions/v2/handler.d.ts +9 -0
- package/dist/renderer/functions/v2/handler.d.ts.map +1 -0
- package/dist/renderer/functions/v2/handler.js +9 -0
- package/dist/renderer/functions/v2/handler.js.map +1 -0
- package/dist/renderer/functions/v2/index.d.ts +41 -0
- package/dist/renderer/functions/v2/index.d.ts.map +1 -0
- package/dist/renderer/functions/v2/index.js +602 -0
- package/dist/renderer/functions/v2/index.js.map +1 -0
- package/dist/renderer/modules.d.ts +21 -0
- package/dist/renderer/modules.d.ts.map +1 -0
- package/dist/renderer/modules.js +41 -0
- package/dist/renderer/modules.js.map +1 -0
- package/dist/renderer/persist.d.ts +121 -0
- package/dist/renderer/persist.d.ts.map +1 -0
- package/dist/renderer/persist.js +201 -0
- package/dist/renderer/persist.js.map +1 -0
- package/dist/renderer/runtime/checks.d.ts +13 -0
- package/dist/renderer/runtime/checks.d.ts.map +1 -0
- package/dist/renderer/runtime/checks.js +132 -0
- package/dist/renderer/runtime/checks.js.map +1 -0
- package/dist/renderer/runtime/components.d.ts +118 -0
- package/dist/renderer/runtime/components.d.ts.map +1 -0
- package/dist/renderer/runtime/components.js +158 -0
- package/dist/renderer/runtime/components.js.map +1 -0
- package/dist/renderer/runtime/context.d.ts +43 -0
- package/dist/renderer/runtime/context.d.ts.map +1 -0
- package/dist/renderer/runtime/context.js +286 -0
- package/dist/renderer/runtime/context.js.map +1 -0
- package/dist/renderer/runtime/functions.d.ts +36 -0
- package/dist/renderer/runtime/functions.d.ts.map +1 -0
- package/dist/renderer/runtime/functions.js +37 -0
- package/dist/renderer/runtime/functions.js.map +1 -0
- package/dist/renderer/runtime/hooks.d.ts +138 -0
- package/dist/renderer/runtime/hooks.d.ts.map +1 -0
- package/dist/renderer/runtime/hooks.js +535 -0
- package/dist/renderer/runtime/hooks.js.map +1 -0
- package/dist/renderer/runtime/index.d.ts +21 -0
- package/dist/renderer/runtime/index.d.ts.map +1 -0
- package/dist/renderer/runtime/index.js +26 -0
- package/dist/renderer/runtime/index.js.map +1 -0
- package/dist/renderer/runtime/nodeState.d.ts +34 -0
- package/dist/renderer/runtime/nodeState.d.ts.map +1 -0
- package/dist/renderer/runtime/nodeState.js +13 -0
- package/dist/renderer/runtime/nodeState.js.map +1 -0
- package/dist/renderer/runtime/normalize.d.ts +21 -0
- package/dist/renderer/runtime/normalize.d.ts.map +1 -0
- package/dist/renderer/runtime/normalize.js +107 -0
- package/dist/renderer/runtime/normalize.js.map +1 -0
- package/dist/renderer/runtime/port.d.ts +24 -0
- package/dist/renderer/runtime/port.d.ts.map +1 -0
- package/dist/renderer/runtime/port.js +5 -0
- package/dist/renderer/runtime/port.js.map +1 -0
- package/dist/renderer/runtime/preflight.d.ts +20 -0
- package/dist/renderer/runtime/preflight.d.ts.map +1 -0
- package/dist/renderer/runtime/preflight.js +195 -0
- package/dist/renderer/runtime/preflight.js.map +1 -0
- package/dist/renderer/runtime/reads.d.ts +101 -0
- package/dist/renderer/runtime/reads.d.ts.map +1 -0
- package/dist/renderer/runtime/reads.js +284 -0
- package/dist/renderer/runtime/reads.js.map +1 -0
- package/dist/renderer/runtime/resolution.d.ts +71 -0
- package/dist/renderer/runtime/resolution.d.ts.map +1 -0
- package/dist/renderer/runtime/resolution.js +403 -0
- package/dist/renderer/runtime/resolution.js.map +1 -0
- package/dist/renderer/runtime/resource.d.ts +71 -0
- package/dist/renderer/runtime/resource.d.ts.map +1 -0
- package/dist/renderer/runtime/resource.js +138 -0
- package/dist/renderer/runtime/resource.js.map +1 -0
- package/dist/renderer/runtime/schemas.d.ts +119 -0
- package/dist/renderer/runtime/schemas.d.ts.map +1 -0
- package/dist/renderer/runtime/schemas.js +139 -0
- package/dist/renderer/runtime/schemas.js.map +1 -0
- package/dist/renderer/runtime/scope.d.ts +41 -0
- package/dist/renderer/runtime/scope.d.ts.map +1 -0
- package/dist/renderer/runtime/scope.js +95 -0
- package/dist/renderer/runtime/scope.js.map +1 -0
- package/dist/renderer/runtime/status.d.ts +35 -0
- package/dist/renderer/runtime/status.d.ts.map +1 -0
- package/dist/renderer/runtime/status.js +23 -0
- package/dist/renderer/runtime/status.js.map +1 -0
- package/dist/renderer/runtime/task.d.ts +63 -0
- package/dist/renderer/runtime/task.d.ts.map +1 -0
- package/dist/renderer/runtime/task.js +99 -0
- package/dist/renderer/runtime/task.js.map +1 -0
- package/dist/renderer/runtime/tree.d.ts +33 -0
- package/dist/renderer/runtime/tree.d.ts.map +1 -0
- package/dist/renderer/runtime/tree.js +59 -0
- package/dist/renderer/runtime/tree.js.map +1 -0
- package/dist/renderer/runtime/types.d.ts +247 -0
- package/dist/renderer/runtime/types.d.ts.map +1 -0
- package/dist/renderer/runtime/types.js +4 -0
- package/dist/renderer/runtime/types.js.map +1 -0
- package/dist/renderer/runtime/utils.d.ts +13 -0
- package/dist/renderer/runtime/utils.d.ts.map +1 -0
- package/dist/renderer/runtime/utils.js +48 -0
- package/dist/renderer/runtime/utils.js.map +1 -0
- package/dist/renderer/runtime/viewer.d.ts +17 -0
- package/dist/renderer/runtime/viewer.d.ts.map +1 -0
- package/dist/renderer/runtime/viewer.js +15 -0
- package/dist/renderer/runtime/viewer.js.map +1 -0
- package/dist/runtime.d.ts +9 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +10 -0
- package/dist/runtime.js.map +1 -0
- package/dist/scene.d.ts +3 -0
- package/dist/scene.d.ts.map +1 -0
- package/dist/scene.js +4 -0
- package/dist/scene.js.map +1 -0
- package/dist/spec/bsx_v2.json +11380 -0
- package/dist/spec/catalogs/base@2.json +210 -0
- package/dist/spec/catalogs/base@2.json.js +210 -0
- package/dist/spec/catalogs/html@1.json +308 -0
- package/dist/spec/catalogs/html@1.json.js +308 -0
- package/dist/spec/catalogs/logo@1.json +1673 -0
- package/dist/spec/catalogs/logo@1.json.js +1673 -0
- package/dist/spec/catalogs/scene@1.json +806 -0
- package/dist/spec/catalogs/scene@1.json.js +806 -0
- package/dist/spec/catalogs/structure@1.json +185 -0
- package/dist/spec/catalogs/structure@1.json.js +185 -0
- package/dist/spec/catalogs/ui@1.json +3696 -0
- package/dist/spec/catalogs/ui@1.json.js +3696 -0
- package/dist/spec/catalogs.d.ts +101 -0
- package/dist/spec/catalogs.d.ts.map +1 -0
- package/dist/spec/catalogs.js +131 -0
- package/dist/spec/catalogs.js.map +1 -0
- package/dist/spec/locals.d.ts +14 -0
- package/dist/spec/locals.d.ts.map +1 -0
- package/dist/spec/locals.js +29 -0
- package/dist/spec/locals.js.map +1 -0
- package/dist/spec/modules/orkestrator.json +2755 -0
- package/dist/spec/modules/orkestrator.json.js +2755 -0
- package/dist/spec/vocabulary.d.ts +209 -0
- package/dist/spec/vocabulary.d.ts.map +1 -0
- package/dist/spec/vocabulary.js +307 -0
- package/dist/spec/vocabulary.js.map +1 -0
- package/dist/spec/vocabulary.json +411 -0
- package/dist/spec/vocabulary.json.js +411 -0
- package/dist/tailwind/defaultTheme.d.ts +3 -0
- package/dist/tailwind/defaultTheme.d.ts.map +1 -0
- package/dist/tailwind/defaultTheme.js +4 -0
- package/dist/tailwind/defaultTheme.js.map +1 -0
- package/dist/tailwind/runtimeTailwind.d.ts +14 -0
- package/dist/tailwind/runtimeTailwind.d.ts.map +1 -0
- package/dist/tailwind/runtimeTailwind.js +124 -0
- package/dist/tailwind/runtimeTailwind.js.map +1 -0
- package/dist/tailwind/theme.css +137 -0
- package/dist/tailwind/useBlokTailwind.d.ts +5 -0
- package/dist/tailwind/useBlokTailwind.d.ts.map +1 -0
- package/dist/tailwind/useBlokTailwind.js +74 -0
- package/dist/tailwind/useBlokTailwind.js.map +1 -0
- package/dist/tailwind.d.ts +3 -0
- package/dist/tailwind.d.ts.map +1 -0
- package/dist/tailwind.js +4 -0
- package/dist/tailwind.js.map +1 -0
- package/dist/vendor/core/data/scene/camera/navigateButtons.d.ts +15 -0
- package/dist/vendor/core/data/scene/camera/navigateButtons.d.ts.map +1 -0
- package/dist/vendor/core/data/scene/camera/navigateButtons.js +15 -0
- package/dist/vendor/core/data/scene/camera/navigateButtons.js.map +1 -0
- package/dist/vendor/core/dialogs/PageDialogHost.d.ts +5 -0
- package/dist/vendor/core/dialogs/PageDialogHost.d.ts.map +1 -0
- package/dist/vendor/core/dialogs/PageDialogHost.js +32 -0
- package/dist/vendor/core/dialogs/PageDialogHost.js.map +1 -0
- package/dist/vendor/core/model/affine.d.ts +44 -0
- package/dist/vendor/core/model/affine.d.ts.map +1 -0
- package/dist/vendor/core/model/affine.js +94 -0
- package/dist/vendor/core/model/affine.js.map +1 -0
- package/dist/vendor/core/model/glb.d.ts +75 -0
- package/dist/vendor/core/model/glb.d.ts.map +1 -0
- package/dist/vendor/core/model/glb.js +478 -0
- package/dist/vendor/core/model/glb.js.map +1 -0
- package/dist/vendor/core/model/joints.d.ts +26 -0
- package/dist/vendor/core/model/joints.d.ts.map +1 -0
- package/dist/vendor/core/model/joints.js +44 -0
- package/dist/vendor/core/model/joints.js.map +1 -0
- package/dist/vendor/core/model/motion.d.ts +65 -0
- package/dist/vendor/core/model/motion.d.ts.map +1 -0
- package/dist/vendor/core/model/motion.js +89 -0
- package/dist/vendor/core/model/motion.js.map +1 -0
- package/dist/vendor/core/model/testing.d.ts +7 -0
- package/dist/vendor/core/model/testing.d.ts.map +1 -0
- package/dist/vendor/core/model/testing.js +54 -0
- package/dist/vendor/core/model/testing.js.map +1 -0
- package/dist/vendor/core/model/units.d.ts +21 -0
- package/dist/vendor/core/model/units.d.ts.map +1 -0
- package/dist/vendor/core/model/units.js +107 -0
- package/dist/vendor/core/model/units.js.map +1 -0
- package/dist/vendor/core/model/writers.d.ts +24 -0
- package/dist/vendor/core/model/writers.d.ts.map +1 -0
- package/dist/vendor/core/model/writers.js +45 -0
- package/dist/vendor/core/model/writers.js.map +1 -0
- package/dist/vendor/core/ui/AsyncBoundary.d.ts +14 -0
- package/dist/vendor/core/ui/AsyncBoundary.d.ts.map +1 -0
- package/dist/vendor/core/ui/AsyncBoundary.js +42 -0
- package/dist/vendor/core/ui/AsyncBoundary.js.map +1 -0
- package/dist/vendor/core/ui/ChromeSurface.d.ts +16 -0
- package/dist/vendor/core/ui/ChromeSurface.d.ts.map +1 -0
- package/dist/vendor/core/ui/ChromeSurface.js +44 -0
- package/dist/vendor/core/ui/ChromeSurface.js.map +1 -0
- package/dist/vendor/core/ui/accordion.d.ts +8 -0
- package/dist/vendor/core/ui/accordion.d.ts.map +1 -0
- package/dist/vendor/core/ui/accordion.js +19 -0
- package/dist/vendor/core/ui/accordion.js.map +1 -0
- package/dist/vendor/core/ui/actionPlan.d.ts +54 -0
- package/dist/vendor/core/ui/actionPlan.d.ts.map +1 -0
- package/dist/vendor/core/ui/actionPlan.js +101 -0
- package/dist/vendor/core/ui/actionPlan.js.map +1 -0
- package/dist/vendor/core/ui/alert-dialog.d.ts +19 -0
- package/dist/vendor/core/ui/alert-dialog.d.ts.map +1 -0
- package/dist/vendor/core/ui/alert-dialog.js +50 -0
- package/dist/vendor/core/ui/alert-dialog.js.map +1 -0
- package/dist/vendor/core/ui/alert.d.ts +11 -0
- package/dist/vendor/core/ui/alert.d.ts.map +1 -0
- package/dist/vendor/core/ui/alert.js +29 -0
- package/dist/vendor/core/ui/alert.js.map +1 -0
- package/dist/vendor/core/ui/aspect-ratio.d.ts +4 -0
- package/dist/vendor/core/ui/aspect-ratio.d.ts.map +1 -0
- package/dist/vendor/core/ui/aspect-ratio.js +8 -0
- package/dist/vendor/core/ui/aspect-ratio.js.map +1 -0
- package/dist/vendor/core/ui/avatar.d.ts +12 -0
- package/dist/vendor/core/ui/avatar.d.ts.map +1 -0
- package/dist/vendor/core/ui/avatar.js +24 -0
- package/dist/vendor/core/ui/avatar.js.map +1 -0
- package/dist/vendor/core/ui/badge.d.ts +10 -0
- package/dist/vendor/core/ui/badge.d.ts.map +1 -0
- package/dist/vendor/core/ui/badge.js +26 -0
- package/dist/vendor/core/ui/badge.js.map +1 -0
- package/dist/vendor/core/ui/bento-grid.d.ts +107 -0
- package/dist/vendor/core/ui/bento-grid.d.ts.map +1 -0
- package/dist/vendor/core/ui/bento-grid.js +631 -0
- package/dist/vendor/core/ui/bento-grid.js.map +1 -0
- package/dist/vendor/core/ui/breadcrumb.d.ts +12 -0
- package/dist/vendor/core/ui/breadcrumb.d.ts.map +1 -0
- package/dist/vendor/core/ui/breadcrumb.js +29 -0
- package/dist/vendor/core/ui/breadcrumb.js.map +1 -0
- package/dist/vendor/core/ui/button-group.d.ts +12 -0
- package/dist/vendor/core/ui/button-group.d.ts.map +1 -0
- package/dist/vendor/core/ui/button-group.js +28 -0
- package/dist/vendor/core/ui/button-group.js.map +1 -0
- package/dist/vendor/core/ui/button.d.ts +24 -0
- package/dist/vendor/core/ui/button.d.ts.map +1 -0
- package/dist/vendor/core/ui/button.js +39 -0
- package/dist/vendor/core/ui/button.js.map +1 -0
- package/dist/vendor/core/ui/calendar.d.ts +9 -0
- package/dist/vendor/core/ui/calendar.d.ts.map +1 -0
- package/dist/vendor/core/ui/calendar.js +76 -0
- package/dist/vendor/core/ui/calendar.js.map +1 -0
- package/dist/vendor/core/ui/card.d.ts +12 -0
- package/dist/vendor/core/ui/card.d.ts.map +1 -0
- package/dist/vendor/core/ui/card.js +26 -0
- package/dist/vendor/core/ui/card.js.map +1 -0
- package/dist/vendor/core/ui/carousel.d.ts +29 -0
- package/dist/vendor/core/ui/carousel.d.ts.map +1 -0
- package/dist/vendor/core/ui/carousel.js +92 -0
- package/dist/vendor/core/ui/carousel.js.map +1 -0
- package/dist/vendor/core/ui/chart.d.ts +41 -0
- package/dist/vendor/core/ui/chart.d.ts.map +1 -0
- package/dist/vendor/core/ui/chart.js +132 -0
- package/dist/vendor/core/ui/chart.js.map +1 -0
- package/dist/vendor/core/ui/checkbox.d.ts +5 -0
- package/dist/vendor/core/ui/checkbox.d.ts.map +1 -0
- package/dist/vendor/core/ui/checkbox.js +10 -0
- package/dist/vendor/core/ui/checkbox.js.map +1 -0
- package/dist/vendor/core/ui/collapsible.d.ts +6 -0
- package/dist/vendor/core/ui/collapsible.d.ts.map +1 -0
- package/dist/vendor/core/ui/collapsible.js +15 -0
- package/dist/vendor/core/ui/collapsible.js.map +1 -0
- package/dist/vendor/core/ui/context-menu.d.ts +28 -0
- package/dist/vendor/core/ui/context-menu.d.ts.map +1 -0
- package/dist/vendor/core/ui/context-menu.js +55 -0
- package/dist/vendor/core/ui/context-menu.js.map +1 -0
- package/dist/vendor/core/ui/dialog.d.ts +20 -0
- package/dist/vendor/core/ui/dialog.d.ts.map +1 -0
- package/dist/vendor/core/ui/dialog.js +44 -0
- package/dist/vendor/core/ui/dialog.js.map +1 -0
- package/dist/vendor/core/ui/drawer.d.ts +14 -0
- package/dist/vendor/core/ui/drawer.d.ts.map +1 -0
- package/dist/vendor/core/ui/drawer.js +38 -0
- package/dist/vendor/core/ui/drawer.js.map +1 -0
- package/dist/vendor/core/ui/dropdown-menu.d.ts +26 -0
- package/dist/vendor/core/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/vendor/core/ui/dropdown-menu.js +56 -0
- package/dist/vendor/core/ui/dropdown-menu.js.map +1 -0
- package/dist/vendor/core/ui/empty.d.ts +12 -0
- package/dist/vendor/core/ui/empty.d.ts.map +1 -0
- package/dist/vendor/core/ui/empty.js +34 -0
- package/dist/vendor/core/ui/empty.js.map +1 -0
- package/dist/vendor/core/ui/field.d.ts +25 -0
- package/dist/vendor/core/ui/field.d.ts.map +1 -0
- package/dist/vendor/core/ui/field.js +68 -0
- package/dist/vendor/core/ui/field.js.map +1 -0
- package/dist/vendor/core/ui/hover-card.d.ts +7 -0
- package/dist/vendor/core/ui/hover-card.d.ts.map +1 -0
- package/dist/vendor/core/ui/hover-card.js +19 -0
- package/dist/vendor/core/ui/hover-card.js.map +1 -0
- package/dist/vendor/core/ui/image.d.ts +10 -0
- package/dist/vendor/core/ui/image.d.ts.map +1 -0
- package/dist/vendor/core/ui/image.js +49 -0
- package/dist/vendor/core/ui/image.js.map +1 -0
- package/dist/vendor/core/ui/input-group.d.ts +17 -0
- package/dist/vendor/core/ui/input-group.d.ts.map +1 -0
- package/dist/vendor/core/ui/input-group.js +59 -0
- package/dist/vendor/core/ui/input-group.js.map +1 -0
- package/dist/vendor/core/ui/input-otp.d.ts +12 -0
- package/dist/vendor/core/ui/input-otp.d.ts.map +1 -0
- package/dist/vendor/core/ui/input-otp.js +21 -0
- package/dist/vendor/core/ui/input-otp.js.map +1 -0
- package/dist/vendor/core/ui/input.d.ts +4 -0
- package/dist/vendor/core/ui/input.d.ts.map +1 -0
- package/dist/vendor/core/ui/input.js +8 -0
- package/dist/vendor/core/ui/input.js.map +1 -0
- package/dist/vendor/core/ui/item.d.ts +24 -0
- package/dist/vendor/core/ui/item.d.ts.map +1 -0
- package/dist/vendor/core/ui/item.js +69 -0
- package/dist/vendor/core/ui/item.js.map +1 -0
- package/dist/vendor/core/ui/kbd.d.ts +4 -0
- package/dist/vendor/core/ui/kbd.d.ts.map +1 -0
- package/dist/vendor/core/ui/kbd.js +10 -0
- package/dist/vendor/core/ui/kbd.js.map +1 -0
- package/dist/vendor/core/ui/label.d.ts +5 -0
- package/dist/vendor/core/ui/label.d.ts.map +1 -0
- package/dist/vendor/core/ui/label.js +10 -0
- package/dist/vendor/core/ui/label.js.map +1 -0
- package/dist/vendor/core/ui/markdown.d.ts +19 -0
- package/dist/vendor/core/ui/markdown.d.ts.map +1 -0
- package/dist/vendor/core/ui/markdown.js +236 -0
- package/dist/vendor/core/ui/markdown.js.map +1 -0
- package/dist/vendor/core/ui/menubar.d.ts +27 -0
- package/dist/vendor/core/ui/menubar.d.ts.map +1 -0
- package/dist/vendor/core/ui/menubar.js +55 -0
- package/dist/vendor/core/ui/menubar.js.map +1 -0
- package/dist/vendor/core/ui/pagination.d.ts +14 -0
- package/dist/vendor/core/ui/pagination.d.ts.map +1 -0
- package/dist/vendor/core/ui/pagination.js +28 -0
- package/dist/vendor/core/ui/pagination.js.map +1 -0
- package/dist/vendor/core/ui/popover.d.ts +11 -0
- package/dist/vendor/core/ui/popover.d.ts.map +1 -0
- package/dist/vendor/core/ui/popover.js +31 -0
- package/dist/vendor/core/ui/popover.js.map +1 -0
- package/dist/vendor/core/ui/progress.d.ts +5 -0
- package/dist/vendor/core/ui/progress.d.ts.map +1 -0
- package/dist/vendor/core/ui/progress.js +9 -0
- package/dist/vendor/core/ui/progress.js.map +1 -0
- package/dist/vendor/core/ui/radio-group.d.ts +6 -0
- package/dist/vendor/core/ui/radio-group.d.ts.map +1 -0
- package/dist/vendor/core/ui/radio-group.js +14 -0
- package/dist/vendor/core/ui/radio-group.js.map +1 -0
- package/dist/vendor/core/ui/resizable.d.ts +9 -0
- package/dist/vendor/core/ui/resizable.d.ts.map +1 -0
- package/dist/vendor/core/ui/resizable.js +15 -0
- package/dist/vendor/core/ui/resizable.js.map +1 -0
- package/dist/vendor/core/ui/scroll-area.d.ts +6 -0
- package/dist/vendor/core/ui/scroll-area.d.ts.map +1 -0
- package/dist/vendor/core/ui/scroll-area.js +13 -0
- package/dist/vendor/core/ui/scroll-area.js.map +1 -0
- package/dist/vendor/core/ui/select.d.ts +16 -0
- package/dist/vendor/core/ui/select.d.ts.map +1 -0
- package/dist/vendor/core/ui/select.js +39 -0
- package/dist/vendor/core/ui/select.js.map +1 -0
- package/dist/vendor/core/ui/separator.d.ts +5 -0
- package/dist/vendor/core/ui/separator.d.ts.map +1 -0
- package/dist/vendor/core/ui/separator.js +10 -0
- package/dist/vendor/core/ui/separator.js.map +1 -0
- package/dist/vendor/core/ui/sheet.d.ts +17 -0
- package/dist/vendor/core/ui/sheet.d.ts.map +1 -0
- package/dist/vendor/core/ui/sheet.js +45 -0
- package/dist/vendor/core/ui/sheet.js.map +1 -0
- package/dist/vendor/core/ui/skeleton.d.ts +3 -0
- package/dist/vendor/core/ui/skeleton.d.ts.map +1 -0
- package/dist/vendor/core/ui/skeleton.js +7 -0
- package/dist/vendor/core/ui/skeleton.js.map +1 -0
- package/dist/vendor/core/ui/slider.d.ts +5 -0
- package/dist/vendor/core/ui/slider.d.ts.map +1 -0
- package/dist/vendor/core/ui/slider.js +14 -0
- package/dist/vendor/core/ui/slider.js.map +1 -0
- package/dist/vendor/core/ui/spinner.d.ts +3 -0
- package/dist/vendor/core/ui/spinner.d.ts.map +1 -0
- package/dist/vendor/core/ui/spinner.js +8 -0
- package/dist/vendor/core/ui/spinner.js.map +1 -0
- package/dist/vendor/core/ui/switch.d.ts +7 -0
- package/dist/vendor/core/ui/switch.d.ts.map +1 -0
- package/dist/vendor/core/ui/switch.js +9 -0
- package/dist/vendor/core/ui/switch.js.map +1 -0
- package/dist/vendor/core/ui/table.d.ts +11 -0
- package/dist/vendor/core/ui/table.d.ts.map +1 -0
- package/dist/vendor/core/ui/table.js +30 -0
- package/dist/vendor/core/ui/table.js.map +1 -0
- package/dist/vendor/core/ui/tabs.d.ts +12 -0
- package/dist/vendor/core/ui/tabs.d.ts.map +1 -0
- package/dist/vendor/core/ui/tabs.js +30 -0
- package/dist/vendor/core/ui/tabs.js.map +1 -0
- package/dist/vendor/core/ui/textarea.d.ts +4 -0
- package/dist/vendor/core/ui/textarea.d.ts.map +1 -0
- package/dist/vendor/core/ui/textarea.js +8 -0
- package/dist/vendor/core/ui/textarea.js.map +1 -0
- package/dist/vendor/core/ui/toggle-group.d.ts +11 -0
- package/dist/vendor/core/ui/toggle-group.d.ts.map +1 -0
- package/dist/vendor/core/ui/toggle-group.js +24 -0
- package/dist/vendor/core/ui/toggle-group.js.map +1 -0
- package/dist/vendor/core/ui/toggle.d.ts +12 -0
- package/dist/vendor/core/ui/toggle.d.ts.map +1 -0
- package/dist/vendor/core/ui/toggle.js +28 -0
- package/dist/vendor/core/ui/toggle.js.map +1 -0
- package/dist/vendor/core/ui/tooltip.d.ts +8 -0
- package/dist/vendor/core/ui/tooltip.d.ts.map +1 -0
- package/dist/vendor/core/ui/tooltip.js +21 -0
- package/dist/vendor/core/ui/tooltip.js.map +1 -0
- package/dist/vendor/core/ui/trigger-child.d.ts +17 -0
- package/dist/vendor/core/ui/trigger-child.d.ts.map +1 -0
- package/dist/vendor/core/ui/trigger-child.js +31 -0
- package/dist/vendor/core/ui/trigger-child.js.map +1 -0
- package/dist/vendor/core/util/hooks/useLatestRef.d.ts +10 -0
- package/dist/vendor/core/util/hooks/useLatestRef.d.ts.map +1 -0
- package/dist/vendor/core/util/hooks/useLatestRef.js +17 -0
- package/dist/vendor/core/util/hooks/useLatestRef.js.map +1 -0
- package/dist/vendor/core/util/utils.d.ts +8 -0
- package/dist/vendor/core/util/utils.d.ts.map +1 -0
- package/dist/vendor/core/util/utils.js +17 -0
- package/dist/vendor/core/util/utils.js.map +1 -0
- package/dist/web.d.ts +13 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/web.js +14 -0
- package/dist/web.js.map +1 -0
- package/package.json +188 -4
- package/src/bsx/analyze.ts +65 -0
- package/src/bsx/bsx.test.ts +111 -0
- package/src/bsx/expr.ts +541 -0
- package/src/bsx/index.ts +8 -0
- package/src/bsx/infer.test.ts +149 -0
- package/src/bsx/infer.ts +308 -0
- package/src/bsx/language.test.ts +204 -0
- package/src/bsx/language.ts +750 -0
- package/src/bsx/parse.ts +848 -0
- package/src/bsx/partial.test.ts +88 -0
- package/src/bsx/partial.ts +193 -0
- package/src/bsx/print.ts +412 -0
- package/src/bsx/references.test.ts +161 -0
- package/src/bsx/references.ts +1155 -0
- package/src/bsx/source.ts +70 -0
- package/src/cache/keyedStore.ts +122 -0
- package/src/editor/BsxEditor.tsx +252 -0
- package/src/editor.ts +2 -0
- package/src/env.d.ts +5 -0
- package/src/index.ts +6 -0
- package/src/logo/CachedBlokLogo.tsx +179 -0
- package/src/logo/SourceLogo.tsx +52 -0
- package/src/logo/actionLogoSource.ts +24 -0
- package/src/logo/demo.ts +21 -0
- package/src/logo/logoCache.test.ts +75 -0
- package/src/logo/logoCache.ts +130 -0
- package/src/platform.ts +121 -0
- package/src/preview/CachedBlokPreview.test.tsx +63 -0
- package/src/preview/CachedBlokPreview.tsx +336 -0
- package/src/preview/previewCache.test.ts +28 -0
- package/src/preview/previewCache.ts +64 -0
- package/src/preview/queue.test.ts +40 -0
- package/src/preview/queue.ts +75 -0
- package/src/preview/snapshot.test.ts +86 -0
- package/src/preview/snapshot.ts +226 -0
- package/src/preview/snapshotMode.test.tsx +45 -0
- package/src/preview/snapshotMode.tsx +45 -0
- package/src/renderer/BlokComponentHost.tsx +151 -0
- package/src/renderer/BlokDebugState.tsx +50 -0
- package/src/renderer/BlokRenderer.test.tsx +124 -0
- package/src/renderer/BlokRenderer.tsx +370 -0
- package/src/renderer/addBlokComponents.test.tsx +62 -0
- package/src/renderer/assets.test.tsx +123 -0
- package/src/renderer/assets.tsx +174 -0
- package/src/renderer/baseCatalog.ts +14 -0
- package/src/renderer/bloks/components.test.tsx +415 -0
- package/src/renderer/bloks/control.tsx +412 -0
- package/src/renderer/bloks/data.tsx +766 -0
- package/src/renderer/bloks/events.test.tsx +139 -0
- package/src/renderer/bloks/feedback.tsx +205 -0
- package/src/renderer/bloks/flow.test.tsx +201 -0
- package/src/renderer/bloks/forms.tsx +1195 -0
- package/src/renderer/bloks/html.tsx +171 -0
- package/src/renderer/bloks/icons.tsx +308 -0
- package/src/renderer/bloks/index.ts +42 -0
- package/src/renderer/bloks/inspector/Inspector.tsx +19 -0
- package/src/renderer/bloks/layout.tsx +538 -0
- package/src/renderer/bloks/logo/index.tsx +529 -0
- package/src/renderer/bloks/logo/logo.fixture.json +323 -0
- package/src/renderer/bloks/logo/logo.test.tsx +192 -0
- package/src/renderer/bloks/navigation.tsx +699 -0
- package/src/renderer/bloks/overlays.tsx +869 -0
- package/src/renderer/bloks/primitives.test.tsx +307 -0
- package/src/renderer/bloks/run/components.tsx +212 -0
- package/src/renderer/bloks/run/host.tsx +63 -0
- package/src/renderer/bloks/run/index.ts +3 -0
- package/src/renderer/bloks/run/math.test.ts +81 -0
- package/src/renderer/bloks/run/math.ts +112 -0
- package/src/renderer/bloks/run/run.test.tsx +164 -0
- package/src/renderer/bloks/scene/Model.tsx +571 -0
- package/src/renderer/bloks/scene/Scene.tsx +882 -0
- package/src/renderer/bloks/scene/Transform.tsx +116 -0
- package/src/renderer/bloks/scene/animate.test.tsx +81 -0
- package/src/renderer/bloks/scene/bindings.tsx +432 -0
- package/src/renderer/bloks/scene/colour.test.ts +47 -0
- package/src/renderer/bloks/scene/colour.ts +56 -0
- package/src/renderer/bloks/scene/context.tsx +228 -0
- package/src/renderer/bloks/scene/embedded.test.tsx +68 -0
- package/src/renderer/bloks/scene/host.tsx +84 -0
- package/src/renderer/bloks/scene/index.ts +32 -0
- package/src/renderer/bloks/scene/interaction.tsx +212 -0
- package/src/renderer/bloks/scene/loadModel.test.ts +69 -0
- package/src/renderer/bloks/scene/loadModel.ts +135 -0
- package/src/renderer/bloks/scene/scene.fixture.json +203 -0
- package/src/renderer/bloks/scene/scene.test.ts +35 -0
- package/src/renderer/bloks/scene/scope.fixture.glb +0 -0
- package/src/renderer/bloks/scene/transform.test.ts +26 -0
- package/src/renderer/bloks/shared/index.ts +5 -0
- package/src/renderer/bloks/shared/props.ts +224 -0
- package/src/renderer/bloks/shared/render.tsx +62 -0
- package/src/renderer/bloks/shared/schemas.ts +215 -0
- package/src/renderer/bloks/shared/state.ts +96 -0
- package/src/renderer/bloks/shared/throttle.test.ts +50 -0
- package/src/renderer/bloks/shared/throttle.ts +53 -0
- package/src/renderer/bloks/testing.tsx +73 -0
- package/src/renderer/bloks/time.test.tsx +78 -0
- package/src/renderer/bloks/toast.test.tsx +82 -0
- package/src/renderer/bloks/toast.tsx +132 -0
- package/src/renderer/bloks/typography.tsx +265 -0
- package/src/renderer/bloks/unavailable.test.tsx +52 -0
- package/src/renderer/catalog.tsx +97 -0
- package/src/renderer/declarations.test.ts +72 -0
- package/src/renderer/declarations.ts +285 -0
- package/src/renderer/functions/index.ts +3 -0
- package/src/renderer/functions/v2/functions.test.ts +256 -0
- package/src/renderer/functions/v2/handler.ts +11 -0
- package/src/renderer/functions/v2/index.ts +638 -0
- package/src/renderer/modules.ts +54 -0
- package/src/renderer/persist.test.ts +182 -0
- package/src/renderer/persist.ts +320 -0
- package/src/renderer/persistComponent.test.tsx +68 -0
- package/src/renderer/runtime/checks.ts +177 -0
- package/src/renderer/runtime/components.tsx +311 -0
- package/src/renderer/runtime/context.test.ts +137 -0
- package/src/renderer/runtime/context.tsx +369 -0
- package/src/renderer/runtime/functions.ts +69 -0
- package/src/renderer/runtime/hooks.ts +764 -0
- package/src/renderer/runtime/index.ts +31 -0
- package/src/renderer/runtime/nodeState.ts +43 -0
- package/src/renderer/runtime/normalize.test.ts +154 -0
- package/src/renderer/runtime/normalize.ts +121 -0
- package/src/renderer/runtime/port.tsx +24 -0
- package/src/renderer/runtime/preflight.test.ts +127 -0
- package/src/renderer/runtime/preflight.ts +264 -0
- package/src/renderer/runtime/reads.test.tsx +278 -0
- package/src/renderer/runtime/reads.tsx +448 -0
- package/src/renderer/runtime/resolution.test.ts +467 -0
- package/src/renderer/runtime/resolution.ts +531 -0
- package/src/renderer/runtime/resource.ts +196 -0
- package/src/renderer/runtime/schemas.ts +181 -0
- package/src/renderer/runtime/scope.tsx +123 -0
- package/src/renderer/runtime/status.ts +54 -0
- package/src/renderer/runtime/task.test.ts +131 -0
- package/src/renderer/runtime/task.ts +149 -0
- package/src/renderer/runtime/tree.tsx +138 -0
- package/src/renderer/runtime/types.ts +285 -0
- package/src/renderer/runtime/utils.test.ts +68 -0
- package/src/renderer/runtime/utils.ts +67 -0
- package/src/renderer/runtime/viewer.tsx +21 -0
- package/src/renderer/unbound.test.tsx +75 -0
- package/src/runtime.ts +9 -0
- package/src/scene.ts +3 -0
- package/src/spec/bsx_v2.json +11380 -0
- package/src/spec/catalogs/base@2.json +210 -0
- package/src/spec/catalogs/html@1.json +308 -0
- package/src/spec/catalogs/logo@1.json +1673 -0
- package/src/spec/catalogs/scene@1.json +806 -0
- package/src/spec/catalogs/structure@1.json +185 -0
- package/src/spec/catalogs/ui@1.json +3696 -0
- package/src/spec/catalogs.ts +210 -0
- package/src/spec/locals.ts +35 -0
- package/src/spec/modules/orkestrator.json +2755 -0
- package/src/spec/spec.test.ts +87 -0
- package/src/spec/vocabulary.json +411 -0
- package/src/spec/vocabulary.ts +514 -0
- package/src/tailwind/defaultTheme.ts +3 -0
- package/src/tailwind/runtimeTailwind.test.ts +86 -0
- package/src/tailwind/runtimeTailwind.ts +137 -0
- package/src/tailwind/theme.css +137 -0
- package/src/tailwind/useBlokTailwind.test.tsx +52 -0
- package/src/tailwind/useBlokTailwind.ts +84 -0
- package/src/tailwind.ts +3 -0
- package/src/vendor/core/data/scene/camera/navigateButtons.ts +15 -0
- package/src/vendor/core/dialogs/PageDialogHost.tsx +42 -0
- package/src/vendor/core/model/affine.ts +117 -0
- package/src/vendor/core/model/glb.ts +580 -0
- package/src/vendor/core/model/joints.ts +65 -0
- package/src/vendor/core/model/model.test.ts +241 -0
- package/src/vendor/core/model/motion.ts +134 -0
- package/src/vendor/core/model/testing.ts +57 -0
- package/src/vendor/core/model/units.ts +112 -0
- package/src/vendor/core/model/writers.ts +62 -0
- package/src/vendor/core/ui/AsyncBoundary.tsx +96 -0
- package/src/vendor/core/ui/ChromeSurface.tsx +51 -0
- package/src/vendor/core/ui/accordion.tsx +79 -0
- package/src/vendor/core/ui/actionPlan.ts +150 -0
- package/src/vendor/core/ui/alert-dialog.tsx +201 -0
- package/src/vendor/core/ui/alert.tsx +72 -0
- package/src/vendor/core/ui/aspect-ratio.tsx +11 -0
- package/src/vendor/core/ui/avatar.tsx +104 -0
- package/src/vendor/core/ui/badge.tsx +45 -0
- package/src/vendor/core/ui/bento-grid.tsx +818 -0
- package/src/vendor/core/ui/breadcrumb.tsx +119 -0
- package/src/vendor/core/ui/button-group.tsx +83 -0
- package/src/vendor/core/ui/button.tsx +82 -0
- package/src/vendor/core/ui/calendar.tsx +214 -0
- package/src/vendor/core/ui/card.tsx +94 -0
- package/src/vendor/core/ui/carousel.tsx +240 -0
- package/src/vendor/core/ui/chart.tsx +354 -0
- package/src/vendor/core/ui/checkbox.tsx +31 -0
- package/src/vendor/core/ui/collapsible.tsx +36 -0
- package/src/vendor/core/ui/context-menu.tsx +239 -0
- package/src/vendor/core/ui/dialog.tsx +165 -0
- package/src/vendor/core/ui/drawer.tsx +119 -0
- package/src/vendor/core/ui/dropdown-menu.tsx +250 -0
- package/src/vendor/core/ui/empty.tsx +99 -0
- package/src/vendor/core/ui/field.tsx +220 -0
- package/src/vendor/core/ui/hover-card.tsx +53 -0
- package/src/vendor/core/ui/image.tsx +70 -0
- package/src/vendor/core/ui/input-group.tsx +144 -0
- package/src/vendor/core/ui/input-otp.tsx +85 -0
- package/src/vendor/core/ui/input.tsx +19 -0
- package/src/vendor/core/ui/item.tsx +187 -0
- package/src/vendor/core/ui/kbd.tsx +26 -0
- package/src/vendor/core/ui/label.tsx +24 -0
- package/src/vendor/core/ui/markdown.tsx +398 -0
- package/src/vendor/core/ui/menubar.tsx +248 -0
- package/src/vendor/core/ui/pagination.tsx +132 -0
- package/src/vendor/core/ui/popover.tsx +96 -0
- package/src/vendor/core/ui/progress.tsx +29 -0
- package/src/vendor/core/ui/radio-group.tsx +45 -0
- package/src/vendor/core/ui/resizable.tsx +51 -0
- package/src/vendor/core/ui/scroll-area.tsx +55 -0
- package/src/vendor/core/ui/select.tsx +185 -0
- package/src/vendor/core/ui/separator.tsx +28 -0
- package/src/vendor/core/ui/sheet.tsx +139 -0
- package/src/vendor/core/ui/skeleton.tsx +13 -0
- package/src/vendor/core/ui/slider.tsx +57 -0
- package/src/vendor/core/ui/spinner.tsx +10 -0
- package/src/vendor/core/ui/switch.tsx +31 -0
- package/src/vendor/core/ui/table.tsx +95 -0
- package/src/vendor/core/ui/tabs.tsx +88 -0
- package/src/vendor/core/ui/textarea.tsx +18 -0
- package/src/vendor/core/ui/toggle-group.tsx +87 -0
- package/src/vendor/core/ui/toggle.tsx +46 -0
- package/src/vendor/core/ui/tooltip.tsx +64 -0
- package/src/vendor/core/ui/trigger-child.ts +35 -0
- package/src/vendor/core/util/hooks/useLatestRef.ts +17 -0
- package/src/vendor/core/util/utils.ts +18 -0
- package/src/web.ts +13 -0
|
@@ -0,0 +1,764 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {z} from 'zod';
|
|
3
|
+
import {useShallow} from 'zustand/react/shallow';
|
|
4
|
+
import {evaluateChecks, getChecksDependencyPaths, type BlokChecksState} from './checks';
|
|
5
|
+
import {statusAtPath, useBlokRuntime, useBlokRuntimeStoreApi} from './context';
|
|
6
|
+
import {
|
|
7
|
+
getActionArgumentsRuntimeDependencies,
|
|
8
|
+
getComponentPropRuntimeDependencies,
|
|
9
|
+
getPropActionCall,
|
|
10
|
+
getPropMap,
|
|
11
|
+
isCommand,
|
|
12
|
+
resolveActionArguments,
|
|
13
|
+
resolvePropValue,
|
|
14
|
+
runActionCall,
|
|
15
|
+
statusOfResult,
|
|
16
|
+
type BlokResolved,
|
|
17
|
+
} from './resolution';
|
|
18
|
+
import {isActionSchema} from './schemas';
|
|
19
|
+
import {isWritableScopedPath, readScopedPath, resolveScopedPath, useBlokScope} from './scope';
|
|
20
|
+
import {defaultBlokView} from '../../spec/catalogs';
|
|
21
|
+
import {useBlokNodeState} from './nodeState';
|
|
22
|
+
import {combineStatus, READY, type BlokSourceStatus} from './status';
|
|
23
|
+
import {bindTask} from './task';
|
|
24
|
+
import {lockedActionKey} from './types';
|
|
25
|
+
import type {
|
|
26
|
+
BlokActionArgument,
|
|
27
|
+
BlokComponentNode,
|
|
28
|
+
BlokComponentProp,
|
|
29
|
+
BlokObjectSchema,
|
|
30
|
+
BlokResolutionContext,
|
|
31
|
+
BlokRuntimeContext,
|
|
32
|
+
BlokRuntimeDependencies,
|
|
33
|
+
BlokRuntimeStore,
|
|
34
|
+
BlokScope,
|
|
35
|
+
BlokValidationState,
|
|
36
|
+
} from './types';
|
|
37
|
+
|
|
38
|
+
type BlokSchemaShape<TSchema extends BlokObjectSchema> =
|
|
39
|
+
TSchema extends z.ZodObject<infer TShape> ? TShape : never;
|
|
40
|
+
|
|
41
|
+
export type BlokPropHandle<TSchema extends z.ZodTypeAny = z.ZodTypeAny> = {
|
|
42
|
+
component: BlokComponentNode;
|
|
43
|
+
key: string;
|
|
44
|
+
schema: TSchema;
|
|
45
|
+
prop?: BlokComponentProp;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type Blok<TSchema extends BlokObjectSchema> = {
|
|
49
|
+
[TKey in keyof BlokSchemaShape<TSchema> & string]: BlokPropHandle<BlokSchemaShape<TSchema>[TKey]>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type AnyBlok = Record<string, BlokPropHandle<z.ZodTypeAny>>;
|
|
53
|
+
|
|
54
|
+
type BlokValueForKey<TBlok extends AnyBlok, TKey extends keyof TBlok & string> =
|
|
55
|
+
TBlok[TKey] extends BlokPropHandle<infer TSchema>
|
|
56
|
+
? z.output<TSchema> | undefined
|
|
57
|
+
: never;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A payload-level failure surfaced while rendering a node: an unknown catalog
|
|
61
|
+
* function, bad function arguments, or an effectful function bound to a value
|
|
62
|
+
* prop. Thrown so the enclosing `BlokNodeBoundary` renders an inline error card
|
|
63
|
+
* for that one node and leaves the rest of the surface alive.
|
|
64
|
+
*/
|
|
65
|
+
export class BlokResolutionError extends Error {
|
|
66
|
+
readonly componentId: string;
|
|
67
|
+
readonly propKey: string;
|
|
68
|
+
|
|
69
|
+
constructor(componentId: string, propKey: string, message: string) {
|
|
70
|
+
super(message);
|
|
71
|
+
this.name = 'BlokResolutionError';
|
|
72
|
+
this.componentId = componentId;
|
|
73
|
+
this.propKey = propKey;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const toBlokPropHandle = <TSchema extends z.ZodTypeAny>(
|
|
78
|
+
component: BlokComponentNode,
|
|
79
|
+
key: string,
|
|
80
|
+
schema: TSchema,
|
|
81
|
+
prop: BlokComponentProp | undefined,
|
|
82
|
+
): BlokPropHandle<TSchema> => ({
|
|
83
|
+
component,
|
|
84
|
+
key,
|
|
85
|
+
schema,
|
|
86
|
+
prop,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const isBlokPropHandle = (value: unknown): value is BlokPropHandle<z.ZodTypeAny> => {
|
|
90
|
+
if (!value || typeof value !== 'object') {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return 'component' in value && 'key' in value && 'schema' in value;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const resolveHandle = (
|
|
98
|
+
handleOrBlok: BlokPropHandle<z.ZodTypeAny> | AnyBlok | undefined,
|
|
99
|
+
key?: string,
|
|
100
|
+
): BlokPropHandle<z.ZodTypeAny> | undefined => {
|
|
101
|
+
if (!handleOrBlok) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (isBlokPropHandle(handleOrBlok)) {
|
|
106
|
+
return handleOrBlok;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!key) {
|
|
110
|
+
throw new Error('Missing blok prop key.');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return handleOrBlok[key];
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/* -------------------------------------------------------------------------- */
|
|
117
|
+
/* Resolution plumbing */
|
|
118
|
+
/* -------------------------------------------------------------------------- */
|
|
119
|
+
|
|
120
|
+
const EMPTY_PATHS: string[] = [];
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Dependency sets are keyed on the prop object, which is stable for the life of
|
|
124
|
+
* a parsed payload, so the walk happens once per prop instead of per render.
|
|
125
|
+
*/
|
|
126
|
+
const dependencyCache = new WeakMap<
|
|
127
|
+
BlokComponentProp,
|
|
128
|
+
Map<z.ZodTypeAny, BlokRuntimeDependencies>
|
|
129
|
+
>();
|
|
130
|
+
|
|
131
|
+
const getCachedDependencies = (
|
|
132
|
+
prop: BlokComponentProp | undefined,
|
|
133
|
+
schema: z.ZodTypeAny,
|
|
134
|
+
): BlokRuntimeDependencies => {
|
|
135
|
+
if (!prop) {
|
|
136
|
+
return {paths: EMPTY_PATHS, needsInvokeFunction: false, needsDispatchAction: false};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let bySchema = dependencyCache.get(prop);
|
|
140
|
+
if (!bySchema) {
|
|
141
|
+
bySchema = new Map();
|
|
142
|
+
dependencyCache.set(prop, bySchema);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const cached = bySchema.get(schema);
|
|
146
|
+
if (cached) {
|
|
147
|
+
return cached;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const dependencies = getComponentPropRuntimeDependencies(prop, schema);
|
|
151
|
+
bySchema.set(schema, dependencies);
|
|
152
|
+
return dependencies;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Builds the render-time resolution context.
|
|
157
|
+
*
|
|
158
|
+
* `readPath` is backed by a snapshot of exactly the paths the caller
|
|
159
|
+
* subscribed to, so "what a component subscribes to" and "what it reads" are
|
|
160
|
+
* the same list by construction. The previous implementation subscribed to a
|
|
161
|
+
* dependency array and then separately read `store.getState()` inside a memo,
|
|
162
|
+
* an invariant that held only by coincidence. Paths outside the snapshot fall
|
|
163
|
+
* back to a live read.
|
|
164
|
+
*/
|
|
165
|
+
/** The status a read of `path` has here: a scope value (a loop item handed down by value) is ready. */
|
|
166
|
+
const scopedStatus = (state: BlokRuntimeContext, path: string, scope: BlokScope): BlokSourceStatus => {
|
|
167
|
+
if (!isWritableScopedPath(path, scope)) return READY;
|
|
168
|
+
return statusAtPath(state.statuses, resolveScopedPath(path, scope));
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const createSnapshotResolutionContext = (
|
|
172
|
+
store: BlokRuntimeStore,
|
|
173
|
+
scope: BlokScope,
|
|
174
|
+
snapshot: PathSnapshot,
|
|
175
|
+
): BlokResolutionContext => ({
|
|
176
|
+
readPath: path =>
|
|
177
|
+
snapshot.values.has(path)
|
|
178
|
+
? snapshot.values.get(path)
|
|
179
|
+
: readScopedPath(store.getState().dataModel, path, scope),
|
|
180
|
+
statusOf: path => snapshot.statuses.get(path) ?? scopedStatus(store.getState(), path, scope),
|
|
181
|
+
resolvePath: path => resolveScopedPath(path, scope),
|
|
182
|
+
invokeFunction: (name, args, options) => store.getState().invokeFunction(name, args, options),
|
|
183
|
+
dispatchAction: () => undefined,
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
/** Live context used inside event handlers, where reads must not be stale. */
|
|
187
|
+
const createLiveResolutionContext = (
|
|
188
|
+
store: BlokRuntimeStore,
|
|
189
|
+
scope: BlokScope,
|
|
190
|
+
): BlokResolutionContext => ({
|
|
191
|
+
readPath: path => readScopedPath(store.getState().dataModel, path, scope),
|
|
192
|
+
statusOf: path => scopedStatus(store.getState(), path, scope),
|
|
193
|
+
resolvePath: path => resolveScopedPath(path, scope),
|
|
194
|
+
refetchQuery: name => store.getState().refetchQuery?.(name),
|
|
195
|
+
fetchMoreQuery: (name, variables) => store.getState().fetchMoreQuery?.(name, variables),
|
|
196
|
+
answerTask: values => store.getState().answerTask?.(values),
|
|
197
|
+
travelling: store.getState().travelAt !== null,
|
|
198
|
+
invokeFunction: (name, args, options) => store.getState().invokeFunction(name, args, options),
|
|
199
|
+
dispatchAction: (action, component, observe) =>
|
|
200
|
+
observe
|
|
201
|
+
? store.getState().dispatchAction(action, component, observe)
|
|
202
|
+
: store.getState().dispatchAction(action, component),
|
|
203
|
+
refuseAction: (action, component) => store.getState().refuseAction?.(action, component) ?? false,
|
|
204
|
+
bindTask: (name, args) => bindTask(store, name, args),
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
type PathSnapshot = {values: ReadonlyMap<string, unknown>; statuses: ReadonlyMap<string, BlokSourceStatus>};
|
|
208
|
+
|
|
209
|
+
const usePathSnapshot = (paths: ReadonlyArray<string>): PathSnapshot => {
|
|
210
|
+
const scope = useBlokScope();
|
|
211
|
+
const pathKey = paths.join(' ');
|
|
212
|
+
|
|
213
|
+
// Values and statuses interleaved, so one shallow comparison covers both.
|
|
214
|
+
const selector = React.useCallback(
|
|
215
|
+
(state: BlokRuntimeContext) =>
|
|
216
|
+
paths.flatMap(path => [readScopedPath(state.dataModel, path, scope), scopedStatus(state, path, scope)]),
|
|
217
|
+
// `pathKey` stands in for the array's contents: callers rebuild the path
|
|
218
|
+
// array each render, but its contents are stable for a given payload.
|
|
219
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
220
|
+
[pathKey, scope],
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
const values = useBlokRuntime(useShallow(selector));
|
|
224
|
+
|
|
225
|
+
return React.useMemo(() => {
|
|
226
|
+
const snapshot = new Map<string, unknown>();
|
|
227
|
+
const statuses = new Map<string, BlokSourceStatus>();
|
|
228
|
+
paths.forEach((path, index) => {
|
|
229
|
+
snapshot.set(path, values[index * 2]);
|
|
230
|
+
statuses.set(path, values[index * 2 + 1] as BlokSourceStatus);
|
|
231
|
+
});
|
|
232
|
+
return {values: snapshot, statuses};
|
|
233
|
+
// `pathKey` stands in for `paths`, whose identity changes each render.
|
|
234
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
235
|
+
}, [pathKey, values]);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/* -------------------------------------------------------------------------- */
|
|
239
|
+
/* Public component-author API */
|
|
240
|
+
/* -------------------------------------------------------------------------- */
|
|
241
|
+
|
|
242
|
+
export const useBlok = <TSchema extends BlokObjectSchema>(
|
|
243
|
+
component: BlokComponentNode,
|
|
244
|
+
schema: TSchema,
|
|
245
|
+
): Blok<TSchema> => {
|
|
246
|
+
return React.useMemo(() => {
|
|
247
|
+
const propMap = getPropMap(component.props);
|
|
248
|
+
const shape = schema.shape as BlokSchemaShape<TSchema>;
|
|
249
|
+
|
|
250
|
+
return Object.fromEntries(
|
|
251
|
+
(Object.keys(shape) as Array<keyof BlokSchemaShape<TSchema> & string>).map(key => [
|
|
252
|
+
key,
|
|
253
|
+
toBlokPropHandle(component, key, shape[key], propMap.get(key)),
|
|
254
|
+
]),
|
|
255
|
+
) as Blok<TSchema>;
|
|
256
|
+
}, [component, schema]);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export function useValue<TSchema extends z.ZodTypeAny>(
|
|
260
|
+
handle: BlokPropHandle<TSchema> | undefined,
|
|
261
|
+
): z.output<TSchema> | undefined;
|
|
262
|
+
export function useValue<TBlok extends AnyBlok, TKey extends keyof TBlok & string>(
|
|
263
|
+
blok: TBlok,
|
|
264
|
+
key: TKey,
|
|
265
|
+
): BlokValueForKey<TBlok, TKey>;
|
|
266
|
+
export function useValue(
|
|
267
|
+
handleOrBlok: BlokPropHandle<z.ZodTypeAny> | AnyBlok | undefined,
|
|
268
|
+
key?: string,
|
|
269
|
+
): unknown {
|
|
270
|
+
const handle = resolveHandle(handleOrBlok, key);
|
|
271
|
+
const store = useBlokRuntimeStoreApi();
|
|
272
|
+
const scope = useBlokScope();
|
|
273
|
+
const dependencies = handle ? getCachedDependencies(handle.prop, handle.schema) : undefined;
|
|
274
|
+
const snapshot = usePathSnapshot(dependencies?.paths ?? EMPTY_PATHS);
|
|
275
|
+
|
|
276
|
+
return React.useMemo(() => {
|
|
277
|
+
if (!handle) {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// A `children` prop with no explicit binding falls back to the node's own
|
|
282
|
+
// declared children.
|
|
283
|
+
if (handle.key === 'children' && !handle.prop && handle.component.children?.length) {
|
|
284
|
+
const childIds = handle.component.children.map(child => child.id);
|
|
285
|
+
const parsedChildren = handle.schema.safeParse(childIds);
|
|
286
|
+
return parsedChildren.success ? parsedChildren.data : undefined;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const context = createSnapshotResolutionContext(store, scope, snapshot);
|
|
290
|
+
const resolved = resolvePropValue(handle.prop, handle.schema, context);
|
|
291
|
+
|
|
292
|
+
if (!resolved.ok) {
|
|
293
|
+
throw new BlokResolutionError(handle.component.id, handle.key, resolved.error);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const parsed = handle.schema.safeParse(resolved.value);
|
|
297
|
+
return parsed.success ? parsed.data : undefined;
|
|
298
|
+
}, [handle, scope, snapshot, store]);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** The scope names a callback's arguments read the payload its component hands it by (`event.value`). */
|
|
302
|
+
export const BLOK_EVENT_ROOT = 'event';
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The payload a component's callback is called with, shaped as its catalog
|
|
306
|
+
* declares it: a callback whose event is `{value}` gets a bare value wrapped,
|
|
307
|
+
* every other event is handed over as the component built it.
|
|
308
|
+
*/
|
|
309
|
+
export const shapeEvent = (component: string, key: string, payload: unknown): unknown => {
|
|
310
|
+
const fields = defaultBlokView().components.get(component)?.props.find(prop => prop.key === key)?.event;
|
|
311
|
+
if (fields && fields.length === 1 && fields[0].key === 'value') {
|
|
312
|
+
const wrapped =
|
|
313
|
+
payload !== null && typeof payload === 'object' && !Array.isArray(payload) && Object.keys(payload).length === 1 && 'value' in payload;
|
|
314
|
+
return wrapped ? payload : {value: payload};
|
|
315
|
+
}
|
|
316
|
+
return payload === undefined ? {} : payload;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
type CallbackRunner = {
|
|
320
|
+
run: ((payload?: unknown) => void) | undefined;
|
|
321
|
+
/** Its call's task is running: the control will not dispatch again. */
|
|
322
|
+
busy: boolean;
|
|
323
|
+
/** Why it cannot run now (an agent offline, the past), or undefined. */
|
|
324
|
+
unavailable: string | undefined;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const TRAVEL_REASON = 'Viewing the past: actions are paused';
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* A callback prop as something a component can call: exactly one task call,
|
|
331
|
+
* one `queries.<name>.refetch()`, `ui.copy` or `task.answer` (the one-thing
|
|
332
|
+
* rule; the parser and the validator refuse anything else).
|
|
333
|
+
*
|
|
334
|
+
* The control is busy while the task its call started runs, so it cannot
|
|
335
|
+
* double-dispatch: until every promise the host returned has settled, and
|
|
336
|
+
* while the record the call writes (`into`) says it is running.
|
|
337
|
+
*/
|
|
338
|
+
const useCallbackRunner = (handle: BlokPropHandle<z.ZodTypeAny> | undefined): CallbackRunner => {
|
|
339
|
+
const store = useBlokRuntimeStoreApi();
|
|
340
|
+
const scope = useBlokScope();
|
|
341
|
+
const prop = handle?.prop;
|
|
342
|
+
const actionCall = React.useMemo(() => getPropActionCall(prop), [prop]);
|
|
343
|
+
const component = handle?.component;
|
|
344
|
+
const key = handle?.key;
|
|
345
|
+
const [inFlight, setInFlight] = React.useState(0);
|
|
346
|
+
const dependencies = React.useMemo(() => actionDependenciesOf(prop), [prop]);
|
|
347
|
+
const into = actionCall?.type === 'agent' ? actionCall.into : undefined;
|
|
348
|
+
const command = isCommand(actionCall);
|
|
349
|
+
|
|
350
|
+
const recordRunning = useBlokRuntime(state => {
|
|
351
|
+
if (!into) return false;
|
|
352
|
+
const record = readScopedPath(state.dataModel, into, scope);
|
|
353
|
+
return typeof record === 'object' && record !== null && (record as {running?: unknown}).running === true;
|
|
354
|
+
});
|
|
355
|
+
const unavailable = useBlokRuntime(state => {
|
|
356
|
+
if (command && state.travelAt !== null) return TRAVEL_REASON;
|
|
357
|
+
for (const dependency of dependencies) {
|
|
358
|
+
const reason = state.unavailableDependencies.get(dependency);
|
|
359
|
+
if (reason) return reason;
|
|
360
|
+
}
|
|
361
|
+
return undefined;
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
const mountedRef = React.useRef(true);
|
|
365
|
+
React.useEffect(() => {
|
|
366
|
+
mountedRef.current = true;
|
|
367
|
+
return () => {
|
|
368
|
+
mountedRef.current = false;
|
|
369
|
+
};
|
|
370
|
+
}, []);
|
|
371
|
+
|
|
372
|
+
const node = useBlokNodeState();
|
|
373
|
+
const busy = inFlight > 0 || recordRunning || (command && node.busy);
|
|
374
|
+
const busyRef = React.useRef(busy);
|
|
375
|
+
React.useEffect(() => {
|
|
376
|
+
busyRef.current = busy;
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
const run = React.useMemo(() => {
|
|
380
|
+
if (!actionCall || !component) {
|
|
381
|
+
return undefined;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return (payload?: unknown) => {
|
|
385
|
+
// One run at a time: a busy control does not dispatch again.
|
|
386
|
+
if (command && busyRef.current) return;
|
|
387
|
+
const event = shapeEvent(component.component, key ?? '', payload);
|
|
388
|
+
const eventScope: BlokScope = {
|
|
389
|
+
...scope,
|
|
390
|
+
values: {...scope.values, [BLOK_EVENT_ROOT]: event},
|
|
391
|
+
};
|
|
392
|
+
const context = createLiveResolutionContext(store, eventScope);
|
|
393
|
+
const result = runActionCall(actionCall, context, component);
|
|
394
|
+
|
|
395
|
+
if (!result.ok) {
|
|
396
|
+
console.error(`[blok] callback on "${component.id}" failed: ${result.error}`);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (result.value instanceof Promise) {
|
|
401
|
+
node.track(result.value);
|
|
402
|
+
setInFlight(count => count + 1);
|
|
403
|
+
const settle = () => {
|
|
404
|
+
if (mountedRef.current) setInFlight(count => Math.max(0, count - 1));
|
|
405
|
+
};
|
|
406
|
+
result.value.then(settle, settle);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
}, [actionCall, command, component, key, node, scope, store]);
|
|
410
|
+
|
|
411
|
+
return {run, busy, unavailable};
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
export function useAction<TSchema extends z.ZodTypeAny>(
|
|
415
|
+
handle: BlokPropHandle<TSchema> | undefined,
|
|
416
|
+
): (() => void) | undefined;
|
|
417
|
+
export function useAction<TBlok extends AnyBlok, TKey extends keyof TBlok & string>(
|
|
418
|
+
blok: TBlok,
|
|
419
|
+
key: TKey,
|
|
420
|
+
): (() => void) | undefined;
|
|
421
|
+
export function useAction(
|
|
422
|
+
handleOrBlok: BlokPropHandle<z.ZodTypeAny> | AnyBlok | undefined,
|
|
423
|
+
key?: string,
|
|
424
|
+
): (() => void) | undefined {
|
|
425
|
+
const {run} = useCallbackRunner(resolveHandle(handleOrBlok, key));
|
|
426
|
+
return React.useMemo(() => (run ? () => run() : undefined), [run]);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** Every dependency a callback prop calls. */
|
|
430
|
+
export const actionDependenciesOf = (prop: BlokComponentProp | undefined): string[] => {
|
|
431
|
+
const found = new Set<string>();
|
|
432
|
+
const visit = (argument: BlokActionArgument) => {
|
|
433
|
+
if (argument.agent_call) {
|
|
434
|
+
found.add(argument.agent_call.dependency);
|
|
435
|
+
argument.agent_call.arguments?.forEach(visit);
|
|
436
|
+
}
|
|
437
|
+
argument.util_call?.arguments?.forEach(visit);
|
|
438
|
+
argument.value_list?.forEach(visit);
|
|
439
|
+
argument.value_dict?.forEach(visit);
|
|
440
|
+
};
|
|
441
|
+
if (prop?.agent_call) {
|
|
442
|
+
found.add(prop.agent_call.dependency);
|
|
443
|
+
prop.agent_call.arguments?.forEach(visit);
|
|
444
|
+
}
|
|
445
|
+
prop?.util_call?.arguments?.forEach(visit);
|
|
446
|
+
return [...found];
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Why a callback prop cannot run right now, or `undefined` when it can: it
|
|
451
|
+
* calls a dependency the host marks unavailable (offline, not bound), or it is
|
|
452
|
+
* a command and the blok shows the past. A control shows itself disabled with
|
|
453
|
+
* this as its tooltip.
|
|
454
|
+
*/
|
|
455
|
+
export function useActionUnavailable<TSchema extends z.ZodTypeAny>(
|
|
456
|
+
handle: BlokPropHandle<TSchema> | undefined,
|
|
457
|
+
): string | undefined {
|
|
458
|
+
return useCallbackRunner(handle).unavailable;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** Every agent call a node's props make: their actions, and the calls in their arguments. */
|
|
462
|
+
const agentCallsOf = (props: ReadonlyArray<BlokComponentProp>): Array<{dependency: string; operation: string}> => {
|
|
463
|
+
const calls: Array<{dependency: string; operation: string}> = [];
|
|
464
|
+
const visit = (argument: BlokActionArgument) => {
|
|
465
|
+
if (argument.agent_call) {
|
|
466
|
+
calls.push(argument.agent_call);
|
|
467
|
+
argument.agent_call.arguments?.forEach(visit);
|
|
468
|
+
}
|
|
469
|
+
argument.util_call?.arguments?.forEach(visit);
|
|
470
|
+
argument.value_list?.forEach(visit);
|
|
471
|
+
argument.value_dict?.forEach(visit);
|
|
472
|
+
};
|
|
473
|
+
for (const prop of props) {
|
|
474
|
+
if (prop.agent_call) {
|
|
475
|
+
calls.push(prop.agent_call);
|
|
476
|
+
prop.agent_call.arguments?.forEach(visit);
|
|
477
|
+
}
|
|
478
|
+
prop.util_call?.arguments?.forEach(visit);
|
|
479
|
+
}
|
|
480
|
+
return calls;
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Why a node cannot run its action now, or `undefined`: one of the agent calls its
|
|
485
|
+
* props make is in the host's `lockedActions` (a lock it takes is held). The node
|
|
486
|
+
* is then marked `data-locked`, for the `locked:` variant.
|
|
487
|
+
*/
|
|
488
|
+
export function useNodeLocked(props: ReadonlyArray<BlokComponentProp>): string | undefined {
|
|
489
|
+
const calls = React.useMemo(() => agentCallsOf(props), [props]);
|
|
490
|
+
return useBlokRuntime(state => {
|
|
491
|
+
if (state.lockedActions.size === 0) return undefined;
|
|
492
|
+
for (const call of calls) {
|
|
493
|
+
const reason = state.lockedActions.get(lockedActionKey(call.dependency, call.operation));
|
|
494
|
+
if (reason) return reason;
|
|
495
|
+
}
|
|
496
|
+
return undefined;
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* `useAction` plus whether what it started is still running (`pending`, the
|
|
502
|
+
* control's `data-busy`): a busy control does not dispatch again.
|
|
503
|
+
*/
|
|
504
|
+
export function usePendingAction<TSchema extends z.ZodTypeAny>(
|
|
505
|
+
handle: BlokPropHandle<TSchema> | undefined,
|
|
506
|
+
): {run: (() => void) | undefined; pending: boolean; unavailable: string | undefined} {
|
|
507
|
+
const {run, busy, unavailable} = useCallbackRunner(handle);
|
|
508
|
+
const bare = React.useMemo(() => (run ? () => run() : undefined), [run]);
|
|
509
|
+
return {run: bare, pending: busy, unavailable};
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* A callback that carries the payload that triggered it, read as `event`
|
|
514
|
+
* (`deps.stage.set(x: event.value)`). The payload is shaped as the
|
|
515
|
+
* component's catalog declares its event (`shapeEvent`), and exists only
|
|
516
|
+
* while the callback runs.
|
|
517
|
+
*/
|
|
518
|
+
export function useEventAction<TSchema extends z.ZodTypeAny>(
|
|
519
|
+
handle: BlokPropHandle<TSchema> | undefined,
|
|
520
|
+
): ((value?: unknown) => void) | undefined;
|
|
521
|
+
export function useEventAction<TBlok extends AnyBlok, TKey extends keyof TBlok & string>(
|
|
522
|
+
blok: TBlok,
|
|
523
|
+
key: TKey,
|
|
524
|
+
): ((value?: unknown) => void) | undefined;
|
|
525
|
+
export function useEventAction(
|
|
526
|
+
handleOrBlok: BlokPropHandle<z.ZodTypeAny> | AnyBlok | undefined,
|
|
527
|
+
key?: string,
|
|
528
|
+
): ((value?: unknown) => void) | undefined {
|
|
529
|
+
return useCallbackRunner(resolveHandle(handleOrBlok, key)).run;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** `useEventAction` with whether its task runs and why it cannot run. */
|
|
533
|
+
export function usePendingEventAction<TSchema extends z.ZodTypeAny>(
|
|
534
|
+
handle: BlokPropHandle<TSchema> | undefined,
|
|
535
|
+
): CallbackRunner {
|
|
536
|
+
return useCallbackRunner(handle);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* The combined status of a node's value props (callbacks and children left
|
|
541
|
+
* out): pending if any read is not known yet, failed if one cannot be known,
|
|
542
|
+
* stale if one stopped updating. What decides whether a node renders, shows a
|
|
543
|
+
* skeleton, or suspends its boundary.
|
|
544
|
+
*/
|
|
545
|
+
export const useNodeStatus = <TSchema extends BlokObjectSchema>(
|
|
546
|
+
component: BlokComponentNode,
|
|
547
|
+
schema: TSchema,
|
|
548
|
+
): BlokSourceStatus => {
|
|
549
|
+
const store = useBlokRuntimeStoreApi();
|
|
550
|
+
const scope = useBlokScope();
|
|
551
|
+
|
|
552
|
+
const {propMap, valueFields, paths} = React.useMemo(() => {
|
|
553
|
+
const nextPropMap = getPropMap(component.props);
|
|
554
|
+
const shape = schema.shape as Record<string, z.ZodTypeAny>;
|
|
555
|
+
const nextValueFields = Object.entries(shape).filter(
|
|
556
|
+
([key, fieldSchema]) => !isActionSchema(fieldSchema) && nextPropMap.has(key),
|
|
557
|
+
);
|
|
558
|
+
const nextPaths = new Set<string>();
|
|
559
|
+
nextValueFields.forEach(([key, fieldSchema]) => {
|
|
560
|
+
getCachedDependencies(nextPropMap.get(key), fieldSchema).paths.forEach(path => nextPaths.add(path));
|
|
561
|
+
});
|
|
562
|
+
return {propMap: nextPropMap, valueFields: nextValueFields, paths: [...nextPaths]};
|
|
563
|
+
}, [component, schema]);
|
|
564
|
+
|
|
565
|
+
const snapshot = usePathSnapshot(paths);
|
|
566
|
+
|
|
567
|
+
return React.useMemo(() => {
|
|
568
|
+
if (paths.length === 0) return READY;
|
|
569
|
+
const context = createSnapshotResolutionContext(store, scope, snapshot);
|
|
570
|
+
let status = READY;
|
|
571
|
+
for (const [key, fieldSchema] of valueFields) {
|
|
572
|
+
status = combineStatus(status, statusOfResult(resolvePropValue(propMap.get(key), fieldSchema, context)));
|
|
573
|
+
}
|
|
574
|
+
return status;
|
|
575
|
+
}, [paths.length, propMap, scope, snapshot, store, valueFields]);
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Schema validity of a node's *value* props. Action props are skipped: they
|
|
580
|
+
* carry a call descriptor rather than a value, and the preflight already
|
|
581
|
+
* verified that the ones the catalog requires are present.
|
|
582
|
+
*/
|
|
583
|
+
export const useValidation = <TSchema extends BlokObjectSchema>(
|
|
584
|
+
component: BlokComponentNode,
|
|
585
|
+
schema: TSchema,
|
|
586
|
+
): BlokValidationState => {
|
|
587
|
+
const store = useBlokRuntimeStoreApi();
|
|
588
|
+
const scope = useBlokScope();
|
|
589
|
+
|
|
590
|
+
const {propMap, valueFields, paths} = React.useMemo(() => {
|
|
591
|
+
const nextPropMap = getPropMap(component.props);
|
|
592
|
+
const shape = schema.shape as Record<string, z.ZodTypeAny>;
|
|
593
|
+
const nextValueFields = Object.entries(shape).filter(
|
|
594
|
+
([, fieldSchema]) => !isActionSchema(fieldSchema),
|
|
595
|
+
);
|
|
596
|
+
const nextPaths = new Set<string>();
|
|
597
|
+
|
|
598
|
+
nextValueFields.forEach(([key, fieldSchema]) => {
|
|
599
|
+
getCachedDependencies(nextPropMap.get(key), fieldSchema).paths.forEach(path =>
|
|
600
|
+
nextPaths.add(path),
|
|
601
|
+
);
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
return {propMap: nextPropMap, valueFields: nextValueFields, paths: [...nextPaths]};
|
|
605
|
+
}, [component, schema]);
|
|
606
|
+
|
|
607
|
+
const snapshot = usePathSnapshot(paths);
|
|
608
|
+
|
|
609
|
+
return React.useMemo(() => {
|
|
610
|
+
const context = createSnapshotResolutionContext(store, scope, snapshot);
|
|
611
|
+
const validationErrors: string[] = [];
|
|
612
|
+
|
|
613
|
+
for (const [key, fieldSchema] of valueFields) {
|
|
614
|
+
const isImplicitChildren =
|
|
615
|
+
key === 'children' && !propMap.has(key) && Boolean(component.children?.length);
|
|
616
|
+
const resolvedValue = isImplicitChildren
|
|
617
|
+
? {ok: true as const, value: component.children?.map(child => child.id)}
|
|
618
|
+
: resolvePropValue(propMap.get(key), fieldSchema, context);
|
|
619
|
+
|
|
620
|
+
if (!resolvedValue.ok) {
|
|
621
|
+
validationErrors.push(`${key}: ${resolvedValue.error}`);
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
const parsed = fieldSchema.safeParse(resolvedValue.value);
|
|
626
|
+
if (!parsed.success) {
|
|
627
|
+
parsed.error.issues.forEach(issue => {
|
|
628
|
+
const issuePath = [key, ...issue.path.map(String)].join('.');
|
|
629
|
+
validationErrors.push(`${issuePath}: ${issue.message}`);
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
return {isValid: validationErrors.length === 0, validationErrors};
|
|
635
|
+
}, [component, propMap, scope, snapshot, store, valueFields]);
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Evaluates a `checks` guard list against live data. Interactive bloks use it
|
|
640
|
+
* to disable themselves until their preconditions hold.
|
|
641
|
+
*/
|
|
642
|
+
export const useChecks = (rawChecks: unknown): BlokChecksState => {
|
|
643
|
+
const store = useBlokRuntimeStoreApi();
|
|
644
|
+
const scope = useBlokScope();
|
|
645
|
+
const paths = React.useMemo(() => getChecksDependencyPaths(rawChecks), [rawChecks]);
|
|
646
|
+
const snapshot = usePathSnapshot(paths);
|
|
647
|
+
|
|
648
|
+
return React.useMemo(() => {
|
|
649
|
+
const context = createSnapshotResolutionContext(store, scope, snapshot);
|
|
650
|
+
return evaluateChecks(rawChecks, context);
|
|
651
|
+
}, [rawChecks, scope, snapshot, store]);
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Two-way binding for input-like bloks: reads the current value at a scoped
|
|
656
|
+
* path and returns a setter that writes through to the shared data model.
|
|
657
|
+
* Returns `undefined` when the blok is not bound to a path.
|
|
658
|
+
*/
|
|
659
|
+
/**
|
|
660
|
+
* The current values at these data-model paths, re-read when any of them
|
|
661
|
+
* changes. For a component whose paths are data rather than props: a picker
|
|
662
|
+
* reading the variables its query names.
|
|
663
|
+
*/
|
|
664
|
+
export const useDataPaths = (paths: ReadonlyArray<string>): ReadonlyMap<string, unknown> =>
|
|
665
|
+
usePathSnapshot(paths).values;
|
|
666
|
+
|
|
667
|
+
export const useBinding = (
|
|
668
|
+
path: string | undefined,
|
|
669
|
+
): {value: unknown; setValue: (value: unknown) => void; readOnly: boolean} | undefined => {
|
|
670
|
+
const store = useBlokRuntimeStoreApi();
|
|
671
|
+
const scope = useBlokScope();
|
|
672
|
+
const paths = React.useMemo(() => (path ? [path] : EMPTY_PATHS), [path]);
|
|
673
|
+
const snapshot = usePathSnapshot(paths);
|
|
674
|
+
const travelling = useBlokRuntime(state => state.travelAt !== null);
|
|
675
|
+
|
|
676
|
+
return React.useMemo(() => {
|
|
677
|
+
if (!path) {
|
|
678
|
+
return undefined;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
const absolutePath = resolveScopedPath(path, scope);
|
|
682
|
+
|
|
683
|
+
return {
|
|
684
|
+
value: snapshot.values.get(path),
|
|
685
|
+
// The past is read-only: a bound control shows what was, and writes nothing.
|
|
686
|
+
setValue: (value: unknown) => {
|
|
687
|
+
if (!travelling) store.getState().setRuntimeValue(absolutePath, value);
|
|
688
|
+
},
|
|
689
|
+
readOnly: travelling,
|
|
690
|
+
};
|
|
691
|
+
}, [path, scope, snapshot, store, travelling]);
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
export type {BlokChecksState};
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* One prop of a node resolved with its status (a guard, an `else`'s
|
|
698
|
+
* condition), without throwing on a payload problem: `ok: false` is returned.
|
|
699
|
+
* With no key, it resolves nothing and is ready.
|
|
700
|
+
*/
|
|
701
|
+
export const useResolvedProp = (
|
|
702
|
+
component: BlokComponentNode,
|
|
703
|
+
key: string | undefined,
|
|
704
|
+
schema: z.ZodTypeAny,
|
|
705
|
+
): BlokResolved => {
|
|
706
|
+
const store = useBlokRuntimeStoreApi();
|
|
707
|
+
const scope = useBlokScope();
|
|
708
|
+
const prop = React.useMemo(() => (key ? component.props?.find(candidate => candidate.key === key) : undefined), [component, key]);
|
|
709
|
+
const dependencies = getCachedDependencies(prop, schema);
|
|
710
|
+
const snapshot = usePathSnapshot(dependencies.paths);
|
|
711
|
+
|
|
712
|
+
return React.useMemo(() => {
|
|
713
|
+
if (!prop) return {ok: true, value: undefined};
|
|
714
|
+
return resolvePropValue(prop, schema, createSnapshotResolutionContext(store, scope, snapshot));
|
|
715
|
+
}, [prop, schema, scope, snapshot, store]);
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Resolves props against the live store with extra scope values (a loop's
|
|
720
|
+
* item while working out its `key`), outside render subscriptions: the caller
|
|
721
|
+
* re-renders when what it iterates changes.
|
|
722
|
+
*/
|
|
723
|
+
export const useScopedResolver = (): ((
|
|
724
|
+
prop: BlokComponentProp | undefined,
|
|
725
|
+
values: Readonly<Record<string, unknown>>,
|
|
726
|
+
aliases?: Readonly<Record<string, string>>,
|
|
727
|
+
) => BlokResolved) => {
|
|
728
|
+
const store = useBlokRuntimeStoreApi();
|
|
729
|
+
const scope = useBlokScope();
|
|
730
|
+
return React.useCallback(
|
|
731
|
+
(prop, values, aliases) =>
|
|
732
|
+
resolvePropValue(
|
|
733
|
+
prop,
|
|
734
|
+
z.unknown(),
|
|
735
|
+
createLiveResolutionContext(store, {
|
|
736
|
+
...scope,
|
|
737
|
+
aliases: aliases ? {...scope.aliases, ...aliases} : scope.aliases,
|
|
738
|
+
values: {...scope.values, ...values},
|
|
739
|
+
}),
|
|
740
|
+
),
|
|
741
|
+
[scope, store],
|
|
742
|
+
);
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
const NO_ARGUMENTS: readonly BlokActionArgument[] = Object.freeze([]);
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Stored arguments resolved against the data model, subscribed to what they
|
|
749
|
+
* read: a declared query's variables. Re-renders when one of them changes.
|
|
750
|
+
*/
|
|
751
|
+
export const useResolvedArguments = (
|
|
752
|
+
argumentsList: readonly BlokActionArgument[] | null,
|
|
753
|
+
): {values: Record<string, unknown>; status: BlokSourceStatus} => {
|
|
754
|
+
const store = useBlokRuntimeStoreApi();
|
|
755
|
+
const scope = useBlokScope();
|
|
756
|
+
const list = argumentsList ?? NO_ARGUMENTS;
|
|
757
|
+
const paths = React.useMemo(() => getActionArgumentsRuntimeDependencies([...list]).paths, [list]);
|
|
758
|
+
const snapshot = usePathSnapshot(paths);
|
|
759
|
+
return React.useMemo(() => {
|
|
760
|
+
const resolved = resolveActionArguments([...list], createSnapshotResolutionContext(store, scope, snapshot), true);
|
|
761
|
+
if (!resolved.ok) return {values: {}, status: {status: 'failed', error: resolved.error}};
|
|
762
|
+
return {values: resolved.value, status: resolved.status ?? READY};
|
|
763
|
+
}, [list, scope, snapshot, store]);
|
|
764
|
+
};
|