svelte-effect-runtime 1.6.2 → 2.0.0-beta.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-BeOE81fW.js +577 -0
- package/.dist/chunks/client-BeOE81fW.js.map +1 -0
- package/.dist/chunks/descriptors-CU2g4U_i.js +36 -0
- package/.dist/chunks/descriptors-CU2g4U_i.js.map +1 -0
- package/.dist/chunks/dispatcher-BSg2-ttN.js +339 -0
- package/.dist/chunks/dispatcher-BSg2-ttN.js.map +1 -0
- package/.dist/chunks/preprocess-BZyUYWY7.js +430 -0
- package/.dist/chunks/preprocess-BZyUYWY7.js.map +1 -0
- package/.dist/chunks/transform-BtlxgJrg.js +836 -0
- package/.dist/chunks/transform-BtlxgJrg.js.map +1 -0
- package/.dist/detect.d.ts +34 -0
- package/.dist/detect.js +56 -0
- package/.dist/detect.js.map +1 -0
- package/.dist/dispatcher/deps.d.ts +14 -0
- package/.dist/dispatcher/fibers.d.ts +52 -0
- package/.dist/dispatcher/index.d.ts +138 -0
- package/.dist/dispatcher/types.d.ts +63 -0
- package/.dist/dispatcher.d.ts +2 -0
- package/.dist/dispatcher.js +2 -0
- package/.dist/error.d.ts +77 -0
- package/.dist/generators.d.ts +16 -0
- package/.dist/internal/descriptors.d.ts +17 -0
- package/.dist/internal/generators.d.ts +6 -0
- package/.dist/internal/generators.js +5 -0
- package/.dist/internal/remote-client.d.ts +6 -0
- package/.dist/internal/remote-client.js +2 -0
- package/.dist/internal/remote-server.d.ts +6 -0
- package/.dist/internal/remote-server.js +2 -0
- package/.dist/markup/promise.d.ts +15 -0
- package/.dist/markup/promise.js +26 -0
- package/.dist/markup/promise.js.map +1 -0
- package/.dist/markup/run.d.ts +12 -0
- package/.dist/markup/run.js +21 -0
- package/.dist/markup/run.js.map +1 -0
- package/.dist/markup/transform/apply.d.ts +6 -0
- package/.dist/markup/transform/classify.d.ts +15 -0
- package/.dist/markup/transform/constants.d.ts +5 -0
- package/.dist/markup/transform/emit.d.ts +12 -0
- package/.dist/markup/transform/expressions.d.ts +39 -0
- package/.dist/markup/transform/index.d.ts +19 -0
- package/.dist/markup/transform/scan.d.ts +8 -0
- package/.dist/markup/transform/types.d.ts +64 -0
- package/.dist/markup/transform.d.ts +1 -0
- package/.dist/markup/transform.js +2 -0
- package/.dist/markup/value.d.ts +20 -0
- package/.dist/markup/value.js +32 -0
- package/.dist/markup/value.js.map +1 -0
- package/.dist/mod.d.ts +186 -0
- package/.dist/mod.js +190 -0
- package/.dist/mod.js.map +1 -0
- package/.dist/preprocess/ast.d.ts +51 -0
- package/.dist/preprocess/imports.d.ts +22 -0
- package/.dist/preprocess/index.d.ts +21 -0
- package/.dist/preprocess/lower.d.ts +12 -0
- package/.dist/preprocess/runtime-block.d.ts +8 -0
- package/.dist/preprocess/source.d.ts +29 -0
- package/.dist/preprocess/types.d.ts +70 -0
- package/.dist/preprocess.d.ts +2 -0
- package/.dist/preprocess.js +3 -0
- package/.dist/remote/client/command.d.ts +17 -0
- package/.dist/remote/client/effect.d.ts +15 -0
- package/.dist/remote/client/failures.d.ts +57 -0
- package/.dist/remote/client/form-data.d.ts +8 -0
- package/.dist/remote/client/form-enhance.d.ts +9 -0
- package/.dist/remote/client/form-transport.d.ts +20 -0
- package/.dist/remote/client/form.d.ts +21 -0
- package/.dist/remote/client/index.d.ts +4 -0
- package/.dist/remote/client/query-result.d.ts +14 -0
- package/.dist/remote/client/query.d.ts +57 -0
- package/.dist/remote/client/responses.d.ts +28 -0
- package/.dist/remote/client/types.d.ts +83 -0
- package/.dist/remote/client/utils.d.ts +11 -0
- package/.dist/remote/client.d.ts +2 -0
- package/.dist/remote/client.js +2 -0
- package/.dist/remote/server.d.ts +66 -0
- package/.dist/remote/server.js +104 -0
- package/.dist/remote/server.js.map +1 -0
- package/.dist/remote/shared.d.ts +202 -0
- package/.dist/remote/shared.js +161 -0
- package/.dist/remote/shared.js.map +1 -0
- package/.dist/runtime/preprocess.d.ts +38 -0
- package/.dist/runtime/preprocess.js +54 -0
- package/.dist/runtime/preprocess.js.map +1 -0
- package/.dist/server/effects.d.ts +49 -0
- package/.dist/server/factories.d.ts +97 -0
- package/.dist/server/index.d.ts +3 -0
- package/.dist/server/invalid.d.ts +9 -0
- package/.dist/server/runtime.d.ts +66 -0
- package/.dist/server/schema.d.ts +42 -0
- package/.dist/server/types.d.ts +271 -0
- package/.dist/server/wrappers.d.ts +45 -0
- package/.dist/server.d.ts +2 -0
- package/.dist/server.js +527 -0
- package/.dist/server.js.map +1 -0
- package/.dist/vite.d.ts +42 -0
- package/.dist/vite.js +118 -0
- package/.dist/vite.js.map +1 -0
- package/README.md +2 -0
- package/package.json +66 -101
- package/dist/chunks/client-vV6UAwoP.js +0 -199
- package/dist/chunks/client-vV6UAwoP.js.map +0 -1
- package/dist/chunks/effect-Crj3S8Cg.js +0 -51
- package/dist/chunks/effect-Crj3S8Cg.js.map +0 -1
- package/dist/chunks/effect-compat-BhW0YPIs.js +0 -103
- package/dist/chunks/effect-compat-BhW0YPIs.js.map +0 -1
- package/dist/chunks/magic-string.es-BnGH-5YR.js +0 -1013
- package/dist/chunks/magic-string.es-BnGH-5YR.js.map +0 -1
- package/dist/chunks/markup-CkPUZIJt.js +0 -13390
- package/dist/chunks/markup-CkPUZIJt.js.map +0 -1
- package/dist/chunks/preprocess-BFePqOC6.js +0 -49
- package/dist/chunks/preprocess-BFePqOC6.js.map +0 -1
- package/dist/chunks/server-Dea1CJuY.js +0 -704
- package/dist/chunks/server-Dea1CJuY.js.map +0 -1
- package/dist/chunks/v3-D0c0MKPf.js +0 -1
- package/dist/chunks/v4-MMhHmzIG.js +0 -1
- package/dist/chunks/vite-BlUTKv2u.js +0 -152
- package/dist/chunks/vite-BlUTKv2u.js.map +0 -1
- package/dist/client.d.ts +0 -1
- package/dist/client.js +0 -2
- package/dist/effect.d.ts +0 -1
- package/dist/effect.js +0 -2
- package/dist/internal/app-server-shim.d.ts +0 -8
- package/dist/internal/effect-compat.d.ts +0 -21
- package/dist/internal/markup.d.ts +0 -11
- package/dist/internal/markup.js +0 -2
- package/dist/internal/remote-client.d.ts +0 -36
- package/dist/internal/remote-client.js +0 -527
- package/dist/internal/remote-client.js.map +0 -1
- package/dist/internal/remote-shared.d.ts +0 -186
- package/dist/internal/remote-shared.js +0 -122
- package/dist/internal/remote-shared.js.map +0 -1
- package/dist/internal/transform.d.ts +0 -18
- package/dist/internal/transform.js +0 -418
- package/dist/internal/transform.js.map +0 -1
- package/dist/language-server.d.ts +0 -9
- package/dist/language-server.js +0 -4
- package/dist/mod.d.ts +0 -22
- package/dist/mod.js +0 -3
- package/dist/preprocess.d.ts +0 -29
- package/dist/preprocess.js +0 -20
- package/dist/preprocess.js.map +0 -1
- package/dist/root-node.d.ts +0 -1
- package/dist/root-node.js +0 -63
- package/dist/root-node.js.map +0 -1
- package/dist/server.d.ts +0 -81
- package/dist/server.js +0 -85
- package/dist/server.js.map +0 -1
- package/dist/v3/client.d.ts +0 -117
- package/dist/v3/effect.d.ts +0 -17
- package/dist/v3/mod.d.ts +0 -27
- package/dist/v3/preprocess.d.ts +0 -28
- package/dist/v3/root-node.d.ts +0 -59
- package/dist/v3/server.d.ts +0 -297
- package/dist/v3/vite.d.ts +0 -46
- package/dist/v4/client.d.ts +0 -2
- package/dist/v4/effect.d.ts +0 -24
- package/dist/v4/effect.js +0 -19
- package/dist/v4/effect.js.map +0 -1
- package/dist/v4/mod.d.ts +0 -27
- package/dist/v4/mod.js +0 -3
- package/dist/v4/preprocess.d.ts +0 -34
- package/dist/v4/preprocess.js +0 -32
- package/dist/v4/preprocess.js.map +0 -1
- package/dist/v4/root-node.d.ts +0 -59
- package/dist/v4/root-node.js +0 -4
- package/dist/v4/server.d.ts +0 -340
- package/dist/v4/server.js +0 -71
- package/dist/v4/server.js.map +0 -1
- package/dist/v4/vite.d.ts +0 -34
- package/dist/v4/vite.js +0 -31
- package/dist/v4/vite.js.map +0 -1
- package/dist/vite.d.ts +0 -31
- package/dist/vite.js +0 -24
- package/dist/vite.js.map +0 -1
|
@@ -1,704 +0,0 @@
|
|
|
1
|
-
import { create_form_error, create_remote_http_error, create_serialized_remote_failure_envelope, is_form_error } from "../internal/remote-shared.js";
|
|
2
|
-
import { a as make_context_key, i as get_effect_schema_field_names, o as to_standard_schema_v1, r as get_cause_failure, s as to_transportable_data } from "./effect-compat-BhW0YPIs.js";
|
|
3
|
-
import { Cause, Effect, Exit, Layer, ManagedRuntime, Schema } from "effect";
|
|
4
|
-
import { error, invalid } from "@sveltejs/kit";
|
|
5
|
-
import { command, form, getRequestEvent, prerender, query } from "$app/server";
|
|
6
|
-
import { get_request_store } from "@sveltejs/kit/internal/server";
|
|
7
|
-
//#region ../../node_modules/.deno/devalue@5.6.4/node_modules/devalue/src/utils.js
|
|
8
|
-
var DevalueError = class extends Error {
|
|
9
|
-
/**
|
|
10
|
-
* @param {string} message
|
|
11
|
-
* @param {string[]} keys
|
|
12
|
-
* @param {any} [value] - The value that failed to be serialized
|
|
13
|
-
* @param {any} [root] - The root value being serialized
|
|
14
|
-
*/
|
|
15
|
-
constructor(message, keys, value, root) {
|
|
16
|
-
super(message);
|
|
17
|
-
this.name = "DevalueError";
|
|
18
|
-
this.path = keys.join("");
|
|
19
|
-
this.value = value;
|
|
20
|
-
this.root = root;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
/** @param {any} thing */
|
|
24
|
-
function is_primitive(thing) {
|
|
25
|
-
return Object(thing) !== thing;
|
|
26
|
-
}
|
|
27
|
-
const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
28
|
-
/** @param {any} thing */
|
|
29
|
-
function is_plain_object(thing) {
|
|
30
|
-
const proto = Object.getPrototypeOf(thing);
|
|
31
|
-
return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names;
|
|
32
|
-
}
|
|
33
|
-
/** @param {any} thing */
|
|
34
|
-
function get_type(thing) {
|
|
35
|
-
return Object.prototype.toString.call(thing).slice(8, -1);
|
|
36
|
-
}
|
|
37
|
-
/** @param {string} char */
|
|
38
|
-
function get_escaped_char(char) {
|
|
39
|
-
switch (char) {
|
|
40
|
-
case "\"": return "\\\"";
|
|
41
|
-
case "<": return "\\u003C";
|
|
42
|
-
case "\\": return "\\\\";
|
|
43
|
-
case "\n": return "\\n";
|
|
44
|
-
case "\r": return "\\r";
|
|
45
|
-
case " ": return "\\t";
|
|
46
|
-
case "\b": return "\\b";
|
|
47
|
-
case "\f": return "\\f";
|
|
48
|
-
case "\u2028": return "\\u2028";
|
|
49
|
-
case "\u2029": return "\\u2029";
|
|
50
|
-
default: return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/** @param {string} str */
|
|
54
|
-
function stringify_string(str) {
|
|
55
|
-
let result = "";
|
|
56
|
-
let last_pos = 0;
|
|
57
|
-
const len = str.length;
|
|
58
|
-
for (let i = 0; i < len; i += 1) {
|
|
59
|
-
const char = str[i];
|
|
60
|
-
const replacement = get_escaped_char(char);
|
|
61
|
-
if (replacement) {
|
|
62
|
-
result += str.slice(last_pos, i) + replacement;
|
|
63
|
-
last_pos = i + 1;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
|
|
67
|
-
}
|
|
68
|
-
/** @param {Record<string | symbol, any>} object */
|
|
69
|
-
function enumerable_symbols(object) {
|
|
70
|
-
return Object.getOwnPropertySymbols(object).filter((symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable);
|
|
71
|
-
}
|
|
72
|
-
const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
|
|
73
|
-
/** @param {string} key */
|
|
74
|
-
function stringify_key(key) {
|
|
75
|
-
return is_identifier.test(key) ? "." + key : "[" + JSON.stringify(key) + "]";
|
|
76
|
-
}
|
|
77
|
-
/** @param {string} s */
|
|
78
|
-
function is_valid_array_index(s) {
|
|
79
|
-
if (s.length === 0) return false;
|
|
80
|
-
if (s.length > 1 && s.charCodeAt(0) === 48) return false;
|
|
81
|
-
for (let i = 0; i < s.length; i++) {
|
|
82
|
-
const c = s.charCodeAt(i);
|
|
83
|
-
if (c < 48 || c > 57) return false;
|
|
84
|
-
}
|
|
85
|
-
const n = +s;
|
|
86
|
-
if (n >= 2 ** 32 - 1) return false;
|
|
87
|
-
if (n < 0) return false;
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Finds the populated indices of an array.
|
|
92
|
-
* @param {unknown[]} array
|
|
93
|
-
*/
|
|
94
|
-
function valid_array_indices(array) {
|
|
95
|
-
const keys = Object.keys(array);
|
|
96
|
-
for (var i = keys.length - 1; i >= 0; i--) if (is_valid_array_index(keys[i])) break;
|
|
97
|
-
keys.length = i + 1;
|
|
98
|
-
return keys;
|
|
99
|
-
}
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region ../../node_modules/.deno/devalue@5.6.4/node_modules/devalue/src/base64.js
|
|
102
|
-
/**
|
|
103
|
-
* Base64 Encodes an arraybuffer
|
|
104
|
-
* @param {ArrayBuffer} arraybuffer
|
|
105
|
-
* @returns {string}
|
|
106
|
-
*/
|
|
107
|
-
function encode64(arraybuffer) {
|
|
108
|
-
const dv = new DataView(arraybuffer);
|
|
109
|
-
let binaryString = "";
|
|
110
|
-
for (let i = 0; i < arraybuffer.byteLength; i++) binaryString += String.fromCharCode(dv.getUint8(i));
|
|
111
|
-
return binaryToAscii(binaryString);
|
|
112
|
-
}
|
|
113
|
-
const KEY_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
114
|
-
/**
|
|
115
|
-
* Substitute for btoa since it's deprecated in node.
|
|
116
|
-
* Does not do any input validation.
|
|
117
|
-
*
|
|
118
|
-
* @see https://github.com/jsdom/abab/blob/master/lib/btoa.js
|
|
119
|
-
*
|
|
120
|
-
* @param {string} str
|
|
121
|
-
* @returns {string}
|
|
122
|
-
*/
|
|
123
|
-
function binaryToAscii(str) {
|
|
124
|
-
let out = "";
|
|
125
|
-
for (let i = 0; i < str.length; i += 3) {
|
|
126
|
-
/** @type {[number, number, number, number]} */
|
|
127
|
-
const groupsOfSix = [
|
|
128
|
-
void 0,
|
|
129
|
-
void 0,
|
|
130
|
-
void 0,
|
|
131
|
-
void 0
|
|
132
|
-
];
|
|
133
|
-
groupsOfSix[0] = str.charCodeAt(i) >> 2;
|
|
134
|
-
groupsOfSix[1] = (str.charCodeAt(i) & 3) << 4;
|
|
135
|
-
if (str.length > i + 1) {
|
|
136
|
-
groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;
|
|
137
|
-
groupsOfSix[2] = (str.charCodeAt(i + 1) & 15) << 2;
|
|
138
|
-
}
|
|
139
|
-
if (str.length > i + 2) {
|
|
140
|
-
groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;
|
|
141
|
-
groupsOfSix[3] = str.charCodeAt(i + 2) & 63;
|
|
142
|
-
}
|
|
143
|
-
for (let j = 0; j < groupsOfSix.length; j++) if (typeof groupsOfSix[j] === "undefined") out += "=";
|
|
144
|
-
else out += KEY_STRING[groupsOfSix[j]];
|
|
145
|
-
}
|
|
146
|
-
return out;
|
|
147
|
-
}
|
|
148
|
-
//#endregion
|
|
149
|
-
//#region ../../node_modules/.deno/devalue@5.6.4/node_modules/devalue/src/stringify.js
|
|
150
|
-
/**
|
|
151
|
-
* Turn a value into a JSON string that can be parsed with `devalue.parse`
|
|
152
|
-
* @param {any} value
|
|
153
|
-
* @param {Record<string, (value: any) => any>} [reducers]
|
|
154
|
-
*/
|
|
155
|
-
function stringify(value, reducers) {
|
|
156
|
-
/** @type {any[]} */
|
|
157
|
-
const stringified = [];
|
|
158
|
-
/** @type {Map<any, number>} */
|
|
159
|
-
const indexes = /* @__PURE__ */ new Map();
|
|
160
|
-
/** @type {Array<{ key: string, fn: (value: any) => any }>} */
|
|
161
|
-
const custom = [];
|
|
162
|
-
if (reducers) for (const key of Object.getOwnPropertyNames(reducers)) custom.push({
|
|
163
|
-
key,
|
|
164
|
-
fn: reducers[key]
|
|
165
|
-
});
|
|
166
|
-
/** @type {string[]} */
|
|
167
|
-
const keys = [];
|
|
168
|
-
let p = 0;
|
|
169
|
-
/** @param {any} thing */
|
|
170
|
-
function flatten(thing) {
|
|
171
|
-
if (thing === void 0) return -1;
|
|
172
|
-
if (Number.isNaN(thing)) return -3;
|
|
173
|
-
if (thing === Infinity) return -4;
|
|
174
|
-
if (thing === -Infinity) return -5;
|
|
175
|
-
if (thing === 0 && 1 / thing < 0) return -6;
|
|
176
|
-
if (indexes.has(thing)) return indexes.get(thing);
|
|
177
|
-
const index = p++;
|
|
178
|
-
indexes.set(thing, index);
|
|
179
|
-
for (const { key, fn } of custom) {
|
|
180
|
-
const value = fn(thing);
|
|
181
|
-
if (value) {
|
|
182
|
-
stringified[index] = `["${key}",${flatten(value)}]`;
|
|
183
|
-
return index;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
if (typeof thing === "function") throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
|
|
187
|
-
let str = "";
|
|
188
|
-
if (is_primitive(thing)) str = stringify_primitive(thing);
|
|
189
|
-
else {
|
|
190
|
-
const type = get_type(thing);
|
|
191
|
-
switch (type) {
|
|
192
|
-
case "Number":
|
|
193
|
-
case "String":
|
|
194
|
-
case "Boolean":
|
|
195
|
-
str = `["Object",${stringify_primitive(thing)}]`;
|
|
196
|
-
break;
|
|
197
|
-
case "BigInt":
|
|
198
|
-
str = `["BigInt",${thing}]`;
|
|
199
|
-
break;
|
|
200
|
-
case "Date":
|
|
201
|
-
str = `["Date","${!isNaN(thing.getDate()) ? thing.toISOString() : ""}"]`;
|
|
202
|
-
break;
|
|
203
|
-
case "URL":
|
|
204
|
-
str = `["URL",${stringify_string(thing.toString())}]`;
|
|
205
|
-
break;
|
|
206
|
-
case "URLSearchParams":
|
|
207
|
-
str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
|
|
208
|
-
break;
|
|
209
|
-
case "RegExp":
|
|
210
|
-
const { source, flags } = thing;
|
|
211
|
-
str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`;
|
|
212
|
-
break;
|
|
213
|
-
case "Array": {
|
|
214
|
-
let mostly_dense = false;
|
|
215
|
-
str = "[";
|
|
216
|
-
for (let i = 0; i < thing.length; i += 1) {
|
|
217
|
-
if (i > 0) str += ",";
|
|
218
|
-
if (Object.hasOwn(thing, i)) {
|
|
219
|
-
keys.push(`[${i}]`);
|
|
220
|
-
str += flatten(thing[i]);
|
|
221
|
-
keys.pop();
|
|
222
|
-
} else if (mostly_dense) str += -2;
|
|
223
|
-
else {
|
|
224
|
-
const populated_keys = valid_array_indices(thing);
|
|
225
|
-
const population = populated_keys.length;
|
|
226
|
-
const d = String(thing.length).length;
|
|
227
|
-
if ((thing.length - population) * 3 > 4 + d + population * (d + 1)) {
|
|
228
|
-
str = "[-7," + thing.length;
|
|
229
|
-
for (let j = 0; j < populated_keys.length; j++) {
|
|
230
|
-
const key = populated_keys[j];
|
|
231
|
-
keys.push(`[${key}]`);
|
|
232
|
-
str += "," + key + "," + flatten(thing[key]);
|
|
233
|
-
keys.pop();
|
|
234
|
-
}
|
|
235
|
-
break;
|
|
236
|
-
} else {
|
|
237
|
-
mostly_dense = true;
|
|
238
|
-
str += -2;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
str += "]";
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
case "Set":
|
|
246
|
-
str = "[\"Set\"";
|
|
247
|
-
for (const value of thing) str += `,${flatten(value)}`;
|
|
248
|
-
str += "]";
|
|
249
|
-
break;
|
|
250
|
-
case "Map":
|
|
251
|
-
str = "[\"Map\"";
|
|
252
|
-
for (const [key, value] of thing) {
|
|
253
|
-
keys.push(`.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`);
|
|
254
|
-
str += `,${flatten(key)},${flatten(value)}`;
|
|
255
|
-
keys.pop();
|
|
256
|
-
}
|
|
257
|
-
str += "]";
|
|
258
|
-
break;
|
|
259
|
-
case "Int8Array":
|
|
260
|
-
case "Uint8Array":
|
|
261
|
-
case "Uint8ClampedArray":
|
|
262
|
-
case "Int16Array":
|
|
263
|
-
case "Uint16Array":
|
|
264
|
-
case "Int32Array":
|
|
265
|
-
case "Uint32Array":
|
|
266
|
-
case "Float32Array":
|
|
267
|
-
case "Float64Array":
|
|
268
|
-
case "BigInt64Array":
|
|
269
|
-
case "BigUint64Array": {
|
|
270
|
-
/** @type {import("./types.js").TypedArray} */
|
|
271
|
-
const typedArray = thing;
|
|
272
|
-
str = "[\"" + type + "\"," + flatten(typedArray.buffer);
|
|
273
|
-
const a = thing.byteOffset;
|
|
274
|
-
const b = a + thing.byteLength;
|
|
275
|
-
if (a > 0 || b !== typedArray.buffer.byteLength) {
|
|
276
|
-
const m = +/(\d+)/.exec(type)[1] / 8;
|
|
277
|
-
str += `,${a / m},${b / m}`;
|
|
278
|
-
}
|
|
279
|
-
str += "]";
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
case "ArrayBuffer":
|
|
283
|
-
str = `["ArrayBuffer","${encode64(thing)}"]`;
|
|
284
|
-
break;
|
|
285
|
-
case "Temporal.Duration":
|
|
286
|
-
case "Temporal.Instant":
|
|
287
|
-
case "Temporal.PlainDate":
|
|
288
|
-
case "Temporal.PlainTime":
|
|
289
|
-
case "Temporal.PlainDateTime":
|
|
290
|
-
case "Temporal.PlainMonthDay":
|
|
291
|
-
case "Temporal.PlainYearMonth":
|
|
292
|
-
case "Temporal.ZonedDateTime":
|
|
293
|
-
str = `["${type}",${stringify_string(thing.toString())}]`;
|
|
294
|
-
break;
|
|
295
|
-
default:
|
|
296
|
-
if (!is_plain_object(thing)) throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
|
|
297
|
-
if (enumerable_symbols(thing).length > 0) throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
|
|
298
|
-
if (Object.getPrototypeOf(thing) === null) {
|
|
299
|
-
str = "[\"null\"";
|
|
300
|
-
for (const key of Object.keys(thing)) {
|
|
301
|
-
if (key === "__proto__") throw new DevalueError(`Cannot stringify objects with __proto__ keys`, keys, thing, value);
|
|
302
|
-
keys.push(stringify_key(key));
|
|
303
|
-
str += `,${stringify_string(key)},${flatten(thing[key])}`;
|
|
304
|
-
keys.pop();
|
|
305
|
-
}
|
|
306
|
-
str += "]";
|
|
307
|
-
} else {
|
|
308
|
-
str = "{";
|
|
309
|
-
let started = false;
|
|
310
|
-
for (const key of Object.keys(thing)) {
|
|
311
|
-
if (key === "__proto__") throw new DevalueError(`Cannot stringify objects with __proto__ keys`, keys, thing, value);
|
|
312
|
-
if (started) str += ",";
|
|
313
|
-
started = true;
|
|
314
|
-
keys.push(stringify_key(key));
|
|
315
|
-
str += `${stringify_string(key)}:${flatten(thing[key])}`;
|
|
316
|
-
keys.pop();
|
|
317
|
-
}
|
|
318
|
-
str += "}";
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
stringified[index] = str;
|
|
323
|
-
return index;
|
|
324
|
-
}
|
|
325
|
-
const index = flatten(value);
|
|
326
|
-
if (index < 0) return `${index}`;
|
|
327
|
-
return `[${stringified.join(",")}]`;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* @param {any} thing
|
|
331
|
-
* @returns {string}
|
|
332
|
-
*/
|
|
333
|
-
function stringify_primitive(thing) {
|
|
334
|
-
const type = typeof thing;
|
|
335
|
-
if (type === "string") return stringify_string(thing);
|
|
336
|
-
if (thing instanceof String) return stringify_string(thing.toString());
|
|
337
|
-
if (thing === void 0) return (-1).toString();
|
|
338
|
-
if (thing === 0 && 1 / thing < 0) return (-6).toString();
|
|
339
|
-
if (type === "bigint") return `["BigInt","${thing}"]`;
|
|
340
|
-
return String(thing);
|
|
341
|
-
}
|
|
342
|
-
//#endregion
|
|
343
|
-
//#region v3/server.ts
|
|
344
|
-
/**
|
|
345
|
-
* v3 server-side entrypoint for `svelte-effect-runtime`.
|
|
346
|
-
*
|
|
347
|
-
* Implements the Effect-aware wrappers around SvelteKit's remote-function
|
|
348
|
-
* primitives (`query`, `command`, `form`, `prerender`) together with the
|
|
349
|
-
* `ServerRuntime` builder and the `RequestEvent` service tag. Applications
|
|
350
|
-
* rarely import this module directly — the Vite plugin rewrites imports
|
|
351
|
-
* inside `.remote.ts` files to resolve here automatically.
|
|
352
|
-
*
|
|
353
|
-
* @example
|
|
354
|
-
* ```ts
|
|
355
|
-
* import { Query, ServerRuntime } from "svelte-effect-runtime/v3/_server";
|
|
356
|
-
* import { Effect, Schema } from "effect";
|
|
357
|
-
*
|
|
358
|
-
* ServerRuntime.make();
|
|
359
|
-
*
|
|
360
|
-
* export const hello = Query(Schema.String, (name) =>
|
|
361
|
-
* Effect.succeed(`hello ${name}`)
|
|
362
|
-
* );
|
|
363
|
-
* ```
|
|
364
|
-
*
|
|
365
|
-
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
366
|
-
*
|
|
367
|
-
* @module
|
|
368
|
-
*/
|
|
369
|
-
/**
|
|
370
|
-
* Effect `Context.Tag` for the current SvelteKit `RequestEvent`.
|
|
371
|
-
*
|
|
372
|
-
* Remote functions can `yield* RequestEvent` to access cookies, headers, and
|
|
373
|
-
* route state for the active request.
|
|
374
|
-
*
|
|
375
|
-
* @see https://ser.barekey.dev/content/runtimes/server
|
|
376
|
-
*/
|
|
377
|
-
const RequestEvent = make_context_key("svelte-effect-runtime/RequestEvent");
|
|
378
|
-
let current_server_runtime = null;
|
|
379
|
-
function runtime_seed() {
|
|
380
|
-
return Layer.effectContext(Effect.context());
|
|
381
|
-
}
|
|
382
|
-
function pipe_server_runtime(...ops) {
|
|
383
|
-
if (ops.length === 0) return Layer.empty;
|
|
384
|
-
return ops.reduce((layer, op) => op(layer), runtime_seed());
|
|
385
|
-
}
|
|
386
|
-
function make_server_runtime(...ops) {
|
|
387
|
-
const layer = ops.length === 0 ? pipe_server_runtime() : pipe_server_runtime(...ops);
|
|
388
|
-
const previous_runtime = current_server_runtime;
|
|
389
|
-
current_server_runtime = ManagedRuntime.make(layer);
|
|
390
|
-
previous_runtime?.dispose().catch(() => void 0);
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Server-side runtime builder used to provide long-lived Effect services to
|
|
394
|
-
* remote functions.
|
|
395
|
-
*
|
|
396
|
-
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
397
|
-
*/
|
|
398
|
-
const ServerRuntime = {
|
|
399
|
-
pipe: pipe_server_runtime,
|
|
400
|
-
make: make_server_runtime
|
|
401
|
-
};
|
|
402
|
-
/**
|
|
403
|
-
* Resolve the active server runtime, lazily creating a default empty runtime
|
|
404
|
-
* when no explicit one has been registered.
|
|
405
|
-
*
|
|
406
|
-
* Emitted by generated server-side remote wrappers - users should never
|
|
407
|
-
* import this directly.
|
|
408
|
-
*
|
|
409
|
-
* @internal Internal - do not use.
|
|
410
|
-
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
411
|
-
*/
|
|
412
|
-
function get_server_runtime_or_throw() {
|
|
413
|
-
if (current_server_runtime !== null) return current_server_runtime;
|
|
414
|
-
current_server_runtime = ManagedRuntime.make(pipe_server_runtime());
|
|
415
|
-
return current_server_runtime;
|
|
416
|
-
}
|
|
417
|
-
function create_missing_remote_functions_error(error) {
|
|
418
|
-
return new Error([
|
|
419
|
-
"This remote helper was evaluated before SvelteKit's remote-function runtime was available.",
|
|
420
|
-
"Enable `kit.experimental.remoteFunctions = true` in `svelte.config.js`.",
|
|
421
|
-
"Enable that flag and restart Vite. If it is already enabled, this is likely an internal bug."
|
|
422
|
-
].join(" "), { cause: error });
|
|
423
|
-
}
|
|
424
|
-
function is_missing_request_store_error(error) {
|
|
425
|
-
return Boolean(error instanceof Error && error.message.includes("Could not get the request store"));
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Remap low-level request-store crashes into a clearer setup error when remote
|
|
429
|
-
* helpers are evaluated outside SvelteKit's remote-function runtime.
|
|
430
|
-
*
|
|
431
|
-
* @internal Internal - do not use.
|
|
432
|
-
*/
|
|
433
|
-
function normalize_remote_helper_error(error) {
|
|
434
|
-
if (is_missing_request_store_error(error)) return create_missing_remote_functions_error(error);
|
|
435
|
-
return error;
|
|
436
|
-
}
|
|
437
|
-
function remap_remote_usage_error(error) {
|
|
438
|
-
throw normalize_remote_helper_error(error);
|
|
439
|
-
}
|
|
440
|
-
function is_effect_schema(value) {
|
|
441
|
-
return Schema.isSchema(value);
|
|
442
|
-
}
|
|
443
|
-
function get_effect_schema_validator(schema) {
|
|
444
|
-
return to_standard_schema_v1(schema);
|
|
445
|
-
}
|
|
446
|
-
function get_effect_form_validator(schema) {
|
|
447
|
-
return to_standard_schema_v1(schema);
|
|
448
|
-
}
|
|
449
|
-
function resolve_remote_args(validate_or_fn, maybe_fn) {
|
|
450
|
-
if (maybe_fn === void 0) return {
|
|
451
|
-
fn: validate_or_fn,
|
|
452
|
-
validate: void 0
|
|
453
|
-
};
|
|
454
|
-
if (validate_or_fn === "unchecked") return {
|
|
455
|
-
fn: maybe_fn,
|
|
456
|
-
validate: "unchecked"
|
|
457
|
-
};
|
|
458
|
-
if (!is_effect_schema(validate_or_fn)) throw new Error("Invalid schema passed to a remote function. Use Effect.Schema, 'unchecked', or omit the validator entirely.");
|
|
459
|
-
return {
|
|
460
|
-
fn: maybe_fn,
|
|
461
|
-
validate: validate_or_fn
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
function get_remote_failure_status(failure) {
|
|
465
|
-
if (failure && typeof failure === "object" && typeof failure.status === "number") return failure.status;
|
|
466
|
-
return 500;
|
|
467
|
-
}
|
|
468
|
-
function is_development_environment() {
|
|
469
|
-
const vite_environment = import.meta.env;
|
|
470
|
-
if (typeof vite_environment?.DEV === "boolean") return vite_environment.DEV;
|
|
471
|
-
const node_process = globalThis.process;
|
|
472
|
-
return node_process?.env?.SVELTE_EFFECT_RUNTIME_DEBUG === "1" || node_process?.env?.DEV === "1" || node_process?.env?.NODE_ENV === "development";
|
|
473
|
-
}
|
|
474
|
-
const ENABLE_REMOTE_SERVER_DEBUG_LOGS = is_development_environment();
|
|
475
|
-
function log_remote_server_step(step, details) {
|
|
476
|
-
if (!ENABLE_REMOTE_SERVER_DEBUG_LOGS) return;
|
|
477
|
-
console.log("[svelte-effect-runtime][server]", step, details ? summarize_log_details(details) : {});
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* Tagged Effect failures are often `Data.TaggedError` subclasses (i.e. real
|
|
481
|
-
* `Error` objects). `console.log`-ing them dumps the full JS stack — which
|
|
482
|
-
* looks like a server crash, even though the failure is a modelled,
|
|
483
|
-
* caller-handleable error. Render such values as their tag + enumerable data
|
|
484
|
-
* instead so the dev log stays readable.
|
|
485
|
-
*/
|
|
486
|
-
function summarize_log_details(details) {
|
|
487
|
-
const summarized = {};
|
|
488
|
-
for (const [key, value] of Object.entries(details)) summarized[key] = summarize_log_value(value);
|
|
489
|
-
return summarized;
|
|
490
|
-
}
|
|
491
|
-
function summarize_log_value(value) {
|
|
492
|
-
if (!(value instanceof Error)) return value;
|
|
493
|
-
const tag = value._tag;
|
|
494
|
-
if (typeof tag !== "string") return value;
|
|
495
|
-
const summary = {
|
|
496
|
-
_tag: tag,
|
|
497
|
-
message: value.message
|
|
498
|
-
};
|
|
499
|
-
for (const name of Object.getOwnPropertyNames(value)) {
|
|
500
|
-
if (name === "stack" || name === "message" || name === "_tag") continue;
|
|
501
|
-
summary[name] = value[name];
|
|
502
|
-
}
|
|
503
|
-
return summary;
|
|
504
|
-
}
|
|
505
|
-
function encode_remote_failure(failure) {
|
|
506
|
-
log_remote_server_step("encode_remote_failure:start", { failure });
|
|
507
|
-
const { state } = get_request_store();
|
|
508
|
-
const encoders = Object.fromEntries(Object.entries(state.transport).map(([name, transporter]) => [name, transporter.encode]));
|
|
509
|
-
const encoded = stringify(to_transportable_data(failure), encoders);
|
|
510
|
-
throw error(get_remote_failure_status(failure), {
|
|
511
|
-
message: "Effect remote failure",
|
|
512
|
-
...create_serialized_remote_failure_envelope(encoded)
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
function throw_form_error(form_error) {
|
|
516
|
-
log_remote_server_step("throw_form_error", { issues: form_error.issues });
|
|
517
|
-
invalid(...form_error.issues.map((issue) => ({
|
|
518
|
-
message: issue.message,
|
|
519
|
-
path: [...issue.path]
|
|
520
|
-
})));
|
|
521
|
-
}
|
|
522
|
-
async function run_remote_effect(program) {
|
|
523
|
-
const request_event = getRequestEvent();
|
|
524
|
-
const runtime = get_server_runtime_or_throw();
|
|
525
|
-
log_remote_server_step("run_remote_effect:start", {
|
|
526
|
-
method: request_event.request.method,
|
|
527
|
-
url: request_event.url.toString()
|
|
528
|
-
});
|
|
529
|
-
const provided_program = Effect.provideService(program, RequestEvent, request_event);
|
|
530
|
-
const exit = await runtime.runPromiseExit(provided_program);
|
|
531
|
-
if (Exit.isSuccess(exit)) {
|
|
532
|
-
log_remote_server_step("run_remote_effect:success", { value: exit.value });
|
|
533
|
-
return exit.value;
|
|
534
|
-
}
|
|
535
|
-
const failure = get_cause_failure(exit.cause);
|
|
536
|
-
if (failure !== void 0) {
|
|
537
|
-
log_remote_server_step("run_remote_effect:failure", { failure });
|
|
538
|
-
if (is_form_error(failure)) throw_form_error(failure);
|
|
539
|
-
encode_remote_failure(failure);
|
|
540
|
-
}
|
|
541
|
-
log_remote_server_step("run_remote_effect:defect", { cause: exit.cause });
|
|
542
|
-
throw Cause.squash(exit.cause);
|
|
543
|
-
}
|
|
544
|
-
function get_schema_field_names(schema) {
|
|
545
|
-
return get_effect_schema_field_names(schema);
|
|
546
|
-
}
|
|
547
|
-
function create_invalid_helper(options = {}) {
|
|
548
|
-
const field_names = options.schema ? new Set(get_schema_field_names(options.schema)) : null;
|
|
549
|
-
const create_issue_effect = (message, path) => Effect.fail(create_form_error({
|
|
550
|
-
message,
|
|
551
|
-
path
|
|
552
|
-
}));
|
|
553
|
-
return new Proxy({ form(message) {
|
|
554
|
-
return create_issue_effect(message, []);
|
|
555
|
-
} }, { get(target, property) {
|
|
556
|
-
if (typeof property !== "string") return Reflect.get(target, property);
|
|
557
|
-
if (property in target) return target[property];
|
|
558
|
-
if (field_names !== null && !field_names.has(property)) throw new Error(`Unknown form field '${property}' in invalid helper. v1 only supports top-level fields declared in the Effect.Schema.`);
|
|
559
|
-
return (message) => create_issue_effect(message, [property]);
|
|
560
|
-
} });
|
|
561
|
-
}
|
|
562
|
-
function define_native_property(value, native) {
|
|
563
|
-
Object.defineProperty(value, "native", {
|
|
564
|
-
value: native,
|
|
565
|
-
enumerable: false
|
|
566
|
-
});
|
|
567
|
-
return value;
|
|
568
|
-
}
|
|
569
|
-
/**
|
|
570
|
-
* Build a devalue transport table from Effect schemas so remote payloads can
|
|
571
|
-
* round-trip custom data across the client/server boundary.
|
|
572
|
-
*
|
|
573
|
-
* @see https://ser.barekey.dev/content/reference/transport
|
|
574
|
-
*/
|
|
575
|
-
function create_effect_transport(schemas) {
|
|
576
|
-
return Object.fromEntries(Object.entries(schemas).map(([name, schema]) => {
|
|
577
|
-
return [name, {
|
|
578
|
-
encode(value) {
|
|
579
|
-
try {
|
|
580
|
-
return Schema.is(schema)(value) ? { value: Schema.encodeSync(schema)(value) } : false;
|
|
581
|
-
} catch {
|
|
582
|
-
return false;
|
|
583
|
-
}
|
|
584
|
-
},
|
|
585
|
-
decode(data) {
|
|
586
|
-
return Schema.decodeSync(schema)(data.value);
|
|
587
|
-
}
|
|
588
|
-
}];
|
|
589
|
-
}));
|
|
590
|
-
}
|
|
591
|
-
function create_native_wrapper(value) {
|
|
592
|
-
return define_native_property(new Proxy(value, {
|
|
593
|
-
apply(target, thisArg, args) {
|
|
594
|
-
try {
|
|
595
|
-
return Reflect.apply(target, thisArg, args);
|
|
596
|
-
} catch (error) {
|
|
597
|
-
remap_remote_usage_error(error);
|
|
598
|
-
}
|
|
599
|
-
},
|
|
600
|
-
get(target, property, _receiver) {
|
|
601
|
-
if (property === "native") return value;
|
|
602
|
-
try {
|
|
603
|
-
return Reflect.get(target, property, target);
|
|
604
|
-
} catch (error) {
|
|
605
|
-
remap_remote_usage_error(error);
|
|
606
|
-
}
|
|
607
|
-
},
|
|
608
|
-
has(target, property) {
|
|
609
|
-
return property === "native" || Reflect.has(target, property);
|
|
610
|
-
},
|
|
611
|
-
getOwnPropertyDescriptor(target, property) {
|
|
612
|
-
return Reflect.getOwnPropertyDescriptor(target, property);
|
|
613
|
-
}
|
|
614
|
-
}), value);
|
|
615
|
-
}
|
|
616
|
-
function wrap_form_remote(native) {
|
|
617
|
-
const wrapped = {};
|
|
618
|
-
for (const key of Reflect.ownKeys(native)) {
|
|
619
|
-
const descriptor = Object.getOwnPropertyDescriptor(native, key);
|
|
620
|
-
if (!descriptor) continue;
|
|
621
|
-
if (key === "for" && typeof descriptor.value === "function") {
|
|
622
|
-
Object.defineProperty(wrapped, key, {
|
|
623
|
-
configurable: descriptor.configurable ?? true,
|
|
624
|
-
enumerable: descriptor.enumerable ?? false,
|
|
625
|
-
writable: descriptor.writable ?? false,
|
|
626
|
-
value: (id) => wrap_form_remote(descriptor.value.call(native, id))
|
|
627
|
-
});
|
|
628
|
-
continue;
|
|
629
|
-
}
|
|
630
|
-
Object.defineProperty(wrapped, key, descriptor);
|
|
631
|
-
}
|
|
632
|
-
Object.defineProperty(wrapped, "native", {
|
|
633
|
-
configurable: true,
|
|
634
|
-
enumerable: false,
|
|
635
|
-
value: native,
|
|
636
|
-
writable: false
|
|
637
|
-
});
|
|
638
|
-
Object.defineProperty(wrapped, "submit", {
|
|
639
|
-
configurable: true,
|
|
640
|
-
enumerable: false,
|
|
641
|
-
writable: false,
|
|
642
|
-
value: () => Effect.fail(create_remote_http_error(/* @__PURE__ */ new Error("form.submit() can only be called on the client. It does not run during server-side rendering."), { status: 500 }))
|
|
643
|
-
});
|
|
644
|
-
return wrapped;
|
|
645
|
-
}
|
|
646
|
-
function query_batch_factory(validate_or_fn, maybe_fn) {
|
|
647
|
-
const resolved = resolve_remote_args(validate_or_fn, maybe_fn);
|
|
648
|
-
if (resolved.validate === void 0) throw new Error("Query.batch requires either 'unchecked' or an Effect.Schema validator to match SvelteKit's native API.");
|
|
649
|
-
return create_native_wrapper(resolved.validate === "unchecked" ? query.batch("unchecked", (args) => run_remote_effect(resolved.fn(args))) : query.batch(get_effect_schema_validator(resolved.validate), (args) => run_remote_effect(resolved.fn(args))));
|
|
650
|
-
}
|
|
651
|
-
const query_impl = (validate_or_fn, maybe_fn) => {
|
|
652
|
-
const resolved = resolve_remote_args(validate_or_fn, maybe_fn);
|
|
653
|
-
return create_native_wrapper(resolved.validate === void 0 ? query(() => run_remote_effect(resolved.fn())) : resolved.validate === "unchecked" ? query("unchecked", (arg) => run_remote_effect(resolved.fn(arg))) : query(get_effect_schema_validator(resolved.validate), (arg) => run_remote_effect(resolved.fn(arg))));
|
|
654
|
-
};
|
|
655
|
-
/**
|
|
656
|
-
* Define a read-only remote function that returns an `Effect` on the client.
|
|
657
|
-
*
|
|
658
|
-
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
659
|
-
*/
|
|
660
|
-
const Query = Object.assign(query_impl, { batch: query_batch_factory });
|
|
661
|
-
const command_impl = (validate_or_fn, maybe_fn) => {
|
|
662
|
-
const resolved = resolve_remote_args(validate_or_fn, maybe_fn);
|
|
663
|
-
return create_native_wrapper(resolved.validate === void 0 ? command(() => run_remote_effect(resolved.fn())) : resolved.validate === "unchecked" ? command("unchecked", (arg) => run_remote_effect(resolved.fn(arg))) : command(get_effect_schema_validator(resolved.validate), (arg) => run_remote_effect(resolved.fn(arg))));
|
|
664
|
-
};
|
|
665
|
-
/**
|
|
666
|
-
* Define a write-oriented remote function that returns an `Effect` on the
|
|
667
|
-
* client.
|
|
668
|
-
*
|
|
669
|
-
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
670
|
-
*/
|
|
671
|
-
const Command = command_impl;
|
|
672
|
-
const form_impl = (validate_or_fn, maybe_fn) => {
|
|
673
|
-
const resolved = resolve_remote_args(validate_or_fn, maybe_fn);
|
|
674
|
-
return wrap_form_remote(resolved.validate === void 0 ? form(() => run_remote_effect(resolved.fn())) : resolved.validate === "unchecked" ? form("unchecked", (data) => run_remote_effect(resolved.fn({
|
|
675
|
-
data,
|
|
676
|
-
invalid: create_invalid_helper()
|
|
677
|
-
}))) : form(get_effect_form_validator(resolved.validate), (data) => run_remote_effect(resolved.fn({
|
|
678
|
-
data,
|
|
679
|
-
invalid: create_invalid_helper({ schema: resolved.validate })
|
|
680
|
-
}))));
|
|
681
|
-
};
|
|
682
|
-
/**
|
|
683
|
-
* Define a remote form handler that maps submitted data into an Effect
|
|
684
|
-
* program.
|
|
685
|
-
*
|
|
686
|
-
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
687
|
-
*/
|
|
688
|
-
const Form = form_impl;
|
|
689
|
-
const native_prerender_fn = prerender;
|
|
690
|
-
const prerender_impl = (validate_or_fn, fn_or_options, maybe_options) => {
|
|
691
|
-
if (typeof validate_or_fn === "function" && typeof fn_or_options !== "function") return create_native_wrapper(native_prerender_fn(() => run_remote_effect(validate_or_fn()), fn_or_options));
|
|
692
|
-
const resolved = resolve_remote_args(validate_or_fn, fn_or_options);
|
|
693
|
-
return create_native_wrapper(resolved.validate === "unchecked" ? native_prerender_fn("unchecked", (arg) => run_remote_effect(resolved.fn(arg)), maybe_options) : native_prerender_fn(get_effect_schema_validator(resolved.validate), (arg) => run_remote_effect(resolved.fn(arg)), maybe_options));
|
|
694
|
-
};
|
|
695
|
-
/**
|
|
696
|
-
* Define a prerenderable remote function backed by an Effect program.
|
|
697
|
-
*
|
|
698
|
-
* @see https://ser.barekey.dev/content/remote-functions/prerender
|
|
699
|
-
*/
|
|
700
|
-
const Prerender = prerender_impl;
|
|
701
|
-
//#endregion
|
|
702
|
-
export { RequestEvent as a, get_server_runtime_or_throw as c, Query as i, normalize_remote_helper_error as l, Form as n, ServerRuntime as o, Prerender as r, create_effect_transport as s, Command as t };
|
|
703
|
-
|
|
704
|
-
//# sourceMappingURL=server-Dea1CJuY.js.map
|