@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,45 @@
|
|
|
1
|
+
// One <template> element per template object, created on first use (view/01-templates.md
|
|
2
|
+
// "Instantiation"). The browser's own parser builds it from the template HTML; the runtime
|
|
3
|
+
// preparer then checks the parse (rule 7). Server templates never get one (rule 11). An svg
|
|
4
|
+
// template's is prepared by `svgTemplate` when its first result is made (template.ts `svg`), so
|
|
5
|
+
// apps without svg templates don't carry that code. Both parse through the `gyral` Trusted Types
|
|
6
|
+
// policy (trusted-html.ts).
|
|
7
|
+
import { verify } from '#prepare';
|
|
8
|
+
import { DEV } from '#view-dev';
|
|
9
|
+
import { message } from './message.js';
|
|
10
|
+
import { SERVER_ONLY, TemplateError } from './normalize/errors.js';
|
|
11
|
+
import { trustedHTML } from './trusted-html.js';
|
|
12
|
+
const elements = new WeakMap();
|
|
13
|
+
/** The cached <template> element for `template`, parsed (and checked) on first use. */
|
|
14
|
+
export function templateElement(template) {
|
|
15
|
+
const cached = elements.get(template);
|
|
16
|
+
if (cached !== undefined)
|
|
17
|
+
return cached;
|
|
18
|
+
if (template.server) {
|
|
19
|
+
// Production keeps a short message: the class and its explanation stay out of the bundle.
|
|
20
|
+
throw DEV ? new TemplateError(11, SERVER_ONLY, template.loc) : new Error(message(71));
|
|
21
|
+
}
|
|
22
|
+
const el = document.createElement('template');
|
|
23
|
+
el.innerHTML = trustedHTML(template.html);
|
|
24
|
+
verify(template, el);
|
|
25
|
+
elements.set(template, el);
|
|
26
|
+
return el;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Prepares an svg template's <template> element (01 "svg templates"): its HTML is parsed inside
|
|
30
|
+
* an <svg>, so the parser creates SVG elements (camelCase names and attributes, namespaced
|
|
31
|
+
* static attributes), and that <svg>'s children become the content. Called with every svg
|
|
32
|
+
* result, before anything renders it; outside a document (the server) there is nothing to do.
|
|
33
|
+
*/
|
|
34
|
+
export function svgTemplate(template) {
|
|
35
|
+
if (elements.has(template) || typeof document === 'undefined')
|
|
36
|
+
return;
|
|
37
|
+
const el = document.createElement('template');
|
|
38
|
+
el.innerHTML = trustedHTML(`<svg>${template.html}</svg>`);
|
|
39
|
+
const content = el.content;
|
|
40
|
+
// Anything the parser moved out of the <svg> is dropped here, and the check reports it.
|
|
41
|
+
content.replaceChildren(...content.firstChild.childNodes);
|
|
42
|
+
verify(template, el);
|
|
43
|
+
elements.set(template, el);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=template-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-element.js","sourceRoot":"","sources":["../../src/view/template-element.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,2FAA2F;AAC3F,4FAA4F;AAC5F,gGAAgG;AAChG,iGAAiG;AACjG,4BAA4B;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAuC,CAAC;AAEpE,uFAAuF;AACvF,MAAM,UAAU,eAAe,CAAC,QAAwB;IACtD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,0FAA0F;QAC1F,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC9C,EAAE,CAAC,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACrB,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC3B,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,QAAwB;IAClD,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IACtE,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC9C,EAAE,CAAC,SAAS,GAAG,WAAW,CAAC,QAAQ,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IAC3B,wFAAwF;IACxF,OAAO,CAAC,eAAe,CAAC,GAAI,OAAO,CAAC,UAAsB,CAAC,UAAU,CAAC,CAAC;IACvE,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACrB,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["// One <template> element per template object, created on first use (view/01-templates.md\n// \"Instantiation\"). The browser's own parser builds it from the template HTML; the runtime\n// preparer then checks the parse (rule 7). Server templates never get one (rule 11). An svg\n// template's is prepared by `svgTemplate` when its first result is made (template.ts `svg`), so\n// apps without svg templates don't carry that code. Both parse through the `gyral` Trusted Types\n// policy (trusted-html.ts).\nimport { verify } from '#prepare';\nimport { DEV } from '#view-dev';\nimport { message } from './message.js';\nimport { SERVER_ONLY, TemplateError } from './normalize/errors.js';\nimport type { TemplateObject } from './normalize/types.js';\nimport { trustedHTML } from './trusted-html.js';\n\nconst elements = new WeakMap<TemplateObject, HTMLTemplateElement>();\n\n/** The cached <template> element for `template`, parsed (and checked) on first use. */\nexport function templateElement(template: TemplateObject): HTMLTemplateElement {\n const cached = elements.get(template);\n if (cached !== undefined) return cached;\n if (template.server) {\n // Production keeps a short message: the class and its explanation stay out of the bundle.\n throw DEV ? new TemplateError(11, SERVER_ONLY, template.loc) : new Error(message(71));\n }\n const el = document.createElement('template');\n el.innerHTML = trustedHTML(template.html);\n verify(template, el);\n elements.set(template, el);\n return el;\n}\n\n/**\n * Prepares an svg template's <template> element (01 \"svg templates\"): its HTML is parsed inside\n * an <svg>, so the parser creates SVG elements (camelCase names and attributes, namespaced\n * static attributes), and that <svg>'s children become the content. Called with every svg\n * result, before anything renders it; outside a document (the server) there is nothing to do.\n */\nexport function svgTemplate(template: TemplateObject): void {\n if (elements.has(template) || typeof document === 'undefined') return;\n const el = document.createElement('template');\n el.innerHTML = trustedHTML(`<svg>${template.html}</svg>`);\n const content = el.content;\n // Anything the parser moved out of the <svg> is dropped here, and the check reports it.\n content.replaceChildren(...(content.firstChild as Element).childNodes);\n verify(template, el);\n elements.set(template, el);\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TemplateObject } from './normalize/types.js';
|
|
2
|
+
declare const SOURCE: unique symbol;
|
|
3
|
+
/** What `html` returns: a template plus this render's values. */
|
|
4
|
+
export interface TemplateResult {
|
|
5
|
+
readonly [SOURCE]: readonly string[] | TemplateObject;
|
|
6
|
+
readonly values: readonly unknown[];
|
|
7
|
+
}
|
|
8
|
+
/** The template tag: `` html`<p>${s.text}</p>` ``. */
|
|
9
|
+
export declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult;
|
|
10
|
+
/**
|
|
11
|
+
* The SVG fragment tag: `` svg`<path d=${s.d} />` ``. Its top level is SVG content, so it
|
|
12
|
+
* renders only inside an `<svg>` (or another SVG element) of an html template
|
|
13
|
+
* (view/01-templates.md "svg templates"). A whole `<svg>` graphic is written with html.
|
|
14
|
+
*/
|
|
15
|
+
export declare const svg: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult;
|
|
16
|
+
/** Internal: what the template compiler (`@gyral/core/vite`) rewrites `html` calls into. */
|
|
17
|
+
export declare function compiled(template: TemplateObject, values: readonly unknown[]): TemplateResult;
|
|
18
|
+
/** Internal: what the template compiler rewrites `svg` calls into. */
|
|
19
|
+
export declare function compiledSvg(template: TemplateObject, values: readonly unknown[]): TemplateResult;
|
|
20
|
+
export declare function isTemplateResult(value: unknown): value is TemplateResult;
|
|
21
|
+
/** Internal: a result's source, compared by identity to skip `templateOf` on updates. */
|
|
22
|
+
export declare const sourceOf: (result: TemplateResult) => readonly string[] | TemplateObject;
|
|
23
|
+
/**
|
|
24
|
+
* The template object of a result: compiled results carry it; a runtime result's call site is
|
|
25
|
+
* normalized once by `#prepare` (cached there, so compiled builds carry neither the preparer
|
|
26
|
+
* nor its cache).
|
|
27
|
+
*/
|
|
28
|
+
export declare function templateOf(result: TemplateResult): TemplateObject;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Template results and the `html` and `svg` tags (view/01-templates.md "Authoring", "Template
|
|
2
|
+
// results", "svg templates"). A result is a template source (the call site's strings, or a
|
|
3
|
+
// template object) plus this call's values, recognised by a module-private symbol so data from
|
|
4
|
+
// JSON can never pass for one. `templateOf` turns the source into the template object: compiled
|
|
5
|
+
// and svg results carry it, html results are normalized once per strings array through
|
|
6
|
+
// `#prepare` (prepare.ts). Development records each call site's source location (loc.ts) for
|
|
7
|
+
// error messages.
|
|
8
|
+
import { prepare } from '#prepare';
|
|
9
|
+
import { DEV } from '#view-dev';
|
|
10
|
+
import { callSite, locOf, setLoc } from './loc.js';
|
|
11
|
+
import { svgTemplate } from './template-element.js';
|
|
12
|
+
const SOURCE = Symbol('gyral.template');
|
|
13
|
+
/** The template tag, as `html` is in production. */
|
|
14
|
+
function tag(strings, ...values) {
|
|
15
|
+
// Development: the call site, from the stack, the first time (unless `html.at` gave it).
|
|
16
|
+
if (DEV && locOf(strings) === undefined)
|
|
17
|
+
setLoc(strings, callSite(new Error().stack));
|
|
18
|
+
return { [SOURCE]: strings, values };
|
|
19
|
+
}
|
|
20
|
+
/** The svg tag, as `svg` is in production: svg results carry their (prepared) template. */
|
|
21
|
+
function svgTag(strings, ...values) {
|
|
22
|
+
// Development: the call site, from the stack, the first time (unless `svg.at` gave it), so
|
|
23
|
+
// the normalizer's rule errors name it.
|
|
24
|
+
if (DEV && locOf(strings) === undefined)
|
|
25
|
+
setLoc(strings, callSite(new Error().stack));
|
|
26
|
+
return compiledSvg(prepare(strings, true), values);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Development: `html.at(loc)` (and `svg.at(loc)`) is the tag with a known call site. The Vite
|
|
30
|
+
* preset's dev transform (compiler/locate.ts) writes it at every call site, since stack
|
|
31
|
+
* positions in transformed modules aren't the author's lines. Attached here, not by a statement
|
|
32
|
+
* that mentions the tag, so production builds don't keep it alive (the compiler checks that).
|
|
33
|
+
*/
|
|
34
|
+
function withAt(html) {
|
|
35
|
+
const tags = new Map();
|
|
36
|
+
const at = (loc) => {
|
|
37
|
+
let located = tags.get(loc);
|
|
38
|
+
if (located === undefined) {
|
|
39
|
+
located = (strings, ...values) => {
|
|
40
|
+
setLoc(strings, loc);
|
|
41
|
+
return html(strings, ...values);
|
|
42
|
+
};
|
|
43
|
+
tags.set(loc, located);
|
|
44
|
+
}
|
|
45
|
+
return located;
|
|
46
|
+
};
|
|
47
|
+
return Object.assign(html, { at });
|
|
48
|
+
}
|
|
49
|
+
/** The template tag: `` html`<p>${s.text}</p>` ``. */
|
|
50
|
+
export const html = DEV
|
|
51
|
+
? withAt(tag)
|
|
52
|
+
: tag;
|
|
53
|
+
/**
|
|
54
|
+
* The SVG fragment tag: `` svg`<path d=${s.d} />` ``. Its top level is SVG content, so it
|
|
55
|
+
* renders only inside an `<svg>` (or another SVG element) of an html template
|
|
56
|
+
* (view/01-templates.md "svg templates"). A whole `<svg>` graphic is written with html.
|
|
57
|
+
*/
|
|
58
|
+
export const svg = DEV
|
|
59
|
+
? withAt(svgTag)
|
|
60
|
+
: svgTag;
|
|
61
|
+
/** Internal: what the template compiler (`@gyral/core/vite`) rewrites `html` calls into. */
|
|
62
|
+
export function compiled(template, values) {
|
|
63
|
+
return { [SOURCE]: template, values };
|
|
64
|
+
}
|
|
65
|
+
/** Internal: what the template compiler rewrites `svg` calls into. */
|
|
66
|
+
export function compiledSvg(template, values) {
|
|
67
|
+
svgTemplate(template);
|
|
68
|
+
return { [SOURCE]: template, values };
|
|
69
|
+
}
|
|
70
|
+
export function isTemplateResult(value) {
|
|
71
|
+
return typeof value === 'object' && value !== null && SOURCE in value;
|
|
72
|
+
}
|
|
73
|
+
/** Internal: a result's source, compared by identity to skip `templateOf` on updates. */
|
|
74
|
+
export const sourceOf = (result) => result[SOURCE];
|
|
75
|
+
/**
|
|
76
|
+
* The template object of a result: compiled results carry it; a runtime result's call site is
|
|
77
|
+
* normalized once by `#prepare` (cached there, so compiled builds carry neither the preparer
|
|
78
|
+
* nor its cache).
|
|
79
|
+
*/
|
|
80
|
+
export function templateOf(result) {
|
|
81
|
+
const source = result[SOURCE];
|
|
82
|
+
return Array.isArray(source) ? prepare(source) : source;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/view/template.ts"],"names":[],"mappings":"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","sourcesContent":["// Template results and the `html` and `svg` tags (view/01-templates.md \"Authoring\", \"Template\n// results\", \"svg templates\"). A result is a template source (the call site's strings, or a\n// template object) plus this call's values, recognised by a module-private symbol so data from\n// JSON can never pass for one. `templateOf` turns the source into the template object: compiled\n// and svg results carry it, html results are normalized once per strings array through\n// `#prepare` (prepare.ts). Development records each call site's source location (loc.ts) for\n// error messages.\nimport { prepare } from '#prepare';\nimport { DEV } from '#view-dev';\nimport { callSite, locOf, setLoc } from './loc.js';\nimport type { TemplateObject } from './normalize/types.js';\nimport { svgTemplate } from './template-element.js';\n\nconst SOURCE: unique symbol = Symbol('gyral.template');\n\n/** What `html` returns: a template plus this render's values. */\nexport interface TemplateResult {\n readonly [SOURCE]: readonly string[] | TemplateObject;\n readonly values: readonly unknown[];\n}\n\n/** The template tag, as `html` is in production. */\nfunction tag(strings: TemplateStringsArray, ...values: unknown[]): TemplateResult {\n // Development: the call site, from the stack, the first time (unless `html.at` gave it).\n if (DEV && locOf(strings) === undefined) setLoc(strings, callSite(new Error().stack));\n return { [SOURCE]: strings, values };\n}\n\n/** The svg tag, as `svg` is in production: svg results carry their (prepared) template. */\nfunction svgTag(strings: TemplateStringsArray, ...values: unknown[]): TemplateResult {\n // Development: the call site, from the stack, the first time (unless `svg.at` gave it), so\n // the normalizer's rule errors name it.\n if (DEV && locOf(strings) === undefined) setLoc(strings, callSite(new Error().stack));\n return compiledSvg(prepare(strings, true), values);\n}\n\ntype Tag = typeof tag;\n\n/**\n * Development: `html.at(loc)` (and `svg.at(loc)`) is the tag with a known call site. The Vite\n * preset's dev transform (compiler/locate.ts) writes it at every call site, since stack\n * positions in transformed modules aren't the author's lines. Attached here, not by a statement\n * that mentions the tag, so production builds don't keep it alive (the compiler checks that).\n */\nfunction withAt(html: Tag): Tag {\n const tags = new Map<string, Tag>();\n const at = (loc: string): Tag => {\n let located = tags.get(loc);\n if (located === undefined) {\n located = (strings, ...values) => {\n setLoc(strings, loc);\n return html(strings, ...values);\n };\n tags.set(loc, located);\n }\n return located;\n };\n return Object.assign(html, { at });\n}\n\n/** The template tag: `` html`<p>${s.text}</p>` ``. */\nexport const html: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult = DEV\n ? withAt(tag)\n : tag;\n\n/**\n * The SVG fragment tag: `` svg`<path d=${s.d} />` ``. Its top level is SVG content, so it\n * renders only inside an `<svg>` (or another SVG element) of an html template\n * (view/01-templates.md \"svg templates\"). A whole `<svg>` graphic is written with html.\n */\nexport const svg: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult = DEV\n ? withAt(svgTag)\n : svgTag;\n\n/** Internal: what the template compiler (`@gyral/core/vite`) rewrites `html` calls into. */\nexport function compiled(template: TemplateObject, values: readonly unknown[]): TemplateResult {\n return { [SOURCE]: template, values };\n}\n\n/** Internal: what the template compiler rewrites `svg` calls into. */\nexport function compiledSvg(template: TemplateObject, values: readonly unknown[]): TemplateResult {\n svgTemplate(template);\n return { [SOURCE]: template, values };\n}\n\nexport function isTemplateResult(value: unknown): value is TemplateResult {\n return typeof value === 'object' && value !== null && SOURCE in value;\n}\n\n/** Internal: a result's source, compared by identity to skip `templateOf` on updates. */\nexport const sourceOf = (result: TemplateResult): readonly string[] | TemplateObject =>\n result[SOURCE];\n\n/**\n * The template object of a result: compiled results carry it; a runtime result's call site is\n * normalized once by `#prepare` (cached there, so compiled builds carry neither the preparer\n * nor its cache).\n */\nexport function templateOf(result: TemplateResult): TemplateObject {\n const source = result[SOURCE];\n return Array.isArray(source) ? prepare(source) : (source as TemplateObject);\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `html` as an HTML sink accepts it: a `TrustedHTML` from the `gyral` policy where the browser
|
|
3
|
+
* has Trusted Types, the string itself elsewhere. Typed as `string` because lib.dom's
|
|
4
|
+
* `innerHTML` setter takes only strings; the browser stringifies a `TrustedHTML` to the same text.
|
|
5
|
+
*/
|
|
6
|
+
export declare function trustedHTML(html: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Trusted Types (view/01-templates.md "Instantiation", gyral-ei9): a document whose CSP says
|
|
2
|
+
// `require-trusted-types-for 'script'` refuses plain strings at HTML sinks such as `innerHTML`.
|
|
3
|
+
// The browser parses only two kinds of HTML for Gyral: a template's HTML, which is the author's
|
|
4
|
+
// own template strings (holes are markers, never values), and `raw()` markup, trusted by
|
|
5
|
+
// contract (view/02 "raw(html)"). Both go through one policy named `gyral`, created on first use
|
|
6
|
+
// where the browser has Trusted Types; an app allows it with `trusted-types gyral`. On first use
|
|
7
|
+
// rather than at import, so a policy that refuses the name fails where HTML is parsed, not when
|
|
8
|
+
// a module loads. A CSP whose `trusted-types` list leaves `gyral` out (with or without
|
|
9
|
+
// enforcement) makes `createPolicy` throw: Gyral then parses plain strings, as before Trusted
|
|
10
|
+
// Types, and warns in development; where Trusted Types are enforced the sink reports it.
|
|
11
|
+
import { DEV } from '#view-dev';
|
|
12
|
+
import { message } from './message.js';
|
|
13
|
+
const passThrough = { createHTML: (input) => input };
|
|
14
|
+
let policy;
|
|
15
|
+
/**
|
|
16
|
+
* `html` as an HTML sink accepts it: a `TrustedHTML` from the `gyral` policy where the browser
|
|
17
|
+
* has Trusted Types, the string itself elsewhere. Typed as `string` because lib.dom's
|
|
18
|
+
* `innerHTML` setter takes only strings; the browser stringifies a `TrustedHTML` to the same text.
|
|
19
|
+
*/
|
|
20
|
+
export function trustedHTML(html) {
|
|
21
|
+
policy ??= create();
|
|
22
|
+
return policy.createHTML(html);
|
|
23
|
+
}
|
|
24
|
+
function create() {
|
|
25
|
+
try {
|
|
26
|
+
return (globalThis.trustedTypes?.createPolicy('gyral', passThrough) ?? passThrough);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (DEV)
|
|
30
|
+
console.warn(message(72), error);
|
|
31
|
+
return passThrough;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=trusted-html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trusted-html.js","sourceRoot":"","sources":["../../src/view/trusted-html.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,gGAAgG;AAChG,gGAAgG;AAChG,yFAAyF;AACzF,iGAAiG;AACjG,iGAAiG;AACjG,gGAAgG;AAChG,uFAAuF;AACvF,8FAA8F;AAC9F,yFAAyF;AACzF,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAUvC,MAAM,WAAW,GAAW,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC;AAE7D,IAAI,MAA0B,CAAC;AAE/B;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,KAAK,MAAM,EAAE,CAAC;IACpB,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,MAAM;IACb,IAAI,CAAC;QACH,OAAO,CACJ,UAA+C,CAAC,YAAY,EAAE,YAAY,CACzE,OAAO,EACP,WAAW,CACZ,IAAI,WAAW,CACjB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,GAAG;YAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAC1C,OAAO,WAAW,CAAC;IACrB,CAAC;AACH,CAAC","sourcesContent":["// Trusted Types (view/01-templates.md \"Instantiation\", gyral-ei9): a document whose CSP says\n// `require-trusted-types-for 'script'` refuses plain strings at HTML sinks such as `innerHTML`.\n// The browser parses only two kinds of HTML for Gyral: a template's HTML, which is the author's\n// own template strings (holes are markers, never values), and `raw()` markup, trusted by\n// contract (view/02 \"raw(html)\"). Both go through one policy named `gyral`, created on first use\n// where the browser has Trusted Types; an app allows it with `trusted-types gyral`. On first use\n// rather than at import, so a policy that refuses the name fails where HTML is parsed, not when\n// a module loads. A CSP whose `trusted-types` list leaves `gyral` out (with or without\n// enforcement) makes `createPolicy` throw: Gyral then parses plain strings, as before Trusted\n// Types, and warns in development; where Trusted Types are enforced the sink reports it.\nimport { DEV } from '#view-dev';\nimport { message } from './message.js';\n\ninterface Policy {\n createHTML(input: string): string;\n}\n\ninterface PolicyFactory {\n createPolicy(name: string, rules: Policy): Policy;\n}\n\nconst passThrough: Policy = { createHTML: (input) => input };\n\nlet policy: Policy | undefined;\n\n/**\n * `html` as an HTML sink accepts it: a `TrustedHTML` from the `gyral` policy where the browser\n * has Trusted Types, the string itself elsewhere. Typed as `string` because lib.dom's\n * `innerHTML` setter takes only strings; the browser stringifies a `TrustedHTML` to the same text.\n */\nexport function trustedHTML(html: string): string {\n policy ??= create();\n return policy.createHTML(html);\n}\n\nfunction create(): Policy {\n try {\n return (\n (globalThis as { trustedTypes?: PolicyFactory }).trustedTypes?.createPolicy(\n 'gyral',\n passThrough,\n ) ?? passThrough\n );\n } catch (error) {\n if (DEV) console.warn(message(72), error);\n return passThrough;\n }\n}\n"]}
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,18 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
export interface TemplateCompilerOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Module specifiers whose `html` (and `svg`) exports are the view layer's tags (default
|
|
5
|
+
* `DEFAULT_TEMPLATE_SOURCES`). An import matches when its specifier is listed, or when it
|
|
6
|
+
* resolves to the same module as a listed one; core's own view modules always match. A
|
|
7
|
+
* source other than '@gyral/core' must also export `compiled` (and `compiledSvg` when it
|
|
8
|
+
* exports `svg`).
|
|
9
|
+
*/
|
|
10
|
+
readonly sources?: readonly string[];
|
|
11
|
+
/**
|
|
12
|
+
* Rule 7's extra check with parse5 (an optional peer dependency): `true` (default) uses
|
|
13
|
+
* 'parse5' when it is installed, a string names the module to load, `false` skips it.
|
|
14
|
+
*/
|
|
15
|
+
readonly parse5?: boolean | string;
|
|
16
|
+
}
|
|
17
|
+
/** Where the preset looks for components and writes their typings (gyral-1zd.25). */
|
|
18
|
+
export interface ElementTypesOptions {
|
|
19
|
+
/** Source directories to scan, relative to the Vite root. Default `['src']`. */
|
|
20
|
+
readonly dirs?: readonly string[];
|
|
21
|
+
/** The declaration file to write, relative to the Vite root. Default `.gyral/elements.d.ts`. */
|
|
22
|
+
readonly out?: string;
|
|
23
|
+
}
|
|
8
24
|
export interface GyralViteOptions {
|
|
9
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Generated element typings (`.gyral/elements.d.ts`, see `ElementTypesOptions`), or `false`
|
|
27
|
+
* to write none. Default: on, scanning `src`.
|
|
28
|
+
*/
|
|
29
|
+
readonly types?: ElementTypesOptions | false;
|
|
30
|
+
/** Modules to pre-bundle in dev, so Vite doesn't discover them mid-run and reload. */
|
|
10
31
|
readonly optimize?: readonly string[];
|
|
32
|
+
/** Template compiler options (`vite build` only). */
|
|
33
|
+
readonly compiler?: TemplateCompilerOptions;
|
|
34
|
+
/**
|
|
35
|
+
* The app is never server-rendered: leave the hydration code out of the browser bundle
|
|
36
|
+
* (`gyralClientOnly()`, view/07-hydration.md "Client-only builds"). Default false.
|
|
37
|
+
*/
|
|
38
|
+
readonly clientOnly?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Automatic component loading (ADR 0016 addendum): every component defined under `include`
|
|
41
|
+
* gets a client module the build splits out, and a loader (`virtual:gyral/components`, added
|
|
42
|
+
* to the client build's input) imports a tag's module once that tag is in the page.
|
|
43
|
+
* `renderPage({ components })` then links exactly the components a page rendered, so pages
|
|
44
|
+
* need no client entry of their own and no side-effect imports. Default off.
|
|
45
|
+
*/
|
|
46
|
+
readonly components?: boolean | ComponentsOptions;
|
|
47
|
+
}
|
|
48
|
+
export interface ComponentsOptions {
|
|
49
|
+
/** Directories (relative to Vite's root) whose modules' `define()` tags are found. Default `['src']`. */
|
|
50
|
+
readonly include?: readonly string[];
|
|
51
|
+
/**
|
|
52
|
+
* Tag → module (relative to Vite's root) for components the scan can't find: those defined
|
|
53
|
+
* through a wrapper such as `defineMemberForm({ tag: 'member-form' })`, which calls
|
|
54
|
+
* `define()` itself. Listed entries win over scanned ones.
|
|
55
|
+
*/
|
|
56
|
+
readonly modules?: Readonly<Record<string, string>>;
|
|
11
57
|
}
|
|
12
58
|
export interface GyralViteConfig {
|
|
13
|
-
readonly
|
|
14
|
-
readonly dedupe: string[];
|
|
15
|
-
};
|
|
59
|
+
readonly plugins: Plugin[];
|
|
16
60
|
readonly optimizeDeps: {
|
|
17
61
|
readonly include: string[];
|
|
18
62
|
};
|
|
@@ -21,5 +65,7 @@ export interface GyralViteConfig {
|
|
|
21
65
|
* Spread into a Vite config, or into each Vitest project:
|
|
22
66
|
*
|
|
23
67
|
* export default defineConfig({ ...gyralVitePreset(), build: { … } });
|
|
68
|
+
*
|
|
69
|
+
* With plugins of your own, list both: `plugins: [...preset.plugins, mine()]`.
|
|
24
70
|
*/
|
|
25
71
|
export declare function gyralVitePreset(options?: GyralViteOptions): GyralViteConfig;
|