svelte-effect-runtime 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/vite.js +27 -0
- package/.dist/vite.js.map +1 -1
- package/package.json +1 -1
package/.dist/vite.js
CHANGED
|
@@ -18,11 +18,24 @@
|
|
|
18
18
|
*/
|
|
19
19
|
function effect(options) {
|
|
20
20
|
return [
|
|
21
|
+
make_reserved_helper_guard_plugin(),
|
|
21
22
|
make_svelte_transform_plugin(),
|
|
22
23
|
make_server_rewrite_plugin(),
|
|
23
24
|
make_remote_client_wrapper_plugin(options)
|
|
24
25
|
];
|
|
25
26
|
}
|
|
27
|
+
function make_reserved_helper_guard_plugin() {
|
|
28
|
+
return {
|
|
29
|
+
name: "svelte-effect-runtime:reserved-helper-guard",
|
|
30
|
+
enforce: "pre",
|
|
31
|
+
transform(code, id) {
|
|
32
|
+
if (!is_svelte_component_module(id) || !has_ser_syntax(code)) return;
|
|
33
|
+
const reserved_names = find_reserved_helper_names(code);
|
|
34
|
+
if (reserved_names.length === 0) return;
|
|
35
|
+
this.warn(make_reserved_helper_warning(reserved_names));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
26
39
|
function make_svelte_transform_plugin() {
|
|
27
40
|
return {
|
|
28
41
|
name: "svelte-effect-runtime:svelte-transform",
|
|
@@ -98,6 +111,20 @@ function is_svelte_component_module(id) {
|
|
|
98
111
|
const allowed_params = ["t", "v"];
|
|
99
112
|
return [...params.keys()].every((key) => allowed_params.includes(key));
|
|
100
113
|
}
|
|
114
|
+
function has_ser_syntax(code) {
|
|
115
|
+
return /\byield\s*\*/.test(code) || /<script\b[^>]*\beffect(?:[\s=>]|$)/.test(code);
|
|
116
|
+
}
|
|
117
|
+
function find_reserved_helper_names(code) {
|
|
118
|
+
const script_segments = [...code.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script\s*>/gi)].map((match) => match[1] ?? "");
|
|
119
|
+
const markup_segments = [...code.matchAll(/\{[^{}]*(?:Dispatcher|Code)[^{}]*\}/g)].map((match) => match[0]);
|
|
120
|
+
const search_segments = [...script_segments, ...markup_segments];
|
|
121
|
+
return ["Dispatcher", "Code"].filter((name) => search_segments.some((segment) => new RegExp(`\\b${name}\\b`).test(segment)));
|
|
122
|
+
}
|
|
123
|
+
function make_reserved_helper_warning(names) {
|
|
124
|
+
const quoted_names = names.map((name) => `\`${name}\``);
|
|
125
|
+
const subject = quoted_names.length === 1 ? quoted_names[0] : `${quoted_names.slice(0, -1).join(", ")} and ${quoted_names[quoted_names.length - 1]}`;
|
|
126
|
+
return [`[svelte-effect-runtime] ${subject} ${names.length === 1 ? "is" : "are"} reserved for generated markup helpers.`, `Rename or alias local bindings that use ${subject} before using SER syntax in this component.`].join(" ");
|
|
127
|
+
}
|
|
101
128
|
/**
|
|
102
129
|
* Rewrites SvelteKit's generated client remote module from:
|
|
103
130
|
*
|
package/.dist/vite.js.map
CHANGED
|
@@ -1 +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_svelte_transform_plugin(),\n make_server_rewrite_plugin(),\n make_remote_client_wrapper_plugin(options),\n ];\n}\n\nfunction make_svelte_transform_plugin(): Plugin {\n return {\n name: \"svelte-effect-runtime:svelte-transform\",\n\n async transform(code: string, id: string, options?: { ssr?: boolean }) {\n if (!is_svelte_component_module(id)) {\n return undefined;\n }\n\n const { transform_svelte_effect } = await import(\n \"./runtime/transform.ts\"\n );\n const result = transform_svelte_effect(code, id, {\n target: options?.ssr ? \"server\" : \"client\",\n });\n\n if (result.code === code) {\n return undefined;\n }\n\n return { code: result.code, map: null };\n },\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 const runtime_package = \"svelte-effect-runtime\";\n\n if (no_external === true) {\n return;\n }\n\n if (Array.isArray(no_external)) {\n const has_runtime_package = no_external.some(\n (entry) => entry === runtime_package,\n );\n\n if (!has_runtime_package) {\n no_external.push(runtime_package);\n }\n\n return;\n }\n\n config.ssr.noExternal = [\n no_external,\n runtime_package,\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\nfunction is_svelte_component_module(id: string): boolean {\n const [filename, query = \"\"] = id.split(\"?\", 2);\n\n if (!filename.endsWith(\".svelte\")) {\n return false;\n }\n\n if (query.length === 0) {\n return true;\n }\n\n const params = new URLSearchParams(query);\n const allowed_params = [\"t\", \"v\"];\n\n return [...params.keys()].every((key) => allowed_params.includes(key));\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;CACxD,OAAO;EACL,6BAA6B;EAC7B,2BAA2B;EAC3B,kCAAkC,OAAO;CAC3C;AACF;AAEA,SAAS,+BAAuC;CAC9C,OAAO;EACL,MAAM;EAEN,MAAM,UAAU,MAAc,IAAY,SAA6B;GACrE,IAAI,CAAC,2BAA2B,EAAE,GAChC;GAGF,MAAM,EAAE,4BAA4B,MAAM,OACxC;GAEF,MAAM,SAAS,wBAAwB,MAAM,IAAI,EAC/C,QAAQ,SAAS,MAAM,WAAW,SACpC,CAAC;GAED,IAAI,OAAO,SAAS,MAClB;GAGF,OAAO;IAAE,MAAM,OAAO;IAAM,KAAK;GAAK;EACxC;CACF;AACF;AAEA,SAAS,6BAAqC;CAC5C,OAAO;EACL,MAAM;EACN,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AAY;AAC3E"}
|
|
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_reserved_helper_guard_plugin(),\n make_svelte_transform_plugin(),\n make_server_rewrite_plugin(),\n make_remote_client_wrapper_plugin(options),\n ];\n}\n\nfunction make_reserved_helper_guard_plugin(): Plugin {\n return {\n name: \"svelte-effect-runtime:reserved-helper-guard\",\n enforce: \"pre\",\n\n transform(code: string, id: string) {\n if (!is_svelte_component_module(id) || !has_ser_syntax(code)) {\n return undefined;\n }\n\n const reserved_names = find_reserved_helper_names(code);\n\n if (reserved_names.length === 0) {\n return undefined;\n }\n\n this.warn(make_reserved_helper_warning(reserved_names));\n\n return undefined;\n },\n };\n}\n\nfunction make_svelte_transform_plugin(): Plugin {\n return {\n name: \"svelte-effect-runtime:svelte-transform\",\n\n async transform(code: string, id: string, options?: { ssr?: boolean }) {\n if (!is_svelte_component_module(id)) {\n return undefined;\n }\n\n const { transform_svelte_effect } = await import(\n \"./runtime/transform.ts\"\n );\n const result = transform_svelte_effect(code, id, {\n target: options?.ssr ? \"server\" : \"client\",\n });\n\n if (result.code === code) {\n return undefined;\n }\n\n return { code: result.code, map: null };\n },\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 const runtime_package = \"svelte-effect-runtime\";\n\n if (no_external === true) {\n return;\n }\n\n if (Array.isArray(no_external)) {\n const has_runtime_package = no_external.some(\n (entry) => entry === runtime_package,\n );\n\n if (!has_runtime_package) {\n no_external.push(runtime_package);\n }\n\n return;\n }\n\n config.ssr.noExternal = [\n no_external,\n runtime_package,\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\nfunction is_svelte_component_module(id: string): boolean {\n const [filename, query = \"\"] = id.split(\"?\", 2);\n\n if (!filename.endsWith(\".svelte\")) {\n return false;\n }\n\n if (query.length === 0) {\n return true;\n }\n\n const params = new URLSearchParams(query);\n const allowed_params = [\"t\", \"v\"];\n\n return [...params.keys()].every((key) => allowed_params.includes(key));\n}\n\nfunction has_ser_syntax(code: string): boolean {\n return /\\byield\\s*\\*/.test(code) ||\n /<script\\b[^>]*\\beffect(?:[\\s=>]|$)/.test(code);\n}\n\nfunction find_reserved_helper_names(code: string): string[] {\n const script_segments = [...code.matchAll(\n /<script\\b[^>]*>([\\s\\S]*?)<\\/script\\s*>/gi,\n )].map((match) => match[1] ?? \"\");\n const markup_segments = [\n ...code.matchAll(/\\{[^{}]*(?:Dispatcher|Code)[^{}]*\\}/g),\n ]\n .map((match) => match[0]);\n const search_segments = [...script_segments, ...markup_segments];\n\n return [\"Dispatcher\", \"Code\"].filter((name) =>\n search_segments.some((segment) => new RegExp(`\\\\b${name}\\\\b`).test(segment))\n );\n}\n\nfunction make_reserved_helper_warning(names: string[]): string {\n const quoted_names = names.map((name) => `\\`${name}\\``);\n const subject = quoted_names.length === 1\n ? quoted_names[0]\n : `${quoted_names.slice(0, -1).join(\", \")} and ${\n quoted_names[quoted_names.length - 1]\n }`;\n const verb = names.length === 1 ? \"is\" : \"are\";\n\n return [\n `[svelte-effect-runtime] ${subject} ${verb} reserved for generated markup helpers.`,\n `Rename or alias local bindings that use ${subject} before using SER syntax in this component.`,\n ].join(\" \");\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;CACxD,OAAO;EACL,kCAAkC;EAClC,6BAA6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