@takazudo/zfb 2.22.1 → 3.1.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/README.md +13 -16
- package/dist/config.d.ts +77 -25
- package/dist/config.js +27 -6
- package/dist/config.js.map +1 -1
- package/dist/content.d.ts +8 -22
- package/dist/content.js +6 -28
- package/dist/content.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/island-boundary.d.ts +4 -0
- package/dist/island-boundary.js +42 -0
- package/dist/island-boundary.js.map +1 -0
- package/dist/island.d.ts +2 -118
- package/dist/island.js +4 -284
- package/dist/island.js.map +1 -1
- package/dist/jsx-types.d.ts +2 -38
- package/dist/jsx-types.js +3 -10
- package/dist/jsx-types.js.map +1 -1
- package/dist/plugins.d.ts +40 -0
- package/dist/plugins.js.map +1 -1
- package/dist/runtime.d.ts +26 -77
- package/dist/runtime.js +307 -340
- package/dist/runtime.js.map +1 -1
- package/dist/zudo-react/client.d.ts +3 -0
- package/dist/zudo-react/client.js +3 -0
- package/dist/zudo-react/client.js.map +1 -0
- package/dist/zudo-react/description.d.ts +16 -0
- package/dist/zudo-react/description.js +64 -0
- package/dist/zudo-react/description.js.map +1 -0
- package/dist/zudo-react/dom-bindings.d.ts +13 -0
- package/dist/zudo-react/dom-bindings.js +58 -0
- package/dist/zudo-react/dom-bindings.js.map +1 -0
- package/dist/zudo-react/escape.d.ts +2 -0
- package/dist/zudo-react/escape.js +7 -0
- package/dist/zudo-react/escape.js.map +1 -0
- package/dist/zudo-react/forms.d.ts +29 -0
- package/dist/zudo-react/forms.js +371 -0
- package/dist/zudo-react/forms.js.map +1 -0
- package/dist/zudo-react/hydrate.d.ts +4 -0
- package/dist/zudo-react/hydrate.js +912 -0
- package/dist/zudo-react/hydrate.js.map +1 -0
- package/dist/zudo-react/index.d.ts +47 -0
- package/dist/zudo-react/index.js +13 -0
- package/dist/zudo-react/index.js.map +1 -0
- package/dist/zudo-react/island-root-type.d.ts +1 -0
- package/dist/zudo-react/island-root-type.js +2 -0
- package/dist/zudo-react/island-root-type.js.map +1 -0
- package/dist/zudo-react/jsx-dev-runtime.d.ts +8 -0
- package/dist/zudo-react/jsx-dev-runtime.js +6 -0
- package/dist/zudo-react/jsx-dev-runtime.js.map +1 -0
- package/dist/zudo-react/jsx-runtime.d.ts +5 -0
- package/dist/zudo-react/jsx-runtime.js +7 -0
- package/dist/zudo-react/jsx-runtime.js.map +1 -0
- package/dist/zudo-react/jsx-types.d.ts +216 -0
- package/dist/zudo-react/jsx-types.js +2 -0
- package/dist/zudo-react/jsx-types.js.map +1 -0
- package/dist/zudo-react/props-transport.d.ts +2 -0
- package/dist/zudo-react/props-transport.js +95 -0
- package/dist/zudo-react/props-transport.js.map +1 -0
- package/dist/zudo-react/reactive-types.d.ts +8 -0
- package/dist/zudo-react/reactive-types.js +2 -0
- package/dist/zudo-react/reactive-types.js.map +1 -0
- package/dist/zudo-react/reactive.d.ts +20 -0
- package/dist/zudo-react/reactive.js +176 -0
- package/dist/zudo-react/reactive.js.map +1 -0
- package/dist/zudo-react/render-html.d.ts +3 -0
- package/dist/zudo-react/render-html.js +535 -0
- package/dist/zudo-react/render-html.js.map +1 -0
- package/dist/zudo-react/root.d.ts +20 -0
- package/dist/zudo-react/root.js +74 -0
- package/dist/zudo-react/root.js.map +1 -0
- package/dist/zudo-react/scheduler.d.ts +12 -0
- package/dist/zudo-react/scheduler.js +113 -0
- package/dist/zudo-react/scheduler.js.map +1 -0
- package/dist/zudo-react/scope.d.ts +42 -0
- package/dist/zudo-react/scope.js +220 -0
- package/dist/zudo-react/scope.js.map +1 -0
- package/dist/zudo-react/server.d.ts +15 -0
- package/dist/zudo-react/server.js +11 -0
- package/dist/zudo-react/server.js.map +1 -0
- package/dist/zudo-react/structure.d.ts +16 -0
- package/dist/zudo-react/structure.js +49 -0
- package/dist/zudo-react/structure.js.map +1 -0
- package/dist/zudo-react/vocabulary.d.ts +12 -0
- package/dist/zudo-react/vocabulary.js +96 -0
- package/dist/zudo-react/vocabulary.js.map +1 -0
- package/package.json +28 -24
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-html.js","sourceRoot":"","sources":["../../src/zudo-react/render-html.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAgC,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAqB,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,QAAQ,EACR,KAAK,EACL,UAAU,EACV,IAAI,GACL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,aAAa,EACb,uBAAuB,EACvB,QAAQ,EACR,OAAO,EAEP,QAAQ,GACT,MAAM,iBAAiB,CAAC;AAEzB,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3D,MAAM,QAAQ,GAAG,KAAK,CAAC,0BAA0B,CAAC,CAAC;AACnD,MAAM,SAAS,GAAG,KAAK,CAAC,gDAAgD,CAAC,CAAC;AAC1E,MAAM,aAAa,GAAgC;IACjD,KAAK,EAAE,KAAK,CAAC,oCAAoC,CAAC;IAClD,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC;IAClB,KAAK,EAAE,KAAK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rB,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,OAAO,CAAC,MAAM;QACxB,QAAQ,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS;QACtC,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,MAAM;KACb,CAAC;IACF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QAC/C,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["import { Fragment, isDescription, type Child, type Description } from \"./description.js\";\nimport { escapeAttribute, escapeText } from \"./escape.js\";\nimport type { IslandIdentity } from \"./index.js\";\nimport { readSnapshot } from \"./reactive.js\";\nimport type { ReadonlySignal } from \"./reactive-types.js\";\nimport { createScope, withScope, type RuntimeScope } from \"./scope.js\";\nimport { serializeProps } from \"./props-transport.js\";\nimport { islandRootType } from \"./island-root-type.js\";\nimport type { IslandOptions, RenderOptions } from \"./server.js\";\nimport {\n isShowType,\n isForType,\n showProps,\n forProps,\n keyed,\n keyPayload,\n view,\n} from \"./structure.js\";\nimport {\n booleanAttrs,\n commonAttrs,\n dialectSuggestion,\n formProps,\n htmlAttrs,\n htmlTags,\n isDialectProp,\n reactiveModelSuggestion,\n svgAttrs,\n svgTags,\n type Namespace,\n voidTags,\n} from \"./vocabulary.js\";\n\nconst words = (value: string) => new Set(value.split(\" \"));\nconst reserved = words(\"key ref children rawHtml\");\nconst sensitive = words(\"noscript xmp iframe noembed noframes plaintext\");\nconst tableChildren: Record<string, Set<string>> = {\n table: words(\"caption colgroup thead tbody tfoot\"),\n thead: words(\"tr\"),\n tbody: words(\"tr\"),\n tfoot: words(\"tr\"),\n tr: words(\"td th\"),\n colgroup: words(\"col\"),\n};\ninterface Context {\n identity: IslandIdentity | undefined;\n boundary: boolean;\n next: number;\n scope: RuntimeScope;\n path: string;\n selectValue?: string | undefined;\n selectSeen?: Set<string> | undefined;\n selectMatches?: number | undefined;\n radioGroups: Map<\n unknown,\n { name: string; form: string; value: string | null; options: Set<string> }\n >;\n radioNames: Map<string, unknown>;\n formId: string;\n nextFormId: number;\n}\nfunction fail(code: string, context: Context, detail: string): never {\n throw new TypeError(\n `${code}: ${detail} at ${context.path} in ${context.identity?.component ?? \"static render\"}`,\n );\n}\nfunction reactive(value: unknown): value is ReadonlySignal<unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"$$zudoReactive\" in value &&\n value.$$zudoReactive === \"zudo-react.reactive.v1\"\n );\n}\nfunction read(value: unknown): unknown {\n return reactive(value) ? readSnapshot(value) : value;\n}\nfunction region(context: Context, kind: string, content: () => string): string {\n if (!context.identity) return content();\n const id = context.next++;\n return `<!--zr:1:${id}:${kind}-->${content()}<!--/zr:1:${id}-->`;\n}\nfunction at<T>(context: Context, part: string, fn: () => T): T {\n const old = context.path;\n context.path += part;\n try {\n return fn();\n } finally {\n context.path = old;\n }\n}\nfunction children(value: unknown, context: Context, namespace: Namespace, parent: string): string {\n if (value == null || typeof value === \"boolean\") return \"\";\n if (Array.isArray(value))\n return value\n .map((item, index) =>\n at(context, `[${index}]`, () => render(item, context, namespace, parent)),\n )\n .join(\"\");\n return render(value, context, namespace, parent);\n}\nfunction renderText(value: unknown, context: Context): string {\n if (value == null || typeof value === \"boolean\") return \"\";\n if (typeof value === \"string\" || (typeof value === \"number\" && Number.isFinite(value)))\n return escapeText(String(value));\n fail(\"ZR_CHILD\", context, `invalid scalar ${typeof value}`);\n}\nfunction style(value: unknown, context: Context): string {\n if (typeof value === \"string\") return value;\n if (\n value === null ||\n typeof value !== \"object\" ||\n Array.isArray(value) ||\n Object.getPrototypeOf(value) !== Object.prototype\n )\n fail(\"ZR_STYLE\", context, \"style must be a string or flat object\");\n let result = \"\";\n for (const [name, entry] of Object.entries(value)) {\n if (!/^(--[a-zA-Z0-9_-]+|[a-z][a-z0-9-]*)$/.test(name) || /[A-Z]/.test(name))\n fail(\"ZR_STYLE\", context, `invalid property ${name}`);\n if (entry == null) continue;\n if (typeof entry !== \"string\" && !(typeof entry === \"number\" && Number.isFinite(entry)))\n fail(\"ZR_STYLE\", context, `invalid value for ${name}`);\n result += `${name}:${entry};`;\n }\n return result;\n}\nfunction attributes(\n tag: string,\n props: Readonly<Record<string, unknown>>,\n context: Context,\n namespace: Namespace,\n custom: boolean,\n): string {\n let output = \"\";\n for (const [name, original] of Object.entries(props)) {\n if (reserved.has(name)) continue;\n if (formProps.has(name)) continue;\n if (isDialectProp(name, namespace, custom)) {\n const suggestion = dialectSuggestion(name, namespace, custom);\n fail(\n \"ZR_PROP_DIALECT\",\n context,\n `${tag}.${name}${suggestion ? ` (use \\`${suggestion}\\` instead of \\`${name}\\`)` : \"\"}`,\n );\n }\n if (name.startsWith(\"on:\")) {\n if (!/^on:[A-Za-z][A-Za-z0-9_-]*(?::capture)?$/.test(name))\n fail(\"ZR_LISTENER\", context, `${tag}.${name}`);\n if (typeof original !== \"function\") fail(\"ZR_LISTENER\", context, `${tag}.${name}`);\n const inline = `on${name.slice(3).replace(/:capture$/, \"\")}`;\n if (inline in props) fail(\"ZR_LISTENER_CONFLICT\", context, `${tag}.${inline}`);\n continue;\n }\n if (!/^[A-Za-z_:][A-Za-z0-9_:.-]*$/.test(name)) fail(\"ZR_ATTRIBUTE\", context, `${tag}.${name}`);\n if (\n !custom &&\n !commonAttrs.has(name) &&\n !(namespace === \"svg\" ? svgAttrs.has(name) : htmlAttrs.has(name)) &&\n !/^data-[\\w.-]+$/.test(name) &&\n !/^aria-[\\w.-]+$/.test(name) &&\n !/^on[a-z]+$/.test(name)\n )\n fail(\"ZR_ATTRIBUTE\", context, `${tag}.${name}`);\n const value = read(original);\n if ((name === \"value\" || name === \"checked\") && reactive(original)) {\n const suggestion = reactiveModelSuggestion(\n tag,\n name,\n String(read(props.type) ?? \"text\"),\n custom,\n );\n fail(\n \"ZR_MODEL_UNSUPPORTED\",\n context,\n `${tag}.${name} requires ${suggestion ?? \"a static value\"}`,\n );\n }\n if (value == null) continue;\n if (/^on[a-z]/.test(name) && typeof value === \"function\")\n fail(\"ZR_PROP_DIALECT\", context, `${tag}.${name} must use on:${name.slice(2)}`);\n if (custom && typeof value !== \"string\")\n fail(\"ZR_ATTRIBUTE\", context, `${tag}.${name} requires a string`);\n if (name === \"style\") output += ` style=\"${escapeAttribute(style(value, context))}\"`;\n else if (booleanAttrs.has(name)) {\n if (typeof value !== \"boolean\")\n fail(\"ZR_ATTRIBUTE\", context, `${tag}.${name} requires a boolean`);\n if (value) output += ` ${name}`;\n } else {\n if (\n typeof value !== \"string\" &&\n typeof value !== \"boolean\" &&\n !(typeof value === \"number\" && Number.isFinite(value))\n )\n fail(\"ZR_ATTRIBUTE\", context, `${tag}.${name} requires a scalar`);\n if (typeof value === \"boolean\" && !name.startsWith(\"aria-\") && !name.startsWith(\"data-\"))\n fail(\"ZR_ATTRIBUTE\", context, `${tag}.${name} requires a string`);\n if (/^on[a-z]/.test(name) && typeof value !== \"string\")\n fail(\"ZR_ATTRIBUTE\", context, `${tag}.${name} requires a string`);\n output += ` ${name}=\"${escapeAttribute(String(value))}\"`;\n }\n }\n return output;\n}\nfunction restricted(\n value: unknown,\n context: Context,\n namespace: Namespace,\n parent: string,\n): string {\n if (value == null || typeof value === \"boolean\") return \"\";\n if (Array.isArray(value))\n return value\n .map((item, index) =>\n at(context, `[${index}]`, () => restricted(item, context, namespace, parent)),\n )\n .join(\"\");\n if (typeof value === \"string\" || typeof value === \"number\") {\n if (parent in tableChildren && String(value).trim())\n fail(\"ZR_PARSER_CONTEXT\", context, `${parent} text`);\n return renderText(value, context);\n }\n if (parent === \"title\" || parent === \"option\")\n fail(\"ZR_PARSER_CONTEXT\", context, `${parent} requires static text`);\n if (!isDescription(value) || typeof value.type !== \"string\")\n fail(\"ZR_PARSER_CONTEXT\", context, `${parent} requires intrinsic children`);\n return element(value, context, namespace, parent);\n}\nfunction element(\n description: Description,\n context: Context,\n namespace: Namespace,\n parent: string,\n): string {\n const tag = description.type as string;\n const custom = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$/.test(tag);\n const elementNamespace = tag === \"svg\" || namespace === \"svg\" ? \"svg\" : \"html\";\n const childNamespace = tag === \"foreignObject\" ? \"html\" : elementNamespace;\n if (elementNamespace === \"svg\" ? !svgTags.has(tag) : !custom && !htmlTags.has(tag))\n fail(\"ZR_TAG\", context, tag);\n if (context.identity && (tag === \"template\" || sensitive.has(tag)))\n fail(\"ZR_PARSER_CONTEXT\", context, tag);\n if (parent in tableChildren && !tableChildren[parent]?.has(tag))\n fail(\"ZR_PARSER_CONTEXT\", context, `${parent} > ${tag}`);\n if (\n (parent === \"select\" && tag !== \"option\" && tag !== \"optgroup\") ||\n (parent === \"optgroup\" && tag !== \"option\")\n )\n fail(\"ZR_PARSER_CONTEXT\", context, `${parent} > ${tag}`);\n const previousFormId = context.formId;\n if (tag === \"form\")\n context.formId =\n typeof description.props.id === \"string\"\n ? `id:${description.props.id}`\n : `form:${context.nextFormId++}`;\n const source = description.props;\n const props: Record<string, unknown> = { ...source };\n const hasValue = source.modelValue !== undefined;\n const hasChecked = source.modelChecked !== undefined;\n if (\n (hasValue && hasChecked) ||\n (source.defaultValue !== undefined && source.value !== undefined) ||\n (source.defaultChecked !== undefined && source.checked !== undefined) ||\n (hasValue &&\n (source.defaultValue !== undefined ||\n (source.type !== \"radio\" && source.value !== undefined))) ||\n (hasChecked && (source.defaultChecked !== undefined || source.checked !== undefined))\n )\n fail(\"ZR_MODEL_CONFLICT\", context, tag);\n if (hasValue || hasChecked) {\n for (const name of [\"type\", \"multiple\", \"name\", \"form\"])\n if (reactive(source[name])) fail(\"ZR_MODEL_UNSUPPORTED\", context, `reactive ${name} shape`);\n const model = hasValue ? source.modelValue : source.modelChecked;\n let prototype = model;\n let writable = false;\n while (prototype && typeof prototype === \"object\") {\n const property = Object.getOwnPropertyDescriptor(prototype, \"value\");\n if (property) {\n writable = typeof property.set === \"function\";\n break;\n }\n prototype = Object.getPrototypeOf(prototype);\n }\n if (\n !reactive(model) ||\n !writable ||\n !(\"$$zudoWritable\" in model) ||\n model.$$zudoWritable !== \"zudo-react.writable.v1\"\n )\n fail(\"ZR_MODEL_READONLY\", context, tag);\n }\n if ((hasValue || hasChecked) && source.contenteditable !== undefined)\n fail(\"ZR_MODEL_UNSUPPORTED\", context, `${tag}[contenteditable]`);\n const inputType = String(source.type ?? \"text\");\n if (\n hasValue &&\n !(\n tag === \"textarea\" ||\n tag === \"select\" ||\n (tag === \"input\" &&\n [\"text\", \"search\", \"email\", \"url\", \"tel\", \"password\", \"radio\"].includes(inputType))\n )\n )\n fail(\"ZR_MODEL_UNSUPPORTED\", context, `${tag}[type=${inputType}]`);\n if (hasChecked && !(tag === \"input\" && inputType === \"checkbox\"))\n fail(\"ZR_MODEL_UNSUPPORTED\", context, tag);\n if (\n source.defaultValue !== undefined &&\n !(tag === \"textarea\" || tag === \"select\" || tag === \"input\")\n )\n fail(\"ZR_MODEL_UNSUPPORTED\", context, tag);\n if (\n source.defaultValue !== undefined &&\n tag === \"input\" &&\n ![\"text\", \"search\", \"email\", \"url\", \"tel\", \"password\"].includes(inputType)\n )\n fail(\"ZR_MODEL_UNSUPPORTED\", context, `${tag}[type=${inputType}]`);\n if (\n source.defaultChecked !== undefined &&\n !(tag === \"input\" && [\"checkbox\", \"radio\"].includes(inputType))\n )\n fail(\"ZR_MODEL_UNSUPPORTED\", context, tag);\n if (tag === \"input\") {\n if (source.defaultValue !== undefined || (hasValue && inputType !== \"radio\"))\n props.value = read(source.modelValue ?? source.defaultValue);\n if (source.defaultChecked !== undefined || hasChecked)\n props.checked = read(source.modelChecked ?? source.defaultChecked);\n if (hasValue && inputType === \"radio\") {\n if (typeof source.name !== \"string\" || !source.name || typeof source.value !== \"string\")\n fail(\"ZR_MODEL_UNSUPPORTED\", context, \"radio requires static name and value\");\n const selected = read(source.modelValue);\n if (selected !== null && typeof selected !== \"string\")\n fail(\"ZR_MODEL_VALUE\", context, \"radio requires string or null\");\n const form = typeof source.form === \"string\" ? `id:${source.form}` : context.formId;\n const key = `${source.name}\\u0000${form}`;\n const owner = context.radioNames.get(key);\n if (owner && owner !== source.modelValue)\n fail(\"ZR_MODEL_CONFLICT\", context, \"same-name radios use different models\");\n context.radioNames.set(key, source.modelValue);\n const group = context.radioGroups.get(source.modelValue);\n if (\n group &&\n (group.name !== source.name || group.form !== form || group.options.has(source.value))\n )\n fail(\"ZR_MODEL_CONFLICT\", context, \"radio membership or duplicate value\");\n if (group) group.options.add(source.value);\n else\n context.radioGroups.set(source.modelValue, {\n name: source.name,\n form,\n value: selected,\n options: new Set([source.value]),\n });\n props.checked = selected === source.value;\n }\n }\n if (tag === \"option\" && context.selectValue !== undefined) {\n const value = source.value;\n if (typeof value !== \"string\")\n fail(\"ZR_MODEL_UNSUPPORTED\", context, \"select option requires static value\");\n if (context.selectSeen!.has(value))\n fail(\"ZR_MODEL_CONFLICT\", context, \"duplicate option value\");\n context.selectSeen!.add(value);\n if (source.selected !== undefined)\n fail(\"ZR_MODEL_CONFLICT\", context, \"select-level value with option selected\");\n props.selected = value === context.selectValue;\n if (props.selected) context.selectMatches = (context.selectMatches ?? 0) + 1;\n }\n if (context.boundary && (\"data-zfb-island\" in props || \"data-zfb-island-skip-ssr\" in props))\n fail(\"ZR_NESTED_ISLAND\", context, tag);\n if (\n tag === \"select\" &&\n read(props.multiple) === true &&\n (context.identity || hasValue || source.defaultValue !== undefined)\n )\n fail(\"ZR_MODEL_UNSUPPORTED\", context, \"select[multiple]\");\n const attrs = attributes(tag, props, context, elementNamespace, custom);\n const raw = props.rawHtml;\n const hasChildren = Object.hasOwn(props, \"children\");\n if (raw !== undefined && hasChildren)\n fail(\"ZR_RAW_HTML\", context, `${tag} has children and rawHtml`);\n if (voidTags.has(tag) && (hasChildren || raw !== undefined))\n fail(\"ZR_VOID_CHILDREN\", context, tag);\n if (\n raw !== undefined &&\n (elementNamespace === \"svg\" ||\n tag === \"textarea\" ||\n tag === \"title\" ||\n tag === \"select\" ||\n tag === \"option\")\n )\n fail(\"ZR_RAW_HTML\", context, tag);\n if (tag === \"textarea\" && hasChildren && (hasValue || source.defaultValue !== undefined))\n fail(\"ZR_MODEL_CONFLICT\", context, tag);\n let content = \"\";\n if (raw !== undefined) {\n if ((tag === \"script\" || tag === \"style\") && reactive(raw))\n fail(\"ZR_RAW_HTML\", context, `${tag} requires static rawHtml`);\n const payload = read(raw);\n if (typeof payload !== \"string\") fail(\"ZR_RAW_HTML\", context, `${tag} requires string rawHtml`);\n if (/<!--\\/?zr:1:|data-zfb-island(?:-skip-ssr)?\\s*=/.test(payload))\n fail(\"ZR_RAW_HTML\", context, \"reserved boundary in rawHtml\");\n if (\n (tag === \"script\" && /<\\/script/i.test(payload)) ||\n (tag === \"style\" && /<\\/style/i.test(payload))\n )\n fail(\"ZR_RAW_HTML\", context, `closing ${tag} in rawHtml`);\n content = tag === \"script\" || tag === \"style\" ? payload : region(context, \"h\", () => payload);\n } else if (tag === \"textarea\" && (hasValue || source.defaultValue !== undefined)) {\n const value = read(source.modelValue ?? source.defaultValue);\n if (typeof value !== \"string\") fail(\"ZR_MODEL_VALUE\", context, \"textarea requires string\");\n content = `${value.startsWith(\"\\n\") ? \"\\n\" : \"\"}${escapeText(value)}`;\n } else if (tag === \"script\" || tag === \"style\") {\n if (hasChildren) fail(\"ZR_RAW_HTML\", context, `${tag} requires rawHtml`);\n } else if (\n tag === \"title\" ||\n tag === \"option\" ||\n tag === \"optgroup\" ||\n tag === \"select\" ||\n tag in tableChildren\n ) {\n if (tag === \"select\" && (hasValue || source.defaultValue !== undefined)) {\n const value = read(source.modelValue ?? source.defaultValue);\n if (typeof value !== \"string\") fail(\"ZR_MODEL_VALUE\", context, \"select requires string\");\n const oldValue = context.selectValue;\n const oldSeen = context.selectSeen;\n const oldMatches = context.selectMatches;\n context.selectValue = value;\n context.selectSeen = new Set();\n context.selectMatches = 0;\n try {\n content = restricted(props.children, context, childNamespace, tag);\n if (context.selectMatches !== 1)\n fail(\"ZR_MODEL_VALUE\", context, `select has no option ${value}`);\n } finally {\n context.selectValue = oldValue;\n context.selectSeen = oldSeen;\n context.selectMatches = oldMatches;\n }\n } else content = restricted(props.children, context, childNamespace, tag);\n } else content = children(props.children, context, childNamespace, tag);\n if (tag === \"pre\" && raw === undefined && (content.startsWith(\"\\n\") || content.startsWith(\"\\r\")))\n content = `\\n${content}`;\n context.formId = previousFormId;\n return `<${tag}${attrs}>${voidTags.has(tag) ? \"\" : `${content}</${tag}>`}`;\n}\nfunction render(value: unknown, context: Context, namespace: Namespace, parent: string): string {\n if (value == null || typeof value === \"boolean\") return \"\";\n if (Array.isArray(value))\n return region(context, \"f\", () => children(value, context, namespace, parent));\n if (reactive(value)) return region(context, \"t\", () => renderText(read(value), context));\n if (typeof value === \"string\" || typeof value === \"number\") return renderText(value, context);\n if (typeof value === \"object\" && value !== null && \"then\" in value)\n fail(\"ZR_ASYNC_COMPONENT\", context, \"promise child\");\n if (!isDescription(value)) fail(\"ZR_CHILD\", context, typeof value);\n if ((value.type as symbol | typeof value.type) === islandRootType)\n return island(value, context, namespace, parent);\n if (value.type === Fragment)\n return region(context, \"f\", () => children(value.props.children, context, namespace, parent));\n if (isShowType(value.type)) {\n if (\n parent in tableChildren ||\n [\"select\", \"optgroup\", \"option\", \"title\", \"textarea\", \"script\", \"style\"].includes(parent)\n )\n fail(\"ZR_PARSER_CONTEXT\", context, parent);\n const props = showProps(value);\n if (\n !reactive(props.when) ||\n typeof props.children !== \"function\" ||\n (props.fallback !== undefined && typeof props.fallback !== \"function\")\n )\n fail(\"ZR_CHILD\", context, \"Show requires signal and factories\");\n const selected = read(props.when);\n if (typeof selected !== \"boolean\") fail(\"ZR_CHILD\", context, \"Show.when requires boolean\");\n return region(context, `s:${selected ? 1 : 0}`, () => {\n const factory = selected ? props.children : props.fallback;\n if (!factory) return \"\";\n const scope = context.scope.child(\"Show\");\n const previous = context.scope;\n context.scope = scope;\n try {\n return withScope(scope, () => render(factory(), context, namespace, parent));\n } finally {\n context.scope = previous;\n }\n });\n }\n if (isForType(value.type)) {\n if (\n parent in tableChildren ||\n [\"select\", \"optgroup\", \"option\", \"title\", \"textarea\", \"script\", \"style\"].includes(parent)\n )\n fail(\"ZR_PARSER_CONTEXT\", context, parent);\n const props = forProps<unknown>(value);\n if (\n !reactive(props.each) ||\n typeof props.by !== \"function\" ||\n typeof props.children !== \"function\"\n )\n fail(\"ZR_CHILD\", context, \"For requires signal, key and factory\");\n const items = read(props.each);\n if (!Array.isArray(items)) fail(\"ZR_CHILD\", context, \"For.each requires array\");\n const keys = keyed(items, props.by, context.path);\n return region(context, \"l\", () =>\n items\n .map((item, index) => {\n const scope = context.scope.child(\"For\");\n const previous = context.scope;\n context.scope = scope;\n try {\n return region(context, `i:${keyPayload(keys[index]!)}`, () =>\n withScope(scope, () =>\n render(\n props.children(view(item).value, view(index).value),\n context,\n namespace,\n parent,\n ),\n ),\n );\n } finally {\n context.scope = previous;\n }\n })\n .join(\"\"),\n );\n }\n if (typeof value.type === \"string\") return element(value, context, namespace, parent);\n const component = value.type;\n const scope = context.scope.child(component.name || \"Anonymous\");\n const prior = context.scope;\n context.scope = scope;\n try {\n return region(context, \"c\", () => {\n const output = withScope(scope, () => component(value.props));\n if (output && typeof output === \"object\" && \"then\" in output)\n fail(\"ZR_ASYNC_COMPONENT\", context, component.name);\n return render(output, context, namespace, parent);\n });\n } finally {\n context.scope = prior;\n }\n}\nfunction empty(value: unknown): boolean {\n return (\n value == null || typeof value === \"boolean\" || (Array.isArray(value) && value.every(empty))\n );\n}\nfunction island(\n description: Description,\n context: Context,\n namespace: Namespace,\n parent: string,\n): string {\n if (context.boundary) fail(\"ZR_NESTED_ISLAND\", context, \"nested island\");\n if (namespace !== \"html\" || parent === \"p\" || parent in tableChildren || parent === \"select\")\n fail(\"ZR_PARSER_CONTEXT\", context, \"island wrapper\");\n const child = description.props.child;\n const options = description.props.options as IslandOptions;\n if (!isDescription(child) || typeof child.type !== \"function\")\n fail(\"ZR_ISLAND_CHILD\", context, \"one function component required\");\n if (!options?.identity?.component || !options.identity.build)\n fail(\"ZR_ISLAND_IDENTITY\", context, \"component/build required\");\n const component =\n (child.type as typeof child.type & { displayName?: string }).displayName ?? child.type.name;\n if (component !== options.identity.component)\n fail(\"ZR_ISLAND_IDENTITY\", context, `expected ${options.identity.component}, got ${component}`);\n if (Object.hasOwn(child.props, \"children\") && !empty(child.props.children))\n fail(\"ZR_ISLAND_CHILD\", context, \"nonempty children\");\n const props = { ...child.props };\n delete props.children;\n let payload: string;\n try {\n payload = serializeProps(props);\n } catch (error) {\n throw new TypeError(\n `ZR_ISLAND_PROPS ${component}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const when = options.when ?? \"load\";\n if (\n ![\"load\", \"idle\", \"visible\", \"media\"].includes(when) ||\n (when === \"media\" && !options.media?.trim()) ||\n (when !== \"media\" && options.media !== undefined)\n )\n fail(\"ZR_ISLAND_WHEN\", context, when);\n const marker = options.skipSsr ? \"data-zfb-island-skip-ssr\" : \"data-zfb-island\";\n const attrs = ` ${marker}=\"${escapeAttribute(options.identity.component)}\" data-when=\"${when}\"${when === \"media\" ? ` data-media=\"${escapeAttribute(options.media!)}\"` : \"\"} data-zfb-transport=\"json/1\" data-zfb-protocol=\"zudo-react/1\" data-zfb-build=\"${escapeAttribute(options.identity.build)}\" data-props=\"${escapeAttribute(payload)}\"`;\n const local: Context = {\n radioGroups: new Map(),\n radioNames: new Map(),\n formId: \"\",\n nextFormId: 0,\n identity: options.skipSsr ? undefined : options.identity,\n boundary: true,\n next: 0,\n scope: context.scope,\n path: context.path,\n };\n const content = options.skipSsr\n ? children(options.fallback, local, namespace, \"div\")\n : render({ ...child, props }, local, \"html\", \"div\");\n validateRadioGroups(local);\n return `<div${attrs}>${content}</div>`;\n}\nfunction validateRadioGroups(context: Context): void {\n for (const group of context.radioGroups.values())\n if (group.value !== null && !group.options.has(group.value))\n fail(\"ZR_MODEL_VALUE\", context, `radio has no option ${group.value}`);\n}\nexport function renderHtml(node: Child, options: RenderOptions): string {\n const root = createScope({ component: options.island?.component ?? \"<root>\" });\n const context: Context = {\n radioGroups: new Map(),\n radioNames: new Map(),\n formId: \"\",\n nextFormId: 0,\n identity: options.island,\n boundary: options.island !== undefined,\n next: 0,\n scope: root,\n path: \"root\",\n };\n try {\n const html = render(node, context, \"html\", \"\");\n validateRadioGroups(context);\n return html;\n } finally {\n root.dispose();\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Diagnostic, IslandIdentity, Reporter } from "./index.js";
|
|
2
|
+
import type { RuntimeScope } from "./scope.js";
|
|
3
|
+
export interface RootOptions {
|
|
4
|
+
identity: IslandIdentity;
|
|
5
|
+
signal?: AbortSignal | undefined;
|
|
6
|
+
report?: Reporter | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface RootHandle {
|
|
9
|
+
readonly protocol: "zudo-react/1";
|
|
10
|
+
readonly identity: IslandIdentity;
|
|
11
|
+
readonly disposed: boolean;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
unmount(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare const ROOT_KEY: unique symbol;
|
|
16
|
+
export declare function storedRoot(container: Element): RootHandle | undefined;
|
|
17
|
+
export declare function report(options: RootOptions, diagnostic: Diagnostic): void;
|
|
18
|
+
export declare function diagnostic(options: RootOptions, code: string, phase: Diagnostic["phase"], path: string, expected: string, actual: string, stack?: readonly string[]): Diagnostic;
|
|
19
|
+
export declare function rootPath(element: Element): string;
|
|
20
|
+
export declare function createRoot(container: Element, options: RootOptions, scope: RuntimeScope, cleanups: Array<() => void>, owned: readonly Node[]): RootHandle;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export const ROOT_KEY = Symbol.for("@takazudo/zfb/zudo-react/root-v1");
|
|
2
|
+
export function storedRoot(container) {
|
|
3
|
+
return container[ROOT_KEY];
|
|
4
|
+
}
|
|
5
|
+
export function report(options, diagnostic) {
|
|
6
|
+
try {
|
|
7
|
+
(options.report ?? ((value) => console.error(value)))(diagnostic);
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
console.error(error);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function diagnostic(options, code, phase, path, expected, actual, stack = [options.identity.component]) {
|
|
14
|
+
return {
|
|
15
|
+
code,
|
|
16
|
+
phase,
|
|
17
|
+
component: stack.at(-1) ?? options.identity.component,
|
|
18
|
+
componentStack: stack,
|
|
19
|
+
path,
|
|
20
|
+
expected,
|
|
21
|
+
actual,
|
|
22
|
+
protocol: "zudo-react/1",
|
|
23
|
+
build: options.identity.build,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function rootPath(element) {
|
|
27
|
+
const parts = [];
|
|
28
|
+
for (let node = element; node; node = node.parentElement) {
|
|
29
|
+
const index = node.parentElement
|
|
30
|
+
? Array.prototype.indexOf.call(node.parentElement.children, node) + 1
|
|
31
|
+
: 1;
|
|
32
|
+
parts.unshift(`${node.localName}:nth-child(${index})`);
|
|
33
|
+
}
|
|
34
|
+
return `/${parts.join("/")}`;
|
|
35
|
+
}
|
|
36
|
+
export function createRoot(container, options, scope, cleanups, owned) {
|
|
37
|
+
let disposed = false;
|
|
38
|
+
let removed = false;
|
|
39
|
+
const handle = {
|
|
40
|
+
protocol: "zudo-react/1",
|
|
41
|
+
identity: options.identity,
|
|
42
|
+
get disposed() {
|
|
43
|
+
return disposed;
|
|
44
|
+
},
|
|
45
|
+
dispose() {
|
|
46
|
+
if (disposed)
|
|
47
|
+
return;
|
|
48
|
+
disposed = true;
|
|
49
|
+
for (const cleanup of [...cleanups].reverse()) {
|
|
50
|
+
try {
|
|
51
|
+
cleanup();
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
report(options, diagnostic(options, "ZR_CLEANUP_ERROR", "cleanup", rootPath(container), "cleanup", String(error)));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
scope.dispose();
|
|
58
|
+
},
|
|
59
|
+
unmount() {
|
|
60
|
+
handle.dispose();
|
|
61
|
+
if (removed || storedRoot(container) !== handle)
|
|
62
|
+
return;
|
|
63
|
+
removed = true;
|
|
64
|
+
for (const node of owned)
|
|
65
|
+
if (node.parentNode === container)
|
|
66
|
+
container.removeChild(node);
|
|
67
|
+
if (storedRoot(container) === handle)
|
|
68
|
+
delete container[ROOT_KEY];
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
container[ROOT_KEY] = handle;
|
|
72
|
+
return handle;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/zudo-react/root.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAEvE,MAAM,UAAU,UAAU,CAAC,SAAkB;IAC3C,OAAQ,SAAyB,CAAC,QAAQ,CAAC,CAAC;AAC9C,CAAC;AACD,MAAM,UAAU,MAAM,CAAC,OAAoB,EAAE,UAAsB;IACjE,IAAI,CAAC;QACH,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACpE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AACD,MAAM,UAAU,UAAU,CACxB,OAAoB,EACpB,IAAY,EACZ,KAA0B,EAC1B,IAAY,EACZ,QAAgB,EAChB,MAAc,EACd,QAA2B,CAAC,OAAO,CAAC,QAAQ,CAAC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;YAChB,KAAK,MAAM,OAAO,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC9C,IAAI,CAAC;oBACH,OAAO,EAAE,CAAC;gBACZ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CACJ,OAAO,EACP,UAAU,CACR,OAAO,EACP,kBAAkB,EAClB,SAAS,EACT,QAAQ,CAAC,SAAS,CAAC,EACnB,SAAS,EACT,MAAM,CAAC,KAAK,CAAC,CACd,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;QACD,OAAO;YACL,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,OAAO,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,MAAM;gBAAE,OAAO;YACxD,OAAO,GAAG,IAAI,CAAC;YACf,KAAK,MAAM,IAAI,IAAI,KAAK;gBAAE,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS;oBAAE,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACzF,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,MAAM;gBAAE,OAAQ,SAAyB,CAAC,QAAQ,CAAC,CAAC;QACpF,CAAC;KACF,CAAC;IACD,SAAyB,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;IAC9C,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { Diagnostic, IslandIdentity, Reporter } from \"./index.js\";\nimport type { RuntimeScope } from \"./scope.js\";\n\nexport interface RootOptions {\n identity: IslandIdentity;\n signal?: AbortSignal | undefined;\n report?: Reporter | undefined;\n}\nexport interface RootHandle {\n readonly protocol: \"zudo-react/1\";\n readonly identity: IslandIdentity;\n readonly disposed: boolean;\n dispose(): void;\n unmount(): void;\n}\nexport const ROOT_KEY = Symbol.for(\"@takazudo/zfb/zudo-react/root-v1\");\ntype RootElement = Element & { [ROOT_KEY]?: RootHandle };\nexport function storedRoot(container: Element): RootHandle | undefined {\n return (container as RootElement)[ROOT_KEY];\n}\nexport function report(options: RootOptions, diagnostic: Diagnostic): void {\n try {\n (options.report ?? ((value) => console.error(value)))(diagnostic);\n } catch (error) {\n console.error(error);\n }\n}\nexport function diagnostic(\n options: RootOptions,\n code: string,\n phase: Diagnostic[\"phase\"],\n path: string,\n expected: string,\n actual: string,\n stack: readonly string[] = [options.identity.component],\n): Diagnostic {\n return {\n code,\n phase,\n component: stack.at(-1) ?? options.identity.component,\n componentStack: stack,\n path,\n expected,\n actual,\n protocol: \"zudo-react/1\",\n build: options.identity.build,\n };\n}\nexport function rootPath(element: Element): string {\n const parts: string[] = [];\n for (let node: Element | null = element; node; node = node.parentElement) {\n const index = node.parentElement\n ? Array.prototype.indexOf.call(node.parentElement.children, node) + 1\n : 1;\n parts.unshift(`${node.localName}:nth-child(${index})`);\n }\n return `/${parts.join(\"/\")}`;\n}\nexport function createRoot(\n container: Element,\n options: RootOptions,\n scope: RuntimeScope,\n cleanups: Array<() => void>,\n owned: readonly Node[],\n): RootHandle {\n let disposed = false;\n let removed = false;\n const handle: RootHandle = {\n protocol: \"zudo-react/1\",\n identity: options.identity,\n get disposed() {\n return disposed;\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n for (const cleanup of [...cleanups].reverse()) {\n try {\n cleanup();\n } catch (error) {\n report(\n options,\n diagnostic(\n options,\n \"ZR_CLEANUP_ERROR\",\n \"cleanup\",\n rootPath(container),\n \"cleanup\",\n String(error),\n ),\n );\n }\n }\n scope.dispose();\n },\n unmount() {\n handle.dispose();\n if (removed || storedRoot(container) !== handle) return;\n removed = true;\n for (const node of owned) if (node.parentNode === container) container.removeChild(node);\n if (storedRoot(container) === handle) delete (container as RootElement)[ROOT_KEY];\n },\n };\n (container as RootElement)[ROOT_KEY] = handle;\n return handle;\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type Phase = "derivation" | "commit" | "effect";
|
|
2
|
+
export interface Job {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly phase: Phase;
|
|
5
|
+
readonly active: () => boolean;
|
|
6
|
+
readonly run: () => void;
|
|
7
|
+
readonly report?: (code: string, actual: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const MAX_FLUSH_PASSES = 100;
|
|
10
|
+
export declare function enqueue(job: Job): void;
|
|
11
|
+
export declare function batch<T>(fn: () => T): T;
|
|
12
|
+
export declare function flush(): Promise<void>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export const MAX_FLUSH_PASSES = 100;
|
|
2
|
+
const phases = ["derivation", "commit", "effect"];
|
|
3
|
+
let pending = new Set();
|
|
4
|
+
let next = new Set();
|
|
5
|
+
let batchDepth = 0;
|
|
6
|
+
let scheduled = false;
|
|
7
|
+
let draining = false;
|
|
8
|
+
let waiters = [];
|
|
9
|
+
function schedule() {
|
|
10
|
+
if (scheduled || draining || batchDepth > 0 || pending.size === 0)
|
|
11
|
+
return;
|
|
12
|
+
scheduled = true;
|
|
13
|
+
queueMicrotask(() => {
|
|
14
|
+
scheduled = false;
|
|
15
|
+
drain();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function enqueue(job) {
|
|
19
|
+
if (!job.active())
|
|
20
|
+
return;
|
|
21
|
+
(draining ? next : pending).add(job);
|
|
22
|
+
schedule();
|
|
23
|
+
}
|
|
24
|
+
function drain() {
|
|
25
|
+
if (draining || batchDepth > 0)
|
|
26
|
+
return;
|
|
27
|
+
draining = true;
|
|
28
|
+
let passes = 0;
|
|
29
|
+
try {
|
|
30
|
+
while (pending.size > 0) {
|
|
31
|
+
if (++passes > MAX_FLUSH_PASSES) {
|
|
32
|
+
const jobs = [...pending, ...next].filter((job) => job.active());
|
|
33
|
+
pending.clear();
|
|
34
|
+
next.clear();
|
|
35
|
+
const actual = [...new Set(jobs.map((job) => job.id))].join(", ");
|
|
36
|
+
const affected = new Map();
|
|
37
|
+
for (const job of jobs) {
|
|
38
|
+
if (!job.report)
|
|
39
|
+
continue;
|
|
40
|
+
const ids = affected.get(job.report) ?? new Set();
|
|
41
|
+
ids.add(job.id);
|
|
42
|
+
affected.set(job.report, ids);
|
|
43
|
+
}
|
|
44
|
+
for (const [report, ids] of affected) {
|
|
45
|
+
try {
|
|
46
|
+
report("ZR_FLUSH_LIMIT", [...ids].join(", "));
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
/* A reporter cannot trap the scheduler. */
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const error = new Error(`ZR_FLUSH_LIMIT: ${actual}`);
|
|
53
|
+
if (affected.size === 0)
|
|
54
|
+
console.error(error);
|
|
55
|
+
for (const waiter of waiters.splice(0))
|
|
56
|
+
waiter.reject(error);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const pass = pending;
|
|
60
|
+
pending = new Set();
|
|
61
|
+
for (const phase of phases) {
|
|
62
|
+
for (const job of pass) {
|
|
63
|
+
if (job.phase !== phase || !job.active())
|
|
64
|
+
continue;
|
|
65
|
+
try {
|
|
66
|
+
job.run();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (job.report) {
|
|
70
|
+
try {
|
|
71
|
+
job.report("ZR_SUBSCRIBER_ERROR", String(error));
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
/* Keep draining. */
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.error(error);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
pending = next;
|
|
84
|
+
next = new Set();
|
|
85
|
+
}
|
|
86
|
+
for (const waiter of waiters.splice(0))
|
|
87
|
+
waiter.resolve();
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
draining = false;
|
|
91
|
+
schedule();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export function batch(fn) {
|
|
95
|
+
batchDepth++;
|
|
96
|
+
try {
|
|
97
|
+
return fn();
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
batchDepth--;
|
|
101
|
+
schedule();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export function flush() {
|
|
105
|
+
if (!draining && pending.size === 0)
|
|
106
|
+
return Promise.resolve();
|
|
107
|
+
const promise = new Promise((resolve, reject) => {
|
|
108
|
+
waiters.push({ resolve, reject });
|
|
109
|
+
});
|
|
110
|
+
schedule();
|
|
111
|
+
return promise;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../src/zudo-react/scheduler.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,MAAM,GAAqB,CAAC,YAAY,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACpE,IAAI,OAAO,GAAG,IAAI,GAAG,EAAO,CAAC;AAC7B,IAAI,IAAI,GAAG,IAAI,GAAG,EAAO,CAAC;AAC1B,IAAI,UAAU,GAAG,CAAC,CAAC;AACnB,IAAI,SAAS,GAAG,KAAK,CAAC;AACtB,IAAI,QAAQ,GAAG,KAAK,CAAC;AACrB,IAAI,OAAO,GAAoE,EAAE,CAAC;AAElF,SAAS,QAAQ;IACf,IAAI,SAAS,IAAI,QAAQ,IAAI,UAAU,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO;IAC1E,SAAS,GAAG,IAAI,CAAC;IACjB,cAAc,CAAC,GAAG,EAAE;QAClB,SAAS,GAAG,KAAK,CAAC;QAClB,KAAK,EAAE,CAAC;IACV,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,GAAQ;IAC9B,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;QAAE,OAAO;IAC1B,CAAC,QAAQ,CAAC,CAAC,C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,GAAG,IAAI,CAAC;YACf,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QACnB,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IAC3D,CAAC;YAAS,CAAC;QACT,QAAQ,GAAG,KAAK,CAAC;QACjB,QAAQ,EAAE,CAAC;IACb,CAAC;AACH,CAAC;AAED,MAAM,UAAU,KAAK,CAAI,EAAW;IAClC,UAAU,EAAE,CAAC;IACb,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;YAAS,CAAC;QACT,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;IACb,CAAC;AACH,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC9D,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpD,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IACH,QAAQ,EAAE,CAAC;IACX,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["export type Phase = \"derivation\" | \"commit\" | \"effect\";\n\nexport interface Job {\n readonly id: string;\n readonly phase: Phase;\n readonly active: () => boolean;\n readonly run: () => void;\n readonly report?: (code: string, actual: string) => void;\n}\n\nexport const MAX_FLUSH_PASSES = 100;\nconst phases: readonly Phase[] = [\"derivation\", \"commit\", \"effect\"];\nlet pending = new Set<Job>();\nlet next = new Set<Job>();\nlet batchDepth = 0;\nlet scheduled = false;\nlet draining = false;\nlet waiters: Array<{ resolve: () => void; reject: (reason: Error) => void }> = [];\n\nfunction schedule(): void {\n if (scheduled || draining || batchDepth > 0 || pending.size === 0) return;\n scheduled = true;\n queueMicrotask(() => {\n scheduled = false;\n drain();\n });\n}\n\nexport function enqueue(job: Job): void {\n if (!job.active()) return;\n (draining ? next : pending).add(job);\n schedule();\n}\n\nfunction drain(): void {\n if (draining || batchDepth > 0) return;\n draining = true;\n let passes = 0;\n try {\n while (pending.size > 0) {\n if (++passes > MAX_FLUSH_PASSES) {\n const jobs = [...pending, ...next].filter((job) => job.active());\n pending.clear();\n next.clear();\n const actual = [...new Set(jobs.map((job) => job.id))].join(\", \");\n const affected = new Map<NonNullable<Job[\"report\"]>, Set<string>>();\n for (const job of jobs) {\n if (!job.report) continue;\n const ids = affected.get(job.report) ?? new Set<string>();\n ids.add(job.id);\n affected.set(job.report, ids);\n }\n for (const [report, ids] of affected) {\n try {\n report(\"ZR_FLUSH_LIMIT\", [...ids].join(\", \"));\n } catch {\n /* A reporter cannot trap the scheduler. */\n }\n }\n const error = new Error(`ZR_FLUSH_LIMIT: ${actual}`);\n if (affected.size === 0) console.error(error);\n for (const waiter of waiters.splice(0)) waiter.reject(error);\n return;\n }\n const pass = pending;\n pending = new Set();\n for (const phase of phases) {\n for (const job of pass) {\n if (job.phase !== phase || !job.active()) continue;\n try {\n job.run();\n } catch (error) {\n if (job.report) {\n try {\n job.report(\"ZR_SUBSCRIBER_ERROR\", String(error));\n } catch {\n /* Keep draining. */\n }\n } else {\n console.error(error);\n }\n }\n }\n }\n pending = next;\n next = new Set();\n }\n for (const waiter of waiters.splice(0)) waiter.resolve();\n } finally {\n draining = false;\n schedule();\n }\n}\n\nexport function batch<T>(fn: () => T): T {\n batchDepth++;\n try {\n return fn();\n } finally {\n batchDepth--;\n schedule();\n }\n}\n\nexport function flush(): Promise<void> {\n if (!draining && pending.size === 0) return Promise.resolve();\n const promise = new Promise<void>((resolve, reject) => {\n waiters.push({ resolve, reject });\n });\n schedule();\n return promise;\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Cleanup, Diagnostic, Reporter, Scope } from "./index.js";
|
|
2
|
+
export interface ScopeOptions {
|
|
3
|
+
component: string;
|
|
4
|
+
reporter?: Reporter;
|
|
5
|
+
parent?: RuntimeScope;
|
|
6
|
+
path?: string;
|
|
7
|
+
protocol?: string;
|
|
8
|
+
build?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class RuntimeScope implements Scope {
|
|
11
|
+
readonly id: number;
|
|
12
|
+
readonly component: string;
|
|
13
|
+
readonly parent: RuntimeScope | undefined;
|
|
14
|
+
private readonly reporter;
|
|
15
|
+
private readonly path;
|
|
16
|
+
private readonly protocol;
|
|
17
|
+
private readonly build;
|
|
18
|
+
private readonly children;
|
|
19
|
+
private readonly cleanups;
|
|
20
|
+
private readonly activations;
|
|
21
|
+
private readonly effects;
|
|
22
|
+
private controller;
|
|
23
|
+
private live;
|
|
24
|
+
private activated;
|
|
25
|
+
private readonly jobReporter;
|
|
26
|
+
private root;
|
|
27
|
+
constructor(options: ScopeOptions);
|
|
28
|
+
get active(): boolean;
|
|
29
|
+
get isActivated(): boolean;
|
|
30
|
+
get abortSignal(): AbortSignal;
|
|
31
|
+
private ensureSetup;
|
|
32
|
+
report(code: string, phase: Diagnostic["phase"], actual: string): void;
|
|
33
|
+
onCleanup(fn: Cleanup): void;
|
|
34
|
+
onActivate(fn: () => void | Cleanup): void;
|
|
35
|
+
effect(fn: () => void | Cleanup): void;
|
|
36
|
+
child(component: string): RuntimeScope;
|
|
37
|
+
activate(): void;
|
|
38
|
+
dispose(): void;
|
|
39
|
+
}
|
|
40
|
+
export declare function createScope(options: ScopeOptions): RuntimeScope;
|
|
41
|
+
export declare function withScope<T>(scope: RuntimeScope, fn: () => T): T;
|
|
42
|
+
export declare function getScope(): Scope;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { subscribe, untracked } from "./reactive.js";
|
|
2
|
+
import { enqueue } from "./scheduler.js";
|
|
3
|
+
let currentScope = null;
|
|
4
|
+
let nextScopeId = 0;
|
|
5
|
+
function isPromise(value) {
|
|
6
|
+
return (value !== null &&
|
|
7
|
+
(typeof value === "object" || typeof value === "function") &&
|
|
8
|
+
typeof value.then === "function");
|
|
9
|
+
}
|
|
10
|
+
export class RuntimeScope {
|
|
11
|
+
id = ++nextScopeId;
|
|
12
|
+
component;
|
|
13
|
+
parent;
|
|
14
|
+
reporter;
|
|
15
|
+
path;
|
|
16
|
+
protocol;
|
|
17
|
+
build;
|
|
18
|
+
children = [];
|
|
19
|
+
cleanups = [];
|
|
20
|
+
activations = [];
|
|
21
|
+
effects = [];
|
|
22
|
+
controller;
|
|
23
|
+
live = true;
|
|
24
|
+
activated = false;
|
|
25
|
+
jobReporter = (code, actual) => {
|
|
26
|
+
this.report(code, "update", actual);
|
|
27
|
+
};
|
|
28
|
+
root() {
|
|
29
|
+
return this.parent?.root() ?? this;
|
|
30
|
+
}
|
|
31
|
+
constructor(options) {
|
|
32
|
+
this.component = options.component;
|
|
33
|
+
this.parent = options.parent;
|
|
34
|
+
this.reporter = options.reporter ?? options.parent?.reporter;
|
|
35
|
+
this.path = options.path ?? options.parent?.path ?? "";
|
|
36
|
+
this.protocol = options.protocol ?? options.parent?.protocol ?? "zudo-react.v1";
|
|
37
|
+
this.build = options.build ?? options.parent?.build ?? "";
|
|
38
|
+
this.parent?.children.push(this);
|
|
39
|
+
}
|
|
40
|
+
get active() {
|
|
41
|
+
return this.live;
|
|
42
|
+
}
|
|
43
|
+
get isActivated() {
|
|
44
|
+
return this.activated;
|
|
45
|
+
}
|
|
46
|
+
get abortSignal() {
|
|
47
|
+
this.controller ??= new AbortController();
|
|
48
|
+
if (!this.live && !this.controller.signal.aborted)
|
|
49
|
+
this.controller.abort();
|
|
50
|
+
return this.controller.signal;
|
|
51
|
+
}
|
|
52
|
+
ensureSetup() {
|
|
53
|
+
if (!this.live || this.activated || currentScope !== this)
|
|
54
|
+
throw new Error("ZR_SCOPE_SETUP: registration requires active setup");
|
|
55
|
+
}
|
|
56
|
+
report(code, phase, actual) {
|
|
57
|
+
const stack = [];
|
|
58
|
+
for (let scope = this; scope; scope = scope.parent)
|
|
59
|
+
stack.unshift(scope.component);
|
|
60
|
+
try {
|
|
61
|
+
this.reporter?.({
|
|
62
|
+
code,
|
|
63
|
+
phase,
|
|
64
|
+
component: this.component,
|
|
65
|
+
componentStack: stack,
|
|
66
|
+
path: this.path,
|
|
67
|
+
expected: "",
|
|
68
|
+
actual,
|
|
69
|
+
protocol: this.protocol,
|
|
70
|
+
build: this.build,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
/* Reporter failures must not stop resource cleanup. */
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
onCleanup(fn) {
|
|
78
|
+
this.ensureSetup();
|
|
79
|
+
this.cleanups.push(fn);
|
|
80
|
+
}
|
|
81
|
+
onActivate(fn) {
|
|
82
|
+
this.ensureSetup();
|
|
83
|
+
this.activations.push(fn);
|
|
84
|
+
}
|
|
85
|
+
effect(fn) {
|
|
86
|
+
this.ensureSetup();
|
|
87
|
+
let cleanup;
|
|
88
|
+
const subscription = subscribe(() => {
|
|
89
|
+
if (cleanup) {
|
|
90
|
+
try {
|
|
91
|
+
const result = untracked(cleanup);
|
|
92
|
+
if (isPromise(result))
|
|
93
|
+
this.report("ZR_ASYNC_CLEANUP", "cleanup", "effect cleanup returned a promise");
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
this.report("ZR_EFFECT_CLEANUP", "cleanup", String(error));
|
|
97
|
+
}
|
|
98
|
+
cleanup = undefined;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
const result = fn();
|
|
102
|
+
if (isPromise(result))
|
|
103
|
+
this.report("ZR_ASYNC_CLEANUP", "update", "effect returned a promise");
|
|
104
|
+
else if (typeof result === "function")
|
|
105
|
+
cleanup = result;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
this.report("ZR_EFFECT_ERROR", "update", String(error));
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
phase: "effect",
|
|
112
|
+
id: `${this.component}:effect:${this.id}:${this.effects.length}`,
|
|
113
|
+
active: () => this.live && this.activated,
|
|
114
|
+
report: this.root().jobReporter,
|
|
115
|
+
});
|
|
116
|
+
const job = {
|
|
117
|
+
id: subscription.id,
|
|
118
|
+
phase: "effect",
|
|
119
|
+
active: () => this.live && this.activated,
|
|
120
|
+
run: () => subscription.run(),
|
|
121
|
+
report: this.root().jobReporter,
|
|
122
|
+
};
|
|
123
|
+
this.effects.push({
|
|
124
|
+
start: () => enqueue(job),
|
|
125
|
+
dispose: () => {
|
|
126
|
+
subscription.dispose();
|
|
127
|
+
if (cleanup) {
|
|
128
|
+
try {
|
|
129
|
+
const result = untracked(cleanup);
|
|
130
|
+
if (isPromise(result))
|
|
131
|
+
this.report("ZR_ASYNC_CLEANUP", "cleanup", "effect cleanup returned a promise");
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
this.report("ZR_EFFECT_CLEANUP", "cleanup", String(error));
|
|
135
|
+
}
|
|
136
|
+
cleanup = undefined;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
child(component) {
|
|
142
|
+
if (!this.live)
|
|
143
|
+
throw new Error("ZR_SCOPE_DISPOSED");
|
|
144
|
+
return new RuntimeScope({ component, parent: this });
|
|
145
|
+
}
|
|
146
|
+
activate() {
|
|
147
|
+
if (!this.live || this.activated)
|
|
148
|
+
return;
|
|
149
|
+
try {
|
|
150
|
+
for (const child of this.children)
|
|
151
|
+
child.activate();
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
this.dispose();
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
this.activated = true;
|
|
158
|
+
for (const fn of this.activations) {
|
|
159
|
+
try {
|
|
160
|
+
const result = fn();
|
|
161
|
+
if (isPromise(result))
|
|
162
|
+
throw new Error("ZR_ASYNC_CLEANUP: activation returned a promise");
|
|
163
|
+
if (typeof result === "function")
|
|
164
|
+
this.cleanups.push(result);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
this.report("ZR_ACTIVATION_ERROR", "activation", String(error));
|
|
168
|
+
this.dispose();
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
for (const effect of this.effects)
|
|
173
|
+
effect.start();
|
|
174
|
+
}
|
|
175
|
+
dispose() {
|
|
176
|
+
if (!this.live)
|
|
177
|
+
return;
|
|
178
|
+
this.live = false;
|
|
179
|
+
this.controller?.abort();
|
|
180
|
+
for (const child of [...this.children].reverse())
|
|
181
|
+
child.dispose();
|
|
182
|
+
this.children.length = 0;
|
|
183
|
+
for (const effect of this.effects)
|
|
184
|
+
effect.dispose();
|
|
185
|
+
this.effects.length = 0;
|
|
186
|
+
for (const cleanup of [...this.cleanups].reverse()) {
|
|
187
|
+
try {
|
|
188
|
+
const result = untracked(cleanup);
|
|
189
|
+
if (isPromise(result))
|
|
190
|
+
this.report("ZR_ASYNC_CLEANUP", "cleanup", "cleanup returned a promise");
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
this.report("ZR_CLEANUP_ERROR", "cleanup", String(error));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
this.cleanups.length = 0;
|
|
197
|
+
this.activations.length = 0;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
export function createScope(options) {
|
|
201
|
+
return new RuntimeScope(options);
|
|
202
|
+
}
|
|
203
|
+
export function withScope(scope, fn) {
|
|
204
|
+
if (!scope.active)
|
|
205
|
+
throw new Error("ZR_SCOPE_DISPOSED");
|
|
206
|
+
const previous = currentScope;
|
|
207
|
+
currentScope = scope;
|
|
208
|
+
try {
|
|
209
|
+
return fn();
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
currentScope = previous;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
export function getScope() {
|
|
216
|
+
if (!currentScope || !currentScope.active || currentScope.isActivated)
|
|
217
|
+
throw new Error("ZR_NO_SCOPE: getScope requires synchronous setup");
|
|
218
|
+
return currentScope;
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=scope.js.map
|