svelte-effect-runtime 3.4.1 → 3.4.2
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/{dispatcher-KxyCmCbv.js → dispatcher-Cyfinirp.js} +2 -2
- package/.dist/chunks/{dispatcher-KxyCmCbv.js.map → dispatcher-Cyfinirp.js.map} +1 -1
- package/.dist/chunks/{runtime-BXbxv4Ai.js → runtime-VdojAxY3.js} +39 -2
- package/.dist/chunks/runtime-VdojAxY3.js.map +1 -0
- package/.dist/internal/generators.js +1 -1
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/run.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/server.js +1 -1
- package/package.json +1 -1
- package/.dist/chunks/runtime-BXbxv4Ai.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as get_dispatcher$1 } from "./dispatcher-s46GfT6n.js";
|
|
2
|
-
import { r as get_server_dispatcher } from "./runtime-
|
|
2
|
+
import { r as get_server_dispatcher } from "./runtime-VdojAxY3.js";
|
|
3
3
|
//#region src/generated/dispatcher.ts
|
|
4
4
|
/**
|
|
5
5
|
* Facade used by transform-generated component code to dispatch runtime
|
|
@@ -44,4 +44,4 @@ function get_dispatcher() {
|
|
|
44
44
|
//#endregion
|
|
45
45
|
export { get_dispatcher as n, Dispatcher as t };
|
|
46
46
|
|
|
47
|
-
//# sourceMappingURL=dispatcher-
|
|
47
|
+
//# sourceMappingURL=dispatcher-Cyfinirp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher-
|
|
1
|
+
{"version":3,"file":"dispatcher-Cyfinirp.js","names":["get_client_dispatcher"],"sources":["../../../modules/svelte-effect-runtime/src/generated/dispatcher.ts"],"sourcesContent":["import { get_dispatcher as get_client_dispatcher } from \"$/dispatcher.ts\";\nimport { get_server_dispatcher } from \"$/server/runtime.ts\";\nimport type {\n Dispatcher as RuntimeDispatcher,\n DispatcherEvent,\n MarkupPromiseEvent,\n MarkupRunEvent,\n MarkupValueEvent,\n} from \"$/dispatcher.ts\";\n\nexport { Code } from \"$/dispatcher.ts\";\nexport type {\n DispatcherEvent,\n MarkupPromiseEvent,\n MarkupPromiseOptions,\n MarkupRunEvent,\n MarkupValueEvent,\n} from \"$/dispatcher.ts\";\n\n/**\n * Facade used by transform-generated component code to dispatch runtime\n * events through the current client or server dispatcher.\n *\n * @example\n * ```ts\n * const value = Dispatcher.emit({\n * type: Code.Markup.Value,\n * id: \"Component.svelte:1:2\",\n * deps: [],\n * fallback: undefined,\n * fn: function* () {\n * return yield* Effect.succeed(1);\n * },\n * });\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport class Dispatcher {\n /**\n * Emits a transform-generated dispatcher event.\n *\n * @example\n * ```ts\n * const promise = Dispatcher.emit({\n * type: Code.Markup.Promise,\n * id: \"Component.svelte:1:2\",\n * deps: [],\n * fn: function* () {\n * return yield* Effect.succeed(1);\n * },\n * });\n * ```\n *\n * @since 3.3.0\n * @param event - Generated event describing the dispatcher operation to run.\n * @returns The result produced by the active dispatcher.\n */\n static emit<A, F>(event: MarkupValueEvent<A, F>): A | F;\n static emit<A>(event: MarkupPromiseEvent<A>): Promise<A>;\n static emit<A>(event: MarkupRunEvent<A>): Promise<A>;\n static emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;\n static emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A> {\n return get_dispatcher().emit(event);\n }\n}\n\n/**\n * Returns the dispatcher appropriate for generated component code.\n *\n * @example\n * ```ts\n * const dispatcher = get_dispatcher();\n * ```\n *\n * @since 3.0.1\n * @returns The server dispatcher during SSR, otherwise the client dispatcher.\n */\nexport function get_dispatcher(): RuntimeDispatcher {\n if (typeof document === \"undefined\") {\n return get_server_dispatcher();\n }\n\n return get_client_dispatcher();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,aAAb,MAAwB;CAwBtB,OAAO,KAAW,OAAkD;EAClE,OAAO,eAAe,EAAE,KAAK,KAAK;CACpC;AACF;;;;;;;;;;;;AAaA,SAAgB,iBAAoC;CAClD,IAAI,OAAO,aAAa,aACtB,OAAO,sBAAsB;CAG/B,OAAOA,iBAAsB;AAC/B"}
|
|
@@ -34,7 +34,13 @@ var ServerRuntime = class {
|
|
|
34
34
|
* @returns The configured ManagedRuntime.
|
|
35
35
|
*/
|
|
36
36
|
static make(layer) {
|
|
37
|
-
|
|
37
|
+
const should_replace_dev_runtime = current_server_runtime !== void 0 && is_vite_dev_ssr();
|
|
38
|
+
/**
|
|
39
|
+
* Keep duplicate production initialization loud while allowing SvelteKit's
|
|
40
|
+
* dev server to re-run hooks.server.ts after an HMR invalidation.
|
|
41
|
+
*/
|
|
42
|
+
if (current_server_runtime && !should_replace_dev_runtime) throw new RuntimeAlreadyInitializedError("ServerRuntime");
|
|
43
|
+
if (should_replace_dev_runtime) reset_server_runtime();
|
|
38
44
|
const runtime = ManagedRuntime.make(layer ?? Layer.empty);
|
|
39
45
|
current_server_runtime = runtime;
|
|
40
46
|
current_server_dispatcher = new Dispatcher(runtime);
|
|
@@ -74,7 +80,38 @@ function get_server_dispatcher() {
|
|
|
74
80
|
current_server_dispatcher ??= new Dispatcher(get_server_runtime_or_throw());
|
|
75
81
|
return current_server_dispatcher;
|
|
76
82
|
}
|
|
83
|
+
function is_vite_dev_ssr() {
|
|
84
|
+
const env = import.meta.env;
|
|
85
|
+
return env?.DEV === true && env?.SSR === true;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Resets the internal server runtime singleton used by source-level tests.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* reset_server_runtime();
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @since 3.4.0
|
|
96
|
+
* @returns Nothing.
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
function reset_server_runtime() {
|
|
100
|
+
const dispatcher = current_server_dispatcher;
|
|
101
|
+
const runtime = current_server_runtime;
|
|
102
|
+
current_server_dispatcher = void 0;
|
|
103
|
+
current_server_runtime = void 0;
|
|
104
|
+
if (dispatcher) {
|
|
105
|
+
dispatcher.dispose();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
runtime?.dispose().catch((error) => {
|
|
109
|
+
queueMicrotask(() => {
|
|
110
|
+
throw error;
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
77
114
|
//#endregion
|
|
78
115
|
export { get_server_runtime_or_throw as i, ServerRuntime as n, get_server_dispatcher as r, RequestEvent as t };
|
|
79
116
|
|
|
80
|
-
//# sourceMappingURL=runtime-
|
|
117
|
+
//# sourceMappingURL=runtime-VdojAxY3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-VdojAxY3.js","names":["InternalDispatcher"],"sources":["../../../modules/svelte-effect-runtime/src/server/runtime.ts"],"sourcesContent":["import type { RequestEvent as SvelteKitRequestEvent } from \"@sveltejs/kit\";\nimport { Context, Layer, ManagedRuntime } from \"effect\";\nimport { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\n\nimport {\n RequestEventUnavailableError,\n RuntimeAlreadyInitializedError,\n} from \"$/errors.ts\";\n\ntype ViteImportMeta = ImportMeta & {\n readonly env?: {\n readonly DEV?: boolean;\n readonly SSR?: boolean;\n };\n};\n\n/**\n * Subset of SvelteKit's `RequestEvent` that remote handlers typically access.\n *\n * @since 2.0.0\n */\nexport interface RequestEvent extends\n Pick<\n SvelteKitRequestEvent,\n | \"cookies\"\n | \"getClientAddress\"\n | \"locals\"\n | \"params\"\n | \"platform\"\n | \"request\"\n | \"route\"\n | \"url\"\n > {}\n\n/**\n * SvelteKit's `RequestEvent` exposed as an Effect {@link Context.Tag}.\n *\n * @example\n * ```ts\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEvent> = Context\n .Reference<RequestEvent>(\"@ser/RequestEvent\", {\n defaultValue: () => {\n throw new RequestEventUnavailableError();\n },\n });\n\n/**\n * Builder for the server-side Effect runtime.\n *\n * @example\n * ```ts\n * ServerRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ServerRuntime {\n /**\n * Build and cache the server-side `ManagedRuntime`.\n *\n * @since 2.0.0\n * @param layer - Optional Effect layer to provide to the runtime.\n * @returns The configured ManagedRuntime.\n */\n static make<R = never>(\n layer?: Layer.Layer<R>,\n ): ManagedRuntime.ManagedRuntime<R, never> {\n const should_replace_dev_runtime = current_server_runtime !== undefined &&\n is_vite_dev_ssr();\n\n /**\n * Keep duplicate production initialization loud while allowing SvelteKit's\n * dev server to re-run hooks.server.ts after an HMR invalidation.\n */\n if (current_server_runtime && !should_replace_dev_runtime) {\n throw new RuntimeAlreadyInitializedError(\"ServerRuntime\");\n }\n\n if (should_replace_dev_runtime) {\n reset_server_runtime();\n }\n\n const runtime = ManagedRuntime.make(\n layer ?? (Layer.empty as unknown as Layer.Layer<R>),\n );\n\n current_server_runtime = runtime as ManagedRuntime.ManagedRuntime<\n unknown,\n never\n >;\n current_server_dispatcher = new InternalDispatcher(\n runtime as unknown as ManagedRuntimeType<unknown, unknown>,\n );\n\n return runtime;\n }\n}\n\nlet current_server_runtime:\n | ManagedRuntime.ManagedRuntime<unknown, never>\n | undefined;\nlet current_server_dispatcher: InternalDispatcher | undefined;\n\n/**\n * Returns the active server runtime, creating a default one if needed.\n *\n * @example\n * ```ts\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n * @returns The current ManagedRuntime instance.\n */\nexport function get_server_runtime_or_throw(): ManagedRuntime.ManagedRuntime<\n unknown,\n never\n> {\n if (!current_server_runtime) {\n current_server_runtime = ManagedRuntime.make(\n Layer.empty,\n ) as ManagedRuntime.ManagedRuntime<unknown, never>;\n }\n\n return current_server_runtime;\n}\n\n/**\n * Returns a dispatcher backed by the active server runtime.\n *\n * @example\n * ```ts\n * const dispatcher = get_server_dispatcher();\n * ```\n *\n * @since 3.0.1\n * @returns The cached server dispatcher, creating one from the current server\n * runtime when needed.\n */\nexport function get_server_dispatcher(): InternalDispatcher {\n current_server_dispatcher ??= new InternalDispatcher(\n get_server_runtime_or_throw() as unknown as ManagedRuntimeType<\n unknown,\n unknown\n >,\n );\n\n return current_server_dispatcher;\n}\n\nfunction is_vite_dev_ssr(): boolean {\n const env = (import.meta as ViteImportMeta).env;\n\n return env?.DEV === true && env?.SSR === true;\n}\n\n/**\n * Resets the internal server runtime singleton used by source-level tests.\n *\n * @example\n * ```ts\n * reset_server_runtime();\n * ```\n *\n * @since 3.4.0\n * @returns Nothing.\n * @internal\n */\nexport function reset_server_runtime(): void {\n const dispatcher = current_server_dispatcher;\n const runtime = current_server_runtime;\n\n current_server_dispatcher = undefined;\n current_server_runtime = undefined;\n\n if (dispatcher) {\n dispatcher.dispose();\n\n return;\n }\n\n void runtime?.dispose().catch((error: unknown) => {\n queueMicrotask(() => {\n throw error;\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AA6CA,MAAa,eAAgD,QAC1D,UAAwB,qBAAqB,EAC5C,oBAAoB;CAClB,MAAM,IAAI,6BAA6B;AACzC,EACF,CAAC;;;;;;;;;;;AAYH,IAAa,gBAAb,MAA2B;;;;;;;;CAQzB,OAAO,KACL,OACyC;EACzC,MAAM,6BAA6B,2BAA2B,KAAA,KAC5D,gBAAgB;;;;;EAMlB,IAAI,0BAA0B,CAAC,4BAC7B,MAAM,IAAI,+BAA+B,eAAe;EAG1D,IAAI,4BACF,qBAAqB;EAGvB,MAAM,UAAU,eAAe,KAC7B,SAAU,MAAM,KAClB;EAEA,yBAAyB;EAIzB,4BAA4B,IAAIA,WAC9B,OACF;EAEA,OAAO;CACT;AACF;AAEA,IAAI;AAGJ,IAAI;;;;;;;;;;;;AAaJ,SAAgB,8BAGd;CACA,IAAI,CAAC,wBACH,yBAAyB,eAAe,KACtC,MAAM,KACR;CAGF,OAAO;AACT;;;;;;;;;;;;;AAcA,SAAgB,wBAA4C;CAC1D,8BAA8B,IAAIA,WAChC,4BAA4B,CAI9B;CAEA,OAAO;AACT;AAEA,SAAS,kBAA2B;CAClC,MAAM,MAAO,OAAO,KAAwB;CAE5C,OAAO,KAAK,QAAQ,QAAQ,KAAK,QAAQ;AAC3C;;;;;;;;;;;;;AAcA,SAAgB,uBAA6B;CAC3C,MAAM,aAAa;CACnB,MAAM,UAAU;CAEhB,4BAA4B,KAAA;CAC5B,yBAAyB,KAAA;CAEzB,IAAI,YAAY;EACd,WAAW,QAAQ;EAEnB;CACF;CAEA,SAAc,QAAQ,EAAE,OAAO,UAAmB;EAChD,qBAAqB;GACnB,MAAM;EACR,CAAC;CACH,CAAC;AACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as Code } from "../chunks/dispatcher-s46GfT6n.js";
|
|
2
|
-
import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-
|
|
2
|
+
import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-Cyfinirp.js";
|
|
3
3
|
import { value } from "../markup/value.js";
|
|
4
4
|
import { promise } from "../markup/promise.js";
|
|
5
5
|
import { run } from "../markup/run.js";
|
package/.dist/markup/promise.js
CHANGED
package/.dist/markup/run.js
CHANGED
package/.dist/markup/value.js
CHANGED
package/.dist/server.js
CHANGED
|
@@ -2,7 +2,7 @@ import { C as UncheckedLiveQueryHandlerMissingError, S as UncheckedFormHandlerMi
|
|
|
2
2
|
import { create_form_error } from "./remote/shared.js";
|
|
3
3
|
import { t as copy_property_descriptors } from "./chunks/descriptors-OS4VfJuW.js";
|
|
4
4
|
import { normalize_remote_helper_error, run_remote_effect } from "./remote/server.js";
|
|
5
|
-
import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-
|
|
5
|
+
import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-VdojAxY3.js";
|
|
6
6
|
import { Effect, Schema, Stream } from "effect";
|
|
7
7
|
import { error, invalid, redirect } from "@sveltejs/kit";
|
|
8
8
|
import { command, form, getRequestEvent, prerender, query } from "$app/server";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-BXbxv4Ai.js","names":["InternalDispatcher"],"sources":["../../../modules/svelte-effect-runtime/src/server/runtime.ts"],"sourcesContent":["import type { RequestEvent as SvelteKitRequestEvent } from \"@sveltejs/kit\";\nimport { Context, Layer, ManagedRuntime } from \"effect\";\nimport { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\n\nimport {\n RequestEventUnavailableError,\n RuntimeAlreadyInitializedError,\n} from \"$/errors.ts\";\n\n/**\n * Subset of SvelteKit's `RequestEvent` that remote handlers typically access.\n *\n * @since 2.0.0\n */\nexport interface RequestEvent extends\n Pick<\n SvelteKitRequestEvent,\n | \"cookies\"\n | \"getClientAddress\"\n | \"locals\"\n | \"params\"\n | \"platform\"\n | \"request\"\n | \"route\"\n | \"url\"\n > {}\n\n/**\n * SvelteKit's `RequestEvent` exposed as an Effect {@link Context.Tag}.\n *\n * @example\n * ```ts\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEvent> = Context\n .Reference<RequestEvent>(\"@ser/RequestEvent\", {\n defaultValue: () => {\n throw new RequestEventUnavailableError();\n },\n });\n\n/**\n * Builder for the server-side Effect runtime.\n *\n * @example\n * ```ts\n * ServerRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ServerRuntime {\n /**\n * Build and cache the server-side `ManagedRuntime`.\n *\n * @since 2.0.0\n * @param layer - Optional Effect layer to provide to the runtime.\n * @returns The configured ManagedRuntime.\n */\n static make<R = never>(\n layer?: Layer.Layer<R>,\n ): ManagedRuntime.ManagedRuntime<R, never> {\n if (current_server_runtime) {\n throw new RuntimeAlreadyInitializedError(\"ServerRuntime\");\n }\n\n const runtime = ManagedRuntime.make(\n layer ?? (Layer.empty as unknown as Layer.Layer<R>),\n );\n\n current_server_runtime = runtime as ManagedRuntime.ManagedRuntime<\n unknown,\n never\n >;\n current_server_dispatcher = new InternalDispatcher(\n runtime as unknown as ManagedRuntimeType<unknown, unknown>,\n );\n\n return runtime;\n }\n}\n\nlet current_server_runtime:\n | ManagedRuntime.ManagedRuntime<unknown, never>\n | undefined;\nlet current_server_dispatcher: InternalDispatcher | undefined;\n\n/**\n * Returns the active server runtime, creating a default one if needed.\n *\n * @example\n * ```ts\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n * @returns The current ManagedRuntime instance.\n */\nexport function get_server_runtime_or_throw(): ManagedRuntime.ManagedRuntime<\n unknown,\n never\n> {\n if (!current_server_runtime) {\n current_server_runtime = ManagedRuntime.make(\n Layer.empty,\n ) as ManagedRuntime.ManagedRuntime<unknown, never>;\n }\n\n return current_server_runtime;\n}\n\n/**\n * Returns a dispatcher backed by the active server runtime.\n *\n * @example\n * ```ts\n * const dispatcher = get_server_dispatcher();\n * ```\n *\n * @since 3.0.1\n * @returns The cached server dispatcher, creating one from the current server\n * runtime when needed.\n */\nexport function get_server_dispatcher(): InternalDispatcher {\n current_server_dispatcher ??= new InternalDispatcher(\n get_server_runtime_or_throw() as unknown as ManagedRuntimeType<\n unknown,\n unknown\n >,\n );\n\n return current_server_dispatcher;\n}\n\n/**\n * Resets the internal server runtime singleton used by source-level tests.\n *\n * @example\n * ```ts\n * reset_server_runtime();\n * ```\n *\n * @since 3.4.0\n * @returns Nothing.\n * @internal\n */\nexport function reset_server_runtime(): void {\n const dispatcher = current_server_dispatcher;\n const runtime = current_server_runtime;\n\n current_server_dispatcher = undefined;\n current_server_runtime = undefined;\n\n if (dispatcher) {\n dispatcher.dispose();\n\n return;\n }\n\n void runtime?.dispose().catch((error: unknown) => {\n queueMicrotask(() => {\n throw error;\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAa,eAAgD,QAC1D,UAAwB,qBAAqB,EAC5C,oBAAoB;CAClB,MAAM,IAAI,6BAA6B;AACzC,EACF,CAAC;;;;;;;;;;;AAYH,IAAa,gBAAb,MAA2B;;;;;;;;CAQzB,OAAO,KACL,OACyC;EACzC,IAAI,wBACF,MAAM,IAAI,+BAA+B,eAAe;EAG1D,MAAM,UAAU,eAAe,KAC7B,SAAU,MAAM,KAClB;EAEA,yBAAyB;EAIzB,4BAA4B,IAAIA,WAC9B,OACF;EAEA,OAAO;CACT;AACF;AAEA,IAAI;AAGJ,IAAI;;;;;;;;;;;;AAaJ,SAAgB,8BAGd;CACA,IAAI,CAAC,wBACH,yBAAyB,eAAe,KACtC,MAAM,KACR;CAGF,OAAO;AACT;;;;;;;;;;;;;AAcA,SAAgB,wBAA4C;CAC1D,8BAA8B,IAAIA,WAChC,4BAA4B,CAI9B;CAEA,OAAO;AACT"}
|