svelte-effect-runtime 1.2.2 → 1.2.3
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 +2 -2
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
package/dist/vite.js
CHANGED
|
@@ -3,7 +3,7 @@ import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { dirname, resolve } from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
|
-
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
7
|
//#region vite.ts
|
|
8
8
|
const ROOT_PACKAGE_ID = "svelte-effect-runtime";
|
|
9
9
|
const INTERNAL_SERVER_PACKAGE_ID = "svelte-effect-runtime/_server";
|
|
@@ -21,7 +21,7 @@ function svelteEffectRuntime(options = {}) {
|
|
|
21
21
|
}
|
|
22
22
|
function resolve_runtime_internal_path(source_relative_path, dist_relative_path) {
|
|
23
23
|
const relative_path = import.meta.url.endsWith(".ts") ? source_relative_path : dist_relative_path;
|
|
24
|
-
return new URL(relative_path, import.meta.url)
|
|
24
|
+
return fileURLToPath(new URL(relative_path, import.meta.url));
|
|
25
25
|
}
|
|
26
26
|
function resolve_kit_internal_runtime_path(relative_path) {
|
|
27
27
|
return pathToFileURL(resolve(dirname(createRequire(resolve(process.cwd(), "package.json")).resolve("@sveltejs/kit/package.json")), relative_path)).href;
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../../modules/svelte-effect-runtime/vite.ts"],"sourcesContent":["import {\n type Options as SveltePluginOptions,\n svelte,\n} from \"@sveltejs/vite-plugin-svelte\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\nimport process from \"node:process\";\nimport { pathToFileURL } from \"node:url\";\nimport type { Plugin } from \"vite\";\nimport {\n effectPreprocess,\n type EffectPreprocessOptions,\n} from \"./preprocess.ts\";\n\nexport interface SvelteEffectRuntimeOptions {\n effect?: EffectPreprocessOptions;\n svelte?: SveltePluginOptions;\n}\n\nexport interface SveltekitEffectRuntimeOptions {\n /**\n * Override the client-side module SvelteKit uses for generated `.remote.ts`\n * imports so remote calls default to Effect-returning adapters.\n */\n remoteModuleId?: string;\n}\n\nconst ROOT_PACKAGE_ID = \"svelte-effect-runtime\";\nconst INTERNAL_SERVER_PACKAGE_ID = \"svelte-effect-runtime/_server\";\nconst SERVER_SOURCE_PATTERN =\n /(?:^|\\/)(?:hooks\\.server\\.[cm]?[jt]s|.+\\.server\\.[cm]?[jt]s|.+\\.remote\\.[cm]?[jt]s)$/;\n\nfunction arrayify<T>(value: T | T[] | undefined): T[] {\n if (value === undefined) {\n return [];\n }\n\n return Array.isArray(value) ? value : [value];\n}\n\nexport function svelteEffectRuntime(\n options: SvelteEffectRuntimeOptions = {},\n): Plugin[] {\n const existingPreprocessors = arrayify(options.svelte?.preprocess);\n\n return svelte({\n ...options.svelte,\n preprocess: [\n effectPreprocess(options.effect),\n ...existingPreprocessors,\n ],\n });\n}\n\nfunction resolve_runtime_internal_path(\n source_relative_path: string,\n dist_relative_path: string,\n): string {\n const relative_path = import.meta.url.endsWith(\".ts\")\n ? source_relative_path\n : dist_relative_path;\n\n return new URL(relative_path, import.meta.url)
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../../modules/svelte-effect-runtime/vite.ts"],"sourcesContent":["import {\n type Options as SveltePluginOptions,\n svelte,\n} from \"@sveltejs/vite-plugin-svelte\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\nimport process from \"node:process\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { Plugin } from \"vite\";\nimport {\n effectPreprocess,\n type EffectPreprocessOptions,\n} from \"./preprocess.ts\";\n\nexport interface SvelteEffectRuntimeOptions {\n effect?: EffectPreprocessOptions;\n svelte?: SveltePluginOptions;\n}\n\nexport interface SveltekitEffectRuntimeOptions {\n /**\n * Override the client-side module SvelteKit uses for generated `.remote.ts`\n * imports so remote calls default to Effect-returning adapters.\n */\n remoteModuleId?: string;\n}\n\nconst ROOT_PACKAGE_ID = \"svelte-effect-runtime\";\nconst INTERNAL_SERVER_PACKAGE_ID = \"svelte-effect-runtime/_server\";\nconst SERVER_SOURCE_PATTERN =\n /(?:^|\\/)(?:hooks\\.server\\.[cm]?[jt]s|.+\\.server\\.[cm]?[jt]s|.+\\.remote\\.[cm]?[jt]s)$/;\n\nfunction arrayify<T>(value: T | T[] | undefined): T[] {\n if (value === undefined) {\n return [];\n }\n\n return Array.isArray(value) ? value : [value];\n}\n\nexport function svelteEffectRuntime(\n options: SvelteEffectRuntimeOptions = {},\n): Plugin[] {\n const existingPreprocessors = arrayify(options.svelte?.preprocess);\n\n return svelte({\n ...options.svelte,\n preprocess: [\n effectPreprocess(options.effect),\n ...existingPreprocessors,\n ],\n });\n}\n\nfunction resolve_runtime_internal_path(\n source_relative_path: string,\n dist_relative_path: string,\n): string {\n const relative_path = import.meta.url.endsWith(\".ts\")\n ? source_relative_path\n : dist_relative_path;\n\n return fileURLToPath(new URL(relative_path, import.meta.url));\n}\n\nfunction resolve_kit_internal_runtime_path(relative_path: string): string {\n const runtime_require = createRequire(resolve(process.cwd(), \"package.json\"));\n const kit_package_path = runtime_require.resolve(\n \"@sveltejs/kit/package.json\",\n );\n const kit_root = dirname(kit_package_path);\n\n return pathToFileURL(resolve(kit_root, relative_path)).href;\n}\n\nfunction create_remote_runtime_module_code(): string {\n const adapter_module_path = resolve_runtime_internal_path(\n \"./internal/remote-client.ts\",\n \"./internal/remote-client.js\",\n );\n const kit_query_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/remote-functions/query.svelte.js\",\n );\n const kit_command_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/remote-functions/command.svelte.js\",\n );\n const kit_form_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/remote-functions/form.svelte.js\",\n );\n const kit_prerender_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/remote-functions/prerender.svelte.js\",\n );\n const kit_shared_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/remote-functions/shared.svelte.js\",\n );\n const kit_client_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/client.js\",\n );\n const kit_form_utils_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/form-utils.js\",\n );\n const kit_shared_runtime_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/shared.js\",\n );\n\n return `\nimport * as devalue from \"devalue\";\nimport { base, app_dir } from \"$app/paths/internal/client\";\nimport { query as native_query, query_batch as native_query_batch } from ${\n JSON.stringify(kit_query_module_path)\n };\nimport { command as native_command } from ${\n JSON.stringify(kit_command_module_path)\n };\nimport { form as native_form } from ${JSON.stringify(kit_form_module_path)};\nimport { prerender as native_prerender } from ${\n JSON.stringify(kit_prerender_module_path)\n };\nimport {\n apply_refreshes,\n get_remote_request_headers,\n remote_request\n} from ${JSON.stringify(kit_shared_module_path)};\nimport { app, invalidateAll, _goto } from ${\n JSON.stringify(kit_client_module_path)\n };\nimport { BINARY_FORM_CONTENT_TYPE, serialize_binary_form } from ${\n JSON.stringify(kit_form_utils_module_path)\n };\nimport { stringify_remote_arg } from ${\n JSON.stringify(kit_shared_runtime_module_path)\n };\nimport {\n create_remote_command_adapter,\n create_remote_form_adapter,\n create_remote_query_adapter\n} from ${JSON.stringify(adapter_module_path)};\n\nconst decode_payload = (encoded) => devalue.parse(encoded, app?.decoders ?? {});\nconst request_dependencies = {\n app,\n app_dir,\n apply_refreshes,\n base,\n get_remote_request_headers,\n remote_request,\n stringify_remote_arg\n};\n\nexport const query = create_remote_query_adapter(native_query, decode_payload, request_dependencies, \"query\");\nexport const query_batch = create_remote_query_adapter(native_query_batch, decode_payload, request_dependencies, \"query_batch\");\nexport const command = create_remote_command_adapter(native_command, decode_payload, request_dependencies);\nexport const prerender = create_remote_query_adapter(native_prerender, decode_payload, request_dependencies, \"prerender\");\nexport const form = create_remote_form_adapter(native_form, decode_payload, {\n binary_form_content_type: BINARY_FORM_CONTENT_TYPE,\n goto: _goto,\n invalidate_all: invalidateAll,\n serialize_binary_form,\n ...request_dependencies\n});\n`;\n}\n\nexport function sveltekitEffectRuntime(\n options: SveltekitEffectRuntimeOptions = {},\n): Plugin {\n const remote_module_id = options.remoteModuleId ??\n \"\\0svelte-effect-runtime:remote\";\n\n return {\n name: \"svelte-effect-runtime-remote\",\n enforce: \"pre\",\n resolveId(id) {\n if (id === \"__sveltekit/remote\") {\n return remote_module_id;\n }\n },\n load(id) {\n if (id !== remote_module_id) {\n return;\n }\n\n return create_remote_runtime_module_code();\n },\n transform(code, id) {\n const filename = id.split(\"?\", 1)[0];\n if (!SERVER_SOURCE_PATTERN.test(filename)) {\n return null;\n }\n\n if (!code.includes(ROOT_PACKAGE_ID)) {\n return null;\n }\n\n return code.replaceAll(ROOT_PACKAGE_ID, INTERNAL_SERVER_PACKAGE_ID);\n },\n };\n}\n"],"mappings":";;;;;;;AA2BA,MAAM,kBAAkB;AACxB,MAAM,6BAA6B;AACnC,MAAM,wBACJ;AAEF,SAAS,SAAY,OAAiC;AACpD,KAAI,UAAU,KAAA,EACZ,QAAO,EAAE;AAGX,QAAO,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;;AAG/C,SAAgB,oBACd,UAAsC,EAAE,EAC9B;CACV,MAAM,wBAAwB,SAAS,QAAQ,QAAQ,WAAW;AAElE,QAAO,OAAO;EACZ,GAAG,QAAQ;EACX,YAAY,CACV,iBAAiB,QAAQ,OAAO,EAChC,GAAG,sBACJ;EACF,CAAC;;AAGJ,SAAS,8BACP,sBACA,oBACQ;CACR,MAAM,gBAAgB,OAAO,KAAK,IAAI,SAAS,MAAM,GACjD,uBACA;AAEJ,QAAO,cAAc,IAAI,IAAI,eAAe,OAAO,KAAK,IAAI,CAAC;;AAG/D,SAAS,kCAA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