@gyral/core 0.1.0 → 0.3.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/CHANGELOG.md +112 -0
- package/LICENSE +1 -1
- package/NOTICE +1 -1
- package/README.md +9 -7
- package/dist/children.d.ts +5 -2
- package/dist/children.js +8 -3
- package/dist/children.js.map +1 -1
- package/dist/command.js +6 -0
- package/dist/command.js.map +1 -1
- package/dist/compiler/ast.d.ts +21 -0
- package/dist/compiler/ast.js +145 -0
- package/dist/compiler/ast.js.map +1 -0
- package/dist/compiler/compile.d.ts +38 -0
- package/dist/compiler/compile.js +129 -0
- package/dist/compiler/compile.js.map +1 -0
- package/dist/compiler/hooks.d.ts +18 -0
- package/dist/compiler/hooks.js +186 -0
- package/dist/compiler/hooks.js.map +1 -0
- package/dist/compiler/parse5-check.d.ts +21 -0
- package/dist/compiler/parse5-check.js +55 -0
- package/dist/compiler/parse5-check.js.map +1 -0
- package/dist/compiler/scan.d.ts +31 -0
- package/dist/compiler/scan.js +152 -0
- package/dist/compiler/scan.js.map +1 -0
- package/dist/compiler/source.d.ts +34 -0
- package/dist/compiler/source.js +114 -0
- package/dist/compiler/source.js.map +1 -0
- package/dist/define.d.ts +2 -2
- package/dist/define.js +35 -334
- package/dist/define.js.map +1 -1
- package/dist/devtools-events.d.ts +5 -0
- package/dist/devtools-events.js.map +1 -1
- package/dist/devtools-off.d.ts +1 -0
- package/dist/devtools-off.js +1 -0
- package/dist/devtools-off.js.map +1 -1
- package/dist/devtools.d.ts +1 -0
- package/dist/devtools.js +3 -0
- package/dist/devtools.js.map +1 -1
- package/dist/drivers-scope.d.ts +1 -1
- package/dist/drivers-scope.js +1 -8
- package/dist/drivers-scope.js.map +1 -1
- package/dist/element-types.d.ts +5 -3
- package/dist/element-types.js.map +1 -1
- package/dist/element.d.ts +3 -0
- package/dist/element.js +269 -0
- package/dist/element.js.map +1 -0
- package/dist/eslint/imports.d.ts +24 -0
- package/dist/eslint/imports.js +78 -0
- package/dist/eslint/imports.js.map +1 -0
- package/dist/eslint/index.d.ts +15 -0
- package/dist/eslint/index.js +15 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/eslint/locate.d.ts +33 -0
- package/dist/eslint/locate.js +132 -0
- package/dist/eslint/locate.js.map +1 -0
- package/dist/eslint/row-purity-rule.d.ts +2 -0
- package/dist/eslint/row-purity-rule.js +103 -0
- package/dist/eslint/row-purity-rule.js.map +1 -0
- package/dist/eslint/template-rule.d.ts +5 -0
- package/dist/eslint/template-rule.js +66 -0
- package/dist/eslint/template-rule.js.map +1 -0
- package/dist/features.d.ts +39 -0
- package/dist/features.js +2 -0
- package/dist/features.js.map +1 -0
- package/dist/focus.d.ts +9 -2
- package/dist/focus.js +17 -2
- package/dist/focus.js.map +1 -1
- package/dist/hooks/invalid.d.ts +14 -0
- package/dist/hooks/invalid.js +72 -0
- package/dist/hooks/invalid.js.map +1 -0
- package/dist/hooks/labelled-by.d.ts +13 -0
- package/dist/hooks/labelled-by.js +51 -0
- package/dist/hooks/labelled-by.js.map +1 -0
- package/dist/host-model.d.ts +48 -0
- package/dist/host-model.js +155 -0
- package/dist/host-model.js.map +1 -0
- package/dist/hydration-client.d.ts +9 -0
- package/dist/hydration-client.js +35 -0
- package/dist/hydration-client.js.map +1 -0
- package/dist/hydration.d.ts +13 -19
- package/dist/hydration.js +45 -45
- package/dist/hydration.js.map +1 -1
- package/dist/index.d.ts +9 -16
- package/dist/index.js +9 -16
- package/dist/index.js.map +1 -1
- package/dist/intent.d.ts +31 -8
- package/dist/intent.js +82 -27
- package/dist/intent.js.map +1 -1
- package/dist/internal/interpreter.d.ts +7 -1
- package/dist/internal/interpreter.js +118 -73
- package/dist/internal/interpreter.js.map +1 -1
- package/dist/invokers-shim.d.ts +6 -0
- package/dist/invokers-shim.js +32 -0
- package/dist/invokers-shim.js.map +1 -0
- package/dist/invokers.d.ts +3 -5
- package/dist/invokers.js +11 -51
- package/dist/invokers.js.map +1 -1
- package/dist/islands.d.ts +0 -2
- package/dist/islands.js +4 -11
- package/dist/islands.js.map +1 -1
- package/dist/light-dom.d.ts +3 -52
- package/dist/light-dom.js +5 -100
- package/dist/light-dom.js.map +1 -1
- package/dist/prop.d.ts +66 -0
- package/dist/prop.js +22 -0
- package/dist/prop.js.map +1 -0
- package/dist/props.d.ts +52 -21
- package/dist/props.js +150 -34
- package/dist/props.js.map +1 -1
- package/dist/scheduler.d.ts +39 -0
- package/dist/scheduler.js +230 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/server-component.d.ts +10 -0
- package/dist/server-component.js +102 -0
- package/dist/server-component.js.map +1 -0
- package/dist/server-specs.d.ts +6 -0
- package/dist/server-specs.js +13 -0
- package/dist/server-specs.js.map +1 -0
- package/dist/server.d.ts +28 -0
- package/dist/server.js +50 -0
- package/dist/server.js.map +1 -0
- package/dist/settled.d.ts +10 -0
- package/dist/settled.js +40 -0
- package/dist/settled.js.map +1 -0
- package/dist/states.d.ts +3 -3
- package/dist/states.js +4 -7
- package/dist/states.js.map +1 -1
- package/dist/store-binding.d.ts +6 -3
- package/dist/store-binding.js +5 -6
- package/dist/store-binding.js.map +1 -1
- package/dist/store-scope.d.ts +6 -7
- package/dist/store-scope.js +11 -26
- package/dist/store-scope.js.map +1 -1
- package/dist/store.d.ts +3 -0
- package/dist/store.js +9 -2
- package/dist/store.js.map +1 -1
- package/dist/stores-provider.d.ts +2 -6
- package/dist/stores-provider.js +21 -55
- package/dist/stores-provider.js.map +1 -1
- package/dist/transitions.d.ts +5 -6
- package/dist/transitions.js +11 -20
- package/dist/transitions.js.map +1 -1
- package/dist/types.d.ts +19 -23
- package/dist/types.js.map +1 -1
- package/dist/view/attributes.d.ts +6 -0
- package/dist/view/attributes.js +10 -0
- package/dist/view/attributes.js.map +1 -0
- package/dist/view/compiled.d.ts +1 -0
- package/dist/view/compiled.js +6 -0
- package/dist/view/compiled.js.map +1 -0
- package/dist/view/dev-off.d.ts +1 -0
- package/dist/view/dev-off.js +4 -0
- package/dist/view/dev-off.js.map +1 -0
- package/dist/view/dev.d.ts +1 -0
- package/dist/view/dev.js +5 -0
- package/dist/view/dev.js.map +1 -0
- package/dist/view/flags.d.ts +1 -0
- package/dist/view/flags.js +4 -0
- package/dist/view/flags.js.map +1 -0
- package/dist/view/index.d.ts +21 -0
- package/dist/view/index.js +21 -0
- package/dist/view/index.js.map +1 -0
- package/dist/view/normalize/check.d.ts +20 -0
- package/dist/view/normalize/check.js +78 -0
- package/dist/view/normalize/check.js.map +1 -0
- package/dist/view/normalize/emit.d.ts +13 -0
- package/dist/view/normalize/emit.js +136 -0
- package/dist/view/normalize/emit.js.map +1 -0
- package/dist/view/normalize/entities.d.ts +4 -0
- package/dist/view/normalize/entities.js +38 -0
- package/dist/view/normalize/entities.js.map +1 -0
- package/dist/view/normalize/errors.d.ts +9 -0
- package/dist/view/normalize/errors.js +19 -0
- package/dist/view/normalize/errors.js.map +1 -0
- package/dist/view/normalize/id.d.ts +7 -0
- package/dist/view/normalize/id.js +48 -0
- package/dist/view/normalize/id.js.map +1 -0
- package/dist/view/normalize/normalize.d.ts +15 -0
- package/dist/view/normalize/normalize.js +36 -0
- package/dist/view/normalize/normalize.js.map +1 -0
- package/dist/view/normalize/repairs.d.ts +24 -0
- package/dist/view/normalize/repairs.js +166 -0
- package/dist/view/normalize/repairs.js.map +1 -0
- package/dist/view/normalize/rules.d.ts +30 -0
- package/dist/view/normalize/rules.js +90 -0
- package/dist/view/normalize/rules.js.map +1 -0
- package/dist/view/normalize/shape.d.ts +5 -0
- package/dist/view/normalize/shape.js +38 -0
- package/dist/view/normalize/shape.js.map +1 -0
- package/dist/view/normalize/source.d.ts +13 -0
- package/dist/view/normalize/source.js +34 -0
- package/dist/view/normalize/source.js.map +1 -0
- package/dist/view/normalize/tag-states.d.ts +23 -0
- package/dist/view/normalize/tag-states.js +192 -0
- package/dist/view/normalize/tag-states.js.map +1 -0
- package/dist/view/normalize/tokenizer.d.ts +5 -0
- package/dist/view/normalize/tokenizer.js +233 -0
- package/dist/view/normalize/tokenizer.js.map +1 -0
- package/dist/view/normalize/tokens.d.ts +51 -0
- package/dist/view/normalize/tokens.js +24 -0
- package/dist/view/normalize/tokens.js.map +1 -0
- package/dist/view/normalize/tree.d.ts +59 -0
- package/dist/view/normalize/tree.js +190 -0
- package/dist/view/normalize/tree.js.map +1 -0
- package/dist/view/normalize/types.d.ts +126 -0
- package/dist/view/normalize/types.js +26 -0
- package/dist/view/normalize/types.js.map +1 -0
- package/dist/view/normalize/whitespace.d.ts +2 -0
- package/dist/view/normalize/whitespace.js +182 -0
- package/dist/view/normalize/whitespace.js.map +1 -0
- package/dist/view/prepare-stub.d.ts +3 -0
- package/dist/view/prepare-stub.js +7 -0
- package/dist/view/prepare-stub.js.map +1 -0
- package/dist/view/prepare.d.ts +8 -0
- package/dist/view/prepare.js +57 -0
- package/dist/view/prepare.js.map +1 -0
- package/dist/view/registry.d.ts +63 -0
- package/dist/view/registry.js +19 -0
- package/dist/view/registry.js.map +1 -0
- package/dist/view/render/adopt-attr.d.ts +14 -0
- package/dist/view/render/adopt-attr.js +77 -0
- package/dist/view/render/adopt-attr.js.map +1 -0
- package/dist/view/render/adopt-plan.d.ts +10 -0
- package/dist/view/render/adopt-plan.js +26 -0
- package/dist/view/render/adopt-plan.js.map +1 -0
- package/dist/view/render/adopt.d.ts +3 -0
- package/dist/view/render/adopt.js +269 -0
- package/dist/view/render/adopt.js.map +1 -0
- package/dist/view/render/attr-parts.d.ts +61 -0
- package/dist/view/render/attr-parts.js +229 -0
- package/dist/view/render/attr-parts.js.map +1 -0
- package/dist/view/render/child-part.d.ts +51 -0
- package/dist/view/render/child-part.js +170 -0
- package/dist/view/render/child-part.js.map +1 -0
- package/dist/view/render/dev-check.d.ts +12 -0
- package/dist/view/render/dev-check.js +122 -0
- package/dist/view/render/dev-check.js.map +1 -0
- package/dist/view/render/hook-part.d.ts +3 -0
- package/dist/view/render/hook-part.js +20 -0
- package/dist/view/render/hook-part.js.map +1 -0
- package/dist/view/render/hooks.d.ts +40 -0
- package/dist/view/render/hooks.js +46 -0
- package/dist/view/render/hooks.js.map +1 -0
- package/dist/view/render/hydrate.d.ts +10 -0
- package/dist/view/render/hydrate.js +33 -0
- package/dist/view/render/hydrate.js.map +1 -0
- package/dist/view/render/instance.d.ts +33 -0
- package/dist/view/render/instance.js +107 -0
- package/dist/view/render/instance.js.map +1 -0
- package/dist/view/render/list.d.ts +20 -0
- package/dist/view/render/list.js +156 -0
- package/dist/view/render/list.js.map +1 -0
- package/dist/view/render/mismatch.d.ts +10 -0
- package/dist/view/render/mismatch.js +53 -0
- package/dist/view/render/mismatch.js.map +1 -0
- package/dist/view/render/nodes.d.ts +10 -0
- package/dist/view/render/nodes.js +37 -0
- package/dist/view/render/nodes.js.map +1 -0
- package/dist/view/render/place.d.ts +18 -0
- package/dist/view/render/place.js +69 -0
- package/dist/view/render/place.js.map +1 -0
- package/dist/view/render/plan.d.ts +26 -0
- package/dist/view/render/plan.js +124 -0
- package/dist/view/render/plan.js.map +1 -0
- package/dist/view/render/raw.d.ts +18 -0
- package/dist/view/render/raw.js +68 -0
- package/dist/view/render/raw.js.map +1 -0
- package/dist/view/render/render.d.ts +12 -0
- package/dist/view/render/render.js +60 -0
- package/dist/view/render/render.js.map +1 -0
- package/dist/view/render/reorder.d.ts +4 -0
- package/dist/view/render/reorder.js +101 -0
- package/dist/view/render/reorder.js.map +1 -0
- package/dist/view/render/rows.d.ts +23 -0
- package/dist/view/render/rows.js +95 -0
- package/dist/view/render/rows.js.map +1 -0
- package/dist/view/render/seen.d.ts +11 -0
- package/dist/view/render/seen.js +17 -0
- package/dist/view/render/seen.js.map +1 -0
- package/dist/view/render/values.d.ts +29 -0
- package/dist/view/render/values.js +13 -0
- package/dist/view/render/values.js.map +1 -0
- package/dist/view/render/warn.d.ts +14 -0
- package/dist/view/render/warn.js +69 -0
- package/dist/view/render/warn.js.map +1 -0
- package/dist/view/server/component.d.ts +9 -0
- package/dist/view/server/component.js +42 -0
- package/dist/view/server/component.js.map +1 -0
- package/dist/view/server/escape.d.ts +10 -0
- package/dist/view/server/escape.js +34 -0
- package/dist/view/server/escape.js.map +1 -0
- package/dist/view/server/index.d.ts +28 -0
- package/dist/view/server/index.js +72 -0
- package/dist/view/server/index.js.map +1 -0
- package/dist/view/server/sha256.d.ts +2 -0
- package/dist/view/server/sha256.js +75 -0
- package/dist/view/server/sha256.js.map +1 -0
- package/dist/view/server/tags.d.ts +57 -0
- package/dist/view/server/tags.js +121 -0
- package/dist/view/server/tags.js.map +1 -0
- package/dist/view/server/values.d.ts +16 -0
- package/dist/view/server/values.js +86 -0
- package/dist/view/server/values.js.map +1 -0
- package/dist/view/server/writer.d.ts +16 -0
- package/dist/view/server/writer.js +155 -0
- package/dist/view/server/writer.js.map +1 -0
- package/dist/view/styles.d.ts +25 -0
- package/dist/view/styles.js +58 -0
- package/dist/view/styles.js.map +1 -0
- package/dist/view/template-element.d.ts +3 -0
- package/dist/view/template-element.js +25 -0
- package/dist/view/template-element.js.map +1 -0
- package/dist/view/template.d.ts +21 -0
- package/dist/view/template.js +30 -0
- package/dist/view/template.js.map +1 -0
- package/dist/vite.d.ts +45 -6
- package/dist/vite.js +150 -25
- package/dist/vite.js.map +1 -1
- package/package.json +41 -7
- package/dist/accessible-name.d.ts +0 -19
- package/dist/accessible-name.js +0 -56
- package/dist/accessible-name.js.map +0 -1
- package/dist/element-directive.d.ts +0 -20
- package/dist/element-directive.js +0 -31
- package/dist/element-directive.js.map +0 -1
- package/dist/internal/runtime.d.ts +0 -7
- package/dist/internal/runtime.js +0 -8
- package/dist/internal/runtime.js.map +0 -1
- package/dist/invalid.d.ts +0 -21
- package/dist/invalid.js +0 -70
- package/dist/invalid.js.map +0 -1
- package/dist/live-boolean.d.ts +0 -22
- package/dist/live-boolean.js +0 -34
- package/dist/live-boolean.js.map +0 -1
- package/dist/styles.d.ts +0 -12
- package/dist/styles.js +0 -11
- package/dist/styles.js.map +0 -1
- package/dist/textarea.d.ts +0 -26
- package/dist/textarea.js +0 -85
- package/dist/textarea.js.map +0 -1
package/dist/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EACL,SAAS,GAKV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAoB,MAAM,2BAA2B,CAAC;AAG9E,MAAM,QAAQ,GAAY,QAAQ,CAAC;AA0FnC,6FAA6F;AAC7F,MAAM,UAAU,WAAW,CAAsB,IAAY,EAAE,IAAqB;IAClF,MAAM,KAAK,GAAgB;QACzB,IAAI;QACJ,IAAI;QACJ,QAAQ,EAAE,CAAC,OAAW,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC;QACzD,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;KAClD,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,KAA6B,EAAU,EAAE,CAC1D,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAErF,SAAS,SAAS,CAChB,MAAgD,EAChD,IAAa;IAEb,oFAAoF;IACpF,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAS,EAAE,CAAC;IAChE,M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AAC;QAC9B,UAAU,CAAC,GAAG,EAAE;YACd,GAAG,CAAC,YAAY,CAAC,CAAC;QACpB,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,4FAA4F;AAC5F,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,mBAAmB;IACzB,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS;CACZ,CAAC;AAQX,8FAA8F;AAC9F,gGAAgG;AAChG,gGAAgG;AAChG,MAAM,UAAU,IAAI,CAAsB,KAAkB,EAAE,GAAe;IAC3E,MAAM,KAAK,GAAmB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IAC7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;AACnE,CAAC;AAWD,mFAAmF;AACnF,MAAM,UAAU,OAAO,CACrB,KAAkB,EAClB,GAAiB;IAEjB,oFAAoF;IACpF,OAAO,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAU,EAAE,IAAI,EAAE,GAAG,CAAC,IAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/F,CAAC","sourcesContent":["// Shared state: stores as \"props from the side\" (docs/design-docs/0013-shared-state.md).\n// A store is MVI without a view: init + pure update, commands run by its own interpreter.\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { isServer } from 'lit';\nimport { DEVTOOLS_ENABLED, devCommands, devStore } from '#devtools';\nimport {\n splitNext,\n type AnyDriver,\n type Command,\n type DriverOverrides,\n type Next,\n} from './command.js';\nimport { makeInterpreter, type Interpreter } from './internal/interpreter.js';\nimport type { IntentRejected, Tagged } from './types.js';\n\nconst onServer: boolean = isServer;\n\ntype Variant<M extends Tagged, K extends M['_tag']> = Extract<M, { readonly _tag: K }>;\n\n/** One pure reducer per message tag, like a component's `update` but without context. */\nexport type StoreUpdate<S, M extends Tagged> = {\n readonly [K in M['_tag']]: (state: S, msg: Variant<M, K>) => Next<S, M>;\n};\n\nexport interface StoreSpec<S, M extends Tagged> {\n /** Initial state (and optional commands, e.g. load a saved cart). */\n readonly init: () => Next<S, M>;\n readonly update: StoreUpdate<S, M>;\n /** Driver substitutions by name for this store's commands. */\n readonly drivers?: DriverOverrides;\n /**\n * Validates the server's page seed before the client uses it (any synchronous Standard\n * Schema). An invalid seed is reported with console.error and the store starts from `init`.\n */\n readonly schema?: StandardSchemaV1<unknown, S>;\n}\n\n/** The result of checking a seed against a store's schema. */\nexport type SeedCheck<S> =\n | { readonly ok: true; readonly state: S }\n | { readonly ok: false; readonly issues: readonly string[] };\n\n/** What `ctx.read()` accepts: anything that names a store and carries its state type. */\nexport interface StoreRef<S> {\n readonly name: string;\n /** Type-only marker for the state type. Never set at runtime. */\n readonly stateType?: (state: S) => S;\n}\n\n/** A live store: one per page on the client, one per request on the server, one per test. */\nexport interface StoreInstance<S, M extends Tagged> {\n readonly store: Store<S, M>;\n readonly state: S;\n /** Feeds a message through the store's `update` and notifies subscribers on change. */\n send(msg: M): void;\n /** Called after every state change. Returns an unsubscribe function. */\n subscribe(listener: (state: S, prev: S) => void): () => void;\n /** Per-instance driver substitutions (test fakes). Checked before the spec's. */\n drivers: DriverOverrides;\n /** Stops running commands and drops subscribers. */\n dispose(): void;\n /** Set by the registry that holds the instance (store-to-store `send`). */\n bindScope(resolve: StoreResolver): void;\n}\n\nexport interface Store<S, M extends Tagged> extends StoreRef<S> {\n readonly spec: StoreSpec<S, M>;\n /**\n * A fresh, independent instance. `initial` skips `init`'s state (a server seed, a test\n * fixture); `init`'s commands still run on the client.\n */\n instance(initial?: S): StoreInstance<S, M>;\n /** Checks a seed with `spec.schema` (ok as-is without one). */\n checkSeed(seed: unknown): SeedCheck<S>;\n /** Type-only marker for the message type. Never set at runtime. */\n readonly messageType?: (msg: M) => M;\n}\n\n/** Any store, with its types erased (for declarations and registries). */\nexport interface AnyStore {\n readonly name: string;\n instance(initial?: never): AnyStoreInstance;\n checkSeed(seed: unknown): SeedCheck<unknown>;\n}\n\n/** Any store instance, with its types erased. */\nexport interface AnyStoreInstance {\n readonly store: AnyStore;\n readonly state: unknown;\n send(msg: never): void;\n subscribe(listener: (state: unknown, prev: unknown) => void): () => void;\n dispose(): void;\n /**\n * Called by the registry that holds this instance, so the store's `send(other, msg)`\n * commands reach `other`'s instance in the same scope (gyral-czi.20).\n */\n bindScope?(resolve: StoreResolver): void;\n}\n\n/** Finds a store's instance in a scope (a registry). */\nexport type StoreResolver = (store: AnyStore) => AnyStoreInstance;\n\n/** Store instances substituted by store name (tests, islands). */\nexport type StoreOverrides = Readonly<Record<string, AnyStoreInstance>>;\n\n/** Defines a store. `name` keys it in registries, seeds and overrides, so keep it unique. */\nexport function defineStore<S, M extends Tagged>(name: string, spec: StoreSpec<S, M>): Store<S, M> {\n const store: Store<S, M> = {\n name,\n spec,\n instance: (initial?: S) => createInstance(store, initial),\n checkSeed: (seed) => checkSeed(spec.schema, seed),\n };\n return store;\n}\n\nconst issuePath = (issue: StandardSchemaV1.Issue): string =>\n (issue.path ?? []).map((s) => String(typeof s === 'object' ? s.key : s)).join('.');\n\nfunction checkSeed<S>(\n schema: StandardSchemaV1<unknown, S> | undefined,\n seed: unknown,\n): SeedCheck<S> {\n // Sound without a schema: the seed is this store's state, serialized by the server.\n if (schema === undefined) return { ok: true, state: seed as S };\n const result = schema['~standard'].validate(seed);\n if (result instanceof Promise) {\n return { ok: false, issues: ['the store schema is async; seeds need a synchronous schema'] };\n }\n if (result.issues === undefined) return { ok: true, state: result.value };\n return {\n ok: false,\n issues: result.issues.map((i) => `${issuePath(i) || '(root)'}: ${i.message}`),\n };\n}\n\nfunction createInstance<S, M extends Tagged>(\n store: Store<S, M>,\n initial: S | undefined,\n): StoreInstance<S, M> {\n // Sound: send() only calls the reducer whose key equals msg._tag.\n const reducers = store.spec.update as unknown as Readonly<\n Record<string, ((state: S, msg: M) => Next<S, M>) | undefined>\n >;\n const listeners = new Set<(state: S, prev: S) => void>();\n let interpreter: Interpreter<M | IntentRejected> | undefined;\n let disposed = false;\n\n const [initState, initCommands] = splitNext(store.spec.init());\n let state = initial === undefined ? initState : initial;\n\n const resolve = (driver: AnyDriver): AnyDriver =>\n instance.drivers[driver.name] ?? store.spec.drivers?.[driver.name] ?? driver;\n\n let scope: StoreResolver | undefined;\n\n // Store-to-store writes: delivered synchronously to the other store's instance in scope.\n const deliver = ({ store: target, msg }: StoreSendInput): void => {\n if (scope === undefined) {\n console.warn(\n `store \"${store.name}\" sends to \"${target.name}\" but is not held by a store scope ` +\n '(a registry, <gyral-stores> or the page default), so the message is dropped.',\n );\n return;\n }\n (scope(target) as { send(msg: unknown): void }).send(msg);\n };\n\n const run = (commands: ReadonlyArray<Command<M | IntentRejected>>): void => {\n if (onServer || disposed || commands.length === 0) return; // never on the server (ADR 0012)\n for (const cmd of commands) {\n if (cmd.driver === STORE_SEND) {\n deliver(cmd.input as StoreSendInput);\n continue;\n }\n interpreter ??= makeInterpreter<M | IntentRejected>(\n resolve,\n (msg) => {\n // Stores have no IntentRejected reducer; only their own messages apply.\n if (msg._tag !== 'IntentRejected') instance.send(msg as M);\n },\n DEVTOOLS_ENABLED ? devCommands(() => `store:${store.name}`) : undefined,\n );\n interpreter.run(cmd);\n }\n };\n\n const instance: StoreInstance<S, M> = {\n store,\n get state() {\n return state;\n },\n drivers: {},\n send(msg) {\n const reducer = reducers[msg._tag];\n if (reducer === undefined) {\n console.warn(`store \"${store.name}\" has no update for message \"${msg._tag}\".`);\n return;\n }\n const prev = state;\n const [next, commands] = splitNext(reducer(prev, msg));\n state = next;\n if (DEVTOOLS_ENABLED) devStore(store.name, msg, prev, next);\n if (!Object.is(next, prev)) for (const listener of [...listeners]) listener(next, prev);\n run(commands);\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n dispose() {\n disposed = true;\n interpreter?.dispose();\n listeners.clear();\n },\n bindScope(resolver) {\n scope = resolver;\n },\n };\n\n // A seeded instance (hydration) starts init's commands after the hydrating renders flushed,\n // so a fast driver can't change state under them (same reason as ADR 0012 for components).\n if (initial === undefined) run(initCommands);\n else if (initCommands.length > 0)\n setTimeout(() => {\n run(initCommands);\n }, 0);\n return instance;\n}\n\n/** Marker driver for `send()`: `define()` delivers these to the resolved store instance. */\nexport const STORE_SEND = {\n name: '@gyral/store-send',\n run: () => undefined,\n} as const;\n\n/** The input of a `send()` command. */\nexport interface StoreSendInput {\n readonly store: AnyStore;\n readonly msg: Tagged;\n}\n\n/** A command that sends `msg` to the component's instance of `store`. Writes are commands. */\n// NoInfer: the store decides the message type, so a literal (`{ _tag: 'Track', … }`) is checked\n// against it instead of widening `_tag` to string (store-to-store sends have no other context).\nexport function send<S, M extends Tagged>(store: Store<S, M>, msg: NoInfer<M>): Command<never> {\n const input: StoreSendInput = { store, msg };\n return { driver: STORE_SEND, input, onSuccess: () => undefined };\n}\n\n/** Framework message: a store this component reads changed (ADR 0013). Optional reducer. */\nexport interface StoreChanged {\n readonly _tag: 'StoreChanged';\n /** The store's name. Narrow with `changed(store, msg)`. */\n readonly store: string;\n readonly state: unknown;\n readonly prev: unknown;\n}\n\n/** Narrows a `StoreChanged` message to one store's typed state, or `undefined`. */\nexport function changed<S>(\n store: StoreRef<S>,\n msg: StoreChanged,\n): { readonly state: S; readonly prev: S } | undefined {\n // Sound: the message was built from this store's instance (matched by unique name).\n return msg.store === store.name ? { state: msg.state as S, prev: msg.prev as S } : undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EACL,SAAS,GAKV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAkB,MAAM,eAAe,CAAC;AACzD,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,IAAI,EAAE,mBAAmB;IACzB,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS;IACpB,gFAAgF;IAChF,KAAK,EAAE,CAAC,IAAe,EAAE,KAAc,EAAE,EAAE;QACzC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,KAAuB,CAAC,CAAC;IAC9C,CAAC;CACO,CAAC;AAQX,8FAA8F;AAC9F,gGAAgG;AAChG,gGAAgG;AAChG,MAAM,UAAU,IAAI,CAAsB,KAAkB,EAAE,GAAe;IAC3E,MAAM,KAAK,GAAmB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IAC7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;AACnE,CAAC;AAWD,mFAAmF;AACnF,MAAM,UAAU,OAAO,CACrB,KAAkB,EAClB,GAAiB;IAEjB,oFAAoF;IACpF,OAAO,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAU,EAAE,IAAI,EAAE,GAAG,CAAC,IAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/F,CAAC","sourcesContent":["// Shared state: stores as \"props from the side\" (docs/design-docs/0013-shared-state.md).\n// A store is MVI without a view: init + pure update, commands run by its own interpreter.\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { DEVTOOLS_ENABLED, devCommands, devStore } from '#devtools';\nimport {\n splitNext,\n type AnyDriver,\n type Command,\n type DriverOverrides,\n type Next,\n} from './command.js';\nimport { features, type LocalHost } from './features.js';\nimport { makeInterpreter, type Interpreter } from './internal/interpreter.js';\nimport { bindStores } from './store-binding.js';\nimport type { IntentRejected, Tagged } from './types.js';\n\n/** No DOM means a server render: store commands never run there (ADR 0012). */\nconst onServer = typeof document === 'undefined';\n\ntype Variant<M extends Tagged, K extends M['_tag']> = Extract<M, { readonly _tag: K }>;\n\n/** One pure reducer per message tag, like a component's `update` but without context. */\nexport type StoreUpdate<S, M extends Tagged> = {\n readonly [K in M['_tag']]: (state: S, msg: Variant<M, K>) => Next<S, M>;\n};\n\nexport interface StoreSpec<S, M extends Tagged> {\n /** Initial state (and optional commands, e.g. load a saved cart). */\n readonly init: () => Next<S, M>;\n readonly update: StoreUpdate<S, M>;\n /** Driver substitutions by name for this store's commands. */\n readonly drivers?: DriverOverrides;\n /**\n * Validates the server's page seed before the client uses it (any synchronous Standard\n * Schema). An invalid seed is reported with console.error and the store starts from `init`.\n */\n readonly schema?: StandardSchemaV1<unknown, S>;\n}\n\n/** The result of checking a seed against a store's schema. */\nexport type SeedCheck<S> =\n | { readonly ok: true; readonly state: S }\n | { readonly ok: false; readonly issues: readonly string[] };\n\n/** What `ctx.read()` accepts: anything that names a store and carries its state type. */\nexport interface StoreRef<S> {\n readonly name: string;\n /** Type-only marker for the state type. Never set at runtime. */\n readonly stateType?: (state: S) => S;\n}\n\n/** A live store: one per page on the client, one per request on the server, one per test. */\nexport interface StoreInstance<S, M extends Tagged> {\n readonly store: Store<S, M>;\n readonly state: S;\n /** Feeds a message through the store's `update` and notifies subscribers on change. */\n send(msg: M): void;\n /** Called after every state change. Returns an unsubscribe function. */\n subscribe(listener: (state: S, prev: S) => void): () => void;\n /** Per-instance driver substitutions (test fakes). Checked before the spec's. */\n drivers: DriverOverrides;\n /** Stops running commands and drops subscribers. */\n dispose(): void;\n /** Set by the registry that holds the instance (store-to-store `send`). */\n bindScope(resolve: StoreResolver): void;\n}\n\nexport interface Store<S, M extends Tagged> extends StoreRef<S> {\n readonly spec: StoreSpec<S, M>;\n /**\n * A fresh, independent instance. `initial` skips `init`'s state (a server seed, a test\n * fixture); `init`'s commands still run on the client.\n */\n instance(initial?: S): StoreInstance<S, M>;\n /** Checks a seed with `spec.schema` (ok as-is without one). */\n checkSeed(seed: unknown): SeedCheck<S>;\n /** Type-only marker for the message type. Never set at runtime. */\n readonly messageType?: (msg: M) => M;\n}\n\n/** Any store, with its types erased (for declarations and registries). */\nexport interface AnyStore {\n readonly name: string;\n instance(initial?: never): AnyStoreInstance;\n checkSeed(seed: unknown): SeedCheck<unknown>;\n}\n\n/** Any store instance, with its types erased. */\nexport interface AnyStoreInstance {\n readonly store: AnyStore;\n readonly state: unknown;\n send(msg: never): void;\n subscribe(listener: (state: unknown, prev: unknown) => void): () => void;\n dispose(): void;\n /**\n * Called by the registry that holds this instance, so the store's `send(other, msg)`\n * commands reach `other`'s instance in the same scope (gyral-czi.20).\n */\n bindScope?(resolve: StoreResolver): void;\n}\n\n/** Finds a store's instance in a scope (a registry). */\nexport type StoreResolver = (store: AnyStore) => AnyStoreInstance;\n\n/** Store instances substituted by store name (tests, islands). */\nexport type StoreOverrides = Readonly<Record<string, AnyStoreInstance>>;\n\n/** Defines a store. `name` keys it in registries, seeds and overrides, so keep it unique. */\nexport function defineStore<S, M extends Tagged>(name: string, spec: StoreSpec<S, M>): Store<S, M> {\n features.stores = bindStores; // components can use stores now (features.ts)\n const store: Store<S, M> = {\n name,\n spec,\n instance: (initial?: S) => createInstance(store, initial),\n checkSeed: (seed) => checkSeed(spec.schema, seed),\n };\n return store;\n}\n\nconst issuePath = (issue: StandardSchemaV1.Issue): string =>\n (issue.path ?? []).map((s) => String(typeof s === 'object' ? s.key : s)).join('.');\n\nfunction checkSeed<S>(\n schema: StandardSchemaV1<unknown, S> | undefined,\n seed: unknown,\n): SeedCheck<S> {\n // Sound without a schema: the seed is this store's state, serialized by the server.\n if (schema === undefined) return { ok: true, state: seed as S };\n const result = schema['~standard'].validate(seed);\n if (result instanceof Promise) {\n return { ok: false, issues: ['the store schema is async; seeds need a synchronous schema'] };\n }\n if (result.issues === undefined) return { ok: true, state: result.value };\n return {\n ok: false,\n issues: result.issues.map((i) => `${issuePath(i) || '(root)'}: ${i.message}`),\n };\n}\n\nfunction createInstance<S, M extends Tagged>(\n store: Store<S, M>,\n initial: S | undefined,\n): StoreInstance<S, M> {\n // Sound: send() only calls the reducer whose key equals msg._tag.\n const reducers = store.spec.update as unknown as Readonly<\n Record<string, ((state: S, msg: M) => Next<S, M>) | undefined>\n >;\n const listeners = new Set<(state: S, prev: S) => void>();\n let interpreter: Interpreter<M | IntentRejected> | undefined;\n let disposed = false;\n\n const [initState, initCommands] = splitNext(store.spec.init());\n let state = initial === undefined ? initState : initial;\n\n const resolve = (driver: AnyDriver): AnyDriver =>\n instance.drivers[driver.name] ?? store.spec.drivers?.[driver.name] ?? driver;\n\n let scope: StoreResolver | undefined;\n\n // Store-to-store writes: delivered synchronously to the other store's instance in scope.\n const deliver = ({ store: target, msg }: StoreSendInput): void => {\n if (scope === undefined) {\n console.warn(\n `store \"${store.name}\" sends to \"${target.name}\" but is not held by a store scope ` +\n '(a registry, <gyral-stores> or the page default), so the message is dropped.',\n );\n return;\n }\n (scope(target) as { send(msg: unknown): void }).send(msg);\n };\n\n const run = (commands: ReadonlyArray<Command<M | IntentRejected>>): void => {\n if (onServer || disposed || commands.length === 0) return; // never on the server (ADR 0012)\n for (const cmd of commands) {\n if (cmd.driver === STORE_SEND) {\n deliver(cmd.input as StoreSendInput);\n continue;\n }\n interpreter ??= makeInterpreter<M | IntentRejected>(\n resolve,\n (msg) => {\n // Stores have no IntentRejected reducer; only their own messages apply.\n if (msg._tag !== 'IntentRejected') instance.send(msg as M);\n },\n DEVTOOLS_ENABLED ? devCommands(() => `store:${store.name}`) : undefined,\n );\n interpreter.run(cmd);\n }\n };\n\n const instance: StoreInstance<S, M> = {\n store,\n get state() {\n return state;\n },\n drivers: {},\n send(msg) {\n const reducer = reducers[msg._tag];\n if (reducer === undefined) {\n console.warn(`store \"${store.name}\" has no update for message \"${msg._tag}\".`);\n return;\n }\n const prev = state;\n const [next, commands] = splitNext(reducer(prev, msg));\n state = next;\n if (DEVTOOLS_ENABLED) devStore(store.name, msg, prev, next);\n if (!Object.is(next, prev)) for (const listener of [...listeners]) listener(next, prev);\n run(commands);\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n dispose() {\n disposed = true;\n interpreter?.dispose();\n listeners.clear();\n },\n bindScope(resolver) {\n scope = resolver;\n },\n };\n\n // A seeded instance (hydration) starts init's commands after the hydrating renders flushed,\n // so a fast driver can't change state under them (same reason as ADR 0012 for components).\n if (initial === undefined) run(initCommands);\n else if (initCommands.length > 0)\n setTimeout(() => {\n run(initCommands);\n }, 0);\n return instance;\n}\n\n/** Marker driver for `send()`: `define()` delivers these to the resolved store instance. */\nexport const STORE_SEND = {\n name: '@gyral/store-send',\n run: () => undefined,\n /** A component's send: delivered to its instance of the store (features.ts). */\n local: (host: LocalHost, input: unknown) => {\n host.stores().send(input as StoreSendInput);\n },\n} as const;\n\n/** The input of a `send()` command. */\nexport interface StoreSendInput {\n readonly store: AnyStore;\n readonly msg: Tagged;\n}\n\n/** A command that sends `msg` to the component's instance of `store`. Writes are commands. */\n// NoInfer: the store decides the message type, so a literal (`{ _tag: 'Track', … }`) is checked\n// against it instead of widening `_tag` to string (store-to-store sends have no other context).\nexport function send<S, M extends Tagged>(store: Store<S, M>, msg: NoInfer<M>): Command<never> {\n const input: StoreSendInput = { store, msg };\n return { driver: STORE_SEND, input, onSuccess: () => undefined };\n}\n\n/** Framework message: a store this component reads changed (ADR 0013). Optional reducer. */\nexport interface StoreChanged {\n readonly _tag: 'StoreChanged';\n /** The store's name. Narrow with `changed(store, msg)`. */\n readonly store: string;\n readonly state: unknown;\n readonly prev: unknown;\n}\n\n/** Narrows a `StoreChanged` message to one store's typed state, or `undefined`. */\nexport function changed<S>(\n store: StoreRef<S>,\n msg: StoreChanged,\n): { readonly state: S; readonly prev: S } | undefined {\n // Sound: the message was built from this store's instance (matched by unique name).\n return msg.store === store.name ? { state: msg.state as S, prev: msg.prev as S } : undefined;\n}\n"]}
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* where a plain `<gyral-stores>` element already scopes stores and the server's shadow root
|
|
4
|
-
* (a `<slot>`) needs no JavaScript. Idempotent.
|
|
5
|
-
*/
|
|
6
|
-
export declare function defineStoresProvider(): void;
|
|
1
|
+
import { type ServerProvider } from './view/index.js';
|
|
2
|
+
export declare const storesProvider: ServerProvider;
|
package/dist/stores-provider.js
CHANGED
|
@@ -1,57 +1,23 @@
|
|
|
1
|
-
// `<gyral-stores>`
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
1
|
+
// `<gyral-stores>` on the server (ADR 0013, view/06-server.md "Components"). In the browser a
|
|
2
|
+
// provider is a plain element: scopeFor() walks the DOM to it. On the server it is written as a
|
|
3
|
+
// plain element too, and the renderer gives its subtree the provider's registry (components'
|
|
4
|
+
// `ctx.read` resolves there) and writes its `data-gyral-stores` seed: the states of the
|
|
5
|
+
// instances passed in `.instances`. Stores not listed start from `init` on both sides.
|
|
6
6
|
import { warnJsonHazard } from './json-safety.js';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// Written before the attributes render; the client restores it (providerScope()).
|
|
24
|
-
if (value !== undefined && value.length > 0) {
|
|
25
|
-
const seed = Object.fromEntries(value.map((i) => [i.store.name, i.state]));
|
|
26
|
-
for (const [name, state] of Object.entries(seed)) {
|
|
27
|
-
warnJsonHazard(`store "${name}" in <${STORES_ELEMENT}>`, state, 'state');
|
|
28
|
-
}
|
|
29
|
-
this.setAttribute(STORE_SEED_ATTRIBUTE, JSON.stringify(seed));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
constructor() {
|
|
33
|
-
super();
|
|
34
|
-
// Lit's SSR routes a slotted child's events slot → getRootNode() → host, and the root is
|
|
35
|
-
// only this element's shadow root if one exists; the renderer never calls connectedCallback
|
|
36
|
-
// (which would create it), so attach it here.
|
|
37
|
-
this.attachShadow({ mode: 'open' });
|
|
38
|
-
this.addEventListener(STORES_REQUEST, (event) => {
|
|
39
|
-
event.stopPropagation();
|
|
40
|
-
event.detail.registry = providerScope(this);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
render() {
|
|
44
|
-
return html `<slot></slot>`;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Registers `<gyral-stores>` for server renders; `@gyral/ssr` calls it. A no-op in the browser,
|
|
49
|
-
* where a plain `<gyral-stores>` element already scopes stores and the server's shadow root
|
|
50
|
-
* (a `<slot>`) needs no JavaScript. Idempotent.
|
|
51
|
-
*/
|
|
52
|
-
export function defineStoresProvider() {
|
|
53
|
-
if (onServer && customElements.get(STORES_ELEMENT) === undefined) {
|
|
54
|
-
customElements.define(STORES_ELEMENT, GyralStores);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
7
|
+
import { STORE_SEED_ATTRIBUTE, STORES_ELEMENT, StoreRegistry } from './store-scope.js';
|
|
8
|
+
import { DEV } from './view/index.js';
|
|
9
|
+
export const storesProvider = {
|
|
10
|
+
tag: STORES_ELEMENT,
|
|
11
|
+
open({ properties }) {
|
|
12
|
+
const listed = properties['instances'];
|
|
13
|
+
const instances = Array.isArray(listed) ? listed : [];
|
|
14
|
+
const registry = new StoreRegistry(instances);
|
|
15
|
+
if (instances.length === 0)
|
|
16
|
+
return { scope: registry, attributes: {} };
|
|
17
|
+
const snapshot = registry.snapshot();
|
|
18
|
+
if (DEV)
|
|
19
|
+
warnJsonHazard(`<${STORES_ELEMENT}>`, snapshot, 'seed');
|
|
20
|
+
return { scope: registry, attributes: { [STORE_SEED_ATTRIBUTE]: JSON.stringify(snapshot) } };
|
|
21
|
+
},
|
|
22
|
+
};
|
|
57
23
|
//# sourceMappingURL=stores-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stores-provider.js","sourceRoot":"","sources":["../src/stores-provider.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"stores-provider.js","sourceRoot":"","sources":["../src/stores-provider.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,gGAAgG;AAChG,6FAA6F;AAC7F,wFAAwF;AACxF,uFAAuF;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEvF,OAAO,EAAE,GAAG,EAAuB,MAAM,iBAAiB,CAAC;AAE3D,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,GAAG,EAAE,cAAc;IACnB,IAAI,CAAC,EAAE,UAAU,EAAE;QACjB,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QACvC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvF,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QACvE,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACrC,IAAI,GAAG;YAAE,cAAc,CAAC,IAAI,cAAc,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACjE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;IAC/F,CAAC;CACF,CAAC","sourcesContent":["// `<gyral-stores>` on the server (ADR 0013, view/06-server.md \"Components\"). In the browser a\n// provider is a plain element: scopeFor() walks the DOM to it. On the server it is written as a\n// plain element too, and the renderer gives its subtree the provider's registry (components'\n// `ctx.read` resolves there) and writes its `data-gyral-stores` seed: the states of the\n// instances passed in `.instances`. Stores not listed start from `init` on both sides.\nimport { warnJsonHazard } from './json-safety.js';\nimport { STORE_SEED_ATTRIBUTE, STORES_ELEMENT, StoreRegistry } from './store-scope.js';\nimport type { AnyStoreInstance } from './store.js';\nimport { DEV, type ServerProvider } from './view/index.js';\n\nexport const storesProvider: ServerProvider = {\n tag: STORES_ELEMENT,\n open({ properties }) {\n const listed = properties['instances'];\n const instances = Array.isArray(listed) ? (listed as readonly AnyStoreInstance[]) : [];\n const registry = new StoreRegistry(instances);\n if (instances.length === 0) return { scope: registry, attributes: {} };\n const snapshot = registry.snapshot();\n if (DEV) warnJsonHazard(`<${STORES_ELEMENT}>`, snapshot, 'seed');\n return { scope: registry, attributes: { [STORE_SEED_ATTRIBUTE]: JSON.stringify(snapshot) } };\n },\n};\n"]}
|
package/dist/transitions.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/** True when a view transition may run now (API present, motion not reduced). */
|
|
2
|
-
export declare
|
|
2
|
+
export declare const canTransition: () => boolean;
|
|
3
3
|
/**
|
|
4
|
-
* Runs `update`
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* rejected `ready` is expected and swallowed.
|
|
4
|
+
* Runs `update` (a whole flush) as a view transition's update callback. A transition skipped
|
|
5
|
+
* by a newer one still runs its update (per spec); its rejected promises are expected and
|
|
6
|
+
* swallowed. Call only after `canTransition()`.
|
|
8
7
|
*/
|
|
9
|
-
export declare function
|
|
8
|
+
export declare function startTransition(update: () => void): void;
|
package/dist/transitions.js
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
// View Transitions for
|
|
2
|
-
// without the API, or with reduced motion requested,
|
|
3
|
-
|
|
1
|
+
// View Transitions for the scheduler (view/04-scheduler.md "View transitions", ADR 0001
|
|
2
|
+
// addendum). An ADR 0003 enhancement: without the API, or with reduced motion requested, the
|
|
3
|
+
// flush runs as normal.
|
|
4
4
|
const ignore = () => undefined;
|
|
5
5
|
/** True when a view transition may run now (API present, motion not reduced). */
|
|
6
|
-
export
|
|
7
|
-
if (typeof document === 'undefined' || !supportsViewTransitions(document))
|
|
8
|
-
return false;
|
|
9
|
-
return !window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
10
|
-
}
|
|
6
|
+
export const canTransition = () => 'startViewTransition' in document && !matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
11
7
|
/**
|
|
12
|
-
* Runs `update`
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* rejected `ready` is expected and swallowed.
|
|
8
|
+
* Runs `update` (a whole flush) as a view transition's update callback. A transition skipped
|
|
9
|
+
* by a newer one still runs its update (per spec); its rejected promises are expected and
|
|
10
|
+
* swallowed. Call only after `canTransition()`.
|
|
16
11
|
*/
|
|
17
|
-
export function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const transition = document.startViewTransition(() => update().then(resolve, reject));
|
|
22
|
-
transition.ready.catch(ignore);
|
|
23
|
-
transition.finished.catch(ignore);
|
|
24
|
-
});
|
|
12
|
+
export function startTransition(update) {
|
|
13
|
+
const transition = document.startViewTransition(update);
|
|
14
|
+
transition.ready.catch(ignore);
|
|
15
|
+
transition.finished.catch(ignore);
|
|
25
16
|
}
|
|
26
17
|
//# sourceMappingURL=transitions.js.map
|
package/dist/transitions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transitions.js","sourceRoot":"","sources":["../src/transitions.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"transitions.js","sourceRoot":"","sources":["../src/transitions.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,6FAA6F;AAC7F,wBAAwB;AAWxB,MAAM,MAAM,GAAG,GAAS,EAAE,CAAC,SAAS,CAAC;AAErC,iFAAiF;AACjF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAY,EAAE,CACzC,qBAAqB,IAAI,QAAQ,IAAI,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AAE/F;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAkB;IAChD,MAAM,UAAU,GAAI,QAA8C,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC/F,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC","sourcesContent":["// View Transitions for the scheduler (view/04-scheduler.md \"View transitions\", ADR 0001\n// addendum). An ADR 0003 enhancement: without the API, or with reduced motion requested, the\n// flush runs as normal.\n\ninterface ViewTransitionLike {\n readonly ready: Promise<unknown>;\n readonly finished: Promise<unknown>;\n}\n\ninterface ViewTransitionDocument {\n startViewTransition(update: () => void): ViewTransitionLike;\n}\n\nconst ignore = (): void => undefined;\n\n/** True when a view transition may run now (API present, motion not reduced). */\nexport const canTransition = (): boolean =>\n 'startViewTransition' in document && !matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n/**\n * Runs `update` (a whole flush) as a view transition's update callback. A transition skipped\n * by a newer one still runs its update (per spec); its rejected promises are expected and\n * swallowed. Call only after `canTransition()`.\n */\nexport function startTransition(update: () => void): void {\n const transition = (document as Document & ViewTransitionDocument).startViewTransition(update);\n transition.ready.catch(ignore);\n transition.finished.catch(ignore);\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Styles } from './
|
|
1
|
+
import type { Prop } from './prop.js';
|
|
2
|
+
import type { ChildValue, Styles } from './view/index.js';
|
|
3
3
|
import type { CommandInfo } from './invokers.js';
|
|
4
4
|
import type { HydrateStrategy } from './islands.js';
|
|
5
5
|
import type { DriverOverrides, Next } from './command.js';
|
|
@@ -106,25 +106,13 @@ export type IntentNames<M extends Tagged> = {
|
|
|
106
106
|
readonly [K in M['_tag']]: K;
|
|
107
107
|
};
|
|
108
108
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* - `default: value`: used whenever the element's value is `undefined`.
|
|
114
|
-
* A prop whose type includes `undefined` needs neither.
|
|
109
|
+
* The prop builders for props type `P` (view/05-element.md "Props"): one `prop.*` builder per
|
|
110
|
+
* key. A builder's output type must fit the prop's type, so a prop whose type excludes
|
|
111
|
+
* `undefined` needs `required: true` or a `default` (the honesty rule, ADR 0007 addendum).
|
|
112
|
+
* Without explicit type arguments, `define()` infers `P` from the builders.
|
|
115
113
|
*/
|
|
116
|
-
export type PropDeclaration<T> = PropertyDeclaration & (undefined extends T ? {
|
|
117
|
-
readonly required?: false;
|
|
118
|
-
readonly default?: T;
|
|
119
|
-
} : {
|
|
120
|
-
readonly required: true;
|
|
121
|
-
readonly default?: undefined;
|
|
122
|
-
} | {
|
|
123
|
-
readonly required?: false;
|
|
124
|
-
readonly default: T;
|
|
125
|
-
});
|
|
126
114
|
export type PropDeclarations<P> = {
|
|
127
|
-
readonly [K in keyof P]-?:
|
|
115
|
+
readonly [K in keyof P]-?: Prop<P[K]>;
|
|
128
116
|
};
|
|
129
117
|
/** State of a component that keeps none (a pure view of its props). Its `init` is optional. */
|
|
130
118
|
export type Stateless = Readonly<Record<string, never>>;
|
|
@@ -137,17 +125,17 @@ type InitField<S, M extends Tagged, P> = Stateless extends S ? {
|
|
|
137
125
|
};
|
|
138
126
|
export type ComponentSpec<S, M extends Tagged, P> = SpecBody<S, M, P> & InitField<S, M, P>;
|
|
139
127
|
interface SpecBody<S, M extends Tagged, P> {
|
|
140
|
-
/**
|
|
128
|
+
/** The component's inputs, declared with `prop.*` builders. */
|
|
141
129
|
readonly props?: PropDeclarations<P>;
|
|
142
130
|
/** INTENT: platform events to messages. */
|
|
143
131
|
readonly intent: Intents<M>;
|
|
144
132
|
/** MODEL: pure state transitions. */
|
|
145
133
|
readonly update: Update<S, M, P>;
|
|
146
134
|
/** VIEW: pure function of state and props. Name intents in markup; never attach closures. */
|
|
147
|
-
readonly view: (state: S, intents: IntentNames<M>, ctx: Ctx<P>) =>
|
|
135
|
+
readonly view: (state: S, intents: IntentNames<M>, ctx: Ctx<P>) => ChildValue;
|
|
148
136
|
/**
|
|
149
|
-
* Shadow-root styles: `css`
|
|
150
|
-
*
|
|
137
|
+
* Shadow-root styles: `css` values, plain CSS strings, or arrays of them, nested freely.
|
|
138
|
+
* Each maps to one shared `CSSStyleSheet`. Ignored (with a warning) when `shadow: false`.
|
|
151
139
|
*/
|
|
152
140
|
readonly styles?: Styles;
|
|
153
141
|
/**
|
|
@@ -176,6 +164,14 @@ interface SpecBody<S, M extends Tagged, P> {
|
|
|
176
164
|
* reorders). Skipped without browser support or when reduced motion is requested.
|
|
177
165
|
*/
|
|
178
166
|
readonly viewTransition?: (prev: S, next: S, msg: Tagged) => boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Messages from bursty sources (a WebSocket feed, a sensor) whose renders wait for the next
|
|
169
|
+
* animation frame, so many messages in one frame cost one render: `renderOnFrame: ['Ticked']`.
|
|
170
|
+
* Reducers still run at once. Any other change to the component renders in the usual
|
|
171
|
+
* microtask flush, taking pending frame work with it. `'StoreChanged'` covers store changes.
|
|
172
|
+
* Pages that get no frames (hidden) render from a 100 ms timer. view/04-scheduler.md.
|
|
173
|
+
*/
|
|
174
|
+
readonly renderOnFrame?: readonly (M['_tag'] | 'StoreChanged')[];
|
|
179
175
|
/**
|
|
180
176
|
* Boolean facts about the state, exposed to CSS as custom states:
|
|
181
177
|
* `states: (s) => ({ loading: s._tag === 'Loading' })` enables `:host(:state(loading))` and
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Prop } from './prop.js';\nimport type { ChildValue, Styles } from './view/index.js';\nimport type { CommandInfo } from './invokers.js';\nimport type { HydrateStrategy } from './islands.js';\nimport type { DriverOverrides, Next } from './command.js';\nimport type { AnyStore, StoreChanged, StoreRef } from './store.js';\n\n/** Every message is a tagged object; the tag is also the intent name used in markup. */\nexport interface Tagged {\n readonly _tag: string;\n}\n\n/** What the intent layer sees when a `data-intent` element fires its trigger event. */\nexport interface IntentInput {\n /** The `data-intent` value (a message tag). */\n readonly name: string;\n readonly event: Event;\n /** The element carrying `data-intent`. */\n readonly target: Element;\n /** `value` of the input, select, textarea or button that carries the intent. */\n readonly value: string | undefined;\n /** `checked` for checkbox and radio inputs. */\n readonly checked: boolean | undefined;\n /** Submitted data (including the submitter button) when the intent is on a `<form>`. */\n readonly formData: FormData | undefined;\n /** The output a child component emitted, when the intent is on a child element. */\n readonly detail: unknown;\n /** `KeyboardEvent.key` for `keydown`/`keyup` intents. */\n readonly key: string | undefined;\n /** For `toggle` intents (popover, `<details>`): the state it changed to. */\n readonly newState: 'open' | 'closed' | undefined;\n /** For `command` intents: the invoker's command (e.g. `--clear`) and source (gyral-czi.6). */\n readonly command: CommandInfo | undefined;\n}\n\n/** Reads a declared store's current state, typed by the store (ADR 0013). */\nexport type StoreReader = <S>(store: StoreRef<S>) => S;\n\n/** Read-only context handed to every reducer and to the view (ADR 0007, 0013). */\nexport interface Ctx<P> {\n /** Props from above. */\n readonly props: P;\n /** Stores from the side: `read(cart).lines`. The store must be in `spec.stores`. */\n readonly read: StoreReader;\n}\n\n/** Framework message: declared props changed after the first render (ADR 0007). */\nexport interface PropsChanged<P> {\n readonly _tag: 'PropsChanged';\n readonly props: P;\n readonly prev: P;\n}\n\n/**\n * Framework message: the component is live in the browser (ADR 0012 addendum). Sent once,\n * after the first client render has completed, to every client-side instance. Use it for\n * progressive enhancement: render the no-JS form on the server and in the first client render\n * (so hydration matches), then switch to the enhanced UI in the `Hydrated` reducer.\n */\nexport interface Hydrated {\n readonly _tag: 'Hydrated';\n /** `true` when the instance resumed from server-rendered markup (a hydration seed). */\n readonly serverRendered: boolean;\n}\n\n/** One validation problem. `path` is dot-joined and matches the field's `name`. */\nexport interface FieldIssue {\n readonly path: string;\n readonly message: string;\n}\n\n/** Submitted text values of a form (Files are dropped: they can't be re-filled). */\nexport type FormFields = Readonly<Record<string, string | readonly string[]>>;\n\n/** Framework message: an intent's input failed schema validation (ADR 0008). */\nexport interface IntentRejected {\n readonly _tag: 'IntentRejected';\n /** The `data-intent` name whose input was rejected. */\n readonly intent: string;\n readonly issues: readonly FieldIssue[];\n /**\n * For `form()` rejections: what the user submitted, so the view can re-fill the form. On\n * the no-JS path (ADR 0008 server half) the server re-renders the page from this.\n */\n // `| undefined` so schemas with plain optional fields (valibot `optional`) can produce it.\n readonly values?: FormFields | undefined;\n}\n\ntype ParseResult<M> = M | IntentRejected | undefined;\n\n/**\n * Parses a platform event into one message variant, `IntentRejected`, or `undefined` to\n * ignore it. May be async because schema validation may be.\n */\nexport type IntentParser<M> = (input: IntentInput) => ParseResult<M> | Promise<ParseResult<M>>;\n\ntype Variant<M extends Tagged, K extends M['_tag']> = Extract<M, { readonly _tag: K }>;\n\n/** Intent parsers keyed by the message tag they produce. Messages from drivers need none. */\nexport type Intents<M extends Tagged> = {\n readonly [K in M['_tag']]?: IntentParser<Variant<M, K>>;\n};\n\ntype Reducer<S, M, Msg, P> = (state: S, msg: Msg, ctx: Ctx<P>) => Next<S, M>;\n\n/**\n * One pure reducer per message tag (exhaustive by construction), plus optional reducers\n * for framework messages. Reducers may return commands.\n */\nexport type Update<S, M extends Tagged, P = object> = {\n readonly [K in M['_tag']]: Reducer<S, M, Variant<M, K>, P>;\n} & {\n readonly PropsChanged?: Reducer<S, M, PropsChanged<P>, P>;\n readonly IntentRejected?: Reducer<S, M, IntentRejected, P>;\n readonly StoreChanged?: Reducer<S, M, StoreChanged, P>;\n readonly Hydrated?: Reducer<S, M, Hydrated, P>;\n};\n\n/** Typed intent names handed to the view, so `data-intent=${i.Increment}` is checked. */\nexport type IntentNames<M extends Tagged> = { readonly [K in M['_tag']]: K };\n\n/**\n * The prop builders for props type `P` (view/05-element.md \"Props\"): one `prop.*` builder per\n * key. A builder's output type must fit the prop's type, so a prop whose type excludes\n * `undefined` needs `required: true` or a `default` (the honesty rule, ADR 0007 addendum).\n * Without explicit type arguments, `define()` infers `P` from the builders.\n */\nexport type PropDeclarations<P> = { readonly [K in keyof P]-?: Prop<P[K]> };\n\n/** State of a component that keeps none (a pure view of its props). Its `init` is optional. */\nexport type Stateless = Readonly<Record<string, never>>;\n\n/** Initial model state (and optional commands), computed from props on first render. */\ntype Init<S, M, P> = (props: P) => Next<S, M>;\n\n// `init` may be omitted only when an empty object is a valid state (Stateless, all-optional).\ntype InitField<S, M extends Tagged, P> = Stateless extends S\n ? { readonly init?: Init<S, M, P> }\n : { readonly init: Init<S, M, P> };\n\nexport type ComponentSpec<S, M extends Tagged, P> = SpecBody<S, M, P> & InitField<S, M, P>;\n\ninterface SpecBody<S, M extends Tagged, P> {\n /** The component's inputs, declared with `prop.*` builders. */\n readonly props?: PropDeclarations<P>;\n /** INTENT: platform events to messages. */\n readonly intent: Intents<M>;\n /** MODEL: pure state transitions. */\n readonly update: Update<S, M, P>;\n /** VIEW: pure function of state and props. Name intents in markup; never attach closures. */\n readonly view: (state: S, intents: IntentNames<M>, ctx: Ctx<P>) => ChildValue;\n /**\n * Shadow-root styles: `css` values, plain CSS strings, or arrays of them, nested freely.\n * Each maps to one shared `CSSStyleSheet`. Ignored (with a warning) when `shadow: false`.\n */\n readonly styles?: Styles;\n /**\n * `false` renders the view as the element's own light-DOM children (ADR 0014): document CSS\n * applies, and the server writes plain children instead of a `<template shadowrootmode>`.\n * For page-level components (listings, articles). No `<slot>`s and no `styles`. Default `true`.\n */\n readonly shadow?: boolean;\n /**\n * When a server-rendered instance hydrates (gyral-4k7.4): `load` (default), `idle`,\n * `visible` (scrolled into view) or `interaction` (first pointer/focus). Client-only\n * renders are unaffected.\n */\n readonly hydrate?: HydrateStrategy;\n /** Extra event types that may trigger intents via `data-intent-on` (e.g. `pointerdown`). */\n readonly events?: readonly string[];\n /** Driver substitutions by name, for every instance (ADR 0006). */\n readonly drivers?: DriverOverrides;\n /**\n * Stores this component reads with `ctx.read(store)` and writes with `send(store, msg)`.\n * Their changes re-render it (and reach the optional `StoreChanged` reducer). ADR 0013.\n */\n readonly stores?: readonly AnyStore[];\n /**\n * Return `true` to render this state change inside a View Transition (route changes, list\n * reorders). Skipped without browser support or when reduced motion is requested.\n */\n readonly viewTransition?: (prev: S, next: S, msg: Tagged) => boolean;\n /**\n * Messages from bursty sources (a WebSocket feed, a sensor) whose renders wait for the next\n * animation frame, so many messages in one frame cost one render: `renderOnFrame: ['Ticked']`.\n * Reducers still run at once. Any other change to the component renders in the usual\n * microtask flush, taking pending frame work with it. `'StoreChanged'` covers store changes.\n * Pages that get no frames (hidden) render from a 100 ms timer. view/04-scheduler.md.\n */\n readonly renderOnFrame?: readonly (M['_tag'] | 'StoreChanged')[];\n /**\n * Boolean facts about the state, exposed to CSS as custom states:\n * `states: (s) => ({ loading: s._tag === 'Loading' })` enables `:host(:state(loading))` and\n * `gy-x:state(loading)`. Applied after each render; feature-detected; not on the server.\n */\n readonly states?: (state: S) => Readonly<Record<string, boolean>>;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Host attribute holding a component's JSON seed (ADR 0012); the client removes it. */
|
|
2
|
+
export declare const SEED_ATTRIBUTE = "data-gyral-seed";
|
|
3
|
+
/** Marks a server-rendered light-DOM host (ADR 0014), so hydration knows its own content. */
|
|
4
|
+
export declare const LIGHT_ATTRIBUTE = "data-gyral-light";
|
|
5
|
+
/** A deferred island's strategy (07 "Islands"), next to `defer-hydration`. */
|
|
6
|
+
export declare const ISLAND_ATTRIBUTE = "data-gyral-hydrate";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Host attributes the server renderer writes (view/06-server.md "Components") and the client
|
|
2
|
+
// reads (07). Core's hydration.ts, light-dom.ts and islands.ts declare the same names for the
|
|
3
|
+
// client; server-components.node.test.ts checks that they match.
|
|
4
|
+
/** Host attribute holding a component's JSON seed (ADR 0012); the client removes it. */
|
|
5
|
+
export const SEED_ATTRIBUTE = 'data-gyral-seed';
|
|
6
|
+
/** Marks a server-rendered light-DOM host (ADR 0014), so hydration knows its own content. */
|
|
7
|
+
export const LIGHT_ATTRIBUTE = 'data-gyral-light';
|
|
8
|
+
/** A deferred island's strategy (07 "Islands"), next to `defer-hydration`. */
|
|
9
|
+
export const ISLAND_ATTRIBUTE = 'data-gyral-hydrate';
|
|
10
|
+
//# sourceMappingURL=attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../src/view/attributes.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,8FAA8F;AAC9F,iEAAiE;AACjE,wFAAwF;AACxF,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAChD,6FAA6F;AAC7F,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAClD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC","sourcesContent":["// Host attributes the server renderer writes (view/06-server.md \"Components\") and the client\n// reads (07). Core's hydration.ts, light-dom.ts and islands.ts declare the same names for the\n// client; server-components.node.test.ts checks that they match.\n/** Host attribute holding a component's JSON seed (ADR 0012); the client removes it. */\nexport const SEED_ATTRIBUTE = 'data-gyral-seed';\n/** Marks a server-rendered light-DOM host (ADR 0014), so hydration knows its own content. */\nexport const LIGHT_ATTRIBUTE = 'data-gyral-light';\n/** A deferred island's strategy (07 \"Islands\"), next to `defer-hydration`. */\nexport const ISLAND_ATTRIBUTE = 'data-gyral-hydrate';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { compiled } from './template.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// `@gyral/core/compiled`: the entry the Vite template compiler's output imports `compiled`
|
|
2
|
+
// from (view/01-templates.md "Compiled"). Internal: apps never import it themselves, and it is
|
|
3
|
+
// not documented as API. A subpath of its own, so the main entry's API stays as documented
|
|
4
|
+
// and compiled code still shares the one template module with `html` (same package copy).
|
|
5
|
+
export { compiled } from './template.js';
|
|
6
|
+
//# sourceMappingURL=compiled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiled.js","sourceRoot":"","sources":["../../src/view/compiled.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,+FAA+F;AAC/F,2FAA2F;AAC3F,0FAA0F;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC","sourcesContent":["// `@gyral/core/compiled`: the entry the Vite template compiler's output imports `compiled`\n// from (view/01-templates.md \"Compiled\"). Internal: apps never import it themselves, and it is\n// not documented as API. A subpath of its own, so the main entry's API stays as documented\n// and compiled code still shares the one template module with `html` (same package copy).\nexport { compiled } from './template.js';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEV: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-off.js","sourceRoot":"","sources":["../../src/view/dev-off.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,sFAAsF;AACtF,MAAM,CAAC,MAAM,GAAG,GAAY,KAAK,CAAC","sourcesContent":["// Production build of the view layer's flag (`#view-dev` without the `development` condition):\n// a literal `false`, so bundlers drop every `if (DEV)` check and warning. See dev.ts.\nexport const DEV: boolean = false;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEV: boolean;
|
package/dist/view/dev.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Development build of the view layer's flag, resolved through core's `#view-dev` import with
|
|
2
|
+
// the `development` condition (view/09-template-rules.md "One rule set, three places"). Checks
|
|
3
|
+
// and warnings are guarded with `if (DEV)`; production builds get dev-off.ts, so they vanish.
|
|
4
|
+
export const DEV = true;
|
|
5
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/view/dev.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,+FAA+F;AAC/F,8FAA8F;AAC9F,MAAM,CAAC,MAAM,GAAG,GAAY,IAAI,CAAC","sourcesContent":["// Development build of the view layer's flag, resolved through core's `#view-dev` import with\n// the `development` condition (view/09-template-rules.md \"One rule set, three places\"). Checks\n// and warnings are guarded with `if (DEV)`; production builds get dev-off.ts, so they vanish.\nexport const DEV: boolean = true;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEV } from '#view-dev';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/view/flags.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,2FAA2F;AAC3F,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// The development flag for view/ modules that may not use `#` imports themselves (view/server/,\n// ADR 0018 \"Where it lives\"): core's `#view-dev`, resolved by the `development` condition.\nexport { DEV } from '#view-dev';\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { DEV } from '#view-dev';
|
|
2
|
+
export { html, compiled, isTemplateResult, templateOf, type TemplateResult } from './template.js';
|
|
3
|
+
export { templateElement } from './template-element.js';
|
|
4
|
+
export { normalize, analyze, type Analysis } from './normalize/normalize.js';
|
|
5
|
+
export { checkTemplate, type TemplateIssue } from './normalize/check.js';
|
|
6
|
+
export { templateId } from './normalize/id.js';
|
|
7
|
+
export { TemplateError } from './normalize/errors.js';
|
|
8
|
+
export { shapeMismatch, repairError } from './normalize/shape.js';
|
|
9
|
+
export type { NormalizedTemplate, PartSpec, Path, Segment, Shape, ShapeNode, TemplateObject, } from './normalize/types.js';
|
|
10
|
+
export { hydrate } from './render/hydrate.js';
|
|
11
|
+
export { render, renderBatch } from './render/render.js';
|
|
12
|
+
export type { Markup, SeenMarkup } from './render/seen.js';
|
|
13
|
+
export { HydrationMismatch } from './render/mismatch.js';
|
|
14
|
+
export { each } from './render/list.js';
|
|
15
|
+
export { raw } from './render/raw.js';
|
|
16
|
+
export { nothing, type ChildValue, type ListResult, type RawResult } from './render/values.js';
|
|
17
|
+
export { defineHook } from './render/hook-part.js';
|
|
18
|
+
export type { HookAttributes, HookResult, HookSpec } from './render/hooks.js';
|
|
19
|
+
export { css, isStyleSource, sheetsFor, styleTexts, type CssValue, type StyleSource, type Styles, } from './styles.js';
|
|
20
|
+
export { ISLAND_ATTRIBUTE, LIGHT_ATTRIBUTE, SEED_ATTRIBUTE } from './attributes.js';
|
|
21
|
+
export { registerServerComponent, registerServerProvider, serverComponent, serverComponents, serverProvider, type ServerComponent, type ServerProvider, type ServerRenderInput, type ServerRendering, } from './registry.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The view layer's entry point for the rest of core (ADR 0018 "Where it lives"): code outside
|
|
2
|
+
// view/ imports only this module. @gyral/core's index re-exports the public part of it.
|
|
3
|
+
export { DEV } from '#view-dev';
|
|
4
|
+
export { html, compiled, isTemplateResult, templateOf } from './template.js';
|
|
5
|
+
export { templateElement } from './template-element.js';
|
|
6
|
+
export { normalize, analyze } from './normalize/normalize.js';
|
|
7
|
+
export { checkTemplate } from './normalize/check.js';
|
|
8
|
+
export { templateId } from './normalize/id.js';
|
|
9
|
+
export { TemplateError } from './normalize/errors.js';
|
|
10
|
+
export { shapeMismatch, repairError } from './normalize/shape.js';
|
|
11
|
+
export { hydrate } from './render/hydrate.js';
|
|
12
|
+
export { render, renderBatch } from './render/render.js';
|
|
13
|
+
export { HydrationMismatch } from './render/mismatch.js';
|
|
14
|
+
export { each } from './render/list.js';
|
|
15
|
+
export { raw } from './render/raw.js';
|
|
16
|
+
export { nothing } from './render/values.js';
|
|
17
|
+
export { defineHook } from './render/hook-part.js';
|
|
18
|
+
export { css, isStyleSource, sheetsFor, styleTexts, } from './styles.js';
|
|
19
|
+
export { ISLAND_ATTRIBUTE, LIGHT_ATTRIBUTE, SEED_ATTRIBUTE } from './attributes.js';
|
|
20
|
+
export { registerServerComponent, registerServerProvider, serverComponent, serverComponents, serverProvider, } from './registry.js';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,wFAAwF;AACxF,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,gBAAgB,EAAE,UAAU,EAAuB,MAAM,eAAe,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAiB,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAsB,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAWlE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAoD,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EACL,GAAG,EACH,aAAa,EACb,SAAS,EACT,UAAU,GAIX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,cAAc,GAKf,MAAM,eAAe,CAAC","sourcesContent":["// The view layer's entry point for the rest of core (ADR 0018 \"Where it lives\"): code outside\n// view/ imports only this module. @gyral/core's index re-exports the public part of it.\nexport { DEV } from '#view-dev';\nexport { html, compiled, isTemplateResult, templateOf, type TemplateResult } from './template.js';\nexport { templateElement } from './template-element.js';\nexport { normalize, analyze, type Analysis } from './normalize/normalize.js';\nexport { checkTemplate, type TemplateIssue } from './normalize/check.js';\nexport { templateId } from './normalize/id.js';\nexport { TemplateError } from './normalize/errors.js';\nexport { shapeMismatch, repairError } from './normalize/shape.js';\nexport type {\n NormalizedTemplate,\n PartSpec,\n Path,\n Segment,\n Shape,\n ShapeNode,\n TemplateObject,\n} from './normalize/types.js';\n\nexport { hydrate } from './render/hydrate.js';\nexport { render, renderBatch } from './render/render.js';\nexport type { Markup, SeenMarkup } from './render/seen.js';\nexport { HydrationMismatch } from './render/mismatch.js';\nexport { each } from './render/list.js';\nexport { raw } from './render/raw.js';\nexport { nothing, type ChildValue, type ListResult, type RawResult } from './render/values.js';\nexport { defineHook } from './render/hook-part.js';\nexport type { HookAttributes, HookResult, HookSpec } from './render/hooks.js';\nexport {\n css,\n isStyleSource,\n sheetsFor,\n styleTexts,\n type CssValue,\n type StyleSource,\n type Styles,\n} from './styles.js';\nexport { ISLAND_ATTRIBUTE, LIGHT_ATTRIBUTE, SEED_ATTRIBUTE } from './attributes.js';\nexport {\n registerServerComponent,\n registerServerProvider,\n serverComponent,\n serverComponents,\n serverProvider,\n type ServerComponent,\n type ServerProvider,\n type ServerRenderInput,\n type ServerRendering,\n} from './registry.js';\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TemplateError } from './errors.js';
|
|
2
|
+
/** A position in the minified strings: string index, offset in that string. */
|
|
3
|
+
export type At = readonly [index: number, offset: number];
|
|
4
|
+
/** A template's first rule violation, and where the normalizer was when it found it. */
|
|
5
|
+
export interface TemplateIssue {
|
|
6
|
+
/** The same error `normalize(strings)` throws. */
|
|
7
|
+
readonly error: TemplateError;
|
|
8
|
+
/** The whitespace-minified strings the rules read (as many as the input). */
|
|
9
|
+
readonly strings: readonly string[];
|
|
10
|
+
/** Where reading stopped. */
|
|
11
|
+
readonly at: At;
|
|
12
|
+
/**
|
|
13
|
+
* Where the token the error is about starts, when the tree builder found it in a tag, an end
|
|
14
|
+
* tag or a run of text (the token ends at `at`). Undefined when the tokenizer found it at
|
|
15
|
+
* `at` itself, or at a child hole (then `at` is the end of the string before the hole).
|
|
16
|
+
*/
|
|
17
|
+
readonly from: At | undefined;
|
|
18
|
+
}
|
|
19
|
+
/** The template's first rule violation, or undefined when `normalize` would accept it. */
|
|
20
|
+
export declare function checkTemplate(strings: readonly string[]): TemplateIssue | undefined;
|