svelte-effect-runtime 3.4.11 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/client-BrZka6DW.js +530 -0
- package/.dist/chunks/client-BrZka6DW.js.map +1 -0
- package/.dist/chunks/compiler-COVzgLYo.js +412 -0
- package/.dist/chunks/compiler-COVzgLYo.js.map +1 -0
- package/.dist/chunks/descriptors-B4otDlm1.js +216 -0
- package/.dist/chunks/descriptors-B4otDlm1.js.map +1 -0
- package/.dist/chunks/diagnostics-BDrky-Di.js +359 -0
- package/.dist/chunks/diagnostics-BDrky-Di.js.map +1 -0
- package/.dist/chunks/dispatcher-BA0PLQhA.js +16 -0
- package/.dist/chunks/dispatcher-BA0PLQhA.js.map +1 -0
- package/.dist/chunks/{dispatcher-pHH4JcFR.js → dispatcher-_x0MQZBS.js} +84 -258
- package/.dist/chunks/dispatcher-_x0MQZBS.js.map +1 -0
- package/.dist/chunks/{errors-Dcf0MVbq.js → errors-CLsbGjIa.js} +57 -106
- package/.dist/chunks/errors-CLsbGjIa.js.map +1 -0
- package/.dist/chunks/live-BundLSoY.js +146 -0
- package/.dist/chunks/live-BundLSoY.js.map +1 -0
- package/.dist/chunks/live-CHK0RrZu.js +10 -0
- package/.dist/chunks/live-CHK0RrZu.js.map +1 -0
- package/.dist/chunks/{remote-client-Bj1pZXgq.js → remote-client-mkQAfP1G.js} +30 -24
- package/.dist/chunks/remote-client-mkQAfP1G.js.map +1 -0
- package/.dist/chunks/{runtime-ekkMQ-wL.js → runtime-HDTlEnzp.js} +3 -27
- package/.dist/chunks/runtime-HDTlEnzp.js.map +1 -0
- package/.dist/chunks/server-BNrA1I-u.js +144 -0
- package/.dist/chunks/server-BNrA1I-u.js.map +1 -0
- package/.dist/chunks/source-scan-9pZxnfct.js +1059 -0
- package/.dist/chunks/source-scan-9pZxnfct.js.map +1 -0
- package/.dist/chunks/{transform-CtQDGS9c.js → transform-BXyYUAez.js} +308 -484
- package/.dist/chunks/transform-BXyYUAez.js.map +1 -0
- package/.dist/compiler/markup-identifiers.d.ts +2 -0
- package/.dist/compiler/remote-client.d.ts +6 -0
- package/.dist/compiler/source-scan.d.ts +101 -0
- package/.dist/compiler/sveltekit-remote-bridge.d.ts +3 -0
- package/.dist/{vite.d.ts → compiler.d.ts} +7 -1
- package/.dist/{vite.js → compiler.js} +1 -1
- package/.dist/detect.d.ts +0 -31
- package/.dist/detect.js +0 -39
- package/.dist/detect.js.map +1 -1
- package/.dist/diagnostics.d.ts +0 -16
- package/.dist/dispatcher/deps.d.ts +3 -14
- package/.dist/dispatcher/fibers.d.ts +5 -46
- package/.dist/dispatcher/index.d.ts +1 -143
- package/.dist/dispatcher/types.d.ts +0 -151
- package/.dist/dispatcher.js +1 -1
- package/.dist/errors.d.ts +44 -86
- package/.dist/generated/dispatcher.d.ts +0 -50
- package/.dist/generators.d.ts +3 -12
- package/.dist/internal/descriptors.d.ts +0 -16
- package/.dist/internal/generators.js +25 -3
- package/.dist/internal/generators.js.map +1 -0
- package/.dist/internal/live.d.ts +9 -0
- package/.dist/internal/remote-client.js +2 -2
- package/.dist/internal/remote-server.js +2 -2
- package/.dist/internal/schema.d.ts +13 -0
- package/.dist/live.d.ts +106 -0
- package/.dist/markup/event-attributes.d.ts +5 -28
- package/.dist/markup/promise.d.ts +1 -23
- package/.dist/markup/promise.js +2 -18
- package/.dist/markup/promise.js.map +1 -1
- package/.dist/markup/run.d.ts +1 -10
- package/.dist/markup/run.js +2 -11
- package/.dist/markup/run.js.map +1 -1
- package/.dist/markup/transform/apply.d.ts +4 -4
- package/.dist/markup/transform/classify.d.ts +2 -11
- package/.dist/markup/transform/constants.d.ts +2 -1
- package/.dist/markup/transform/effect-bindings.d.ts +2 -26
- package/.dist/markup/transform/effect-callbacks.d.ts +0 -20
- package/.dist/markup/transform/emit.d.ts +2 -11
- package/.dist/markup/transform/expressions.d.ts +0 -35
- package/.dist/markup/transform/scan.d.ts +3 -22
- package/.dist/markup/transform/types.d.ts +2 -129
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.d.ts +1 -18
- package/.dist/markup/value.js +2 -19
- package/.dist/markup/value.js.map +1 -1
- package/.dist/mod.d.ts +6 -8
- package/.dist/mod.js +5 -4
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/cause-codec.d.ts +19 -0
- package/.dist/remote/client/command.d.ts +3 -17
- package/.dist/remote/client/form-data.d.ts +0 -7
- package/.dist/remote/client/form-enhance.d.ts +0 -7
- package/.dist/remote/client/form-transport.d.ts +15 -18
- package/.dist/remote/client/form.d.ts +9 -20
- package/.dist/remote/client/index.d.ts +2 -1
- package/.dist/remote/client/prerender.d.ts +6 -0
- package/.dist/remote/client/query-result.d.ts +2 -14
- package/.dist/remote/client/query.d.ts +9 -59
- package/.dist/remote/client/responses.d.ts +3 -27
- package/.dist/remote/client/types.d.ts +26 -101
- package/.dist/remote/client/utils.d.ts +0 -8
- package/.dist/remote/client.d.ts +2 -2
- package/.dist/remote/client.js +2 -2
- package/.dist/remote/effect.d.ts +6 -0
- package/.dist/remote/failures.d.ts +4 -0
- package/.dist/remote/query-update.d.ts +2 -0
- package/.dist/remote/resource.d.ts +25 -0
- package/.dist/remote/server.d.ts +5 -60
- package/.dist/remote/server.js +2 -179
- package/.dist/remote/shared.d.ts +6 -145
- package/.dist/remote/shared.js +6 -127
- package/.dist/remote/shared.js.map +1 -1
- package/.dist/runtime/transform.js +83 -87
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/ast.d.ts +0 -46
- package/.dist/script-transform/imports.d.ts +2 -38
- package/.dist/script-transform/lower.d.ts +0 -9
- package/.dist/script-transform/runes.d.ts +0 -10
- package/.dist/script-transform/runtime-block.d.ts +0 -17
- package/.dist/script-transform/source.d.ts +0 -24
- package/.dist/script-transform/types.d.ts +9 -126
- package/.dist/server/effects.d.ts +8 -57
- package/.dist/server/factories.d.ts +7 -7
- package/.dist/server/handler.d.ts +37 -0
- package/.dist/server/index.d.ts +4 -1
- package/.dist/server/invalid.d.ts +0 -7
- package/.dist/server/live-snapshot.d.ts +5 -0
- package/.dist/server/remote-handler-context.d.ts +5 -0
- package/.dist/server/runtime.d.ts +6 -24
- package/.dist/server/schema.d.ts +2 -40
- package/.dist/server/transport.d.ts +2 -0
- package/.dist/server/types.d.ts +88 -71
- package/.dist/server/wrappers.d.ts +4 -41
- package/.dist/server.d.ts +2 -2
- package/.dist/server.js +255 -279
- package/.dist/server.js.map +1 -1
- package/.dist/yieldable.d.ts +7 -0
- package/README.md +1 -1
- package/package.json +5 -5
- package/.dist/chunks/client-CsVu54pU.js +0 -627
- package/.dist/chunks/client-CsVu54pU.js.map +0 -1
- package/.dist/chunks/descriptors-cOe9uRJz.js +0 -36
- package/.dist/chunks/descriptors-cOe9uRJz.js.map +0 -1
- package/.dist/chunks/dispatcher-LtvFKYUp.js +0 -47
- package/.dist/chunks/dispatcher-LtvFKYUp.js.map +0 -1
- package/.dist/chunks/dispatcher-pHH4JcFR.js.map +0 -1
- package/.dist/chunks/errors-Dcf0MVbq.js.map +0 -1
- package/.dist/chunks/event-attributes-gHzP2ycp.js +0 -39
- package/.dist/chunks/event-attributes-gHzP2ycp.js.map +0 -1
- package/.dist/chunks/remote-client-Bj1pZXgq.js.map +0 -1
- package/.dist/chunks/runtime-ekkMQ-wL.js.map +0 -1
- package/.dist/chunks/transform-CtQDGS9c.js.map +0 -1
- package/.dist/chunks/vite-WGlbSnso.js +0 -486
- package/.dist/chunks/vite-WGlbSnso.js.map +0 -1
- package/.dist/remote/client/effect.d.ts +0 -29
- package/.dist/remote/client/failures.d.ts +0 -42
- package/.dist/remote/server.js.map +0 -1
- package/.dist/vite/remote-client.d.ts +0 -24
|
@@ -1,12 +1,3 @@
|
|
|
1
1
|
import type { LoweredStatement, ScriptLoweringContext } from "./types.js";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
/**
|
|
4
|
-
* Delegates a statement to the correct lowerer based on syntax kind.
|
|
5
|
-
*
|
|
6
|
-
* @since 2.0.0
|
|
7
|
-
* @param stmt - Statement to lower.
|
|
8
|
-
* @param content - Original source text.
|
|
9
|
-
* @param context - Lowering services for this transform pass.
|
|
10
|
-
* @returns Lowered statement descriptor.
|
|
11
|
-
*/
|
|
12
3
|
export declare function lower_statement(stmt: ts.Statement, content: string, context: ScriptLoweringContext): LoweredStatement;
|
|
@@ -1,12 +1,2 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
-
/**
|
|
3
|
-
* Validates that `yield*` only appears in rune positions the script-effect
|
|
4
|
-
* transform can lower without changing the rune's normal Svelte contract.
|
|
5
|
-
*
|
|
6
|
-
* @since 2.0.0
|
|
7
|
-
* @param node - AST node to scan.
|
|
8
|
-
* @param content - Original script source used for diagnostics.
|
|
9
|
-
* @param filename - Source filename used for diagnostics.
|
|
10
|
-
* @returns Nothing.
|
|
11
|
-
*/
|
|
12
2
|
export declare function validate_rune_yield_usage(node: ts.Node, content: string, filename: string): void;
|
|
@@ -1,19 +1,2 @@
|
|
|
1
1
|
import type { EffectBlock, RuntimeImportBindings } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Builds the runtime blocks appended to lowered script effect code.
|
|
4
|
-
*
|
|
5
|
-
* @since 2.0.0
|
|
6
|
-
* @param blocks - Effect bodies and dependency reads to emit.
|
|
7
|
-
* @returns Full `$effect` blocks that fork generated `Effect.gen` programs.
|
|
8
|
-
*/
|
|
9
|
-
export declare function make_runtime_block(blocks: EffectBlock[]): string;
|
|
10
|
-
/**
|
|
11
|
-
* Builds the runtime blocks appended to lowered script effect code with
|
|
12
|
-
* explicit runtime import bindings.
|
|
13
|
-
*
|
|
14
|
-
* @since 2.4.2
|
|
15
|
-
* @param blocks - Effect bodies and dependency reads to emit.
|
|
16
|
-
* @param bindings - Runtime binding names available in the generated code.
|
|
17
|
-
* @returns Full `$effect` blocks that fork generated `Effect.gen` programs.
|
|
18
|
-
*/
|
|
19
2
|
export declare function make_runtime_block_with_bindings(blocks: EffectBlock[], bindings: RuntimeImportBindings): string;
|
|
@@ -1,29 +1,5 @@
|
|
|
1
1
|
import type MagicString from "magic-string";
|
|
2
2
|
import type ts from "typescript";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a source map from transformed script back to the original block.
|
|
5
|
-
*
|
|
6
|
-
* @since 2.0.0
|
|
7
|
-
* @param magic - MagicString instance holding the transformed source.
|
|
8
|
-
* @param filename - Source filename used for the source map entry.
|
|
9
|
-
* @returns A plain source map object.
|
|
10
|
-
*/
|
|
11
3
|
export declare function create_source_map(magic: MagicString, filename: string): Record<string, unknown>;
|
|
12
|
-
/**
|
|
13
|
-
* Slices a substring matching a node's full source range.
|
|
14
|
-
*
|
|
15
|
-
* @since 2.0.0
|
|
16
|
-
* @param content - Original source text.
|
|
17
|
-
* @param node - AST node whose full range should be extracted.
|
|
18
|
-
* @returns Source text including leading trivia.
|
|
19
|
-
*/
|
|
20
4
|
export declare function slice(content: string, node: ts.Node): string;
|
|
21
|
-
/**
|
|
22
|
-
* Slices a substring matching a node's source range without leading trivia.
|
|
23
|
-
*
|
|
24
|
-
* @since 2.0.0
|
|
25
|
-
* @param content - Original source text.
|
|
26
|
-
* @param node - AST node whose non-trivia range should be extracted.
|
|
27
|
-
* @returns Source text excluding leading trivia.
|
|
28
|
-
*/
|
|
29
5
|
export declare function slice_start(content: string, node: ts.Node): string;
|
|
@@ -41,60 +41,16 @@ export interface ScriptTransformResult {
|
|
|
41
41
|
/** Offset ranges that preserve hoverable moved source spans. */
|
|
42
42
|
relocations?: Relocation[];
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Offset mapping between original script code and generated helper code.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```ts
|
|
49
|
-
* const relocation: Relocation = {
|
|
50
|
-
* originalStart: 10,
|
|
51
|
-
* originalEnd: 28,
|
|
52
|
-
* generatedStart: 64,
|
|
53
|
-
* generatedEnd: 82,
|
|
54
|
-
* };
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @since 3.2.3
|
|
58
|
-
*/
|
|
59
44
|
export interface Relocation {
|
|
60
45
|
originalStart: number;
|
|
61
46
|
originalEnd: number;
|
|
62
47
|
generatedStart: number;
|
|
63
48
|
generatedEnd: number;
|
|
64
49
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Internal descriptor for a single `$state` temp variable that will be
|
|
67
|
-
* emitted at component scope before the rewritten statement.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```ts
|
|
71
|
-
* const temp: TempBinding = {
|
|
72
|
-
* name: "__SER___user",
|
|
73
|
-
* type: "Effect.Success<typeof user>",
|
|
74
|
-
* };
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* @since 2.0.0
|
|
78
|
-
*/
|
|
79
50
|
export interface TempBinding {
|
|
80
51
|
name: string;
|
|
81
52
|
type?: string;
|
|
82
53
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Describes how a single statement was lowered.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```ts
|
|
88
|
-
* const lowered: LoweredStatement = {
|
|
89
|
-
* temps: [],
|
|
90
|
-
* rewritten_text: "const user = __SER___dispatcher.value(...);",
|
|
91
|
-
* effect_blocks: [],
|
|
92
|
-
* range: { start: 0, end: 26 },
|
|
93
|
-
* };
|
|
94
|
-
* ```
|
|
95
|
-
*
|
|
96
|
-
* @since 2.0.0
|
|
97
|
-
*/
|
|
98
54
|
export interface LoweredStatement {
|
|
99
55
|
/** `$state` bindings to emit at component scope. */
|
|
100
56
|
temps: TempBinding[];
|
|
@@ -112,64 +68,18 @@ export interface LoweredStatement {
|
|
|
112
68
|
end: number;
|
|
113
69
|
};
|
|
114
70
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Describes a generated script effect body and the identifiers it reads
|
|
117
|
-
* synchronously for Svelte dependency tracking.
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* ```ts
|
|
121
|
-
* const block: EffectBlock = {
|
|
122
|
-
* statements: ["const user = yield* load_user(id);"],
|
|
123
|
-
* deps: ["id"],
|
|
124
|
-
* };
|
|
125
|
-
* ```
|
|
126
|
-
*
|
|
127
|
-
* @since 2.0.0
|
|
128
|
-
*/
|
|
129
71
|
export interface EffectBlock {
|
|
130
72
|
/** Statements to emit inside the generated `Effect.gen` body. */
|
|
131
73
|
statements: string[];
|
|
132
74
|
/** Identifier reads that should rerun this block when they change. */
|
|
133
75
|
deps: string[];
|
|
134
76
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Describes how a single expression was lowered.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```ts
|
|
140
|
-
* const expression: LoweredExpression = {
|
|
141
|
-
* temps: [],
|
|
142
|
-
* rewritten_expr: "__SER___dispatcher.value(...)",
|
|
143
|
-
* effect_blocks: [],
|
|
144
|
-
* };
|
|
145
|
-
* ```
|
|
146
|
-
*
|
|
147
|
-
* @since 2.0.0
|
|
148
|
-
*/
|
|
149
77
|
export interface LoweredExpression {
|
|
150
78
|
temps: TempBinding[];
|
|
151
|
-
type_helpers
|
|
79
|
+
type_helpers: string[];
|
|
152
80
|
rewritten_expr: string;
|
|
153
81
|
effect_blocks: EffectBlock[];
|
|
154
82
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Stateful services used while lowering one script block.
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* ```ts
|
|
160
|
-
* const context: ScriptLoweringContext = {
|
|
161
|
-
* filename: "App.svelte",
|
|
162
|
-
* dispatcher_name: "get_dispatcher",
|
|
163
|
-
* effect_name: "Effect",
|
|
164
|
-
* emit_types: true,
|
|
165
|
-
* next_helper_name: (hint = "helper") => hint,
|
|
166
|
-
* next_temp_name: (hint = "temp") => hint,
|
|
167
|
-
* next_type_helper_name: (hint = "type") => hint,
|
|
168
|
-
* };
|
|
169
|
-
* ```
|
|
170
|
-
*
|
|
171
|
-
* @since 2.0.0
|
|
172
|
-
*/
|
|
173
83
|
export interface ScriptLoweringContext {
|
|
174
84
|
/** Source filename used for stable generated runtime ids. */
|
|
175
85
|
filename: string;
|
|
@@ -177,47 +87,16 @@ export interface ScriptLoweringContext {
|
|
|
177
87
|
dispatcher_name: string;
|
|
178
88
|
/** Binding name used for the Effect namespace in generated code. */
|
|
179
89
|
effect_name: string;
|
|
90
|
+
/** Binding name used for the yieldable normalization helper. */
|
|
91
|
+
yieldable_name: string;
|
|
92
|
+
/** Binding name used for yieldable success type extraction. */
|
|
93
|
+
yield_success_name: string;
|
|
180
94
|
/** Whether generated state placeholders should carry TypeScript types. */
|
|
181
95
|
emit_types: boolean;
|
|
182
|
-
/**
|
|
183
|
-
* Reserves a generated helper identifier.
|
|
184
|
-
*
|
|
185
|
-
* @param hint - Optional readable stem for the generated identifier.
|
|
186
|
-
* @returns A collision-free helper identifier.
|
|
187
|
-
*/
|
|
188
96
|
next_helper_name(hint?: string): string;
|
|
189
|
-
/**
|
|
190
|
-
* Reserves a generated `$state` temporary identifier.
|
|
191
|
-
*
|
|
192
|
-
* @param hint - Optional readable stem for the generated identifier.
|
|
193
|
-
* @returns A collision-free temporary identifier.
|
|
194
|
-
*/
|
|
195
97
|
next_temp_name(hint?: string): string;
|
|
196
|
-
/**
|
|
197
|
-
* Reserves a generated type-helper identifier.
|
|
198
|
-
*
|
|
199
|
-
* @param hint - Optional readable stem for the generated identifier.
|
|
200
|
-
* @returns A collision-free type-helper identifier.
|
|
201
|
-
*/
|
|
202
98
|
next_type_helper_name(hint?: string): string;
|
|
203
99
|
}
|
|
204
|
-
/**
|
|
205
|
-
* Runtime import bindings selected for generated script effect code.
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* ```ts
|
|
209
|
-
* const bindings: RuntimeImportBindings = {
|
|
210
|
-
* effect: "Effect",
|
|
211
|
-
* dispatcher: "get_dispatcher",
|
|
212
|
-
* dispatcher_value: "__SER___dispatcher",
|
|
213
|
-
* program: "__SER___program",
|
|
214
|
-
* cancel: "__SER___cancel",
|
|
215
|
-
* untrack: "untrack",
|
|
216
|
-
* };
|
|
217
|
-
* ```
|
|
218
|
-
*
|
|
219
|
-
* @since 2.4.2
|
|
220
|
-
*/
|
|
221
100
|
export interface RuntimeImportBindings {
|
|
222
101
|
/** Binding name used for the Effect namespace in generated code. */
|
|
223
102
|
effect: string;
|
|
@@ -231,4 +110,8 @@ export interface RuntimeImportBindings {
|
|
|
231
110
|
cancel: string;
|
|
232
111
|
/** Binding name used for Svelte's untrack helper. */
|
|
233
112
|
untrack: string;
|
|
113
|
+
/** Binding name used for the yieldable normalization helper. */
|
|
114
|
+
yieldable: string;
|
|
115
|
+
/** Binding name used for yieldable success type extraction. */
|
|
116
|
+
yield_success: string;
|
|
234
117
|
}
|
|
@@ -1,63 +1,14 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
1
|
import type { RequestEvent as RequestEventShape } from "./runtime.js";
|
|
3
|
-
import
|
|
4
|
-
type
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* @since 2.0.0
|
|
10
|
-
* @param value - Value to inspect.
|
|
11
|
-
* @returns Whether the value should be wrapped with `Effect.gen`.
|
|
12
|
-
*/
|
|
2
|
+
import { Effect, Stream } from "effect";
|
|
3
|
+
import type { EffectLike } from "./types.js";
|
|
4
|
+
type ResolvedLiveSource<A> = AsyncIterable<A>;
|
|
5
|
+
type LiveHandlerResult<A> = Stream.Stream<A, unknown, unknown>;
|
|
6
|
+
type LiveHandler<A> = () => LiveHandlerResult<A>;
|
|
13
7
|
export declare function is_generator_result<A>(value: unknown): value is Effect.gen.Return<A, unknown, unknown>;
|
|
14
|
-
/**
|
|
15
|
-
* Normalizes an Effect-like handler return value into an Effect.
|
|
16
|
-
*
|
|
17
|
-
* @since 2.0.0
|
|
18
|
-
* @param value - Effect or generator return value.
|
|
19
|
-
* @returns Normalized Effect.
|
|
20
|
-
*/
|
|
21
8
|
export declare function ToEffect<A, E, R>(value: EffectLike<A, E, R>): Effect.Effect<A, E, R>;
|
|
22
|
-
|
|
23
|
-
* Compatibility alias for {@link ToEffect}.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* const program = to_effect(Effect.succeed(1));
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @since 2.0.0
|
|
31
|
-
* @param value - Effect or generator return value.
|
|
32
|
-
* @returns Normalized Effect.
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
export declare const to_effect: typeof ToEffect;
|
|
36
|
-
/**
|
|
37
|
-
* Checks whether a value is a live query source SvelteKit can consume.
|
|
38
|
-
*
|
|
39
|
-
* @since 2.0.0
|
|
40
|
-
* @param value - Value to inspect.
|
|
41
|
-
* @returns Whether the value is an Effect Stream or native iterable source.
|
|
42
|
-
*/
|
|
43
|
-
export declare function is_live_source<A>(value: unknown): value is EffectRemoteLiveSource<A>;
|
|
44
|
-
/**
|
|
45
|
-
* Runs and normalizes a live query handler result with request services
|
|
46
|
-
* available to Effect Streams.
|
|
47
|
-
*
|
|
48
|
-
* @since 2.0.0
|
|
49
|
-
* @param value - Live query source or Effect that resolves to one.
|
|
50
|
-
* @param event - SvelteKit request event for this remote call.
|
|
51
|
-
* @returns Promise resolving with a source SvelteKit can stream.
|
|
52
|
-
*/
|
|
9
|
+
export declare function is_live_source<A>(value: unknown): value is Stream.Stream<A, unknown, unknown>;
|
|
53
10
|
export declare function run_live_handler_source<A>(value: LiveHandlerResult<A>, event: RequestEventShape): Promise<ResolvedLiveSource<A>>;
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
* @since 2.0.0
|
|
58
|
-
* @param value - Handler return value.
|
|
59
|
-
* @param event - SvelteKit request event for this remote call.
|
|
60
|
-
* @returns Promise resolving with the handler output.
|
|
61
|
-
*/
|
|
11
|
+
/** Runs a live handler inside the request-local ownership scope. */
|
|
12
|
+
export declare function run_live_handler<A>(handler: LiveHandler<A>, event: RequestEventShape): Promise<ResolvedLiveSource<A>>;
|
|
62
13
|
export declare function run_handler_effect<A>(value: EffectLike<A, unknown, unknown>, event: RequestEventShape): Promise<A>;
|
|
63
14
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { EffectLike, EffectRemoteCommand, EffectRemoteForm, EffectRemotePrerenderFunction, PrerenderOptions, QueryFactory, RemoteFormHandler, RemoteHandler, SchemaEncodedInput, SchemaInput, StandardSchema, StandardSchemaInput, StandardSchemaOutput } from "./types.js";
|
|
1
2
|
import type { RemoteFormInput } from "@sveltejs/kit";
|
|
2
3
|
import { type Schema } from "effect";
|
|
3
|
-
import type { EffectLike, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, PrerenderOptions, QueryFactory, RemoteFormHandler, RemoteHandler, SchemaEncodedInput, SchemaInput, StandardSchema, StandardSchemaInput, StandardSchemaOutput } from "./types.js";
|
|
4
4
|
type FormSchemaEncodedInput<S> = S extends Schema.Top ? FormRemoteInput<S["Encoded"]> : never;
|
|
5
5
|
type FormRemoteInput<Input> = NormalizeFormEncoded<Input> extends RemoteFormInput ? NormalizeFormEncoded<Input> : never;
|
|
6
6
|
type FormStandardSchemaInput<S> = StandardSchemaInput<S> extends RemoteFormInput ? StandardSchemaInput<S> : RemoteFormInput;
|
|
@@ -134,7 +134,7 @@ export declare function Form<S extends StandardSchema, A, E = never, R = never>(
|
|
|
134
134
|
* configuration.
|
|
135
135
|
* @returns A prerender function that yields an Effect when called.
|
|
136
136
|
*/
|
|
137
|
-
export declare function Prerender<A, E = never, R = never>(validate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>, maybe_options?: PrerenderOptions):
|
|
137
|
+
export declare function Prerender<A, E = never, R = never>(validate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>, maybe_options?: PrerenderOptions<void>): EffectRemotePrerenderFunction<void, A, E>;
|
|
138
138
|
/**
|
|
139
139
|
* Creates a prerenderable remote function with unchecked input.
|
|
140
140
|
*
|
|
@@ -143,7 +143,7 @@ export declare function Prerender<A, E = never, R = never>(validate_or_handler:
|
|
|
143
143
|
* export const GetPost = Prerender(
|
|
144
144
|
* "unchecked",
|
|
145
145
|
* (slug: string) => Effect.succeed({ slug }),
|
|
146
|
-
* { inputs: () => ["intro"] },
|
|
146
|
+
* { inputs: () => Effect.succeed(["intro"]) },
|
|
147
147
|
* );
|
|
148
148
|
* ```
|
|
149
149
|
*
|
|
@@ -155,7 +155,7 @@ export declare function Prerender<A, E = never, R = never>(validate_or_handler:
|
|
|
155
155
|
* configuration.
|
|
156
156
|
* @returns A prerender function that yields an Effect when called with input.
|
|
157
157
|
*/
|
|
158
|
-
export declare function Prerender<Input, A, E = never, R = never>(validate_or_handler: "unchecked", maybe_handler: RemoteHandler<Input, A, E, R>, maybe_options?: PrerenderOptions):
|
|
158
|
+
export declare function Prerender<Input, A, E = never, R = never>(validate_or_handler: "unchecked", maybe_handler: RemoteHandler<Input, A, E, R>, maybe_options?: PrerenderOptions<Input>): EffectRemotePrerenderFunction<Input, A, E>;
|
|
159
159
|
/**
|
|
160
160
|
* Creates a prerenderable remote function validated with an Effect Schema.
|
|
161
161
|
*
|
|
@@ -164,7 +164,7 @@ export declare function Prerender<Input, A, E = never, R = never>(validate_or_ha
|
|
|
164
164
|
* export const GetPost = Prerender(
|
|
165
165
|
* Schema.String,
|
|
166
166
|
* (slug) => Effect.succeed({ slug }),
|
|
167
|
-
* { inputs: () => ["intro"] },
|
|
167
|
+
* { inputs: () => Effect.succeed(["intro"]) },
|
|
168
168
|
* );
|
|
169
169
|
* ```
|
|
170
170
|
*
|
|
@@ -176,7 +176,7 @@ export declare function Prerender<Input, A, E = never, R = never>(validate_or_ha
|
|
|
176
176
|
* configuration.
|
|
177
177
|
* @returns A prerender function whose caller input is the schema encoded type.
|
|
178
178
|
*/
|
|
179
|
-
export declare function Prerender<S extends Schema.Schema<unknown>, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>, maybe_options?: PrerenderOptions):
|
|
179
|
+
export declare function Prerender<S extends Schema.Schema<unknown>, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>, maybe_options?: PrerenderOptions<SchemaEncodedInput<S>>): EffectRemotePrerenderFunction<SchemaEncodedInput<S>, A, E>;
|
|
180
180
|
/**
|
|
181
181
|
* Creates a prerenderable remote function validated with a Standard Schema.
|
|
182
182
|
*
|
|
@@ -197,5 +197,5 @@ export declare function Prerender<S extends Schema.Schema<unknown>, A, E = never
|
|
|
197
197
|
* configuration.
|
|
198
198
|
* @returns A prerender function whose caller input is the schema input type.
|
|
199
199
|
*/
|
|
200
|
-
export declare function Prerender<S extends StandardSchema, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>, maybe_options?: PrerenderOptions):
|
|
200
|
+
export declare function Prerender<S extends StandardSchema, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>, maybe_options?: PrerenderOptions<StandardSchemaInput<S>>): EffectRemotePrerenderFunction<StandardSchemaInput<S>, A, E>;
|
|
201
201
|
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { EffectHandler } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Adapts an Effect-producing callback to a native SvelteKit server handler.
|
|
4
|
+
* SvelteKit continues to select the handler by its exported binding name, such
|
|
5
|
+
* as `GET`, `PUT`, or `load`.
|
|
6
|
+
*
|
|
7
|
+
* @example A `+server.ts` request handler:
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Handler } from "svelte-effect-runtime/server";
|
|
10
|
+
* import type { RequestHandler } from "./$types";
|
|
11
|
+
*
|
|
12
|
+
* export const GET = Handler<RequestHandler>(function* ({ params }) {
|
|
13
|
+
* const post = yield* Posts.get(params.slug);
|
|
14
|
+
*
|
|
15
|
+
* return Response.json(post);
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example A `+page.server.ts` load function:
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { Handler } from "svelte-effect-runtime/server";
|
|
22
|
+
* import type { PageServerLoad } from "./$types";
|
|
23
|
+
*
|
|
24
|
+
* export const load = Handler<PageServerLoad>(function* ({ locals }) {
|
|
25
|
+
* const profile = yield* Profiles.get(locals.user.id);
|
|
26
|
+
*
|
|
27
|
+
* return { profile };
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @since 4.0.0
|
|
32
|
+
* @param handler - Effect-producing callback whose parameters and successful
|
|
33
|
+
* result match the native SvelteKit handler type.
|
|
34
|
+
* @returns A native handler that runs the callback through the configured
|
|
35
|
+
* {@link ServerRuntime} with the current {@link RequestEvent} available.
|
|
36
|
+
*/
|
|
37
|
+
export declare function Handler<NativeHandler extends (...arguments_: never[]) => unknown>(handler: EffectHandler<NativeHandler>): NativeHandler;
|
package/.dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { Command, Form, Prerender, Query } from "./factories.js";
|
|
2
|
+
export { Handler } from "./handler.js";
|
|
2
3
|
export { Error, Redirect } from "./control-flow.js";
|
|
3
4
|
export { get_server_runtime_or_throw, RequestEvent, ServerRuntime } from "./runtime.js";
|
|
4
5
|
export { RuntimeAlreadyInitializedError } from "../errors.js";
|
|
6
|
+
export { Live } from "../live.js";
|
|
7
|
+
export type { LiveFactory, LiveStatus, RemoteLiveStream } from "../live.js";
|
|
5
8
|
export type { ErrorBody, ErrorEffectFactory, ErrorProperties, ErrorStatus, ErrorStatusName, RedirectEffectFactory, RedirectOptions, RedirectStatus, RedirectStatusName, } from "./control-flow.js";
|
|
6
|
-
export type { CommandFactory, EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction,
|
|
9
|
+
export type { CommandFactory, EffectHandler, EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteCommandCall, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction, EffectRemotePrerender, EffectRemotePrerenderFunction, EffectRemoteQuery, EffectRemoteQueryFunction, FormFactory, FormInvalid, PrerenderFactory, PrerenderInputs, PrerenderOptions, QueryBatchFactory, QueryFactory, QueryLiveFactory, RemoteFormHandler, RemoteHandler, RemoteLiveHandler, RemoteLiveSource, SchemaEncodedInput, SchemaInput, ServerRuntimeFactory, StandardSchema, StandardSchemaInput, StandardSchemaOutput, } from "./types.js";
|
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import type { FormInvalid } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a path-aware proxy for remote form validation failures.
|
|
4
|
-
*
|
|
5
|
-
* @since 2.0.0
|
|
6
|
-
* @param path - Current nested form path.
|
|
7
|
-
* @returns Callable invalid proxy for this path.
|
|
8
|
-
*/
|
|
9
2
|
export declare function make_invalid_proxy<Input = unknown>(path?: readonly (string | number)[]): FormInvalid<Input>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type NativeTransport = Readonly<Record<string, {
|
|
2
|
+
readonly encode: (value: unknown) => false | unknown;
|
|
3
|
+
}>>;
|
|
4
|
+
/** Converts SvelteKit transport hooks into a devalue live snapshot encoder. */
|
|
5
|
+
export declare function make_remote_live_snapshot_encoder(transport: NativeTransport): (value: unknown) => string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
/** Tracks ownership per request event so concurrent requests remain isolated. */
|
|
3
|
+
export declare function is_running_remote_effect_handler(event?: object): boolean;
|
|
4
|
+
/** Marks one request as handler-owned for the lifetime of the supplied Effect. */
|
|
5
|
+
export declare const RunInsideRemoteEffectHandler: <A, E, R>(event: object, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
@@ -4,6 +4,12 @@ import { Context, Layer, ManagedRuntime } from "effect";
|
|
|
4
4
|
/**
|
|
5
5
|
* Subset of SvelteKit's `RequestEvent` that remote handlers typically access.
|
|
6
6
|
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const event: RequestEvent = yield* RequestEvent;
|
|
10
|
+
* console.log(event.url.pathname);
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
7
13
|
* @since 2.0.0
|
|
8
14
|
*/
|
|
9
15
|
export interface RequestEvent extends Pick<SvelteKitRequestEvent, "cookies" | "getClientAddress" | "locals" | "params" | "platform" | "request" | "route" | "url"> {
|
|
@@ -51,29 +57,5 @@ export declare class ServerRuntime {
|
|
|
51
57
|
* @returns The current ManagedRuntime instance.
|
|
52
58
|
*/
|
|
53
59
|
export declare function get_server_runtime_or_throw(): ManagedRuntime.ManagedRuntime<unknown, never>;
|
|
54
|
-
/**
|
|
55
|
-
* Returns a dispatcher backed by the active server runtime.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```ts
|
|
59
|
-
* const dispatcher = get_server_dispatcher();
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @since 3.0.1
|
|
63
|
-
* @returns The cached server dispatcher, creating one from the current server
|
|
64
|
-
* runtime when needed.
|
|
65
|
-
*/
|
|
66
60
|
export declare function get_server_dispatcher(): InternalDispatcher;
|
|
67
|
-
/**
|
|
68
|
-
* Resets the internal server runtime singleton used by source-level tests.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```ts
|
|
72
|
-
* reset_server_runtime();
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* @since 3.4.0
|
|
76
|
-
* @returns Nothing.
|
|
77
|
-
* @internal
|
|
78
|
-
*/
|
|
79
61
|
export declare function reset_server_runtime(): void;
|
package/.dist/server/schema.d.ts
CHANGED
|
@@ -1,42 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Checks whether a value is the string sentinel for unchecked remotes.
|
|
5
|
-
*
|
|
6
|
-
* @since 2.0.0
|
|
7
|
-
* @param value - Value to inspect.
|
|
8
|
-
* @returns Whether the value is `"unchecked"`.
|
|
9
|
-
*/
|
|
1
|
+
import type { RemoteHandler } from "./types.js";
|
|
2
|
+
export { is_effect_schema, is_standard_schema, normalize_validator, type StandardSchema, } from "../internal/schema.js";
|
|
10
3
|
export declare function is_unchecked(value: unknown): value is "unchecked";
|
|
11
|
-
/**
|
|
12
|
-
* Checks whether a value is a remote handler function.
|
|
13
|
-
*
|
|
14
|
-
* @since 2.0.0
|
|
15
|
-
* @param value - Value to inspect.
|
|
16
|
-
* @returns Whether the value is callable as a handler.
|
|
17
|
-
*/
|
|
18
4
|
export declare function is_handler(value: unknown): value is RemoteHandler<unknown, unknown, unknown, unknown>;
|
|
19
|
-
/**
|
|
20
|
-
* Checks whether a value implements the Standard Schema contract.
|
|
21
|
-
*
|
|
22
|
-
* @since 2.0.0
|
|
23
|
-
* @param value - Value to inspect.
|
|
24
|
-
* @returns Whether the value is a Standard Schema.
|
|
25
|
-
*/
|
|
26
|
-
export declare function is_standard_schema(value: unknown): value is StandardSchema;
|
|
27
|
-
/**
|
|
28
|
-
* Checks whether a value looks like an Effect Schema.
|
|
29
|
-
*
|
|
30
|
-
* @since 2.0.0
|
|
31
|
-
* @param value - Value to inspect.
|
|
32
|
-
* @returns Whether the value should be converted to Standard Schema.
|
|
33
|
-
*/
|
|
34
|
-
export declare function is_effect_schema(value: unknown): value is Schema.Schema<unknown>;
|
|
35
|
-
/**
|
|
36
|
-
* Converts Effect Schema inputs to Standard Schema for SvelteKit.
|
|
37
|
-
*
|
|
38
|
-
* @since 2.0.0
|
|
39
|
-
* @param value - Schema or handler input.
|
|
40
|
-
* @returns Original value or Standard Schema view of an Effect Schema.
|
|
41
|
-
*/
|
|
42
|
-
export declare function normalize_validator(value: unknown): unknown;
|