svelte-effect-runtime 1.6.2 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/client-BeOE81fW.js +577 -0
- package/.dist/chunks/client-BeOE81fW.js.map +1 -0
- package/.dist/chunks/descriptors-CU2g4U_i.js +36 -0
- package/.dist/chunks/descriptors-CU2g4U_i.js.map +1 -0
- package/.dist/chunks/dispatcher-BSg2-ttN.js +339 -0
- package/.dist/chunks/dispatcher-BSg2-ttN.js.map +1 -0
- package/.dist/chunks/preprocess-BZyUYWY7.js +430 -0
- package/.dist/chunks/preprocess-BZyUYWY7.js.map +1 -0
- package/.dist/chunks/transform-BtlxgJrg.js +836 -0
- package/.dist/chunks/transform-BtlxgJrg.js.map +1 -0
- package/.dist/detect.d.ts +34 -0
- package/.dist/detect.js +56 -0
- package/.dist/detect.js.map +1 -0
- package/.dist/dispatcher/deps.d.ts +14 -0
- package/.dist/dispatcher/fibers.d.ts +52 -0
- package/.dist/dispatcher/index.d.ts +138 -0
- package/.dist/dispatcher/types.d.ts +63 -0
- package/.dist/dispatcher.d.ts +2 -0
- package/.dist/dispatcher.js +2 -0
- package/.dist/error.d.ts +77 -0
- package/.dist/generators.d.ts +16 -0
- package/.dist/internal/descriptors.d.ts +17 -0
- package/.dist/internal/generators.d.ts +6 -0
- package/.dist/internal/generators.js +5 -0
- package/.dist/internal/remote-client.d.ts +6 -0
- package/.dist/internal/remote-client.js +2 -0
- package/.dist/internal/remote-server.d.ts +6 -0
- package/.dist/internal/remote-server.js +2 -0
- package/.dist/markup/promise.d.ts +15 -0
- package/.dist/markup/promise.js +26 -0
- package/.dist/markup/promise.js.map +1 -0
- package/.dist/markup/run.d.ts +12 -0
- package/.dist/markup/run.js +21 -0
- package/.dist/markup/run.js.map +1 -0
- package/.dist/markup/transform/apply.d.ts +6 -0
- package/.dist/markup/transform/classify.d.ts +15 -0
- package/.dist/markup/transform/constants.d.ts +5 -0
- package/.dist/markup/transform/emit.d.ts +12 -0
- package/.dist/markup/transform/expressions.d.ts +39 -0
- package/.dist/markup/transform/index.d.ts +19 -0
- package/.dist/markup/transform/scan.d.ts +8 -0
- package/.dist/markup/transform/types.d.ts +64 -0
- package/.dist/markup/transform.d.ts +1 -0
- package/.dist/markup/transform.js +2 -0
- package/.dist/markup/value.d.ts +20 -0
- package/.dist/markup/value.js +32 -0
- package/.dist/markup/value.js.map +1 -0
- package/.dist/mod.d.ts +186 -0
- package/.dist/mod.js +190 -0
- package/.dist/mod.js.map +1 -0
- package/.dist/preprocess/ast.d.ts +51 -0
- package/.dist/preprocess/imports.d.ts +22 -0
- package/.dist/preprocess/index.d.ts +21 -0
- package/.dist/preprocess/lower.d.ts +12 -0
- package/.dist/preprocess/runtime-block.d.ts +8 -0
- package/.dist/preprocess/source.d.ts +29 -0
- package/.dist/preprocess/types.d.ts +70 -0
- package/.dist/preprocess.d.ts +2 -0
- package/.dist/preprocess.js +3 -0
- package/.dist/remote/client/command.d.ts +17 -0
- package/.dist/remote/client/effect.d.ts +15 -0
- package/.dist/remote/client/failures.d.ts +57 -0
- package/.dist/remote/client/form-data.d.ts +8 -0
- package/.dist/remote/client/form-enhance.d.ts +9 -0
- package/.dist/remote/client/form-transport.d.ts +20 -0
- package/.dist/remote/client/form.d.ts +21 -0
- package/.dist/remote/client/index.d.ts +4 -0
- package/.dist/remote/client/query-result.d.ts +14 -0
- package/.dist/remote/client/query.d.ts +57 -0
- package/.dist/remote/client/responses.d.ts +28 -0
- package/.dist/remote/client/types.d.ts +83 -0
- package/.dist/remote/client/utils.d.ts +11 -0
- package/.dist/remote/client.d.ts +2 -0
- package/.dist/remote/client.js +2 -0
- package/.dist/remote/server.d.ts +66 -0
- package/.dist/remote/server.js +104 -0
- package/.dist/remote/server.js.map +1 -0
- package/.dist/remote/shared.d.ts +202 -0
- package/.dist/remote/shared.js +161 -0
- package/.dist/remote/shared.js.map +1 -0
- package/.dist/runtime/preprocess.d.ts +38 -0
- package/.dist/runtime/preprocess.js +54 -0
- package/.dist/runtime/preprocess.js.map +1 -0
- package/.dist/server/effects.d.ts +49 -0
- package/.dist/server/factories.d.ts +97 -0
- package/.dist/server/index.d.ts +3 -0
- package/.dist/server/invalid.d.ts +9 -0
- package/.dist/server/runtime.d.ts +66 -0
- package/.dist/server/schema.d.ts +42 -0
- package/.dist/server/types.d.ts +271 -0
- package/.dist/server/wrappers.d.ts +45 -0
- package/.dist/server.d.ts +2 -0
- package/.dist/server.js +527 -0
- package/.dist/server.js.map +1 -0
- package/.dist/vite.d.ts +42 -0
- package/.dist/vite.js +118 -0
- package/.dist/vite.js.map +1 -0
- package/README.md +2 -0
- package/package.json +66 -101
- package/dist/chunks/client-vV6UAwoP.js +0 -199
- package/dist/chunks/client-vV6UAwoP.js.map +0 -1
- package/dist/chunks/effect-Crj3S8Cg.js +0 -51
- package/dist/chunks/effect-Crj3S8Cg.js.map +0 -1
- package/dist/chunks/effect-compat-BhW0YPIs.js +0 -103
- package/dist/chunks/effect-compat-BhW0YPIs.js.map +0 -1
- package/dist/chunks/magic-string.es-BnGH-5YR.js +0 -1013
- package/dist/chunks/magic-string.es-BnGH-5YR.js.map +0 -1
- package/dist/chunks/markup-CkPUZIJt.js +0 -13390
- package/dist/chunks/markup-CkPUZIJt.js.map +0 -1
- package/dist/chunks/preprocess-BFePqOC6.js +0 -49
- package/dist/chunks/preprocess-BFePqOC6.js.map +0 -1
- package/dist/chunks/server-Dea1CJuY.js +0 -704
- package/dist/chunks/server-Dea1CJuY.js.map +0 -1
- package/dist/chunks/v3-D0c0MKPf.js +0 -1
- package/dist/chunks/v4-MMhHmzIG.js +0 -1
- package/dist/chunks/vite-BlUTKv2u.js +0 -152
- package/dist/chunks/vite-BlUTKv2u.js.map +0 -1
- package/dist/client.d.ts +0 -1
- package/dist/client.js +0 -2
- package/dist/effect.d.ts +0 -1
- package/dist/effect.js +0 -2
- package/dist/internal/app-server-shim.d.ts +0 -8
- package/dist/internal/effect-compat.d.ts +0 -21
- package/dist/internal/markup.d.ts +0 -11
- package/dist/internal/markup.js +0 -2
- package/dist/internal/remote-client.d.ts +0 -36
- package/dist/internal/remote-client.js +0 -527
- package/dist/internal/remote-client.js.map +0 -1
- package/dist/internal/remote-shared.d.ts +0 -186
- package/dist/internal/remote-shared.js +0 -122
- package/dist/internal/remote-shared.js.map +0 -1
- package/dist/internal/transform.d.ts +0 -18
- package/dist/internal/transform.js +0 -418
- package/dist/internal/transform.js.map +0 -1
- package/dist/language-server.d.ts +0 -9
- package/dist/language-server.js +0 -4
- package/dist/mod.d.ts +0 -22
- package/dist/mod.js +0 -3
- package/dist/preprocess.d.ts +0 -29
- package/dist/preprocess.js +0 -20
- package/dist/preprocess.js.map +0 -1
- package/dist/root-node.d.ts +0 -1
- package/dist/root-node.js +0 -63
- package/dist/root-node.js.map +0 -1
- package/dist/server.d.ts +0 -81
- package/dist/server.js +0 -85
- package/dist/server.js.map +0 -1
- package/dist/v3/client.d.ts +0 -117
- package/dist/v3/effect.d.ts +0 -17
- package/dist/v3/mod.d.ts +0 -27
- package/dist/v3/preprocess.d.ts +0 -28
- package/dist/v3/root-node.d.ts +0 -59
- package/dist/v3/server.d.ts +0 -297
- package/dist/v3/vite.d.ts +0 -46
- package/dist/v4/client.d.ts +0 -2
- package/dist/v4/effect.d.ts +0 -24
- package/dist/v4/effect.js +0 -19
- package/dist/v4/effect.js.map +0 -1
- package/dist/v4/mod.d.ts +0 -27
- package/dist/v4/mod.js +0 -3
- package/dist/v4/preprocess.d.ts +0 -34
- package/dist/v4/preprocess.js +0 -32
- package/dist/v4/preprocess.js.map +0 -1
- package/dist/v4/root-node.d.ts +0 -59
- package/dist/v4/root-node.js +0 -4
- package/dist/v4/server.d.ts +0 -340
- package/dist/v4/server.js +0 -71
- package/dist/v4/server.js.map +0 -1
- package/dist/v4/vite.d.ts +0 -34
- package/dist/v4/vite.js +0 -31
- package/dist/v4/vite.js.map +0 -1
- package/dist/vite.d.ts +0 -31
- package/dist/vite.js +0 -24
- package/dist/vite.js.map +0 -1
package/.dist/vite.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//#region src/vite.ts
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin for SvelteKit. The pre plugin rewrites server-side imports
|
|
4
|
+
* to the server entrypoint; the post plugin wraps SvelteKit's generated
|
|
5
|
+
* client remote exports in Effect-returning adapters.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { effect } from "svelte-effect-runtime";
|
|
10
|
+
* import { sveltekit } from "@sveltejs/kit/vite";
|
|
11
|
+
*
|
|
12
|
+
* export default defineConfig({ plugins: [effect(), sveltekit()] });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @since 2.0.0
|
|
16
|
+
* @param options - Optional configuration.
|
|
17
|
+
* @returns Vite plugins that integrate the runtime with SvelteKit.
|
|
18
|
+
*/
|
|
19
|
+
function effect(options) {
|
|
20
|
+
return [make_server_rewrite_plugin(), make_remote_client_wrapper_plugin(options)];
|
|
21
|
+
}
|
|
22
|
+
function make_server_rewrite_plugin() {
|
|
23
|
+
return {
|
|
24
|
+
name: "svelte-effect-runtime:server-imports",
|
|
25
|
+
enforce: "pre",
|
|
26
|
+
config() {
|
|
27
|
+
return { optimizeDeps: { exclude: ["svelte-effect-runtime"] } };
|
|
28
|
+
},
|
|
29
|
+
transform(code, id) {
|
|
30
|
+
if (!is_server_runtime_module(id)) return;
|
|
31
|
+
const rewritten = code.replace(/from\s+["']svelte-effect-runtime["']/g, `from "svelte-effect-runtime/server"`).replace(/from\s+["']svelte-effect-runtime\/internal\/generators["']/g, `from "svelte-effect-runtime/server"`);
|
|
32
|
+
if (rewritten === code) return;
|
|
33
|
+
return {
|
|
34
|
+
code: rewritten,
|
|
35
|
+
map: null
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function make_remote_client_wrapper_plugin(options) {
|
|
41
|
+
return {
|
|
42
|
+
name: "svelte-effect-runtime:remote-client",
|
|
43
|
+
enforce: "post",
|
|
44
|
+
config() {
|
|
45
|
+
return { ssr: { noExternal: ["svelte-effect-runtime"] } };
|
|
46
|
+
},
|
|
47
|
+
configResolved(config) {
|
|
48
|
+
const no_external = config.ssr.noExternal;
|
|
49
|
+
if (no_external === true) return;
|
|
50
|
+
if (Array.isArray(no_external)) {
|
|
51
|
+
if (!no_external.includes("svelte-effect-runtime")) no_external.push("svelte-effect-runtime");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
config.ssr.noExternal = [no_external, "svelte-effect-runtime"].filter((value) => value !== void 0);
|
|
55
|
+
},
|
|
56
|
+
transform(code, id) {
|
|
57
|
+
if (!is_remote_module(id) || !code.includes("__sveltekit/remote")) return;
|
|
58
|
+
const rewritten = rewrite_remote_client_exports(code, options);
|
|
59
|
+
if (rewritten === code) return;
|
|
60
|
+
return {
|
|
61
|
+
code: rewritten,
|
|
62
|
+
map: null
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function is_server_runtime_module(id) {
|
|
68
|
+
return id.endsWith(".server.ts") || id.endsWith(".remote.ts") || id.includes("hooks.server.");
|
|
69
|
+
}
|
|
70
|
+
function is_remote_module(id) {
|
|
71
|
+
return /\.(remote|remote\.[cm]?)\.[jt]s(?:\?.*)?$/.test(id) || id.includes(".remote.");
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Rewrites SvelteKit's generated client remote module from:
|
|
75
|
+
*
|
|
76
|
+
* `export const get_post = __remote.query("hash/get_post")`
|
|
77
|
+
*
|
|
78
|
+
* into an Effect-aware wrapper around the same native function.
|
|
79
|
+
*
|
|
80
|
+
* @since 2.0.0
|
|
81
|
+
* @param code - The generated client remote module code.
|
|
82
|
+
* @param options - Optional plugin options.
|
|
83
|
+
* @returns The rewritten module code.
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
function rewrite_remote_client_exports(code, options) {
|
|
87
|
+
const import_match = code.match(/import\s+\*\s+as\s+([A-Za-z_$][\w$]*)\s+from\s+["']__sveltekit\/remote["'];?/);
|
|
88
|
+
if (!import_match) return code;
|
|
89
|
+
const namespace = import_match[1];
|
|
90
|
+
const export_pattern = new RegExp(`export\\s+const\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*${namespace}\\.(query_batch|query_live|query|command|form|prerender)\\((["'][^"']+["'])\\);?`, "g");
|
|
91
|
+
let replaced_any = false;
|
|
92
|
+
const body = code.replace(export_pattern, (_match, name, type, id_literal) => {
|
|
93
|
+
replaced_any = true;
|
|
94
|
+
return make_remote_export(name, type, id_literal, namespace);
|
|
95
|
+
});
|
|
96
|
+
if (!replaced_any) return code;
|
|
97
|
+
const imports = [`import { app_dir, base } from "$app/paths/internal/client";`, `import { create_remote_query_adapter, create_remote_live_query_adapter, create_remote_command_adapter, create_remote_form_adapter } from "svelte-effect-runtime/internal/remote-client";`].join("\n");
|
|
98
|
+
const helpers = [`const __ser_remote_base = \`\${base}/\${app_dir}/remote\`;`, `function __ser_decode_payload(value) { return value; }`].join("\n");
|
|
99
|
+
const debug_line = options?.debug ? `console.log("[ser] remote client wrappers loaded");` : "";
|
|
100
|
+
const injected = [
|
|
101
|
+
import_match[0],
|
|
102
|
+
imports,
|
|
103
|
+
helpers,
|
|
104
|
+
debug_line
|
|
105
|
+
].filter(Boolean).join("\n");
|
|
106
|
+
return body.replace(import_match[0], injected);
|
|
107
|
+
}
|
|
108
|
+
function make_remote_export(name, type, id_literal, namespace) {
|
|
109
|
+
const native_call = `${namespace}.${type}(${id_literal})`;
|
|
110
|
+
if (type === "command") return `export const ${name} = create_remote_command_adapter(${native_call}, __ser_decode_payload);`;
|
|
111
|
+
if (type === "form") return `export const ${name} = create_remote_form_adapter(${native_call}, __ser_decode_payload, __ser_remote_base);`;
|
|
112
|
+
if (type === "query_live") return `export const ${name} = create_remote_live_query_adapter(${native_call}, __ser_decode_payload);`;
|
|
113
|
+
return `export const ${name} = create_remote_query_adapter(${native_call}, __ser_decode_payload);`;
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
export { effect, rewrite_remote_client_exports };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=vite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/vite.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\n\n/**\n * Options for the {@link effect} Vite plugin.\n *\n * @since 2.0.0\n */\nexport interface EffectOptions {\n /** Whether to emit debug logging in the generated remote client module. */\n debug?: boolean;\n}\n\n/**\n * Vite plugin for SvelteKit. The pre plugin rewrites server-side imports\n * to the server entrypoint; the post plugin wraps SvelteKit's generated\n * client remote exports in Effect-returning adapters.\n *\n * @example\n * ```ts\n * import { effect } from \"svelte-effect-runtime\";\n * import { sveltekit } from \"@sveltejs/kit/vite\";\n *\n * export default defineConfig({ plugins: [effect(), sveltekit()] });\n * ```\n *\n * @since 2.0.0\n * @param options - Optional configuration.\n * @returns Vite plugins that integrate the runtime with SvelteKit.\n */\nexport function effect(options?: EffectOptions): Plugin[] {\n return [\n make_server_rewrite_plugin(),\n make_remote_client_wrapper_plugin(options),\n ];\n}\n\nfunction make_server_rewrite_plugin(): Plugin {\n return {\n name: \"svelte-effect-runtime:server-imports\",\n enforce: \"pre\",\n\n config() {\n return { optimizeDeps: { exclude: [\"svelte-effect-runtime\"] } };\n },\n\n transform(code: string, id: string) {\n if (!is_server_runtime_module(id)) {\n return undefined;\n }\n\n const rewritten = code\n .replace(\n /from\\s+[\"']svelte-effect-runtime[\"']/g,\n `from \"svelte-effect-runtime/server\"`,\n )\n .replace(\n /from\\s+[\"']svelte-effect-runtime\\/internal\\/generators[\"']/g,\n `from \"svelte-effect-runtime/server\"`,\n );\n\n if (rewritten === code) {\n return undefined;\n }\n\n return { code: rewritten, map: null };\n },\n };\n}\n\nfunction make_remote_client_wrapper_plugin(options?: EffectOptions): Plugin {\n return {\n name: \"svelte-effect-runtime:remote-client\",\n enforce: \"post\",\n\n config() {\n return { ssr: { noExternal: [\"svelte-effect-runtime\"] } };\n },\n\n configResolved(config) {\n const no_external = config.ssr.noExternal;\n\n if (no_external === true) {\n return;\n }\n\n if (Array.isArray(no_external)) {\n if (!no_external.includes(\"svelte-effect-runtime\")) {\n no_external.push(\"svelte-effect-runtime\");\n }\n\n return;\n }\n\n config.ssr.noExternal = [\n no_external,\n \"svelte-effect-runtime\",\n ].filter((value): value is string | RegExp => value !== undefined);\n },\n\n transform(code: string, id: string) {\n if (!is_remote_module(id) || !code.includes(\"__sveltekit/remote\")) {\n return undefined;\n }\n\n const rewritten = rewrite_remote_client_exports(code, options);\n\n if (rewritten === code) {\n return undefined;\n }\n\n return { code: rewritten, map: null };\n },\n };\n}\n\nfunction is_server_runtime_module(id: string): boolean {\n return (\n id.endsWith(\".server.ts\") ||\n id.endsWith(\".remote.ts\") ||\n id.includes(\"hooks.server.\")\n );\n}\n\nfunction is_remote_module(id: string): boolean {\n return /\\.(remote|remote\\.[cm]?)\\.[jt]s(?:\\?.*)?$/.test(id) ||\n id.includes(\".remote.\");\n}\n\n/**\n * Rewrites SvelteKit's generated client remote module from:\n *\n * `export const get_post = __remote.query(\"hash/get_post\")`\n *\n * into an Effect-aware wrapper around the same native function.\n *\n * @since 2.0.0\n * @param code - The generated client remote module code.\n * @param options - Optional plugin options.\n * @returns The rewritten module code.\n * @internal\n */\nexport function rewrite_remote_client_exports(\n code: string,\n options?: EffectOptions,\n): string {\n const import_match = code.match(\n /import\\s+\\*\\s+as\\s+([A-Za-z_$][\\w$]*)\\s+from\\s+[\"']__sveltekit\\/remote[\"'];?/,\n );\n\n if (!import_match) {\n return code;\n }\n\n const namespace = import_match[1];\n const export_pattern = new RegExp(\n `export\\\\s+const\\\\s+([A-Za-z_$][\\\\w$]*)\\\\s*=\\\\s*${namespace}\\\\.(query_batch|query_live|query|command|form|prerender)\\\\(([\"'][^\"']+[\"'])\\\\);?`,\n \"g\",\n );\n\n let replaced_any = false;\n const body = code.replace(\n export_pattern,\n (_match, name, type, id_literal) => {\n replaced_any = true;\n\n return make_remote_export(name, type, id_literal, namespace);\n },\n );\n\n if (!replaced_any) {\n return code;\n }\n\n const imports = [\n `import { app_dir, base } from \"$app/paths/internal/client\";`,\n `import { create_remote_query_adapter, create_remote_live_query_adapter, create_remote_command_adapter, create_remote_form_adapter } from \"svelte-effect-runtime/internal/remote-client\";`,\n ].join(\"\\n\");\n\n const helpers = [\n `const __ser_remote_base = \\`\\${base}/\\${app_dir}/remote\\`;`,\n `function __ser_decode_payload(value) { return value; }`,\n ].join(\"\\n\");\n\n const debug_line = options?.debug\n ? `console.log(\"[ser] remote client wrappers loaded\");`\n : \"\";\n\n const injected = [\n import_match[0],\n imports,\n helpers,\n debug_line,\n ].filter(Boolean).join(\"\\n\");\n\n return body.replace(import_match[0], injected);\n}\n\nfunction make_remote_export(\n name: string,\n type: string,\n id_literal: string,\n namespace: string,\n): string {\n const native_call = `${namespace}.${type}(${id_literal})`;\n\n if (type === \"command\") {\n return `export const ${name} = create_remote_command_adapter(${native_call}, __ser_decode_payload);`;\n }\n\n if (type === \"form\") {\n return `export const ${name} = create_remote_form_adapter(${native_call}, __ser_decode_payload, __ser_remote_base);`;\n }\n\n if (type === \"query_live\") {\n return `export const ${name} = create_remote_live_query_adapter(${native_call}, __ser_decode_payload);`;\n }\n\n return `export const ${name} = create_remote_query_adapter(${native_call}, __ser_decode_payload);`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAAgB,OAAO,SAAmC;AACxD,QAAO,CACL,4BAA4B,EAC5B,kCAAkC,QAAQ,CAC3C;;AAGH,SAAS,6BAAqC;AAC5C,QAAO;EACL,MAAM;EACN,SAAS;EAET,SAAS;AACP,UAAO,EAAE,cAAc,EAAE,SAAS,CAAC,wBAAwB,EAAE,EAAE;;EAGjE,UAAU,MAAc,IAAY;AA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|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"types": "./dist/v4/server.d.ts",
|
|
68
|
-
"default": "./dist/v4/server.js"
|
|
69
|
-
},
|
|
70
|
-
"./language-server": {
|
|
71
|
-
"types": "./dist/language-server.d.ts",
|
|
72
|
-
"default": "./dist/language-server.js"
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
"scripts": {
|
|
76
|
-
"build": "deno task build",
|
|
77
|
-
"build:npm": "npm run build",
|
|
78
|
-
"check": "deno task check",
|
|
79
|
-
"clean": "deno task clean",
|
|
80
|
-
"smoke:v4": "deno task smoke:v4",
|
|
81
|
-
"test": "deno task test"
|
|
82
|
-
},
|
|
83
|
-
"peerDependencies": {
|
|
84
|
-
"@sveltejs/kit": "^2.0.0",
|
|
85
|
-
"@sveltejs/vite-plugin-svelte": "^6.0.0 || ^7.0.0",
|
|
86
|
-
"effect": "^3.0.0 || >=4.0.0-beta.0 <5",
|
|
87
|
-
"svelte": "^5.0.0",
|
|
88
|
-
"vite": "^7.0.0 || ^8.0.0"
|
|
89
|
-
},
|
|
90
|
-
"dependencies": {
|
|
91
|
-
"devalue": "^5.5.0",
|
|
92
|
-
"magic-string": "^0.30.21",
|
|
93
|
-
"typescript": "^5.9.3"
|
|
94
|
-
},
|
|
95
|
-
"devDependencies": {
|
|
96
|
-
"@types/node": "^24.6.1",
|
|
97
|
-
"@sveltejs/adapter-static": "^3.0.10",
|
|
98
|
-
"jsdom": "^26.1.0",
|
|
99
|
-
"rolldown": "^1.0.0-rc.13"
|
|
100
|
-
}
|
|
101
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "svelte-effect-runtime",
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
|
+
"description": "Core module that houses the Vite plugin to enable effectful execution.",
|
|
5
|
+
"license": "BSD-3-Clause",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/usebarekey/svelte-effect-runtime.git"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
".dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./.dist/mod.d.ts",
|
|
21
|
+
"default": "./.dist/mod.js"
|
|
22
|
+
},
|
|
23
|
+
"./server": {
|
|
24
|
+
"types": "./.dist/server.d.ts",
|
|
25
|
+
"default": "./.dist/server.js"
|
|
26
|
+
},
|
|
27
|
+
"./runtime/preprocess": {
|
|
28
|
+
"types": "./.dist/runtime/preprocess.d.ts",
|
|
29
|
+
"default": "./.dist/runtime/preprocess.js"
|
|
30
|
+
},
|
|
31
|
+
"./internal/generators": {
|
|
32
|
+
"types": "./.dist/internal/generators.d.ts",
|
|
33
|
+
"default": "./.dist/internal/generators.js"
|
|
34
|
+
},
|
|
35
|
+
"./internal/remote-client": {
|
|
36
|
+
"types": "./.dist/internal/remote-client.d.ts",
|
|
37
|
+
"default": "./.dist/internal/remote-client.js"
|
|
38
|
+
},
|
|
39
|
+
"./internal/remote-server": {
|
|
40
|
+
"types": "./.dist/internal/remote-server.d.ts",
|
|
41
|
+
"default": "./.dist/internal/remote-server.js"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "deno task build",
|
|
46
|
+
"check": "deno task check",
|
|
47
|
+
"clean": "deno task clean",
|
|
48
|
+
"test": "deno task test"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@sveltejs/kit": "^2.0.0",
|
|
52
|
+
"@sveltejs/vite-plugin-svelte": "^6.0.0 || ^7.0.0",
|
|
53
|
+
"effect": "^4.0.0-beta",
|
|
54
|
+
"svelte": "^5.0.0",
|
|
55
|
+
"vite": "^7.0.0 || ^8.0.0"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"devalue": "^5.5.0",
|
|
59
|
+
"magic-string": "^0.30.21",
|
|
60
|
+
"typescript": "^5.9.3"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/node": "^24.6.1",
|
|
64
|
+
"rolldown": "^1.0.0-rc.13"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { REMOTE_ERROR_DECODER, create_remote_http_error, create_remote_transport_error, create_remote_validation_error, is_serialized_remote_failure_envelope } from "../internal/remote-shared.js";
|
|
2
|
-
import { n as exit_has_interrupts, t as create_async_effect } from "./effect-compat-BhW0YPIs.js";
|
|
3
|
-
import { Cause, Effect, Exit, Layer, ManagedRuntime } from "effect";
|
|
4
|
-
import { getContext, hasContext, onDestroy, setContext } from "svelte";
|
|
5
|
-
//#region v3/client.ts
|
|
6
|
-
const EFFECT_RUNTIME_CONTEXT = Symbol.for("svelte-effect-runtime/runtime");
|
|
7
|
-
let current_client_runtime = null;
|
|
8
|
-
function runtime_seed() {
|
|
9
|
-
return Layer.effectContext(Effect.context());
|
|
10
|
-
}
|
|
11
|
-
function pipe_client_runtime(...ops) {
|
|
12
|
-
if (ops.length === 0) return Layer.empty;
|
|
13
|
-
return ops.reduce((layer, op) => op(layer), runtime_seed());
|
|
14
|
-
}
|
|
15
|
-
function make_client_runtime(...ops) {
|
|
16
|
-
const layer = ops.length === 0 ? pipe_client_runtime() : pipe_client_runtime(...ops);
|
|
17
|
-
const runtime = track_client_runtime(ManagedRuntime.make(layer));
|
|
18
|
-
current_client_runtime?.dispose().catch(() => void 0);
|
|
19
|
-
current_client_runtime = runtime;
|
|
20
|
-
if (is_component_context_available()) return provide_effect_runtime(runtime, { disposeOnDestroy: true });
|
|
21
|
-
return runtime;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Build or compose the shared client-side `ManagedRuntime` used by generated
|
|
25
|
-
* `<script effect>` and markup helpers.
|
|
26
|
-
*
|
|
27
|
-
* @see https://ser.barekey.dev/content/reference/client-runtime
|
|
28
|
-
*/
|
|
29
|
-
const ClientRuntime = {
|
|
30
|
-
pipe: pipe_client_runtime,
|
|
31
|
-
make: make_client_runtime
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Register a pre-built `ManagedRuntime` on the current Svelte component
|
|
35
|
-
* context. Not exported - callers should go through `ClientRuntime.make`.
|
|
36
|
-
*
|
|
37
|
-
* @internal Internal - do not use.
|
|
38
|
-
*/
|
|
39
|
-
function provide_effect_runtime(runtime, options = {}) {
|
|
40
|
-
current_client_runtime = track_client_runtime(runtime);
|
|
41
|
-
setContext(EFFECT_RUNTIME_CONTEXT, runtime);
|
|
42
|
-
if (options.disposeOnDestroy) onDestroy(() => {
|
|
43
|
-
runtime.dispose();
|
|
44
|
-
});
|
|
45
|
-
return runtime;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Look up the active client runtime for the current component, or lazily
|
|
49
|
-
* create a default empty-layer runtime when no explicit one has been
|
|
50
|
-
* registered.
|
|
51
|
-
*
|
|
52
|
-
* Emitted by the `<script effect>` / `{yield* ...}` preprocessor - users
|
|
53
|
-
* should never import this directly.
|
|
54
|
-
*
|
|
55
|
-
* @internal Internal - do not use.
|
|
56
|
-
* @see https://ser.barekey.dev/content/reference/client-runtime
|
|
57
|
-
*/
|
|
58
|
-
function get_effect_runtime_or_throw() {
|
|
59
|
-
if (has_runtime_context()) return getContext(EFFECT_RUNTIME_CONTEXT);
|
|
60
|
-
if (current_client_runtime !== null) return current_client_runtime;
|
|
61
|
-
const default_runtime = track_client_runtime(ManagedRuntime.make(Layer.empty));
|
|
62
|
-
current_client_runtime = default_runtime;
|
|
63
|
-
return default_runtime;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Mount-time runner used by generated `<script effect>` output.
|
|
67
|
-
*
|
|
68
|
-
* Emitted by the preprocessor - users should never import this directly.
|
|
69
|
-
*
|
|
70
|
-
* @internal Internal - do not use.
|
|
71
|
-
* @see https://ser.barekey.dev/content/reference/client-runtime
|
|
72
|
-
*/
|
|
73
|
-
function run_component_effect(runtime, program) {
|
|
74
|
-
let disposed = false;
|
|
75
|
-
const cancel = runtime.runCallback(program, { onExit(exit) {
|
|
76
|
-
if (Exit.isFailure(exit) && !exit_has_interrupts(exit)) queueMicrotask(() => {
|
|
77
|
-
throw Cause.squash(exit.cause);
|
|
78
|
-
});
|
|
79
|
-
} });
|
|
80
|
-
return () => {
|
|
81
|
-
if (disposed) return;
|
|
82
|
-
disposed = true;
|
|
83
|
-
cancel();
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Promise-returning runner used by generated `{yield* ...}` markup helpers.
|
|
88
|
-
*
|
|
89
|
-
* Emitted by the preprocessor - users should never import this directly.
|
|
90
|
-
*
|
|
91
|
-
* @internal Internal - do not use.
|
|
92
|
-
* @see https://ser.barekey.dev/content/reference/client-runtime
|
|
93
|
-
*/
|
|
94
|
-
function run_inline_effect(runtime, program) {
|
|
95
|
-
return runtime.runPromise(program).catch((error) => {
|
|
96
|
-
queueMicrotask(() => {
|
|
97
|
-
throw error;
|
|
98
|
-
});
|
|
99
|
-
throw error;
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
function has_runtime_context() {
|
|
103
|
-
try {
|
|
104
|
-
return hasContext(EFFECT_RUNTIME_CONTEXT);
|
|
105
|
-
} catch {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function is_component_context_available() {
|
|
110
|
-
try {
|
|
111
|
-
hasContext(EFFECT_RUNTIME_CONTEXT);
|
|
112
|
-
return true;
|
|
113
|
-
} catch {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function track_client_runtime(runtime) {
|
|
118
|
-
const tracked_runtime = runtime;
|
|
119
|
-
if (tracked_runtime.__ser_tracked__ === true) return tracked_runtime;
|
|
120
|
-
const dispose = runtime.dispose.bind(runtime);
|
|
121
|
-
tracked_runtime.__ser_tracked__ = true;
|
|
122
|
-
runtime.dispose = (() => {
|
|
123
|
-
if (current_client_runtime === tracked_runtime) current_client_runtime = null;
|
|
124
|
-
return dispose();
|
|
125
|
-
});
|
|
126
|
-
return tracked_runtime;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Internal redirect guard used by the remote client adapters.
|
|
130
|
-
*
|
|
131
|
-
* @internal Internal - do not use.
|
|
132
|
-
*/
|
|
133
|
-
function is_redirect_like(value) {
|
|
134
|
-
return Boolean(value && typeof value === "object" && typeof value.location === "string" && typeof value.status === "number");
|
|
135
|
-
}
|
|
136
|
-
function is_http_error_like(value) {
|
|
137
|
-
return Boolean(value && typeof value === "object" && typeof value.status === "number");
|
|
138
|
-
}
|
|
139
|
-
function get_error_status(value) {
|
|
140
|
-
return is_http_error_like(value) ? value.status ?? 500 : 500;
|
|
141
|
-
}
|
|
142
|
-
function get_remote_error_decoder(value) {
|
|
143
|
-
if (value && (typeof value === "object" || typeof value === "function") && REMOTE_ERROR_DECODER in value) return value[REMOTE_ERROR_DECODER];
|
|
144
|
-
}
|
|
145
|
-
function decode_remote_error(error, decode_payload) {
|
|
146
|
-
if (is_http_error_like(error)) {
|
|
147
|
-
const body = error.body;
|
|
148
|
-
if (is_serialized_remote_failure_envelope(body) && decode_payload) try {
|
|
149
|
-
return decode_payload(body.encoded);
|
|
150
|
-
} catch (cause) {
|
|
151
|
-
return create_remote_transport_error(cause, body);
|
|
152
|
-
}
|
|
153
|
-
if (get_error_status(error) === 400) return create_remote_validation_error([], {
|
|
154
|
-
body,
|
|
155
|
-
status: 400
|
|
156
|
-
});
|
|
157
|
-
return create_remote_http_error(error, {
|
|
158
|
-
body,
|
|
159
|
-
status: get_error_status(error)
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
return create_remote_http_error(error);
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Internal adapter that lifts a promise-producing callback into the shared
|
|
166
|
-
* remote failure channel used by client wrappers.
|
|
167
|
-
*
|
|
168
|
-
* @internal Internal - do not use.
|
|
169
|
-
*/
|
|
170
|
-
function create_remote_effect_from_promise(create_promise, decode_error = (error) => create_remote_http_error(error)) {
|
|
171
|
-
return create_async_effect((resume) => {
|
|
172
|
-
Promise.resolve().then(create_promise).then((value) => resume(Effect.succeed(value)), (error) => {
|
|
173
|
-
if (is_redirect_like(error)) {
|
|
174
|
-
resume(Effect.die(error));
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
resume(Effect.fail(decode_error(error)));
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
function to_effect(value) {
|
|
182
|
-
const decode_payload = get_remote_error_decoder(value);
|
|
183
|
-
if (typeof value === "function") return ((...args) => create_remote_effect_from_promise(() => Promise.resolve(value(...args)), (error) => decode_remote_error(error, decode_payload)));
|
|
184
|
-
return create_remote_effect_from_promise(() => value, (error) => decode_remote_error(error, decode_payload));
|
|
185
|
-
}
|
|
186
|
-
function to_native(value) {
|
|
187
|
-
let current = value;
|
|
188
|
-
const seen = /* @__PURE__ */ new Set();
|
|
189
|
-
while (current && (typeof current === "object" || typeof current === "function") && "native" in current) {
|
|
190
|
-
if (seen.has(current)) break;
|
|
191
|
-
seen.add(current);
|
|
192
|
-
current = current.native;
|
|
193
|
-
}
|
|
194
|
-
return current;
|
|
195
|
-
}
|
|
196
|
-
//#endregion
|
|
197
|
-
export { run_component_effect as a, to_native as c, is_redirect_like as i, create_remote_effect_from_promise as n, run_inline_effect as o, get_effect_runtime_or_throw as r, to_effect as s, ClientRuntime as t };
|
|
198
|
-
|
|
199
|
-
//# sourceMappingURL=client-vV6UAwoP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-vV6UAwoP.js","names":[],"sources":["../../../modules/svelte-effect-runtime/v3/client.ts"],"sourcesContent":["import { Cause, Effect, Exit, Layer, ManagedRuntime } from \"effect\";\nimport { getContext, hasContext, onDestroy, setContext } from \"svelte\";\nimport {\n create_remote_http_error,\n create_remote_transport_error,\n create_remote_validation_error,\n is_serialized_remote_failure_envelope,\n REMOTE_ERROR_DECODER,\n type RemoteFailure,\n} from \"$internal/remote-shared.ts\";\nimport {\n create_async_effect,\n exit_has_interrupts,\n} from \"$internal/effect-compat.ts\";\n\nconst EFFECT_RUNTIME_CONTEXT = Symbol.for(\"svelte-effect-runtime/runtime\");\nlet current_client_runtime: EffectRuntime<unknown> | null = null;\n\ninterface ProvideEffectRuntimeOptions {\n disposeOnDestroy?: boolean;\n}\n\n/**\n * Minimal runtime abstraction the client adapters rely on. Implemented by the\n * Effect `ManagedRuntime` returned from {@link ClientRuntime.make}, but\n * callers may substitute their own object conforming to this shape.\n *\n * @see https://ser.barekey.dev/content/reference/client-runtime\n */\nexport interface EffectRuntime<R = unknown> {\n /**\n * Execute an Effect and receive a cancellation token. The optional `onExit`\n * callback fires with the final `Exit` value once the fiber completes.\n */\n runCallback<A, E, R2>(\n effect: Effect.Effect<A, E, R2>,\n options?: {\n onExit?: (exit: Exit.Exit<A, E>) => void;\n },\n ): () => void;\n /**\n * Execute an Effect and return a Promise that resolves with the success\n * value or rejects with the propagated failure.\n */\n runPromise<A, E, R2>(effect: Effect.Effect<A, E, R2>): Promise<A>;\n /**\n * Tear down the runtime and release any resources held by its root scope.\n */\n dispose(): Promise<void>;\n}\n\nexport type {\n FormError,\n FormIssue,\n RemoteDomainError,\n RemoteFailure,\n RemoteHttpError,\n RemoteTransportError,\n RemoteValidationError,\n} from \"$internal/remote-shared.ts\";\n\n/**\n * Alias for {@link EffectRuntime} exposed as a stable service name used by\n * generated code and documentation.\n *\n * @see https://ser.barekey.dev/content/reference/client-runtime\n */\nexport interface ClientRuntimeService extends EffectRuntime<unknown> {}\n\ntype RuntimeSeedLayer<R> = Layer.Layer<R, never, R>;\n\nfunction runtime_seed<R>(): RuntimeSeedLayer<R> {\n return Layer.effectContext(Effect.context<R>());\n}\n\ntype RuntimeOperator = (\n self: Layer.Layer<unknown, unknown, unknown>,\n) => Layer.Layer<unknown, unknown, unknown>;\n\ntype ProvidedBy<Op> = Op extends\n (self: RuntimeSeedLayer<infer R>) => Layer.Layer<unknown, unknown, infer RIn>\n ? Exclude<R, RIn>\n : never;\n\ntype ProvidedByAll<Ops extends ReadonlyArray<RuntimeOperator>> = Ops extends\n readonly [infer Head, ...infer Tail] ?\n | ProvidedBy<Head>\n | ProvidedByAll<Extract<Tail, ReadonlyArray<RuntimeOperator>>>\n : never;\n\ntype ApplyOperator<Seed, Op> = Op extends (self: Seed) => infer Out ? Out\n : never;\n\ntype ApplyOperators<\n Seed,\n Ops extends ReadonlyArray<RuntimeOperator>,\n> = Ops extends readonly [infer Head, ...infer Tail] ? ApplyOperators<\n ApplyOperator<Seed, Head>,\n Extract<Tail, ReadonlyArray<RuntimeOperator>>\n >\n : Seed;\n\ntype FinalRuntimeLayer<Ops extends ReadonlyArray<RuntimeOperator>> =\n ApplyOperators<RuntimeSeedLayer<ProvidedByAll<Ops>>, Ops> extends infer Out\n ? Out extends Layer.Layer<unknown, unknown, infer RIn>\n ? [RIn] extends [never] ? Out\n : never\n : never\n : never;\n\ninterface ClientRuntimeSeed {\n pipe(): Layer.Layer<never>;\n pipe<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): FinalRuntimeLayer<Ops>;\n make(): ManagedRuntime.ManagedRuntime<never, never>;\n make<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): ManagedRuntimeFromOps<Ops>;\n}\n\ntype ManagedRuntimeFromOps<Ops extends ReadonlyArray<RuntimeOperator>> =\n ManagedRuntime.ManagedRuntime<\n Layer.Layer.Success<FinalRuntimeLayer<Ops>>,\n Layer.Layer.Error<FinalRuntimeLayer<Ops>>\n >;\n\nfunction pipe_client_runtime(): Layer.Layer<never>;\nfunction pipe_client_runtime<\n const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>],\n>(...ops: Ops): FinalRuntimeLayer<Ops>;\nfunction pipe_client_runtime(\n ...ops: Array<RuntimeOperator>\n): Layer.Layer<never, unknown, unknown> {\n if (ops.length === 0) {\n return Layer.empty;\n }\n\n return ops.reduce<Layer.Layer<unknown, unknown, unknown>>(\n (layer, op) => op(layer),\n runtime_seed<unknown>(),\n ) as Layer.Layer<never, unknown, unknown>;\n}\n\nfunction make_client_runtime(): ManagedRuntime.ManagedRuntime<never, never>;\nfunction make_client_runtime<\n const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>],\n>(...ops: Ops): ManagedRuntimeFromOps<Ops>;\nfunction make_client_runtime(\n ...ops: [] | [RuntimeOperator, ...Array<RuntimeOperator>]\n): ManagedRuntime.ManagedRuntime<never, unknown> {\n const layer = ops.length === 0 ? pipe_client_runtime() : pipe_client_runtime(\n ...(ops as [RuntimeOperator, ...Array<RuntimeOperator>]),\n );\n\n const runtime = track_client_runtime(ManagedRuntime.make(\n layer as unknown as Layer.Layer<unknown, unknown, never>,\n ));\n\n void current_client_runtime?.dispose().catch(() => undefined);\n current_client_runtime = runtime;\n\n if (is_component_context_available()) {\n return provide_effect_runtime(runtime, { disposeOnDestroy: true });\n }\n\n return runtime;\n}\n\n/**\n * Build or compose the shared client-side `ManagedRuntime` used by generated\n * `<script effect>` and markup helpers.\n *\n * @see https://ser.barekey.dev/content/reference/client-runtime\n */\nexport const ClientRuntime: ClientRuntimeSeed = {\n pipe: pipe_client_runtime,\n make: make_client_runtime,\n};\n\n/**\n * Register a pre-built `ManagedRuntime` on the current Svelte component\n * context. Not exported - callers should go through `ClientRuntime.make`.\n *\n * @internal Internal - do not use.\n */\nfunction provide_effect_runtime<T extends EffectRuntime>(\n runtime: T,\n options: ProvideEffectRuntimeOptions = {},\n): T {\n current_client_runtime = track_client_runtime(runtime);\n setContext(EFFECT_RUNTIME_CONTEXT, runtime);\n\n if (options.disposeOnDestroy) {\n onDestroy(() => {\n void runtime.dispose();\n });\n }\n\n return runtime;\n}\n\n/**\n * Look up the active client runtime for the current component, or lazily\n * create a default empty-layer runtime when no explicit one has been\n * registered.\n *\n * Emitted by the `<script effect>` / `{yield* ...}` preprocessor - users\n * should never import this directly.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/client-runtime\n */\nexport function get_effect_runtime_or_throw<\n T extends EffectRuntime = EffectRuntime<never>,\n>(): T {\n if (has_runtime_context()) {\n return getContext<T>(EFFECT_RUNTIME_CONTEXT);\n }\n\n if (current_client_runtime !== null) {\n return current_client_runtime as T;\n }\n\n // No runtime registered — lazily create a default one with an empty layer.\n // This makes `ClientRuntime.make()` in `hooks.client.ts` optional for apps\n // that don't need to provide custom dependencies. A later explicit call to\n // `ClientRuntime.make(...)` will dispose this default and replace it.\n const default_runtime = track_client_runtime(\n ManagedRuntime.make(\n Layer.empty as unknown as Layer.Layer<unknown, unknown, never>,\n ),\n );\n current_client_runtime = default_runtime;\n return default_runtime as unknown as T;\n}\n\n/**\n * Mount-time runner used by generated `<script effect>` output.\n *\n * Emitted by the preprocessor - users should never import this directly.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/client-runtime\n */\nexport function run_component_effect<A, E, R>(\n runtime: EffectRuntime<R>,\n program: Effect.Effect<A, E, R>,\n): () => void {\n let disposed = false;\n\n const cancel = runtime.runCallback(program, {\n onExit(exit) {\n if (Exit.isFailure(exit) && !exit_has_interrupts(exit)) {\n queueMicrotask(() => {\n throw Cause.squash(exit.cause);\n });\n }\n },\n });\n\n return () => {\n if (disposed) {\n return;\n }\n\n disposed = true;\n cancel();\n };\n}\n\n/**\n * Promise-returning runner used by generated `{yield* ...}` markup helpers.\n *\n * Emitted by the preprocessor - users should never import this directly.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/client-runtime\n */\nexport function run_inline_effect<A, E, R>(\n runtime: EffectRuntime<R>,\n program: Effect.Effect<A, E, R>,\n): Promise<A> {\n return runtime.runPromise(program).catch((error) => {\n queueMicrotask(() => {\n throw error;\n });\n\n throw error;\n });\n}\n\nfunction has_runtime_context(): boolean {\n try {\n return hasContext(EFFECT_RUNTIME_CONTEXT);\n } catch {\n return false;\n }\n}\n\nfunction is_component_context_available(): boolean {\n try {\n void hasContext(EFFECT_RUNTIME_CONTEXT);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction track_client_runtime<T extends EffectRuntime>(runtime: T): T {\n const tracked_runtime = runtime as T & { __ser_tracked__?: true };\n\n if (tracked_runtime.__ser_tracked__ === true) {\n return tracked_runtime;\n }\n\n const dispose = runtime.dispose.bind(runtime);\n tracked_runtime.__ser_tracked__ = true;\n runtime.dispose = (() => {\n if (current_client_runtime === tracked_runtime) {\n current_client_runtime = null;\n }\n\n return dispose();\n }) as typeof runtime.dispose;\n\n return tracked_runtime;\n}\n\n/**\n * Internal redirect guard used by the remote client adapters.\n *\n * @internal Internal - do not use.\n */\nfunction is_redirect_like(value: unknown): boolean {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n typeof (value as { location?: unknown }).location === \"string\" &&\n typeof (value as { status?: unknown }).status === \"number\",\n );\n}\n\ntype Decode_remote_payload = <ErrorType = unknown>(\n encoded: string,\n) => ErrorType;\n\nfunction is_http_error_like(\n value: unknown,\n): value is {\n readonly body?: unknown;\n readonly status?: number;\n} {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n typeof (value as { status?: unknown }).status === \"number\",\n );\n}\n\nfunction get_error_status(value: unknown): number {\n return is_http_error_like(value) ? value.status ?? 500 : 500;\n}\n\nfunction get_remote_error_decoder(\n value: unknown,\n): Decode_remote_payload | undefined {\n if (\n value &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n REMOTE_ERROR_DECODER in value\n ) {\n return (value as { [REMOTE_ERROR_DECODER]: Decode_remote_payload })[\n REMOTE_ERROR_DECODER\n ];\n }\n}\n\nfunction decode_remote_error<ErrorType>(\n error: unknown,\n decode_payload?: Decode_remote_payload,\n): RemoteFailure<ErrorType> {\n if (is_http_error_like(error)) {\n const body = error.body;\n\n if (is_serialized_remote_failure_envelope(body) && decode_payload) {\n try {\n return decode_payload<ErrorType>(\n body.encoded,\n ) as RemoteFailure<ErrorType>;\n } catch (cause) {\n return create_remote_transport_error(cause, body);\n }\n }\n\n if (get_error_status(error) === 400) {\n return create_remote_validation_error([], {\n body,\n status: 400,\n });\n }\n\n return create_remote_http_error(error, {\n body,\n status: get_error_status(error),\n });\n }\n\n return create_remote_http_error(error);\n}\n\n/**\n * Internal adapter that lifts a promise-producing callback into the shared\n * remote failure channel used by client wrappers.\n *\n * @internal Internal - do not use.\n */\nfunction create_remote_effect_from_promise<Success, ErrorType = never>(\n create_promise: () => PromiseLike<Success>,\n decode_error: (error: unknown) => RemoteFailure<ErrorType> = (error) =>\n create_remote_http_error(error),\n): Effect.Effect<Success, RemoteFailure<ErrorType>, never> {\n return create_async_effect<Success, RemoteFailure<ErrorType>>((resume) => {\n void Promise.resolve()\n .then(create_promise)\n .then(\n (value) => resume(Effect.succeed(value)),\n (error) => {\n if (is_redirect_like(error)) {\n resume(Effect.die(error));\n return;\n }\n\n resume(Effect.fail(decode_error(error)));\n },\n );\n });\n}\n\ntype AnyCallable = (...args: Array<unknown>) => unknown;\n\n/**\n * Convert a promise or promise-returning function into an `Effect` that uses\n * the remote failure channel when applicable.\n *\n * @see https://ser.barekey.dev/content/reference/effect\n */\nexport function to_effect<Success, ErrorType = never>(\n promise_like: PromiseLike<Success>,\n): Effect.Effect<Success, RemoteFailure<ErrorType>, never>;\nexport function to_effect<\n Args extends Array<unknown>,\n Success,\n ErrorType = never,\n>(\n fn: (...args: Args) => PromiseLike<Success>,\n): (...args: Args) => Effect.Effect<Success, RemoteFailure<ErrorType>, never>;\nexport function to_effect<Success, ErrorType = never>(\n value: PromiseLike<Success> | AnyCallable,\n): Effect.Effect<Success, RemoteFailure<ErrorType>, never> | AnyCallable {\n const decode_payload = get_remote_error_decoder(value);\n\n if (typeof value === \"function\") {\n return ((...args: Array<unknown>) =>\n create_remote_effect_from_promise(\n () => Promise.resolve((value as AnyCallable)(...args)),\n (error) => decode_remote_error<ErrorType>(error, decode_payload),\n )) as AnyCallable;\n }\n\n return create_remote_effect_from_promise(\n () => value,\n (error) => decode_remote_error<ErrorType>(error, decode_payload),\n );\n}\n\n/**\n * Unwrap a runtime wrapper and recover the original native value.\n *\n * @see https://ser.barekey.dev/content/reference/effect\n */\nexport function to_native<Value>(\n value: Value,\n): Value extends { native: infer Native } ? Native\n : Value;\nexport function to_native(value: unknown): unknown {\n let current = value;\n const seen = new Set<unknown>();\n\n while (\n current &&\n (typeof current === \"object\" || typeof current === \"function\") &&\n \"native\" in current\n ) {\n if (seen.has(current)) {\n break;\n }\n\n seen.add(current);\n current = (current as { native: unknown }).native;\n }\n\n return current;\n}\n\nexport { create_remote_effect_from_promise, is_redirect_like };\n"],"mappings":";;;;;AAeA,MAAM,yBAAyB,OAAO,IAAI,gCAAgC;AAC1E,IAAI,yBAAwD;AAuD5D,SAAS,eAAuC;AAC9C,QAAO,MAAM,cAAc,OAAO,SAAY,CAAC;;AA2DjD,SAAS,oBACP,GAAG,KACmC;AACtC,KAAI,IAAI,WAAW,EACjB,QAAO,MAAM;AAGf,QAAO,IAAI,QACR,OAAO,OAAO,GAAG,MAAM,EACxB,cAAuB,CACxB;;AAOH,SAAS,oBACP,GAAG,KAC4C;CAC/C,MAAM,QAAQ,IAAI,WAAW,IAAI,qBAAqB,GAAG,oBACvD,GAAI,IACL;CAED,MAAM,UAAU,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AAiB,MAAM,EAAE;AAC3B,WAAO,OAAO,IAAI,MAAM,CAAC;AACzB;;AAGF,UAAO,OAAO,KAAK,aAAa,MAAM,CAAC,CAAC;IAE3C;GACH;;AAqBJ,SAAgB,UACd,OACuE;CACvE,MAAM,iBAAiB,yBAAyB,MAAM;AAEtD,KAAI,OAAO,UAAU,WACnB,UAAS,GAAG,SACV,wCACQ,QAAQ,QAAS,MAAsB,GAAG,KAAK,CAAC,GACrD,UAAU,oBAA+B,OAAO,eAAe,CACjE;AAGL,QAAO,wCACC,QACL,UAAU,oBAA+B,OAAO,eAAe,CACjE;;AAYH,SAAgB,UAAU,OAAyB;CACjD,IAAI,UAAU;CACd,MAAM,uBAAO,IAAI,KAAc;AAE/B,QACE,YACC,OAAO,YAAY,YAAY,OAAO,YAAY,eACnD,YAAY,SACZ;AACA,MAAI,KAAK,IAAI,QAAQ,CACnB;AAGF,OAAK,IAAI,QAAQ;AACjB,YAAW,QAAgC;;AAG7C,QAAO"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { t as effect_preprocess } from "./preprocess-BFePqOC6.js";
|
|
2
|
-
import { n as sveltekit_effect_runtime } from "./vite-BlUTKv2u.js";
|
|
3
|
-
import { preprocess } from "svelte/compiler";
|
|
4
|
-
//#region v3/effect.ts
|
|
5
|
-
/**
|
|
6
|
-
* High-level Vite integration for `svelte-effect-runtime`.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { effect } from "svelte-effect-runtime";
|
|
11
|
-
*
|
|
12
|
-
* export default {
|
|
13
|
-
* plugins: [effect()],
|
|
14
|
-
* };
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @module
|
|
18
|
-
*/
|
|
19
|
-
function create_effect_svelte_transform(options = {}) {
|
|
20
|
-
const preprocessor = effect_preprocess(options);
|
|
21
|
-
return {
|
|
22
|
-
name: "svelte-effect-runtime-transform",
|
|
23
|
-
enforce: "pre",
|
|
24
|
-
async transform(code, id, _options) {
|
|
25
|
-
const filename = id.split("?", 1)[0];
|
|
26
|
-
if (!filename.endsWith(".svelte")) return null;
|
|
27
|
-
const transformed = await preprocess(code, preprocessor, { filename });
|
|
28
|
-
if (transformed.code === code) return null;
|
|
29
|
-
return {
|
|
30
|
-
code: transformed.code,
|
|
31
|
-
...transformed.map ? { map: transformed.map } : {}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Convenience Vite plugin that enables `<script effect>` transforms and wires
|
|
38
|
-
* SvelteKit remote functions to the Effect-aware client adapters.
|
|
39
|
-
*
|
|
40
|
-
* Use this in `vite.config.ts` instead of composing lower-level runtime
|
|
41
|
-
* plugins yourself.
|
|
42
|
-
*
|
|
43
|
-
* @see https://ser.barekey.dev/
|
|
44
|
-
*/
|
|
45
|
-
function effect(options = {}) {
|
|
46
|
-
return [create_effect_svelte_transform(options.effect), sveltekit_effect_runtime({ remoteModuleId: options.remoteModuleId })];
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
export { effect as t };
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=effect-Crj3S8Cg.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effect-Crj3S8Cg.js","names":[],"sources":["../../../modules/svelte-effect-runtime/v3/effect.ts"],"sourcesContent":["/**\n * High-level Vite integration for `svelte-effect-runtime`.\n *\n * @example\n * ```ts\n * import { effect } from \"svelte-effect-runtime\";\n *\n * export default {\n * plugins: [effect()],\n * };\n * ```\n *\n * @module\n */\nimport { preprocess } from \"svelte/compiler\";\nimport type { Plugin, PluginOption } from \"vite\";\nimport {\n effect_preprocess,\n type EffectPreprocessOptions,\n} from \"$/v3/preprocess.ts\";\nimport { sveltekit_effect_runtime } from \"$/v3/vite.ts\";\n\n/** Options for the high-level {@link effect} Vite plugin. */\nexport interface EffectPluginOptions {\n effect?: EffectPreprocessOptions;\n remoteModuleId?: string;\n}\n\nfunction create_effect_svelte_transform(\n options: EffectPreprocessOptions = {},\n): Plugin {\n const preprocessor = effect_preprocess(options);\n\n return {\n name: \"svelte-effect-runtime-transform\",\n enforce: \"pre\",\n async transform(code, id, _options) {\n const filename = id.split(\"?\", 1)[0];\n if (!filename.endsWith(\".svelte\")) {\n return null;\n }\n\n const transformed = await preprocess(code, preprocessor, { filename });\n if (transformed.code === code) {\n return null;\n }\n\n return {\n code: transformed.code,\n ...(transformed.map ? { map: transformed.map as never } : {}),\n };\n },\n };\n}\n\n/**\n * Convenience Vite plugin that enables `<script effect>` transforms and wires\n * SvelteKit remote functions to the Effect-aware client adapters.\n *\n * Use this in `vite.config.ts` instead of composing lower-level runtime\n * plugins yourself.\n *\n * @see https://ser.barekey.dev/\n */\nexport function effect(\n options: EffectPluginOptions = {},\n): PluginOption[] {\n const transform_plugin = create_effect_svelte_transform(options.effect);\n\n return [\n transform_plugin,\n sveltekit_effect_runtime({\n remoteModuleId: options.remoteModuleId,\n }),\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,SAAS,+BACP,UAAmC,EAAE,EAC7B;CACR,MAAM,eAAe,kBAAkB,QAAQ;AAE/C,QAAO;EACL,MAAM;EACN,SAAS;EACT,MAAM,UAAU,MAAM,IAAI,UAAU;GAClC,MAAM,WAAW,GAAG,MAAM,KAAK,EAAE,CAAC;AAClC,OAAI,CAAC,SAAS,SAAS,UAAU,CAC/B,QAAO;GAGT,MAAM,cAAc,MAAM,WAAW,MAAM,cAAc,EAAE,UAAU,CAAC;AACtE,OAAI,YAAY,SAAS,KACvB,QAAO;AAGT,UAAO;IACL,MAAM,YAAY;IAClB,GAAI,YAAY,MAAM,EAAE,KAAK,YAAY,KAAc,GAAG,EAAE;IAC7D;;EAEJ;;;;;;;;;;;AAYH,SAAgB,OACd,UAA+B,EAAE,EACjB;AAGhB,QAAO,CAFkB,+BAA+B,QAAQ,OAAO,EAIrE,yBAAyB,EACvB,gBAAgB,QAAQ,gBACzB,CAAC,CACH"}
|