screenreader-speech-capture 0.8.2 → 0.9.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.
Files changed (177) hide show
  1. package/README.md +8 -2
  2. package/dist/cli.mjs +984 -278
  3. package/dist/ui/adapter-node.js +1 -1
  4. package/dist/ui/client/ui/_app/immutable/chunks/{CM9WugkD.js → 0YgL1EU2.js} +36 -36
  5. package/dist/ui/client/ui/_app/immutable/chunks/0YgL1EU2.js.br +0 -0
  6. package/dist/ui/client/ui/_app/immutable/chunks/0YgL1EU2.js.gz +0 -0
  7. package/dist/ui/client/ui/_app/immutable/chunks/BYvlzyV8.js +1 -0
  8. package/dist/ui/client/ui/_app/immutable/chunks/BYvlzyV8.js.br +2 -0
  9. package/dist/ui/client/ui/_app/immutable/chunks/BYvlzyV8.js.gz +0 -0
  10. package/dist/ui/client/ui/_app/immutable/chunks/BfvDkxmG.js +3 -0
  11. package/dist/ui/client/ui/_app/immutable/chunks/BfvDkxmG.js.br +0 -0
  12. package/dist/ui/client/ui/_app/immutable/chunks/BfvDkxmG.js.gz +0 -0
  13. package/dist/ui/client/ui/_app/immutable/chunks/CSCPyqWx.js +1 -0
  14. package/dist/ui/client/ui/_app/immutable/chunks/CSCPyqWx.js.br +3 -0
  15. package/dist/ui/client/ui/_app/immutable/chunks/CSCPyqWx.js.gz +0 -0
  16. package/dist/ui/client/ui/_app/immutable/chunks/{Fimt9aTv.js → Cba3ZwaX.js} +11 -11
  17. package/dist/ui/client/ui/_app/immutable/chunks/Cba3ZwaX.js.br +0 -0
  18. package/dist/ui/client/ui/_app/immutable/chunks/Cba3ZwaX.js.gz +0 -0
  19. package/dist/ui/client/ui/_app/immutable/chunks/DErxe_FC.js +3 -0
  20. package/dist/ui/client/ui/_app/immutable/chunks/DErxe_FC.js.br +0 -0
  21. package/dist/ui/client/ui/_app/immutable/chunks/DErxe_FC.js.gz +0 -0
  22. package/dist/ui/client/ui/_app/immutable/chunks/Dqufijaz.js +1 -0
  23. package/dist/ui/client/ui/_app/immutable/chunks/Dqufijaz.js.br +0 -0
  24. package/dist/ui/client/ui/_app/immutable/chunks/Dqufijaz.js.gz +0 -0
  25. package/dist/ui/client/ui/_app/immutable/chunks/WpCriteK.js +1 -0
  26. package/dist/ui/client/ui/_app/immutable/chunks/WpCriteK.js.br +1 -0
  27. package/dist/ui/client/ui/_app/immutable/chunks/WpCriteK.js.gz +0 -0
  28. package/dist/ui/client/ui/_app/immutable/chunks/wbLSPbHY.js +4 -0
  29. package/dist/ui/client/ui/_app/immutable/chunks/wbLSPbHY.js.br +0 -0
  30. package/dist/ui/client/ui/_app/immutable/chunks/wbLSPbHY.js.gz +0 -0
  31. package/dist/ui/client/ui/_app/immutable/entry/app.B6hhDf4F.js +2 -0
  32. package/dist/ui/client/ui/_app/immutable/entry/app.B6hhDf4F.js.br +0 -0
  33. package/dist/ui/client/ui/_app/immutable/entry/app.B6hhDf4F.js.gz +0 -0
  34. package/dist/ui/client/ui/_app/immutable/entry/{start.uodUAHNT.js → start.Dluk7nQO.js} +2 -2
  35. package/dist/ui/client/ui/_app/immutable/entry/start.Dluk7nQO.js.br +0 -0
  36. package/dist/ui/client/ui/_app/immutable/entry/start.Dluk7nQO.js.gz +0 -0
  37. package/dist/ui/client/ui/_app/immutable/nodes/0.D-lhv0Us.js +1 -0
  38. package/dist/ui/client/ui/_app/immutable/nodes/0.D-lhv0Us.js.br +0 -0
  39. package/dist/ui/client/ui/_app/immutable/nodes/0.D-lhv0Us.js.gz +0 -0
  40. package/dist/ui/client/ui/_app/immutable/nodes/1.Cs4GAsCO.js +1 -0
  41. package/dist/ui/client/ui/_app/immutable/nodes/1.Cs4GAsCO.js.br +1 -0
  42. package/dist/ui/client/ui/_app/immutable/nodes/1.Cs4GAsCO.js.gz +0 -0
  43. package/dist/ui/client/ui/_app/immutable/nodes/2.CmuzlN_T.js +52 -0
  44. package/dist/ui/client/ui/_app/immutable/nodes/2.CmuzlN_T.js.br +0 -0
  45. package/dist/ui/client/ui/_app/immutable/nodes/2.CmuzlN_T.js.gz +0 -0
  46. package/dist/ui/client/ui/_app/immutable/nodes/3.DMXXeBbC.js +5 -0
  47. package/dist/ui/client/ui/_app/immutable/nodes/3.DMXXeBbC.js.br +0 -0
  48. package/dist/ui/client/ui/_app/immutable/nodes/3.DMXXeBbC.js.gz +0 -0
  49. package/dist/ui/client/ui/_app/immutable/nodes/{4.DY8qq4Io.js → 4.CMHCNMDn.js} +1 -1
  50. package/dist/ui/client/ui/_app/immutable/nodes/4.CMHCNMDn.js.br +0 -0
  51. package/dist/ui/client/ui/_app/immutable/nodes/4.CMHCNMDn.js.gz +0 -0
  52. package/dist/ui/client/ui/_app/version.json +1 -1
  53. package/dist/ui/client/ui/_app/version.json.br +0 -0
  54. package/dist/ui/client/ui/_app/version.json.gz +0 -0
  55. package/dist/ui/server/.vite/manifest.json +97 -54
  56. package/dist/ui/server/chunks/composition.js +112 -118
  57. package/dist/ui/server/chunks/composition.js.map +1 -1
  58. package/dist/ui/server/chunks/config.js +139 -3
  59. package/dist/ui/server/chunks/config.js.map +1 -1
  60. package/dist/ui/server/chunks/exports.js +19 -204
  61. package/dist/ui/server/chunks/exports.js.map +1 -1
  62. package/dist/ui/server/chunks/functions.js +1 -1
  63. package/dist/ui/server/chunks/icon-button.js +1 -1
  64. package/dist/ui/server/chunks/instance.js +9 -56
  65. package/dist/ui/server/chunks/instance.js.map +1 -1
  66. package/dist/ui/server/chunks/internal.js +55 -4
  67. package/dist/ui/server/chunks/internal.js.map +1 -1
  68. package/dist/ui/server/chunks/outlined-text-field.js +1 -1
  69. package/dist/ui/server/chunks/remote-1j2tn2d.js +4 -0
  70. package/dist/ui/server/chunks/remote.js +1565 -0
  71. package/dist/ui/server/chunks/remote.js.map +1 -0
  72. package/dist/ui/server/chunks/scope.js +13 -0
  73. package/dist/ui/server/chunks/scope.js.map +1 -0
  74. package/dist/ui/server/chunks/server-errors.js +48 -1
  75. package/dist/ui/server/chunks/server-errors.js.map +1 -1
  76. package/dist/ui/server/chunks/server2.js +24 -1
  77. package/dist/ui/server/chunks/server2.js.map +1 -1
  78. package/dist/ui/server/chunks/sessions.js +65 -0
  79. package/dist/ui/server/chunks/sessions.js.map +1 -0
  80. package/dist/ui/server/chunks/sessions.remote.js +56 -0
  81. package/dist/ui/server/chunks/sessions.remote.js.map +1 -0
  82. package/dist/ui/server/chunks/shared-errors.js +214 -0
  83. package/dist/ui/server/chunks/shared-errors.js.map +1 -0
  84. package/dist/ui/server/chunks/src.js +123 -44
  85. package/dist/ui/server/chunks/src.js.map +1 -1
  86. package/dist/ui/server/entries/endpoints/api/config/_server.ts.js +3 -5
  87. package/dist/ui/server/entries/endpoints/api/config/_server.ts.js.map +1 -1
  88. package/dist/ui/server/entries/endpoints/api/markers/_server.ts.js +3 -4
  89. package/dist/ui/server/entries/endpoints/api/markers/_server.ts.js.map +1 -1
  90. package/dist/ui/server/entries/endpoints/api/sessions/_id_id_/_server.ts.js +12 -0
  91. package/dist/ui/server/entries/endpoints/api/sessions/_id_id_/_server.ts.js.map +1 -0
  92. package/dist/ui/server/entries/endpoints/api/sessions/_server.ts.js +4 -9
  93. package/dist/ui/server/entries/endpoints/api/sessions/_server.ts.js.map +1 -1
  94. package/dist/ui/server/entries/endpoints/api/sessions/end/_server.ts.js +2 -3
  95. package/dist/ui/server/entries/endpoints/api/sessions/end/_server.ts.js.map +1 -1
  96. package/dist/ui/server/entries/endpoints/api/speech/_server.ts.js +6 -9
  97. package/dist/ui/server/entries/endpoints/api/speech/_server.ts.js.map +1 -1
  98. package/dist/ui/server/entries/endpoints/api/speech/stream/_server.ts.js +3 -3
  99. package/dist/ui/server/entries/endpoints/api/speech/stream/_server.ts.js.map +1 -1
  100. package/dist/ui/server/entries/endpoints/api/status/_server.ts.js +2 -3
  101. package/dist/ui/server/entries/endpoints/api/status/_server.ts.js.map +1 -1
  102. package/dist/ui/server/entries/fallbacks/error.svelte.js +1 -1
  103. package/dist/ui/server/entries/hooks.server.js +145 -1
  104. package/dist/ui/server/entries/hooks.server.js.map +1 -1
  105. package/dist/ui/server/entries/pages/_layout.server.ts.js +2 -3
  106. package/dist/ui/server/entries/pages/_layout.server.ts.js.map +1 -1
  107. package/dist/ui/server/entries/pages/_layout.svelte.js +4 -2
  108. package/dist/ui/server/entries/pages/_layout.svelte.js.map +1 -1
  109. package/dist/ui/server/entries/pages/_page.server.ts.js +3 -3
  110. package/dist/ui/server/entries/pages/_page.server.ts.js.map +1 -1
  111. package/dist/ui/server/entries/pages/_page.svelte.js +8 -62
  112. package/dist/ui/server/entries/pages/_page.svelte.js.map +1 -1
  113. package/dist/ui/server/entries/pages/settings/_page.svelte.js +3 -2
  114. package/dist/ui/server/entries/pages/settings/_page.svelte.js.map +1 -1
  115. package/dist/ui/server/entries/params.js +60 -0
  116. package/dist/ui/server/entries/params.js.map +1 -0
  117. package/dist/ui/server/env.js +1 -1
  118. package/dist/ui/server/index.js +2 -2
  119. package/dist/ui/server/manifest-full.js +7 -6
  120. package/dist/ui/server/manifest.js +7 -6
  121. package/dist/ui/server/nodes/0.js +1 -1
  122. package/dist/ui/server/nodes/1.js +1 -1
  123. package/dist/ui/server/nodes/2.js +1 -1
  124. package/dist/ui/server/nodes/3.js +1 -1
  125. package/dist/ui/server/nodes/4.js +1 -1
  126. package/dist/ui/server/remote-entry.js +1 -1565
  127. package/dist/ui/server/server.js +7 -6
  128. package/package.json +3 -2
  129. package/dist/ui/client/ui/_app/immutable/chunks/C67ohLw_.js +0 -1
  130. package/dist/ui/client/ui/_app/immutable/chunks/C67ohLw_.js.br +0 -3
  131. package/dist/ui/client/ui/_app/immutable/chunks/C67ohLw_.js.gz +0 -0
  132. package/dist/ui/client/ui/_app/immutable/chunks/CKeiBgOI.js +0 -1
  133. package/dist/ui/client/ui/_app/immutable/chunks/CKeiBgOI.js.br +0 -1
  134. package/dist/ui/client/ui/_app/immutable/chunks/CKeiBgOI.js.gz +0 -0
  135. package/dist/ui/client/ui/_app/immutable/chunks/CM9WugkD.js.br +0 -0
  136. package/dist/ui/client/ui/_app/immutable/chunks/CM9WugkD.js.gz +0 -0
  137. package/dist/ui/client/ui/_app/immutable/chunks/CVUOwNb5.js +0 -3
  138. package/dist/ui/client/ui/_app/immutable/chunks/CVUOwNb5.js.br +0 -0
  139. package/dist/ui/client/ui/_app/immutable/chunks/CVUOwNb5.js.gz +0 -0
  140. package/dist/ui/client/ui/_app/immutable/chunks/CXrPUR7p.js +0 -4
  141. package/dist/ui/client/ui/_app/immutable/chunks/CXrPUR7p.js.br +0 -0
  142. package/dist/ui/client/ui/_app/immutable/chunks/CXrPUR7p.js.gz +0 -0
  143. package/dist/ui/client/ui/_app/immutable/chunks/Dksil5Gu.js +0 -1
  144. package/dist/ui/client/ui/_app/immutable/chunks/Dksil5Gu.js.br +0 -0
  145. package/dist/ui/client/ui/_app/immutable/chunks/Dksil5Gu.js.gz +0 -0
  146. package/dist/ui/client/ui/_app/immutable/chunks/DnL0kOQY.js +0 -1
  147. package/dist/ui/client/ui/_app/immutable/chunks/DnL0kOQY.js.br +0 -2
  148. package/dist/ui/client/ui/_app/immutable/chunks/DnL0kOQY.js.gz +0 -0
  149. package/dist/ui/client/ui/_app/immutable/chunks/Fimt9aTv.js.br +0 -0
  150. package/dist/ui/client/ui/_app/immutable/chunks/Fimt9aTv.js.gz +0 -0
  151. package/dist/ui/client/ui/_app/immutable/chunks/h7UQ89-l.js +0 -3
  152. package/dist/ui/client/ui/_app/immutable/chunks/h7UQ89-l.js.br +0 -0
  153. package/dist/ui/client/ui/_app/immutable/chunks/h7UQ89-l.js.gz +0 -0
  154. package/dist/ui/client/ui/_app/immutable/entry/app.BQe0vf14.js +0 -2
  155. package/dist/ui/client/ui/_app/immutable/entry/app.BQe0vf14.js.br +0 -0
  156. package/dist/ui/client/ui/_app/immutable/entry/app.BQe0vf14.js.gz +0 -0
  157. package/dist/ui/client/ui/_app/immutable/entry/start.uodUAHNT.js.br +0 -0
  158. package/dist/ui/client/ui/_app/immutable/entry/start.uodUAHNT.js.gz +0 -0
  159. package/dist/ui/client/ui/_app/immutable/nodes/0.kO9a4iA1.js +0 -1
  160. package/dist/ui/client/ui/_app/immutable/nodes/0.kO9a4iA1.js.br +0 -0
  161. package/dist/ui/client/ui/_app/immutable/nodes/0.kO9a4iA1.js.gz +0 -0
  162. package/dist/ui/client/ui/_app/immutable/nodes/1.jZ-iBVjE.js +0 -1
  163. package/dist/ui/client/ui/_app/immutable/nodes/1.jZ-iBVjE.js.br +0 -2
  164. package/dist/ui/client/ui/_app/immutable/nodes/1.jZ-iBVjE.js.gz +0 -0
  165. package/dist/ui/client/ui/_app/immutable/nodes/2.CWoJ2uhd.js +0 -52
  166. package/dist/ui/client/ui/_app/immutable/nodes/2.CWoJ2uhd.js.br +0 -0
  167. package/dist/ui/client/ui/_app/immutable/nodes/2.CWoJ2uhd.js.gz +0 -0
  168. package/dist/ui/client/ui/_app/immutable/nodes/3.DcigOv3T.js +0 -5
  169. package/dist/ui/client/ui/_app/immutable/nodes/3.DcigOv3T.js.br +0 -0
  170. package/dist/ui/client/ui/_app/immutable/nodes/3.DcigOv3T.js.gz +0 -0
  171. package/dist/ui/client/ui/_app/immutable/nodes/4.DY8qq4Io.js.br +0 -0
  172. package/dist/ui/client/ui/_app/immutable/nodes/4.DY8qq4Io.js.gz +0 -0
  173. package/dist/ui/server/chunks/bridge-api.js +0 -105
  174. package/dist/ui/server/chunks/bridge-api.js.map +0 -1
  175. package/dist/ui/server/entries/endpoints/api/sessions/_id_/_server.ts.js +0 -13
  176. package/dist/ui/server/entries/endpoints/api/sessions/_id_/_server.ts.js.map +0 -1
  177. package/dist/ui/server/remote-entry.js.map +0 -1
