@gyral/core 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -0
- package/LICENSE +1 -1
- package/NOTICE +1 -1
- package/README.md +9 -7
- package/dist/children.d.ts +5 -2
- package/dist/children.js +8 -3
- package/dist/children.js.map +1 -1
- package/dist/command.js +6 -0
- package/dist/command.js.map +1 -1
- package/dist/compiler/ast.d.ts +21 -0
- package/dist/compiler/ast.js +145 -0
- package/dist/compiler/ast.js.map +1 -0
- package/dist/compiler/compile.d.ts +38 -0
- package/dist/compiler/compile.js +129 -0
- package/dist/compiler/compile.js.map +1 -0
- package/dist/compiler/hooks.d.ts +18 -0
- package/dist/compiler/hooks.js +186 -0
- package/dist/compiler/hooks.js.map +1 -0
- package/dist/compiler/parse5-check.d.ts +21 -0
- package/dist/compiler/parse5-check.js +55 -0
- package/dist/compiler/parse5-check.js.map +1 -0
- package/dist/compiler/scan.d.ts +31 -0
- package/dist/compiler/scan.js +152 -0
- package/dist/compiler/scan.js.map +1 -0
- package/dist/compiler/source.d.ts +34 -0
- package/dist/compiler/source.js +114 -0
- package/dist/compiler/source.js.map +1 -0
- package/dist/define.d.ts +2 -2
- package/dist/define.js +35 -334
- package/dist/define.js.map +1 -1
- package/dist/devtools-events.d.ts +5 -0
- package/dist/devtools-events.js.map +1 -1
- package/dist/devtools-off.d.ts +1 -0
- package/dist/devtools-off.js +1 -0
- package/dist/devtools-off.js.map +1 -1
- package/dist/devtools.d.ts +1 -0
- package/dist/devtools.js +3 -0
- package/dist/devtools.js.map +1 -1
- package/dist/drivers-scope.d.ts +1 -1
- package/dist/drivers-scope.js +1 -8
- package/dist/drivers-scope.js.map +1 -1
- package/dist/element-types.d.ts +5 -3
- package/dist/element-types.js.map +1 -1
- package/dist/element.d.ts +3 -0
- package/dist/element.js +269 -0
- package/dist/element.js.map +1 -0
- package/dist/eslint/imports.d.ts +24 -0
- package/dist/eslint/imports.js +78 -0
- package/dist/eslint/imports.js.map +1 -0
- package/dist/eslint/index.d.ts +15 -0
- package/dist/eslint/index.js +15 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/eslint/locate.d.ts +33 -0
- package/dist/eslint/locate.js +132 -0
- package/dist/eslint/locate.js.map +1 -0
- package/dist/eslint/row-purity-rule.d.ts +2 -0
- package/dist/eslint/row-purity-rule.js +103 -0
- package/dist/eslint/row-purity-rule.js.map +1 -0
- package/dist/eslint/template-rule.d.ts +5 -0
- package/dist/eslint/template-rule.js +66 -0
- package/dist/eslint/template-rule.js.map +1 -0
- package/dist/features.d.ts +39 -0
- package/dist/features.js +2 -0
- package/dist/features.js.map +1 -0
- package/dist/focus.d.ts +9 -2
- package/dist/focus.js +17 -2
- package/dist/focus.js.map +1 -1
- package/dist/hooks/invalid.d.ts +14 -0
- package/dist/hooks/invalid.js +72 -0
- package/dist/hooks/invalid.js.map +1 -0
- package/dist/hooks/labelled-by.d.ts +13 -0
- package/dist/hooks/labelled-by.js +51 -0
- package/dist/hooks/labelled-by.js.map +1 -0
- package/dist/host-model.d.ts +48 -0
- package/dist/host-model.js +155 -0
- package/dist/host-model.js.map +1 -0
- package/dist/hydration-client.d.ts +9 -0
- package/dist/hydration-client.js +35 -0
- package/dist/hydration-client.js.map +1 -0
- package/dist/hydration.d.ts +13 -19
- package/dist/hydration.js +45 -45
- package/dist/hydration.js.map +1 -1
- package/dist/index.d.ts +9 -16
- package/dist/index.js +9 -16
- package/dist/index.js.map +1 -1
- package/dist/intent.d.ts +31 -8
- package/dist/intent.js +82 -27
- package/dist/intent.js.map +1 -1
- package/dist/internal/interpreter.d.ts +7 -1
- package/dist/internal/interpreter.js +118 -73
- package/dist/internal/interpreter.js.map +1 -1
- package/dist/invokers-shim.d.ts +6 -0
- package/dist/invokers-shim.js +32 -0
- package/dist/invokers-shim.js.map +1 -0
- package/dist/invokers.d.ts +3 -5
- package/dist/invokers.js +11 -51
- package/dist/invokers.js.map +1 -1
- package/dist/islands.d.ts +0 -2
- package/dist/islands.js +4 -11
- package/dist/islands.js.map +1 -1
- package/dist/light-dom.d.ts +3 -52
- package/dist/light-dom.js +5 -100
- package/dist/light-dom.js.map +1 -1
- package/dist/prop.d.ts +66 -0
- package/dist/prop.js +22 -0
- package/dist/prop.js.map +1 -0
- package/dist/props.d.ts +52 -21
- package/dist/props.js +150 -34
- package/dist/props.js.map +1 -1
- package/dist/scheduler.d.ts +39 -0
- package/dist/scheduler.js +230 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/server-component.d.ts +10 -0
- package/dist/server-component.js +102 -0
- package/dist/server-component.js.map +1 -0
- package/dist/server-specs.d.ts +6 -0
- package/dist/server-specs.js +13 -0
- package/dist/server-specs.js.map +1 -0
- package/dist/server.d.ts +28 -0
- package/dist/server.js +50 -0
- package/dist/server.js.map +1 -0
- package/dist/settled.d.ts +10 -0
- package/dist/settled.js +40 -0
- package/dist/settled.js.map +1 -0
- package/dist/states.d.ts +3 -3
- package/dist/states.js +4 -7
- package/dist/states.js.map +1 -1
- package/dist/store-binding.d.ts +6 -3
- package/dist/store-binding.js +5 -6
- package/dist/store-binding.js.map +1 -1
- package/dist/store-scope.d.ts +6 -7
- package/dist/store-scope.js +11 -26
- package/dist/store-scope.js.map +1 -1
- package/dist/store.d.ts +3 -0
- package/dist/store.js +9 -2
- package/dist/store.js.map +1 -1
- package/dist/stores-provider.d.ts +2 -6
- package/dist/stores-provider.js +21 -55
- package/dist/stores-provider.js.map +1 -1
- package/dist/transitions.d.ts +5 -6
- package/dist/transitions.js +11 -20
- package/dist/transitions.js.map +1 -1
- package/dist/types.d.ts +19 -23
- package/dist/types.js.map +1 -1
- package/dist/view/attributes.d.ts +6 -0
- package/dist/view/attributes.js +10 -0
- package/dist/view/attributes.js.map +1 -0
- package/dist/view/compiled.d.ts +1 -0
- package/dist/view/compiled.js +6 -0
- package/dist/view/compiled.js.map +1 -0
- package/dist/view/dev-off.d.ts +1 -0
- package/dist/view/dev-off.js +4 -0
- package/dist/view/dev-off.js.map +1 -0
- package/dist/view/dev.d.ts +1 -0
- package/dist/view/dev.js +5 -0
- package/dist/view/dev.js.map +1 -0
- package/dist/view/flags.d.ts +1 -0
- package/dist/view/flags.js +4 -0
- package/dist/view/flags.js.map +1 -0
- package/dist/view/index.d.ts +21 -0
- package/dist/view/index.js +21 -0
- package/dist/view/index.js.map +1 -0
- package/dist/view/normalize/check.d.ts +20 -0
- package/dist/view/normalize/check.js +78 -0
- package/dist/view/normalize/check.js.map +1 -0
- package/dist/view/normalize/emit.d.ts +13 -0
- package/dist/view/normalize/emit.js +136 -0
- package/dist/view/normalize/emit.js.map +1 -0
- package/dist/view/normalize/entities.d.ts +4 -0
- package/dist/view/normalize/entities.js +38 -0
- package/dist/view/normalize/entities.js.map +1 -0
- package/dist/view/normalize/errors.d.ts +9 -0
- package/dist/view/normalize/errors.js +19 -0
- package/dist/view/normalize/errors.js.map +1 -0
- package/dist/view/normalize/id.d.ts +7 -0
- package/dist/view/normalize/id.js +48 -0
- package/dist/view/normalize/id.js.map +1 -0
- package/dist/view/normalize/normalize.d.ts +15 -0
- package/dist/view/normalize/normalize.js +36 -0
- package/dist/view/normalize/normalize.js.map +1 -0
- package/dist/view/normalize/repairs.d.ts +24 -0
- package/dist/view/normalize/repairs.js +166 -0
- package/dist/view/normalize/repairs.js.map +1 -0
- package/dist/view/normalize/rules.d.ts +30 -0
- package/dist/view/normalize/rules.js +90 -0
- package/dist/view/normalize/rules.js.map +1 -0
- package/dist/view/normalize/shape.d.ts +5 -0
- package/dist/view/normalize/shape.js +38 -0
- package/dist/view/normalize/shape.js.map +1 -0
- package/dist/view/normalize/source.d.ts +13 -0
- package/dist/view/normalize/source.js +34 -0
- package/dist/view/normalize/source.js.map +1 -0
- package/dist/view/normalize/tag-states.d.ts +23 -0
- package/dist/view/normalize/tag-states.js +192 -0
- package/dist/view/normalize/tag-states.js.map +1 -0
- package/dist/view/normalize/tokenizer.d.ts +5 -0
- package/dist/view/normalize/tokenizer.js +233 -0
- package/dist/view/normalize/tokenizer.js.map +1 -0
- package/dist/view/normalize/tokens.d.ts +51 -0
- package/dist/view/normalize/tokens.js +24 -0
- package/dist/view/normalize/tokens.js.map +1 -0
- package/dist/view/normalize/tree.d.ts +59 -0
- package/dist/view/normalize/tree.js +190 -0
- package/dist/view/normalize/tree.js.map +1 -0
- package/dist/view/normalize/types.d.ts +126 -0
- package/dist/view/normalize/types.js +26 -0
- package/dist/view/normalize/types.js.map +1 -0
- package/dist/view/normalize/whitespace.d.ts +2 -0
- package/dist/view/normalize/whitespace.js +182 -0
- package/dist/view/normalize/whitespace.js.map +1 -0
- package/dist/view/prepare-stub.d.ts +3 -0
- package/dist/view/prepare-stub.js +7 -0
- package/dist/view/prepare-stub.js.map +1 -0
- package/dist/view/prepare.d.ts +8 -0
- package/dist/view/prepare.js +57 -0
- package/dist/view/prepare.js.map +1 -0
- package/dist/view/registry.d.ts +63 -0
- package/dist/view/registry.js +19 -0
- package/dist/view/registry.js.map +1 -0
- package/dist/view/render/adopt-attr.d.ts +14 -0
- package/dist/view/render/adopt-attr.js +77 -0
- package/dist/view/render/adopt-attr.js.map +1 -0
- package/dist/view/render/adopt-plan.d.ts +10 -0
- package/dist/view/render/adopt-plan.js +26 -0
- package/dist/view/render/adopt-plan.js.map +1 -0
- package/dist/view/render/adopt.d.ts +3 -0
- package/dist/view/render/adopt.js +269 -0
- package/dist/view/render/adopt.js.map +1 -0
- package/dist/view/render/attr-parts.d.ts +61 -0
- package/dist/view/render/attr-parts.js +229 -0
- package/dist/view/render/attr-parts.js.map +1 -0
- package/dist/view/render/child-part.d.ts +51 -0
- package/dist/view/render/child-part.js +170 -0
- package/dist/view/render/child-part.js.map +1 -0
- package/dist/view/render/dev-check.d.ts +12 -0
- package/dist/view/render/dev-check.js +122 -0
- package/dist/view/render/dev-check.js.map +1 -0
- package/dist/view/render/hook-part.d.ts +3 -0
- package/dist/view/render/hook-part.js +20 -0
- package/dist/view/render/hook-part.js.map +1 -0
- package/dist/view/render/hooks.d.ts +40 -0
- package/dist/view/render/hooks.js +46 -0
- package/dist/view/render/hooks.js.map +1 -0
- package/dist/view/render/hydrate.d.ts +10 -0
- package/dist/view/render/hydrate.js +33 -0
- package/dist/view/render/hydrate.js.map +1 -0
- package/dist/view/render/instance.d.ts +33 -0
- package/dist/view/render/instance.js +107 -0
- package/dist/view/render/instance.js.map +1 -0
- package/dist/view/render/list.d.ts +20 -0
- package/dist/view/render/list.js +156 -0
- package/dist/view/render/list.js.map +1 -0
- package/dist/view/render/mismatch.d.ts +10 -0
- package/dist/view/render/mismatch.js +53 -0
- package/dist/view/render/mismatch.js.map +1 -0
- package/dist/view/render/nodes.d.ts +10 -0
- package/dist/view/render/nodes.js +37 -0
- package/dist/view/render/nodes.js.map +1 -0
- package/dist/view/render/place.d.ts +18 -0
- package/dist/view/render/place.js +69 -0
- package/dist/view/render/place.js.map +1 -0
- package/dist/view/render/plan.d.ts +26 -0
- package/dist/view/render/plan.js +124 -0
- package/dist/view/render/plan.js.map +1 -0
- package/dist/view/render/raw.d.ts +18 -0
- package/dist/view/render/raw.js +68 -0
- package/dist/view/render/raw.js.map +1 -0
- package/dist/view/render/render.d.ts +12 -0
- package/dist/view/render/render.js +60 -0
- package/dist/view/render/render.js.map +1 -0
- package/dist/view/render/reorder.d.ts +4 -0
- package/dist/view/render/reorder.js +101 -0
- package/dist/view/render/reorder.js.map +1 -0
- package/dist/view/render/rows.d.ts +23 -0
- package/dist/view/render/rows.js +95 -0
- package/dist/view/render/rows.js.map +1 -0
- package/dist/view/render/seen.d.ts +11 -0
- package/dist/view/render/seen.js +17 -0
- package/dist/view/render/seen.js.map +1 -0
- package/dist/view/render/values.d.ts +29 -0
- package/dist/view/render/values.js +13 -0
- package/dist/view/render/values.js.map +1 -0
- package/dist/view/render/warn.d.ts +14 -0
- package/dist/view/render/warn.js +69 -0
- package/dist/view/render/warn.js.map +1 -0
- package/dist/view/server/component.d.ts +9 -0
- package/dist/view/server/component.js +42 -0
- package/dist/view/server/component.js.map +1 -0
- package/dist/view/server/escape.d.ts +10 -0
- package/dist/view/server/escape.js +34 -0
- package/dist/view/server/escape.js.map +1 -0
- package/dist/view/server/index.d.ts +28 -0
- package/dist/view/server/index.js +72 -0
- package/dist/view/server/index.js.map +1 -0
- package/dist/view/server/sha256.d.ts +2 -0
- package/dist/view/server/sha256.js +75 -0
- package/dist/view/server/sha256.js.map +1 -0
- package/dist/view/server/tags.d.ts +57 -0
- package/dist/view/server/tags.js +121 -0
- package/dist/view/server/tags.js.map +1 -0
- package/dist/view/server/values.d.ts +16 -0
- package/dist/view/server/values.js +86 -0
- package/dist/view/server/values.js.map +1 -0
- package/dist/view/server/writer.d.ts +16 -0
- package/dist/view/server/writer.js +155 -0
- package/dist/view/server/writer.js.map +1 -0
- package/dist/view/styles.d.ts +25 -0
- package/dist/view/styles.js +58 -0
- package/dist/view/styles.js.map +1 -0
- package/dist/view/template-element.d.ts +3 -0
- package/dist/view/template-element.js +25 -0
- package/dist/view/template-element.js.map +1 -0
- package/dist/view/template.d.ts +21 -0
- package/dist/view/template.js +30 -0
- package/dist/view/template.js.map +1 -0
- package/dist/vite.d.ts +45 -6
- package/dist/vite.js +150 -25
- package/dist/vite.js.map +1 -1
- package/package.json +41 -7
- package/dist/accessible-name.d.ts +0 -19
- package/dist/accessible-name.js +0 -56
- package/dist/accessible-name.js.map +0 -1
- package/dist/element-directive.d.ts +0 -20
- package/dist/element-directive.js +0 -31
- package/dist/element-directive.js.map +0 -1
- package/dist/internal/runtime.d.ts +0 -7
- package/dist/internal/runtime.js +0 -8
- package/dist/internal/runtime.js.map +0 -1
- package/dist/invalid.d.ts +0 -21
- package/dist/invalid.js +0 -70
- package/dist/invalid.js.map +0 -1
- package/dist/live-boolean.d.ts +0 -22
- package/dist/live-boolean.js +0 -34
- package/dist/live-boolean.js.map +0 -1
- package/dist/styles.d.ts +0 -12
- package/dist/styles.js +0 -11
- package/dist/styles.js.map +0 -1
- package/dist/textarea.d.ts +0 -26
- package/dist/textarea.js +0 -85
- package/dist/textarea.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../../src/view/server/values.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,yFAAyF;AACzF,4FAA4F;AAC5F,4FAA4F;AAC5F,8EAA8E;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AAErC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAU,EAAW,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,OAAO,CAAC;AAC9F,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAU,EAAW,EAAE,CAAC,CAAC,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;AAEpE,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAe,EAAE,CAC3C,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,UAAU,CAAC;AAEnE,2FAA2F;AAC3F,MAAM,IAAI,GAAG,MAAoC,CAAC;AAElD,MAAM,UAAU,GAAG,CAAC,CAAS,EAAW,EAAE,CACxC,OAAQ,CAAiC,CAAC,IAAI,KAAK,UAAU,CAAC;AAEhE,yFAAyF;AACzF,MAAM,UAAU,YAAY,CAAC,CAAS,EAAE,KAAa;IACnD,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO;IAC3B,MAAM,IAAI,SAAS,CACjB,UAAU,KAAK,wEAAwE;QACrF,qFAAqF;QACrF,gBAAgB,IAAI,uBAAuB,CAC9C,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,SAAS,OAAO,CAAC,CAAU,EAAE,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S,CAAC,IAAI,CAAC,IAAI;QAC1F,uCAAuC,IAAI,mCAAmC,CACjF,CAAC;AACJ,CAAC","sourcesContent":["// Value rules for attribute and text-content holes on the server (view/02-bindings.md\n// \"Attribute values\", \"Live form state\"; view/06-server.md \"Writing a template result\"),\n// identical to the client's (render/attr-parts.ts) so both sides write the same attributes.\n// And the server-only errors: a Promise anywhere (renders are synchronous), text the parser\n// would move out of table structure, children given to a light-DOM component.\nimport { nothing } from '../render/values.js';\nimport { warnTrue, warnValue } from '../render/warn.js';\n\nconst SPEC = 'docs/design-docs/view';\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): v is object =>\n (typeof v === 'object' && v !== null) || typeof v === 'function';\n\n/** `String(v)`: objects and functions as the client writes them (render/attr-parts.ts). */\nconst text = String as (value: unknown) => string;\n\nconst isThenable = (v: object): boolean =>\n typeof (v as { readonly then?: unknown }).then === 'function';\n\n/** A Promise in any hole: server renders are synchronous (06 \"API\"). Always an error. */\nexport function checkPromise(v: object, where: string): void {\n if (!isThenable(v)) return;\n throw new TypeError(\n `gyral: ${where} got a Promise. Server renders are synchronous: state is known before ` +\n 'rendering, so load the data first (in the route handler or a form action) and pass ' +\n `it as props (${SPEC}/06-server.md \"API\").`,\n );\n}\n\n/** `String(v)` for an attribute value, with the development warning for objects. */\nfunction written(v: unknown, at: object, name: string, dev: boolean): string {\n if (typeof v === 'string') return v;\n if (isObject(v)) {\n checkPromise(v, `the attribute ${name}`);\n if (dev) warnValue(at, v, `the attribute ${name}`);\n }\n return text(v);\n}\n\n/** `name=${v}`: the value to write, or null to leave the attribute out. */\nexport function attrText(v: unknown, at: object, name: string, dev: boolean): string | null {\n return absent(v) ? null : written(v, at, name, dev);\n}\n\n/** `name=\"a ${x} b\"`: pieces joined; `nothing` in any piece leaves the attribute out. */\nexport function multiText(\n values: readonly unknown[],\n from: number,\n strings: readonly string[],\n at: object,\n name: string,\n dev: boolean,\n): string | null {\n let joined = strings[0] ?? '';\n for (let i = 1; i < strings.length; i++) {\n const v = values[from + i - 1];\n if (v === nothing) return null;\n joined +=\n (v === null || v === undefined ? '' : written(v, at, name, dev)) + (strings[i] as string);\n }\n return joined;\n}\n\n/** `<textarea>`/`<title>` content: child-hole rules flattened to a string, as on the client. */\nexport function textContent(v: unknown, at: object, dev: boolean): string {\n if (typeof v === 'string') return v;\n if (typeof v === 'number') return String(v);\n if (isObject(v)) {\n checkPromise(v, 'the text content');\n if (dev) warnValue(at, v, 'the text content');\n return text(v);\n }\n if (dev && v === true) warnTrue(at);\n return '';\n}\n\n/** Text written directly in table structure would be foster-parented (rule 7). */\nexport function fosterError(text: string, parent: string): never {\n throw new Error(\n `gyral: the text ${JSON.stringify(text.slice(0, 40))} is written directly inside ` +\n `<${parent}>. The HTML parser moves text out of table structure (foster parenting), so ` +\n 'the page would differ from what the client renders. Put text inside a <td>, <th> or ' +\n `<caption> (${SPEC}/09-template-rules.md, rule 7).`,\n );\n}\n\n/** A light-DOM component owns its children (ADR 0014). */\nexport function lightChildrenError(tag: string): never {\n throw new Error(\n `gyral: <${tag}> renders in light DOM (shadow: false), so it owns its children, but its ` +\n 'parent wrote children inside it. Pass the data as props instead, or make it a shadow ' +\n `component and use <slot> (${SPEC}/06-server.md \"Components\", ADR 0014).`,\n );\n}\n\n/** An attribute name from a hook's server half must not break the start tag. */\nexport function checkAttrName(name: string): void {\n if (/^[^\\s\"'>/=\\0]+$/.test(name)) return;\n throw new TypeError(\n `gyral: an element hook's server half returned the attribute name ${JSON.stringify(name)}, ` +\n `which isn't a valid attribute name (${SPEC}/02-bindings.md \"Element hooks\").`,\n );\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type TemplateResult } from '../template.js';
|
|
2
|
+
import { Markup } from './tags.js';
|
|
3
|
+
export type { Deferred, Item } from './tags.js';
|
|
4
|
+
/** Warning key for values outside any template (the render root, a component's view). */
|
|
5
|
+
export declare const ROOT: object;
|
|
6
|
+
export declare class Writer extends Markup {
|
|
7
|
+
/** Writing a page shell's holes (a `server` template): never hydrated, so no anchors (06). */
|
|
8
|
+
private shell;
|
|
9
|
+
/** A child value (02 "Child values"). `table`: the parent, when it is table structure. */
|
|
10
|
+
child(v: unknown, table: string | undefined, at: object): void;
|
|
11
|
+
private object;
|
|
12
|
+
/** `each(…)`: rows one after another, no markers (03). Keys are checked in development. */
|
|
13
|
+
private list;
|
|
14
|
+
/** One template instance: its segments with this render's values. */
|
|
15
|
+
template(result: TemplateResult, table: string | undefined): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// The server renderer's walk (view/06-server.md "Writing a template result"): writes a child
|
|
2
|
+
// value by walking template objects' `segments` (01), never tokenizing or building a DOM. Each
|
|
3
|
+
// string segment is written verbatim; each hole op takes its value(s). Start tags and custom
|
|
4
|
+
// elements are tags.ts.
|
|
5
|
+
import { isList, nothing, rawHtml } from '../render/values.js';
|
|
6
|
+
import { badChild, badKey, warnTrue } from '../render/warn.js';
|
|
7
|
+
import { isTemplateResult, templateOf } from '../template.js';
|
|
8
|
+
import { escapeText, onlyWhitespace } from './escape.js';
|
|
9
|
+
import { Markup, PLAIN } from './tags.js';
|
|
10
|
+
import { checkPromise, fosterError, textContent, truthy } from './values.js';
|
|
11
|
+
/** Parents in which the parser moves non-whitespace text out (foster parenting). */
|
|
12
|
+
const TABLE = new Set(['table', 'tbody', 'thead', 'tfoot', 'tr']);
|
|
13
|
+
const tableTag = (parent) => (TABLE.has(parent) ? parent : undefined);
|
|
14
|
+
/** Warning key for values outside any template (the render root, a component's view). */
|
|
15
|
+
export const ROOT = {};
|
|
16
|
+
export class Writer extends Markup {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
/** Writing a page shell's holes (a `server` template): never hydrated, so no anchors (06). */
|
|
20
|
+
this.shell = false;
|
|
21
|
+
}
|
|
22
|
+
/** A child value (02 "Child values"). `table`: the parent, when it is table structure. */
|
|
23
|
+
child(v, table, at) {
|
|
24
|
+
switch (typeof v) {
|
|
25
|
+
case 'string':
|
|
26
|
+
if (v === '')
|
|
27
|
+
return;
|
|
28
|
+
if (table !== undefined && this.dev && !onlyWhitespace(v))
|
|
29
|
+
fosterError(v, table);
|
|
30
|
+
this.buf += escapeText(v);
|
|
31
|
+
return;
|
|
32
|
+
case 'number':
|
|
33
|
+
if (table !== undefined && this.dev)
|
|
34
|
+
fosterError(String(v), table);
|
|
35
|
+
this.buf += String(v);
|
|
36
|
+
return;
|
|
37
|
+
case 'object':
|
|
38
|
+
if (v !== null)
|
|
39
|
+
this.object(v, table, at);
|
|
40
|
+
return;
|
|
41
|
+
case 'boolean':
|
|
42
|
+
if (v && this.dev)
|
|
43
|
+
warnTrue(at);
|
|
44
|
+
return;
|
|
45
|
+
case 'undefined':
|
|
46
|
+
return;
|
|
47
|
+
default:
|
|
48
|
+
if (v !== nothing && this.dev)
|
|
49
|
+
badChild(v);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
object(v, table, at) {
|
|
53
|
+
if (isTemplateResult(v)) {
|
|
54
|
+
this.template(v, table);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (isList(v)) {
|
|
58
|
+
this.list(v, table, at);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(v)) {
|
|
62
|
+
for (const item of v)
|
|
63
|
+
this.child(item, table, at);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const raw = rawHtml(v);
|
|
67
|
+
if (raw !== undefined) {
|
|
68
|
+
// The start anchor hydration finds (02 "raw(html)"); a page shell is never hydrated.
|
|
69
|
+
this.buf += this.shell ? raw : `<!---->${raw}`;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
checkPromise(v, 'a child hole');
|
|
73
|
+
if (this.dev)
|
|
74
|
+
badChild(v);
|
|
75
|
+
}
|
|
76
|
+
/** `each(…)`: rows one after another, no markers (03). Keys are checked in development. */
|
|
77
|
+
list(v, table, at) {
|
|
78
|
+
const { items, key, row, pick } = v;
|
|
79
|
+
const seen = this.dev ? new Set() : undefined;
|
|
80
|
+
for (let i = 0; i < items.length; i++) {
|
|
81
|
+
const item = items[i];
|
|
82
|
+
if (seen !== undefined) {
|
|
83
|
+
const k = key(item);
|
|
84
|
+
const dup = seen.has(k);
|
|
85
|
+
if (dup || (typeof k !== 'string' && typeof k !== 'number'))
|
|
86
|
+
badKey(k, i, dup);
|
|
87
|
+
seen.add(k);
|
|
88
|
+
}
|
|
89
|
+
this.child(row(item, pick === undefined ? undefined : pick(item)), table, at);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** One template instance: its segments with this render's values. */
|
|
93
|
+
template(result, table) {
|
|
94
|
+
const template = templateOf(result);
|
|
95
|
+
const segments = template.segments;
|
|
96
|
+
if (segments === undefined) {
|
|
97
|
+
throw new Error(`gyral: template ${JSON.stringify(template.html.slice(0, 40))} has no server ` +
|
|
98
|
+
'segments: it was compiled for the client. Render on the server with an SSR build ' +
|
|
99
|
+
'(or the runtime normalizer), which keeps them ' +
|
|
100
|
+
'(docs/design-docs/view/01-templates.md "Compiled").');
|
|
101
|
+
}
|
|
102
|
+
// Development marker: hydration checks the id before each instance (07). Page shells are
|
|
103
|
+
// never hydrated.
|
|
104
|
+
if (this.dev && !template.server)
|
|
105
|
+
this.buf += `<!--gyral:${template.id ?? ''}-->`;
|
|
106
|
+
const values = result.values;
|
|
107
|
+
const outer = this.shell;
|
|
108
|
+
this.shell = template.server === true;
|
|
109
|
+
let at = 0;
|
|
110
|
+
let opening;
|
|
111
|
+
let frames;
|
|
112
|
+
for (const s of segments) {
|
|
113
|
+
if (typeof s === 'string') {
|
|
114
|
+
this.buf += s;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
switch (s.k) {
|
|
118
|
+
case 'child':
|
|
119
|
+
this.child(values[at++], s.in === undefined ? table : tableTag(s.in), s);
|
|
120
|
+
break;
|
|
121
|
+
case 'text':
|
|
122
|
+
this.buf += escapeText(textContent(values[at++], s, this.dev));
|
|
123
|
+
break;
|
|
124
|
+
case 'attr':
|
|
125
|
+
at = this.attr(s, values, at, opening);
|
|
126
|
+
break;
|
|
127
|
+
case 'bool':
|
|
128
|
+
// `?indeterminate` has no attribute: it is the property only (02 "Live form state").
|
|
129
|
+
if (truthy(values[at]) && s.name !== 'indeterminate')
|
|
130
|
+
this.bare(s.name, opening);
|
|
131
|
+
at++;
|
|
132
|
+
break;
|
|
133
|
+
case 'prop':
|
|
134
|
+
if (opening !== undefined)
|
|
135
|
+
opening.properties[s.name] = values[at];
|
|
136
|
+
at++;
|
|
137
|
+
break;
|
|
138
|
+
case 'hook':
|
|
139
|
+
this.hook(values[at++], opening);
|
|
140
|
+
break;
|
|
141
|
+
case 'open':
|
|
142
|
+
opening = this.open(s.tag, s.html, s.attrs);
|
|
143
|
+
break;
|
|
144
|
+
case 'openEnd':
|
|
145
|
+
(frames ??= []).push(this.openEnd(opening));
|
|
146
|
+
opening = undefined;
|
|
147
|
+
break;
|
|
148
|
+
case 'close':
|
|
149
|
+
this.close(frames?.pop() ?? PLAIN, s.tag);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
this.shell = outer;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../../../src/view/server/writer.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,+FAA+F;AAC/F,6FAA6F;AAC7F,wBAAwB;AACxB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAmB,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAuB,M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AG,KAAK,CAAC;IACrB,CAAC;CACF","sourcesContent":["// The server renderer's walk (view/06-server.md \"Writing a template result\"): writes a child\n// value by walking template objects' `segments` (01), never tokenizing or building a DOM. Each\n// string segment is written verbatim; each hole op takes its value(s). Start tags and custom\n// elements are tags.ts.\nimport { isList, nothing, rawHtml, type ListResult } from '../render/values.js';\nimport { badChild, badKey, warnTrue } from '../render/warn.js';\nimport { isTemplateResult, templateOf, type TemplateResult } from '../template.js';\nimport { escapeText, onlyWhitespace } from './escape.js';\nimport { Markup, PLAIN, type Frame, type Opening } from './tags.js';\nimport { checkPromise, fosterError, textContent, truthy } from './values.js';\n\nexport type { Deferred, Item } from './tags.js';\n\n/** Parents in which the parser moves non-whitespace text out (foster parenting). */\nconst TABLE = new Set(['table', 'tbody', 'thead', 'tfoot', 'tr']);\n\nconst tableTag = (parent: string): string | undefined => (TABLE.has(parent) ? parent : undefined);\n\n/** Warning key for values outside any template (the render root, a component's view). */\nexport const ROOT: object = {};\n\nexport class Writer extends Markup {\n /** Writing a page shell's holes (a `server` template): never hydrated, so no anchors (06). */\n private shell = false;\n\n /** A child value (02 \"Child values\"). `table`: the parent, when it is table structure. */\n child(v: unknown, table: string | undefined, at: object): void {\n switch (typeof v) {\n case 'string':\n if (v === '') return;\n if (table !== undefined && this.dev && !onlyWhitespace(v)) fosterError(v, table);\n this.buf += escapeText(v);\n return;\n case 'number':\n if (table !== undefined && this.dev) fosterError(String(v), table);\n this.buf += String(v);\n return;\n case 'object':\n if (v !== null) this.object(v, table, at);\n return;\n case 'boolean':\n if (v && this.dev) warnTrue(at);\n return;\n case 'undefined':\n return;\n default:\n if (v !== nothing && this.dev) badChild(v);\n }\n }\n\n private object(v: object, table: string | undefined, at: object): void {\n if (isTemplateResult(v)) {\n this.template(v, table);\n return;\n }\n if (isList(v)) {\n this.list(v, table, at);\n return;\n }\n if (Array.isArray(v)) {\n for (const item of v as readonly unknown[]) this.child(item, table, at);\n return;\n }\n const raw = rawHtml(v);\n if (raw !== undefined) {\n // The start anchor hydration finds (02 \"raw(html)\"); a page shell is never hydrated.\n this.buf += this.shell ? raw : `<!---->${raw}`;\n return;\n }\n checkPromise(v, 'a child hole');\n if (this.dev) badChild(v);\n }\n\n /** `each(…)`: rows one after another, no markers (03). Keys are checked in development. */\n private list(v: ListResult, table: string | undefined, at: object): void {\n const { items, key, row, pick } = v;\n const seen = this.dev ? new Set<unknown>() : undefined;\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n if (seen !== undefined) {\n const k = key(item);\n const dup = seen.has(k);\n if (dup || (typeof k !== 'string' && typeof k !== 'number')) badKey(k, i, dup);\n seen.add(k);\n }\n this.child(row(item, pick === undefined ? undefined : pick(item)), table, at);\n }\n }\n\n /** One template instance: its segments with this render's values. */\n template(result: TemplateResult, table: string | undefined): void {\n const template = templateOf(result);\n const segments = template.segments;\n if (segments === undefined) {\n throw new Error(\n `gyral: template ${JSON.stringify(template.html.slice(0, 40))} has no server ` +\n 'segments: it was compiled for the client. Render on the server with an SSR build ' +\n '(or the runtime normalizer), which keeps them ' +\n '(docs/design-docs/view/01-templates.md \"Compiled\").',\n );\n }\n // Development marker: hydration checks the id before each instance (07). Page shells are\n // never hydrated.\n if (this.dev && !template.server) this.buf += `<!--gyral:${template.id ?? ''}-->`;\n const values = result.values;\n const outer = this.shell;\n this.shell = template.server === true;\n let at = 0;\n let opening: Opening | undefined;\n let frames: Frame[] | undefined;\n for (const s of segments) {\n if (typeof s === 'string') {\n this.buf += s;\n continue;\n }\n switch (s.k) {\n case 'child':\n this.child(values[at++], s.in === undefined ? table : tableTag(s.in), s);\n break;\n case 'text':\n this.buf += escapeText(textContent(values[at++], s, this.dev));\n break;\n case 'attr':\n at = this.attr(s, values, at, opening);\n break;\n case 'bool':\n // `?indeterminate` has no attribute: it is the property only (02 \"Live form state\").\n if (truthy(values[at]) && s.name !== 'indeterminate') this.bare(s.name, opening);\n at++;\n break;\n case 'prop':\n if (opening !== undefined) opening.properties[s.name] = values[at];\n at++;\n break;\n case 'hook':\n this.hook(values[at++], opening);\n break;\n case 'open':\n opening = this.open(s.tag, s.html, s.attrs);\n break;\n case 'openEnd':\n (frames ??= []).push(this.openEnd(opening));\n opening = undefined;\n break;\n case 'close':\n this.close(frames?.pop() ?? PLAIN, s.tag);\n }\n }\n this.shell = outer;\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const STYLE: unique symbol;
|
|
2
|
+
/** What `css` returns: CSS text, mapped to one shared `CSSStyleSheet` in the browser. */
|
|
3
|
+
export interface StyleSource {
|
|
4
|
+
readonly [STYLE]: true;
|
|
5
|
+
readonly text: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* What `spec.styles` accepts: `css` values, plain CSS strings (e.g.
|
|
9
|
+
* `import base from './base.css?inline'`) and arrays of them, nested freely. CSS is trusted
|
|
10
|
+
* author code: never interpolate user input.
|
|
11
|
+
*/
|
|
12
|
+
export type Styles = StyleSource | string | readonly Styles[];
|
|
13
|
+
/** A `css` interpolation: inserted as written (another `css` value inserts its text). */
|
|
14
|
+
export type CssValue = string | number | StyleSource;
|
|
15
|
+
export declare const isStyleSource: (value: unknown) => value is StyleSource;
|
|
16
|
+
/**
|
|
17
|
+
* Component CSS: `` css`p { margin-block: ${GAP}px; }` ``. Strings and numbers are inserted as
|
|
18
|
+
* written, so values from your own constants need no wrapper.
|
|
19
|
+
*/
|
|
20
|
+
export declare function css(strings: TemplateStringsArray, ...values: readonly CssValue[]): StyleSource;
|
|
21
|
+
/** The CSS texts of `styles`, flattened in order (the server writes them, 06). */
|
|
22
|
+
export declare function styleTexts(styles: Styles | undefined): string[];
|
|
23
|
+
/** One shared sheet per style source (or per distinct string), created on first use. */
|
|
24
|
+
export declare function sheetsFor(styles: Styles | undefined): CSSStyleSheet[];
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Component styles (view/08-styles.md "Authoring", "Browser"): the `css` tag and the shared
|
|
2
|
+
// sheets. A style source is CSS text plus a cache slot for its one `CSSStyleSheet`, created on
|
|
3
|
+
// first use with `replaceSync`; components that share a source share the sheet. Plain strings
|
|
4
|
+
// are style sources too (cached by text). The server reads the text (06), never the sheet.
|
|
5
|
+
const STYLE = Symbol('gyral.css');
|
|
6
|
+
export const isStyleSource = (value) => typeof value === 'object' && value !== null && STYLE in value;
|
|
7
|
+
/**
|
|
8
|
+
* Component CSS: `` css`p { margin-block: ${GAP}px; }` ``. Strings and numbers are inserted as
|
|
9
|
+
* written, so values from your own constants need no wrapper.
|
|
10
|
+
*/
|
|
11
|
+
export function css(strings, ...values) {
|
|
12
|
+
let text = strings[0] ?? '';
|
|
13
|
+
for (let i = 0; i < values.length; i++) {
|
|
14
|
+
const v = values[i];
|
|
15
|
+
text += (isStyleSource(v) ? v.text : String(v)) + (strings[i + 1] ?? '');
|
|
16
|
+
}
|
|
17
|
+
return { [STYLE]: true, text };
|
|
18
|
+
}
|
|
19
|
+
/** The CSS texts of `styles`, flattened in order (the server writes them, 06). */
|
|
20
|
+
export function styleTexts(styles) {
|
|
21
|
+
if (styles === undefined)
|
|
22
|
+
return [];
|
|
23
|
+
if (typeof styles === 'string')
|
|
24
|
+
return [styles];
|
|
25
|
+
if (isStyleSource(styles))
|
|
26
|
+
return [styles.text];
|
|
27
|
+
return styles.flatMap(styleTexts);
|
|
28
|
+
}
|
|
29
|
+
const bySource = new WeakMap();
|
|
30
|
+
const byText = new Map();
|
|
31
|
+
function sheetOf(text) {
|
|
32
|
+
const sheet = new CSSStyleSheet();
|
|
33
|
+
sheet.replaceSync(text);
|
|
34
|
+
return sheet;
|
|
35
|
+
}
|
|
36
|
+
/** One shared sheet per style source (or per distinct string), created on first use. */
|
|
37
|
+
export function sheetsFor(styles) {
|
|
38
|
+
if (styles === undefined)
|
|
39
|
+
return [];
|
|
40
|
+
if (typeof styles === 'string') {
|
|
41
|
+
let sheet = byText.get(styles);
|
|
42
|
+
if (sheet === undefined) {
|
|
43
|
+
sheet = sheetOf(styles);
|
|
44
|
+
byText.set(styles, sheet);
|
|
45
|
+
}
|
|
46
|
+
return [sheet];
|
|
47
|
+
}
|
|
48
|
+
if (isStyleSource(styles)) {
|
|
49
|
+
let sheet = bySource.get(styles);
|
|
50
|
+
if (sheet === undefined) {
|
|
51
|
+
sheet = sheetOf(styles.text);
|
|
52
|
+
bySource.set(styles, sheet);
|
|
53
|
+
}
|
|
54
|
+
return [sheet];
|
|
55
|
+
}
|
|
56
|
+
return styles.flatMap(sheetsFor);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/view/styles.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,+FAA+F;AAC/F,8FAA8F;AAC9F,2FAA2F;AAE3F,MAAM,KAAK,GAAkB,MAAM,CAAC,WAAW,CAAC,CAAC;AAkBjD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,IAAI,KAAK,CAAC;AAEhE;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,OAA6B,EAAE,GAAG,MAA2B;IAC/E,IAAI,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC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;QACjC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC7B,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC","sourcesContent":["// Component styles (view/08-styles.md \"Authoring\", \"Browser\"): the `css` tag and the shared\n// sheets. A style source is CSS text plus a cache slot for its one `CSSStyleSheet`, created on\n// first use with `replaceSync`; components that share a source share the sheet. Plain strings\n// are style sources too (cached by text). The server reads the text (06), never the sheet.\n\nconst STYLE: unique symbol = Symbol('gyral.css');\n\n/** What `css` returns: CSS text, mapped to one shared `CSSStyleSheet` in the browser. */\nexport interface StyleSource {\n readonly [STYLE]: true;\n readonly text: string;\n}\n\n/**\n * What `spec.styles` accepts: `css` values, plain CSS strings (e.g.\n * `import base from './base.css?inline'`) and arrays of them, nested freely. CSS is trusted\n * author code: never interpolate user input.\n */\nexport type Styles = StyleSource | string | readonly Styles[];\n\n/** A `css` interpolation: inserted as written (another `css` value inserts its text). */\nexport type CssValue = string | number | StyleSource;\n\nexport const isStyleSource = (value: unknown): value is StyleSource =>\n typeof value === 'object' && value !== null && STYLE in value;\n\n/**\n * Component CSS: `` css`p { margin-block: ${GAP}px; }` ``. Strings and numbers are inserted as\n * written, so values from your own constants need no wrapper.\n */\nexport function css(strings: TemplateStringsArray, ...values: readonly CssValue[]): StyleSource {\n let text = strings[0] ?? '';\n for (let i = 0; i < values.length; i++) {\n const v = values[i];\n text += (isStyleSource(v) ? v.text : String(v)) + (strings[i + 1] ?? '');\n }\n return { [STYLE]: true, text };\n}\n\n/** The CSS texts of `styles`, flattened in order (the server writes them, 06). */\nexport function styleTexts(styles: Styles | undefined): string[] {\n if (styles === undefined) return [];\n if (typeof styles === 'string') return [styles];\n if (isStyleSource(styles)) return [styles.text];\n return styles.flatMap(styleTexts);\n}\n\nconst bySource = new WeakMap<StyleSource, CSSStyleSheet>();\nconst byText = new Map<string, CSSStyleSheet>();\n\nfunction sheetOf(text: string): CSSStyleSheet {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(text);\n return sheet;\n}\n\n/** One shared sheet per style source (or per distinct string), created on first use. */\nexport function sheetsFor(styles: Styles | undefined): CSSStyleSheet[] {\n if (styles === undefined) return [];\n if (typeof styles === 'string') {\n let sheet = byText.get(styles);\n if (sheet === undefined) {\n sheet = sheetOf(styles);\n byText.set(styles, sheet);\n }\n return [sheet];\n }\n if (isStyleSource(styles)) {\n let sheet = bySource.get(styles);\n if (sheet === undefined) {\n sheet = sheetOf(styles.text);\n bySource.set(styles, sheet);\n }\n return [sheet];\n }\n return styles.flatMap(sheetsFor);\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
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).
|
|
4
|
+
import { verify } from '#prepare';
|
|
5
|
+
import { DEV } from '#view-dev';
|
|
6
|
+
import { SERVER_ONLY, TemplateError } from './normalize/errors.js';
|
|
7
|
+
const elements = new WeakMap();
|
|
8
|
+
/** The cached <template> element for `template`, parsed (and checked) on first use. */
|
|
9
|
+
export function templateElement(template) {
|
|
10
|
+
const cached = elements.get(template);
|
|
11
|
+
if (cached !== undefined)
|
|
12
|
+
return cached;
|
|
13
|
+
if (template.server) {
|
|
14
|
+
// Production keeps a short message: the class and its explanation stay out of the bundle.
|
|
15
|
+
throw DEV
|
|
16
|
+
? new TemplateError(11, SERVER_ONLY, template.loc)
|
|
17
|
+
: new Error('gyral: template rule 11: a page shell rendered in the browser.');
|
|
18
|
+
}
|
|
19
|
+
const el = document.createElement('template');
|
|
20
|
+
el.innerHTML = template.html;
|
|
21
|
+
verify(template, el);
|
|
22
|
+
elements.set(template, el);
|
|
23
|
+
return el;
|
|
24
|
+
}
|
|
25
|
+
//# 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,qFAAqF;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGnE,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;YACP,CAAC,CAAC,IAAI,aAAa,CAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC;YAClD,CAAC,CAAC,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IAClF,CAAC;IACD,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC9C,EAAE,CAAC,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC7B,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACrB,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC3B,OAAO,EAAE,CAAC;AACZ,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).\nimport { verify } from '#prepare';\nimport { DEV } from '#view-dev';\nimport { SERVER_ONLY, TemplateError } from './normalize/errors.js';\nimport type { TemplateObject } from './normalize/types.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\n ? new TemplateError(11, SERVER_ONLY, template.loc)\n : new Error('gyral: template rule 11: a page shell rendered in the browser.');\n }\n const el = document.createElement('template');\n el.innerHTML = template.html;\n verify(template, el);\n elements.set(template, el);\n return el;\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 function html(strings: TemplateStringsArray, ...values: unknown[]): TemplateResult;
|
|
10
|
+
/** Internal: what the template compiler (Phase 6) rewrites `html` calls into. */
|
|
11
|
+
export declare function compiled(template: TemplateObject, values: readonly unknown[]): TemplateResult;
|
|
12
|
+
export declare function isTemplateResult(value: unknown): value is TemplateResult;
|
|
13
|
+
/** Internal: a result's source, compared by identity to skip `templateOf` on updates. */
|
|
14
|
+
export declare const sourceOf: (result: TemplateResult) => readonly string[] | TemplateObject;
|
|
15
|
+
/**
|
|
16
|
+
* The template object of a result: compiled results carry it; a runtime result's call site is
|
|
17
|
+
* normalized once by `#prepare` (cached there, so compiled builds carry neither the preparer
|
|
18
|
+
* nor its cache).
|
|
19
|
+
*/
|
|
20
|
+
export declare function templateOf(result: TemplateResult): TemplateObject;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Template results and the `html` tag (view/01-templates.md "Authoring", "Template results").
|
|
2
|
+
// A result is a template source (the call site's strings, or a compiled template object) plus
|
|
3
|
+
// this call's values, recognised by a module-private symbol so data from JSON can never pass
|
|
4
|
+
// for one. `templateOf` turns the source into the template object: compiled results carry it,
|
|
5
|
+
// runtime results are normalized once per strings array through `#prepare` (prepare.ts).
|
|
6
|
+
import { prepare } from '#prepare';
|
|
7
|
+
const SOURCE = Symbol('gyral.template');
|
|
8
|
+
/** The template tag: `` html`<p>${s.text}</p>` ``. */
|
|
9
|
+
export function html(strings, ...values) {
|
|
10
|
+
return { [SOURCE]: strings, values };
|
|
11
|
+
}
|
|
12
|
+
/** Internal: what the template compiler (Phase 6) rewrites `html` calls into. */
|
|
13
|
+
export function compiled(template, values) {
|
|
14
|
+
return { [SOURCE]: template, values };
|
|
15
|
+
}
|
|
16
|
+
export function isTemplateResult(value) {
|
|
17
|
+
return typeof value === 'object' && value !== null && SOURCE in value;
|
|
18
|
+
}
|
|
19
|
+
/** Internal: a result's source, compared by identity to skip `templateOf` on updates. */
|
|
20
|
+
export const sourceOf = (result) => result[SOURCE];
|
|
21
|
+
/**
|
|
22
|
+
* The template object of a result: compiled results carry it; a runtime result's call site is
|
|
23
|
+
* normalized once by `#prepare` (cached there, so compiled builds carry neither the preparer
|
|
24
|
+
* nor its cache).
|
|
25
|
+
*/
|
|
26
|
+
export function templateOf(result) {
|
|
27
|
+
const source = result[SOURCE];
|
|
28
|
+
return Array.isArray(source) ? prepare(source) : source;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/view/template.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,8FAA8F;AAC9F,6FAA6F;AAC7F,8FAA8F;AAC9F,yFAAyF;AACzF,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,MAAM,MAAM,GAAkB,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAQvD,sDAAsD;AACtD,MAAM,UAAU,IAAI,CAAC,OAA6B,EAAE,GAAG,MAAiB;IACtE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACvC,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,QAAQ,CAAC,QAAwB,EAAE,MAA0B;IAC3E,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,CAAC;AACxE,CAAC;AAED,yFAAyF;AACzF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAsB,EAAsC,EAAE,CACrF,MAAM,CAAC,MAAM,CAAC,CAAC;AAEjB;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,MAAsB;IAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAyB,CAAC;AAC9E,CAAC","sourcesContent":["// Template results and the `html` tag (view/01-templates.md \"Authoring\", \"Template results\").\n// A result is a template source (the call site's strings, or a compiled template object) plus\n// this call's values, recognised by a module-private symbol so data from JSON can never pass\n// for one. `templateOf` turns the source into the template object: compiled results carry it,\n// runtime results are normalized once per strings array through `#prepare` (prepare.ts).\nimport { prepare } from '#prepare';\nimport type { TemplateObject } from './normalize/types.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: `` html`<p>${s.text}</p>` ``. */\nexport function html(strings: TemplateStringsArray, ...values: unknown[]): TemplateResult {\n return { [SOURCE]: strings, values };\n}\n\n/** Internal: what the template compiler (Phase 6) rewrites `html` calls into. */\nexport function compiled(template: TemplateObject, values: readonly unknown[]): TemplateResult {\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"]}
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,15 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
export interface TemplateCompilerOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Module specifiers whose `html` export is the view layer's tag (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`.
|
|
8
|
+
*/
|
|
9
|
+
readonly sources?: readonly string[];
|
|
10
|
+
/**
|
|
11
|
+
* Rule 7's extra check with parse5 (an optional peer dependency): `true` (default) uses
|
|
12
|
+
* 'parse5' when it is installed, a string names the module to load, `false` skips it.
|
|
13
|
+
*/
|
|
14
|
+
readonly parse5?: boolean | string;
|
|
15
|
+
}
|
|
16
|
+
/** Where the view layer's `html` comes from: core's main entry (ADR 0018, Phase 3). */
|
|
17
|
+
export declare const DEFAULT_TEMPLATE_SOURCES: readonly string[];
|
|
18
|
+
/** The resolve condition that maps core's `#prepare` to its stub (ADR 0017's mechanism). */
|
|
19
|
+
export declare const COMPILED_CONDITION = "gyral-compiled";
|
|
20
|
+
/** Vite 8's default resolve conditions (`defaultClientConditions`, server ones without browser). */
|
|
21
|
+
export declare const CLIENT_CONDITIONS: readonly string[];
|
|
22
|
+
export declare const SERVER_CONDITIONS: readonly string[];
|
|
23
|
+
/** The template compiler alone (`gyralVitePreset()` includes it). */
|
|
24
|
+
export declare function gyralTemplateCompiler(options?: TemplateCompilerOptions): Plugin;
|
|
25
|
+
/** Gyral's packages: the dev server runs them through Vite, never Node (view/06). */
|
|
26
|
+
export declare const GYRAL_PACKAGES: RegExp;
|
|
27
|
+
/**
|
|
28
|
+
* The app's direct dependencies that depend on a Gyral package (a design system, say). They
|
|
29
|
+
* import @gyral/core, so they must share the copy the dev server runs.
|
|
30
|
+
*/
|
|
31
|
+
export declare function gyralDependents(root: string): string[];
|
|
3
32
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
33
|
+
* Development output from the dev server's SSR (`ssrLoadModule`, view/06 "Development
|
|
34
|
+
* markers"). Vite externalizes installed packages there and Node imports them itself, resolving
|
|
35
|
+
* core's `#view-dev` without the `development` condition (Vite's `externalConditions` only pick
|
|
36
|
+
* the entry file, not the package's own imports), so the server rendered production output.
|
|
37
|
+
* In serve mode this plugin keeps Gyral's packages, and the app's dependencies that use them,
|
|
38
|
+
* out of externalization in server environments: Vite resolves them with its conditions
|
|
39
|
+
* (`development` in dev), and they all share one copy of core. `vite build` is unaffected.
|
|
6
40
|
*/
|
|
7
|
-
export declare
|
|
41
|
+
export declare function gyralDevServer(): Plugin;
|
|
8
42
|
export interface GyralViteOptions {
|
|
9
|
-
/**
|
|
43
|
+
/** Modules to pre-bundle in dev, so Vite doesn't discover them mid-run and reload. */
|
|
10
44
|
readonly optimize?: readonly string[];
|
|
45
|
+
/** Template compiler options (`vite build` only). */
|
|
46
|
+
readonly compiler?: TemplateCompilerOptions;
|
|
11
47
|
}
|
|
12
48
|
export interface GyralViteConfig {
|
|
49
|
+
readonly plugins: Plugin[];
|
|
13
50
|
readonly resolve: {
|
|
14
51
|
readonly dedupe: string[];
|
|
15
52
|
};
|
|
@@ -21,5 +58,7 @@ export interface GyralViteConfig {
|
|
|
21
58
|
* Spread into a Vite config, or into each Vitest project:
|
|
22
59
|
*
|
|
23
60
|
* export default defineConfig({ ...gyralVitePreset(), build: { … } });
|
|
61
|
+
*
|
|
62
|
+
* With plugins of your own, list both: `plugins: [...preset.plugins, mine()]`.
|
|
24
63
|
*/
|
|
25
64
|
export declare function gyralVitePreset(options?: GyralViteOptions): GyralViteConfig;
|