@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":"attr-parts.js","sourceRoot":"","sources":["../../../src/view/render/attr-parts.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,8FAA8F;AAC9F,0FAA0F;AAC1F,0FAA0F;AAC1F,0FAA0F;AAC1F,2FAA2F;AAC3F,6FAA6F;AAC7F,uFAAuF;AACvF,+FAA+F;AAC/F,wFAAwF;AACxF,yFAAyF;AACzF,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAkC,MAAM,YAAY,CAAC;AACj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AC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACtD,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,CAAC,IAAI,EAAE,CAAe,CAAC,CAAC;aACnD,IAAI,GAAG;YAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;CACF","sourcesContent":["// Element parts (view/02-bindings.md \"Attribute values\", \"Boolean attributes\", \"Properties\",\n// \"Live form state\", \"Element hooks\"): every hole on or inside one element that isn't a child\n// hole, as one class with a kind, so an instance's update loop sees only two part shapes.\n// Every part compares with its committed value and writes only on change. Live form state\n// sets the attribute too on first creation (the default, so `form.reset()` returns to the\n// model's first value); when the model's value changes it compares with the element's live\n// state and writes only on a difference, so the change lands even over a user's edit, and an\n// unchanged model never touches the control. Constructors only record nodes; hydration\n// (view/07-hydration.md) builds the same parts over server DOM and adopts this render's values\n// as committed (adopt-attr.ts), so edits made before scripts ran stay by the same rule.\n// `style` is written through the CSSOM, never `setAttribute`, so a strict CSP allows it.\nimport { DEV } from '#view-dev';\nimport type { PartSpec } from '../normalize/types.js';\nimport { COMMIT_HOOK, isHook, type HookResult, type HookSpec } from './hooks.js';\nimport { toggle } from './toggles.js';\nimport { nothing, UNSET } from './values.js';\nimport { badHook, warnFunctionProp, warnToggle, warnTrue, warnValue } from './warn.js';\n\n/** What every part of an instance implements: commit its value(s) from this render's values. */\nexport interface Part {\n set(values: readonly unknown[]): void;\n}\n\n/** `name=${v}`; `value=${v}` on a non-text input becomes this after its first commit. */\nexport const ATTR = 0;\n/** `name=\"a ${x} b\"`. */\nexport const MULTI = 1;\n/** `?name=${v}`. */\nexport const BOOL = 2;\n/** `.name=${v}`. */\nexport const PROP = 3;\n/** `value=${v}` on `<input>`: live `.value`. */\nexport const VALUE = 4;\n/** `?checked` on `<input>`, `?selected` on `<option>`: attribute first, then the live property. */\nexport const CHECKED = 5;\n/** `?indeterminate` on `<input>`: the property only. */\nexport const STATE = 6;\n/** `?open` on `<details>`/`<dialog>`: the attribute, compared with its live presence. */\nexport const OPEN = 7;\n/** `<title>${v}</title>`: text content. */\nexport const TITLE = 8;\n/** `<textarea>${v}</textarea>`: text content first, then the live `.value`. */\nexport const TEXTAREA = 9;\n/** `${hook(…)}` in a start tag. */\nexport const HOOK = 10;\n/** `?modal` on `<dialog>`, `?popover-open` on `[popover]`: opened and closed (toggles.ts). */\nexport const TOGGLE = 11;\n\n/** Input types whose `value` is a submitted value, not state the user edits. */\nexport const PLAIN = /^(checkbox|radio|hidden|button|submit|reset|image|file)$/;\n\n/** `String(v)`: numbers and booleans as text (objects warn in development first). */\nconst text = String as (value: unknown) => string;\n\nexport const absent = (v: unknown): boolean => v === null || v === undefined || v === nothing;\nexport const truthy = (v: unknown): boolean => v !== nothing && !!v;\n\nconst isObject = (v: unknown): boolean =>\n (typeof v === 'object' && v !== null) || typeof v === 'function';\n\n/** The text of a `<textarea>`/`<title>` value: child-hole rules, as one string. */\nexport function textOf(part: object, v: unknown): string {\n if (typeof v === 'string') return v;\n if (typeof v === 'number') return String(v);\n if (DEV) {\n if (v === true) warnTrue(part);\n else if (isObject(v)) warnValue(part, v, 'the text content');\n }\n return absent(v) || typeof v === 'boolean' ? '' : text(v);\n}\n\n/** The kind of a bound attribute (`?name` when `bool`) on `el`. */\nexport function attrKind(el: Element, name: string, bool: boolean): number {\n const tag = el.localName;\n if (!bool) return name === 'value' && tag === 'input' ? VALUE : ATTR;\n if (tag === 'input')\n return name === 'checked' ? CHECKED : name === 'indeterminate' ? STATE : BOOL;\n if (tag === 'option' && name === 'selected') return CHECKED;\n if (name === 'modal' || name === 'popover-open') return TOGGLE;\n return name === 'open' && (tag === 'details' || tag === 'dialog') ? OPEN : BOOL;\n}\n\n/** The element part for part table entry `spec`: `[kind, path, name?, strings?]` (01). */\nexport function attrPart(el: Element, kind: number, spec: PartSpec, at: number): AttrPart {\n const s = spec as readonly [number, unknown, string?, (readonly string[])?];\n return new AttrPart(el, kind, s[2] ?? '', at, s[3]);\n}\n\nexport class AttrPart implements Part {\n readonly el: Element;\n kind: number;\n readonly name: string;\n readonly at: number;\n /** The committed value: raw (ATTR, PROP, VALUE), boolean, string (MULTI, text), or UNSET. */\n value: unknown;\n /** MULTI: the static strings and the committed pieces. */\n readonly strings: readonly string[] | undefined;\n readonly pieces: unknown[] | undefined;\n /** HOOK: the hook, its committed arguments and the ones before. */\n spec: HookSpec<readonly unknown[]> | null;\n args: readonly unknown[] | undefined;\n prev: readonly unknown[] | undefined;\n\n constructor(el: Element, kind: number, name: string, at: number, strings?: readonly string[]) {\n this.el = el;\n this.kind = kind;\n this.name = name;\n this.at = at;\n this.value = UNSET;\n this.strings = strings;\n this.pieces =\n strings === undefined ? undefined : new Array<unknown>(strings.length - 1).fill(UNSET);\n this.spec = null;\n this.args = undefined;\n this.prev = undefined;\n }\n\n set(values: readonly unknown[]): void {\n const v = values[this.at];\n const el = this.el;\n const live = el as unknown as Record<string, unknown>;\n switch (this.kind) {\n case ATTR:\n if (v === this.value) return;\n this.value = v;\n if (absent(v)) el.removeAttribute(this.name);\n else {\n if (DEV && isObject(v)) warnValue(this, v, `the attribute ${this.name}`);\n this.write(typeof v === 'string' ? v : text(v));\n }\n return;\n case MULTI:\n this.multi(values);\n return;\n case BOOL: {\n const on = truthy(v);\n if (on === this.value) return;\n this.value = on;\n el.toggleAttribute(this.name, on);\n return;\n }\n case PROP:\n if (Object.is(v, this.value)) return;\n if (DEV && typeof v === 'function') warnFunctionProp(this, el, this.name);\n this.value = v;\n live[this.name] = v;\n return;\n case VALUE: {\n if (v === this.value) return;\n const s = absent(v) ? '' : text(v);\n if (this.value === UNSET) {\n // First creation: the attribute (the default), then the live value.\n if (absent(v)) el.removeAttribute('value');\n else el.setAttribute('value', s);\n if (PLAIN.test((el as HTMLInputElement).type)) this.kind = ATTR;\n }\n this.value = v;\n if (this.kind === VALUE && live.value !== s) live.value = s;\n return;\n }\n case CHECKED:\n case STATE: {\n const on = truthy(v);\n if (on === this.value) return;\n if (this.kind === CHECKED && this.value === UNSET) el.toggleAttribute(this.name, on);\n this.value = on;\n if (live[this.name] !== on) live[this.name] = on;\n return;\n }\n case OPEN: {\n const on = truthy(v);\n if (on === this.value) return;\n this.value = on;\n if (el.hasAttribute('open') !== on) el.toggleAttribute('open', on);\n return;\n }\n case TOGGLE: {\n const on = truthy(v);\n if (on === this.value) return;\n this.value = on;\n if (toggle !== undefined) toggle(this, this.name, on);\n else if (DEV) warnToggle(el, this.name);\n return;\n }\n case TITLE:\n case TEXTAREA: {\n const s = textOf(this, v);\n if (s === this.value) return;\n if (this.kind === TEXTAREA && this.value !== UNSET) {\n if (live.value !== s) live.value = s;\n } else el.textContent = s;\n this.value = s;\n return;\n }\n default:\n this.hook(v);\n }\n }\n\n /**\n * Writes the attribute; `style` through the CSSOM (`.style.cssText`), which a strict CSP\n * (`style-src` without `'unsafe-inline'`) allows where `setAttribute('style', …)` is blocked.\n * HTML, SVG and MathML elements all have `.style`.\n */\n write(s: string): void {\n if (this.name === 'style') (this.el as Element & ElementCSSInlineStyle).style.cssText = s;\n else this.el.setAttribute(this.name, s);\n }\n\n /**\n * MULTI: pieces joined with the static strings; `nothing` in any piece removes. With no\n * pieces it is a static `style` attribute (01 \"Normalization\"): written once, at creation.\n */\n private multi(values: readonly unknown[]): void {\n const pieces = this.pieces as unknown[];\n let changed = false;\n for (let i = 0; i < pieces.length; i++) {\n const v = values[this.at + i];\n if (v !== pieces[i]) {\n pieces[i] = v;\n changed = true;\n }\n }\n if (!changed && this.value !== UNSET) return;\n const joined = this.join(pieces);\n if (joined === this.value) return;\n this.value = joined;\n if (joined === null) this.el.removeAttribute(this.name);\n else this.write(joined);\n }\n\n /** The joined value of `pieces`, or null when one is `nothing`. */\n join(pieces: readonly unknown[]): string | null {\n const strings = this.strings as readonly string[];\n let joined = strings[0] as string;\n for (let i = 0; i < pieces.length; i++) {\n const v = pieces[i];\n if (v === nothing) return null;\n if (DEV && isObject(v)) warnValue(this, v, `the attribute ${this.name}`);\n joined += (v === null || v === undefined ? '' : text(v)) + (strings[i + 1] as string);\n }\n return joined;\n }\n\n /** HOOK: the result commits itself (hook-part.ts); an absent value forgets the hook. */\n hook(v: unknown): void {\n if (absent(v)) {\n this.spec = null;\n this.args = undefined;\n return;\n }\n const commit = isHook(v) ? v[COMMIT_HOOK] : undefined;\n if (commit !== undefined) commit(this, v as HookResult);\n else if (DEV) badHook(v);\n }\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Instance } from './instance.js';
|
|
2
|
+
import { type List } from './list.js';
|
|
3
|
+
import type { RawRange } from './raw.js';
|
|
4
|
+
/** What a child part holds. */
|
|
5
|
+
export declare const EMPTY = 0;
|
|
6
|
+
export declare const TEXT = 1;
|
|
7
|
+
export declare const INSTANCE = 2;
|
|
8
|
+
export declare const ITEMS = 3;
|
|
9
|
+
export declare const LIST = 4;
|
|
10
|
+
export declare const RAW = 5;
|
|
11
|
+
/** Resolves the position of the parts it owns (root-level open parts, rows, items). */
|
|
12
|
+
export interface Owner {
|
|
13
|
+
parentFor(index: number): Node;
|
|
14
|
+
endFor(index: number): Node | null;
|
|
15
|
+
}
|
|
16
|
+
export declare class ChildPart {
|
|
17
|
+
/** The parent element, when fixed (holes inside an element, the render root). */
|
|
18
|
+
parentNode: Node | null;
|
|
19
|
+
/** The static reference node; null: the end of `parentNode`. Unused when `owner` is set. */
|
|
20
|
+
ref: Node | null;
|
|
21
|
+
/** Set for open parts: their position comes from the owner. */
|
|
22
|
+
owner: Owner | null;
|
|
23
|
+
/** Position among the owner's rows or items. */
|
|
24
|
+
index: number;
|
|
25
|
+
/** Index of the value in the instance's values. */
|
|
26
|
+
readonly at: number;
|
|
27
|
+
/** The part is its parent element's only content (lists clear with replaceChildren). */
|
|
28
|
+
readonly sole: boolean;
|
|
29
|
+
kind: number;
|
|
30
|
+
/** Committed text value (TEXT). */
|
|
31
|
+
value: unknown;
|
|
32
|
+
content: Text | Instance | List | RawRange | null;
|
|
33
|
+
/** Rows of `each` (view/03-lists.md): key, item and pick result last rendered. */
|
|
34
|
+
key: unknown;
|
|
35
|
+
item: unknown;
|
|
36
|
+
picked: unknown;
|
|
37
|
+
constructor(parentNode: Node | null, ref: Node | null, owner: Owner | null, index: number, sole: boolean, at: number);
|
|
38
|
+
set(values: readonly unknown[]): void;
|
|
39
|
+
/** The node new content goes into. */
|
|
40
|
+
parent(): Node;
|
|
41
|
+
/** The node after this part's content (null: the end of the parent). */
|
|
42
|
+
end(): Node | null;
|
|
43
|
+
first(): Node | null;
|
|
44
|
+
last(): Node | null;
|
|
45
|
+
commit(value: unknown): void;
|
|
46
|
+
private text;
|
|
47
|
+
private template;
|
|
48
|
+
private create;
|
|
49
|
+
/** Removes the content; the part becomes empty. */
|
|
50
|
+
clear(): void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// The child part (view/02-bindings.md "Child values", "The anchor rule"): one class for every
|
|
2
|
+
// child hole, list row, array item and render root, so its call sites stay monomorphic. It
|
|
3
|
+
// inserts before its reference node: a static node of the template (`ref`), the end of its
|
|
4
|
+
// parent element (`ref` null), or, for root-level holes, rows and items, wherever its owner
|
|
5
|
+
// says (the instance's or list's position, resolved only when something is inserted).
|
|
6
|
+
import { DEV } from '#view-dev';
|
|
7
|
+
import { isTemplateResult, sourceOf, templateOf } from '../template.js';
|
|
8
|
+
import { Instance } from './instance.js';
|
|
9
|
+
import { clearList, commitItems } from './list.js';
|
|
10
|
+
import { EACH, isList, isRaw, MARKUP, nothing } from './values.js';
|
|
11
|
+
import { badChild, checkSvgParent, warnTrue } from './warn.js';
|
|
12
|
+
/** What a child part holds. */
|
|
13
|
+
export const EMPTY = 0;
|
|
14
|
+
export const TEXT = 1;
|
|
15
|
+
export const INSTANCE = 2;
|
|
16
|
+
export const ITEMS = 3;
|
|
17
|
+
export const LIST = 4;
|
|
18
|
+
export const RAW = 5;
|
|
19
|
+
export class ChildPart {
|
|
20
|
+
constructor(parentNode, ref, owner, index, sole, at) {
|
|
21
|
+
this.parentNode = parentNode;
|
|
22
|
+
this.ref = ref;
|
|
23
|
+
this.owner = owner;
|
|
24
|
+
this.index = index;
|
|
25
|
+
this.at = at;
|
|
26
|
+
this.sole = sole;
|
|
27
|
+
this.kind = EMPTY;
|
|
28
|
+
this.value = undefined;
|
|
29
|
+
this.content = null;
|
|
30
|
+
this.key = undefined;
|
|
31
|
+
this.item = undefined;
|
|
32
|
+
this.picked = undefined;
|
|
33
|
+
}
|
|
34
|
+
set(values) {
|
|
35
|
+
this.commit(values[this.at]);
|
|
36
|
+
}
|
|
37
|
+
/** The node new content goes into. */
|
|
38
|
+
parent() {
|
|
39
|
+
if (this.parentNode !== null)
|
|
40
|
+
return this.parentNode;
|
|
41
|
+
if (this.owner !== null)
|
|
42
|
+
return this.owner.parentFor(this.index);
|
|
43
|
+
return this.ref.parentNode;
|
|
44
|
+
}
|
|
45
|
+
/** The node after this part's content (null: the end of the parent). */
|
|
46
|
+
end() {
|
|
47
|
+
return this.owner === null ? this.ref : this.owner.endFor(this.index);
|
|
48
|
+
}
|
|
49
|
+
first() {
|
|
50
|
+
const content = this.content;
|
|
51
|
+
return this.kind === TEXT ? content : content && content.first();
|
|
52
|
+
}
|
|
53
|
+
last() {
|
|
54
|
+
const content = this.content;
|
|
55
|
+
return this.kind === TEXT ? content : content && content.last();
|
|
56
|
+
}
|
|
57
|
+
commit(value) {
|
|
58
|
+
switch (typeof value) {
|
|
59
|
+
case 'string':
|
|
60
|
+
case 'number':
|
|
61
|
+
this.text(value);
|
|
62
|
+
return;
|
|
63
|
+
case 'object':
|
|
64
|
+
if (value === null)
|
|
65
|
+
break;
|
|
66
|
+
if (isTemplateResult(value)) {
|
|
67
|
+
this.template(value);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (isList(value)) {
|
|
71
|
+
value[EACH](this, value);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(value)) {
|
|
75
|
+
commitItems(this, value);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (isRaw(value)) {
|
|
79
|
+
value[MARKUP](this, value.html);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (DEV)
|
|
83
|
+
badChild(value);
|
|
84
|
+
break;
|
|
85
|
+
case 'boolean':
|
|
86
|
+
if (DEV && value)
|
|
87
|
+
warnTrue(this);
|
|
88
|
+
break;
|
|
89
|
+
case 'undefined':
|
|
90
|
+
break;
|
|
91
|
+
default:
|
|
92
|
+
if (DEV && value !== nothing)
|
|
93
|
+
badChild(value);
|
|
94
|
+
}
|
|
95
|
+
if (this.kind !== EMPTY)
|
|
96
|
+
this.clear();
|
|
97
|
+
}
|
|
98
|
+
text(value) {
|
|
99
|
+
if (this.kind === TEXT) {
|
|
100
|
+
if (value !== this.value) {
|
|
101
|
+
this.value = value;
|
|
102
|
+
this.content.data = typeof value === 'string' ? value : String(value);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (this.kind !== EMPTY)
|
|
107
|
+
this.clear();
|
|
108
|
+
const data = typeof value === 'string' ? value : String(value);
|
|
109
|
+
const parent = this.parentNode;
|
|
110
|
+
let node;
|
|
111
|
+
if (this.sole && parent !== null && data !== '') {
|
|
112
|
+
// The parent's only content: one DOM call creates and inserts the Text node.
|
|
113
|
+
parent.textContent = data;
|
|
114
|
+
node = parent.firstChild;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
node = document.createTextNode(data);
|
|
118
|
+
this.parent().insertBefore(node, this.end());
|
|
119
|
+
}
|
|
120
|
+
this.kind = TEXT;
|
|
121
|
+
this.content = node;
|
|
122
|
+
this.value = value;
|
|
123
|
+
}
|
|
124
|
+
template(result) {
|
|
125
|
+
const source = sourceOf(result);
|
|
126
|
+
if (this.kind === INSTANCE) {
|
|
127
|
+
const instance = this.content;
|
|
128
|
+
if (instance.source === source) {
|
|
129
|
+
instance.update(result.values);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
// Another source with the same id (a second call site, a module reloaded in development)
|
|
133
|
+
// is the same template. Production client objects have no id: each is its own template,
|
|
134
|
+
// so a different object replaces the instance (01 "Template ids").
|
|
135
|
+
const template = templateOf(result);
|
|
136
|
+
if (template.id !== undefined && template.id === instance.template.id) {
|
|
137
|
+
instance.source = source;
|
|
138
|
+
instance.update(result.values);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this.clear();
|
|
142
|
+
this.create(result, source);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (this.kind !== EMPTY)
|
|
146
|
+
this.clear();
|
|
147
|
+
this.create(result, source);
|
|
148
|
+
}
|
|
149
|
+
create(result, source) {
|
|
150
|
+
const template = templateOf(result);
|
|
151
|
+
if (DEV && template.svg)
|
|
152
|
+
checkSvgParent(this.parent());
|
|
153
|
+
const instance = new Instance(template, source, this);
|
|
154
|
+
instance.update(result.values);
|
|
155
|
+
instance.insert(this.parent(), this.end());
|
|
156
|
+
this.kind = INSTANCE;
|
|
157
|
+
this.content = instance;
|
|
158
|
+
}
|
|
159
|
+
/** Removes the content; the part becomes empty. */
|
|
160
|
+
clear() {
|
|
161
|
+
const content = this.content;
|
|
162
|
+
if (this.kind === TEXT)
|
|
163
|
+
content.remove();
|
|
164
|
+
else if (this.kind === ITEMS || this.kind === LIST)
|
|
165
|
+
clearList(this, content);
|
|
166
|
+
else if (content !== null)
|
|
167
|
+
content.remove();
|
|
168
|
+
this.kind = EMPTY;
|
|
169
|
+
this.content = null;
|
|
170
|
+
this.value = undefined;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=child-part.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"child-part.js","sourceRoot":"","sources":["../../../src/view/render/child-part.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,2FAA2F;AAC3F,2FAA2F;AAC3F,4FAA4F;AAC5F,sFAAsF;AACtF,OAAO,EAAE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;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAG,OAAgB,CAAC,MAAM,EAAE,CAAC;aAC9C,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,SAAS,CAAC,IAAI,EAAE,OAAe,CAAC,CAAC;aAChF,IAAI,OAAO,KAAK,IAAI;YAAG,OAA+B,CAAC,MAAM,EAAE,CAAC;QACrE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF","sourcesContent":["// The child part (view/02-bindings.md \"Child values\", \"The anchor rule\"): one class for every\n// child hole, list row, array item and render root, so its call sites stay monomorphic. It\n// inserts before its reference node: a static node of the template (`ref`), the end of its\n// parent element (`ref` null), or, for root-level holes, rows and items, wherever its owner\n// says (the instance's or list's position, resolved only when something is inserted).\nimport { DEV } from '#view-dev';\nimport { isTemplateResult, sourceOf, templateOf, type TemplateResult } from '../template.js';\nimport { Instance } from './instance.js';\nimport { clearList, commitItems, type List } from './list.js';\nimport { EACH, isList, isRaw, MARKUP, nothing } from './values.js';\nimport type { RawRange } from './raw.js';\nimport { badChild, checkSvgParent, warnTrue } from './warn.js';\n\n/** What a child part holds. */\nexport const EMPTY = 0;\nexport const TEXT = 1;\nexport const INSTANCE = 2;\nexport const ITEMS = 3;\nexport const LIST = 4;\nexport const RAW = 5;\n\n/** Resolves the position of the parts it owns (root-level open parts, rows, items). */\nexport interface Owner {\n parentFor(index: number): Node;\n endFor(index: number): Node | null;\n}\n\n/** What a child part's content can be, besides text. */\ntype Span = Instance | List | RawRange;\n\nexport class ChildPart {\n /** The parent element, when fixed (holes inside an element, the render root). */\n parentNode: Node | null;\n /** The static reference node; null: the end of `parentNode`. Unused when `owner` is set. */\n ref: Node | null;\n /** Set for open parts: their position comes from the owner. */\n owner: Owner | null;\n /** Position among the owner's rows or items. */\n index: number;\n /** Index of the value in the instance's values. */\n readonly at: number;\n /** The part is its parent element's only content (lists clear with replaceChildren). */\n readonly sole: boolean;\n kind: number;\n /** Committed text value (TEXT). */\n value: unknown;\n content: Text | Instance | List | RawRange | null;\n /** Rows of `each` (view/03-lists.md): key, item and pick result last rendered. */\n key: unknown;\n item: unknown;\n picked: unknown;\n\n constructor(\n parentNode: Node | null,\n ref: Node | null,\n owner: Owner | null,\n index: number,\n sole: boolean,\n at: number,\n ) {\n this.parentNode = parentNode;\n this.ref = ref;\n this.owner = owner;\n this.index = index;\n this.at = at;\n this.sole = sole;\n this.kind = EMPTY;\n this.value = undefined;\n this.content = null;\n this.key = undefined;\n this.item = undefined;\n this.picked = undefined;\n }\n\n set(values: readonly unknown[]): void {\n this.commit(values[this.at]);\n }\n\n /** The node new content goes into. */\n parent(): Node {\n if (this.parentNode !== null) return this.parentNode;\n if (this.owner !== null) return this.owner.parentFor(this.index);\n return (this.ref as Node).parentNode as Node;\n }\n\n /** The node after this part's content (null: the end of the parent). */\n end(): Node | null {\n return this.owner === null ? this.ref : this.owner.endFor(this.index);\n }\n\n first(): Node | null {\n const content = this.content;\n return this.kind === TEXT ? (content as Text) : content && (content as Span).first();\n }\n\n last(): Node | null {\n const content = this.content;\n return this.kind === TEXT ? (content as Text) : content && (content as Span).last();\n }\n\n commit(value: unknown): void {\n switch (typeof value) {\n case 'string':\n case 'number':\n this.text(value);\n return;\n case 'object':\n if (value === null) break;\n if (isTemplateResult(value)) {\n this.template(value);\n return;\n }\n if (isList(value)) {\n value[EACH](this, value);\n return;\n }\n if (Array.isArray(value)) {\n commitItems(this, value);\n return;\n }\n if (isRaw(value)) {\n value[MARKUP](this, value.html);\n return;\n }\n if (DEV) badChild(value);\n break;\n case 'boolean':\n if (DEV && value) warnTrue(this);\n break;\n case 'undefined':\n break;\n default:\n if (DEV && value !== nothing) badChild(value);\n }\n if (this.kind !== EMPTY) this.clear();\n }\n\n private text(value: string | number): void {\n if (this.kind === TEXT) {\n if (value !== this.value) {\n this.value = value;\n (this.content as Text).data = typeof value === 'string' ? value : String(value);\n }\n return;\n }\n if (this.kind !== EMPTY) this.clear();\n const data = typeof value === 'string' ? value : String(value);\n const parent = this.parentNode;\n let node: Text;\n if (this.sole && parent !== null && data !== '') {\n // The parent's only content: one DOM call creates and inserts the Text node.\n parent.textContent = data;\n node = parent.firstChild as Text;\n } else {\n node = document.createTextNode(data);\n this.parent().insertBefore(node, this.end());\n }\n this.kind = TEXT;\n this.content = node;\n this.value = value;\n }\n\n private template(result: TemplateResult): void {\n const source = sourceOf(result);\n if (this.kind === INSTANCE) {\n const instance = this.content as Instance;\n if (instance.source === source) {\n instance.update(result.values);\n return;\n }\n // Another source with the same id (a second call site, a module reloaded in development)\n // is the same template. Production client objects have no id: each is its own template,\n // so a different object replaces the instance (01 \"Template ids\").\n const template = templateOf(result);\n if (template.id !== undefined && template.id === instance.template.id) {\n instance.source = source;\n instance.update(result.values);\n return;\n }\n this.clear();\n this.create(result, source);\n return;\n }\n if (this.kind !== EMPTY) this.clear();\n this.create(result, source);\n }\n\n private create(result: TemplateResult, source: unknown): void {\n const template = templateOf(result);\n if (DEV && template.svg) checkSvgParent(this.parent());\n const instance = new Instance(template, source, this);\n instance.update(result.values);\n instance.insert(this.parent(), this.end());\n this.kind = INSTANCE;\n this.content = instance;\n }\n\n /** Removes the content; the part becomes empty. */\n clear(): void {\n const content = this.content;\n if (this.kind === TEXT) (content as Text).remove();\n else if (this.kind === ITEMS || this.kind === LIST) clearList(this, content as List);\n else if (content !== null) (content as Instance | RawRange).remove();\n this.kind = EMPTY;\n this.content = null;\n this.value = undefined;\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChildPart } from './child-part.js';
|
|
2
|
+
import { type List } from './rows.js';
|
|
3
|
+
import { type ListResult } from './values.js';
|
|
4
|
+
/** Rows re-evaluated per flush (render.ts `renderBatch`), or per render call outside one. */
|
|
5
|
+
export declare const ROW_CHECKS = 200;
|
|
6
|
+
/** Called at the start of each flush, or of a `render` call outside one. */
|
|
7
|
+
export declare function resetRowChecks(): void;
|
|
8
|
+
/** Keys are unique strings or numbers. Guarded here too: the lazy hydration chunk calls it. */
|
|
9
|
+
export declare function checkKeys(items: readonly unknown[], key: (item: unknown) => unknown): void;
|
|
10
|
+
export declare function recheckRows(list: List, l: ListResult): void;
|
|
11
|
+
/** Whether rendering `value` into `part` would change nothing. */
|
|
12
|
+
export declare function sameChild(part: ChildPart, value: unknown): boolean;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Development checks for lists (view/03-lists.md "Keys", "Rows must be pure"). Keys must be
|
|
2
|
+
// unique strings or numbers. Skipped rows are re-evaluated and compared with what is committed
|
|
3
|
+
// (template, by id or identity, and values, recursively); a difference warns once per row
|
|
4
|
+
// function. At most 200 rows are checked per flush (per render call outside one), rotating
|
|
5
|
+
// through each list. Only reached under `if (DEV)`.
|
|
6
|
+
import { DEV } from '#view-dev';
|
|
7
|
+
import { isTemplateResult, templateOf } from '../template.js';
|
|
8
|
+
import { BOOL, CHECKED, HOOK, MULTI, OPEN, STATE, TEXTAREA, textOf, TITLE, truthy, } from './attr-parts.js';
|
|
9
|
+
import { ChildPart, EMPTY, INSTANCE, ITEMS, LIST, RAW, TEXT } from './child-part.js';
|
|
10
|
+
import { hookSpec, sameArgs } from './hooks.js';
|
|
11
|
+
import { samePick } from './rows.js';
|
|
12
|
+
import { isList, rawHtml } from './values.js';
|
|
13
|
+
import { badKey, warnImpureRow } from './warn.js';
|
|
14
|
+
/** Rows re-evaluated per flush (render.ts `renderBatch`), or per render call outside one. */
|
|
15
|
+
export const ROW_CHECKS = 200;
|
|
16
|
+
let budget = ROW_CHECKS;
|
|
17
|
+
const warned = new WeakSet();
|
|
18
|
+
/** Called at the start of each flush, or of a `render` call outside one. */
|
|
19
|
+
export function resetRowChecks() {
|
|
20
|
+
budget = ROW_CHECKS;
|
|
21
|
+
}
|
|
22
|
+
/** Keys are unique strings or numbers. Guarded here too: the lazy hydration chunk calls it. */
|
|
23
|
+
export function checkKeys(items, key) {
|
|
24
|
+
if (!DEV)
|
|
25
|
+
return;
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
for (let i = 0; i < items.length; i++) {
|
|
28
|
+
const k = key(items[i]);
|
|
29
|
+
if (typeof k !== 'string' && typeof k !== 'number')
|
|
30
|
+
badKey(k, i, false);
|
|
31
|
+
if (seen.has(k))
|
|
32
|
+
badKey(k, i, true);
|
|
33
|
+
seen.add(k);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function recheckRows(list, l) {
|
|
37
|
+
const rows = list.rows;
|
|
38
|
+
const n = rows.length;
|
|
39
|
+
if (n === 0 || budget <= 0 || warned.has(l.row))
|
|
40
|
+
return;
|
|
41
|
+
const count = Math.min(budget, n);
|
|
42
|
+
budget -= count;
|
|
43
|
+
let at = list.cursor % n;
|
|
44
|
+
for (let k = 0; k < count; k++) {
|
|
45
|
+
const row = rows[at];
|
|
46
|
+
if (!sameChild(row, l.row(row.item, row.picked))) {
|
|
47
|
+
warned.add(l.row);
|
|
48
|
+
warnImpureRow(l.row);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
at = (at + 1) % n;
|
|
52
|
+
}
|
|
53
|
+
list.cursor = at;
|
|
54
|
+
}
|
|
55
|
+
/** Whether rendering `value` into `part` would change nothing. */
|
|
56
|
+
export function sameChild(part, value) {
|
|
57
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
58
|
+
return part.kind === TEXT && Object.is(part.value, value);
|
|
59
|
+
}
|
|
60
|
+
if (typeof value === 'object' && value !== null) {
|
|
61
|
+
if (isTemplateResult(value)) {
|
|
62
|
+
if (part.kind !== INSTANCE)
|
|
63
|
+
return false;
|
|
64
|
+
const committed = part.content;
|
|
65
|
+
const template = templateOf(value);
|
|
66
|
+
return ((committed.template === template ||
|
|
67
|
+
(template.id !== undefined && template.id === committed.template.id)) &&
|
|
68
|
+
committed.parts.every((p) => samePart(p, value.values)));
|
|
69
|
+
}
|
|
70
|
+
if (isList(value))
|
|
71
|
+
return part.kind === LIST && sameList(part.content, value);
|
|
72
|
+
if (Array.isArray(value)) {
|
|
73
|
+
if (part.kind !== ITEMS)
|
|
74
|
+
return false;
|
|
75
|
+
const rows = part.content.rows;
|
|
76
|
+
return rows.length === value.length && rows.every((r, i) => sameChild(r, value[i]));
|
|
77
|
+
}
|
|
78
|
+
const html = rawHtml(value);
|
|
79
|
+
if (html !== undefined)
|
|
80
|
+
return part.kind === RAW && part.content.html === html;
|
|
81
|
+
}
|
|
82
|
+
return part.kind === EMPTY;
|
|
83
|
+
}
|
|
84
|
+
function samePart(p, values) {
|
|
85
|
+
if (p instanceof ChildPart)
|
|
86
|
+
return sameChild(p, values[p.at]);
|
|
87
|
+
const part = p;
|
|
88
|
+
const v = values[part.at];
|
|
89
|
+
switch (part.kind) {
|
|
90
|
+
case MULTI:
|
|
91
|
+
return (part.pieces ?? []).every((piece, i) => Object.is(piece, values[part.at + i]));
|
|
92
|
+
case BOOL:
|
|
93
|
+
case CHECKED:
|
|
94
|
+
case STATE:
|
|
95
|
+
case OPEN:
|
|
96
|
+
return part.value === truthy(v);
|
|
97
|
+
case TITLE:
|
|
98
|
+
case TEXTAREA:
|
|
99
|
+
return part.value === textOf(part, v);
|
|
100
|
+
case HOOK: {
|
|
101
|
+
const spec = hookSpec(v);
|
|
102
|
+
if (spec === undefined)
|
|
103
|
+
return part.spec === null;
|
|
104
|
+
return spec === part.spec && sameArgs(v.args, part.args);
|
|
105
|
+
}
|
|
106
|
+
default:
|
|
107
|
+
// ATTR, PROP and VALUE keep the raw committed value.
|
|
108
|
+
return Object.is(part.value, v);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function sameList(list, l) {
|
|
112
|
+
const rows = list.rows;
|
|
113
|
+
if (rows.length !== l.items.length)
|
|
114
|
+
return false;
|
|
115
|
+
return rows.every((row, i) => {
|
|
116
|
+
const item = l.items[i];
|
|
117
|
+
return (row.item === item &&
|
|
118
|
+
Object.is(row.key, l.key(item)) &&
|
|
119
|
+
samePick(row.picked, l.pick === undefined ? undefined : l.pick(item)));
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=dev-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-check.js","sourceRoot":"","sources":["../../../src/view/render/dev-check.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,+FAA+F;AAC/F,0FAA0F;AAC1F,2FAA2F;AAC3F,oDAAoD;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,GAGP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAErF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAmB,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAa,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAmB,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAElD,6FAA6F;AAC7F,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC;AAC9B,IAAI,MAAM,GAAG,UAAU,CAAC;AACxB,MAAM,MAAM,GAAG,IAAI,OAAO,EAAU,CAAC;AAErC,4EAA4E;AAC5E,MAAM,UAAU,cAAc;IAC5B,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M,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC/B,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CACtE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Development checks for lists (view/03-lists.md \"Keys\", \"Rows must be pure\"). Keys must be\n// unique strings or numbers. Skipped rows are re-evaluated and compared with what is committed\n// (template, by id or identity, and values, recursively); a difference warns once per row\n// function. At most 200 rows are checked per flush (per render call outside one), rotating\n// through each list. Only reached under `if (DEV)`.\nimport { DEV } from '#view-dev';\nimport { isTemplateResult, templateOf } from '../template.js';\nimport {\n BOOL,\n CHECKED,\n HOOK,\n MULTI,\n OPEN,\n STATE,\n TEXTAREA,\n textOf,\n TITLE,\n truthy,\n type AttrPart,\n type Part,\n} from './attr-parts.js';\nimport { ChildPart, EMPTY, INSTANCE, ITEMS, LIST, RAW, TEXT } from './child-part.js';\nimport type { RawRange } from './raw.js';\nimport { hookSpec, sameArgs, type HookResult } from './hooks.js';\nimport type { Instance } from './instance.js';\nimport { samePick, type List } from './rows.js';\nimport { isList, rawHtml, type ListResult } from './values.js';\nimport { badKey, warnImpureRow } from './warn.js';\n\n/** Rows re-evaluated per flush (render.ts `renderBatch`), or per render call outside one. */\nexport const ROW_CHECKS = 200;\nlet budget = ROW_CHECKS;\nconst warned = new WeakSet<object>();\n\n/** Called at the start of each flush, or of a `render` call outside one. */\nexport function resetRowChecks(): void {\n budget = ROW_CHECKS;\n}\n\n/** Keys are unique strings or numbers. Guarded here too: the lazy hydration chunk calls it. */\nexport function checkKeys(items: readonly unknown[], key: (item: unknown) => unknown): void {\n if (!DEV) return;\n const seen = new Set<unknown>();\n for (let i = 0; i < items.length; i++) {\n const k = key(items[i]);\n if (typeof k !== 'string' && typeof k !== 'number') badKey(k, i, false);\n if (seen.has(k)) badKey(k, i, true);\n seen.add(k);\n }\n}\n\nexport function recheckRows(list: List, l: ListResult): void {\n const rows = list.rows;\n const n = rows.length;\n if (n === 0 || budget <= 0 || warned.has(l.row)) return;\n const count = Math.min(budget, n);\n budget -= count;\n let at = list.cursor % n;\n for (let k = 0; k < count; k++) {\n const row = rows[at] as ChildPart;\n if (!sameChild(row, l.row(row.item, row.picked))) {\n warned.add(l.row);\n warnImpureRow(l.row);\n break;\n }\n at = (at + 1) % n;\n }\n list.cursor = at;\n}\n\n/** Whether rendering `value` into `part` would change nothing. */\nexport function sameChild(part: ChildPart, value: unknown): boolean {\n if (typeof value === 'string' || typeof value === 'number') {\n return part.kind === TEXT && Object.is(part.value, value);\n }\n if (typeof value === 'object' && value !== null) {\n if (isTemplateResult(value)) {\n if (part.kind !== INSTANCE) return false;\n const committed = part.content as Instance;\n const template = templateOf(value);\n return (\n (committed.template === template ||\n (template.id !== undefined && template.id === committed.template.id)) &&\n committed.parts.every((p) => samePart(p, value.values))\n );\n }\n if (isList(value)) return part.kind === LIST && sameList(part.content as List, value);\n if (Array.isArray(value)) {\n if (part.kind !== ITEMS) return false;\n const rows = (part.content as List).rows;\n return rows.length === value.length && rows.every((r, i) => sameChild(r, value[i]));\n }\n const html = rawHtml(value);\n if (html !== undefined) return part.kind === RAW && (part.content as RawRange).html === html;\n }\n return part.kind === EMPTY;\n}\n\nfunction samePart(p: Part, values: readonly unknown[]): boolean {\n if (p instanceof ChildPart) return sameChild(p, values[p.at]);\n const part = p as AttrPart;\n const v = values[part.at];\n switch (part.kind) {\n case MULTI:\n return (part.pieces ?? []).every((piece, i) => Object.is(piece, values[part.at + i]));\n case BOOL:\n case CHECKED:\n case STATE:\n case OPEN:\n return part.value === truthy(v);\n case TITLE:\n case TEXTAREA:\n return part.value === textOf(part, v);\n case HOOK: {\n const spec = hookSpec(v);\n if (spec === undefined) return part.spec === null;\n return spec === part.spec && sameArgs((v as HookResult).args, part.args);\n }\n default:\n // ATTR, PROP and VALUE keep the raw committed value.\n return Object.is(part.value, v);\n }\n}\n\nfunction sameList(list: List, l: ListResult): boolean {\n const rows = list.rows;\n if (rows.length !== l.items.length) return false;\n return rows.every((row, i) => {\n const item = l.items[i];\n return (\n row.item === item &&\n Object.is(row.key, l.key(item)) &&\n samePick(row.picked, l.pick === undefined ? undefined : l.pick(item))\n );\n });\n}\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Disposable hooks (view/02-bindings.md "Widgets with a lifecycle"): hooks whose spec has
|
|
2
|
+
// `dispose`, and the tracking behind it. A disposable hook is tracked per render root from its commit
|
|
3
|
+
// (`track`), with the spec and arguments to dispose (`kept`, `keptArgs`). After each render of
|
|
4
|
+
// a root commits, before its client calls, `run` disposes every tracked hook whose element left
|
|
5
|
+
// the root (Gyral removed it: a cleared part, a replaced instance, a removed row; moves keep it
|
|
6
|
+
// inside) or whose position no longer holds it (`nothing`, another hook); a disposable hook
|
|
7
|
+
// replacing one disposes the old one in `track`. When the host disconnects, `run(root, true)`
|
|
8
|
+
// disposes the root's hooks and marks them `off`: the render on reconnect re-commits them from
|
|
9
|
+
// scratch (`prev` undefined) or, for skipped rows, `run` queues their `client` again. Nothing
|
|
10
|
+
// here is bundled unless it is registered (`#spec-features`, or use-disposal.ts when a module
|
|
11
|
+
// names `dispose`: gyral-c5d.2, gyral-1zd.24), and nothing runs until such a hook commits.
|
|
12
|
+
import { commitHook } from './hook-part.js';
|
|
13
|
+
import { committing, queueHook, useDisposal, } from './hooks.js';
|
|
14
|
+
/** Parts committed since their root's hooks last ran, with that root. */
|
|
15
|
+
let fresh = [];
|
|
16
|
+
const live = new WeakMap();
|
|
17
|
+
const dispose = (p) => {
|
|
18
|
+
p.kept.dispose?.(p.el, p.keptArgs);
|
|
19
|
+
};
|
|
20
|
+
function run(root, disconnect) {
|
|
21
|
+
let tracked = live.get(root);
|
|
22
|
+
if (disconnect !== true) {
|
|
23
|
+
// Inside a flush several roots commit before their hooks run: keep the others' parts.
|
|
24
|
+
const rest = [];
|
|
25
|
+
for (const entry of fresh) {
|
|
26
|
+
const [p, owner] = entry;
|
|
27
|
+
if (owner !== root) {
|
|
28
|
+
if (p.el.isConnected)
|
|
29
|
+
rest.push(entry);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (!root.contains(p.el))
|
|
33
|
+
continue; // left over from a render that threw
|
|
34
|
+
if (tracked === undefined)
|
|
35
|
+
live.set(root, (tracked = new Set()));
|
|
36
|
+
tracked.add(p);
|
|
37
|
+
}
|
|
38
|
+
fresh = rest;
|
|
39
|
+
}
|
|
40
|
+
if (tracked === undefined)
|
|
41
|
+
return false;
|
|
42
|
+
for (const p of tracked) {
|
|
43
|
+
const off = p.off;
|
|
44
|
+
p.off = disconnect;
|
|
45
|
+
if (disconnect === true || !root.contains(p.el) || p.spec !== p.kept) {
|
|
46
|
+
if (disconnect !== true)
|
|
47
|
+
tracked.delete(p);
|
|
48
|
+
if (off !== true)
|
|
49
|
+
dispose(p);
|
|
50
|
+
}
|
|
51
|
+
else if (off === true) {
|
|
52
|
+
p.prev = undefined; // a skipped row's hook: client again, from scratch
|
|
53
|
+
queueHook(p);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return tracked.size > 0;
|
|
57
|
+
}
|
|
58
|
+
/** A disposable hook committed at `part`: tracks it, and turns disposal on. */
|
|
59
|
+
function track(part) {
|
|
60
|
+
useDisposal(run);
|
|
61
|
+
// Replaced by this one, unless a disconnect disposed it already.
|
|
62
|
+
if (part.off !== true && part.kept !== undefined && part.kept !== part.spec)
|
|
63
|
+
dispose(part);
|
|
64
|
+
part.off = false;
|
|
65
|
+
part.kept = part.spec ?? undefined;
|
|
66
|
+
part.keptArgs = part.args;
|
|
67
|
+
fresh.push([part, committing()]);
|
|
68
|
+
}
|
|
69
|
+
/** Commits a disposable hook, then tracks it for removal and disconnects. */
|
|
70
|
+
export function commitTracked(part, result) {
|
|
71
|
+
if (part.off === true)
|
|
72
|
+
part.spec = null; // disposed by a disconnect: start over, always queued
|
|
73
|
+
commitHook(part, result);
|
|
74
|
+
track(part);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=dispose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispose.js","sourceRoot":"","sources":["../../../src/view/render/dispose.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,sGAAsG;AACtG,+FAA+F;AAC/F,gGAAgG;AAChG,gGAAgG;AAChG,4FAA4F;AAC5F,8FAA8F;AAC9F,+FAA+F;AAC/F,8FAA8F;AAC9F,8FAA8F;AAC9F,2FAA2F;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,GAIZ,MAAM,YAAY,CAAC;AAEpB,yEAAyE;AACzE,IAAI,KAAK,GAAmC,EAAE,CAAC;AAC/C,MAAM,IAAI,GAAG,IAAI,OAAO,EAAuB,CAAC;AAEhD,MAAM,OAAO,GAAG,CAAC,CAAW,EAAQ,EAAE;IACnC,CAAC,CAAC,IAAqC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAA8B,CAAC,CAAC;AAC7F,CAAC,CAAC;AAEF,SAAS,GAAG,CAAC,IAAU,EAAE,UAAoB;IAC3C,IAAI,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,sFAAsF;QACtF,MAAM,IAAI,GAAmC,EAAE,CAAC;QAChD,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;YAC1B,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;YACzB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,IAAI,CAAC,CAAC,EAAE,CAAC,W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I,CAAC,GAAG,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3F,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;IACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC;IACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;IAC1B,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,aAAa,CAAC,IAAc,EAAE,MAAkB;IAC9D,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI;QAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,sDAAsD;IAC/F,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzB,KAAK,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","sourcesContent":["// Disposable hooks (view/02-bindings.md \"Widgets with a lifecycle\"): hooks whose spec has\n// `dispose`, and the tracking behind it. A disposable hook is tracked per render root from its commit\n// (`track`), with the spec and arguments to dispose (`kept`, `keptArgs`). After each render of\n// a root commits, before its client calls, `run` disposes every tracked hook whose element left\n// the root (Gyral removed it: a cleared part, a replaced instance, a removed row; moves keep it\n// inside) or whose position no longer holds it (`nothing`, another hook); a disposable hook\n// replacing one disposes the old one in `track`. When the host disconnects, `run(root, true)`\n// disposes the root's hooks and marks them `off`: the render on reconnect re-commits them from\n// scratch (`prev` undefined) or, for skipped rows, `run` queues their `client` again. Nothing\n// here is bundled unless it is registered (`#spec-features`, or use-disposal.ts when a module\n// names `dispose`: gyral-c5d.2, gyral-1zd.24), and nothing runs until such a hook commits.\nimport { commitHook } from './hook-part.js';\nimport {\n committing,\n queueHook,\n useDisposal,\n type HookPart,\n type HookResult,\n type HookSpec,\n} from './hooks.js';\n\n/** Parts committed since their root's hooks last ran, with that root. */\nlet fresh: [HookPart, Node | undefined][] = [];\nconst live = new WeakMap<Node, Set<HookPart>>();\n\nconst dispose = (p: HookPart): void => {\n (p.kept as HookSpec<readonly unknown[]>).dispose?.(p.el, p.keptArgs as readonly unknown[]);\n};\n\nfunction run(root: Node, disconnect?: boolean): boolean {\n let tracked = live.get(root);\n if (disconnect !== true) {\n // Inside a flush several roots commit before their hooks run: keep the others' parts.\n const rest: [HookPart, Node | undefined][] = [];\n for (const entry of fresh) {\n const [p, owner] = entry;\n if (owner !== root) {\n if (p.el.isConnected) rest.push(entry);\n continue;\n }\n if (!root.contains(p.el)) continue; // left over from a render that threw\n if (tracked === undefined) live.set(root, (tracked = new Set()));\n tracked.add(p);\n }\n fresh = rest;\n }\n if (tracked === undefined) return false;\n for (const p of tracked) {\n const off = p.off;\n p.off = disconnect;\n if (disconnect === true || !root.contains(p.el) || p.spec !== p.kept) {\n if (disconnect !== true) tracked.delete(p);\n if (off !== true) dispose(p);\n } else if (off === true) {\n p.prev = undefined; // a skipped row's hook: client again, from scratch\n queueHook(p);\n }\n }\n return tracked.size > 0;\n}\n\n/** A disposable hook committed at `part`: tracks it, and turns disposal on. */\nfunction track(part: HookPart): void {\n useDisposal(run);\n // Replaced by this one, unless a disconnect disposed it already.\n if (part.off !== true && part.kept !== undefined && part.kept !== part.spec) dispose(part);\n part.off = false;\n part.kept = part.spec ?? undefined;\n part.keptArgs = part.args;\n fresh.push([part, committing()]);\n}\n\n/** Commits a disposable hook, then tracks it for removal and disconnects. */\nexport function commitTracked(part: HookPart, result: HookResult): void {\n if (part.off === true) part.spec = null; // disposed by a disconnect: start over, always queued\n commitHook(part, result);\n track(part);\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type HookPart, type HookResult, type HookSpec } from './hooks.js';
|
|
2
|
+
/** Queues the client call when the hook or its arguments changed, or always (`update`). */
|
|
3
|
+
export declare function commitHook(part: HookPart, result: HookResult): void;
|
|
4
|
+
/** Defines an element hook: a small behaviour attached to the element it sits on. */
|
|
5
|
+
export declare function defineHook<A extends readonly unknown[]>(spec: HookSpec<A>): (...args: A) => HookResult<A>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// `defineHook` (view/02-bindings.md "Element hooks"): its results carry `commitHook`, so the
|
|
2
|
+
// code that compares arguments and queues client calls is bundled only by apps with hooks.
|
|
3
|
+
// A spec with `dispose` commits through dispose.ts's tracking, registered separately (hooks.ts
|
|
4
|
+
// `disposableCommit`) so apps whose hooks have no teardown don't bundle it (gyral-c5d.2).
|
|
5
|
+
import { DEV } from '#view-dev';
|
|
6
|
+
import { runner } from './hook-run.js';
|
|
7
|
+
import { disposableCommit, hookResult, hookSpec, queueHook, sameArgs, useHookRunner, } from './hooks.js';
|
|
8
|
+
/** Queues the client call when the hook or its arguments changed, or always (`update`). */
|
|
9
|
+
export function commitHook(part, result) {
|
|
10
|
+
const spec = hookSpec(result);
|
|
11
|
+
const args = result.args;
|
|
12
|
+
const same = spec === part.spec;
|
|
13
|
+
if (same && spec.update !== 'always' && sameArgs(args, part.args))
|
|
14
|
+
return;
|
|
15
|
+
part.prev = same ? part.args : undefined;
|
|
16
|
+
part.spec = spec;
|
|
17
|
+
part.args = args;
|
|
18
|
+
queueHook(part);
|
|
19
|
+
}
|
|
20
|
+
/** Defines an element hook: a small behaviour attached to the element it sits on. */
|
|
21
|
+
export function defineHook(spec) {
|
|
22
|
+
useHookRunner(runner);
|
|
23
|
+
return (...args) => hookResult(spec, args, spec.dispose === undefined ? commitHook : commitDisposable);
|
|
24
|
+
}
|
|
25
|
+
let warned = false;
|
|
26
|
+
/** A hook with `dispose`: tracked when disposal is registered, else committed plainly. */
|
|
27
|
+
function commitDisposable(part, result) {
|
|
28
|
+
if (DEV && disposableCommit === undefined && !warned) {
|
|
29
|
+
warned = true;
|
|
30
|
+
console.warn('gyral: a hook declares dispose, but the build found no module naming it, so hook ' +
|
|
31
|
+
'disposal was left out and dispose never runs. Write the dispose key in your source ' +
|
|
32
|
+
'(view/05-element.md "Features register themselves").');
|
|
33
|
+
}
|
|
34
|
+
(disposableCommit ?? commitHook)(part, result);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=hook-part.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-part.js","sourceRoot":"","sources":["../../../src/view/render/hook-part.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,2FAA2F;AAC3F,+FAA+F;AAC/F,0FAA0F;AAC1F,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,GAId,MAAM,YAAY,CAAC;AAEpB,2FAA2F;AAC3F,MAAM,UAAU,UAAU,CAAC,IAAc,EAAE,MAAkB;IAC3D,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAiC,CAAC;IAC9D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,MAAM,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;IAChC,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO;IAC1E,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,SAAS,CAAC,IAAI,CAAC,CAAC;AAClB,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,UAAU,CACxB,IAAiB;IAEjB,aAAa,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,CACjB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;AACvF,CAAC;AAED,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,0FAA0F;AAC1F,SAAS,gBAAgB,CAAC,IAAc,EAAE,MAAkB;IAC1D,IAAI,GAAG,IAAI,gBAAgB,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC;QACrD,MAAM,GAAG,IAAI,CAAC;QACd,OAAO,CAAC,IAAI,CACV,mFAAmF;YACjF,qFAAqF;YACrF,sDAAsD,CACzD,CAAC;IACJ,CAAC;IACD,CAAC,gBAAgB,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// `defineHook` (view/02-bindings.md \"Element hooks\"): its results carry `commitHook`, so the\n// code that compares arguments and queues client calls is bundled only by apps with hooks.\n// A spec with `dispose` commits through dispose.ts's tracking, registered separately (hooks.ts\n// `disposableCommit`) so apps whose hooks have no teardown don't bundle it (gyral-c5d.2).\nimport { DEV } from '#view-dev';\nimport { runner } from './hook-run.js';\nimport {\n disposableCommit,\n hookResult,\n hookSpec,\n queueHook,\n sameArgs,\n useHookRunner,\n type HookPart,\n type HookResult,\n type HookSpec,\n} from './hooks.js';\n\n/** Queues the client call when the hook or its arguments changed, or always (`update`). */\nexport function commitHook(part: HookPart, result: HookResult): void {\n const spec = hookSpec(result) as HookSpec<readonly unknown[]>;\n const args = result.args;\n const same = spec === part.spec;\n if (same && spec.update !== 'always' && sameArgs(args, part.args)) return;\n part.prev = same ? part.args : undefined;\n part.spec = spec;\n part.args = args;\n queueHook(part);\n}\n\n/** Defines an element hook: a small behaviour attached to the element it sits on. */\nexport function defineHook<A extends readonly unknown[]>(\n spec: HookSpec<A>,\n): (...args: A) => HookResult<A> {\n useHookRunner(runner);\n return (...args) =>\n hookResult(spec, args, spec.dispose === undefined ? commitHook : commitDisposable);\n}\n\nlet warned = false;\n\n/** A hook with `dispose`: tracked when disposal is registered, else committed plainly. */\nfunction commitDisposable(part: HookPart, result: HookResult): void {\n if (DEV && disposableCommit === undefined && !warned) {\n warned = true;\n console.warn(\n 'gyral: a hook declares dispose, but the build found no module naming it, so hook ' +\n 'disposal was left out and dispose never runs. Write the dispose key in your source ' +\n '(view/05-element.md \"Features register themselves\").',\n );\n }\n (disposableCommit ?? commitHook)(part, result);\n}\n"]}
|