@@ -0,0 +1,1565 @@
1
+ import { C as MUTATIVE_METHODS, _ as get_request_store, t as error, y as with_request_store } from "./exports.js";
2
+ import { J as parse_remote_arg, K as create_remote_key, Y as stringify_remote_arg, ct as flatten_issues, dt as parse_form_key, ft as split_path, j as handle_error_and_jsonify, jt as app_dir, lt as group_formdata, nt as stringify, ot as create_field_proxy, st as deep_set, tt as parse, ut as normalize_issue } from "./internal.js";
3
+ import { n as HandledHttpError, o as ValidationError } from "./shared.js";
4
+ import { A as remote_command_render, B as remote_query_prerender, F as remote_invalid_validator, G as remote_requested_invalid_query, H as remote_requested_async_validator, K as remote_requested_wrong_method, M as remote_cookie_path_relative, O as remote_command_method, P as remote_headers_forbidden, R as remote_query_live_no_value, U as remote_requested_context, V as remote_request_property, W as remote_requested_invalid_limit, X as server_api_unavailable, j as remote_cookie_forbidden, k as remote_command_readonly, z as remote_query_live_not_iterable } from "./server-errors.js";
5
+ import { n as noop } from "./functions.js";
6
+ import { t as prerendering } from "./server.js";
7
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/app/server/remote/shared.js
8
+ /** @import { RequestEvent } from '@sveltejs/kit' */
9
+ /** @import { MaybePromise, RequestState, RemoteInternals, RequestStore, RemoteLiveQueryUserFunctionReturnType } from 'types' */
10
+ /**
11
+ * @param {any} validate_or_fn
12
+ * @param {((arg?: any) => any) | undefined} [maybe_fn]
13
+ * @param {(() => import('types').BaseRemoteInternals | undefined) | undefined} [get_internals]
14
+ * @returns {(arg?: any) => MaybePromise<any>}
15
+ */
16
+ function create_validator(validate_or_fn, maybe_fn, get_internals) {
17
+ if (!maybe_fn) return (arg) => {
18
+ if (arg !== void 0) error(400, "Bad Request");
19
+ };
20
+ if (validate_or_fn === "unchecked") return (arg) => arg;
21
+ if ("~standard" in validate_or_fn) return async (arg) => {
22
+ const result = await validate_or_fn["~standard"].validate(arg);
23
+ if (result.issues) {
24
+ const internals = get_internals?.();
25
+ throw new ValidationError(result.issues, internals?.name ? {
26
+ name: internals.name,
27
+ file: internals.file
28
+ } : void 0);
29
+ }
30
+ return result.value;
31
+ };
32
+ remote_invalid_validator();
33
+ }
34
+ /**
35
+ * In case of a single remote function call, just returns the result.
36
+ *
37
+ * In case of a full page reload, returns the response for a remote function call,
38
+ * either from the cache or by invoking the function.
39
+ * Also saves an uneval'ed version of the result for later HTML inlining for hydration.
40
+ *
41
+ * @template {MaybePromise<any>} T
42
+ * @param {RemoteInternals} internals
43
+ * @param {string} payload — the stringified raw argument (i.e. the cache key the client will use)
44
+ * @param {RequestState} state
45
+ * @param {() => Promise<T>} get_result
46
+ * @returns {Promise<T>}
47
+ */
48
+ async function get_response(internals, payload, state, get_result) {
49
+ await 0;
50
+ const cache = get_cache(internals, state);
51
+ if (!state.is_in_remote_query) get_implicit_lookup(internals, state)[payload] = get_result;
52
+ return cache[payload] ??= get_result();
53
+ }
54
+ /**
55
+ * @param {RequestEvent} event
56
+ * @param {RequestState} state
57
+ * @param {boolean} allow_cookies
58
+ * @returns {RequestStore}
59
+ */
60
+ function derive_remote_function_event(event, state, allow_cookies) {
61
+ /** @type {RequestEvent} */
62
+ const derived = {
63
+ ...event,
64
+ setHeaders: () => {
65
+ remote_headers_forbidden();
66
+ },
67
+ cookies: {
68
+ ...event.cookies,
69
+ set: (name, value, opts) => {
70
+ if (!allow_cookies) remote_cookie_forbidden({ operation: "set" });
71
+ if (opts?.path && !opts.path.startsWith("/")) remote_cookie_path_relative({ operation: "set" });
72
+ return event.cookies.set(name, value, opts);
73
+ },
74
+ delete: (name, opts) => {
75
+ if (!allow_cookies) remote_cookie_forbidden({ operation: "delete" });
76
+ if (opts?.path && !opts.path.startsWith("/")) remote_cookie_path_relative({ operation: "deleted" });
77
+ return event.cookies.delete(name, opts);
78
+ }
79
+ }
80
+ };
81
+ if (state.is_in_remote_query) for (const property of [
82
+ "url",
83
+ "params",
84
+ "route"
85
+ ]) Object.defineProperty(derived, property, {
86
+ enumerable: false,
87
+ get() {
88
+ return remote_request_property({ property });
89
+ }
90
+ });
91
+ return {
92
+ event: derived,
93
+ state: {
94
+ ...state,
95
+ is_in_remote_function: true
96
+ }
97
+ };
98
+ }
99
+ /**
100
+ * Like `with_event` but removes things from `event` you cannot see/call in remote functions, such as `setHeaders`.
101
+ * @template T
102
+ * @param {RequestEvent} event
103
+ * @param {RequestState} state
104
+ * @param {boolean} allow_cookies
105
+ * @param {() => any} get_input
106
+ * @param {(arg?: any) => T} fn
107
+ */
108
+ async function run_remote_function(event, state, allow_cookies, get_input, fn) {
109
+ const store = derive_remote_function_event(event, state, allow_cookies);
110
+ const input = await with_request_store(store, get_input);
111
+ return with_request_store(store, () => fn(input));
112
+ }
113
+ /**
114
+ * Like `with_event` but removes things from `event` you cannot see/call in remote functions, such as `setHeaders`.
115
+ * @template T
116
+ * @param {RequestEvent} event
117
+ * @param {RequestState} state
118
+ * @param {boolean} allow_cookies
119
+ * @param {() => any} get_input
120
+ * @param {(arg?: any) => RemoteLiveQueryUserFunctionReturnType<T>} fn
121
+ * @param {string} name
122
+ */
123
+ async function* run_remote_generator(event, state, allow_cookies, get_input, fn, name) {
124
+ const store = derive_remote_function_event(event, state, allow_cookies);
125
+ const input = await with_request_store(store, get_input);
126
+ const iterator = to_iterator(await with_request_store(store, () => fn(input)), name);
127
+ let done = false;
128
+ try {
129
+ while (true) {
130
+ const result = await with_request_store(store, () => iterator.next());
131
+ if (result.done) {
132
+ done = true;
133
+ return result.value;
134
+ }
135
+ yield result.value;
136
+ }
137
+ } finally {
138
+ if (!done && typeof iterator.return === "function") await with_request_store(store, () => iterator.return?.(void 0));
139
+ }
140
+ }
141
+ /**
142
+ * @template T
143
+ * @param {Awaited<RemoteLiveQueryUserFunctionReturnType<T>>} source
144
+ * @param {string} name
145
+ * @returns {Iterator<T> | AsyncIterator<T>}
146
+ */
147
+ function to_iterator(source, name) {
148
+ if ("next" in source && typeof source.next === "function") return source;
149
+ if (Symbol.asyncIterator in source && typeof source[Symbol.asyncIterator] === "function") return source[Symbol.asyncIterator]();
150
+ if (Symbol.iterator in source && typeof source[Symbol.iterator] === "function") return source[Symbol.iterator]();
151
+ remote_query_live_not_iterable({ name });
152
+ }
153
+ /**
154
+ * Note that `state` is deliberately not optional: resources that capture the request
155
+ * state at creation must pass it explicitly, because reading it from the request store
156
+ * at call time is only equivalent on runtimes with `AsyncLocalStorage` support.
157
+ * Callers without a captured state (such as the module-level `form` instance getters)
158
+ * should pass `get_request_store().state` themselves.
159
+ * @param {RemoteInternals} internals
160
+ * @param {RequestState} state
161
+ */
162
+ function get_cache(internals, state) {
163
+ let cache = state.remote.data?.get(internals);
164
+ if (cache === void 0) {
165
+ cache = {};
166
+ (state.remote.data ??= /* @__PURE__ */ new Map()).set(internals, cache);
167
+ }
168
+ return cache;
169
+ }
170
+ /**
171
+ * @param {RemoteInternals} internals
172
+ * @param {RequestState} state
173
+ */
174
+ function get_implicit_lookup(internals, state) {
175
+ let cache = state.remote.implicit?.get(internals);
176
+ if (cache === void 0) {
177
+ cache = {};
178
+ (state.remote.implicit ??= /* @__PURE__ */ new Map()).set(internals, cache);
179
+ }
180
+ return cache;
181
+ }
182
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/app/server/remote/command.js
183
+ /** @import { RemoteCommand } from '$app/server' */
184
+ /** @import { MaybePromise, RemoteCommandInternals } from 'types' */
185
+ /** @import { StandardSchemaV1 } from '@standard-schema/spec' */
186
+ /**
187
+ * Creates a remote command. When called from the browser, the function will be invoked on the server via a `fetch` call.
188
+ *
189
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.
190
+ *
191
+ * @template Output
192
+ * @overload
193
+ * @param {() => MaybePromise<Output>} fn
194
+ * @returns {RemoteCommand<void, Output>}
195
+ * @since 2.27
196
+ */
197
+ /**
198
+ * Creates a remote command. When called from the browser, the function will be invoked on the server via a `fetch` call.
199
+ *
200
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.
201
+ *
202
+ * @template Input
203
+ * @template Output
204
+ * @overload
205
+ * @param {'unchecked'} validate
206
+ * @param {(arg: Input) => MaybePromise<Output>} fn
207
+ * @returns {RemoteCommand<Input, Output>}
208
+ * @since 2.27
209
+ */
210
+ /**
211
+ * Creates a remote command. When called from the browser, the function will be invoked on the server via a `fetch` call.
212
+ *
213
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#command) for full documentation.
214
+ *
215
+ * @template {StandardSchemaV1} Schema
216
+ * @template Output
217
+ * @overload
218
+ * @param {Schema} validate
219
+ * @param {(arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>} fn
220
+ * @returns {RemoteCommand<StandardSchemaV1.InferInput<Schema>, Output>}
221
+ * @since 2.27
222
+ */
223
+ /**
224
+ * @template Input
225
+ * @template Output
226
+ * @param {any} validate_or_fn
227
+ * @param {(arg?: Input) => MaybePromise<Output>} [maybe_fn]
228
+ * @returns {RemoteCommand<Input, Output>}
229
+ * @since 2.27
230
+ */
231
+ /*@__NO_SIDE_EFFECTS__*/
232
+ function command(validate_or_fn, maybe_fn) {
233
+ /** @type {(arg?: Input) => MaybePromise<Output>} */
234
+ const fn = maybe_fn ?? validate_or_fn;
235
+ /** @type {RemoteCommandInternals} */
236
+ const __ = {
237
+ type: "command",
238
+ id: "",
239
+ name: ""
240
+ };
241
+ /** @type {(arg?: any) => MaybePromise<Input>} */
242
+ const validate = create_validator(validate_or_fn, maybe_fn, () => __);
243
+ /** @type {RemoteCommand<Input, Output> & { __: RemoteCommandInternals }} */
244
+ const wrapper = (arg) => {
245
+ const { event, state } = get_request_store();
246
+ if (!MUTATIVE_METHODS.includes(event.request.method) || state.is_in_remote_query || state.is_in_remote_prerender) {
247
+ if (state.is_in_remote_query || state.is_in_remote_prerender) remote_command_readonly({ name: __.name });
248
+ remote_command_method({
249
+ name: __.name,
250
+ method: event.request.method
251
+ });
252
+ }
253
+ if (state.is_in_render) remote_command_render({ name: __.name });
254
+ const promise = Promise.resolve(run_remote_function(event, state, true, () => validate(arg), fn));
255
+ promise.updates = () => {
256
+ server_api_unavailable({ name: `${__.name}(...).updates(...)` });
257
+ };
258
+ return promise;
259
+ };
260
+ Object.defineProperty(wrapper, "__", { value: __ });
261
+ Object.defineProperty(wrapper, "pending", { get: () => 0 });
262
+ return wrapper;
263
+ }
264
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/app/server/remote/form.js
265
+ /** @import { RemoteFormInput, RemoteForm, RemoteFormInvalidField } from '$app/server' */
266
+ /** @import { InternalRemoteFormIssue, MaybePromise, HasNonOptionalBoolean, RemoteFormInternals } from 'types' */
267
+ /** @import { StandardSchemaV1 } from '@standard-schema/spec' */
268
+ /**
269
+ * Creates a form object that can be spread onto a `<form>` element.
270
+ *
271
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
272
+ *
273
+ * @template Output
274
+ * @overload
275
+ * @param {() => MaybePromise<Output>} fn
276
+ * @returns {RemoteForm<void, Output>}
277
+ * @since 2.27
278
+ */
279
+ /**
280
+ * Creates a form object that can be spread onto a `<form>` element.
281
+ *
282
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
283
+ *
284
+ * @template {RemoteFormInput} Input
285
+ * @template Output
286
+ * @overload
287
+ * @param {'unchecked'} validate
288
+ * @param {(data: Input, issue: RemoteFormInvalidField<Input>) => MaybePromise<Output>} fn
289
+ * @returns {RemoteForm<Input, Output>}
290
+ * @since 2.27
291
+ */
292
+ /**
293
+ * Creates a form object that can be spread onto a `<form>` element.
294
+ *
295
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
296
+ *
297
+ * @template {StandardSchemaV1<RemoteFormInput, Record<string, any>>} Schema
298
+ * @template Output
299
+ * @overload
300
+ * @param {true extends HasNonOptionalBoolean<StandardSchemaV1.InferInput<Schema>> ? 'Error: All booleans in form schemas must be optional (e.g. `v.optional(v.boolean(), false)`) because checkbox inputs do not send a false value when unchecked.' : Schema} validate
301
+ * @param {(data: StandardSchemaV1.InferOutput<Schema>, issue: RemoteFormInvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>} fn
302
+ * @returns {RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>}
303
+ * @since 2.27
304
+ */
305
+ /**
306
+ * @template {RemoteFormInput} Input
307
+ * @template Output
308
+ * @param {any} validate_or_fn
309
+ * @param {(data_or_issue: any, issue?: any) => MaybePromise<Output>} [maybe_fn]
310
+ * @returns {RemoteForm<Input, Output>}
311
+ * @since 2.27
312
+ */
313
+ /*@__NO_SIDE_EFFECTS__*/
314
+ function form(validate_or_fn, maybe_fn) {
315
+ /** @type {any} */
316
+ const fn = maybe_fn ?? validate_or_fn;
317
+ /** @type {StandardSchemaV1 | null} */
318
+ const schema = !maybe_fn || validate_or_fn === "unchecked" ? null : validate_or_fn;
319
+ /**
320
+ * @param {string | number | boolean} [key]
321
+ */
322
+ function create_instance(key) {
323
+ const instance = {};
324
+ instance.method = "POST";
325
+ Object.defineProperty(instance, "enhance", { value: () => {
326
+ return {
327
+ action: instance.action,
328
+ method: instance.method
329
+ };
330
+ } });
331
+ /** @type {RemoteFormInternals} */
332
+ const __ = {
333
+ type: "form",
334
+ name: "",
335
+ id: "",
336
+ fn: async (data, meta, form_data) => {
337
+ const output = {};
338
+ output.submission = true;
339
+ const { event, state } = get_request_store();
340
+ const validated = await schema?.["~standard"].validate(data);
341
+ if (meta.validate_only) return validated?.issues?.map((issue) => normalize_issue(issue, true)) ?? [];
342
+ if (validated?.issues !== void 0) handle_issues(output, validated.issues, form_data, __.id);
343
+ else {
344
+ if (validated !== void 0) data = validated.value;
345
+ const issue = create_issues();
346
+ try {
347
+ output.result = await run_remote_function(event, state, true, () => data, (data) => !maybe_fn ? fn() : fn(data, issue));
348
+ } catch (error) {
349
+ if (error instanceof ValidationError) handle_issues(output, error.issues, form_data, __.id);
350
+ else throw error;
351
+ }
352
+ }
353
+ if (!event.isRemoteRequest) {
354
+ const cache = get_cache(__, state);
355
+ cache[""] ??= output;
356
+ get_implicit_lookup(__, state)[__.key ? `${__.id}/${__.key}` : __.id] = () => cache[""];
357
+ }
358
+ return output;
359
+ }
360
+ };
361
+ Object.defineProperty(instance, "__", { value: __ });
362
+ Object.defineProperty(instance, "action", {
363
+ get: () => {
364
+ const { event, state } = get_request_store();
365
+ const search = new URLSearchParams(state.prerendering ? "" : event.url.search);
366
+ search.delete("/remote");
367
+ const query = search.toString();
368
+ const action_id = __.key ? `${__.id}/${encodeURIComponent(__.key)}` : __.id;
369
+ return `?${query ? `${query}&` : ""}/remote=${action_id}`;
370
+ },
371
+ enumerable: true
372
+ });
373
+ Object.defineProperty(instance, "fields", { get() {
374
+ return create_field_proxy({
375
+ form_id: __.id,
376
+ get: () => get_cache(__, get_request_store().state)?.[""]?.input ?? {},
377
+ set: (path, value) => {
378
+ const cache = get_cache(__, get_request_store().state);
379
+ const entry = cache[""];
380
+ if (entry?.submission) return;
381
+ if (path.length === 0) {
382
+ (cache[""] ??= {}).input = value;
383
+ return;
384
+ }
385
+ const input = entry?.input ?? {};
386
+ deep_set(input, path.map(String), value);
387
+ (cache[""] ??= {}).input = input;
388
+ },
389
+ get_issues: () => flatten_issues(get_cache(__, get_request_store().state)?.[""]?.issues ?? []),
390
+ get_touched: () => ({}),
391
+ get_dirty: () => ({})
392
+ });
393
+ } });
394
+ Object.defineProperty(instance, "result", { get() {
395
+ try {
396
+ return get_cache(__, get_request_store().state)?.[""]?.result;
397
+ } catch {
398
+ return;
399
+ }
400
+ } });
401
+ Object.defineProperty(instance, "pending", { get: () => 0 });
402
+ Object.defineProperty(instance, "submitted", { get: () => false });
403
+ Object.defineProperty(instance, "preflight", { value: () => instance });
404
+ Object.defineProperty(instance, "validate", { value: () => {
405
+ server_api_unavailable({ name: "form.validate()" });
406
+ } });
407
+ Object.defineProperty(instance, "submit", { value: () => {
408
+ server_api_unavailable({ name: "form.submit()" });
409
+ } });
410
+ Object.defineProperty(instance, "element", { get: () => null });
411
+ if (key == void 0) Object.defineProperty(instance, "for", {
412
+ /** @type {RemoteForm<any, any>['for']} */
413
+ value: (key) => {
414
+ const { state } = get_request_store();
415
+ const cache_key = __.id + "|" + JSON.stringify(key);
416
+ /** @type {RemoteForm<Input, Output> & { __: RemoteFormInternals }} */
417
+ let instance = (state.remote.forms ??= /* @__PURE__ */ new Map()).get(cache_key);
418
+ if (!instance) {
419
+ instance = create_instance(key);
420
+ instance.__.id = __.id;
421
+ instance.__.key = JSON.stringify(key);
422
+ instance.__.name = __.name;
423
+ state.remote.forms.set(cache_key, instance);
424
+ }
425
+ return instance;
426
+ } });
427
+ return instance;
428
+ }
429
+ return create_instance();
430
+ }
431
+ /**
432
+ * @param {{ issues?: InternalRemoteFormIssue[], input?: Record<string, any>, result: any }} output
433
+ * @param {readonly StandardSchemaV1.Issue[]} issues
434
+ * @param {FormData | null} form_data - null if the form is progressively enhanced
435
+ * @param {string} form_id - hash/name of the form
436
+ */
437
+ function handle_issues(output, issues, form_data, form_id) {
438
+ output.issues = issues.map((issue) => normalize_issue(issue, true));
439
+ if (form_data) {
440
+ output.input = {};
441
+ for (const [field_name, entries] of group_formdata(form_data)) {
442
+ const field = parse_form_key(form_id, field_name);
443
+ const path = split_path(field.name);
444
+ if (path.some((part) => part.startsWith("_"))) continue;
445
+ const values = entries.filter((value) => typeof value === "string");
446
+ deep_set(output.input, path, field.is_array ? values : values[0]);
447
+ }
448
+ }
449
+ }
450
+ /**
451
+ * Creates an invalid function that can be used to imperatively mark form fields as invalid
452
+ * @returns {RemoteFormInvalidField<any>}
453
+ */
454
+ function create_issues() {
455
+ return new Proxy(
456
+ /** @param {string} message */
457
+ (message) => {
458
+ return create_issue(message);
459
+ },
460
+ { get(target, prop) {
461
+ if (typeof prop === "symbol") return target[prop];
462
+ return create_issue_proxy(prop, []);
463
+ } }
464
+ );
465
+ /**
466
+ * @param {string} message
467
+ * @param {(string | number)[]} path
468
+ * @returns {StandardSchemaV1.Issue}
469
+ */
470
+ function create_issue(message, path = []) {
471
+ return {
472
+ message,
473
+ path
474
+ };
475
+ }
476
+ /**
477
+ * Creates a proxy that builds up a path and returns a function to create an issue
478
+ * @param {string | number} key
479
+ * @param {(string | number)[]} path
480
+ */
481
+ function create_issue_proxy(key, path) {
482
+ const new_path = [...path, key];
483
+ /**
484
+ * @param {string} message
485
+ * @returns {StandardSchemaV1.Issue}
486
+ */
487
+ const issue_func = (message) => create_issue(message, new_path);
488
+ return new Proxy(issue_func, { get(target, prop) {
489
+ if (typeof prop === "symbol") return target[prop];
490
+ if (/^\d+$/.test(prop)) return create_issue_proxy(parseInt(prop, 10), new_path);
491
+ return create_issue_proxy(prop, new_path);
492
+ } });
493
+ }
494
+ }
495
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/app/server/remote/prerender.js
496
+ /** @import { RemoteResource, RemotePrerenderFunction } from '$app/server' */
497
+ /** @import { RemoteFunctionResponse, RemotePrerenderInputsGenerator, RemotePrerenderInternals, MaybePromise } from 'types' */
498
+ /** @import { StandardSchemaV1 } from '@standard-schema/spec' */
499
+ /**
500
+ * Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.
501
+ *
502
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.
503
+ *
504
+ * @template Output
505
+ * @overload
506
+ * @param {() => MaybePromise<Output>} fn
507
+ * @param {{ inputs?: RemotePrerenderInputsGenerator<void>, dynamic?: boolean }} [options]
508
+ * @returns {RemotePrerenderFunction<void, Output>}
509
+ * @since 2.27
510
+ */
511
+ /**
512
+ * Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.
513
+ *
514
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.
515
+ *
516
+ * @template Input
517
+ * @template Output
518
+ * @overload
519
+ * @param {'unchecked'} validate
520
+ * @param {(arg: Input) => MaybePromise<Output>} fn
521
+ * @param {{ inputs?: RemotePrerenderInputsGenerator<Input>, dynamic?: boolean }} [options]
522
+ * @returns {RemotePrerenderFunction<Input, Output>}
523
+ * @since 2.27
524
+ */
525
+ /**
526
+ * Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.
527
+ *
528
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#prerender) for full documentation.
529
+ *
530
+ * @template {StandardSchemaV1} Schema
531
+ * @template Output
532
+ * @overload
533
+ * @param {Schema} schema
534
+ * @param {(arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>} fn
535
+ * @param {{ inputs?: RemotePrerenderInputsGenerator<StandardSchemaV1.InferInput<Schema>>, dynamic?: boolean }} [options]
536
+ * @returns {RemotePrerenderFunction<StandardSchemaV1.InferInput<Schema>, Output>}
537
+ * @since 2.27
538
+ */
539
+ /**
540
+ * @template Input
541
+ * @template Output
542
+ * @param {any} validate_or_fn
543
+ * @param {any} [fn_or_options]
544
+ * @param {{ inputs?: RemotePrerenderInputsGenerator<Input>, dynamic?: boolean }} [maybe_options]
545
+ * @returns {RemotePrerenderFunction<Input, Output>}
546
+ * @since 2.27
547
+ */
548
+ /*@__NO_SIDE_EFFECTS__*/
549
+ function prerender(validate_or_fn, fn_or_options, maybe_options) {
550
+ const maybe_fn = typeof fn_or_options === "function" ? fn_or_options : void 0;
551
+ /** @type {typeof maybe_options} */
552
+ const options = maybe_options ?? (maybe_fn ? void 0 : fn_or_options);
553
+ /** @type {(arg?: Input) => MaybePromise<Output>} */
554
+ const fn = maybe_fn ?? validate_or_fn;
555
+ /** @type {RemotePrerenderInternals} */
556
+ const __ = {
557
+ type: "prerender",
558
+ id: "",
559
+ name: "",
560
+ has_arg: !!maybe_fn,
561
+ inputs: options?.inputs,
562
+ dynamic: options?.dynamic
563
+ };
564
+ /** @type {(arg?: any) => MaybePromise<Input>} */
565
+ const validate = create_validator(validate_or_fn, maybe_fn, () => __);
566
+ /** @type {RemotePrerenderFunction<Input, Output> & { __: RemotePrerenderInternals }} */
567
+ const wrapper = (arg) => {
568
+ const { event, state } = get_request_store();
569
+ const payload = stringify_remote_arg(arg);
570
+ /** @type {Promise<Output> & Partial<RemoteResource<Output>>} */
571
+ const promise = get_response(__, payload, state, async () => {
572
+ const id = __.id;
573
+ const url = `/ui/${app_dir}/remote/${id}${payload ? `/${payload}` : ""}`;
574
+ if (!state.prerendering && !event.isRemoteRequest) {
575
+ /** @type {RemoteFunctionResponse | undefined} */
576
+ let prerendered;
577
+ try {
578
+ const response = await fetch(new URL(url, event.request.url).href, { redirect: "manual" });
579
+ if (response.ok) prerendered = await response.json();
580
+ } catch {}
581
+ if (prerendered) {
582
+ if (prerendered.type === "error") throw new HandledHttpError(prerendered.error);
583
+ return parse(prerendered.data)._;
584
+ }
585
+ }
586
+ if (state.prerendering?.remote_responses.has(url)) return state.prerendering.remote_responses.get(url);
587
+ const promise = run_remote_function(event, {
588
+ ...state,
589
+ is_in_remote_prerender: true
590
+ }, false, () => validate(arg), fn);
591
+ if (state.prerendering) state.prerendering.remote_responses.set(url, promise);
592
+ const result = await promise;
593
+ if (state.prerendering) {
594
+ const body = {
595
+ type: "result",
596
+ data: stringify({ _: result })
597
+ };
598
+ state.prerendering.dependencies.set(url, {
599
+ body: JSON.stringify(body),
600
+ response: Response.json(body)
601
+ });
602
+ }
603
+ return result;
604
+ });
605
+ promise.catch(noop);
606
+ return promise;
607
+ };
608
+ Object.defineProperty(wrapper, "__", { value: __ });
609
+ return wrapper;
610
+ }
611
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/utils/shared-iterator.js
612
+ /**
613
+ * A pull-style async iterator that fans out a single stream of values to
614
+ * multiple `for await (...)` consumers. Each subscriber gets its own
615
+ * `AsyncGenerator` whose `.next()` resolves whenever a value is pushed via
616
+ * `push(value)`. Multiple consumers see the same values without each one
617
+ * driving an independent underlying source.
618
+ *
619
+ * Backpressure is **latest-wins**: if values arrive faster than a particular
620
+ * consumer drains its iterator, only the most-recently-pushed value is kept
621
+ * pending for that subscriber. Earlier undrained values are dropped. This is
622
+ * appropriate for live data streams (reactive state replication), not for
623
+ * event logs where every value must be delivered.
624
+ *
625
+ * Lifecycle hooks are exposed via the constructor:
626
+ *
627
+ * - `start()` is called when the subscriber count transitions
628
+ * from 0 to 1 (e.g. to start a pump pulling from a real source).
629
+ * - `stop()` is called when the subscriber count transitions
630
+ * from non-zero back to 0 (e.g. to tear down that pump).
631
+ *
632
+ * Either hook may be omitted.
633
+ *
634
+ * The owner is responsible for calling `push(value)` to broadcast values,
635
+ * `done()` to signal natural completion to all subscribers, and `fail(error)`
636
+ * to broadcast a terminal error. After `done()` or `fail()`, the iterator
637
+ * rejects further `subscribe()` calls with the terminal state appropriately.
638
+ *
639
+ * @template T
640
+ */
641
+ var SharedIterator = class {
642
+ /**
643
+ * @typedef {object} Subscriber
644
+ * @property {{ value: any } | null} pending
645
+ * @property {{ error: unknown } | null} pending_error
646
+ * @property {boolean} finished
647
+ * @property {((result: IteratorResult<any, void>) => void) | null} waiting_resolve
648
+ * @property {((reason: unknown) => void) | null} waiting_reject
649
+ */
650
+ /** @type {Set<Subscriber>} */
651
+ #subscribers = /* @__PURE__ */ new Set();
652
+ /** @type {((instance: SharedIterator<T>) => (() => void)) | undefined} */
653
+ #start = void 0;
654
+ /** @type {(() => void) | undefined} */
655
+ #stop = void 0;
656
+ /** Once `done()` or `fail()` has been broadcast, no new values are accepted. */
657
+ #closed = false;
658
+ /** @type {unknown} */
659
+ #terminal_error = void 0;
660
+ /** Whether `done()` or `fail()` has been broadcast. */
661
+ get closed() {
662
+ return this.#closed;
663
+ }
664
+ /**
665
+ * @param {(instance: SharedIterator<T>) => (() => void)} [start]
666
+ */
667
+ constructor(start) {
668
+ this.#start = start;
669
+ }
670
+ /** @param {T} value */
671
+ push(value) {
672
+ if (this.#closed) return;
673
+ for (const subscriber of this.#subscribers) if (subscriber.waiting_resolve) {
674
+ const resolve = subscriber.waiting_resolve;
675
+ subscriber.waiting_resolve = null;
676
+ subscriber.waiting_reject = null;
677
+ resolve({
678
+ value,
679
+ done: false
680
+ });
681
+ } else subscriber.pending = { value };
682
+ }
683
+ /**
684
+ * Signal natural completion to all current subscribers, and to any future
685
+ * subscriber (which will receive an immediately-done iterator).
686
+ */
687
+ done() {
688
+ if (this.#closed) return;
689
+ this.#closed = true;
690
+ for (const subscriber of this.#subscribers) {
691
+ subscriber.finished = true;
692
+ if (subscriber.waiting_resolve) {
693
+ const resolve = subscriber.waiting_resolve;
694
+ subscriber.waiting_resolve = null;
695
+ subscriber.waiting_reject = null;
696
+ resolve({
697
+ value: void 0,
698
+ done: true
699
+ });
700
+ }
701
+ }
702
+ this.#subscribers.clear();
703
+ }
704
+ /**
705
+ * Broadcast a terminal error. All current subscribers will reject their
706
+ * next `.next()` call with `error`. Future subscribers will also reject
707
+ * their first `.next()`.
708
+ *
709
+ * @param {unknown} error
710
+ */
711
+ fail(error) {
712
+ if (this.#closed) return;
713
+ this.#closed = true;
714
+ this.#terminal_error = error;
715
+ for (const subscriber of this.#subscribers) {
716
+ subscriber.finished = true;
717
+ if (subscriber.waiting_reject) {
718
+ const reject = subscriber.waiting_reject;
719
+ subscriber.waiting_resolve = null;
720
+ subscriber.waiting_reject = null;
721
+ reject(error);
722
+ } else subscriber.pending_error = { error };
723
+ }
724
+ this.#subscribers.clear();
725
+ }
726
+ /**
727
+ * Subscribe to the shared stream. Returns an `AsyncGenerator<T>` that
728
+ * yields every value pushed after this call (and, if `initial_value` is
729
+ * provided, that value as the first yield).
730
+ *
731
+ * @param {{ initial_value?: { value: T } }} [options]
732
+ * `initial_value` lets the caller seed the iterator with a synchronously-
733
+ * available current value before any new pushes arrive (e.g. the
734
+ * "last-seen value" of a reactive resource). Pass it wrapped in an
735
+ * object so `undefined` can be distinguished from "no initial value".
736
+ * @returns {AsyncGenerator<T, void, void>}
737
+ */
738
+ subscribe(options) {
739
+ /** @type {Subscriber} */
740
+ const subscriber = {
741
+ pending: options?.initial_value ? { value: options.initial_value.value } : null,
742
+ pending_error: this.#closed && this.#terminal_error !== void 0 ? { error: this.#terminal_error } : null,
743
+ finished: this.#closed && this.#terminal_error === void 0,
744
+ waiting_resolve: null,
745
+ waiting_reject: null
746
+ };
747
+ if (!subscriber.finished && subscriber.pending_error === null) this.#subscribers.add(subscriber);
748
+ if (!this.#closed) this.#stop ??= this.#start?.(this);
749
+ const unsubscribe = () => {
750
+ subscriber.finished = true;
751
+ if (this.#subscribers.delete(subscriber) && this.#subscribers.size === 0) this.#stop?.();
752
+ };
753
+ /** @type {AsyncGenerator<T, void, void>} */
754
+ const iterator = {
755
+ next() {
756
+ if (subscriber.pending_error) {
757
+ const { error } = subscriber.pending_error;
758
+ subscriber.pending_error = null;
759
+ unsubscribe();
760
+ return Promise.reject(error);
761
+ }
762
+ if (subscriber.pending) {
763
+ const { value } = subscriber.pending;
764
+ subscriber.pending = null;
765
+ return Promise.resolve({
766
+ value,
767
+ done: false
768
+ });
769
+ }
770
+ if (subscriber.finished) return Promise.resolve({
771
+ value: void 0,
772
+ done: true
773
+ });
774
+ return new Promise((resolve, reject) => {
775
+ subscriber.waiting_resolve = resolve;
776
+ subscriber.waiting_reject = reject;
777
+ });
778
+ },
779
+ return(value) {
780
+ unsubscribe();
781
+ if (subscriber.waiting_resolve) {
782
+ const resolve = subscriber.waiting_resolve;
783
+ subscriber.waiting_resolve = null;
784
+ subscriber.waiting_reject = null;
785
+ resolve({
786
+ value: void 0,
787
+ done: true
788
+ });
789
+ }
790
+ return Promise.resolve({
791
+ value,
792
+ done: true
793
+ });
794
+ },
795
+ throw(error) {
796
+ unsubscribe();
797
+ if (subscriber.waiting_reject) {
798
+ const reject = subscriber.waiting_reject;
799
+ subscriber.waiting_resolve = null;
800
+ subscriber.waiting_reject = null;
801
+ reject(error);
802
+ }
803
+ return Promise.reject(error);
804
+ },
805
+ [Symbol.asyncIterator]() {
806
+ return iterator;
807
+ },
808
+ async [Symbol.asyncDispose]() {}
809
+ };
810
+ return iterator;
811
+ }
812
+ };
813
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/app/server/remote/query.js
814
+ /** @import { RemoteLiveQuery, RemoteLiveQueryFunction, RemoteQuery, RemoteQueryFunction } from '$app/server' */
815
+ /** @import { RequestEvent } from '@sveltejs/kit' */
816
+ /** @import { RemoteInternals, MaybePromise, RequestState, RemoteQueryLiveInternals, RemoteQueryBatchInternals, RemoteQueryInternals, RemoteLiveQueryUserFunctionReturnType } from 'types' */
817
+ /** @import { StandardSchemaV1 } from '@standard-schema/spec' */
818
+ /**
819
+ * Creates a remote query. When called from the browser, the function will be invoked on the server via a `fetch` call.
820
+ *
821
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.
822
+ *
823
+ * @template Output
824
+ * @overload
825
+ * @param {() => MaybePromise<Output>} fn
826
+ * @returns {RemoteQueryFunction<void, Output>}
827
+ * @since 2.27
828
+ */
829
+ /**
830
+ * Creates a remote query. When called from the browser, the function will be invoked on the server via a `fetch` call.
831
+ *
832
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.
833
+ *
834
+ * @template Input
835
+ * @template Output
836
+ * @overload
837
+ * @param {'unchecked'} validate
838
+ * @param {(arg: Input) => MaybePromise<Output>} fn
839
+ * @returns {RemoteQueryFunction<Input, Output>}
840
+ * @since 2.27
841
+ */
842
+ /**
843
+ * Creates a remote query. When called from the browser, the function will be invoked on the server via a `fetch` call.
844
+ *
845
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query) for full documentation.
846
+ *
847
+ * @template {StandardSchemaV1} Schema
848
+ * @template Output
849
+ * @overload
850
+ * @param {Schema} schema
851
+ * @param {(arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>} fn
852
+ * @returns {RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output, StandardSchemaV1.InferOutput<Schema>>}
853
+ * @since 2.27
854
+ */
855
+ /**
856
+ * @template Input
857
+ * @template Output
858
+ * @param {any} validate_or_fn
859
+ * @param {(args?: Input) => MaybePromise<Output>} [maybe_fn]
860
+ * @returns {RemoteQueryFunction<Input, Output>}
861
+ * @since 2.27
862
+ */
863
+ /*@__NO_SIDE_EFFECTS__*/
864
+ function query(validate_or_fn, maybe_fn) {
865
+ /** @type {(arg?: Input) => Output} */
866
+ const fn = maybe_fn ?? validate_or_fn;
867
+ /** @type {(arg?: any) => MaybePromise<Input>} */
868
+ const validate = create_validator(validate_or_fn, maybe_fn, () => __);
869
+ /** @type {RemoteQueryInternals} */
870
+ const __ = {
871
+ type: "query",
872
+ id: "",
873
+ name: "",
874
+ validate,
875
+ bind(payload, validated_arg) {
876
+ const { event, state } = get_request_store();
877
+ return create_query_resource(__, payload, event, state, () => run_remote_function(event, {
878
+ ...state,
879
+ is_in_remote_query: true
880
+ }, false, () => validated_arg, fn));
881
+ }
882
+ };
883
+ /** @type {RemoteQueryFunction<Input, Output> & { __: RemoteQueryInternals }} */
884
+ const wrapper = (arg) => {
885
+ if (prerendering) remote_query_prerender({
886
+ type: "query",
887
+ name: __.name
888
+ });
889
+ const { event, state } = get_request_store();
890
+ const payload = stringify_remote_arg(arg);
891
+ return create_query_resource(__, payload, event, state, () => run_remote_function(event, {
892
+ ...state,
893
+ is_in_remote_query: true
894
+ }, false, () => validate(arg), fn));
895
+ };
896
+ Object.defineProperty(wrapper, "__", { value: __ });
897
+ return wrapper;
898
+ }
899
+ /**
900
+ * Creates a live remote query. When called from the browser, the function will be invoked on the server via a streaming `fetch` call.
901
+ *
902
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.live) for full documentation.
903
+ *
904
+ * @template Output
905
+ * @overload
906
+ * @param {(arg: void) => RemoteLiveQueryUserFunctionReturnType<Output>} fn
907
+ * @returns {RemoteLiveQueryFunction<void, Output>}
908
+ */
909
+ /**
910
+ * @template Input
911
+ * @template Output
912
+ * @overload
913
+ * @param {'unchecked'} validate
914
+ * @param {(arg: Input) => RemoteLiveQueryUserFunctionReturnType<Output>} fn
915
+ * @returns {RemoteLiveQueryFunction<Input, Output>}
916
+ */
917
+ /**
918
+ * @template {StandardSchemaV1} Schema
919
+ * @template Output
920
+ * @overload
921
+ * @param {Schema} schema
922
+ * @param {(arg: StandardSchemaV1.InferOutput<Schema>) => RemoteLiveQueryUserFunctionReturnType<Output>} fn
923
+ * @returns {RemoteLiveQueryFunction<StandardSchemaV1.InferInput<Schema>, Output, StandardSchemaV1.InferOutput<Schema>>}
924
+ */
925
+ /**
926
+ * @template Input
927
+ * @template Output
928
+ * @param {any} validate_or_fn
929
+ * @param {(args: Input) => RemoteLiveQueryUserFunctionReturnType<Output>} [maybe_fn]
930
+ * @returns {RemoteLiveQueryFunction<Input, Output>}
931
+ */
932
+ /*@__NO_SIDE_EFFECTS__*/
933
+ function live(validate_or_fn, maybe_fn) {
934
+ /** @type {(arg: Input) => RemoteLiveQueryUserFunctionReturnType<Output>} */
935
+ const fn = maybe_fn ?? validate_or_fn;
936
+ /** @type {(arg?: any) => MaybePromise<Input>} */
937
+ const validate = create_validator(validate_or_fn, maybe_fn, () => __);
938
+ /**
939
+ * @param {any} event
940
+ * @param {any} state
941
+ * @param {any} get_input
942
+ */
943
+ const run = (event, state, get_input) => run_remote_generator(event, {
944
+ ...state,
945
+ is_in_remote_query: true
946
+ }, false, get_input, fn, __.name);
947
+ /** @type {RemoteQueryLiveInternals} */
948
+ const __ = {
949
+ type: "query_live",
950
+ id: "",
951
+ name: "",
952
+ run: (event, state, arg) => run(event, state, () => validate(arg)),
953
+ validate,
954
+ bind(payload, validated_arg) {
955
+ const { event, state } = get_request_store();
956
+ return create_live_query_resource(__, payload, event, state, () => run(event, state, () => validated_arg));
957
+ }
958
+ };
959
+ /** @type {RemoteLiveQueryFunction<Input, Output> & { __: RemoteQueryLiveInternals }} */
960
+ const wrapper = (arg) => {
961
+ if (prerendering) remote_query_prerender({
962
+ type: "query.live",
963
+ name: __.name
964
+ });
965
+ const { event, state } = get_request_store();
966
+ const payload = stringify_remote_arg(arg);
967
+ return create_live_query_resource(__, payload, event, state, () => run(event, state, () => validate(arg)));
968
+ };
969
+ Object.defineProperty(wrapper, "__", { value: __ });
970
+ return wrapper;
971
+ }
972
+ /**
973
+ * Creates a batch query function that collects multiple calls and executes them in a single request
974
+ *
975
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.batch) for full documentation.
976
+ *
977
+ * @template Input
978
+ * @template Output
979
+ * @overload
980
+ * @param {'unchecked'} validate
981
+ * @param {(args: Input[]) => MaybePromise<(arg: Input, idx: number) => Output>} fn
982
+ * @returns {RemoteQueryFunction<Input, Output>}
983
+ * @since 2.35
984
+ */
985
+ /**
986
+ * Creates a batch query function that collects multiple calls and executes them in a single request
987
+ *
988
+ * See [Remote functions](https://svelte.dev/docs/kit/remote-functions#query.batch) for full documentation.
989
+ *
990
+ * @template {StandardSchemaV1} Schema
991
+ * @template Output
992
+ * @overload
993
+ * @param {Schema} schema
994
+ * @param {(args: StandardSchemaV1.InferOutput<Schema>[]) => MaybePromise<(arg: StandardSchemaV1.InferOutput<Schema>, idx: number) => Output>} fn
995
+ * @returns {RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output, StandardSchemaV1.InferOutput<Schema>>}
996
+ * @since 2.35
997
+ */
998
+ /**
999
+ * @template Input
1000
+ * @template Output
1001
+ * @param {any} validate_or_fn
1002
+ * @param {(args?: Input[]) => MaybePromise<(arg: Input, idx: number) => Output>} [maybe_fn]
1003
+ * @returns {RemoteQueryFunction<Input, Output>}
1004
+ * @since 2.35
1005
+ */
1006
+ /*@__NO_SIDE_EFFECTS__*/
1007
+ function batch(validate_or_fn, maybe_fn) {
1008
+ /** @type {(args?: Input[]) => MaybePromise<(arg: Input, idx: number) => Output>} */
1009
+ const fn = maybe_fn ?? validate_or_fn;
1010
+ /** @type {(arg?: any) => MaybePromise<Input>} */
1011
+ const validate = create_validator(validate_or_fn, maybe_fn, () => __);
1012
+ /**
1013
+ * Enqueues a single call into the current batch (creating one if necessary)
1014
+ * and returns a promise that resolves with the result for this entry.
1015
+ *
1016
+ * @param {string} payload — the stringified raw argument (cache key)
1017
+ * @param {() => MaybePromise<any>} get_validated — produces the validated argument for this entry
1018
+ * @returns {Promise<any>}
1019
+ */
1020
+ const enqueue = (payload, get_validated) => {
1021
+ const { event, state } = get_request_store();
1022
+ return new Promise((resolve, reject) => {
1023
+ const batches = state.remote.batches ??= /* @__PURE__ */ new Map();
1024
+ let batched = batches.get(__);
1025
+ if (!batched) {
1026
+ batched = /* @__PURE__ */ new Map();
1027
+ batches.set(__, batched);
1028
+ }
1029
+ const entry = batched.get(payload);
1030
+ if (entry) {
1031
+ entry.resolvers.push({
1032
+ resolve,
1033
+ reject
1034
+ });
1035
+ return;
1036
+ }
1037
+ batched.set(payload, {
1038
+ get_validated,
1039
+ resolvers: [{
1040
+ resolve,
1041
+ reject
1042
+ }]
1043
+ });
1044
+ if (batched.size > 1) return;
1045
+ setTimeout(async () => {
1046
+ batches.delete(__);
1047
+ const entries = Array.from(batched.values());
1048
+ try {
1049
+ return await run_remote_function(event, {
1050
+ ...state,
1051
+ is_in_remote_query: true
1052
+ }, false, async () => Promise.all(entries.map((entry) => entry.get_validated())), async (input) => {
1053
+ const get_result = await fn(input);
1054
+ for (let i = 0; i < entries.length; i++) try {
1055
+ const result = get_result(input[i], i);
1056
+ for (const resolver of entries[i].resolvers) resolver.resolve(result);
1057
+ } catch (error) {
1058
+ for (const resolver of entries[i].resolvers) resolver.reject(error);
1059
+ }
1060
+ });
1061
+ } catch (error) {
1062
+ for (const entry of batched.values()) for (const resolver of entry.resolvers) resolver.reject(error);
1063
+ }
1064
+ }, 0);
1065
+ });
1066
+ };
1067
+ /** @type {RemoteQueryBatchInternals} */
1068
+ const __ = {
1069
+ type: "query_batch",
1070
+ id: "",
1071
+ name: "",
1072
+ validate,
1073
+ run: async (args) => {
1074
+ const { event, state } = get_request_store();
1075
+ return run_remote_function(event, {
1076
+ ...state,
1077
+ is_in_remote_query: true
1078
+ }, false, async () => Promise.all(args.map(validate)), async (input) => {
1079
+ const get_result = await fn(input);
1080
+ return Promise.all(input.map(async (arg, i) => {
1081
+ try {
1082
+ return {
1083
+ type: "result",
1084
+ data: get_result(arg, i)
1085
+ };
1086
+ } catch (error) {
1087
+ return {
1088
+ type: "error",
1089
+ error: await handle_error_and_jsonify(event, state, error)
1090
+ };
1091
+ }
1092
+ }));
1093
+ });
1094
+ },
1095
+ bind(payload, validated_arg) {
1096
+ const { event, state } = get_request_store();
1097
+ return create_query_resource(__, payload, event, state, () => enqueue(payload, () => validated_arg));
1098
+ }
1099
+ };
1100
+ /** @type {RemoteQueryFunction<Input, Output> & { __: RemoteQueryBatchInternals }} */
1101
+ const wrapper = (arg) => {
1102
+ if (prerendering) remote_query_prerender({
1103
+ type: "query.batch",
1104
+ name: __.name
1105
+ });
1106
+ const { event, state } = get_request_store();
1107
+ const payload = stringify_remote_arg(arg);
1108
+ return create_query_resource(__, payload, event, state, () => enqueue(payload, () => validate(arg)));
1109
+ };
1110
+ Object.defineProperty(wrapper, "__", { value: __ });
1111
+ return wrapper;
1112
+ }
1113
+ /**
1114
+ * Include this value in the returned payload...
1115
+ * @param {RequestEvent} event
1116
+ * @param {RequestState} state
1117
+ * @param {RemoteInternals} internals
1118
+ * @param {string} payload
1119
+ * @param {() => Promise<any>} fn
1120
+ */
1121
+ function refresh(event, state, internals, payload, fn) {
1122
+ if (!internals.id) return;
1123
+ if (!event.isRemoteRequest && state.is_in_remote_form_or_command) return;
1124
+ const key = create_remote_key(internals.id, payload);
1125
+ (state.remote.explicit ??= /* @__PURE__ */ new Map()).set(key, {
1126
+ internals,
1127
+ fn
1128
+ });
1129
+ }
1130
+ /**
1131
+ * @param {RemoteInternals} __
1132
+ * @param {string} payload — the stringified raw argument (i.e. the cache key the client will use)
1133
+ * @param {RequestEvent} event
1134
+ * @param {RequestState} state
1135
+ * @param {() => Promise<any>} fn
1136
+ * @returns {RemoteQuery<any>}
1137
+ */
1138
+ function create_query_resource(__, payload, event, state, fn) {
1139
+ /** @type {Promise<any> | null} */
1140
+ let promise = null;
1141
+ const get_promise = () => {
1142
+ return promise ??= get_response(__, payload, state, fn);
1143
+ };
1144
+ const populate_hydratable = () => {
1145
+ if (__.id && state.is_in_render) get_promise().catch(noop);
1146
+ };
1147
+ return {
1148
+ /** @type {Promise<any>['catch']} */
1149
+ catch(onrejected) {
1150
+ return get_promise().catch(onrejected);
1151
+ },
1152
+ get current() {
1153
+ populate_hydratable();
1154
+ },
1155
+ get error() {
1156
+ populate_hydratable();
1157
+ },
1158
+ /** @type {Promise<any>['finally']} */
1159
+ finally(onfinally) {
1160
+ return get_promise().finally(onfinally);
1161
+ },
1162
+ get loading() {
1163
+ populate_hydratable();
1164
+ return true;
1165
+ },
1166
+ get ready() {
1167
+ populate_hydratable();
1168
+ return false;
1169
+ },
1170
+ refresh() {
1171
+ promise = null;
1172
+ delete get_cache(__, state)[payload];
1173
+ refresh(event, state, __, payload, get_promise);
1174
+ return Promise.resolve();
1175
+ },
1176
+ /** @param {any} value */
1177
+ set(value) {
1178
+ const p = promise = Promise.resolve(value);
1179
+ get_cache(__, state)[payload] = p;
1180
+ refresh(event, state, __, payload, () => p);
1181
+ },
1182
+ /** @type {Promise<any>['then']} */
1183
+ then(onfulfilled, onrejected) {
1184
+ return get_promise().then(onfulfilled, onrejected);
1185
+ },
1186
+ withOverride() {
1187
+ server_api_unavailable({ name: `${__.name}.withOverride()` });
1188
+ },
1189
+ get [Symbol.toStringTag]() {
1190
+ return "QueryResource";
1191
+ }
1192
+ };
1193
+ }
1194
+ /**
1195
+ * @param {RemoteQueryLiveInternals} __
1196
+ * @param {string} payload — the stringified raw argument (i.e. the cache key the client will use)
1197
+ * @param {RequestEvent} event
1198
+ * @param {RequestState} state
1199
+ * @param {() => AsyncGenerator<any, void, void>} get_generator
1200
+ * @returns {RemoteLiveQuery<any>}
1201
+ */
1202
+ function create_live_query_resource(__, payload, event, state, get_generator) {
1203
+ /** @type {Promise<any> | null} */
1204
+ let promise = null;
1205
+ const get_first_value = async () => {
1206
+ for await (const value of get_generator()) return value;
1207
+ remote_query_live_no_value({ name: __.name });
1208
+ };
1209
+ const get_promise = () => {
1210
+ return promise ??= get_response(__, payload, state, get_first_value);
1211
+ };
1212
+ const populate_hydratable = () => {
1213
+ if (__.id && state.is_in_render) get_promise().catch(noop);
1214
+ };
1215
+ return {
1216
+ /** @type {Promise<any>['catch']} */
1217
+ catch(onrejected) {
1218
+ return get_promise().catch(onrejected);
1219
+ },
1220
+ get current() {
1221
+ populate_hydratable();
1222
+ },
1223
+ get error() {
1224
+ populate_hydratable();
1225
+ },
1226
+ /** @type {Promise<any>['finally']} */
1227
+ finally(onfinally) {
1228
+ return get_promise().finally(onfinally);
1229
+ },
1230
+ get done() {
1231
+ populate_hydratable();
1232
+ return false;
1233
+ },
1234
+ get loading() {
1235
+ populate_hydratable();
1236
+ return true;
1237
+ },
1238
+ get ready() {
1239
+ populate_hydratable();
1240
+ return false;
1241
+ },
1242
+ get connected() {
1243
+ populate_hydratable();
1244
+ return false;
1245
+ },
1246
+ reconnect() {
1247
+ promise = null;
1248
+ delete get_cache(__, state)[payload];
1249
+ refresh(event, state, __, payload, get_promise);
1250
+ return Promise.resolve();
1251
+ },
1252
+ /** @type {Promise<any>['then']} */
1253
+ then(onfulfilled, onrejected) {
1254
+ return get_promise().then(onfulfilled, onrejected);
1255
+ },
1256
+ [Symbol.asyncIterator]() {
1257
+ const key = create_remote_key(__.id, payload);
1258
+ const cache = state.remote.live_iterators ??= /* @__PURE__ */ new Map();
1259
+ let cached = cache.get(key);
1260
+ if (!cached) {
1261
+ cached = create_shared_live_iterator(event.request.signal, get_generator);
1262
+ cache.set(key, cached);
1263
+ }
1264
+ return cached.subscribe();
1265
+ },
1266
+ get [Symbol.toStringTag]() {
1267
+ return "LiveQueryResource";
1268
+ }
1269
+ };
1270
+ }
1271
+ /**
1272
+ * Wraps a lazily-created live-query generator so that multiple `for await`
1273
+ * consumers within the same request share one underlying iteration. The first
1274
+ * subscriber starts the generator; values are broadcast to all subscribers
1275
+ * via a `SharedIterator`. When the last subscriber unsubscribes, the generator
1276
+ * is closed via `generator.return(undefined)`.
1277
+ *
1278
+ * If `signal` aborts (typically because the client has disconnected), the
1279
+ * pump is torn down and any in-flight `next()` calls on consumer iterators
1280
+ * resolve with `{ done: true }`, so suspended `for await` loops unwind
1281
+ * cleanly rather than leaking.
1282
+ *
1283
+ * @param {AbortSignal} signal
1284
+ * @param {() => AsyncGenerator<any, void, void>} get_generator
1285
+ */
1286
+ function create_shared_live_iterator(signal, get_generator) {
1287
+ return new SharedIterator((instance) => {
1288
+ if (signal.aborted) {
1289
+ instance.done();
1290
+ return noop;
1291
+ }
1292
+ const generator = get_generator();
1293
+ let aborted = false;
1294
+ const close = () => {
1295
+ aborted = true;
1296
+ generator.return().catch(noop);
1297
+ };
1298
+ signal.addEventListener("abort", () => (close(), instance.done()), { once: true });
1299
+ (async () => {
1300
+ try {
1301
+ while (true) {
1302
+ const result = await generator.next();
1303
+ if (result.done) {
1304
+ instance.done();
1305
+ return;
1306
+ }
1307
+ instance.push(result.value);
1308
+ }
1309
+ } catch (error) {
1310
+ if (!aborted) instance.fail(error);
1311
+ } finally {
1312
+ close();
1313
+ }
1314
+ })();
1315
+ return close;
1316
+ });
1317
+ }
1318
+ Object.defineProperty(query, "batch", {
1319
+ value: batch,
1320
+ enumerable: true
1321
+ });
1322
+ Object.defineProperty(query, "live", {
1323
+ value: live,
1324
+ enumerable: true
1325
+ });
1326
+ // ../../node_modules/.pnpm/@sveltejs+kit@3.2.0_@sveltejs+vite-plugin-svelte@7.3.1_svelte@5.57.3_@typescript-eslint_ccfe35d88efff66f949c986fae0769d3/node_modules/@sveltejs/kit/src/runtime/app/server/remote/requested.js
1327
+ /** @import { RemoteLiveQuery, RemoteLiveQueryFunction, RemoteQuery, RemoteQueryFunction, RequestedResult, RemoteQueryRequestedResult, RemoteLiveQueryRequestedResult } from '$app/server' */
1328
+ /** @import { MaybePromise, RemoteAnyQueryInternals } from 'types' */
1329
+ /**
1330
+ * Inside a remote `command` or `form` callback, returns an iterable
1331
+ * of `{ arg, query }` entries for the query instances the client asked to refresh, up to
1332
+ * the supplied `limit`. Each `query` is a `RemoteQuery` bound to the original
1333
+ * client-side cache key, so `refresh()` / `set()` propagate correctly even when
1334
+ * the query's schema transforms the input. `arg` is the *validated* argument,
1335
+ * i.e. the value after the schema has run (so `InferOutput<Schema>` for queries
1336
+ * declared with a Standard Schema).
1337
+ *
1338
+ * Arguments that fail validation or exceed `limit` are recorded as failures in
1339
+ * the response to the client.
1340
+ * See [Client-requested refreshes](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations-Client-requested-refreshes)
1341
+ * for usage in a remote `command` or `form`.
1342
+ *
1343
+ * @example
1344
+ * ```ts
1345
+ * import { requested } from '$app/server';
1346
+ *
1347
+ * for (const { arg, query } of requested(getPost, 5)) {
1348
+ * // `arg` is the validated argument; `query` is bound to the client's
1349
+ * // cache key. It's safe to throw away this promise -- SvelteKit will
1350
+ * // await it and forward any errors to the client.
1351
+ * void query.refresh();
1352
+ * }
1353
+ * ```
1354
+ *
1355
+ * As a shorthand for the above, you can also call `refreshAll` on the result:
1356
+ *
1357
+ * @example
1358
+ * ```ts
1359
+ * import { requested } from '$app/server';
1360
+ *
1361
+ * await requested(getPost, 5).refreshAll();
1362
+ * ```
1363
+ *
1364
+ * Works with `query.batch` as well — refreshes for individual entries are
1365
+ * collected into a single batched call.
1366
+ *
1367
+ * For live queries, the same applies, but with `reconnect` and `reconnectAll`.
1368
+ *
1369
+ * @template Input
1370
+ * @template Output
1371
+ * @template [Validated=Input]
1372
+ * @overload
1373
+ * @param {RemoteQueryFunction<Input, Output, Validated>} query
1374
+ * @param {number} limit
1375
+ * @returns {RemoteQueryRequestedResult<Validated, Output>}
1376
+ */
1377
+ /**
1378
+ * Inside a remote `command` or `form` callback, returns an iterable
1379
+ * of `{ arg, query }` entries for the live query instances the client asked to reconnect, up to
1380
+ * the supplied `limit`. Each `query` is a `RemoteLiveQuery` bound to the original
1381
+ * client-side cache key, so `reconnect()` propagates correctly even when
1382
+ * the query's schema transforms the input. `arg` is the *validated* argument.
1383
+ *
1384
+ * Arguments that fail validation or exceed `limit` are recorded as failures in
1385
+ * the response to the client.
1386
+ * See [Client-requested refreshes](https://svelte.dev/docs/kit/remote-functions#Single-flight-mutations-Client-requested-refreshes)
1387
+ * for usage in a remote `command` or `form`.
1388
+ *
1389
+ * @example
1390
+ * ```ts
1391
+ * import { requested } from '$app/server';
1392
+ *
1393
+ * for (const { query } of requested(getPost, 5)) {
1394
+ * void query.reconnect();
1395
+ * }
1396
+ * ```
1397
+ *
1398
+ * As a shorthand, you can also call `reconnectAll` on the result:
1399
+ *
1400
+ * @example
1401
+ * ```ts
1402
+ * import { requested } from '$app/server';
1403
+ *
1404
+ * await requested(getPost, 5).reconnectAll();
1405
+ * ```
1406
+ *
1407
+ * @template Input
1408
+ * @template Output
1409
+ * @template [Validated=Input]
1410
+ * @overload
1411
+ * @param {RemoteLiveQueryFunction<Input, Output, Validated>} query
1412
+ * @param {number} limit
1413
+ * @returns {RemoteLiveQueryRequestedResult<Validated, Output>}
1414
+ */
1415
+ /**
1416
+ * @template Input
1417
+ * @template Output
1418
+ * @template [Validated=Input]
1419
+ * @param {RemoteQueryFunction<Input, Output, Validated> | RemoteLiveQueryFunction<Input, Output, Validated>} query
1420
+ * @param {number} limit
1421
+ * @returns {RequestedResult<Validated, Output>}
1422
+ */
1423
+ function requested(query, limit) {
1424
+ const { event, state } = get_request_store();
1425
+ const internals = query.__;
1426
+ if (internals?.type !== "query" && internals?.type !== "query_batch" && internals?.type !== "query_live") remote_requested_invalid_query();
1427
+ const __ = internals;
1428
+ const requested = state.remote.requested;
1429
+ const payloads = requested?.get(__.id) ?? /* @__PURE__ */ new Set();
1430
+ const ignored = state.remote.ignored ??= /* @__PURE__ */ new Set();
1431
+ /** @param {string} payload */
1432
+ const consume = (payload) => {
1433
+ payloads.delete(payload);
1434
+ if (payloads.size === 0) requested?.delete(__.id);
1435
+ };
1436
+ /** @param {string} payload */
1437
+ const create_ignore = (payload) => () => {
1438
+ ignored.add(create_remote_key(__.id, payload));
1439
+ };
1440
+ if (!state.is_in_remote_form_or_command) remote_requested_context();
1441
+ const [selected, skipped] = split_limit([...payloads], limit);
1442
+ /**
1443
+ * Registers the failure exactly like `.set()` registers a value: the error record
1444
+ * is serialized to the client (putting the query there into a failed state), and
1445
+ * subsequent server-side calls of the query with the same argument reject with it.
1446
+ * @param {string} payload
1447
+ * @param {unknown} error
1448
+ */
1449
+ const record_failure = (payload, error) => {
1450
+ const promise = Promise.reject(error);
1451
+ promise.catch(noop);
1452
+ get_cache(__, state)[payload] = promise;
1453
+ refresh(event, state, __, payload, () => promise);
1454
+ };
1455
+ for (const payload of skipped) consume(payload);
1456
+ const result = {
1457
+ *[Symbol.iterator]() {
1458
+ for (const payload of selected) {
1459
+ consume(payload);
1460
+ try {
1461
+ const parsed = parse_remote_arg(payload);
1462
+ const validated = __.validate(parsed);
1463
+ if (is_thenable(validated)) remote_requested_async_validator({
1464
+ name: __.name,
1465
+ limit: String(limit)
1466
+ });
1467
+ yield {
1468
+ arg: validated,
1469
+ query: __.bind(payload, validated),
1470
+ ignore: create_ignore(payload)
1471
+ };
1472
+ } catch (error) {
1473
+ record_failure(payload, error);
1474
+ continue;
1475
+ }
1476
+ }
1477
+ },
1478
+ async *[Symbol.asyncIterator]() {
1479
+ yield* race_all(selected, async (payload) => {
1480
+ consume(payload);
1481
+ try {
1482
+ const parsed = parse_remote_arg(payload);
1483
+ const validated = await __.validate(parsed);
1484
+ return {
1485
+ arg: validated,
1486
+ query: __.bind(payload, validated),
1487
+ ignore: create_ignore(payload)
1488
+ };
1489
+ } catch (error) {
1490
+ record_failure(payload, error);
1491
+ throw new Error(`Skipping ${__.name}(${payload})`, { cause: error });
1492
+ }
1493
+ });
1494
+ },
1495
+ async refreshAll() {
1496
+ if (__.type === "query_live") remote_requested_wrong_method({
1497
+ method: "refreshAll",
1498
+ type: "live",
1499
+ replacement: "reconnectAll"
1500
+ });
1501
+ for await (const { query } of result) query.refresh();
1502
+ },
1503
+ async reconnectAll() {
1504
+ if (__.type !== "query_live") remote_requested_wrong_method({
1505
+ method: "reconnectAll",
1506
+ type: "regular",
1507
+ replacement: "refreshAll"
1508
+ });
1509
+ for await (const { query } of result) query.reconnect();
1510
+ },
1511
+ async ignoreAll() {
1512
+ for await (const { ignore } of result) ignore();
1513
+ }
1514
+ };
1515
+ return result;
1516
+ }
1517
+ /**
1518
+ * @template T
1519
+ * @param {Array<T>} array
1520
+ * @param {number} limit
1521
+ * @returns {[Array<T>, Array<T>]}
1522
+ */
1523
+ function split_limit(array, limit) {
1524
+ if (limit === Infinity) return [array, []];
1525
+ if (!Number.isInteger(limit) || limit < 0) remote_requested_invalid_limit();
1526
+ return [array.slice(0, limit), array.slice(limit)];
1527
+ }
1528
+ /**
1529
+ * @param {any} value
1530
+ * @returns {value is PromiseLike<any>}
1531
+ */
1532
+ function is_thenable(value) {
1533
+ return !!value && (typeof value === "object" || typeof value === "function") && "then" in value;
1534
+ }
1535
+ /**
1536
+ * Runs all callbacks immediately and yields resolved values in completion order.
1537
+ * If the promise rejects, it is skipped.
1538
+ *
1539
+ * @template T
1540
+ * @template R
1541
+ * @param {Array<T>} array
1542
+ * @param {(value: T) => MaybePromise<R>} fn
1543
+ * @returns {AsyncIterable<R>}
1544
+ */
1545
+ async function* race_all(array, fn) {
1546
+ /** @type {Set<Promise<{ promise: Promise<any>, value: Awaited<R> }>>} */
1547
+ const pending = /* @__PURE__ */ new Set();
1548
+ for (const value of array) {
1549
+ /** @type {Promise<{ promise: Promise<any>, value: Awaited<R> }>} */
1550
+ const promise = Promise.resolve(fn(value)).then((result) => ({
1551
+ promise,
1552
+ value: result
1553
+ }));
1554
+ promise.catch(() => pending.delete(promise));
1555
+ pending.add(promise);
1556
+ }
1557
+ while (pending.size > 0) try {
1558
+ const { promise, value } = await Promise.race(pending);
1559
+ pending.delete(promise);
1560
+ yield value;
1561
+ } catch {}
1562
+ }
1563
+ export { command as a, form as i, query as n, prerender as r, requested as t };
1564
+
1565
+ //# sourceMappingURL=remote.js.map