@gyral/core 0.2.0 → 0.3.1
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 +129 -0
- package/NOTICE +19 -0
- package/README.md +35 -8
- package/dist/call.d.ts +32 -0
- package/dist/call.js +63 -0
- package/dist/call.js.map +1 -0
- package/dist/children.d.ts +30 -5
- package/dist/children.js +26 -4
- package/dist/children.js.map +1 -1
- package/dist/cli/gyral-types.d.ts +2 -0
- package/dist/cli/gyral-types.js +23 -0
- package/dist/cli/gyral-types.js.map +1 -0
- package/dist/command.d.ts +54 -12
- package/dist/command.js +31 -11
- package/dist/command.js.map +1 -1
- package/dist/compiler/ast.d.ts +23 -0
- package/dist/compiler/ast.js +149 -0
- package/dist/compiler/ast.js.map +1 -0
- package/dist/compiler/compile.d.ts +41 -0
- package/dist/compiler/compile.js +148 -0
- package/dist/compiler/compile.js.map +1 -0
- package/dist/compiler/component-entries.d.ts +7 -0
- package/dist/compiler/component-entries.js +42 -0
- package/dist/compiler/component-entries.js.map +1 -0
- package/dist/compiler/components.d.ts +4 -0
- package/dist/compiler/components.js +182 -0
- package/dist/compiler/components.js.map +1 -0
- package/dist/compiler/facts.d.ts +31 -0
- package/dist/compiler/facts.js +285 -0
- package/dist/compiler/facts.js.map +1 -0
- package/dist/compiler/features.d.ts +34 -0
- package/dist/compiler/features.js +158 -0
- package/dist/compiler/features.js.map +1 -0
- package/dist/compiler/hooks.d.ts +22 -0
- package/dist/compiler/hooks.js +241 -0
- package/dist/compiler/hooks.js.map +1 -0
- package/dist/compiler/loader-source.d.ts +14 -0
- package/dist/compiler/loader-source.js +86 -0
- package/dist/compiler/loader-source.js.map +1 -0
- package/dist/compiler/locate.d.ts +14 -0
- package/dist/compiler/locate.js +78 -0
- package/dist/compiler/locate.js.map +1 -0
- package/dist/compiler/parse5-check.d.ts +21 -0
- package/dist/compiler/parse5-check.js +60 -0
- package/dist/compiler/parse5-check.js.map +1 -0
- package/dist/compiler/prop-schemas.d.ts +4 -0
- package/dist/compiler/prop-schemas.js +108 -0
- package/dist/compiler/prop-schemas.js.map +1 -0
- package/dist/compiler/scan.d.ts +41 -0
- package/dist/compiler/scan.js +160 -0
- package/dist/compiler/scan.js.map +1 -0
- package/dist/compiler/scope.d.ts +8 -0
- package/dist/compiler/scope.js +116 -0
- package/dist/compiler/scope.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/compiler/tag-map.d.ts +41 -0
- package/dist/compiler/tag-map.js +126 -0
- package/dist/compiler/tag-map.js.map +1 -0
- package/dist/components-ready.d.ts +7 -0
- package/dist/components-ready.js +19 -0
- package/dist/components-ready.js.map +1 -0
- package/dist/define.d.ts +13 -4
- package/dist/define.js +35 -331
- package/dist/define.js.map +1 -1
- package/dist/devtools-events.d.ts +13 -0
- package/dist/devtools-events.js.map +1 -1
- package/dist/devtools-off.d.ts +2 -0
- package/dist/devtools-off.js +2 -0
- package/dist/devtools-off.js.map +1 -1
- package/dist/devtools.d.ts +4 -0
- package/dist/devtools.js +17 -2
- 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-internals.d.ts +1 -0
- package/dist/element-internals.js +11 -0
- package/dist/element-internals.js.map +1 -0
- package/dist/element-types.d.ts +11 -5
- package/dist/element-types.js.map +1 -1
- package/dist/element.d.ts +3 -0
- package/dist/element.js +322 -0
- package/dist/element.js.map +1 -0
- package/dist/error-view.d.ts +10 -0
- package/dist/error-view.js +30 -0
- package/dist/error-view.js.map +1 -0
- package/dist/errors.d.ts +21 -0
- package/dist/errors.js +47 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.json +289 -0
- package/dist/eslint/imports.d.ts +26 -0
- package/dist/eslint/imports.js +78 -0
- package/dist/eslint/imports.js.map +1 -0
- package/dist/eslint/index.d.ts +16 -0
- package/dist/eslint/index.js +23 -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 +6 -0
- package/dist/eslint/template-rule.js +76 -0
- package/dist/eslint/template-rule.js.map +1 -0
- package/dist/eslint/unused-intent-rule.d.ts +2 -0
- package/dist/eslint/unused-intent-rule.js +186 -0
- package/dist/eslint/unused-intent-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 +13 -12
- package/dist/focus.js +44 -11
- package/dist/focus.js.map +1 -1
- package/dist/form-associated.d.ts +46 -0
- package/dist/form-associated.js +77 -0
- package/dist/form-associated.js.map +1 -0
- package/dist/forms.d.ts +42 -30
- package/dist/forms.js +85 -41
- package/dist/forms.js.map +1 -1
- package/dist/frame-lane.d.ts +11 -0
- package/dist/frame-lane.js +28 -0
- package/dist/frame-lane.js.map +1 -0
- package/dist/head.d.ts +61 -0
- package/dist/head.js +85 -0
- package/dist/head.js.map +1 -0
- 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/host-model.d.ts +77 -0
- package/dist/host-model.js +278 -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-loader.d.ts +13 -0
- package/dist/hydration-loader.js +58 -0
- package/dist/hydration-loader.js.map +1 -0
- package/dist/hydration-off.d.ts +8 -0
- package/dist/hydration-off.js +25 -0
- package/dist/hydration-off.js.map +1 -0
- package/dist/hydration.d.ts +3 -21
- package/dist/hydration.js +14 -63
- package/dist/hydration.js.map +1 -1
- package/dist/index.d.ts +24 -36
- package/dist/index.js +14 -32
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-types.d.ts +97 -0
- package/dist/indexeddb-types.js +2 -0
- package/dist/indexeddb-types.js.map +1 -0
- package/dist/indexeddb.d.ts +5 -0
- package/dist/indexeddb.js +118 -0
- package/dist/indexeddb.js.map +1 -0
- package/dist/intent.d.ts +62 -17
- package/dist/intent.js +193 -100
- package/dist/intent.js.map +1 -1
- package/dist/internal/indexeddb-open.d.ts +8 -0
- package/dist/internal/indexeddb-open.js +96 -0
- package/dist/internal/indexeddb-open.js.map +1 -0
- package/dist/internal/indexeddb-transaction.d.ts +4 -0
- package/dist/internal/indexeddb-transaction.js +134 -0
- package/dist/internal/indexeddb-transaction.js.map +1 -0
- package/dist/internal/interpreter.d.ts +15 -1
- package/dist/internal/interpreter.js +42 -47
- package/dist/internal/interpreter.js.map +1 -1
- package/dist/internal/token.d.ts +1 -0
- package/dist/internal/token.js +7 -0
- package/dist/internal/token.js.map +1 -0
- package/dist/internal.d.ts +20 -0
- package/dist/internal.js +22 -0
- package/dist/internal.js.map +1 -0
- package/dist/invoker-fallback-used.d.ts +4 -0
- package/dist/invoker-fallback-used.js +10 -0
- package/dist/invoker-fallback-used.js.map +1 -0
- package/dist/invoker-fallback.d.ts +4 -0
- package/dist/invoker-fallback.js +15 -0
- package/dist/invoker-fallback.js.map +1 -0
- 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 +4 -53
- package/dist/light-dom.js +5 -100
- package/dist/light-dom.js.map +1 -1
- package/dist/prop.d.ts +89 -0
- package/dist/prop.js +41 -0
- package/dist/prop.js.map +1 -0
- package/dist/props.d.ts +57 -21
- package/dist/props.js +157 -34
- package/dist/props.js.map +1 -1
- package/dist/retry.d.ts +15 -0
- package/dist/retry.js +48 -0
- package/dist/retry.js.map +1 -0
- package/dist/scheduler.d.ts +43 -0
- package/dist/scheduler.js +212 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/script-json.d.ts +2 -0
- package/dist/script-json.js +13 -0
- package/dist/script-json.js.map +1 -0
- package/dist/server-component.d.ts +10 -0
- package/dist/server-component.js +133 -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 +34 -0
- package/dist/server.js +59 -0
- package/dist/server.js.map +1 -0
- package/dist/settled.d.ts +11 -0
- package/dist/settled.js +62 -0
- package/dist/settled.js.map +1 -0
- package/dist/spec-features-used.d.ts +21 -0
- package/dist/spec-features-used.js +50 -0
- package/dist/spec-features-used.js.map +1 -0
- package/dist/spec-features.d.ts +28 -0
- package/dist/spec-features.js +42 -0
- package/dist/spec-features.js.map +1 -0
- package/dist/states.d.ts +3 -5
- package/dist/states.js +22 -11
- package/dist/states.js.map +1 -1
- package/dist/storage.d.ts +69 -0
- package/dist/storage.js +158 -0
- package/dist/storage.js.map +1 -0
- package/dist/store-binding.d.ts +6 -3
- package/dist/store-binding.js +7 -8
- package/dist/store-binding.js.map +1 -1
- package/dist/store-scope.d.ts +8 -11
- package/dist/store-scope.js +15 -40
- package/dist/store-scope.js.map +1 -1
- package/dist/store.d.ts +3 -0
- package/dist/store.js +45 -10
- 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/subscription.d.ts +35 -0
- package/dist/subscription.js +74 -0
- package/dist/subscription.js.map +1 -0
- package/dist/subscriptions.d.ts +26 -0
- package/dist/subscriptions.js +98 -0
- package/dist/subscriptions.js.map +1 -0
- package/dist/transitions.d.ts +5 -7
- package/dist/transitions.js +17 -20
- package/dist/transitions.js.map +1 -1
- package/dist/types.d.ts +142 -49
- package/dist/types.js.map +1 -1
- package/dist/use-dialogs.d.ts +2 -0
- package/dist/use-dialogs.js +9 -0
- package/dist/use-dialogs.js.map +1 -0
- package/dist/use-disposal.d.ts +2 -0
- package/dist/use-disposal.js +9 -0
- package/dist/use-disposal.js.map +1 -0
- package/dist/use-error-view.d.ts +2 -0
- package/dist/use-error-view.js +9 -0
- package/dist/use-error-view.js.map +1 -0
- package/dist/use-errored.d.ts +2 -0
- package/dist/use-errored.js +9 -0
- package/dist/use-errored.js.map +1 -0
- package/dist/use-form-associated.d.ts +2 -0
- package/dist/use-form-associated.js +7 -0
- package/dist/use-form-associated.js.map +1 -0
- package/dist/use-frame-lane.d.ts +2 -0
- package/dist/use-frame-lane.js +10 -0
- package/dist/use-frame-lane.js.map +1 -0
- package/dist/use-invokers.d.ts +2 -0
- package/dist/use-invokers.js +10 -0
- package/dist/use-invokers.js.map +1 -0
- package/dist/use-states.d.ts +2 -0
- package/dist/use-states.js +10 -0
- package/dist/use-states.js.map +1 -0
- package/dist/use-subscriptions.d.ts +2 -0
- package/dist/use-subscriptions.js +10 -0
- package/dist/use-subscriptions.js.map +1 -0
- package/dist/use-transitions.d.ts +2 -0
- package/dist/use-transitions.js +10 -0
- package/dist/use-transitions.js.map +1 -0
- package/dist/view/attributes.d.ts +11 -0
- package/dist/view/attributes.js +15 -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 +26 -0
- package/dist/view/index.js +27 -0
- package/dist/view/index.js.map +1 -0
- package/dist/view/loc.d.ts +9 -0
- package/dist/view/loc.js +50 -0
- package/dist/view/loc.js.map +1 -0
- package/dist/view/message.d.ts +17 -0
- package/dist/view/message.js +40 -0
- package/dist/view/message.js.map +1 -0
- package/dist/view/messages.d.ts +43 -0
- package/dist/view/messages.js +84 -0
- package/dist/view/messages.js.map +1 -0
- package/dist/view/normalize/check.d.ts +23 -0
- package/dist/view/normalize/check.js +81 -0
- package/dist/view/normalize/check.js.map +1 -0
- package/dist/view/normalize/emit.d.ts +15 -0
- package/dist/view/normalize/emit.js +165 -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 +10 -0
- package/dist/view/normalize/id.js +55 -0
- package/dist/view/normalize/id.js.map +1 -0
- package/dist/view/normalize/normalize.d.ts +18 -0
- package/dist/view/normalize/normalize.js +42 -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 +39 -0
- package/dist/view/normalize/rules.js +120 -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/svg.d.ts +14 -0
- package/dist/view/normalize/svg.js +40 -0
- package/dist/view/normalize/svg.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 +55 -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 +65 -0
- package/dist/view/normalize/tree.js +235 -0
- package/dist/view/normalize/tree.js.map +1 -0
- package/dist/view/normalize/types.d.ts +146 -0
- package/dist/view/normalize/types.js +29 -0
- package/dist/view/normalize/types.js.map +1 -0
- package/dist/view/normalize/whitespace.d.ts +2 -0
- package/dist/{template-whitespace.js → view/normalize/whitespace.js} +27 -36
- 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 +11 -0
- package/dist/view/prepare.js +63 -0
- package/dist/view/prepare.js.map +1 -0
- package/dist/view/registry.d.ts +78 -0
- package/dist/view/registry.js +27 -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 +83 -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 +286 -0
- package/dist/view/render/adopt.js.map +1 -0
- package/dist/view/render/attr-parts.d.ts +72 -0
- package/dist/view/render/attr-parts.js +262 -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 +173 -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/dispose.d.ts +3 -0
- package/dist/view/render/dispose.js +76 -0
- package/dist/view/render/dispose.js.map +1 -0
- package/dist/view/render/hook-part.d.ts +5 -0
- package/dist/view/render/hook-part.js +36 -0
- package/dist/view/render/hook-part.js.map +1 -0
- package/dist/view/render/hook-run.d.ts +2 -0
- package/dist/view/render/hook-run.js +72 -0
- package/dist/view/render/hook-run.js.map +1 -0
- package/dist/view/render/hooks.d.ts +108 -0
- package/dist/view/render/hooks.js +108 -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/keyed.d.ts +6 -0
- package/dist/view/render/keyed.js +15 -0
- package/dist/view/render/keyed.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 +55 -0
- package/dist/view/render/mismatch.js.map +1 -0
- package/dist/view/render/modal.d.ts +3 -0
- package/dist/view/render/modal.js +39 -0
- package/dist/view/render/modal.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 +21 -0
- package/dist/view/render/raw.js +72 -0
- package/dist/view/render/raw.js.map +1 -0
- package/dist/view/render/render.d.ts +15 -0
- package/dist/view/render/render.js +65 -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/toggles.d.ts +6 -0
- package/dist/view/render/toggles.js +6 -0
- package/dist/view/render/toggles.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 +28 -0
- package/dist/view/render/warn.js +114 -0
- package/dist/view/render/warn.js.map +1 -0
- package/dist/view/server/component.d.ts +12 -0
- package/dist/view/server/component.js +64 -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 +48 -0
- package/dist/view/server/index.js +80 -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 +68 -0
- package/dist/view/server/tags.js +132 -0
- package/dist/view/server/tags.js.map +1 -0
- package/dist/view/server/values.d.ts +18 -0
- package/dist/view/server/values.js +94 -0
- package/dist/view/server/values.js.map +1 -0
- package/dist/view/server/writer.d.ts +21 -0
- package/dist/view/server/writer.js +170 -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 +10 -0
- package/dist/view/template-element.js +45 -0
- package/dist/view/template-element.js.map +1 -0
- package/dist/view/template.d.ts +29 -0
- package/dist/view/template.js +84 -0
- package/dist/view/template.js.map +1 -0
- package/dist/view/trusted-html.d.ts +6 -0
- package/dist/view/trusted-html.js +34 -0
- package/dist/view/trusted-html.js.map +1 -0
- package/dist/vite.d.ts +57 -11
- package/dist/vite.js +319 -27
- package/dist/vite.js.map +1 -1
- package/package.json +70 -4
- 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/invalid.d.ts +0 -21
- package/dist/invalid.js +0 -70
- package/dist/invalid.js.map +0 -1
- package/dist/lit-html-check.d.ts +0 -6
- package/dist/lit-html-check.js +0 -48
- package/dist/lit-html-check.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/random.d.ts +0 -13
- package/dist/random.js +0 -19
- package/dist/random.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/template-whitespace.d.ts +0 -7
- package/dist/template-whitespace.js.map +0 -1
- package/dist/templates.d.ts +0 -5
- package/dist/templates.js +0 -15
- package/dist/templates.js.map +0 -1
- package/dist/textarea.d.ts +0 -26
- package/dist/textarea.js +0 -85
- package/dist/textarea.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whitespace.js","sourceRoot":"","sources":["../../../src/view/normalize/whitespace.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,sFAAsF;AACtF,uFAAuF;AACvF,EAAE;AACF,SAAS;AACT,4FAA4F;AAC5F,6FAA6F;AAC7F,2FAA2F;AAC3F,6FAA6F;AAC7F,uFAAuF;AACvF,yCAAyC;AACzC,6FAA6F;AAC7F,mDAAmD;AACnD,0FAA0F;AAC1F,2FAA2F;AAC3F,aAAa;AACb,0EAA0E;AAE1E,+EAA+E;AAC/E,MAAM,KAAK,GAAG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AK,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC;QAC1B,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;IACvB,CAAC;AACH,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,aAAa,CAAC,OAA0B;IACtD,MAAM,KAAK,GAAS;QAClB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,EAAE;QACT,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE,CAAC;QACX,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,UAAU;KACjB,CAAC;IACF,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CACpC,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAC5D,CAAC;AACJ,CAAC","sourcesContent":["// Whitespace minification for templates (view/01-templates.md \"Whitespace\", ADR 0016 addendum).\n// Moved from core's template-whitespace.ts (Gyral's own design) into the view layer's\n// normalizer, so the compiler, the runtime preparer and the server minify identically.\n//\n// Rules:\n// - Whitespace-only text that contains a newline is removed when it sits next to a template\n// edge, a block-level tag (head-only tags count: <head>, <meta>, <link>, <base>, <title>),\n// or the inside edge of a <button>/<select>/<svg> (never rendered there). Inside <head>,\n// whitespace-only text is always removed, newline or not, between holes too: nothing there\n// renders. Between two inline neighbours (phrasing elements, custom elements, holes,\n// comments) it collapses to one space.\n// - Other runs of whitespace in text collapse to one space; a leading or trailing run with a\n// newline next to one of those edges is removed.\n// - <pre>, <textarea>, <script>, <style> and <title> contents, tags and attribute values,\n// and comments are copied unchanged. Holes never move: the result has the same number of\n// strings.\n// The function is idempotent: minifying minified strings changes nothing.\n\n/** Elements whose box is block-level (or never laid out inline) by default. */\nconst BLOCK = new Set(\n (\n 'address article aside blockquote body caption col colgroup datalist dd details dialog div ' +\n 'dl dt fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html ' +\n 'legend li main menu nav ol optgroup option p pre search section select summary table tbody ' +\n 'td tfoot th thead tr ul ' +\n // Head-only elements: never rendered at all, so never inline.\n 'base link meta title ' +\n // SVG containers and shapes: whitespace between them is never rendered.\n 'circle clippath defs ellipse g line lineargradient marker mask path pattern polygon ' +\n 'polyline radialgradient rect stop symbol use'\n ).split(' '),\n);\n\n/** Elements whose text content is copied verbatim (whitespace is meaningful or raw text). */\nconst RAW_TEXT = new Set(['script', 'style', 'textarea', 'title']);\nconst PRESERVE = 'pre';\n\n/** What sits on one side of a text chunk. */\ntype Edge = 'template' | 'inline' | 'block';\n\n/**\n * Inline-block controls: they sit inline among their neighbours, but whitespace at the start or\n * end of their own content is never rendered (it is at the edge of their own line box). Same\n * for <svg>: SVG content renders no text outside its text elements.\n */\nconst INLINE_BOX = new Set(['button', 'select', 'svg']);\n\n/**\n * The edge a tag makes for the text next to it. `inside` is true when the text is inside the\n * element (after its start tag, or before its end tag).\n */\nfunction edgeOfTag(name: string, inside: boolean): Edge {\n const lower = name.toLowerCase();\n if (BLOCK.has(lower)) return 'block';\n return inside && INLINE_BOX.has(lower) ? 'block' : 'inline';\n}\n\nconst WS = /^[ \\t\\n\\r\\f]*$/;\nconst RUN = /[ \\t\\n\\r\\f]+/g;\n\n/** `head`: the text is inside `<head>`, which is never rendered. */\nfunction minifyChunk(text: string, left: Edge, right: Edge, head: boolean): string {\n if (text === '') return text;\n if (WS.test(text)) {\n const removable =\n head ||\n (/[\\n\\r]/.test(text) &&\n (left === 'template' || right === 'template' || left === 'block' || right === 'block'));\n return removable ? '' : ' ';\n }\n // Mixed text: a leading or trailing run with a newline next to a removable edge goes too.\n const dropStart = left !== 'inline' && /^[ \\t\\f]*[\\n\\r]/.test(text);\n const dropEnd = right !== 'inline' && /[\\n\\r][ \\t\\n\\r\\f]*$/.test(text);\n let body = text.replace(RUN, ' ');\n if (dropStart) body = body.replace(/^ /, '');\n if (dropEnd) body = body.replace(/ $/, '');\n return body;\n}\n\nconst Mode = { Text: 0, Tag: 1, Comment: 2, RawText: 3 } as const;\ntype Mode = (typeof Mode)[keyof typeof Mode];\n\ninterface Scan {\n mode: Mode;\n /** Quote char while inside an attribute value in a tag, else ''. */\n quote: string;\n /** Name of the tag being read (lower case), and whether it is a closing tag. */\n tagName: string;\n closing: boolean;\n /** Raw-text element we are inside (its contents are copied verbatim). */\n rawName: string;\n /** Depth of open <pre> elements: text is copied verbatim while > 0. */\n preDepth: number;\n /** Inside <head> (until </head> or <body>). */\n head: boolean;\n /** Edge type of the boundary before the current text chunk. */\n left: Edge;\n}\n\nconst TAG_START = /^<(\\/?)([A-Za-z!?][^\\s/>]*)/;\n\n/** Minify one segment, carrying the HTML scan state across bindings. */\nfunction minifySegment(segment: string, state: Scan, last: boolean): string {\n let out = '';\n let chunk = '';\n const flushText = (right: Edge): void => {\n out += state.preDepth > 0 ? chunk : minifyChunk(chunk, state.left, right, state.head);\n chunk = '';\n };\n let i = 0;\n while (i < segment.length) {\n const ch = segment.charAt(i);\n if (state.mode === Mode.Comment) {\n if (segment.startsWith('-->', i)) {\n out += '-->';\n i += 3;\n state.mode = Mode.Text;\n state.left = 'inline';\n } else {\n out += ch;\n i += 1;\n }\n continue;\n }\n if (state.mode === Mode.RawText) {\n const close = `</${state.rawName}`;\n if (segment.slice(i, i + close.length).toLowerCase() === close) {\n state.mode = Mode.Text;\n state.left = 'inline';\n continue; // the closing tag is read in Text mode\n }\n out += ch;\n i += 1;\n continue;\n }\n if (state.mode === Mode.Tag) {\n out += ch;\n i += 1;\n if (state.quote !== '') {\n if (ch === state.quote) state.quote = '';\n } else if (ch === '\"' || ch === \"'\") {\n state.quote = ch;\n } else if (ch === '>') {\n endTag(state, out.endsWith('/>'));\n }\n continue;\n }\n // Text mode.\n if (ch === '<' && segment.startsWith('<!--', i)) {\n flushText('inline');\n state.mode = Mode.Comment;\n out += '<!--';\n i += 4;\n continue;\n }\n const tag = ch === '<' ? TAG_START.exec(segment.slice(i)) : null;\n if (tag !== null) {\n const name = (tag[2] ?? '').toLowerCase();\n const closing = tag[1] === '/';\n flushText(edgeOfTag(name, closing));\n state.closing = closing;\n state.tagName = name;\n state.mode = Mode.Tag;\n out += tag[0];\n i += tag[0].length;\n continue;\n }\n chunk += ch;\n i += 1;\n }\n if (state.mode === Mode.Text) {\n flushText(last ? 'template' : 'inline');\n state.left = 'inline'; // the next segment starts after a binding\n }\n return out;\n}\n\nfunction endTag(state: Scan, selfClosing: boolean): void {\n const name = state.tagName;\n state.mode = Mode.Text;\n state.left = edgeOfTag(name, !state.closing && !selfClosing);\n if (name === 'head' && !selfClosing) state.head = !state.closing;\n if (name === 'body') state.head = false;\n if (name === PRESERVE) {\n if (state.closing) state.preDepth = Math.max(0, state.preDepth - 1);\n else if (!selfClosing) state.preDepth += 1;\n }\n if (!state.closing && !selfClosing && RAW_TEXT.has(name)) {\n state.mode = Mode.RawText;\n state.rawName = name;\n }\n}\n\n/** Minified copy of template strings (same length, bindings unmoved). Idempotent. */\nexport function minifyStrings(strings: readonly string[]): string[] {\n const state: Scan = {\n mode: Mode.Text,\n quote: '',\n tagName: '',\n closing: false,\n rawName: '',\n preDepth: 0,\n head: false,\n left: 'template',\n };\n return strings.map((segment, index) =>\n minifySegment(segment, state, index === strings.length - 1),\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-stub.js","sourceRoot":"","sources":["../../src/view/prepare-stub.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,CAAC,MAAM,OAAO,GAA2B,CAAC,OAAO,EAAE,EAAE;IACzD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACvD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAA0B,GAAG,EAAE,CAAC,SAAS,CAAC","sourcesContent":["// The `gyral-compiled` build of core's `#prepare` import (view/01-templates.md \"Compiled\"):\n// with the Vite preset's template compiler every `html` template is precompiled, so the\n// runtime preparer is left out of the bundle. Reaching this means one template was not.\nimport type * as Prepare from './prepare.js';\nimport { message } from './message.js';\n\nexport const prepare: typeof Prepare.prepare = (strings) => {\n const start = strings.join('${…}').trim().slice(0, 80);\n throw new Error(message(70, start));\n};\n\nexport const verify: typeof Prepare.verify = () => undefined;\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TemplateObject } from './normalize/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The template object of a call site's strings, normalized (with development checks) once.
|
|
4
|
+
* `svg`: the call site is an svg template (template.ts `svg`), whose first call prepares it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function prepare(strings: readonly string[], svg?: boolean): TemplateObject;
|
|
7
|
+
/**
|
|
8
|
+
* Throws rule 7 when the browser's parse of `template.html` (in `el`) differs from the tree
|
|
9
|
+
* the normalizer computed paths for. Templates that didn't come from `prepare` are skipped.
|
|
10
|
+
*/
|
|
11
|
+
export declare function verify(template: TemplateObject, el: HTMLTemplateElement): void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// The runtime template preparer (view/01-templates.md "Runtime"), resolved through core's
|
|
2
|
+
// `#prepare` import by default. It runs the normalizer once per call site (template.ts caches
|
|
3
|
+
// the result) and, when the browser first parses a template's HTML (template-element.ts),
|
|
4
|
+
// checks that the parse built exactly the DOM the normalizer's paths assume. A difference
|
|
5
|
+
// means the parser repaired the markup: rule 7 (view/09-template-rules.md). Builds made with
|
|
6
|
+
// the `gyral-compiled` condition get prepare-stub.ts instead.
|
|
7
|
+
import { DEV } from '#view-dev';
|
|
8
|
+
import { locOf } from './loc.js';
|
|
9
|
+
import { recordTemplateId } from './normalize/id.js';
|
|
10
|
+
import { analyze } from './normalize/normalize.js';
|
|
11
|
+
import { repairError, shapeMismatch } from './normalize/shape.js';
|
|
12
|
+
const shapes = new WeakMap();
|
|
13
|
+
const prepared = new WeakMap();
|
|
14
|
+
// One-entry cache in front of the WeakMap: list rows ask for the same call site in a row.
|
|
15
|
+
let lastSource;
|
|
16
|
+
let lastTemplate;
|
|
17
|
+
/**
|
|
18
|
+
* The template object of a call site's strings, normalized (with development checks) once.
|
|
19
|
+
* `svg`: the call site is an svg template (template.ts `svg`), whose first call prepares it.
|
|
20
|
+
*/
|
|
21
|
+
export function prepare(strings, svg) {
|
|
22
|
+
if (strings === lastSource)
|
|
23
|
+
return lastTemplate;
|
|
24
|
+
let template = prepared.get(strings);
|
|
25
|
+
if (template === undefined) {
|
|
26
|
+
// Development: the call site (loc.ts), so rule errors and hydration mismatches name it.
|
|
27
|
+
const analysis = analyze(strings, DEV ? locOf(strings) : undefined, svg);
|
|
28
|
+
template = analysis.template;
|
|
29
|
+
recordTemplateId(analysis.template.id, analysis.strings);
|
|
30
|
+
shapes.set(template, analysis.shape);
|
|
31
|
+
prepared.set(strings, template);
|
|
32
|
+
}
|
|
33
|
+
lastSource = strings;
|
|
34
|
+
lastTemplate = template;
|
|
35
|
+
return template;
|
|
36
|
+
}
|
|
37
|
+
/** The DOM the browser built, as a Shape (lower-case names, <template> content inlined). */
|
|
38
|
+
function domShape(nodes) {
|
|
39
|
+
return [...nodes].map((node) => {
|
|
40
|
+
if (node.nodeType === 3)
|
|
41
|
+
return '#text';
|
|
42
|
+
if (node.nodeType === 8)
|
|
43
|
+
return '#comment';
|
|
44
|
+
if (node.nodeType !== 1)
|
|
45
|
+
return [node.nodeName.toLowerCase(), []];
|
|
46
|
+
const el = node;
|
|
47
|
+
const children = el.localName === 'template' ? el.content.childNodes : el.childNodes;
|
|
48
|
+
return [el.localName.toLowerCase(), domShape(children)];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Throws rule 7 when the browser's parse of `template.html` (in `el`) differs from the tree
|
|
53
|
+
* the normalizer computed paths for. Templates that didn't come from `prepare` are skipped.
|
|
54
|
+
*/
|
|
55
|
+
export function verify(template, el) {
|
|
56
|
+
const shape = shapes.get(template);
|
|
57
|
+
if (shape === undefined)
|
|
58
|
+
return;
|
|
59
|
+
const problem = shapeMismatch(shape, domShape(el.content.childNodes));
|
|
60
|
+
if (problem !== undefined)
|
|
61
|
+
throw repairError(template, "The browser's HTML parser", problem);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=prepare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../src/view/prepare.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,8FAA8F;AAC9F,0FAA0F;AAC1F,0FAA0F;AAC1F,6FAA6F;AAC7F,8DAA8D;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGlE,MAAM,MAAM,GAAG,IAAI,OAAO,EAAyB,CAAC;AACpD,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAqC,CAAC;AAClE,0FAA0F;AAC1F,IAAI,UAAyC,CAAC;AAC9C,IAAI,YAAwC,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,OAA0B,EAAE,GAAa;IAC/D,IAAI,OAAO,KAAK,UAAU;QAAE,OAAO,YAA8B,CAAC;IAClE,IAAI,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,w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ACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,QAAwB,EAAE,EAAuB;IACtE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO;IAChC,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IACtE,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,WAAW,CAAC,QAAQ,EAAE,2BAA2B,EAAE,OAAO,CAAC,CAAC;AAC/F,CAAC","sourcesContent":["// The runtime template preparer (view/01-templates.md \"Runtime\"), resolved through core's\n// `#prepare` import by default. It runs the normalizer once per call site (template.ts caches\n// the result) and, when the browser first parses a template's HTML (template-element.ts),\n// checks that the parse built exactly the DOM the normalizer's paths assume. A difference\n// means the parser repaired the markup: rule 7 (view/09-template-rules.md). Builds made with\n// the `gyral-compiled` condition get prepare-stub.ts instead.\nimport { DEV } from '#view-dev';\nimport { locOf } from './loc.js';\nimport { recordTemplateId } from './normalize/id.js';\nimport { analyze } from './normalize/normalize.js';\nimport { repairError, shapeMismatch } from './normalize/shape.js';\nimport type { Shape, ShapeNode, TemplateObject } from './normalize/types.js';\n\nconst shapes = new WeakMap<TemplateObject, Shape>();\nconst prepared = new WeakMap<readonly string[], TemplateObject>();\n// One-entry cache in front of the WeakMap: list rows ask for the same call site in a row.\nlet lastSource: readonly string[] | undefined;\nlet lastTemplate: TemplateObject | undefined;\n\n/**\n * The template object of a call site's strings, normalized (with development checks) once.\n * `svg`: the call site is an svg template (template.ts `svg`), whose first call prepares it.\n */\nexport function prepare(strings: readonly string[], svg?: boolean): TemplateObject {\n if (strings === lastSource) return lastTemplate as TemplateObject;\n let template = prepared.get(strings);\n if (template === undefined) {\n // Development: the call site (loc.ts), so rule errors and hydration mismatches name it.\n const analysis = analyze(strings, DEV ? locOf(strings) : undefined, svg);\n template = analysis.template;\n recordTemplateId(analysis.template.id, analysis.strings);\n shapes.set(template, analysis.shape);\n prepared.set(strings, template);\n }\n lastSource = strings;\n lastTemplate = template;\n return template;\n}\n\n/** The DOM the browser built, as a Shape (lower-case names, <template> content inlined). */\nfunction domShape(nodes: NodeListOf<ChildNode>): Shape {\n return [...nodes].map((node): ShapeNode => {\n if (node.nodeType === 3) return '#text';\n if (node.nodeType === 8) return '#comment';\n if (node.nodeType !== 1) return [node.nodeName.toLowerCase(), []];\n const el = node as Element;\n const children =\n el.localName === 'template' ? (el as HTMLTemplateElement).content.childNodes : el.childNodes;\n return [el.localName.toLowerCase(), domShape(children)];\n });\n}\n\n/**\n * Throws rule 7 when the browser's parse of `template.html` (in `el`) differs from the tree\n * the normalizer computed paths for. Templates that didn't come from `prepare` are skipped.\n */\nexport function verify(template: TemplateObject, el: HTMLTemplateElement): void {\n const shape = shapes.get(template);\n if (shape === undefined) return;\n const problem = shapeMismatch(shape, domShape(el.content.childNodes));\n if (problem !== undefined) throw repairError(template, \"The browser's HTML parser\", problem);\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ChildValue } from './render/values.js';
|
|
2
|
+
/** What a server render of one component returns: its view and what its seed must carry. */
|
|
3
|
+
export interface ServerRendering {
|
|
4
|
+
/** `view(state, intents, ctx)` for the resolved props and state. */
|
|
5
|
+
readonly view: ChildValue;
|
|
6
|
+
/**
|
|
7
|
+
* The `data-gyral-seed` payload (ADR 0012): `props` that no attribute carries, and `state`
|
|
8
|
+
* unless it equals `init(props)`'s state. JSON-serializable.
|
|
9
|
+
*/
|
|
10
|
+
readonly seed: {
|
|
11
|
+
readonly state?: unknown;
|
|
12
|
+
readonly props: Readonly<Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Set when `init` or the view threw (ADR 0024): `view` is the component's error view (or
|
|
16
|
+
* nothing), the host is marked `data-gyral-error` with no seed, and the renderer reports this
|
|
17
|
+
* value (core's `GyralError`, opaque here) through its `onError` option.
|
|
18
|
+
*/
|
|
19
|
+
readonly failed?: unknown;
|
|
20
|
+
}
|
|
21
|
+
/** The input of one server render, gathered from the start tag (06 "Components"). */
|
|
22
|
+
export interface ServerRenderInput {
|
|
23
|
+
/** Static attributes plus attribute/boolean holes, as strings (`''` for a present boolean). */
|
|
24
|
+
readonly attributes: Readonly<Record<string, string>>;
|
|
25
|
+
/** Property holes: values as is. */
|
|
26
|
+
readonly properties: Readonly<Record<string, unknown>>;
|
|
27
|
+
/** Messages run through their reducers after `init` (ADR 0008's rejected-form re-render). */
|
|
28
|
+
readonly initialMessages?: readonly unknown[] | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The nearest provider's scope (opaque to view/), or undefined for the request's own scope.
|
|
31
|
+
* The renderer passes it down: a provider's subtree can span several streamed chunks, so a
|
|
32
|
+
* global set around the subtree would not survive between pulls.
|
|
33
|
+
*/
|
|
34
|
+
readonly scope?: unknown;
|
|
35
|
+
}
|
|
36
|
+
/** One registered component, as the server renderer sees it. */
|
|
37
|
+
export interface ServerComponent {
|
|
38
|
+
readonly tag: string;
|
|
39
|
+
/** `shadow: false` (ADR 0014): render as light-DOM children, not `<template shadowrootmode>`. */
|
|
40
|
+
readonly light: boolean;
|
|
41
|
+
/** `shadow: { delegatesFocus: true }`: the declarative root gets `shadowrootdelegatesfocus`. */
|
|
42
|
+
readonly delegatesFocus?: boolean;
|
|
43
|
+
/** CSS texts for the declarative shadow root's `<style>` (08). Empty for light components. */
|
|
44
|
+
readonly styles: readonly string[];
|
|
45
|
+
/** The island strategy (07): anything but `load` adds `defer-hydration` and `data-gyral-hydrate`. */
|
|
46
|
+
readonly hydrate: 'load' | 'idle' | 'visible' | 'interaction';
|
|
47
|
+
/** Parses props (validated as in the browser), runs `init` (commands dropped) and the view. */
|
|
48
|
+
render(input: ServerRenderInput): ServerRendering;
|
|
49
|
+
/** The error rendering for a view value that failed while being written (ADR 0024). */
|
|
50
|
+
fallback?(cause: unknown): ServerRendering;
|
|
51
|
+
}
|
|
52
|
+
/** Records a component. A tag registered twice keeps its first entry, as `customElements` does. */
|
|
53
|
+
export declare function registerServerComponent(component: ServerComponent): void;
|
|
54
|
+
/**
|
|
55
|
+
* Changes whenever the registry does (a component, and so its CSS, is added): caches derived
|
|
56
|
+
* from the registry (the CSP header of `@gyral/ssr`'s `renderPage`) key on it.
|
|
57
|
+
*/
|
|
58
|
+
export declare const serverRegistryVersion: () => number;
|
|
59
|
+
/** The component registered under `tag`, if any. */
|
|
60
|
+
export declare const serverComponent: (tag: string) => ServerComponent | undefined;
|
|
61
|
+
/** Every registered component (for `styleHashes()`, 06 "CSP"). */
|
|
62
|
+
export declare const serverComponents: () => readonly ServerComponent[];
|
|
63
|
+
/**
|
|
64
|
+
* A server-side provider element (`<gyral-stores>`, ADR 0013): written as a plain element, it
|
|
65
|
+
* gives its subtree a scope (passed to components as `ServerRenderInput.scope`) and may add
|
|
66
|
+
* attributes to its start tag (its seed).
|
|
67
|
+
*/
|
|
68
|
+
export interface ServerProvider {
|
|
69
|
+
readonly tag: string;
|
|
70
|
+
open(input: ServerRenderInput): {
|
|
71
|
+
readonly scope: unknown;
|
|
72
|
+
readonly attributes: Readonly<Record<string, string>>;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Records a provider element. A tag registered twice keeps its first entry. */
|
|
76
|
+
export declare function registerServerProvider(provider: ServerProvider): void;
|
|
77
|
+
/** The provider registered under `tag`, if any. */
|
|
78
|
+
export declare const serverProvider: (tag: string) => ServerProvider | undefined;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const components = new Map();
|
|
2
|
+
let version = 0;
|
|
3
|
+
/** Records a component. A tag registered twice keeps its first entry, as `customElements` does. */
|
|
4
|
+
export function registerServerComponent(component) {
|
|
5
|
+
if (components.has(component.tag))
|
|
6
|
+
return;
|
|
7
|
+
components.set(component.tag, component);
|
|
8
|
+
version++;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Changes whenever the registry does (a component, and so its CSS, is added): caches derived
|
|
12
|
+
* from the registry (the CSP header of `@gyral/ssr`'s `renderPage`) key on it.
|
|
13
|
+
*/
|
|
14
|
+
export const serverRegistryVersion = () => version;
|
|
15
|
+
/** The component registered under `tag`, if any. */
|
|
16
|
+
export const serverComponent = (tag) => components.get(tag);
|
|
17
|
+
/** Every registered component (for `styleHashes()`, 06 "CSP"). */
|
|
18
|
+
export const serverComponents = () => [...components.values()];
|
|
19
|
+
const providers = new Map();
|
|
20
|
+
/** Records a provider element. A tag registered twice keeps its first entry. */
|
|
21
|
+
export function registerServerProvider(provider) {
|
|
22
|
+
if (!providers.has(provider.tag))
|
|
23
|
+
providers.set(provider.tag, provider);
|
|
24
|
+
}
|
|
25
|
+
/** The provider registered under `tag`, if any. */
|
|
26
|
+
export const serverProvider = (tag) => providers.get(tag);
|
|
27
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/view/registry.ts"],"names":[],"mappings":"AA0DA,MAAM,UAAU,GAAG,IAAI,GAAG,EAA2B,CAAC;AACtD,IAAI,OAAO,GAAG,CAAC,CAAC;AAEhB,mGAAmG;AACnG,MAAM,UAAU,uBAAuB,CAAC,SAA0B;IAChE,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC;QAAE,OAAO;IAC1C,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACzC,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAW,EAAE,CAAC,OAAO,CAAC;AAE3D,oDAAoD;AACpD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAW,EAA+B,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjG,kEAAkE;AAClE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAA+B,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;AAe3F,MAAM,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;AAEpD,gFAAgF;AAChF,MAAM,UAAU,sBAAsB,CAAC,QAAwB;IAC7D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC1E,CAAC;AAED,mDAAmD;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAA8B,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC","sourcesContent":["// The server registry (view/05-element.md \"Registration\", view/06-server.md \"Components\").\n// Outside the browser `define()` records each spec (server-specs.ts); `@gyral/core/internal/server`\n// turns them into entries here (server-component.ts `registerRecordedSpecs`) before each\n// render, and its renderer (view/server/) looks start tags up and renders the component in\n// place. Providers (`<gyral-stores>`, ADR 0013) register a scope for their subtree. Plain data\n// and functions, no DOM: it lives in view/ so view/server/ can read it.\nimport type { ChildValue } from './render/values.js';\n\n/** What a server render of one component returns: its view and what its seed must carry. */\nexport interface ServerRendering {\n /** `view(state, intents, ctx)` for the resolved props and state. */\n readonly view: ChildValue;\n /**\n * The `data-gyral-seed` payload (ADR 0012): `props` that no attribute carries, and `state`\n * unless it equals `init(props)`'s state. JSON-serializable.\n */\n readonly seed: { readonly state?: unknown; readonly props: Readonly<Record<string, unknown>> };\n /**\n * Set when `init` or the view threw (ADR 0024): `view` is the component's error view (or\n * nothing), the host is marked `data-gyral-error` with no seed, and the renderer reports this\n * value (core's `GyralError`, opaque here) through its `onError` option.\n */\n readonly failed?: unknown;\n}\n\n/** The input of one server render, gathered from the start tag (06 \"Components\"). */\nexport interface ServerRenderInput {\n /** Static attributes plus attribute/boolean holes, as strings (`''` for a present boolean). */\n readonly attributes: Readonly<Record<string, string>>;\n /** Property holes: values as is. */\n readonly properties: Readonly<Record<string, unknown>>;\n /** Messages run through their reducers after `init` (ADR 0008's rejected-form re-render). */\n readonly initialMessages?: readonly unknown[] | undefined;\n /**\n * The nearest provider's scope (opaque to view/), or undefined for the request's own scope.\n * The renderer passes it down: a provider's subtree can span several streamed chunks, so a\n * global set around the subtree would not survive between pulls.\n */\n readonly scope?: unknown;\n}\n\n/** One registered component, as the server renderer sees it. */\nexport interface ServerComponent {\n readonly tag: string;\n /** `shadow: false` (ADR 0014): render as light-DOM children, not `<template shadowrootmode>`. */\n readonly light: boolean;\n /** `shadow: { delegatesFocus: true }`: the declarative root gets `shadowrootdelegatesfocus`. */\n readonly delegatesFocus?: boolean;\n /** CSS texts for the declarative shadow root's `<style>` (08). Empty for light components. */\n readonly styles: readonly string[];\n /** The island strategy (07): anything but `load` adds `defer-hydration` and `data-gyral-hydrate`. */\n readonly hydrate: 'load' | 'idle' | 'visible' | 'interaction';\n /** Parses props (validated as in the browser), runs `init` (commands dropped) and the view. */\n render(input: ServerRenderInput): ServerRendering;\n /** The error rendering for a view value that failed while being written (ADR 0024). */\n fallback?(cause: unknown): ServerRendering;\n}\n\nconst components = new Map<string, ServerComponent>();\nlet version = 0;\n\n/** Records a component. A tag registered twice keeps its first entry, as `customElements` does. */\nexport function registerServerComponent(component: ServerComponent): void {\n if (components.has(component.tag)) return;\n components.set(component.tag, component);\n version++;\n}\n\n/**\n * Changes whenever the registry does (a component, and so its CSS, is added): caches derived\n * from the registry (the CSP header of `@gyral/ssr`'s `renderPage`) key on it.\n */\nexport const serverRegistryVersion = (): number => version;\n\n/** The component registered under `tag`, if any. */\nexport const serverComponent = (tag: string): ServerComponent | undefined => components.get(tag);\n\n/** Every registered component (for `styleHashes()`, 06 \"CSP\"). */\nexport const serverComponents = (): readonly ServerComponent[] => [...components.values()];\n\n/**\n * A server-side provider element (`<gyral-stores>`, ADR 0013): written as a plain element, it\n * gives its subtree a scope (passed to components as `ServerRenderInput.scope`) and may add\n * attributes to its start tag (its seed).\n */\nexport interface ServerProvider {\n readonly tag: string;\n open(input: ServerRenderInput): {\n readonly scope: unknown;\n readonly attributes: Readonly<Record<string, string>>;\n };\n}\n\nconst providers = new Map<string, ServerProvider>();\n\n/** Records a provider element. A tag registered twice keeps its first entry. */\nexport function registerServerProvider(provider: ServerProvider): void {\n if (!providers.has(provider.tag)) providers.set(provider.tag, provider);\n}\n\n/** The provider registered under `tag`, if any. */\nexport const serverProvider = (tag: string): ServerProvider | undefined => providers.get(tag);\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type AttrPart } from './attr-parts.js';
|
|
2
|
+
/**
|
|
3
|
+
* Takes this render's values as committed without writing (the server wrote them). Form state
|
|
4
|
+
* the user changed before scripts ran stays: like every part, it writes only when the model's
|
|
5
|
+
* value changes (07 "Form state"). `?indeterminate`, which no attribute carries, is set; a
|
|
6
|
+
* property is set unless a nested component already has it from its own seed.
|
|
7
|
+
*/
|
|
8
|
+
export declare function adoptAttr(part: AttrPart, values: readonly unknown[]): void;
|
|
9
|
+
/**
|
|
10
|
+
* Development: the element shows what `part` adopted. Form state the user edits is compared
|
|
11
|
+
* by its attribute or default text, which edits don't change; `?open` isn't compared. `fail`
|
|
12
|
+
* throws the walk's mismatch.
|
|
13
|
+
*/
|
|
14
|
+
export declare function checkAttr(part: AttrPart, fail: (expected: string, found: string, at: Node) => never): void;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Element parts in hydration (view/07-hydration.md "The parallel walk", "Form state"): an
|
|
2
|
+
// attribute, property, hook or text part built over server DOM takes this render's values as
|
|
3
|
+
// committed. Lives with the walk, in the lazily loaded hydration code, not in attr-parts.ts.
|
|
4
|
+
import { absent, ATTR, BOOL, CHECKED, HOOK, MULTI, PLAIN, PROP, STATE, TEXTAREA, textOf, TITLE, TOGGLE, truthy, VALUE, } from './attr-parts.js';
|
|
5
|
+
/**
|
|
6
|
+
* Takes this render's values as committed without writing (the server wrote them). Form state
|
|
7
|
+
* the user changed before scripts ran stays: like every part, it writes only when the model's
|
|
8
|
+
* value changes (07 "Form state"). `?indeterminate`, which no attribute carries, is set; a
|
|
9
|
+
* property is set unless a nested component already has it from its own seed.
|
|
10
|
+
*/
|
|
11
|
+
export function adoptAttr(part, values) {
|
|
12
|
+
const v = values[part.at];
|
|
13
|
+
const el = part.el;
|
|
14
|
+
const live = el;
|
|
15
|
+
const name = part.name;
|
|
16
|
+
const kind = part.kind;
|
|
17
|
+
if (kind === HOOK)
|
|
18
|
+
part.hook(v);
|
|
19
|
+
else if (kind === PROP) {
|
|
20
|
+
part.value = v;
|
|
21
|
+
const own = live[name] !== undefined && el.localName.includes('-');
|
|
22
|
+
if (!own && !Object.is(live[name], v))
|
|
23
|
+
live[name] = v;
|
|
24
|
+
}
|
|
25
|
+
else if (kind === MULTI) {
|
|
26
|
+
const pieces = part.pieces;
|
|
27
|
+
for (let i = 0; i < pieces.length; i++)
|
|
28
|
+
pieces[i] = values[part.at + i];
|
|
29
|
+
part.value = part.join(pieces);
|
|
30
|
+
}
|
|
31
|
+
else if (kind === ATTR || kind === VALUE) {
|
|
32
|
+
part.value = v;
|
|
33
|
+
if (kind === VALUE && PLAIN.test(el.type))
|
|
34
|
+
part.kind = ATTR;
|
|
35
|
+
}
|
|
36
|
+
else if (kind === TITLE || kind === TEXTAREA)
|
|
37
|
+
part.value = textOf(part, v);
|
|
38
|
+
else if (kind === TOGGLE)
|
|
39
|
+
part.set(values); // the server can't open a modal: open it now
|
|
40
|
+
else {
|
|
41
|
+
part.value = truthy(v);
|
|
42
|
+
if (kind === STATE && live[name] !== part.value)
|
|
43
|
+
live[name] = part.value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Development: the element shows what `part` adopted. Form state the user edits is compared
|
|
48
|
+
* by its attribute or default text, which edits don't change; `?open` isn't compared. `fail`
|
|
49
|
+
* throws the walk's mismatch.
|
|
50
|
+
*/
|
|
51
|
+
export function checkAttr(part, fail) {
|
|
52
|
+
const { el, name, value } = part;
|
|
53
|
+
let want = value;
|
|
54
|
+
let got;
|
|
55
|
+
switch (part.kind) {
|
|
56
|
+
case ATTR:
|
|
57
|
+
case VALUE:
|
|
58
|
+
case MULTI:
|
|
59
|
+
// A style the CSP blocked can't be compared: Firefox empties the attribute.
|
|
60
|
+
if (name === 'style' && el.hasAttribute(name) && el.style.length === 0) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (part.kind !== MULTI)
|
|
64
|
+
want = absent(value) ? null : String(value);
|
|
65
|
+
got = el.getAttribute(name);
|
|
66
|
+
break;
|
|
67
|
+
case BOOL:
|
|
68
|
+
case CHECKED:
|
|
69
|
+
got = el.hasAttribute(name);
|
|
70
|
+
break;
|
|
71
|
+
case TITLE:
|
|
72
|
+
case TEXTAREA:
|
|
73
|
+
got = el.textContent;
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (got !== want) {
|
|
79
|
+
const what = name === '' ? 'content' : name;
|
|
80
|
+
fail(`${what} ${JSON.stringify(want)}`, `${JSON.stringify(got)} on <${el.localName}>`, el);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=adopt-attr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adopt-attr.js","sourceRoot":"","sources":["../../../src/view/render/adopt-attr.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,6FAA6F;AAC7F,6FAA6F;AAC7F,OAAO,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,KAAK,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,GAEN,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,IAAc,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AC;YAC5B,MAAM;QACR,KAAK,IAAI,CAAC;QACV,KAAK,OAAO;YACV,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAC5B,MAAM;QACR,KAAK,KAAK,CAAC;QACX,KAAK,QAAQ;YACX,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC;YACrB,MAAM;QACR;YACE,OAAO;IACX,CAAC;IACD,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5C,IAAI,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC","sourcesContent":["// Element parts in hydration (view/07-hydration.md \"The parallel walk\", \"Form state\"): an\n// attribute, property, hook or text part built over server DOM takes this render's values as\n// committed. Lives with the walk, in the lazily loaded hydration code, not in attr-parts.ts.\nimport {\n absent,\n ATTR,\n BOOL,\n CHECKED,\n HOOK,\n MULTI,\n PLAIN,\n PROP,\n STATE,\n TEXTAREA,\n textOf,\n TITLE,\n TOGGLE,\n truthy,\n VALUE,\n type AttrPart,\n} from './attr-parts.js';\n\n/**\n * Takes this render's values as committed without writing (the server wrote them). Form state\n * the user changed before scripts ran stays: like every part, it writes only when the model's\n * value changes (07 \"Form state\"). `?indeterminate`, which no attribute carries, is set; a\n * property is set unless a nested component already has it from its own seed.\n */\nexport function adoptAttr(part: AttrPart, values: readonly unknown[]): void {\n const v = values[part.at];\n const el = part.el;\n const live = el as unknown as Record<string, unknown>;\n const name = part.name;\n const kind = part.kind;\n if (kind === HOOK) part.hook(v);\n else if (kind === PROP) {\n part.value = v;\n const own = live[name] !== undefined && el.localName.includes('-');\n if (!own && !Object.is(live[name], v)) live[name] = v;\n } else if (kind === MULTI) {\n const pieces = part.pieces as unknown[];\n for (let i = 0; i < pieces.length; i++) pieces[i] = values[part.at + i];\n part.value = part.join(pieces);\n } else if (kind === ATTR || kind === VALUE) {\n part.value = v;\n if (kind === VALUE && PLAIN.test((el as HTMLInputElement).type)) part.kind = ATTR;\n } else if (kind === TITLE || kind === TEXTAREA) part.value = textOf(part, v);\n else if (kind === TOGGLE)\n part.set(values); // the server can't open a modal: open it now\n else {\n part.value = truthy(v);\n if (kind === STATE && live[name] !== part.value) live[name] = part.value;\n }\n}\n\n/**\n * Development: the element shows what `part` adopted. Form state the user edits is compared\n * by its attribute or default text, which edits don't change; `?open` isn't compared. `fail`\n * throws the walk's mismatch.\n */\nexport function checkAttr(\n part: AttrPart,\n fail: (expected: string, found: string, at: Node) => never,\n): void {\n const { el, name, value } = part;\n let want: unknown = value;\n let got: unknown;\n switch (part.kind) {\n case ATTR:\n case VALUE:\n case MULTI:\n // A style the CSP blocked can't be compared: Firefox empties the attribute.\n if (name === 'style' && el.hasAttribute(name) && (el as HTMLElement).style.length === 0) {\n return;\n }\n if (part.kind !== MULTI) want = absent(value) ? null : String(value);\n got = el.getAttribute(name);\n break;\n case BOOL:\n case CHECKED:\n got = el.hasAttribute(name);\n break;\n case TITLE:\n case TEXTAREA:\n got = el.textContent;\n break;\n default:\n return;\n }\n if (got !== want) {\n const what = name === '' ? 'content' : name;\n fail(`${what} ${JSON.stringify(want)}`, `${JSON.stringify(got)} on <${el.localName}>`, el);\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PartSpec, TemplateObject } from '../normalize/types.js';
|
|
2
|
+
import { type Plan } from './plan.js';
|
|
3
|
+
/** Per template: its element parts per static element, its child holes per parent node. */
|
|
4
|
+
export interface Adoption {
|
|
5
|
+
readonly plan: Plan;
|
|
6
|
+
readonly specs: readonly PartSpec[];
|
|
7
|
+
readonly attrs: Map<Node, number[]>;
|
|
8
|
+
readonly holes: Map<Node, number[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare function adoptionOf(template: TemplateObject): Adoption;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { nodes, planOf, stack, walk } from './plan.js';
|
|
2
|
+
const adoptions = new WeakMap();
|
|
3
|
+
export function adoptionOf(template) {
|
|
4
|
+
let a = adoptions.get(template);
|
|
5
|
+
if (a !== undefined)
|
|
6
|
+
return a;
|
|
7
|
+
const plan = planOf(template);
|
|
8
|
+
// The plan's targets in the template's own content: where each part sits.
|
|
9
|
+
stack[0] = plan.content;
|
|
10
|
+
if (plan.single)
|
|
11
|
+
stack[1] = plan.content.firstChild;
|
|
12
|
+
walk(plan);
|
|
13
|
+
a = { plan, specs: template.parts, attrs: new Map(), holes: new Map() };
|
|
14
|
+
for (let i = 0; i < plan.kinds.length; i++) {
|
|
15
|
+
const node = nodes[plan.a[i]];
|
|
16
|
+
const map = plan.kinds[i] >= 0 ? a.attrs : a.holes;
|
|
17
|
+
const list = map.get(node);
|
|
18
|
+
if (list === undefined)
|
|
19
|
+
map.set(node, [i]);
|
|
20
|
+
else
|
|
21
|
+
list.push(i);
|
|
22
|
+
}
|
|
23
|
+
adoptions.set(template, a);
|
|
24
|
+
return a;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=adopt-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adopt-plan.js","sourceRoot":"","sources":["../../../src/view/render/adopt-plan.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAa,MAAM,WAAW,CAAC;AAUlE,MAAM,SAAS,GAAG,IAAI,OAAO,EAA4B,CAAC;AAE1D,MAAM,UAAU,UAAU,CAAC,QAAwB;IACjD,IAAI,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC9B,0EAA0E;IAC1E,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;IACxB,IAAI,IAAI,CAAC,MAAM;QAAE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,UAAkB,CAAC;IAC5D,IAAI,CAAC,IAAI,CAAC,CAAC;IACX,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;IACxE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAW,CAAS,CAAC;QAChD,MAAM,GAAG,GAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAY,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC/D,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,IAAI,KAAK,SAAS;YAAE,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;;YACtC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC3B,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["// Per-template data for the hydration walk (adopt.ts, view/07-hydration.md \"The parallel\n// walk\"): which parts sit on each static element of the template's parsed content, and which\n// child holes sit in each parent node, in order. Computed once per template from its plan.\nimport type { PartSpec, TemplateObject } from '../normalize/types.js';\nimport { nodes, planOf, stack, walk, type Plan } from './plan.js';\n\n/** Per template: its element parts per static element, its child holes per parent node. */\nexport interface Adoption {\n readonly plan: Plan;\n readonly specs: readonly PartSpec[];\n readonly attrs: Map<Node, number[]>;\n readonly holes: Map<Node, number[]>;\n}\n\nconst adoptions = new WeakMap<TemplateObject, Adoption>();\n\nexport function adoptionOf(template: TemplateObject): Adoption {\n let a = adoptions.get(template);\n if (a !== undefined) return a;\n const plan = planOf(template);\n // The plan's targets in the template's own content: where each part sits.\n stack[0] = plan.content;\n if (plan.single) stack[1] = plan.content.firstChild as Node;\n walk(plan);\n a = { plan, specs: template.parts, attrs: new Map(), holes: new Map() };\n for (let i = 0; i < plan.kinds.length; i++) {\n const node = nodes[plan.a[i] as number] as Node;\n const map = (plan.kinds[i] as number) >= 0 ? a.attrs : a.holes;\n const list = map.get(node);\n if (list === undefined) map.set(node, [i]);\n else list.push(i);\n }\n adoptions.set(template, a);\n return a;\n}\n"]}
|