svelte-effect-runtime 3.4.5 → 3.4.7
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-5cizmHtc.js → client-CsVu54pU.js} +119 -56
- package/.dist/chunks/client-CsVu54pU.js.map +1 -0
- package/.dist/chunks/{descriptors-OS4VfJuW.js → descriptors-cOe9uRJz.js} +2 -2
- package/.dist/chunks/descriptors-cOe9uRJz.js.map +1 -0
- package/.dist/chunks/{dispatcher-C38yhZRs.js → dispatcher-LtvFKYUp.js} +3 -3
- package/.dist/chunks/dispatcher-LtvFKYUp.js.map +1 -0
- package/.dist/chunks/{dispatcher-DuBLHNa6.js → dispatcher-pHH4JcFR.js} +12 -11
- package/.dist/chunks/dispatcher-pHH4JcFR.js.map +1 -0
- package/.dist/chunks/{errors-0PaWf7Bq.js → errors-Dcf0MVbq.js} +3 -3
- package/.dist/chunks/errors-Dcf0MVbq.js.map +1 -0
- package/.dist/chunks/remote-client-Bj1pZXgq.js +108 -0
- package/.dist/chunks/remote-client-Bj1pZXgq.js.map +1 -0
- package/.dist/chunks/{runtime-C51Dv3K6.js → runtime-ekkMQ-wL.js} +4 -4
- package/.dist/chunks/runtime-ekkMQ-wL.js.map +1 -0
- package/.dist/chunks/{transform-Cdsx7ygD.js → transform-CEK6Ccll.js} +246 -172
- package/.dist/chunks/transform-CEK6Ccll.js.map +1 -0
- package/.dist/chunks/{vite-DR3-WaqQ.js → vite-Dm3bXmR3.js} +54 -46
- package/.dist/chunks/vite-Dm3bXmR3.js.map +1 -0
- package/.dist/detect.js.map +1 -1
- package/.dist/dispatcher.d.ts +1 -1
- package/.dist/dispatcher.js +1 -1
- package/.dist/errors.d.ts +1 -1
- package/.dist/internal/generators.js +2 -2
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/promise.js.map +1 -1
- package/.dist/markup/run.js +3 -3
- package/.dist/markup/run.js.map +1 -1
- package/.dist/markup/transform/index.d.ts +8 -0
- package/.dist/markup/transform/scan.d.ts +20 -0
- package/.dist/markup/transform/types.d.ts +136 -2
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/markup/value.js.map +1 -1
- package/.dist/mod.js +3 -3
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/client/command.d.ts +1 -1
- package/.dist/remote/client/effect.d.ts +15 -1
- package/.dist/remote/client/index.d.ts +1 -1
- package/.dist/remote/client/types.d.ts +3 -1
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/server.js +27 -9
- package/.dist/remote/server.js.map +1 -1
- package/.dist/remote/shared.d.ts +126 -0
- package/.dist/remote/shared.js +117 -5
- package/.dist/remote/shared.js.map +1 -1
- package/.dist/runtime/transform.js +3 -3
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/types.d.ts +95 -0
- package/.dist/server/effects.d.ts +15 -1
- package/.dist/server/factories.d.ts +128 -9
- package/.dist/server/index.d.ts +1 -1
- package/.dist/server/runtime.d.ts +1 -1
- package/.dist/server/types.d.ts +128 -7
- package/.dist/server.js +28 -13
- package/.dist/server.js.map +1 -1
- package/.dist/vite/remote-client.d.ts +24 -0
- package/.dist/vite.d.ts +8 -3
- package/.dist/vite.js +1 -1
- package/LICENSE +29 -0
- package/package.json +21 -21
- package/.dist/chunks/client-5cizmHtc.js.map +0 -1
- package/.dist/chunks/descriptors-OS4VfJuW.js.map +0 -1
- package/.dist/chunks/dispatcher-C38yhZRs.js.map +0 -1
- package/.dist/chunks/dispatcher-DuBLHNa6.js.map +0 -1
- package/.dist/chunks/errors-0PaWf7Bq.js.map +0 -1
- package/.dist/chunks/runtime-C51Dv3K6.js.map +0 -1
- package/.dist/chunks/transform-Cdsx7ygD.js.map +0 -1
- package/.dist/chunks/vite-DR3-WaqQ.js.map +0 -1
package/.dist/dispatcher.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Code, Dispatcher, get_dispatcher, reset_dispatcher
|
|
1
|
+
export { Code, Dispatcher, get_dispatcher, reset_dispatcher } from "./dispatcher/index.js";
|
|
2
2
|
export type { DispatcherEvent, Dispose, MarkupPromiseEvent, MarkupPromiseOptions, MarkupRunEvent, MarkupValueEvent, PromiseOptions, ValueOptions, } from "./dispatcher/types.js";
|
package/.dist/dispatcher.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as Code, n as get_dispatcher, r as reset_dispatcher, t as Dispatcher } from "./chunks/dispatcher-
|
|
1
|
+
import { i as Code, n as get_dispatcher, r as reset_dispatcher, t as Dispatcher } from "./chunks/dispatcher-pHH4JcFR.js";
|
|
2
2
|
export { Code, Dispatcher, get_dispatcher, reset_dispatcher };
|
package/.dist/errors.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare class PreprocessError extends RuntimeError {
|
|
|
65
65
|
*
|
|
66
66
|
* @since 2.4.0
|
|
67
67
|
* @param plugin_names - Names of Vite plugins that declare pre-transform
|
|
68
|
-
* priority and may parse raw
|
|
68
|
+
* priority and may parse raw component files before SER lowers them.
|
|
69
69
|
* @returns A runtime-authored Error describing the possible plugin ordering
|
|
70
70
|
* conflict.
|
|
71
71
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Code } from "../chunks/dispatcher-
|
|
2
|
-
import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-
|
|
1
|
+
import { i as Code } from "../chunks/dispatcher-pHH4JcFR.js";
|
|
2
|
+
import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-LtvFKYUp.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";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-
|
|
1
|
+
import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-CsVu54pU.js";
|
|
2
2
|
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
|
package/.dist/markup/promise.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/promise.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Options for markup promise behavior during server rendering.\n *\n * @since 2.4.0\n */\ninterface MarkupPromiseOptions {\n
|
|
1
|
+
{"version":3,"file":"promise.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/promise.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Options for markup promise behavior during server rendering.\n *\n * @since 2.4.0\n */\ninterface MarkupPromiseOptions {\n\t/** Keep the SSR promise pending so Svelte renders an await block fallback. */\n\tssr?: \"pending\";\n}\n\n/**\n * Runtime helper emitted by the markup transform for\n * `{#await yield* expr}` blocks. Delegates to the dispatcher's\n * promise mechanism. During SSR it can return a fallback promise without\n * starting the dispatcher.\n *\n * @since 2.0.0\n * @param id - Stable identifier generated from the expression's source\n * position, used for cache lookups.\n * @param deps - Array of reactive dependencies.\n * @param factory - Generator function that yields the effect to run.\n * @param ssr_fallback - Value to resolve during SSR when the helper is used\n * from an awaited expression outside a Svelte await block.\n * @param options - Optional SSR behavior for contexts such as await blocks\n * that should render pending UI.\n * @returns A Promise that resolves with the effect's result.\n */\nexport function promise<A, E, R>(\n\tid: string,\n\tdeps: readonly unknown[],\n\tfactory: () => Effect.gen.Return<A, E, R>,\n\tssr_fallback?: A,\n\toptions?: MarkupPromiseOptions,\n): Promise<A> {\n\tif (is_server_render()) {\n\t\tif (options?.ssr === \"pending\") {\n\t\t\treturn new Promise<A>(() => {});\n\t\t}\n\n\t\tif (arguments.length >= 4) {\n\t\t\treturn Promise.resolve(ssr_fallback as A);\n\t\t}\n\t}\n\n\treturn get_dispatcher().promise({ id, deps, factory });\n}\n\nfunction is_server_render(): boolean {\n\treturn typeof document === \"undefined\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,QACf,IACA,MACA,SACA,cACA,SACa;CACb,IAAI,iBAAiB,GAAG;EACvB,IAAI,SAAS,QAAQ,WACpB,OAAO,IAAI,cAAiB,CAAC,CAAC;EAG/B,IAAI,UAAU,UAAU,GACvB,OAAO,QAAQ,QAAQ,YAAiB;CAE1C;CAEA,OAAO,eAAe,CAAC,CAAC,QAAQ;EAAE;EAAI;EAAM;CAAQ,CAAC;AACtD;AAEA,SAAS,mBAA4B;CACpC,OAAO,OAAO,aAAa;AAC5B"}
|
package/.dist/markup/run.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as get_dispatcher } from "../chunks/dispatcher-
|
|
1
|
+
import { n as get_dispatcher } from "../chunks/dispatcher-LtvFKYUp.js";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
//#region src/markup/run.ts
|
|
4
4
|
/**
|
|
@@ -12,8 +12,8 @@ import { Effect } from "effect";
|
|
|
12
12
|
* @returns A Promise that resolves or rejects when the effect completes.
|
|
13
13
|
*/
|
|
14
14
|
function run(factory) {
|
|
15
|
-
const
|
|
16
|
-
return get_dispatcher().run(
|
|
15
|
+
const Program = Effect.gen(factory);
|
|
16
|
+
return get_dispatcher().run(Program);
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
19
|
export { run };
|
package/.dist/markup/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/run.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup transform for inline event\n * handlers containing `yield*`. Wraps the user's generator in an\n * `Effect.gen` and delegates to the dispatcher's fire-and-forget\n * mechanism.\n *\n * @since 2.0.0\n * @param factory - Generator function that yields the effect to run.\n * @returns A Promise that resolves or rejects when the effect completes.\n */\nexport function run<A, E, R>(
|
|
1
|
+
{"version":3,"file":"run.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/run.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup transform for inline event\n * handlers containing `yield*`. Wraps the user's generator in an\n * `Effect.gen` and delegates to the dispatcher's fire-and-forget\n * mechanism.\n *\n * @since 2.0.0\n * @param factory - Generator function that yields the effect to run.\n * @returns A Promise that resolves or rejects when the effect completes.\n */\nexport function run<A, E, R>(factory: () => Effect.gen.Return<A, E, R>): Promise<A> {\n\tconst Program = Effect.gen(factory);\n\n\treturn get_dispatcher().run(Program);\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,IAAa,SAAuD;CACnF,MAAM,UAAU,OAAO,IAAI,OAAO;CAElC,OAAO,eAAe,CAAC,CAAC,IAAI,OAAO;AACpC"}
|
|
@@ -10,6 +10,14 @@ export type { MarkupRelocation, MarkupTransformOptions, MarkupTransformResult, M
|
|
|
10
10
|
* context for each placeholder (plain expression, #each, #await, event
|
|
11
11
|
* handler, etc.).
|
|
12
12
|
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const result = transform_markup_effect(
|
|
16
|
+
* "<button onclick={yield* save()}>Save</button>",
|
|
17
|
+
* "SaveButton.svelte",
|
|
18
|
+
* );
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
13
21
|
* @since 2.0.0
|
|
14
22
|
* @param content - The raw `.svelte` file content.
|
|
15
23
|
* @param filename - The source filename, used in error messages.
|
|
@@ -3,6 +3,26 @@ interface SanitizeResult {
|
|
|
3
3
|
code: string;
|
|
4
4
|
candidates: MarkupCandidate[];
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Replaces markup `yield*` expressions with placeholders before Svelte parses
|
|
8
|
+
* the component.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const sanitized = sanitize_markup(
|
|
13
|
+
* `<p>{yield* loadLabel()}</p>`,
|
|
14
|
+
* "Label.svelte",
|
|
15
|
+
* );
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @since 2.0.0
|
|
19
|
+
* @param content - Raw Svelte component source to scan for effectful markup
|
|
20
|
+
* expressions.
|
|
21
|
+
* @param filename - Source filename used when validation errors need to point
|
|
22
|
+
* back to the component being transformed.
|
|
23
|
+
* @returns Sanitized source plus placeholder candidates that should be lowered
|
|
24
|
+
* after Svelte classifies their markup positions.
|
|
25
|
+
*/
|
|
6
26
|
export declare function sanitize_markup(content: string, filename: string): SanitizeResult;
|
|
7
27
|
export {};
|
|
8
28
|
/** Free identifier collection helpers for generated closures. */
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Result of the markup transform pass.
|
|
3
3
|
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const result: MarkupTransformResult = {
|
|
7
|
+
* code: "<p>{__SER___value}</p>",
|
|
8
|
+
* has_yield: true,
|
|
9
|
+
* };
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
4
12
|
* @since 2.0.0
|
|
5
13
|
*/
|
|
6
14
|
export interface MarkupTransformResult {
|
|
@@ -38,7 +46,21 @@ export interface MarkupTransformOptions {
|
|
|
38
46
|
/** Legacy emission target retained for compatibility with older callers. */
|
|
39
47
|
target?: MarkupTransformTarget;
|
|
40
48
|
}
|
|
41
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Offset mapping between original markup and generated helper code.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const relocation: MarkupRelocation = {
|
|
55
|
+
* originalStart: 4,
|
|
56
|
+
* originalEnd: 17,
|
|
57
|
+
* generatedStart: 32,
|
|
58
|
+
* generatedEnd: 45,
|
|
59
|
+
* };
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @since 3.2.3
|
|
63
|
+
*/
|
|
42
64
|
export interface MarkupRelocation {
|
|
43
65
|
/** Start offset in the original source. */
|
|
44
66
|
originalStart: number;
|
|
@@ -49,7 +71,23 @@ export interface MarkupRelocation {
|
|
|
49
71
|
/** End offset in the transformed source. */
|
|
50
72
|
generatedEnd: number;
|
|
51
73
|
}
|
|
52
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Describes a brace expression that contains `yield*` and needs lowering.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const candidate: MarkupCandidate = {
|
|
80
|
+
* placeholder: "__SER___0",
|
|
81
|
+
* start: 4,
|
|
82
|
+
* end: 19,
|
|
83
|
+
* expr_text: "yield* load()",
|
|
84
|
+
* filename: "App.svelte",
|
|
85
|
+
* key: "plain",
|
|
86
|
+
* };
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @since 2.0.0
|
|
90
|
+
*/
|
|
53
91
|
export interface MarkupCandidate {
|
|
54
92
|
/** The placeholder identifier injected into the sanitized markup. */
|
|
55
93
|
placeholder: string;
|
|
@@ -64,7 +102,31 @@ export interface MarkupCandidate {
|
|
|
64
102
|
/** Whether this expression is a key context (each/promise/render key). */
|
|
65
103
|
key: TagKind;
|
|
66
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Markup AST context where a lowered `yield*` expression was discovered.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* const kind: TagKind = "event";
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @since 2.0.0
|
|
114
|
+
*/
|
|
67
115
|
export type TagKind = "plain" | "each" | "await" | "event" | "render" | "render_argument";
|
|
116
|
+
/**
|
|
117
|
+
* Source edit emitted for one lowered markup candidate.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* const replacement: Replacement = {
|
|
122
|
+
* start: 4,
|
|
123
|
+
* end: 19,
|
|
124
|
+
* text: "__SER___value",
|
|
125
|
+
* };
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @since 2.0.0
|
|
129
|
+
*/
|
|
68
130
|
export interface Replacement {
|
|
69
131
|
start: number;
|
|
70
132
|
end: number;
|
|
@@ -72,25 +134,97 @@ export interface Replacement {
|
|
|
72
134
|
helpers?: HelperDeclaration[];
|
|
73
135
|
relocation?: PendingRelocation;
|
|
74
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Helper declaration emitted alongside markup replacements.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const helper: HelperDeclaration = {
|
|
143
|
+
* text: "const __SER___value = dispatcher.value(...);",
|
|
144
|
+
* };
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* @since 2.0.0
|
|
148
|
+
*/
|
|
75
149
|
export interface HelperDeclaration {
|
|
76
150
|
text: string;
|
|
77
151
|
relocation?: PendingRelocation;
|
|
78
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Relocation range that is relative to a pending replacement.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* const relocation: PendingRelocation = {
|
|
159
|
+
* originalStart: 4,
|
|
160
|
+
* originalEnd: 17,
|
|
161
|
+
* generatedStartInReplacement: 6,
|
|
162
|
+
* generatedEndInReplacement: 19,
|
|
163
|
+
* };
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @since 3.2.3
|
|
167
|
+
*/
|
|
79
168
|
export interface PendingRelocation {
|
|
80
169
|
originalStart: number;
|
|
81
170
|
originalEnd: number;
|
|
82
171
|
generatedStartInReplacement: number;
|
|
83
172
|
generatedEndInReplacement: number;
|
|
84
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Helper-code insertion point with optional relocation metadata.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* const insertion: Insertion = {
|
|
180
|
+
* start: 42,
|
|
181
|
+
* text: "<script>const dispatcher = get_dispatcher();</script>",
|
|
182
|
+
* };
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* @since 2.0.0
|
|
186
|
+
*/
|
|
85
187
|
export interface Insertion {
|
|
86
188
|
start: number;
|
|
87
189
|
text: string;
|
|
88
190
|
relocations?: PendingRelocation[];
|
|
89
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Generated binding names used by markup helper injection.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* const bindings: MarkupHelperBindings = {
|
|
198
|
+
* codes: "__SER___codes",
|
|
199
|
+
* dispatcher: "__SER___dispatcher",
|
|
200
|
+
* };
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @since 2.0.0
|
|
204
|
+
*/
|
|
90
205
|
export interface MarkupHelperBindings {
|
|
91
206
|
codes: string;
|
|
92
207
|
dispatcher: string;
|
|
93
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Allocator that reserves collision-free helper names for generated markup.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* const allocator: MarkupNameAllocator = {
|
|
215
|
+
* reserve: (name) => name,
|
|
216
|
+
* };
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @since 2.0.0
|
|
220
|
+
*/
|
|
94
221
|
export interface MarkupNameAllocator {
|
|
222
|
+
/**
|
|
223
|
+
* Reserves a generated name.
|
|
224
|
+
*
|
|
225
|
+
* @param name - Preferred identifier to reserve.
|
|
226
|
+
* @returns A collision-free identifier that can be emitted into generated
|
|
227
|
+
* markup helper code.
|
|
228
|
+
*/
|
|
95
229
|
reserve(name: string): string;
|
|
96
230
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as transform_markup_effect } from "../chunks/transform-
|
|
1
|
+
import { t as transform_markup_effect } from "../chunks/transform-CEK6Ccll.js";
|
|
2
2
|
export { transform_markup_effect };
|
package/.dist/markup/value.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/value.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup transform for `{yield* expr}`\n * expressions in Svelte templates. Delegates to the dispatcher's\n * cached reactive value mechanism — returns the fallback synchronously,\n * then the resolved value once the effect completes in the browser. During\n * SSR the client dispatcher is not touched, so browser-only layers cannot\n * turn server rendering into a 500.\n *\n * @since 2.0.0\n * @param id - Stable identifier generated from the expression's source\n * position, used for cache lookups.\n * @param deps - Array of reactive dependencies (free identifiers in the\n * expression). When any dep changes, the previous fiber is cancelled\n * and a new one starts.\n * @param fallback - Value returned while the effect is running.\n * @param factory - Generator function that yields the effect to run.\n * @returns The cached value if resolved, or the fallback.\n */\nexport function value<A, F, E, R>(\n
|
|
1
|
+
{"version":3,"file":"value.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/value.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup transform for `{yield* expr}`\n * expressions in Svelte templates. Delegates to the dispatcher's\n * cached reactive value mechanism — returns the fallback synchronously,\n * then the resolved value once the effect completes in the browser. During\n * SSR the client dispatcher is not touched, so browser-only layers cannot\n * turn server rendering into a 500.\n *\n * @since 2.0.0\n * @param id - Stable identifier generated from the expression's source\n * position, used for cache lookups.\n * @param deps - Array of reactive dependencies (free identifiers in the\n * expression). When any dep changes, the previous fiber is cancelled\n * and a new one starts.\n * @param fallback - Value returned while the effect is running.\n * @param factory - Generator function that yields the effect to run.\n * @returns The cached value if resolved, or the fallback.\n */\nexport function value<A, F, E, R>(\n\tid: string,\n\tdeps: readonly unknown[],\n\tfallback: F,\n\tfactory: () => Effect.gen.Return<A, E, R>,\n): A | F {\n\tif (is_server_render()) {\n\t\treturn fallback;\n\t}\n\n\treturn get_dispatcher().value<A | F>({ id, deps, fallback, factory });\n}\n\nfunction is_server_render(): boolean {\n\treturn typeof document === \"undefined\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,MACf,IACA,MACA,UACA,SACQ;CACR,IAAI,iBAAiB,GACpB,OAAO;CAGR,OAAO,eAAe,CAAC,CAAC,MAAa;EAAE;EAAI;EAAM;EAAU;CAAQ,CAAC;AACrE;AAEA,SAAS,mBAA4B;CACpC,OAAO,OAAO,aAAa;AAC5B"}
|
package/.dist/mod.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as YieldStarInEventCallbackError, C as UncheckedLiveQueryHandlerMissingError, D as UnsupportedMarkupEffectPositionError, E as UnknownRuntimeError, O as UnsupportedRemoteFormResponseError, S as UncheckedFormHandlerMissingError, T as UncheckedQueryHandlerMissingError, _ as RuntimeAlreadyInitializedError, a as DispatcherDisposedError, b as SvelteKitServerExportUnavailableError, c as InvalidLiveQueryReturnError, d as PreprocessError, f as RemoteErrorDecodeError, g as RequestEventUnavailableError, h as RemoteHelperError, i as BatchQueryHandlerMissingError, k as VitePreTransformPluginConflictError, l as InvalidQueryFactoryError, m as RemoteHelperContextError, n as AsyncEffectInSyncRuneError, o as InvalidCommandFactoryError, p as RemoteFormEndpointMissingError, r as AwaitInEffectWorkError, s as InvalidLiveQueryFactoryError, t as AsyncEffectInEventCallbackError, u as InvalidRemoteFormResponseError, v as RuntimeError, w as UncheckedPrerenderHandlerMissingError, x as UncheckedCommandHandlerMissingError, y as ServerOnlyImportError } from "./chunks/errors-
|
|
2
|
-
import { t as Dispatcher } from "./chunks/dispatcher-
|
|
1
|
+
import { A as YieldStarInEventCallbackError, C as UncheckedLiveQueryHandlerMissingError, D as UnsupportedMarkupEffectPositionError, E as UnknownRuntimeError, O as UnsupportedRemoteFormResponseError, S as UncheckedFormHandlerMissingError, T as UncheckedQueryHandlerMissingError, _ as RuntimeAlreadyInitializedError, a as DispatcherDisposedError, b as SvelteKitServerExportUnavailableError, c as InvalidLiveQueryReturnError, d as PreprocessError, f as RemoteErrorDecodeError, g as RequestEventUnavailableError, h as RemoteHelperError, i as BatchQueryHandlerMissingError, k as VitePreTransformPluginConflictError, l as InvalidQueryFactoryError, m as RemoteHelperContextError, n as AsyncEffectInSyncRuneError, o as InvalidCommandFactoryError, p as RemoteFormEndpointMissingError, r as AwaitInEffectWorkError, s as InvalidLiveQueryFactoryError, t as AsyncEffectInEventCallbackError, u as InvalidRemoteFormResponseError, v as RuntimeError, w as UncheckedPrerenderHandlerMissingError, x as UncheckedCommandHandlerMissingError, y as ServerOnlyImportError } from "./chunks/errors-Dcf0MVbq.js";
|
|
2
|
+
import { t as Dispatcher } from "./chunks/dispatcher-pHH4JcFR.js";
|
|
3
3
|
import { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error } from "./remote/shared.js";
|
|
4
|
-
import { t as effect } from "./chunks/vite-
|
|
4
|
+
import { t as effect } from "./chunks/vite-Dm3bXmR3.js";
|
|
5
5
|
//#region src/mod.ts
|
|
6
6
|
/**
|
|
7
7
|
* Public API surface for `svelte-effect-runtime`.
|
package/.dist/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport { ServerOnlyImportError } from \"$/errors.ts\";\nimport type {
|
|
1
|
+
{"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport { ServerOnlyImportError } from \"$/errors.ts\";\nimport type { ErrorEffectFactory, RedirectEffectFactory } from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n\tCommandFactory,\n\tFormFactory,\n\tPrerenderFactory,\n\tQueryFactory,\n\tServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n\t/**\n\t * Build and cache the client-side dispatcher runtime.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): void {\n\t\tInternalDispatcher.make(layer);\n\t}\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\"ServerRuntime\") as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(make_server_only_function(\"Query\"), {\n\tbatch: make_server_only_function(\"Query.batch\"),\n\tlive: make_server_only_function(\"Query.live\"),\n}) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\"Command\") as never;\n\n/**\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\n * from the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Error } from \"svelte-effect-runtime\";\n *\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Error: ErrorEffectFactory = make_server_only_function(\"Error\") as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\"Form\") as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\"Prerender\") as never;\n\n/**\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\n * the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Redirect } from \"svelte-effect-runtime\";\n *\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\"Redirect\") as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> = make_server_only_function(\n\t\"RequestEvent\",\n) as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<unknown, never> =\n\tmake_server_only_function(\"get_server_runtime_or_throw\") as never;\n\n/** Re-export error types users need for typed catch handlers. */\nexport type {\n\tFormError,\n\tFormIssue,\n\tRemoteFailure,\n\tRemoteHttpError,\n\tRemoteTransportError,\n\tRemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n\tAsyncEffectInEventCallbackError,\n\tAsyncEffectInSyncRuneError,\n\tAwaitInEffectWorkError,\n\tBatchQueryHandlerMissingError,\n\tDispatcherDisposedError,\n\tInvalidCommandFactoryError,\n\tInvalidLiveQueryFactoryError,\n\tInvalidLiveQueryReturnError,\n\tInvalidQueryFactoryError,\n\tInvalidRemoteFormResponseError,\n\tPreprocessError,\n\tRemoteErrorDecodeError,\n\tRemoteFormEndpointMissingError,\n\tRemoteHelperContextError,\n\tRemoteHelperError,\n\tRequestEventUnavailableError,\n\tRuntimeAlreadyInitializedError,\n\tRuntimeError,\n\tServerOnlyImportError,\n\tSvelteKitServerExportUnavailableError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n\tUnknownRuntimeError,\n\tUnsupportedMarkupEffectPositionError,\n\tUnsupportedRemoteFormResponseError,\n\tVitePreTransformPluginConflictError,\n\tYieldStarInEventCallbackError,\n} from \"$/errors.ts\";\n\nexport {\n\tis_form_error,\n\tis_remote_http_error,\n\tis_remote_transport_error,\n\tis_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\n/** Re-export app setup helpers so users can import them from root. */\nexport { effect, type EffectOptions } from \"$/vite.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tErrorBody,\n\tErrorEffectFactory,\n\tErrorProperties,\n\tErrorStatus,\n\tErrorStatusName,\n\tRedirectEffectFactory,\n\tRedirectOptions,\n\tRedirectStatus,\n\tRedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tCommandFactory,\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteForm,\n\tEffectRemoteFunction,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemoteLiveQueryResource,\n\tEffectRemoteLiveSource,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tFormFactory,\n\tFormInvalid,\n\tPrerenderFactory,\n\tPrerenderOptions,\n\tQueryBatchFactory,\n\tQueryFactory,\n\tQueryLiveFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tServerRuntimeFactory,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"$/server/types.ts\";\n\nfunction make_server_only_class(name: string): unknown {\n\treturn class ServerOnlyRuntime {\n\t\tstatic make(): never {\n\t\t\tthrow make_server_only_error(name);\n\t\t}\n\t};\n}\n\nfunction make_server_only_function(name: string): (...args: unknown[]) => never {\n\treturn (..._args: unknown[]): never => {\n\t\tthrow make_server_only_error(name);\n\t};\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n\treturn new ServerOnlyImportError(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,gBAAb,MAA2B;;;;;;;CAO1B,OAAO,KAAgB,OAA8B;EACpD,WAAmB,KAAK,KAAK;CAC9B;AACD;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBAAuB,eAAe;;;;;;;;;;;;;;AAezF,MAAa,QAAsB,OAAO,OAAO,0BAA0B,OAAO,GAAG;CACpF,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC7C,CAAC;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BAA0B,SAAS;;;;;;;;;;;;;;;AAgB1E,MAAa,QAA4B,0BAA0B,OAAO;;;;;;;;;;;;;;AAe1E,MAAa,OAAoB,0BAA0B,MAAM;;;;;;;;;;;;;;;AAgBjE,MAAa,YAA8B,0BAA0B,WAAW;;;;;;;;;;;;;;;AAgBhF,MAAa,WAAkC,0BAA0B,UAAU;;;;;;;;;;;;;;;AAgBnF,MAAa,eAAqD,0BACjE,cACD;;;;;;;;;;;;;;AAeA,MAAa,8BACZ,0BAA0B,6BAA6B;AAoGxD,SAAS,uBAAuB,MAAuB;CACtD,OAAO,MAAM,kBAAkB;EAC9B,OAAO,OAAc;GACpB,MAAM,uBAAuB,IAAI;EAClC;CACD;AACD;AAEA,SAAS,0BAA0B,MAA6C;CAC/E,QAAQ,GAAG,UAA4B;EACtC,MAAM,uBAAuB,IAAI;CAClC;AACD;AAEA,SAAS,uBAAuB,MAAgC;CAC/D,OAAO,IAAI,sBAAsB,IAAI;AACtC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RemoteFailure } from "../shared.js";
|
|
2
|
-
import type { Effect } from "effect";
|
|
3
2
|
import type { Pending } from "./types.js";
|
|
3
|
+
import type { Effect } from "effect";
|
|
4
4
|
type EffectRemoteCommandAdapter<Input, Output, ErrorType = never> = ((input: undefined extends Input ? Input | void : Input) => Effect.Effect<Output, RemoteFailure<ErrorType>>) & {
|
|
5
5
|
readonly pending: number;
|
|
6
6
|
};
|
|
@@ -12,4 +12,18 @@ import { Effect } from "effect";
|
|
|
12
12
|
* @param run - Promise-producing operation that invokes a native remote helper.
|
|
13
13
|
* @returns Effect that maps thrown values into remote failures.
|
|
14
14
|
*/
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function MakeEffectFromPromise<Output, ErrorType = never>(run: () => Promise<Output>): Effect.Effect<Output, RemoteFailure<ErrorType>>;
|
|
16
|
+
/**
|
|
17
|
+
* Compatibility alias for {@link MakeEffectFromPromise}.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const program = make_effect_from_promise(() => native_remote(input));
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @since 2.0.0
|
|
25
|
+
* @param run - Promise-producing operation that invokes a native remote helper.
|
|
26
|
+
* @returns Effect that maps thrown values into remote failures.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare const make_effect_from_promise: typeof MakeEffectFromPromise;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { create_remote_command_adapter } from "./command.js";
|
|
2
2
|
export { create_remote_form_adapter } from "./form.js";
|
|
3
|
-
export { create_remote_live_query_adapter, create_remote_query_adapter
|
|
3
|
+
export { create_remote_live_query_adapter, create_remote_query_adapter } from "./query.js";
|
|
4
4
|
export type { EffectRemoteForm, EffectRemoteFormEnhanceOptions, EffectRemoteFormSubmit, Pending, } from "./types.js";
|
|
@@ -18,7 +18,9 @@ export declare const EFFECT_REMOTE_QUERY_UPDATE: unique symbol;
|
|
|
18
18
|
export type EffectRemoteQueryUpdateBrand = {
|
|
19
19
|
readonly [EFFECT_REMOTE_QUERY_UPDATE]: true;
|
|
20
20
|
};
|
|
21
|
-
type EffectRemoteFormCallable<Input extends RemoteFormInput | void, Output, ErrorType> = [
|
|
21
|
+
type EffectRemoteFormCallable<Input extends RemoteFormInput | void, Output, ErrorType> = [
|
|
22
|
+
Input
|
|
23
|
+
] extends [void] ? () => Effect.Effect<Output, RemoteFailure<ErrorType>> : undefined extends Input ? (input?: Input) => Effect.Effect<Output, RemoteFailure<ErrorType>> : (input: Input) => Effect.Effect<Output, RemoteFailure<ErrorType>>;
|
|
22
24
|
type EffectRemoteQueryUpdate = NativeRemoteQueryUpdate | EffectRemoteQueryUpdateFunction | EffectRemoteLiveQueryUpdateFunction;
|
|
23
25
|
type EffectRemoteCommandUpdate = {
|
|
24
26
|
readonly pending: number;
|
package/.dist/remote/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-
|
|
1
|
+
import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-CsVu54pU.js";
|
|
2
2
|
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
|
package/.dist/remote/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as RemoteHelperError, m as RemoteHelperContextError } from "../chunks/errors-
|
|
1
|
+
import { h as RemoteHelperError, m as RemoteHelperContextError } from "../chunks/errors-Dcf0MVbq.js";
|
|
2
2
|
import { create_serialized_remote_failure_envelope } from "./shared.js";
|
|
3
3
|
import { Cause, Effect, Exit } from "effect";
|
|
4
4
|
import { isHttpError, isRedirect, isValidationError } from "@sveltejs/kit";
|
|
@@ -64,13 +64,10 @@ function handle_failure(cause, invalid, error) {
|
|
|
64
64
|
function encode_remote_failure(cause) {
|
|
65
65
|
const reasons = get_cause_reasons(cause);
|
|
66
66
|
for (const reason of reasons) if (Cause.isFailReason(reason)) {
|
|
67
|
-
const
|
|
68
|
-
const encoded = stringify_failure(failure);
|
|
67
|
+
const encoded = stringify_failure(to_public_remote_failure(reason.error));
|
|
69
68
|
if (encoded !== void 0) return encoded;
|
|
70
|
-
const serializable_encoded = stringify_failure(to_serializable_failure(failure));
|
|
71
|
-
if (serializable_encoded !== void 0) return serializable_encoded;
|
|
72
69
|
}
|
|
73
|
-
return
|
|
70
|
+
return stringify_unknown_remote_failure();
|
|
74
71
|
}
|
|
75
72
|
function get_cause_reasons(cause) {
|
|
76
73
|
return cause.reasons ?? [];
|
|
@@ -85,13 +82,18 @@ function stringify_failure(value) {
|
|
|
85
82
|
return;
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
|
-
function
|
|
85
|
+
function to_public_remote_failure(value) {
|
|
86
|
+
if (!has_public_remote_failure_tag(value)) return create_unknown_remote_failure();
|
|
87
|
+
return to_serializable_public_failure(value) ?? create_unknown_remote_failure();
|
|
88
|
+
}
|
|
89
|
+
function to_serializable_public_failure(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
89
90
|
if (typeof value === "function" || typeof value === "symbol") return;
|
|
90
91
|
if (!is_object_like(value)) return value;
|
|
91
92
|
if (stringify_failure(value) !== void 0) return value;
|
|
93
|
+
if (is_internal_object(value)) return;
|
|
92
94
|
if (seen.has(value)) return;
|
|
93
95
|
seen.add(value);
|
|
94
|
-
const serializable = Array.isArray(value) ? value.map((item) =>
|
|
96
|
+
const serializable = Array.isArray(value) ? value.map((item) => to_serializable_public_failure(item, seen)) : to_plain_record(value, seen);
|
|
95
97
|
seen.delete(value);
|
|
96
98
|
return serializable;
|
|
97
99
|
}
|
|
@@ -100,7 +102,7 @@ function to_plain_record(value, seen) {
|
|
|
100
102
|
const record = {};
|
|
101
103
|
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
102
104
|
if (key === "stack" || !("value" in descriptor)) continue;
|
|
103
|
-
record[key] =
|
|
105
|
+
record[key] = to_serializable_public_failure(descriptor.value, seen);
|
|
104
106
|
}
|
|
105
107
|
if (value instanceof Error && !("message" in record)) record.message = value.message;
|
|
106
108
|
return record;
|
|
@@ -108,6 +110,22 @@ function to_plain_record(value, seen) {
|
|
|
108
110
|
function is_object_like(value) {
|
|
109
111
|
return typeof value === "object" && value !== null;
|
|
110
112
|
}
|
|
113
|
+
function has_public_remote_failure_tag(value) {
|
|
114
|
+
return is_object_like(value) && typeof value._tag === "string";
|
|
115
|
+
}
|
|
116
|
+
function is_internal_object(value) {
|
|
117
|
+
return !Array.isArray(value) && !is_plain_record(value) && !has_public_remote_failure_tag(value);
|
|
118
|
+
}
|
|
119
|
+
function is_plain_record(value) {
|
|
120
|
+
const prototype = Object.getPrototypeOf(value);
|
|
121
|
+
return prototype === Object.prototype || prototype === null;
|
|
122
|
+
}
|
|
123
|
+
function create_unknown_remote_failure() {
|
|
124
|
+
return { message: "[UNKNOWN_REMOTE_FAILURE]: Unknown error" };
|
|
125
|
+
}
|
|
126
|
+
function stringify_unknown_remote_failure() {
|
|
127
|
+
return stringify(create_unknown_remote_failure());
|
|
128
|
+
}
|
|
111
129
|
/**
|
|
112
130
|
* Throws a SvelteKit `invalid` response from a {@link FormError}, calling
|
|
113
131
|
* through to the request-scoped `invalid` helper.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { RemoteHelperContextError, RemoteHelperError } from \"$/errors.ts\";\nimport { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\nimport { Cause, Effect, Exit } from \"effect\";\nimport { stringify } from \"devalue\";\n\ntype CauseReason = {\n readonly _tag: string;\n readonly defect?: unknown;\n readonly error?: unknown;\n};\n\ntype SvelteInvalid = (...issues: readonly (FormIssue | string)[]) => never;\n\ntype SvelteError = (status: number, body: unknown) => never;\n\nconst request_event_context_error_start =\n \"Can only read the current request event inside functions invoked during `handle`\";\n\nconst request_store_context_error = \"Could not get the request store.\";\n\n/**\n * Runs a user-supplied Effect program through a ManagedRuntime, maps its\n * exit into the shape expected by SvelteKit, and returns the result or\n * throws a SvelteKit-compatible error.\n *\n * @since 2.0.0\n * @param effect - The Effect program to execute.\n * @param runtime - The server-side ManagedRuntime.\n * @param invalid - SvelteKit's `invalid` helper (bound per-request).\n * @param error - SvelteKit's `error` helper.\n * @returns A Promise that resolves with the effect's success value.\n * @internal\n */\nexport async function run_remote_effect<A>(\n effect: Effect.Effect<A, unknown, unknown>,\n runtime: {\n runPromise: (\n e: Effect.Effect<unknown, unknown, unknown>,\n ) => Promise<unknown>;\n },\n invalid: SvelteInvalid,\n error: SvelteError,\n): Promise<A> {\n const exit: Exit.Exit<A, unknown> = await runtime.runPromise(\n Effect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\n ) as Exit.Exit<A, unknown>;\n\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n handle_failure(exit.cause, invalid, error);\n}\n\n/**\n * Inspects the Effect Cause for failures and either throws a form\n * validation error (via SvelteKit's `invalid`) or encodes the error\n * and throws it via SvelteKit's `error`.\n */\nfunction handle_failure(\n cause: Cause.Cause<unknown>,\n invalid: SvelteInvalid,\n error: SvelteError,\n): never {\n const reasons = get_cause_reasons(cause);\n\n /**\n * Phase 1 — let SvelteKit's thrown control-flow sentinels escape.\n */\n for (const reason of reasons) {\n if (!Cause.isDieReason(reason as never)) {\n continue;\n }\n\n const defect = reason.defect;\n\n if (is_sveltekit_control_flow(defect)) {\n throw defect;\n }\n }\n\n /**\n * Phase 2 — let cancellation escape without becoming a remote failure.\n */\n if (Cause.hasInterruptsOnly(cause)) {\n throw Cause.squash(cause);\n }\n\n /**\n * Phase 3 — preserve typed form validation failures.\n */\n for (const reason of reasons) {\n if (Cause.isFailReason(reason as never)) {\n const failure = reason.error;\n if (\n typeof failure === \"object\" &&\n failure !== null &&\n (failure as Record<string, unknown>)._tag === \"FormError\"\n ) {\n const issues = (failure as { issues?: readonly FormIssue[] }).issues ??\n [];\n invalid(...issues);\n }\n }\n }\n\n /**\n * Phase 4 — encode all other failures for the remote client.\n */\n const encoded = encode_remote_failure(cause);\n const envelope = create_serialized_remote_failure_envelope(encoded);\n\n error(500, envelope);\n}\n\n/**\n * Encodes an Effect Cause into a string that the client-side adapter can\n * decode back into a typed `RemoteFailure`.\n *\n * @since 2.0.0\n * @param cause - The Effect Cause from a failed execution.\n * @returns A devalue-encoded string representing the serialised failure.\n * @internal\n */\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\n const reasons = get_cause_reasons(cause);\n\n for (const reason of reasons) {\n if (Cause.isFailReason(reason as never)) {\n const failure = reason.error;\n\n const encoded = stringify_failure(failure);\n\n if (encoded !== undefined) {\n return encoded;\n }\n\n const serializable_failure = to_serializable_failure(failure);\n const serializable_encoded = stringify_failure(serializable_failure);\n\n if (serializable_encoded !== undefined) {\n return serializable_encoded;\n }\n }\n }\n\n return stringify({ message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" });\n}\n\nfunction get_cause_reasons(\n cause: Cause.Cause<unknown>,\n): readonly CauseReason[] {\n const reasons = (cause as unknown as { reasons?: readonly CauseReason[] })\n .reasons;\n\n return reasons ?? [];\n}\n\nfunction is_sveltekit_control_flow(value: unknown): boolean {\n return isRedirect(value) || isHttpError(value) || isValidationError(value);\n}\n\nfunction stringify_failure(value: unknown): string | undefined {\n try {\n return stringify(value);\n } catch {\n return undefined;\n }\n}\n\nfunction to_serializable_failure(\n value: unknown,\n seen = new WeakSet<object>(),\n): unknown {\n if (typeof value === \"function\" || typeof value === \"symbol\") {\n return undefined;\n }\n\n if (!is_object_like(value)) {\n return value;\n }\n\n if (stringify_failure(value) !== undefined) {\n return value;\n }\n\n if (seen.has(value)) {\n return undefined;\n }\n\n seen.add(value);\n\n const serializable = Array.isArray(value)\n ? value.map((item) => to_serializable_failure(item, seen))\n : to_plain_record(value, seen);\n\n seen.delete(value);\n\n return serializable;\n}\n\nfunction to_plain_record(\n value: object,\n seen: WeakSet<object>,\n): Record<string, unknown> {\n const descriptors = Object.getOwnPropertyDescriptors(value);\n const record: Record<string, unknown> = {};\n\n for (const [key, descriptor] of Object.entries(descriptors)) {\n if (key === \"stack\" || !(\"value\" in descriptor)) {\n continue;\n }\n\n record[key] = to_serializable_failure(descriptor.value, seen);\n }\n\n if (value instanceof Error && !(\"message\" in record)) {\n record.message = value.message;\n }\n\n return record;\n}\n\nfunction is_object_like(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\n\n/**\n * Throws a SvelteKit `invalid` response from a {@link FormError}, calling\n * through to the request-scoped `invalid` helper.\n *\n * @example\n * ```ts\n * throw_form_error(\n * [{ message: \"Name is required\", path: [\"name\"] }],\n * invalid,\n * );\n * ```\n *\n * @since 2.0.0\n * @param issues - The list of form validation issues.\n * @param invalid - SvelteKit's `invalid` helper bound to the current request.\n * @internal\n */\nexport function throw_form_error(\n issues: readonly FormIssue[],\n invalid: SvelteInvalid,\n): never {\n invalid(...issues);\n}\n\n/**\n * Remaps SvelteKit's unbranded request-context errors into clear, actionable\n * messages.\n *\n * @example\n * ```ts\n * try {\n * return native_query(handler);\n * } catch (err) {\n * throw normalize_remote_helper_error(err, \"Query\");\n * }\n * ```\n *\n * @since 2.0.0\n * @param err - The error thrown by SvelteKit's native functions.\n * @param helper_name - Name of the helper that triggered the error.\n * @returns A more descriptive error.\n * @internal\n */\nexport function normalize_remote_helper_error(\n err: unknown,\n helper_name: string,\n): Error {\n if (is_sveltekit_remote_context_error(err)) {\n return new RemoteHelperContextError(helper_name);\n }\n\n return err instanceof Error ? err : new RemoteHelperError(err);\n}\n\nfunction is_sveltekit_remote_context_error(err: unknown): err is Error {\n if (!(err instanceof Error)) {\n return false;\n }\n\n return err.message.startsWith(request_event_context_error_start) ||\n err.message === request_store_context_error;\n}\n"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kBAAkB,GAAG;AAC/D;AAEA,SAAS,kCAAkC,KAA4B;CACrE,IAAI,EAAE,eAAe,QACnB,OAAO;CAGT,OAAO,IAAI,QAAQ,WAAW,iCAAiC,KAC7D,IAAI,YAAY;AACpB"}
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { RemoteHelperContextError, RemoteHelperError } from \"$/errors.ts\";\nimport { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\nimport { Cause, Effect, Exit } from \"effect\";\nimport { stringify } from \"devalue\";\n\ntype CauseReason = {\n\treadonly _tag: string;\n\treadonly defect?: unknown;\n\treadonly error?: unknown;\n};\n\ntype SvelteInvalid = (...issues: readonly (FormIssue | string)[]) => never;\n\ntype SvelteError = (status: number, body: unknown) => never;\n\nconst request_event_context_error_start =\n\t\"Can only read the current request event inside functions invoked during `handle`\";\n\nconst request_store_context_error = \"Could not get the request store.\";\n\n/**\n * Runs a user-supplied Effect program through a ManagedRuntime, maps its\n * exit into the shape expected by SvelteKit, and returns the result or\n * throws a SvelteKit-compatible error.\n *\n * @since 2.0.0\n * @param effect - The Effect program to execute.\n * @param runtime - The server-side ManagedRuntime.\n * @param invalid - SvelteKit's `invalid` helper (bound per-request).\n * @param error - SvelteKit's `error` helper.\n * @returns A Promise that resolves with the effect's success value.\n * @internal\n */\nexport async function run_remote_effect<A>(\n\teffect: Effect.Effect<A, unknown, unknown>,\n\truntime: {\n\t\trunPromise: (e: Effect.Effect<unknown, unknown, unknown>) => Promise<unknown>;\n\t},\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n): Promise<A> {\n\tconst exit: Exit.Exit<A, unknown> = (await runtime.runPromise(\n\t\tEffect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\n\t)) as Exit.Exit<A, unknown>;\n\n\tif (Exit.isSuccess(exit)) {\n\t\treturn exit.value;\n\t}\n\n\thandle_failure(exit.cause, invalid, error);\n}\n\n/**\n * Inspects the Effect Cause for failures and either throws a form\n * validation error (via SvelteKit's `invalid`) or encodes the error\n * and throws it via SvelteKit's `error`.\n */\nfunction handle_failure(\n\tcause: Cause.Cause<unknown>,\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n): never {\n\tconst reasons = get_cause_reasons(cause);\n\n\t/**\n\t * Phase 1 — let SvelteKit's thrown control-flow sentinels escape.\n\t */\n\tfor (const reason of reasons) {\n\t\tif (!Cause.isDieReason(reason as never)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst defect = reason.defect;\n\n\t\tif (is_sveltekit_control_flow(defect)) {\n\t\t\tthrow defect;\n\t\t}\n\t}\n\n\t/**\n\t * Phase 2 — let cancellation escape without becoming a remote failure.\n\t */\n\tif (Cause.hasInterruptsOnly(cause)) {\n\t\tthrow Cause.squash(cause);\n\t}\n\n\t/**\n\t * Phase 3 — preserve typed form validation failures.\n\t */\n\tfor (const reason of reasons) {\n\t\tif (Cause.isFailReason(reason as never)) {\n\t\t\tconst failure = reason.error;\n\t\t\tif (\n\t\t\t\ttypeof failure === \"object\" &&\n\t\t\t\tfailure !== null &&\n\t\t\t\t(failure as Record<string, unknown>)._tag === \"FormError\"\n\t\t\t) {\n\t\t\t\tconst issues = (failure as { issues?: readonly FormIssue[] }).issues ?? [];\n\t\t\t\tinvalid(...issues);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Phase 4 — encode all other failures for the remote client.\n\t */\n\tconst encoded = encode_remote_failure(cause);\n\tconst envelope = create_serialized_remote_failure_envelope(encoded);\n\n\terror(500, envelope);\n}\n\n/**\n * Encodes an Effect Cause into a string that the client-side adapter can\n * decode back into a typed `RemoteFailure`.\n *\n * @since 2.0.0\n * @param cause - The Effect Cause from a failed execution.\n * @returns A devalue-encoded string representing the serialised failure.\n * @internal\n */\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\n\tconst reasons = get_cause_reasons(cause);\n\n\tfor (const reason of reasons) {\n\t\tif (Cause.isFailReason(reason as never)) {\n\t\t\tconst failure = to_public_remote_failure(reason.error);\n\t\t\tconst encoded = stringify_failure(failure);\n\n\t\t\tif (encoded !== undefined) {\n\t\t\t\treturn encoded;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn stringify_unknown_remote_failure();\n}\n\nfunction get_cause_reasons(cause: Cause.Cause<unknown>): readonly CauseReason[] {\n\tconst reasons = (cause as unknown as { reasons?: readonly CauseReason[] }).reasons;\n\n\treturn reasons ?? [];\n}\n\nfunction is_sveltekit_control_flow(value: unknown): boolean {\n\treturn isRedirect(value) || isHttpError(value) || isValidationError(value);\n}\n\nfunction stringify_failure(value: unknown): string | undefined {\n\ttry {\n\t\treturn stringify(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction to_public_remote_failure(value: unknown): unknown {\n\tif (!has_public_remote_failure_tag(value)) {\n\t\treturn create_unknown_remote_failure();\n\t}\n\n\tconst serializable_failure = to_serializable_public_failure(value);\n\n\treturn serializable_failure ?? create_unknown_remote_failure();\n}\n\nfunction to_serializable_public_failure(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (typeof value === \"function\" || typeof value === \"symbol\") {\n\t\treturn undefined;\n\t}\n\n\tif (!is_object_like(value)) {\n\t\treturn value;\n\t}\n\n\tif (stringify_failure(value) !== undefined) {\n\t\treturn value;\n\t}\n\n\tif (is_internal_object(value)) {\n\t\treturn undefined;\n\t}\n\n\tif (seen.has(value)) {\n\t\treturn undefined;\n\t}\n\n\tseen.add(value);\n\n\tconst serializable = Array.isArray(value)\n\t\t? value.map((item) => to_serializable_public_failure(item, seen))\n\t\t: to_plain_record(value, seen);\n\n\tseen.delete(value);\n\n\treturn serializable;\n}\n\nfunction to_plain_record(value: object, seen: WeakSet<object>): Record<string, unknown> {\n\tconst descriptors = Object.getOwnPropertyDescriptors(value);\n\tconst record: Record<string, unknown> = {};\n\n\tfor (const [key, descriptor] of Object.entries(descriptors)) {\n\t\tif (key === \"stack\" || !(\"value\" in descriptor)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\trecord[key] = to_serializable_public_failure(descriptor.value, seen);\n\t}\n\n\tif (value instanceof Error && !(\"message\" in record)) {\n\t\trecord.message = value.message;\n\t}\n\n\treturn record;\n}\n\nfunction is_object_like(value: unknown): value is object {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction has_public_remote_failure_tag(value: unknown): boolean {\n\treturn is_object_like(value) && typeof (value as { _tag?: unknown })._tag === \"string\";\n}\n\nfunction is_internal_object(value: object): boolean {\n\treturn (\n\t\t!Array.isArray(value) && !is_plain_record(value) && !has_public_remote_failure_tag(value)\n\t);\n}\n\nfunction is_plain_record(value: object): boolean {\n\tconst prototype = Object.getPrototypeOf(value);\n\n\treturn prototype === Object.prototype || prototype === null;\n}\n\nfunction create_unknown_remote_failure(): { readonly message: string } {\n\treturn { message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" };\n}\n\nfunction stringify_unknown_remote_failure(): string {\n\treturn stringify(create_unknown_remote_failure());\n}\n\n/**\n * Throws a SvelteKit `invalid` response from a {@link FormError}, calling\n * through to the request-scoped `invalid` helper.\n *\n * @example\n * ```ts\n * throw_form_error(\n * [{ message: \"Name is required\", path: [\"name\"] }],\n * invalid,\n * );\n * ```\n *\n * @since 2.0.0\n * @param issues - The list of form validation issues.\n * @param invalid - SvelteKit's `invalid` helper bound to the current request.\n * @internal\n */\nexport function throw_form_error(issues: readonly FormIssue[], invalid: SvelteInvalid): never {\n\tinvalid(...issues);\n}\n\n/**\n * Remaps SvelteKit's unbranded request-context errors into clear, actionable\n * messages.\n *\n * @example\n * ```ts\n * try {\n * return native_query(handler);\n * } catch (err) {\n * throw normalize_remote_helper_error(err, \"Query\");\n * }\n * ```\n *\n * @since 2.0.0\n * @param err - The error thrown by SvelteKit's native functions.\n * @param helper_name - Name of the helper that triggered the error.\n * @returns A more descriptive error.\n * @internal\n */\nexport function normalize_remote_helper_error(err: unknown, helper_name: string): Error {\n\tif (is_sveltekit_remote_context_error(err)) {\n\t\treturn new RemoteHelperContextError(helper_name);\n\t}\n\n\treturn err instanceof Error ? err : new RemoteHelperError(err);\n}\n\nfunction is_sveltekit_remote_context_error(err: unknown): err is Error {\n\tif (!(err instanceof Error)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\terr.message.startsWith(request_event_context_error_start) ||\n\t\terr.message === request_store_context_error\n\t);\n}\n"],"mappings":";;;;;;AAiBA,MAAM,oCACL;AAED,MAAM,8BAA8B;;;;;;;;;;;;;;AAepC,eAAsB,kBACrB,QACA,SAGA,SACA,OACa;CACb,MAAM,OAA+B,MAAM,QAAQ,WAClD,OAAO,KAAK,MAAM,CACnB;CAEA,IAAI,KAAK,UAAU,IAAI,GACtB,OAAO,KAAK;CAGb,eAAe,KAAK,OAAO,SAAS,KAAK;AAC1C;;;;;;AAOA,SAAS,eACR,OACA,SACA,OACQ;CACR,MAAM,UAAU,kBAAkB,KAAK;;;;CAKvC,KAAK,MAAM,UAAU,SAAS;EAC7B,IAAI,CAAC,MAAM,YAAY,MAAe,GACrC;EAGD,MAAM,SAAS,OAAO;EAEtB,IAAI,0BAA0B,MAAM,GACnC,MAAM;CAER;;;;CAKA,IAAI,MAAM,kBAAkB,KAAK,GAChC,MAAM,MAAM,OAAO,KAAK;;;;CAMzB,KAAK,MAAM,UAAU,SACpB,IAAI,MAAM,aAAa,MAAe,GAAG;EACxC,MAAM,UAAU,OAAO;EACvB,IACC,OAAO,YAAY,YACnB,YAAY,QACX,QAAoC,SAAS,aAG9C,QAAQ,GADQ,QAA8C,UAAU,CAAC,CACxD;CAEnB;CASD,MAAM,KAFW,0CADD,sBAAsB,KAC2B,CAE/C,CAAC;AACpB;;;;;;;;;;AAWA,SAAgB,sBAAsB,OAAqC;CAC1E,MAAM,UAAU,kBAAkB,KAAK;CAEvC,KAAK,MAAM,UAAU,SACpB,IAAI,MAAM,aAAa,M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