@takazudo/zfb 2.22.1 → 3.0.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 +5 -9
- package/dist/config.d.ts +62 -19
- 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 +23 -77
- package/dist/runtime.js +149 -320
- 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 +909 -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 +203 -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 +537 -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 +14 -0
- package/dist/zudo-react/structure.js +35 -0
- package/dist/zudo-react/structure.js.map +1 -0
- package/package.json +28 -24
|
@@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D,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,UAAU,WAAW,CAAC,OAAqB;IAC/C,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AACD,MAAM,UAAU,SAAS,CAAI,KAAmB,EAAE,EAAW;IAC3D,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,YAAY,CAAC;IAC9B,YAAY,GAAG,KAAK,CAAC;IACrB,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;YAAS,CAAC;QACT,YAAY,GAAG,QAAQ,CAAC;IAC1B,CAAC;AACH,CAAC;AACD,MAAM,UAAU,QAAQ;IACtB,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,CAAC,MAAM,IAAI,YAAY,CAAC,WAAW;QACnE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { subscribe, untracked, type Subscription } from \"./reactive.js\";\nimport { enqueue, type Job } from \"./scheduler.js\";\nimport type { Cleanup, Diagnostic, Reporter, Scope } from \"./index.js\";\n\nlet currentScope: RuntimeScope | null = null;\nlet nextScopeId = 0;\n\nfunction isPromise(value: unknown): value is PromiseLike<unknown> {\n return (\n value !== null &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n typeof (value as { then?: unknown }).then === \"function\"\n );\n}\n\nexport interface ScopeOptions {\n component: string;\n reporter?: Reporter;\n parent?: RuntimeScope;\n path?: string;\n protocol?: string;\n build?: string;\n}\n\nexport class RuntimeScope implements Scope {\n readonly id = ++nextScopeId;\n readonly component: string;\n readonly parent: RuntimeScope | undefined;\n private readonly reporter: Reporter | undefined;\n private readonly path: string;\n private readonly protocol: string;\n private readonly build: string;\n private readonly children: RuntimeScope[] = [];\n private readonly cleanups: Cleanup[] = [];\n private readonly activations: Array<() => void | Cleanup> = [];\n private readonly effects: Array<{ start: () => void; dispose: () => void }> = [];\n private controller: AbortController | undefined;\n private live = true;\n private activated = false;\n private readonly jobReporter = (code: string, actual: string): void => {\n this.report(code, \"update\", actual);\n };\n private root(): RuntimeScope {\n return this.parent?.root() ?? this;\n }\n\n constructor(options: ScopeOptions) {\n this.component = options.component;\n this.parent = options.parent;\n this.reporter = options.reporter ?? options.parent?.reporter;\n this.path = options.path ?? options.parent?.path ?? \"\";\n this.protocol = options.protocol ?? options.parent?.protocol ?? \"zudo-react.v1\";\n this.build = options.build ?? options.parent?.build ?? \"\";\n this.parent?.children.push(this);\n }\n get active(): boolean {\n return this.live;\n }\n get isActivated(): boolean {\n return this.activated;\n }\n get abortSignal(): AbortSignal {\n this.controller ??= new AbortController();\n if (!this.live && !this.controller.signal.aborted) this.controller.abort();\n return this.controller.signal;\n }\n private ensureSetup(): void {\n if (!this.live || this.activated || currentScope !== this)\n throw new Error(\"ZR_SCOPE_SETUP: registration requires active setup\");\n }\n report(code: string, phase: Diagnostic[\"phase\"], actual: string): void {\n const stack: string[] = [];\n for (let scope: RuntimeScope | undefined = this; scope; scope = scope.parent)\n stack.unshift(scope.component);\n try {\n this.reporter?.({\n code,\n phase,\n component: this.component,\n componentStack: stack,\n path: this.path,\n expected: \"\",\n actual,\n protocol: this.protocol,\n build: this.build,\n });\n } catch {\n /* Reporter failures must not stop resource cleanup. */\n }\n }\n onCleanup(fn: Cleanup): void {\n this.ensureSetup();\n this.cleanups.push(fn);\n }\n onActivate(fn: () => void | Cleanup): void {\n this.ensureSetup();\n this.activations.push(fn);\n }\n effect(fn: () => void | Cleanup): void {\n this.ensureSetup();\n let cleanup: Cleanup | undefined;\n const subscription: Subscription = subscribe(\n () => {\n if (cleanup) {\n try {\n const result: unknown = untracked(cleanup);\n if (isPromise(result))\n this.report(\"ZR_ASYNC_CLEANUP\", \"cleanup\", \"effect cleanup returned a promise\");\n } catch (error) {\n this.report(\"ZR_EFFECT_CLEANUP\", \"cleanup\", String(error));\n }\n cleanup = undefined;\n }\n try {\n const result = fn();\n if (isPromise(result))\n this.report(\"ZR_ASYNC_CLEANUP\", \"update\", \"effect returned a promise\");\n else if (typeof result === \"function\") cleanup = result;\n } catch (error) {\n this.report(\"ZR_EFFECT_ERROR\", \"update\", String(error));\n }\n },\n {\n phase: \"effect\",\n id: `${this.component}:effect:${this.id}:${this.effects.length}`,\n active: () => this.live && this.activated,\n report: this.root().jobReporter,\n },\n );\n const job: Job = {\n id: subscription.id,\n phase: \"effect\",\n active: () => this.live && this.activated,\n run: () => subscription.run(),\n report: this.root().jobReporter,\n };\n this.effects.push({\n start: () => enqueue(job),\n dispose: () => {\n subscription.dispose();\n if (cleanup) {\n try {\n const result: unknown = untracked(cleanup);\n if (isPromise(result))\n this.report(\"ZR_ASYNC_CLEANUP\", \"cleanup\", \"effect cleanup returned a promise\");\n } catch (error) {\n this.report(\"ZR_EFFECT_CLEANUP\", \"cleanup\", String(error));\n }\n cleanup = undefined;\n }\n },\n });\n }\n child(component: string): RuntimeScope {\n if (!this.live) throw new Error(\"ZR_SCOPE_DISPOSED\");\n return new RuntimeScope({ component, parent: this });\n }\n activate(): void {\n if (!this.live || this.activated) return;\n try {\n for (const child of this.children) child.activate();\n } catch (error) {\n this.dispose();\n throw error;\n }\n this.activated = true;\n for (const fn of this.activations) {\n try {\n const result = fn();\n if (isPromise(result)) throw new Error(\"ZR_ASYNC_CLEANUP: activation returned a promise\");\n if (typeof result === \"function\") this.cleanups.push(result);\n } catch (error) {\n this.report(\"ZR_ACTIVATION_ERROR\", \"activation\", String(error));\n this.dispose();\n throw error;\n }\n }\n for (const effect of this.effects) effect.start();\n }\n dispose(): void {\n if (!this.live) return;\n this.live = false;\n this.controller?.abort();\n for (const child of [...this.children].reverse()) child.dispose();\n this.children.length = 0;\n for (const effect of this.effects) effect.dispose();\n this.effects.length = 0;\n for (const cleanup of [...this.cleanups].reverse()) {\n try {\n const result: unknown = untracked(cleanup);\n if (isPromise(result))\n this.report(\"ZR_ASYNC_CLEANUP\", \"cleanup\", \"cleanup returned a promise\");\n } catch (error) {\n this.report(\"ZR_CLEANUP_ERROR\", \"cleanup\", String(error));\n }\n }\n this.cleanups.length = 0;\n this.activations.length = 0;\n }\n}\n\nexport function createScope(options: ScopeOptions): RuntimeScope {\n return new RuntimeScope(options);\n}\nexport function withScope<T>(scope: RuntimeScope, fn: () => T): T {\n if (!scope.active) throw new Error(\"ZR_SCOPE_DISPOSED\");\n const previous = currentScope;\n currentScope = scope;\n try {\n return fn();\n } finally {\n currentScope = previous;\n }\n}\nexport function getScope(): Scope {\n if (!currentScope || !currentScope.active || currentScope.isActivated)\n throw new Error(\"ZR_NO_SCOPE: getScope requires synchronous setup\");\n return currentScope;\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Child, Description } from "./description.js";
|
|
2
|
+
import type { IslandIdentity } from "./index.js";
|
|
3
|
+
export { serializeProps } from "./props-transport.js";
|
|
4
|
+
export interface RenderOptions {
|
|
5
|
+
island?: IslandIdentity | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface IslandOptions {
|
|
8
|
+
identity: IslandIdentity;
|
|
9
|
+
when?: "load" | "idle" | "visible" | "media" | undefined;
|
|
10
|
+
media?: string | undefined;
|
|
11
|
+
skipSsr?: boolean | undefined;
|
|
12
|
+
fallback?: Child;
|
|
13
|
+
}
|
|
14
|
+
export declare function islandRoot(child: Description, options: IslandOptions): Description;
|
|
15
|
+
export declare function renderToString(node: Child, options?: RenderOptions): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createDescription } from "./description.js";
|
|
2
|
+
import { islandRootType } from "./island-root-type.js";
|
|
3
|
+
import { renderHtml } from "./render-html.js";
|
|
4
|
+
export { serializeProps } from "./props-transport.js";
|
|
5
|
+
export function islandRoot(child, options) {
|
|
6
|
+
return createDescription(islandRootType, { child, options });
|
|
7
|
+
}
|
|
8
|
+
export function renderToString(node, options = {}) {
|
|
9
|
+
return renderHtml(node, options);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/zudo-react/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAYtD,MAAM,UAAU,UAAU,CAAC,KAAkB,EAAE,OAAsB;IACnE,OAAO,iBAAiB,CAAC,cAAuB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AACxE,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,IAAW,EAAE,UAAyB,EAAE;IACrE,OAAO,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import type { Child, Description } from \"./description.js\";\nimport type { IslandIdentity } from \"./index.js\";\nimport { createDescription } from \"./description.js\";\nimport { islandRootType } from \"./island-root-type.js\";\nimport { renderHtml } from \"./render-html.js\";\n\nexport { serializeProps } from \"./props-transport.js\";\n\nexport interface RenderOptions {\n island?: IslandIdentity | undefined;\n}\nexport interface IslandOptions {\n identity: IslandIdentity;\n when?: \"load\" | \"idle\" | \"visible\" | \"media\" | undefined;\n media?: string | undefined;\n skipSsr?: boolean | undefined;\n fallback?: Child;\n}\nexport function islandRoot(child: Description, options: IslandOptions): Description {\n return createDescription(islandRootType as never, { child, options });\n}\nexport function renderToString(node: Child, options: RenderOptions = {}): string {\n return renderHtml(node, options);\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Child, type Description, type Key } from "./description.js";
|
|
2
|
+
import type { ReadonlySignal } from "./reactive-types.js";
|
|
3
|
+
import type { ShowProps, ForProps } from "./index.js";
|
|
4
|
+
export declare function Show(props: ShowProps): Description;
|
|
5
|
+
export declare function For<T>(props: ForProps<T>): Description;
|
|
6
|
+
export declare function showProps(description: Description): ShowProps;
|
|
7
|
+
export declare function forProps<T>(description: Description): ForProps<T>;
|
|
8
|
+
export declare function keyed<T>(items: readonly T[], by: (item: T) => Key, path: string): Key[];
|
|
9
|
+
export declare function keyPayload(key: Key): string;
|
|
10
|
+
export declare function view<T>(initial: T): {
|
|
11
|
+
readonly value: ReadonlySignal<T>;
|
|
12
|
+
write(next: T): void;
|
|
13
|
+
};
|
|
14
|
+
export type Factory = () => Child;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createDescription } from "./description.js";
|
|
2
|
+
import { computed, signal } from "./reactive.js";
|
|
3
|
+
export function Show(props) {
|
|
4
|
+
return createDescription(Show, props);
|
|
5
|
+
}
|
|
6
|
+
export function For(props) {
|
|
7
|
+
return createDescription(For, props);
|
|
8
|
+
}
|
|
9
|
+
export function showProps(description) {
|
|
10
|
+
return description.props;
|
|
11
|
+
}
|
|
12
|
+
export function forProps(description) {
|
|
13
|
+
return description.props;
|
|
14
|
+
}
|
|
15
|
+
export function keyed(items, by, path) {
|
|
16
|
+
const seen = new Set();
|
|
17
|
+
return items.map((item) => {
|
|
18
|
+
const key = by(item);
|
|
19
|
+
if (typeof key !== "string" && !(typeof key === "number" && Number.isFinite(key)))
|
|
20
|
+
throw new TypeError(`ZR_KEY_TYPE: For at ${path}, key ${String(key)}`);
|
|
21
|
+
if (seen.has(key))
|
|
22
|
+
throw new TypeError(`ZR_DUPLICATE_KEY: For at ${path}, key ${String(key)}`);
|
|
23
|
+
seen.add(key);
|
|
24
|
+
return key;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export function keyPayload(key) {
|
|
28
|
+
const bytes = new TextEncoder().encode(String(key));
|
|
29
|
+
return `${typeof key === "number" ? "n" : "s"}${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
30
|
+
}
|
|
31
|
+
export function view(initial) {
|
|
32
|
+
const source = signal(initial);
|
|
33
|
+
return { value: computed(() => source.value), write: (next) => (source.value = next) };
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=structure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structure.js","sourceRoot":"","sources":["../../src/zudo-react/structure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA0C,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIjD,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,OAAO,iBAAiB,CAAC,IAAI,EAAE,KAA2C,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,UAAU,GAAG,CAAI,KAAkB;IACvC,OAAO,iBAAiB,CAAC,GAAG,EAAE,KAA2C,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,WAAwB;IAChD,OAAO,WAAW,CAAC,KAA6B,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAI,WAAwB;IAClD,OAAO,WAAW,CAAC,KAA+B,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,KAAK,CAAI,KAAmB,EAAE,EAAoB,EAAE,IAAY;IAC9E,MAAM,IAAI,GAAG,IAAI,GAAG,EAAO,CAAC;IAC5B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC/E,MAAM,IAAI,SAAS,CAAC,uBAAuB,IAAI,SAAS,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzE,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,4BAA4B,IAAI,SAAS,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC/F,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAQ;IACjC,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACpD,OAAO,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CACzE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CACnC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;AACf,CAAC;AAED,MAAM,UAAU,IAAI,CAAI,OAAU;IAChC,MAAM,MAAM,GAAc,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1C,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC;AACzF,CAAC","sourcesContent":["import { createDescription, type Child, type Description, type Key } from \"./description.js\";\nimport { computed, signal } from \"./reactive.js\";\nimport type { ReadonlySignal, Signal } from \"./reactive-types.js\";\nimport type { ShowProps, ForProps } from \"./index.js\";\n\nexport function Show(props: ShowProps): Description {\n return createDescription(Show, props as unknown as Record<string, unknown>);\n}\n\nexport function For<T>(props: ForProps<T>): Description {\n return createDescription(For, props as unknown as Record<string, unknown>);\n}\n\nexport function showProps(description: Description): ShowProps {\n return description.props as unknown as ShowProps;\n}\n\nexport function forProps<T>(description: Description): ForProps<T> {\n return description.props as unknown as ForProps<T>;\n}\n\nexport function keyed<T>(items: readonly T[], by: (item: T) => Key, path: string): Key[] {\n const seen = new Set<Key>();\n return items.map((item) => {\n const key = by(item);\n if (typeof key !== \"string\" && !(typeof key === \"number\" && Number.isFinite(key)))\n throw new TypeError(`ZR_KEY_TYPE: For at ${path}, key ${String(key)}`);\n if (seen.has(key)) throw new TypeError(`ZR_DUPLICATE_KEY: For at ${path}, key ${String(key)}`);\n seen.add(key);\n return key;\n });\n}\n\nexport function keyPayload(key: Key): string {\n const bytes = new TextEncoder().encode(String(key));\n return `${typeof key === \"number\" ? \"n\" : \"s\"}${Array.from(bytes, (byte) =>\n byte.toString(16).padStart(2, \"0\"),\n ).join(\"\")}`;\n}\n\nexport function view<T>(initial: T): { readonly value: ReadonlySignal<T>; write(next: T): void } {\n const source: Signal<T> = signal(initial);\n return { value: computed(() => source.value), write: (next) => (source.value = next) };\n}\n\nexport type Factory = () => Child;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takazudo/zfb",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Content-site engine on the web's Request/Response model — prerender to static HTML, serve on Cloudflare Workers, or run as a local content server inside your app. One Rust binary. SDK with islands, content collections, pagination, and config helpers.",
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
"islands",
|
|
12
12
|
"mdx",
|
|
13
13
|
"content-collections",
|
|
14
|
-
"preact",
|
|
15
|
-
"react",
|
|
16
14
|
"rust"
|
|
17
15
|
],
|
|
18
16
|
"license": "MIT",
|
|
@@ -61,7 +59,27 @@
|
|
|
61
59
|
"types": "./dist/slugify.d.ts",
|
|
62
60
|
"default": "./dist/slugify.js"
|
|
63
61
|
},
|
|
64
|
-
"./package.json": "./package.json"
|
|
62
|
+
"./package.json": "./package.json",
|
|
63
|
+
"./zudo-react": {
|
|
64
|
+
"types": "./dist/zudo-react/index.d.ts",
|
|
65
|
+
"default": "./dist/zudo-react/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./zudo-react/jsx-runtime": {
|
|
68
|
+
"types": "./dist/zudo-react/jsx-runtime.d.ts",
|
|
69
|
+
"default": "./dist/zudo-react/jsx-runtime.js"
|
|
70
|
+
},
|
|
71
|
+
"./zudo-react/jsx-dev-runtime": {
|
|
72
|
+
"types": "./dist/zudo-react/jsx-dev-runtime.d.ts",
|
|
73
|
+
"default": "./dist/zudo-react/jsx-dev-runtime.js"
|
|
74
|
+
},
|
|
75
|
+
"./zudo-react/server": {
|
|
76
|
+
"types": "./dist/zudo-react/server.d.ts",
|
|
77
|
+
"default": "./dist/zudo-react/server.js"
|
|
78
|
+
},
|
|
79
|
+
"./zudo-react/client": {
|
|
80
|
+
"types": "./dist/zudo-react/client.d.ts",
|
|
81
|
+
"default": "./dist/zudo-react/client.js"
|
|
82
|
+
}
|
|
65
83
|
},
|
|
66
84
|
"bin": {
|
|
67
85
|
"zfb": "./bin/zfb.mjs"
|
|
@@ -74,11 +92,11 @@
|
|
|
74
92
|
"LICENSE"
|
|
75
93
|
],
|
|
76
94
|
"optionalDependencies": {
|
|
77
|
-
"@takazudo/zfb-darwin-arm64": "
|
|
78
|
-
"@takazudo/zfb-darwin-x64": "
|
|
79
|
-
"@takazudo/zfb-linux-arm64-gnu": "
|
|
80
|
-
"@takazudo/zfb-linux-x64-gnu": "
|
|
81
|
-
"@takazudo/zfb-win32-x64-msvc": "
|
|
95
|
+
"@takazudo/zfb-darwin-arm64": "3.0.0",
|
|
96
|
+
"@takazudo/zfb-darwin-x64": "3.0.0",
|
|
97
|
+
"@takazudo/zfb-linux-arm64-gnu": "3.0.0",
|
|
98
|
+
"@takazudo/zfb-linux-x64-gnu": "3.0.0",
|
|
99
|
+
"@takazudo/zfb-win32-x64-msvc": "3.0.0"
|
|
82
100
|
},
|
|
83
101
|
"publishConfig": {
|
|
84
102
|
"access": "public"
|
|
@@ -87,29 +105,15 @@
|
|
|
87
105
|
"node": ">=22.0.0",
|
|
88
106
|
"pnpm": ">=10.0.0"
|
|
89
107
|
},
|
|
90
|
-
"peerDependencies": {
|
|
91
|
-
"react": "^19.2.3"
|
|
92
|
-
},
|
|
93
|
-
"peerDependenciesMeta": {
|
|
94
|
-
"react": {
|
|
95
|
-
"optional": true
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
108
|
"devDependencies": {
|
|
99
109
|
"@types/node": "^22.0.0",
|
|
100
|
-
"@types/react": "^19.0.0",
|
|
101
|
-
"@types/react-dom": "^19.2.4",
|
|
102
110
|
"happy-dom": "^15.7.4",
|
|
103
|
-
"preact": "^10.29.0",
|
|
104
|
-
"preact-render-to-string": "^6.6.7",
|
|
105
|
-
"react": "^19.2.3",
|
|
106
|
-
"react-dom": "19.2.6",
|
|
107
111
|
"typescript": "^5.9.0",
|
|
108
112
|
"vitest": "^2.1.9"
|
|
109
113
|
},
|
|
110
114
|
"scripts": {
|
|
111
115
|
"build": "tsc",
|
|
112
|
-
"test": "vitest run && tsc -p tsconfig.
|
|
116
|
+
"test": "vitest run && tsc -p tsconfig.zudo-react-fixture.json && tsc -p tsconfig.zudo-react-dev-fixture.json && tsc -p tsconfig.zudo-react-sdk-fixture.json",
|
|
113
117
|
"test:watch": "vitest",
|
|
114
118
|
"typecheck": "tsc --noEmit"
|
|
115
119
|
}
|