svelte-effect-runtime 1.2.3 → 1.3.0
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-DkW4e4dD.js +199 -0
- package/dist/chunks/client-DkW4e4dD.js.map +1 -0
- package/dist/chunks/effect-CL8GJs8A.js +51 -0
- package/dist/chunks/effect-CL8GJs8A.js.map +1 -0
- package/dist/chunks/effect-compat-BhW0YPIs.js +103 -0
- package/dist/chunks/effect-compat-BhW0YPIs.js.map +1 -0
- package/dist/chunks/{magic-string.es-5gRBdMgP.js → magic-string.es-BnGH-5YR.js} +1 -1
- package/dist/chunks/{magic-string.es-5gRBdMgP.js.map → magic-string.es-BnGH-5YR.js.map} +1 -1
- package/dist/chunks/{markup-Ccw42uCl.js → markup-BpSHnnYD.js} +4 -4
- package/dist/chunks/{markup-Ccw42uCl.js.map → markup-BpSHnnYD.js.map} +1 -1
- package/dist/chunks/preprocess-CtLrnJcK.js +44 -0
- package/dist/chunks/preprocess-CtLrnJcK.js.map +1 -0
- package/dist/chunks/server-DR-6LMdP.js +629 -0
- package/dist/chunks/server-DR-6LMdP.js.map +1 -0
- package/dist/chunks/v3-p8V3Drpp.js +1 -0
- package/dist/chunks/v4-DIhYCbb_.js +1 -0
- package/dist/chunks/vite-DqjXRZd4.js +143 -0
- package/dist/chunks/vite-DqjXRZd4.js.map +1 -0
- package/dist/client.d.ts +1 -64
- package/dist/client.js +2 -170
- package/dist/effect.d.ts +1 -7
- package/dist/effect.js +1 -27
- package/dist/internal/effect-compat.d.ts +21 -0
- package/dist/internal/markup.d.ts +1 -1
- package/dist/internal/markup.js +1 -1
- package/dist/internal/remote-client.js +30 -6
- package/dist/internal/remote-client.js.map +1 -1
- package/dist/internal/transform.d.ts +1 -1
- package/dist/internal/transform.js +3 -4
- package/dist/internal/transform.js.map +1 -1
- package/dist/language-server.d.ts +9 -3
- package/dist/language-server.js +3 -3
- package/dist/mod.d.ts +1 -6
- package/dist/mod.js +3 -5
- package/dist/preprocess.d.ts +23 -6
- package/dist/preprocess.js +10 -31
- package/dist/preprocess.js.map +1 -1
- package/dist/root-node.d.ts +1 -14
- package/dist/root-node.js +63 -8
- package/dist/root-node.js.map +1 -0
- package/dist/server.d.ts +56 -129
- package/dist/server.js +44 -508
- package/dist/server.js.map +1 -1
- package/dist/v3/client.d.ts +93 -0
- package/dist/v3/effect.d.ts +17 -0
- package/dist/v3/mod.d.ts +3 -0
- package/dist/v3/preprocess.d.ts +28 -0
- package/dist/v3/root-node.d.ts +59 -0
- package/dist/v3/server.d.ts +167 -0
- package/dist/v3/vite.d.ts +46 -0
- package/dist/v4/client.d.ts +2 -0
- package/dist/v4/effect.d.ts +24 -0
- package/dist/v4/effect.js +19 -0
- package/dist/v4/effect.js.map +1 -0
- package/dist/v4/mod.d.ts +3 -0
- package/dist/v4/mod.js +3 -0
- package/dist/v4/preprocess.d.ts +30 -0
- package/dist/v4/preprocess.js +28 -0
- package/dist/v4/preprocess.js.map +1 -0
- package/dist/v4/root-node.d.ts +59 -0
- package/dist/v4/root-node.js +63 -0
- package/dist/v4/root-node.js.map +1 -0
- package/dist/v4/server.d.ts +118 -0
- package/dist/v4/server.js +22 -0
- package/dist/v4/server.js.map +1 -0
- package/dist/v4/vite.d.ts +34 -0
- package/dist/v4/vite.js +31 -0
- package/dist/v4/vite.js.map +1 -0
- package/dist/vite.d.ts +30 -15
- package/dist/vite.js +18 -101
- package/dist/vite.js.map +1 -1
- package/package.json +46 -3
- package/dist/client.js.map +0 -1
- package/dist/effect.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-DR-6LMdP.js","names":["devalue.stringify","svelte_error","get_native_request_event","native_query","native_command","native_form","native_prerender"],"sources":["../../../node_modules/.deno/devalue@5.6.4/node_modules/devalue/src/utils.js","../../../node_modules/.deno/devalue@5.6.4/node_modules/devalue/src/base64.js","../../../node_modules/.deno/devalue@5.6.4/node_modules/devalue/src/stringify.js","../../../modules/svelte-effect-runtime/v3/server.ts"],"sourcesContent":["/** @type {Record<string, string>} */\nexport const escaped = {\n\t'<': '\\\\u003C',\n\t'\\\\': '\\\\\\\\',\n\t'\\b': '\\\\b',\n\t'\\f': '\\\\f',\n\t'\\n': '\\\\n',\n\t'\\r': '\\\\r',\n\t'\\t': '\\\\t',\n\t'\\u2028': '\\\\u2028',\n\t'\\u2029': '\\\\u2029'\n};\n\nexport class DevalueError extends Error {\n\t/**\n\t * @param {string} message\n\t * @param {string[]} keys\n\t * @param {any} [value] - The value that failed to be serialized\n\t * @param {any} [root] - The root value being serialized\n\t */\n\tconstructor(message, keys, value, root) {\n\t\tsuper(message);\n\t\tthis.name = 'DevalueError';\n\t\tthis.path = keys.join('');\n\t\tthis.value = value;\n\t\tthis.root = root;\n\t}\n}\n\n/** @param {any} thing */\nexport function is_primitive(thing) {\n\treturn Object(thing) !== thing;\n}\n\nconst object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(\n\tObject.prototype\n)\n\t.sort()\n\t.join('\\0');\n\n/** @param {any} thing */\nexport function is_plain_object(thing) {\n\tconst proto = Object.getPrototypeOf(thing);\n\n\treturn (\n\t\tproto === Object.prototype ||\n\t\tproto === null ||\n\t\tObject.getPrototypeOf(proto) === null ||\n\t\tObject.getOwnPropertyNames(proto).sort().join('\\0') === object_proto_names\n\t);\n}\n\n/** @param {any} thing */\nexport function get_type(thing) {\n\treturn Object.prototype.toString.call(thing).slice(8, -1);\n}\n\n/** @param {string} char */\nfunction get_escaped_char(char) {\n\tswitch (char) {\n\t\tcase '\"':\n\t\t\treturn '\\\\\"';\n\t\tcase '<':\n\t\t\treturn '\\\\u003C';\n\t\tcase '\\\\':\n\t\t\treturn '\\\\\\\\';\n\t\tcase '\\n':\n\t\t\treturn '\\\\n';\n\t\tcase '\\r':\n\t\t\treturn '\\\\r';\n\t\tcase '\\t':\n\t\t\treturn '\\\\t';\n\t\tcase '\\b':\n\t\t\treturn '\\\\b';\n\t\tcase '\\f':\n\t\t\treturn '\\\\f';\n\t\tcase '\\u2028':\n\t\t\treturn '\\\\u2028';\n\t\tcase '\\u2029':\n\t\t\treturn '\\\\u2029';\n\t\tdefault:\n\t\t\treturn char < ' '\n\t\t\t\t? `\\\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`\n\t\t\t\t: '';\n\t}\n}\n\n/** @param {string} str */\nexport function stringify_string(str) {\n\tlet result = '';\n\tlet last_pos = 0;\n\tconst len = str.length;\n\n\tfor (let i = 0; i < len; i += 1) {\n\t\tconst char = str[i];\n\t\tconst replacement = get_escaped_char(char);\n\t\tif (replacement) {\n\t\t\tresult += str.slice(last_pos, i) + replacement;\n\t\t\tlast_pos = i + 1;\n\t\t}\n\t}\n\n\treturn `\"${last_pos === 0 ? str : result + str.slice(last_pos)}\"`;\n}\n\n/** @param {Record<string | symbol, any>} object */\nexport function enumerable_symbols(object) {\n\treturn Object.getOwnPropertySymbols(object).filter(\n\t\t(symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable\n\t);\n}\n\nconst is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;\n\n/** @param {string} key */\nexport function stringify_key(key) {\n\treturn is_identifier.test(key) ? '.' + key : '[' + JSON.stringify(key) + ']';\n}\n\n/** @param {string} s */\nfunction is_valid_array_index(s) {\n\tif (s.length === 0) return false;\n\tif (s.length > 1 && s.charCodeAt(0) === 48) return false; // leading zero\n\tfor (let i = 0; i < s.length; i++) {\n\t\tconst c = s.charCodeAt(i);\n\t\tif (c < 48 || c > 57) return false;\n\t}\n\t// by this point we know it's a string of digits, but it has to be within the range of valid array indices\n\tconst n = +s;\n\tif (n >= 2 ** 32 - 1) return false;\n\tif (n < 0) return false;\n\treturn true;\n}\n\n/**\n * Finds the populated indices of an array.\n * @param {unknown[]} array\n */\nexport function valid_array_indices(array) {\n\tconst keys = Object.keys(array);\n\tfor (var i = keys.length - 1; i >= 0; i--) {\n\t\tif (is_valid_array_index(keys[i])) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tkeys.length = i + 1;\n\treturn keys;\n}\n","/**\n * Base64 Encodes an arraybuffer\n * @param {ArrayBuffer} arraybuffer\n * @returns {string}\n */\nexport function encode64(arraybuffer) {\n const dv = new DataView(arraybuffer);\n let binaryString = \"\";\n\n for (let i = 0; i < arraybuffer.byteLength; i++) {\n binaryString += String.fromCharCode(dv.getUint8(i));\n }\n\n return binaryToAscii(binaryString);\n}\n\n/**\n * Decodes a base64 string into an arraybuffer\n * @param {string} string\n * @returns {ArrayBuffer}\n */\nexport function decode64(string) {\n const binaryString = asciiToBinary(string);\n const arraybuffer = new ArrayBuffer(binaryString.length);\n const dv = new DataView(arraybuffer);\n\n for (let i = 0; i < arraybuffer.byteLength; i++) {\n dv.setUint8(i, binaryString.charCodeAt(i));\n }\n\n return arraybuffer;\n}\n\nconst KEY_STRING =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n/**\n * Substitute for atob since it's deprecated in node.\n * Does not do any input validation.\n *\n * @see https://github.com/jsdom/abab/blob/master/lib/atob.js\n *\n * @param {string} data\n * @returns {string}\n */\nfunction asciiToBinary(data) {\n if (data.length % 4 === 0) {\n data = data.replace(/==?$/, \"\");\n }\n\n let output = \"\";\n let buffer = 0;\n let accumulatedBits = 0;\n\n for (let i = 0; i < data.length; i++) {\n buffer <<= 6;\n buffer |= KEY_STRING.indexOf(data[i]);\n accumulatedBits += 6;\n if (accumulatedBits === 24) {\n output += String.fromCharCode((buffer & 0xff0000) >> 16);\n output += String.fromCharCode((buffer & 0xff00) >> 8);\n output += String.fromCharCode(buffer & 0xff);\n buffer = accumulatedBits = 0;\n }\n }\n if (accumulatedBits === 12) {\n buffer >>= 4;\n output += String.fromCharCode(buffer);\n } else if (accumulatedBits === 18) {\n buffer >>= 2;\n output += String.fromCharCode((buffer & 0xff00) >> 8);\n output += String.fromCharCode(buffer & 0xff);\n }\n return output;\n}\n\n/**\n * Substitute for btoa since it's deprecated in node.\n * Does not do any input validation.\n *\n * @see https://github.com/jsdom/abab/blob/master/lib/btoa.js\n *\n * @param {string} str\n * @returns {string}\n */\nfunction binaryToAscii(str) {\n let out = \"\";\n for (let i = 0; i < str.length; i += 3) {\n /** @type {[number, number, number, number]} */\n const groupsOfSix = [undefined, undefined, undefined, undefined];\n groupsOfSix[0] = str.charCodeAt(i) >> 2;\n groupsOfSix[1] = (str.charCodeAt(i) & 0x03) << 4;\n if (str.length > i + 1) {\n groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;\n groupsOfSix[2] = (str.charCodeAt(i + 1) & 0x0f) << 2;\n }\n if (str.length > i + 2) {\n groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;\n groupsOfSix[3] = str.charCodeAt(i + 2) & 0x3f;\n }\n for (let j = 0; j < groupsOfSix.length; j++) {\n if (typeof groupsOfSix[j] === \"undefined\") {\n out += \"=\";\n } else {\n out += KEY_STRING[groupsOfSix[j]];\n }\n }\n }\n return out;\n}\n","import {\n\tDevalueError,\n\tenumerable_symbols,\n\tget_type,\n\tis_plain_object,\n\tis_primitive,\n\tstringify_key,\n\tstringify_string,\n\tvalid_array_indices\n} from './utils.js';\nimport {\n\tHOLE,\n\tNAN,\n\tNEGATIVE_INFINITY,\n\tNEGATIVE_ZERO,\n\tPOSITIVE_INFINITY,\n\tSPARSE,\n\tUNDEFINED\n} from './constants.js';\nimport { encode64 } from './base64.js';\n\n/**\n * Turn a value into a JSON string that can be parsed with `devalue.parse`\n * @param {any} value\n * @param {Record<string, (value: any) => any>} [reducers]\n */\nexport function stringify(value, reducers) {\n\t/** @type {any[]} */\n\tconst stringified = [];\n\n\t/** @type {Map<any, number>} */\n\tconst indexes = new Map();\n\n\t/** @type {Array<{ key: string, fn: (value: any) => any }>} */\n\tconst custom = [];\n\tif (reducers) {\n\t\tfor (const key of Object.getOwnPropertyNames(reducers)) {\n\t\t\tcustom.push({ key, fn: reducers[key] });\n\t\t}\n\t}\n\n\t/** @type {string[]} */\n\tconst keys = [];\n\n\tlet p = 0;\n\n\t/** @param {any} thing */\n\tfunction flatten(thing) {\n\t\tif (thing === undefined) return UNDEFINED;\n\t\tif (Number.isNaN(thing)) return NAN;\n\t\tif (thing === Infinity) return POSITIVE_INFINITY;\n\t\tif (thing === -Infinity) return NEGATIVE_INFINITY;\n\t\tif (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;\n\n\t\tif (indexes.has(thing)) return indexes.get(thing);\n\n\t\tconst index = p++;\n\t\tindexes.set(thing, index);\n\n\t\tfor (const { key, fn } of custom) {\n\t\t\tconst value = fn(thing);\n\t\t\tif (value) {\n\t\t\t\tstringified[index] = `[\"${key}\",${flatten(value)}]`;\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\n\t\tif (typeof thing === 'function') {\n\t\t\tthrow new DevalueError(`Cannot stringify a function`, keys, thing, value);\n\t\t}\n\n\t\tlet str = '';\n\n\t\tif (is_primitive(thing)) {\n\t\t\tstr = stringify_primitive(thing);\n\t\t} else {\n\t\t\tconst type = get_type(thing);\n\n\t\t\tswitch (type) {\n\t\t\t\tcase 'Number':\n\t\t\t\tcase 'String':\n\t\t\t\tcase 'Boolean':\n\t\t\t\t\tstr = `[\"Object\",${stringify_primitive(thing)}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'BigInt':\n\t\t\t\t\tstr = `[\"BigInt\",${thing}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Date':\n\t\t\t\t\tconst valid = !isNaN(thing.getDate());\n\t\t\t\t\tstr = `[\"Date\",\"${valid ? thing.toISOString() : ''}\"]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'URL':\n\t\t\t\t\tstr = `[\"URL\",${stringify_string(thing.toString())}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'URLSearchParams':\n\t\t\t\t\tstr = `[\"URLSearchParams\",${stringify_string(thing.toString())}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'RegExp':\n\t\t\t\t\tconst { source, flags } = thing;\n\t\t\t\t\tstr = flags\n\t\t\t\t\t\t? `[\"RegExp\",${stringify_string(source)},\"${flags}\"]`\n\t\t\t\t\t\t: `[\"RegExp\",${stringify_string(source)}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Array': {\n\t\t\t\t\t// For dense arrays (no holes), we iterate normally.\n\t\t\t\t\t// When we encounter the first hole, we call Object.keys\n\t\t\t\t\t// to determine the sparseness, then decide between:\n\t\t\t\t\t// - HOLE encoding: [-2, val, -2, ...] (default)\n\t\t\t\t\t// - Sparse encoding: [-7, length, idx, val, ...] (for very sparse arrays)\n\t\t\t\t\t// Only the sparse path avoids iterating every slot, which\n\t\t\t\t\t// is what protects against the DoS of e.g. `arr[1000000] = 1`.\n\t\t\t\t\tlet mostly_dense = false;\n\n\t\t\t\t\tstr = '[';\n\n\t\t\t\t\tfor (let i = 0; i < thing.length; i += 1) {\n\t\t\t\t\t\tif (i > 0) str += ',';\n\n\t\t\t\t\t\tif (Object.hasOwn(thing, i)) {\n\t\t\t\t\t\t\tkeys.push(`[${i}]`);\n\t\t\t\t\t\t\tstr += flatten(thing[i]);\n\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t} else if (mostly_dense) {\n\t\t\t\t\t\t\t// Use dense encoding. The heuristic guarantees the\n\t\t\t\t\t\t\t// array is only mildly sparse, so iterating over every\n\t\t\t\t\t\t\t// slot is fine.\n\t\t\t\t\t\t\tstr += HOLE;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Decide between HOLE encoding and sparse encoding.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// HOLE encoding: each hole is serialized as the HOLE\n\t\t\t\t\t\t\t// sentinel (-2). For example, [, \"a\", ,] becomes\n\t\t\t\t\t\t\t// [-2, 0, -2]. Each hole costs 3 chars (\"-2\" + comma).\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// Sparse encoding: lists only populated indices.\n\t\t\t\t\t\t\t// For example, [, \"a\", ,] becomes [-7, 3, 1, 0] — the\n\t\t\t\t\t\t\t// -7 sentinel, the array length (3), then index-value\n\t\t\t\t\t\t\t// pairs. This avoids paying per-hole, but each element\n\t\t\t\t\t\t\t// costs extra chars to write its index.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// The values are the same size either way, so the\n\t\t\t\t\t\t\t// choice comes down to structural overhead:\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// HOLE overhead:\n\t\t\t\t\t\t\t// 3 chars per hole (\"-2\" + comma)\n\t\t\t\t\t\t\t// = (L - P) * 3\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// Sparse overhead:\n\t\t\t\t\t\t\t// \"-7,\" — 3 chars (sparse sentinel + comma)\n\t\t\t\t\t\t\t// + length + \",\" — (d + 1) chars (array length + comma)\n\t\t\t\t\t\t\t// + per element: index + \",\" — (d + 1) chars\n\t\t\t\t\t\t\t// = (4 + d) + P * (d + 1)\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// where L is the array length, P is the number of\n\t\t\t\t\t\t\t// populated elements, and d is the number of digits\n\t\t\t\t\t\t\t// in L (an upper bound on the digits in any index).\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// Sparse encoding is cheaper when:\n\t\t\t\t\t\t\t// (4 + d) + P * (d + 1) < (L - P) * 3\n\t\t\t\t\t\t\tconst populated_keys = valid_array_indices(/** @type {any[]} */ (thing));\n\t\t\t\t\t\t\tconst population = populated_keys.length;\n\t\t\t\t\t\t\tconst d = String(thing.length).length;\n\n\t\t\t\t\t\t\tconst hole_cost = (thing.length - population) * 3;\n\t\t\t\t\t\t\tconst sparse_cost = 4 + d + population * (d + 1);\n\n\t\t\t\t\t\t\tif (hole_cost > sparse_cost) {\n\t\t\t\t\t\t\t\tstr = '[' + SPARSE + ',' + thing.length;\n\t\t\t\t\t\t\t\tfor (let j = 0; j < populated_keys.length; j++) {\n\t\t\t\t\t\t\t\t\tconst key = populated_keys[j];\n\t\t\t\t\t\t\t\t\tkeys.push(`[${key}]`);\n\t\t\t\t\t\t\t\t\tstr += ',' + key + ',' + flatten(thing[key]);\n\t\t\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tmostly_dense = true;\n\t\t\t\t\t\t\t\tstr += HOLE;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'Set':\n\t\t\t\t\tstr = '[\"Set\"';\n\n\t\t\t\t\tfor (const value of thing) {\n\t\t\t\t\t\tstr += `,${flatten(value)}`;\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Map':\n\t\t\t\t\tstr = '[\"Map\"';\n\n\t\t\t\t\tfor (const [key, value] of thing) {\n\t\t\t\t\t\tkeys.push(\n\t\t\t\t\t\t\t`.get(${is_primitive(key) ? stringify_primitive(key) : '...'})`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstr += `,${flatten(key)},${flatten(value)}`;\n\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Int8Array':\n\t\t\t\tcase 'Uint8Array':\n\t\t\t\tcase 'Uint8ClampedArray':\n\t\t\t\tcase 'Int16Array':\n\t\t\t\tcase 'Uint16Array':\n\t\t\t\tcase 'Int32Array':\n\t\t\t\tcase 'Uint32Array':\n\t\t\t\tcase 'Float32Array':\n\t\t\t\tcase 'Float64Array':\n\t\t\t\tcase 'BigInt64Array':\n\t\t\t\tcase 'BigUint64Array': {\n\t\t\t\t\t/** @type {import(\"./types.js\").TypedArray} */\n\t\t\t\t\tconst typedArray = thing;\n\t\t\t\t\tstr = '[\"' + type + '\",' + flatten(typedArray.buffer);\n\n\t\t\t\t\tconst a = thing.byteOffset;\n\t\t\t\t\tconst b = a + thing.byteLength;\n\n\t\t\t\t\t// handle subarrays\n\t\t\t\t\tif (a > 0 || b !== typedArray.buffer.byteLength) {\n\t\t\t\t\t\tconst m = +/(\\d+)/.exec(type)[1] / 8;\n\t\t\t\t\t\tstr += `,${a / m},${b / m}`;\n\t\t\t\t\t}\n\n\t\t\t\t\tstr += ']';\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'ArrayBuffer': {\n\t\t\t\t\t/** @type {ArrayBuffer} */\n\t\t\t\t\tconst arraybuffer = thing;\n\t\t\t\t\tconst base64 = encode64(arraybuffer);\n\n\t\t\t\t\tstr = `[\"ArrayBuffer\",\"${base64}\"]`;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'Temporal.Duration':\n\t\t\t\tcase 'Temporal.Instant':\n\t\t\t\tcase 'Temporal.PlainDate':\n\t\t\t\tcase 'Temporal.PlainTime':\n\t\t\t\tcase 'Temporal.PlainDateTime':\n\t\t\t\tcase 'Temporal.PlainMonthDay':\n\t\t\t\tcase 'Temporal.PlainYearMonth':\n\t\t\t\tcase 'Temporal.ZonedDateTime':\n\t\t\t\t\tstr = `[\"${type}\",${stringify_string(thing.toString())}]`;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tif (!is_plain_object(thing)) {\n\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t`Cannot stringify arbitrary non-POJOs`,\n\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (enumerable_symbols(thing).length > 0) {\n\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t`Cannot stringify POJOs with symbolic keys`,\n\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (Object.getPrototypeOf(thing) === null) {\n\t\t\t\t\t\tstr = '[\"null\"';\n\t\t\t\t\t\tfor (const key of Object.keys(thing)) {\n\t\t\t\t\t\t\tif (key === '__proto__') {\n\t\t\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t\t\t`Cannot stringify objects with __proto__ keys`,\n\t\t\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tkeys.push(stringify_key(key));\n\t\t\t\t\t\t\tstr += `,${stringify_string(key)},${flatten(thing[key])}`;\n\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstr += ']';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstr = '{';\n\t\t\t\t\t\tlet started = false;\n\t\t\t\t\t\tfor (const key of Object.keys(thing)) {\n\t\t\t\t\t\t\tif (key === '__proto__') {\n\t\t\t\t\t\t\t\tthrow new DevalueError(\n\t\t\t\t\t\t\t\t\t`Cannot stringify objects with __proto__ keys`,\n\t\t\t\t\t\t\t\t\tkeys,\n\t\t\t\t\t\t\t\t\tthing,\n\t\t\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (started) str += ',';\n\t\t\t\t\t\t\tstarted = true;\n\t\t\t\t\t\t\tkeys.push(stringify_key(key));\n\t\t\t\t\t\t\tstr += `${stringify_string(key)}:${flatten(thing[key])}`;\n\t\t\t\t\t\t\tkeys.pop();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstr += '}';\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tstringified[index] = str;\n\t\treturn index;\n\t}\n\n\tconst index = flatten(value);\n\n\t// special case — value is represented as a negative index\n\tif (index < 0) return `${index}`;\n\n\treturn `[${stringified.join(',')}]`;\n}\n\n/**\n * @param {any} thing\n * @returns {string}\n */\nfunction stringify_primitive(thing) {\n\tconst type = typeof thing;\n\tif (type === 'string') return stringify_string(thing);\n\tif (thing instanceof String) return stringify_string(thing.toString());\n\tif (thing === void 0) return UNDEFINED.toString();\n\tif (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();\n\tif (type === 'bigint') return `[\"BigInt\",\"${thing}\"]`;\n\treturn String(thing);\n}\n","import {\n error as svelte_error,\n invalid as svelte_invalid,\n} from \"@sveltejs/kit\";\nimport type {\n RemoteForm as SvelteKitRemoteForm,\n RemoteFormInput as SvelteKitRemoteFormInput,\n} from \"@sveltejs/kit\";\nimport {\n command as native_command,\n form as native_form,\n getRequestEvent as get_native_request_event,\n prerender as native_prerender,\n query as native_query,\n} from \"$app/server\";\nimport { get_request_store } from \"@sveltejs/kit/internal/server\";\nimport * as devalue from \"devalue\";\nimport { Cause, Effect, Exit, Layer, ManagedRuntime, Schema } from \"effect\";\nimport type { Context } from \"effect\";\nimport {\n create_form_error,\n create_serialized_remote_failure_envelope,\n type FormError,\n is_form_error,\n} from \"$internal/remote-shared.ts\";\nimport {\n get_cause_failure,\n get_effect_schema_field_names,\n make_context_key,\n to_standard_schema_v1,\n to_transportable_data,\n} from \"$internal/effect-compat.ts\";\n\ntype EffectSchema = Schema.Schema.Any;\n\nexport interface Transporter<T = unknown, U = { value: unknown }> {\n decode: (data: U) => T;\n encode: (value: T) => false | U;\n}\n\nexport type Transport = Record<string, Transporter>;\n\nexport type RemoteFormInput = SvelteKitRemoteFormInput;\n\nexport type RemoteQueryFunction<Input, Output> = (\n arg: OptionalArgument<Input>,\n) => Promise<Output>;\n\nexport type RemoteCommand<Input, Output> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Promise<Output> & {\n updates(...updates: Array<unknown>): Promise<Output>;\n })\n & {\n readonly pending: number;\n };\n\nexport type RemotePrerenderFunction<Input, Output> = (\n arg: OptionalArgument<Input>,\n) => Promise<Output>;\n\nexport type RemoteForm<Input extends RemoteFormInput | void, Output> =\n SvelteKitRemoteForm<Input, Output>;\n\ntype RuntimeOperator = (\n self: Layer.Layer<unknown, unknown, unknown>,\n) => Layer.Layer<unknown, unknown, unknown>;\n\ntype RuntimeSeedLayer<Requirements> = Layer.Layer<\n Requirements,\n never,\n Requirements\n>;\n\ntype ProvidedBy<Op> = Op extends (\n self: RuntimeSeedLayer<infer Requirements>,\n) => Layer.Layer<unknown, unknown, infer Incoming>\n ? Exclude<Requirements, Incoming>\n : never;\n\ntype ProvidedByAll<Ops extends ReadonlyArray<RuntimeOperator>> = Ops extends\n readonly [infer Head, ...infer Tail] ?\n | ProvidedBy<Head>\n | ProvidedByAll<Extract<Tail, ReadonlyArray<RuntimeOperator>>>\n : never;\n\ntype ApplyOperator<Seed, Op> = Op extends (self: Seed) => infer Out ? Out\n : never;\n\ntype ApplyOperators<\n Seed,\n Ops extends ReadonlyArray<RuntimeOperator>,\n> = Ops extends readonly [infer Head, ...infer Tail] ? ApplyOperators<\n ApplyOperator<Seed, Head>,\n Extract<Tail, ReadonlyArray<RuntimeOperator>>\n >\n : Seed;\n\ntype FinalRuntimeLayer<Ops extends ReadonlyArray<RuntimeOperator>> =\n ApplyOperators<RuntimeSeedLayer<ProvidedByAll<Ops>>, Ops> extends infer Out\n ? Out extends Layer.Layer<unknown, unknown, infer Incoming>\n ? [Incoming] extends [never] ? Out\n : never\n : never\n : never;\n\ntype OptionalArgument<Input> = undefined extends Input ? Input | void : Input;\n\ntype SchemaInput<SchemaType extends EffectSchema> = Schema.Schema.Encoded<\n SchemaType\n>;\ntype SchemaOutput<SchemaType extends EffectSchema> = Schema.Schema.Type<\n SchemaType\n>;\n\ntype FieldHelpers<FormShape, SchemaType> = FormShape extends\n Record<string, unknown> ? {\n [Key in keyof FormShape as Key extends string ? Key : never]: (\n message: string,\n ) => Effect.Effect<never, FormError<SchemaType>, never>;\n }\n : Record<PropertyKey, never>;\n\nexport type Invalid<SchemaType = unknown> =\n & {\n form: (\n message: string,\n ) => Effect.Effect<never, FormError<SchemaType>, never>;\n }\n & FieldHelpers<\n SchemaType extends EffectSchema ? SchemaOutput<SchemaType> : unknown,\n SchemaType\n >;\n\nexport type EffectQueryFunction<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect.Effect<\n Output,\n import(\"$internal/remote-shared.ts\").RemoteFailure<Error>,\n never\n >)\n & {\n native: RemoteQueryFunction<Input, Output>;\n };\n\nexport type EffectCommand<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect.Effect<\n Output,\n import(\"$internal/remote-shared.ts\").RemoteFailure<Error>,\n never\n >)\n & {\n native: RemoteCommand<Input, Output>;\n readonly pending: number;\n };\n\nexport type EffectPrerenderFunction<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect.Effect<\n Output,\n import(\"$internal/remote-shared.ts\").RemoteFailure<Error>,\n never\n >)\n & {\n native: RemotePrerenderFunction<Input, Output>;\n };\n\nexport type EffectForm<\n Input extends RemoteFormInput | void,\n Output,\n Error = never,\n> = RemoteForm<Input, Output> & {\n native: RemoteForm<Input, Output>;\n submit(\n data: OptionalArgument<Input>,\n ): Effect.Effect<\n Output,\n import(\"$internal/remote-shared.ts\").RemoteFailure<Error>,\n never\n >;\n for: RemoteForm<Input, Output>[\"for\"] extends\n (...args: infer Args) => infer Result\n ? (...args: Args) => EffectForm<Input, Output, Error>\n : never;\n};\n\nexport type RequestEventService = ReturnType<typeof get_native_request_event>;\n\n/**\n * Effect `Context.Tag` for the current SvelteKit `RequestEvent`.\n *\n * Remote functions can `yield* RequestEvent` to access cookies, headers, and\n * route state for the active request.\n *\n * @see https://ser.barekey.dev/content/runtimes/server\n */\nexport const RequestEvent: Context.Tag<\n RequestEventService,\n RequestEventService\n> = make_context_key<RequestEventService>(\n \"svelte-effect-runtime/RequestEvent\",\n) as Context.Tag<RequestEventService, RequestEventService>;\n\ninterface ServerRuntimeSeed {\n pipe(): Layer.Layer<never>;\n pipe<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): FinalRuntimeLayer<Ops>;\n make(): void;\n make<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): void;\n}\n\ntype ServerManagedRuntime = ManagedRuntime.ManagedRuntime<unknown, unknown>;\n\nlet current_server_runtime: ServerManagedRuntime | null = null;\n\nfunction runtime_seed<Requirements>(): RuntimeSeedLayer<Requirements> {\n return Layer.effectContext(Effect.context<Requirements>());\n}\n\nfunction pipe_server_runtime(): Layer.Layer<never>;\nfunction pipe_server_runtime<\n const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>],\n>(...ops: Ops): FinalRuntimeLayer<Ops>;\nfunction pipe_server_runtime(\n ...ops: Array<RuntimeOperator>\n): Layer.Layer<never, unknown, unknown> {\n if (ops.length === 0) {\n return Layer.empty;\n }\n\n return ops.reduce<Layer.Layer<unknown, unknown, unknown>>(\n (layer, op) => op(layer),\n runtime_seed<unknown>(),\n ) as Layer.Layer<never, unknown, unknown>;\n}\n\nfunction make_server_runtime(): void;\nfunction make_server_runtime<\n const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>],\n>(...ops: Ops): void;\nfunction make_server_runtime(\n ...ops: [] | [RuntimeOperator, ...Array<RuntimeOperator>]\n): void {\n const layer = ops.length === 0 ? pipe_server_runtime() : pipe_server_runtime(\n ...(ops as [RuntimeOperator, ...Array<RuntimeOperator>]),\n );\n\n const previous_runtime = current_server_runtime;\n\n current_server_runtime = ManagedRuntime.make(\n layer as unknown as Layer.Layer<unknown, unknown, never>,\n );\n\n void previous_runtime?.dispose().catch(() => undefined);\n}\n\n/**\n * Server-side runtime builder used to provide long-lived Effect services to\n * remote functions.\n *\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const ServerRuntime: ServerRuntimeSeed = {\n pipe: pipe_server_runtime,\n make: make_server_runtime,\n};\n\n/**\n * Resolve the active server runtime, lazily creating a default empty runtime\n * when no explicit one has been registered.\n *\n * Emitted by generated server-side remote wrappers - users should never\n * import this directly.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport function get_server_runtime_or_throw(): ServerManagedRuntime {\n if (current_server_runtime !== null) {\n return current_server_runtime;\n }\n\n // No runtime registered — lazily create a default one with an empty layer.\n // This mirrors the client runtime behavior and makes `ServerRuntime.make()`\n // in `hooks.server.ts` optional for apps that don't need to provide custom\n // dependencies. A later explicit call to `ServerRuntime.make(...)` will\n // dispose this default and replace it.\n current_server_runtime = ManagedRuntime.make(\n pipe_server_runtime() as unknown as Layer.Layer<unknown, unknown, never>,\n );\n\n return current_server_runtime;\n}\n\nfunction create_missing_remote_functions_error(error: unknown): Error {\n return new Error(\n [\n \"This remote helper was evaluated before SvelteKit's remote-function runtime was available.\",\n \"Enable `kit.experimental.remoteFunctions = true` in `svelte.config.js`.\",\n \"Enable that flag and restart Vite. If it is already enabled, this is likely an internal bug.\",\n ].join(\" \"),\n { cause: error },\n );\n}\n\nfunction is_missing_request_store_error(error: unknown): boolean {\n return Boolean(\n error instanceof Error &&\n error.message.includes(\"Could not get the request store\"),\n );\n}\n\n/**\n * Remap low-level request-store crashes into a clearer setup error when remote\n * helpers are evaluated outside SvelteKit's remote-function runtime.\n *\n * @internal Internal - do not use.\n */\nexport function normalize_remote_helper_error(error: unknown): unknown {\n if (is_missing_request_store_error(error)) {\n return create_missing_remote_functions_error(error);\n }\n\n return error;\n}\n\nfunction remap_remote_usage_error(error: unknown): never {\n throw normalize_remote_helper_error(error);\n}\n\nfunction is_effect_schema(value: unknown): value is EffectSchema {\n return Schema.isSchema(value);\n}\n\nfunction get_effect_schema_validator(schema: EffectSchema) {\n return to_standard_schema_v1(schema) as never;\n}\n\nfunction get_effect_form_validator(schema: EffectSchema) {\n return to_standard_schema_v1(schema) as never;\n}\n\nfunction resolve_remote_args<Fn>(validate_or_fn: unknown, maybe_fn?: Fn): {\n readonly fn: Fn;\n readonly validate: EffectSchema | \"unchecked\" | undefined;\n} {\n if (maybe_fn === undefined) {\n return {\n fn: validate_or_fn as Fn,\n validate: undefined,\n };\n }\n\n if (validate_or_fn === \"unchecked\") {\n return {\n fn: maybe_fn,\n validate: \"unchecked\",\n };\n }\n\n if (!is_effect_schema(validate_or_fn)) {\n throw new Error(\n \"Invalid schema passed to a remote function. Use Effect.Schema, 'unchecked', or omit the validator entirely.\",\n );\n }\n\n return {\n fn: maybe_fn,\n validate: validate_or_fn,\n };\n}\n\nfunction get_remote_failure_status(failure: unknown): number {\n if (\n failure &&\n typeof failure === \"object\" &&\n typeof (failure as { status?: unknown }).status === \"number\"\n ) {\n return (failure as { status: number }).status;\n }\n\n return 500;\n}\n\nfunction is_development_environment(): boolean {\n const vite_environment = (\n import.meta as ImportMeta & {\n env?: {\n DEV?: boolean;\n };\n }\n ).env;\n\n if (typeof vite_environment?.DEV === \"boolean\") {\n return vite_environment.DEV;\n }\n\n const node_process = (globalThis as typeof globalThis & {\n process?: {\n env?: {\n DEV?: string;\n NODE_ENV?: string;\n SVELTE_EFFECT_RUNTIME_DEBUG?: string;\n };\n };\n }).process;\n\n return (\n node_process?.env?.SVELTE_EFFECT_RUNTIME_DEBUG === \"1\" ||\n node_process?.env?.DEV === \"1\" ||\n node_process?.env?.NODE_ENV === \"development\"\n );\n}\n\nconst ENABLE_REMOTE_SERVER_DEBUG_LOGS = is_development_environment();\n\nfunction log_remote_server_step(\n step: string,\n details?: Record<string, unknown>,\n): void {\n if (!ENABLE_REMOTE_SERVER_DEBUG_LOGS) {\n return;\n }\n\n console.log(\"[svelte-effect-runtime][server]\", step, details ?? {});\n}\n\nfunction encode_remote_failure(failure: unknown): never {\n log_remote_server_step(\"encode_remote_failure:start\", {\n failure,\n });\n const { state } = get_request_store();\n const encoders = Object.fromEntries(\n Object.entries(state.transport as Transport).map(([name, transporter]) => [\n name,\n transporter.encode,\n ]),\n );\n const encoded = devalue.stringify(to_transportable_data(failure), encoders);\n const status = get_remote_failure_status(failure);\n\n throw svelte_error(\n status,\n {\n message: \"Effect remote failure\",\n ...create_serialized_remote_failure_envelope(encoded),\n } as never,\n );\n}\n\nfunction throw_form_error(form_error: FormError): never {\n log_remote_server_step(\"throw_form_error\", {\n issues: form_error.issues,\n });\n svelte_invalid(\n ...form_error.issues.map((issue) => ({\n message: issue.message,\n path: [...issue.path],\n })),\n );\n}\n\nasync function run_remote_effect<Success, ErrorType, Requirements>(\n program: Effect.Effect<Success, ErrorType, Requirements>,\n): Promise<Success> {\n const request_event = get_native_request_event();\n const runtime = get_server_runtime_or_throw();\n log_remote_server_step(\"run_remote_effect:start\", {\n method: request_event.request.method,\n url: request_event.url.toString(),\n });\n const provided_program = Effect.provideService(\n program,\n RequestEvent,\n request_event,\n );\n const exit = await runtime.runPromiseExit(provided_program);\n\n if (Exit.isSuccess(exit)) {\n log_remote_server_step(\"run_remote_effect:success\", {\n value: exit.value,\n });\n return exit.value;\n }\n\n const failure = get_cause_failure<ErrorType>(exit.cause);\n\n if (failure !== undefined) {\n log_remote_server_step(\"run_remote_effect:failure\", {\n failure,\n });\n if (is_form_error(failure)) {\n throw_form_error(failure);\n }\n\n encode_remote_failure(failure);\n }\n\n log_remote_server_step(\"run_remote_effect:defect\", {\n cause: exit.cause,\n });\n throw Cause.squash(exit.cause);\n}\n\nfunction get_schema_field_names(schema: EffectSchema): ReadonlyArray<string> {\n return get_effect_schema_field_names(schema);\n}\n\nfunction create_invalid_helper<SchemaType = unknown>(\n options: {\n readonly schema?: EffectSchema;\n } = {},\n): Invalid<SchemaType> {\n const field_names = options.schema\n ? new Set(get_schema_field_names(options.schema))\n : null;\n\n const create_issue_effect = (\n message: string,\n path: ReadonlyArray<string | number>,\n ): Effect.Effect<never, FormError<SchemaType>, never> =>\n Effect.fail(create_form_error<SchemaType>({\n message,\n path,\n }));\n\n const invalid = new Proxy(\n {\n form(message: string) {\n return create_issue_effect(message, []);\n },\n } as Record<\n string,\n (message: string) => Effect.Effect<never, FormError<SchemaType>, never>\n >,\n {\n get(target, property) {\n if (typeof property !== \"string\") {\n return Reflect.get(target, property);\n }\n\n if (property in target) {\n return target[property];\n }\n\n if (field_names !== null && !field_names.has(property)) {\n throw new Error(\n `Unknown form field '${property}' in invalid helper. v1 only supports top-level fields declared in the Effect.Schema.`,\n );\n }\n\n return (message: string) => create_issue_effect(message, [property]);\n },\n },\n );\n\n return invalid as Invalid<SchemaType>;\n}\n\nfunction define_native_property<T extends object, Native>(\n value: T,\n native: Native,\n): T {\n Object.defineProperty(value, \"native\", {\n value: native,\n enumerable: false,\n });\n\n return value;\n}\n\n/**\n * Build a devalue transport table from Effect schemas so remote payloads can\n * round-trip custom data across the client/server boundary.\n *\n * @see https://ser.barekey.dev/content/reference/transport\n */\nexport function create_effect_transport<\n const Schemas extends Record<string, EffectSchema>,\n>(schemas: Schemas): Transport {\n return Object.fromEntries(\n Object.entries(schemas).map(([name, schema]) => {\n return [name, {\n encode(value: unknown) {\n try {\n return Schema.is(schema)(value)\n ? {\n value: Schema.encodeSync(\n schema as Schema.Schema<unknown, unknown, never>,\n )(value),\n }\n : false;\n } catch {\n return false;\n }\n },\n decode(data: { value: unknown }) {\n return Schema.decodeSync(\n schema as Schema.Schema<unknown, unknown, never>,\n )(data.value);\n },\n }];\n }),\n );\n}\n\nexport interface EffectQueryFactory {\n <Output, ErrorType, Requirements>(\n fn: () => Effect.Effect<Output, ErrorType, Requirements>,\n ): EffectQueryFunction<void, Output, ErrorType>;\n <Input, Output, ErrorType, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect.Effect<Output, ErrorType, Requirements>,\n ): EffectQueryFunction<Input, Output, ErrorType>;\n <SchemaType extends EffectSchema, Output, ErrorType, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect.Effect<Output, ErrorType, Requirements>,\n ): EffectQueryFunction<SchemaInput<SchemaType>, Output, ErrorType>;\n batch: typeof query_batch_factory;\n}\n\ntype RemotePrerenderInputsGenerator<Input> = (\n event: RequestEventService,\n) => AsyncIterable<Input> | Iterable<Input>;\n\ntype RemotePrerenderOptions<Input> = {\n inputs?: RemotePrerenderInputsGenerator<Input>;\n dynamic?: boolean;\n};\n\nfunction create_native_wrapper(value: object) {\n const wrapped = new Proxy(value, {\n apply(target, thisArg, args) {\n try {\n return Reflect.apply(\n target as unknown as (...args: Array<unknown>) => unknown,\n thisArg,\n args,\n );\n } catch (error) {\n remap_remote_usage_error(error);\n }\n },\n get(target, property, _receiver) {\n if (property === \"native\") {\n return value;\n }\n\n try {\n return Reflect.get(target, property, target);\n } catch (error) {\n remap_remote_usage_error(error);\n }\n },\n has(target, property) {\n return property === \"native\" || Reflect.has(target, property);\n },\n getOwnPropertyDescriptor(target, property) {\n if (property === \"native\") {\n return {\n configurable: true,\n enumerable: false,\n value,\n writable: false,\n };\n }\n\n return Reflect.getOwnPropertyDescriptor(target, property);\n },\n });\n\n return define_native_property(wrapped, value);\n}\n\nfunction query_batch_factory(\n validate_or_fn: unknown,\n maybe_fn?: unknown,\n): unknown {\n const resolved = resolve_remote_args(\n validate_or_fn,\n maybe_fn as\n | ((args: Array<unknown>) => Effect.Effect<unknown, unknown, unknown>)\n | undefined,\n );\n\n if (resolved.validate === undefined) {\n throw new Error(\n \"Query.batch requires either 'unchecked' or an Effect.Schema validator to match SvelteKit's native API.\",\n );\n }\n\n const native = resolved.validate === \"unchecked\"\n ? native_query.batch(\n \"unchecked\",\n (args: Array<unknown>) =>\n run_remote_effect(resolved.fn(args)) as Promise<\n (arg: unknown, idx: number) => unknown\n >,\n )\n : native_query.batch(\n get_effect_schema_validator(resolved.validate),\n (args: Array<unknown>) =>\n run_remote_effect(resolved.fn(args)) as Promise<\n (arg: unknown, idx: number) => unknown\n >,\n );\n\n return create_native_wrapper(native);\n}\n\nconst query_impl = (validate_or_fn: unknown, maybe_fn?: unknown): unknown => {\n const resolved = resolve_remote_args(\n validate_or_fn,\n maybe_fn as\n | ((arg: unknown) => Effect.Effect<unknown, unknown, unknown>)\n | undefined,\n );\n const native = resolved.validate === undefined\n ? native_query(() =>\n run_remote_effect(\n (resolved.fn as () => Effect.Effect<unknown, unknown, unknown>)(),\n )\n )\n : resolved.validate === \"unchecked\"\n ? native_query(\n \"unchecked\",\n (arg: unknown) =>\n run_remote_effect(\n (resolved.fn as (\n arg: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>)(arg),\n ),\n )\n : native_query(\n get_effect_schema_validator(resolved.validate),\n (arg: unknown) =>\n run_remote_effect(\n (resolved.fn as (\n arg: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>)(arg),\n ),\n );\n\n return create_native_wrapper(native);\n};\n\n/**\n * Define a read-only remote function that returns an `Effect` on the client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/query\n */\nexport const Query = Object.assign(query_impl, {\n batch: query_batch_factory,\n}) as unknown as EffectQueryFactory;\n\nconst command_impl = (validate_or_fn: unknown, maybe_fn?: unknown): unknown => {\n const resolved = resolve_remote_args(\n validate_or_fn,\n maybe_fn as\n | ((arg: unknown) => Effect.Effect<unknown, unknown, unknown>)\n | undefined,\n );\n const native = resolved.validate === undefined\n ? native_command(() =>\n run_remote_effect(\n (resolved.fn as () => Effect.Effect<unknown, unknown, unknown>)(),\n )\n )\n : resolved.validate === \"unchecked\"\n ? native_command(\n \"unchecked\",\n (arg: unknown) =>\n run_remote_effect(\n (resolved.fn as (\n arg: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>)(arg),\n ),\n )\n : native_command(\n get_effect_schema_validator(resolved.validate),\n (arg: unknown) =>\n run_remote_effect(\n (resolved.fn as (\n arg: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>)(arg),\n ),\n );\n\n return create_native_wrapper(native);\n};\n\nexport interface EffectCommandFactory {\n <Output, ErrorType, Requirements>(\n fn: () => Effect.Effect<Output, ErrorType, Requirements>,\n ): EffectCommand<void, Output, ErrorType>;\n <Input, Output, ErrorType, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect.Effect<Output, ErrorType, Requirements>,\n ): EffectCommand<Input, Output, ErrorType>;\n <SchemaType extends EffectSchema, Output, ErrorType, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect.Effect<Output, ErrorType, Requirements>,\n ): EffectCommand<SchemaInput<SchemaType>, Output, ErrorType>;\n}\n\n/**\n * Define a write-oriented remote function that returns an `Effect` on the\n * client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/command\n */\nexport const Command = command_impl as unknown as EffectCommandFactory;\n\nconst form_impl = (validate_or_fn: unknown, maybe_fn?: unknown): unknown => {\n const resolved = resolve_remote_args(\n validate_or_fn,\n maybe_fn as\n | ((args: unknown) => Effect.Effect<unknown, unknown, unknown>)\n | undefined,\n );\n const native = resolved.validate === undefined\n ? native_form(() =>\n run_remote_effect(\n (resolved.fn as () => Effect.Effect<unknown, unknown, unknown>)(),\n )\n )\n : resolved.validate === \"unchecked\"\n ? native_form(\n \"unchecked\",\n (data: RemoteFormInput) =>\n run_remote_effect(\n (resolved.fn as (\n args: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>)({\n data,\n invalid: create_invalid_helper(),\n }),\n ),\n )\n : native_form(\n get_effect_form_validator(resolved.validate as EffectSchema),\n (data: Record<string, unknown>) =>\n run_remote_effect(\n (resolved.fn as (\n args: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>)({\n data,\n invalid: create_invalid_helper({\n schema: resolved.validate as EffectSchema,\n }),\n }),\n ),\n );\n\n return create_native_wrapper(native);\n};\n\nexport interface EffectFormFactory {\n <Output, ErrorType, Requirements>(\n fn: () => Effect.Effect<Output, ErrorType, Requirements>,\n ): EffectForm<void, Output, ErrorType>;\n <Input extends RemoteFormInput, Output, ErrorType, Requirements>(\n validate: \"unchecked\",\n fn: (\n args: {\n data: Input;\n invalid: Invalid;\n },\n ) => Effect.Effect<Output, ErrorType | FormError, Requirements>,\n ): EffectForm<Input, Output, ErrorType>;\n <SchemaType extends EffectSchema, Output, ErrorType, Requirements>(\n validate: SchemaType,\n fn: (\n args: {\n data: SchemaOutput<SchemaType>;\n invalid: Invalid<SchemaType>;\n },\n ) => Effect.Effect<Output, ErrorType | FormError<SchemaType>, Requirements>,\n ): EffectForm<SchemaInput<SchemaType> & RemoteFormInput, Output, ErrorType>;\n}\n\n/**\n * Define a remote form handler that maps submitted data into an Effect\n * program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/form\n */\nexport const Form = form_impl as unknown as EffectFormFactory;\n\nexport interface EffectPrerenderFactory {\n <Output, ErrorType, Requirements>(\n fn: () => Effect.Effect<Output, ErrorType, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<void>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<void, Output, ErrorType>;\n <Input, Output, ErrorType, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect.Effect<Output, ErrorType, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<Input>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<Input, Output, ErrorType>;\n <SchemaType extends EffectSchema, Output, ErrorType, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect.Effect<Output, ErrorType, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<SchemaInput<SchemaType>>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<SchemaInput<SchemaType>, Output, ErrorType>;\n}\n\ntype NativePrerender = {\n (\n fn: () => Promise<unknown>,\n options?: RemotePrerenderOptions<void>,\n ): object;\n (\n validate: \"unchecked\",\n fn: (arg: unknown) => Promise<unknown>,\n options?: RemotePrerenderOptions<unknown>,\n ): object;\n (\n validate: EffectSchema,\n fn: (arg: unknown) => Promise<unknown>,\n options?: RemotePrerenderOptions<unknown>,\n ): object;\n};\n\nconst native_prerender_fn = native_prerender as unknown as NativePrerender;\n\nconst prerender_impl = (\n validate_or_fn: unknown,\n fn_or_options?: unknown,\n maybe_options?: unknown,\n): unknown => {\n if (\n typeof validate_or_fn === \"function\" &&\n typeof fn_or_options !== \"function\"\n ) {\n const native = native_prerender_fn(\n () =>\n run_remote_effect(\n (validate_or_fn as () => Effect.Effect<unknown, unknown, unknown>)(),\n ),\n fn_or_options as RemotePrerenderOptions<void> | undefined,\n );\n\n return create_native_wrapper(native);\n }\n\n const resolved = resolve_remote_args(\n validate_or_fn,\n fn_or_options as\n | ((arg: unknown) => Effect.Effect<unknown, unknown, unknown>)\n | undefined,\n );\n const native = resolved.validate === \"unchecked\"\n ? native_prerender_fn(\n \"unchecked\",\n (arg: unknown) =>\n run_remote_effect(\n (resolved.fn as (\n arg: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>)(arg),\n ),\n maybe_options as RemotePrerenderOptions<unknown> | undefined,\n )\n : native_prerender_fn(\n get_effect_schema_validator(resolved.validate as EffectSchema),\n (arg: unknown) =>\n run_remote_effect(\n (resolved.fn as (\n arg: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>)(arg),\n ),\n maybe_options as RemotePrerenderOptions<unknown> | undefined,\n );\n\n return create_native_wrapper(native);\n};\n\n/**\n * Define a prerenderable remote function backed by an Effect program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/prerender\n */\nexport const Prerender = prerender_impl as unknown as EffectPrerenderFactory;\n"],"x_google_ignoreList":[0,1,2],"mappings":";;;;;;;AAaA,IAAa,eAAb,cAAkC,MAAM;;;;;;;CAOvC,YAAY,SAAS,MAAM,OAAO,MAAM;AACvC,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO,KAAK,KAAK,GAAG;AACzB,OAAK,QAAQ;AACb,OAAK,OAAO;;;;AAKd,SAAgB,aAAa,OAAO;AACnC,QAAO,OAAO,MAAM,KAAK;;AAG1B,MAAM,qBAAqC,uBAAO,oBACjD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tC,MAAa,OAAO;AA+CpB,MAAM,sBAAsBC;AAE5B,MAAM,kBACJ,gBACA,eACA,kBACY;AACZ,KACE,OAAO,mBAAmB,cAC1B,OAAO,kBAAkB,WAUzB,QAAO,sBARQ,0BAEX,kBACG,gBAAmE,CACrE,EACH,cACD,CAEmC;CAGtC,MAAM,WAAW,oBACf,gBACA,cAGD;AAuBD,QAAO,sBAtBQ,SAAS,aAAa,cACjC,oBACA,cACC,QACC,kBACG,SAAS,GAEqC,IAAI,CACpD,EACH,cACD,GACC,oBACA,4BAA4B,SAAS,SAAyB,GAC7D,QACC,kBACG,SAAS,GAEqC,IAAI,CACpD,EACH,cACD,CAEiC;;;;;;;AAQtC,MAAa,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./client-DkW4e4dD.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./client-DkW4e4dD.js";
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { t as effect_preprocess } from "./preprocess-CtLrnJcK.js";
|
|
2
|
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
//#region v3/vite.ts
|
|
8
|
+
/**
|
|
9
|
+
* Low-level Vite integration entrypoints for `svelte-effect-runtime`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { svelte_effect_runtime } from "svelte-effect-runtime/vite";
|
|
14
|
+
*
|
|
15
|
+
* export default {
|
|
16
|
+
* plugins: [svelte_effect_runtime()],
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
const SERVER_RUNTIME_PACKAGE_IDS = new Map([
|
|
23
|
+
["svelte-effect-runtime", "svelte-effect-runtime/_server"],
|
|
24
|
+
["svelte-effect-runtime/v3", "svelte-effect-runtime/v3/_server"],
|
|
25
|
+
["svelte-effect-runtime/v4", "svelte-effect-runtime/v4/_server"]
|
|
26
|
+
]);
|
|
27
|
+
const SERVER_SOURCE_PATTERN = /(?:^|\/)(?:hooks\.server\.[cm]?[jt]s|.+\.server\.[cm]?[jt]s|.+\.remote\.[cm]?[jt]s)$/;
|
|
28
|
+
function arrayify(value) {
|
|
29
|
+
if (value === void 0) return [];
|
|
30
|
+
return Array.isArray(value) ? value : [value];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Low-level Vite plugin wrapper for non-SvelteKit builds that only need the
|
|
34
|
+
* Svelte preprocessor integration.
|
|
35
|
+
*
|
|
36
|
+
* @see https://ser.barekey.dev/content/reference/tooling
|
|
37
|
+
*/
|
|
38
|
+
function svelte_effect_runtime(options = {}) {
|
|
39
|
+
const existingPreprocessors = arrayify(options.svelte?.preprocess);
|
|
40
|
+
return svelte({
|
|
41
|
+
...options.svelte,
|
|
42
|
+
preprocess: [effect_preprocess(options.effect), ...existingPreprocessors]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function resolve_runtime_internal_path(source_relative_path, dist_relative_path) {
|
|
46
|
+
const relative_path = import.meta.url.endsWith(".ts") ? source_relative_path : dist_relative_path;
|
|
47
|
+
return fileURLToPath(new URL(relative_path, import.meta.url));
|
|
48
|
+
}
|
|
49
|
+
function resolve_kit_internal_runtime_path(relative_path) {
|
|
50
|
+
return pathToFileURL(resolve(dirname(createRequire(resolve(process.cwd(), "package.json")).resolve("@sveltejs/kit/package.json")), relative_path)).href;
|
|
51
|
+
}
|
|
52
|
+
function create_remote_runtime_module_code() {
|
|
53
|
+
const adapter_module_path = resolve_runtime_internal_path("../internal/remote-client.ts", "../internal/remote-client.js");
|
|
54
|
+
const kit_query_module_path = resolve_kit_internal_runtime_path("src/runtime/client/remote-functions/query.svelte.js");
|
|
55
|
+
const kit_command_module_path = resolve_kit_internal_runtime_path("src/runtime/client/remote-functions/command.svelte.js");
|
|
56
|
+
const kit_form_module_path = resolve_kit_internal_runtime_path("src/runtime/client/remote-functions/form.svelte.js");
|
|
57
|
+
const kit_prerender_module_path = resolve_kit_internal_runtime_path("src/runtime/client/remote-functions/prerender.svelte.js");
|
|
58
|
+
const kit_shared_module_path = resolve_kit_internal_runtime_path("src/runtime/client/remote-functions/shared.svelte.js");
|
|
59
|
+
const kit_client_module_path = resolve_kit_internal_runtime_path("src/runtime/client/client.js");
|
|
60
|
+
const kit_form_utils_module_path = resolve_kit_internal_runtime_path("src/runtime/form-utils.js");
|
|
61
|
+
const kit_shared_runtime_module_path = resolve_kit_internal_runtime_path("src/runtime/shared.js");
|
|
62
|
+
return `
|
|
63
|
+
import * as devalue from "devalue";
|
|
64
|
+
import { base, app_dir } from "$app/paths/internal/client";
|
|
65
|
+
import { query as native_query, query_batch as native_query_batch } from ${JSON.stringify(kit_query_module_path)};
|
|
66
|
+
import { command as native_command } from ${JSON.stringify(kit_command_module_path)};
|
|
67
|
+
import { form as native_form } from ${JSON.stringify(kit_form_module_path)};
|
|
68
|
+
import { prerender as native_prerender } from ${JSON.stringify(kit_prerender_module_path)};
|
|
69
|
+
import {
|
|
70
|
+
apply_refreshes,
|
|
71
|
+
get_remote_request_headers,
|
|
72
|
+
remote_request
|
|
73
|
+
} from ${JSON.stringify(kit_shared_module_path)};
|
|
74
|
+
import { app, invalidateAll, _goto } from ${JSON.stringify(kit_client_module_path)};
|
|
75
|
+
import { BINARY_FORM_CONTENT_TYPE, serialize_binary_form } from ${JSON.stringify(kit_form_utils_module_path)};
|
|
76
|
+
import { stringify_remote_arg } from ${JSON.stringify(kit_shared_runtime_module_path)};
|
|
77
|
+
import {
|
|
78
|
+
create_remote_command_adapter,
|
|
79
|
+
create_remote_form_adapter,
|
|
80
|
+
create_remote_query_adapter
|
|
81
|
+
} from ${JSON.stringify(adapter_module_path)};
|
|
82
|
+
|
|
83
|
+
const decode_payload = (encoded) => devalue.parse(encoded, app?.decoders ?? {});
|
|
84
|
+
const request_dependencies = {
|
|
85
|
+
app,
|
|
86
|
+
app_dir,
|
|
87
|
+
apply_refreshes,
|
|
88
|
+
base,
|
|
89
|
+
get_remote_request_headers,
|
|
90
|
+
remote_request,
|
|
91
|
+
stringify_remote_arg
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const query = create_remote_query_adapter(native_query, decode_payload, request_dependencies, "query");
|
|
95
|
+
export const query_batch = create_remote_query_adapter(native_query_batch, decode_payload, request_dependencies, "query_batch");
|
|
96
|
+
export const command = create_remote_command_adapter(native_command, decode_payload, request_dependencies);
|
|
97
|
+
export const prerender = create_remote_query_adapter(native_prerender, decode_payload, request_dependencies, "prerender");
|
|
98
|
+
export const form = create_remote_form_adapter(native_form, decode_payload, {
|
|
99
|
+
binary_form_content_type: BINARY_FORM_CONTENT_TYPE,
|
|
100
|
+
goto: _goto,
|
|
101
|
+
invalidate_all: invalidateAll,
|
|
102
|
+
serialize_binary_form,
|
|
103
|
+
...request_dependencies
|
|
104
|
+
});
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Low-level Vite plugin that swaps SvelteKit's generated remote client module
|
|
109
|
+
* for the Effect-aware adapters used by `effect()`.
|
|
110
|
+
*
|
|
111
|
+
* Prefer `effect()` unless you are assembling a custom Vite plugin stack.
|
|
112
|
+
*
|
|
113
|
+
* @see https://ser.barekey.dev/content/reference/tooling
|
|
114
|
+
*/
|
|
115
|
+
function sveltekit_effect_runtime(options = {}) {
|
|
116
|
+
const remote_module_id = options.remoteModuleId ?? "\0svelte-effect-runtime:remote";
|
|
117
|
+
return {
|
|
118
|
+
name: "svelte-effect-runtime-remote",
|
|
119
|
+
enforce: "pre",
|
|
120
|
+
resolveId(id) {
|
|
121
|
+
if (id === "__sveltekit/remote") return remote_module_id;
|
|
122
|
+
},
|
|
123
|
+
load(id) {
|
|
124
|
+
if (id !== remote_module_id) return;
|
|
125
|
+
return create_remote_runtime_module_code();
|
|
126
|
+
},
|
|
127
|
+
transform(code, id) {
|
|
128
|
+
const filename = id.split("?", 1)[0];
|
|
129
|
+
if (!SERVER_SOURCE_PATTERN.test(filename)) return null;
|
|
130
|
+
let transformed = code;
|
|
131
|
+
for (const [client_package_id, server_package_id] of SERVER_RUNTIME_PACKAGE_IDS) {
|
|
132
|
+
transformed = transformed.replaceAll(`"${client_package_id}"`, `"${server_package_id}"`);
|
|
133
|
+
transformed = transformed.replaceAll(`'${client_package_id}'`, `'${server_package_id}'`);
|
|
134
|
+
}
|
|
135
|
+
if (transformed === code) return null;
|
|
136
|
+
return transformed;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
export { sveltekit_effect_runtime as n, svelte_effect_runtime as t };
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=vite-DqjXRZd4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-DqjXRZd4.js","names":[],"sources":["../../../modules/svelte-effect-runtime/v3/vite.ts"],"sourcesContent":["/**\n * Low-level Vite integration entrypoints for `svelte-effect-runtime`.\n *\n * @example\n * ```ts\n * import { svelte_effect_runtime } from \"svelte-effect-runtime/vite\";\n *\n * export default {\n * plugins: [svelte_effect_runtime()],\n * };\n * ```\n *\n * @module\n */\nimport {\n type Options as SveltePluginOptions,\n svelte,\n} from \"@sveltejs/vite-plugin-svelte\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\nimport process from \"node:process\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport type { Plugin } from \"vite\";\nimport {\n effect_preprocess,\n type EffectPreprocessOptions,\n} from \"$/v3/preprocess.ts\";\n\n/** Options for the plain Vite + Svelte preprocess wrapper. */\nexport interface SvelteEffectRuntimeOptions {\n effect?: EffectPreprocessOptions;\n svelte?: SveltePluginOptions;\n}\n\n/** Options for the SvelteKit remote-function adapter plugin. */\nexport interface SveltekitEffectRuntimeOptions {\n /**\n * Override the client-side module SvelteKit uses for generated `.remote.ts`\n * imports so remote calls default to Effect-returning adapters.\n */\n remoteModuleId?: string;\n}\n\nconst SERVER_RUNTIME_PACKAGE_IDS = new Map([\n [\"svelte-effect-runtime\", \"svelte-effect-runtime/_server\"],\n [\"svelte-effect-runtime/v3\", \"svelte-effect-runtime/v3/_server\"],\n [\"svelte-effect-runtime/v4\", \"svelte-effect-runtime/v4/_server\"],\n]);\nconst SERVER_SOURCE_PATTERN =\n /(?:^|\\/)(?:hooks\\.server\\.[cm]?[jt]s|.+\\.server\\.[cm]?[jt]s|.+\\.remote\\.[cm]?[jt]s)$/;\n\nfunction arrayify<T>(value: T | T[] | undefined): T[] {\n if (value === undefined) {\n return [];\n }\n\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Low-level Vite plugin wrapper for non-SvelteKit builds that only need the\n * Svelte preprocessor integration.\n *\n * @see https://ser.barekey.dev/content/reference/tooling\n */\nexport function svelte_effect_runtime(\n options: SvelteEffectRuntimeOptions = {},\n): Plugin[] {\n const existingPreprocessors = arrayify(options.svelte?.preprocess);\n\n return svelte({\n ...options.svelte,\n preprocess: [\n effect_preprocess(options.effect),\n ...existingPreprocessors,\n ],\n });\n}\n\nfunction resolve_runtime_internal_path(\n source_relative_path: string,\n dist_relative_path: string,\n): string {\n const relative_path = import.meta.url.endsWith(\".ts\")\n ? source_relative_path\n : dist_relative_path;\n\n return fileURLToPath(new URL(relative_path, import.meta.url));\n}\n\nfunction resolve_kit_internal_runtime_path(relative_path: string): string {\n const runtime_require = createRequire(resolve(process.cwd(), \"package.json\"));\n const kit_package_path = runtime_require.resolve(\n \"@sveltejs/kit/package.json\",\n );\n const kit_root = dirname(kit_package_path);\n\n return pathToFileURL(resolve(kit_root, relative_path)).href;\n}\n\nfunction create_remote_runtime_module_code(): string {\n const adapter_module_path = resolve_runtime_internal_path(\n \"../internal/remote-client.ts\",\n \"../internal/remote-client.js\",\n );\n const kit_query_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/remote-functions/query.svelte.js\",\n );\n const kit_command_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/remote-functions/command.svelte.js\",\n );\n const kit_form_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/remote-functions/form.svelte.js\",\n );\n const kit_prerender_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/remote-functions/prerender.svelte.js\",\n );\n const kit_shared_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/remote-functions/shared.svelte.js\",\n );\n const kit_client_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/client/client.js\",\n );\n const kit_form_utils_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/form-utils.js\",\n );\n const kit_shared_runtime_module_path = resolve_kit_internal_runtime_path(\n \"src/runtime/shared.js\",\n );\n\n return `\nimport * as devalue from \"devalue\";\nimport { base, app_dir } from \"$app/paths/internal/client\";\nimport { query as native_query, query_batch as native_query_batch } from ${\n JSON.stringify(kit_query_module_path)\n };\nimport { command as native_command } from ${\n JSON.stringify(kit_command_module_path)\n };\nimport { form as native_form } from ${JSON.stringify(kit_form_module_path)};\nimport { prerender as native_prerender } from ${\n JSON.stringify(kit_prerender_module_path)\n };\nimport {\n apply_refreshes,\n get_remote_request_headers,\n remote_request\n} from ${JSON.stringify(kit_shared_module_path)};\nimport { app, invalidateAll, _goto } from ${\n JSON.stringify(kit_client_module_path)\n };\nimport { BINARY_FORM_CONTENT_TYPE, serialize_binary_form } from ${\n JSON.stringify(kit_form_utils_module_path)\n };\nimport { stringify_remote_arg } from ${\n JSON.stringify(kit_shared_runtime_module_path)\n };\nimport {\n create_remote_command_adapter,\n create_remote_form_adapter,\n create_remote_query_adapter\n} from ${JSON.stringify(adapter_module_path)};\n\nconst decode_payload = (encoded) => devalue.parse(encoded, app?.decoders ?? {});\nconst request_dependencies = {\n app,\n app_dir,\n apply_refreshes,\n base,\n get_remote_request_headers,\n remote_request,\n stringify_remote_arg\n};\n\nexport const query = create_remote_query_adapter(native_query, decode_payload, request_dependencies, \"query\");\nexport const query_batch = create_remote_query_adapter(native_query_batch, decode_payload, request_dependencies, \"query_batch\");\nexport const command = create_remote_command_adapter(native_command, decode_payload, request_dependencies);\nexport const prerender = create_remote_query_adapter(native_prerender, decode_payload, request_dependencies, \"prerender\");\nexport const form = create_remote_form_adapter(native_form, decode_payload, {\n binary_form_content_type: BINARY_FORM_CONTENT_TYPE,\n goto: _goto,\n invalidate_all: invalidateAll,\n serialize_binary_form,\n ...request_dependencies\n});\n`;\n}\n\n/**\n * Low-level Vite plugin that swaps SvelteKit's generated remote client module\n * for the Effect-aware adapters used by `effect()`.\n *\n * Prefer `effect()` unless you are assembling a custom Vite plugin stack.\n *\n * @see https://ser.barekey.dev/content/reference/tooling\n */\nexport function sveltekit_effect_runtime(\n options: SveltekitEffectRuntimeOptions = {},\n): Plugin {\n const remote_module_id = options.remoteModuleId ??\n \"\\0svelte-effect-runtime:remote\";\n\n return {\n name: \"svelte-effect-runtime-remote\",\n enforce: \"pre\",\n resolveId(id) {\n if (id === \"__sveltekit/remote\") {\n return remote_module_id;\n }\n },\n load(id) {\n if (id !== remote_module_id) {\n return;\n }\n\n return create_remote_runtime_module_code();\n },\n transform(code, id) {\n const filename = id.split(\"?\", 1)[0];\n if (!SERVER_SOURCE_PATTERN.test(filename)) {\n return null;\n }\n\n let transformed = code;\n\n for (\n const [client_package_id, server_package_id]\n of SERVER_RUNTIME_PACKAGE_IDS\n ) {\n transformed = transformed.replaceAll(\n `\"${client_package_id}\"`,\n `\"${server_package_id}\"`,\n );\n transformed = transformed.replaceAll(\n `'${client_package_id}'`,\n `'${server_package_id}'`,\n );\n }\n\n if (transformed === code) {\n return null;\n }\n\n return transformed;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,6BAA6B,IAAI,IAAI;CACzC,CAAC,yBAAyB,gCAAgC;CAC1D,CAAC,4BAA4B,mCAAmC;C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BAAuB,CACvC;kEAEC,KAAK,UAAU,2BAA2B,CAC3C;uCAEC,KAAK,UAAU,+BAA+B,CAC/C;;;;;SAKM,KAAK,UAAU,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmC7C,SAAgB,yBACd,UAAyC,EAAE,EACnC;CACR,MAAM,mBAAmB,QAAQ,kBAC/B;AAEF,QAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,IAAI;AACZ,OAAI,OAAO,qBACT,QAAO;;EAGX,KAAK,IAAI;AACP,OAAI,OAAO,iBACT;AAGF,UAAO,mCAAmC;;EAE5C,UAAU,MAAM,IAAI;GAClB,MAAM,WAAW,GAAG,MAAM,KAAK,EAAE,CAAC;AAClC,OAAI,CAAC,sBAAsB,KAAK,SAAS,CACvC,QAAO;GAGT,IAAI,cAAc;AAElB,QACE,MAAM,CAAC,mBAAmB,sBACrB,4BACL;AACA,kBAAc,YAAY,WAC1B,IAAI,kBAAkB,IACtB,IAAI,kBAAkB,GACrB;AACD,kBAAc,YAAY,WAC1B,IAAI,kBAAkB,IACtB,IAAI,kBAAkB,GACrB;;AAGH,OAAI,gBAAgB,KAClB,QAAO;AAGT,UAAO;;EAEV"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,64 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
4
|
-
import * as ManagedRuntime from "effect/ManagedRuntime";
|
|
5
|
-
import * as Exit from "effect/Exit";
|
|
6
|
-
import { type RemoteFailure } from "./internal/remote-shared.ts";
|
|
7
|
-
export interface ProvideEffectRuntimeOptions {
|
|
8
|
-
disposeOnDestroy?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface ImportMetaLike {
|
|
11
|
-
hot?: {
|
|
12
|
-
dispose(callback: () => void): void;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export interface EffectRuntime<R = unknown> {
|
|
16
|
-
runCallback<A, E, R2>(effect: Effect.Effect<A, E, R2>, options?: {
|
|
17
|
-
onExit?: (exit: Exit.Exit<A, E>) => void;
|
|
18
|
-
}): () => void;
|
|
19
|
-
runPromise<A, E, R2>(effect: Effect.Effect<A, E, R2>): Promise<A>;
|
|
20
|
-
dispose(): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
export type { FormError, FormIssue, RemoteDomainError, RemoteFailure, RemoteHttpError, RemoteTransportError, RemoteValidationError, } from "./internal/remote-shared.ts";
|
|
23
|
-
export interface ClientRuntimeService extends EffectRuntime<unknown> {
|
|
24
|
-
}
|
|
25
|
-
export declare const ClientRuntimeTag: Context.Tag<ClientRuntimeService, ClientRuntimeService>;
|
|
26
|
-
type RuntimeSeedLayer<R> = Layer.Layer<R, never, R>;
|
|
27
|
-
type RuntimeOperator = (self: Layer.Layer<unknown, unknown, unknown>) => Layer.Layer<unknown, unknown, unknown>;
|
|
28
|
-
type ProvidedBy<Op> = Op extends (self: RuntimeSeedLayer<infer R>) => Layer.Layer<unknown, unknown, infer RIn> ? Exclude<R, RIn> : never;
|
|
29
|
-
type ProvidedByAll<Ops extends ReadonlyArray<RuntimeOperator>> = Ops extends readonly [infer Head, ...infer Tail] ? ProvidedBy<Head> | ProvidedByAll<Extract<Tail, ReadonlyArray<RuntimeOperator>>> : never;
|
|
30
|
-
type ApplyOperator<Seed, Op> = Op extends (self: Seed) => infer Out ? Out : never;
|
|
31
|
-
type ApplyOperators<Seed, Ops extends ReadonlyArray<RuntimeOperator>> = Ops extends readonly [infer Head, ...infer Tail] ? ApplyOperators<ApplyOperator<Seed, Head>, Extract<Tail, ReadonlyArray<RuntimeOperator>>> : Seed;
|
|
32
|
-
type FinalRuntimeLayer<Ops extends ReadonlyArray<RuntimeOperator>> = ApplyOperators<RuntimeSeedLayer<ProvidedByAll<Ops>>, Ops> extends infer Out ? Out extends Layer.Layer<unknown, unknown, infer RIn> ? [RIn] extends [never] ? Out : never : never : never;
|
|
33
|
-
interface ClientRuntimeSeed {
|
|
34
|
-
pipe(): Layer.Layer<never>;
|
|
35
|
-
pipe<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(...ops: Ops): FinalRuntimeLayer<Ops>;
|
|
36
|
-
make(): ManagedRuntime.ManagedRuntime<never, never>;
|
|
37
|
-
make<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(...ops: Ops): ManagedRuntimeFromOps<Ops>;
|
|
38
|
-
}
|
|
39
|
-
type ManagedRuntimeFromOps<Ops extends ReadonlyArray<RuntimeOperator>> = ManagedRuntime.ManagedRuntime<Layer.Layer.Success<FinalRuntimeLayer<Ops>>, Layer.Layer.Error<FinalRuntimeLayer<Ops>>>;
|
|
40
|
-
/**
|
|
41
|
-
* A pass-through layer representing the dependency graph you want to include
|
|
42
|
-
* in the client ManagedRuntime. Users can compose this directly:
|
|
43
|
-
*
|
|
44
|
-
* ManagedRuntime.make(
|
|
45
|
-
* ClientRuntime.pipe(
|
|
46
|
-
* Layer.provide(MyApi.Live),
|
|
47
|
-
* Layer.provide(Logger.Live),
|
|
48
|
-
* ),
|
|
49
|
-
* )
|
|
50
|
-
*/
|
|
51
|
-
export declare const ClientRuntime: ClientRuntimeSeed;
|
|
52
|
-
export declare function provideEffectRuntime<T extends EffectRuntime>(runtime: T, options?: ProvideEffectRuntimeOptions): T;
|
|
53
|
-
export declare function getEffectRuntimeOrThrow<T extends EffectRuntime = EffectRuntime<never>>(): T;
|
|
54
|
-
export declare function runComponentEffect<A, E, R>(runtime: EffectRuntime<R>, program: Effect.Effect<A, E, R>): () => void;
|
|
55
|
-
export declare function runInlineEffect<A, E, R>(runtime: EffectRuntime<R>, program: Effect.Effect<A, E, R>): Promise<A>;
|
|
56
|
-
export declare function registerHotDispose(meta: ImportMetaLike, cleanup: () => void): void;
|
|
57
|
-
declare function is_redirect_like(value: unknown): boolean;
|
|
58
|
-
declare function create_remote_effect_from_promise<Success, ErrorType = never>(create_promise: () => PromiseLike<Success>, decode_error?: (error: unknown) => RemoteFailure<ErrorType>): Effect.Effect<Success, RemoteFailure<ErrorType>, never>;
|
|
59
|
-
export declare function to_effect<Success, ErrorType = never>(promise_like: PromiseLike<Success>): Effect.Effect<Success, RemoteFailure<ErrorType>, never>;
|
|
60
|
-
export declare function to_effect<Args extends Array<unknown>, Success, ErrorType = never>(fn: (...args: Args) => PromiseLike<Success>): (...args: Args) => Effect.Effect<Success, RemoteFailure<ErrorType>, never>;
|
|
61
|
-
export declare function to_native<Value>(value: Value): Value extends {
|
|
62
|
-
native: infer Native;
|
|
63
|
-
} ? Native : Value;
|
|
64
|
-
export { create_remote_effect_from_promise, is_redirect_like };
|
|
1
|
+
export * from "./v3/client.js";
|
package/dist/client.js
CHANGED
|
@@ -1,170 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import * as Effect from "effect/Effect";
|
|
4
|
-
import * as Layer from "effect/Layer";
|
|
5
|
-
import * as ManagedRuntime from "effect/ManagedRuntime";
|
|
6
|
-
import * as Cause from "effect/Cause";
|
|
7
|
-
import * as Exit from "effect/Exit";
|
|
8
|
-
import { getContext, hasContext, onDestroy, setContext } from "svelte";
|
|
9
|
-
//#region client.ts
|
|
10
|
-
const EFFECT_RUNTIME_CONTEXT = Symbol.for("svelte-effect-runtime/runtime");
|
|
11
|
-
let current_client_runtime = null;
|
|
12
|
-
const ClientRuntimeTag = Context.GenericTag("svelte-effect-runtime/ClientRuntime");
|
|
13
|
-
function runtimeSeed() {
|
|
14
|
-
return Layer.effectContext(Effect.context());
|
|
15
|
-
}
|
|
16
|
-
function pipeClientRuntime(...ops) {
|
|
17
|
-
if (ops.length === 0) return Layer.empty;
|
|
18
|
-
return ops.reduce((layer, op) => op(layer), runtimeSeed());
|
|
19
|
-
}
|
|
20
|
-
function makeClientRuntime(...ops) {
|
|
21
|
-
const layer = ops.length === 0 ? pipeClientRuntime() : pipeClientRuntime(...ops);
|
|
22
|
-
const runtime = track_client_runtime(ManagedRuntime.make(layer));
|
|
23
|
-
current_client_runtime?.dispose().catch(() => void 0);
|
|
24
|
-
current_client_runtime = runtime;
|
|
25
|
-
if (is_component_context_available()) return provideEffectRuntime(runtime, { disposeOnDestroy: true });
|
|
26
|
-
return runtime;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* A pass-through layer representing the dependency graph you want to include
|
|
30
|
-
* in the client ManagedRuntime. Users can compose this directly:
|
|
31
|
-
*
|
|
32
|
-
* ManagedRuntime.make(
|
|
33
|
-
* ClientRuntime.pipe(
|
|
34
|
-
* Layer.provide(MyApi.Live),
|
|
35
|
-
* Layer.provide(Logger.Live),
|
|
36
|
-
* ),
|
|
37
|
-
* )
|
|
38
|
-
*/
|
|
39
|
-
const ClientRuntime = {
|
|
40
|
-
pipe: pipeClientRuntime,
|
|
41
|
-
make: makeClientRuntime
|
|
42
|
-
};
|
|
43
|
-
function provideEffectRuntime(runtime, options = {}) {
|
|
44
|
-
current_client_runtime = track_client_runtime(runtime);
|
|
45
|
-
setContext(EFFECT_RUNTIME_CONTEXT, runtime);
|
|
46
|
-
if (options.disposeOnDestroy) onDestroy(() => {
|
|
47
|
-
runtime.dispose();
|
|
48
|
-
});
|
|
49
|
-
return runtime;
|
|
50
|
-
}
|
|
51
|
-
function getEffectRuntimeOrThrow() {
|
|
52
|
-
if (has_runtime_context()) return getContext(EFFECT_RUNTIME_CONTEXT);
|
|
53
|
-
if (current_client_runtime !== null) return current_client_runtime;
|
|
54
|
-
const default_runtime = track_client_runtime(ManagedRuntime.make(Layer.empty));
|
|
55
|
-
current_client_runtime = default_runtime;
|
|
56
|
-
return default_runtime;
|
|
57
|
-
}
|
|
58
|
-
function runComponentEffect(runtime, program) {
|
|
59
|
-
let disposed = false;
|
|
60
|
-
const cancel = runtime.runCallback(program, { onExit(exit) {
|
|
61
|
-
if (Exit.isFailure(exit) && !Exit.isInterrupted(exit)) queueMicrotask(() => {
|
|
62
|
-
throw Cause.squash(exit.cause);
|
|
63
|
-
});
|
|
64
|
-
} });
|
|
65
|
-
return () => {
|
|
66
|
-
if (disposed) return;
|
|
67
|
-
disposed = true;
|
|
68
|
-
cancel();
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function runInlineEffect(runtime, program) {
|
|
72
|
-
console.log("[svelte-effect-runtime][client]", "runInlineEffect:start");
|
|
73
|
-
return runtime.runPromise(program).catch((error) => {
|
|
74
|
-
console.error("[svelte-effect-runtime][client]", "runInlineEffect:error", { error });
|
|
75
|
-
queueMicrotask(() => {
|
|
76
|
-
throw error;
|
|
77
|
-
});
|
|
78
|
-
throw error;
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
function registerHotDispose(meta, cleanup) {
|
|
82
|
-
meta.hot?.dispose(cleanup);
|
|
83
|
-
}
|
|
84
|
-
function has_runtime_context() {
|
|
85
|
-
try {
|
|
86
|
-
return hasContext(EFFECT_RUNTIME_CONTEXT);
|
|
87
|
-
} catch {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function is_component_context_available() {
|
|
92
|
-
try {
|
|
93
|
-
hasContext(EFFECT_RUNTIME_CONTEXT);
|
|
94
|
-
return true;
|
|
95
|
-
} catch {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function track_client_runtime(runtime) {
|
|
100
|
-
const tracked_runtime = runtime;
|
|
101
|
-
if (tracked_runtime.__ser_tracked__ === true) return tracked_runtime;
|
|
102
|
-
const dispose = runtime.dispose.bind(runtime);
|
|
103
|
-
tracked_runtime.__ser_tracked__ = true;
|
|
104
|
-
runtime.dispose = (() => {
|
|
105
|
-
if (current_client_runtime === tracked_runtime) current_client_runtime = null;
|
|
106
|
-
return dispose();
|
|
107
|
-
});
|
|
108
|
-
return tracked_runtime;
|
|
109
|
-
}
|
|
110
|
-
function is_redirect_like(value) {
|
|
111
|
-
return Boolean(value && typeof value === "object" && typeof value.location === "string" && typeof value.status === "number");
|
|
112
|
-
}
|
|
113
|
-
function is_http_error_like(value) {
|
|
114
|
-
return Boolean(value && typeof value === "object" && typeof value.status === "number");
|
|
115
|
-
}
|
|
116
|
-
function get_error_status(value) {
|
|
117
|
-
return is_http_error_like(value) ? value.status ?? 500 : 500;
|
|
118
|
-
}
|
|
119
|
-
function get_remote_error_decoder(value) {
|
|
120
|
-
if (value && (typeof value === "object" || typeof value === "function") && REMOTE_ERROR_DECODER in value) return value[REMOTE_ERROR_DECODER];
|
|
121
|
-
}
|
|
122
|
-
function decode_remote_error(error, decode_payload) {
|
|
123
|
-
if (is_http_error_like(error)) {
|
|
124
|
-
const body = error.body;
|
|
125
|
-
if (is_serialized_remote_failure_envelope(body) && decode_payload) try {
|
|
126
|
-
return create_remote_domain_error(decode_payload(body.encoded), get_error_status(error));
|
|
127
|
-
} catch (cause) {
|
|
128
|
-
return create_remote_transport_error(cause, body);
|
|
129
|
-
}
|
|
130
|
-
if (get_error_status(error) === 400) return create_remote_validation_error([], {
|
|
131
|
-
body,
|
|
132
|
-
status: 400
|
|
133
|
-
});
|
|
134
|
-
return create_remote_http_error(error, {
|
|
135
|
-
body,
|
|
136
|
-
status: get_error_status(error)
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return create_remote_http_error(error);
|
|
140
|
-
}
|
|
141
|
-
function create_remote_effect_from_promise(create_promise, decode_error = (error) => create_remote_http_error(error)) {
|
|
142
|
-
return Effect.async((resume) => {
|
|
143
|
-
Promise.resolve().then(create_promise).then((value) => resume(Effect.succeed(value)), (error) => {
|
|
144
|
-
if (is_redirect_like(error)) {
|
|
145
|
-
resume(Effect.die(error));
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
resume(Effect.fail(decode_error(error)));
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
function to_effect(value) {
|
|
153
|
-
const decode_payload = get_remote_error_decoder(value);
|
|
154
|
-
if (typeof value === "function") return ((...args) => create_remote_effect_from_promise(() => Promise.resolve(value(...args)), (error) => decode_remote_error(error, decode_payload)));
|
|
155
|
-
return create_remote_effect_from_promise(() => value, (error) => decode_remote_error(error, decode_payload));
|
|
156
|
-
}
|
|
157
|
-
function to_native(value) {
|
|
158
|
-
let current = value;
|
|
159
|
-
const seen = /* @__PURE__ */ new Set();
|
|
160
|
-
while (current && (typeof current === "object" || typeof current === "function") && "native" in current) {
|
|
161
|
-
if (seen.has(current)) break;
|
|
162
|
-
seen.add(current);
|
|
163
|
-
current = current.native;
|
|
164
|
-
}
|
|
165
|
-
return current;
|
|
166
|
-
}
|
|
167
|
-
//#endregion
|
|
168
|
-
export { ClientRuntime, ClientRuntimeTag, create_remote_effect_from_promise, getEffectRuntimeOrThrow, is_redirect_like, provideEffectRuntime, registerHotDispose, runComponentEffect, runInlineEffect, to_effect, to_native };
|
|
169
|
-
|
|
170
|
-
//# sourceMappingURL=client.js.map
|
|
1
|
+
import { a as run_component_effect, c as to_native, i as is_redirect_like, n as create_remote_effect_from_promise, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "./chunks/client-DkW4e4dD.js";
|
|
2
|
+
export { ClientRuntime, create_remote_effect_from_promise, get_effect_runtime_or_throw, is_redirect_like, run_component_effect, run_inline_effect, to_effect, to_native };
|
package/dist/effect.d.ts
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { type EffectPreprocessOptions } from "./preprocess.ts";
|
|
3
|
-
export interface EffectPluginOptions {
|
|
4
|
-
effect?: EffectPreprocessOptions;
|
|
5
|
-
remoteModuleId?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function effect(options?: EffectPluginOptions): PluginOption[];
|
|
1
|
+
export * from "./v3/effect.js";
|
package/dist/effect.js
CHANGED
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { sveltekitEffectRuntime } from "./vite.js";
|
|
3
|
-
import { preprocess } from "svelte/compiler";
|
|
4
|
-
//#region effect.ts
|
|
5
|
-
function create_effect_svelte_transform(options = {}) {
|
|
6
|
-
const preprocessor = effectPreprocess(options);
|
|
7
|
-
return {
|
|
8
|
-
name: "svelte-effect-runtime-transform",
|
|
9
|
-
enforce: "pre",
|
|
10
|
-
async transform(code, id, _options) {
|
|
11
|
-
const filename = id.split("?", 1)[0];
|
|
12
|
-
if (!filename.endsWith(".svelte")) return null;
|
|
13
|
-
const transformed = await preprocess(code, preprocessor, { filename });
|
|
14
|
-
if (transformed.code === code) return null;
|
|
15
|
-
return {
|
|
16
|
-
code: transformed.code,
|
|
17
|
-
...transformed.map ? { map: transformed.map } : {}
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function effect(options = {}) {
|
|
23
|
-
return [create_effect_svelte_transform(options.effect), sveltekitEffectRuntime({ remoteModuleId: options.remoteModuleId })];
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
1
|
+
import { t as effect } from "./chunks/effect-CL8GJs8A.js";
|
|
26
2
|
export { effect };
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Effect, Exit } from "effect";
|
|
2
|
+
export interface EffectContextKey<Identifier, Service> {
|
|
3
|
+
readonly Identifier: Identifier;
|
|
4
|
+
readonly Service: Service;
|
|
5
|
+
readonly key: string;
|
|
6
|
+
}
|
|
7
|
+
export interface EffectSchemaLike {
|
|
8
|
+
readonly Encoded?: unknown;
|
|
9
|
+
readonly Type?: unknown;
|
|
10
|
+
readonly ast?: unknown;
|
|
11
|
+
readonly fields?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
type EffectResume<A, E, R> = (effect: Effect.Effect<A, E, R>) => void;
|
|
14
|
+
export declare function make_context_key<Identifier, Service = Identifier>(key: string): EffectContextKey<Identifier, Service>;
|
|
15
|
+
export declare function to_standard_schema_v1(schema: EffectSchemaLike): unknown;
|
|
16
|
+
export declare function create_async_effect<A, E = never, R = never>(register: (resume: EffectResume<A, E, R>) => void | Effect.Effect<void, never, R>): Effect.Effect<A, E, R>;
|
|
17
|
+
export declare function get_cause_failure<ErrorType>(cause: unknown): ErrorType | undefined;
|
|
18
|
+
export declare function exit_has_interrupts<A, E>(exit: Exit.Exit<A, E>): boolean;
|
|
19
|
+
export declare function get_effect_schema_field_names(schema: EffectSchemaLike): ReadonlyArray<string>;
|
|
20
|
+
export declare function to_transportable_data(value: unknown, seen?: WeakMap<object, unknown>): unknown;
|
|
21
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SourceMap } from "magic-string";
|
|
2
|
-
import type { EffectPreprocessOptions } from "../preprocess.
|
|
2
|
+
import type { EffectPreprocessOptions } from "../preprocess.js";
|
|
3
3
|
interface TransformEffectMarkupOptions extends EffectPreprocessOptions {
|
|
4
4
|
filename: string;
|
|
5
5
|
}
|
package/dist/internal/markup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as transformEffectMarkup } from "../chunks/markup-
|
|
1
|
+
import { t as transformEffectMarkup } from "../chunks/markup-BpSHnnYD.js";
|
|
2
2
|
export { transformEffectMarkup };
|