@solidjs/web 2.0.0-beta.32 → 2.0.0-beta.33

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 (52) hide show
  1. package/dist/dev.cjs +51 -15
  2. package/dist/dev.js +47 -16
  3. package/dist/server.cjs +710 -71
  4. package/dist/server.js +707 -74
  5. package/dist/web.cjs +51 -15
  6. package/dist/web.js +47 -16
  7. package/frames/dist/client.cjs +181 -64
  8. package/frames/dist/client.dev.cjs +185 -64
  9. package/frames/dist/client.dev.js +183 -62
  10. package/frames/dist/client.js +179 -62
  11. package/frames/dist/server.cjs +969 -133
  12. package/frames/dist/server.js +971 -135
  13. package/package.json +17 -6
  14. package/serialization/decode/package.json +20 -0
  15. package/serialization/dist/decode.cjs +110 -0
  16. package/serialization/dist/decode.js +104 -0
  17. package/serialization/dist/serialization.cjs +98 -43
  18. package/serialization/dist/serialization.js +99 -44
  19. package/serialization/types/index.d.ts +18 -160
  20. package/serialization/types/serializer-decode.d.ts +182 -0
  21. package/serialization/types-cjs/index.d.cts +18 -160
  22. package/serialization/types-cjs/serializer-decode.d.cts +182 -0
  23. package/server-functions/dist/client.cjs +101 -105
  24. package/server-functions/dist/client.js +101 -105
  25. package/server-functions/dist/server.cjs +131 -107
  26. package/server-functions/dist/server.dev.cjs +131 -107
  27. package/server-functions/dist/server.dev.js +132 -108
  28. package/server-functions/dist/server.js +132 -108
  29. package/types/client.d.ts +23 -1
  30. package/types/cookies.d.ts +93 -0
  31. package/types/core.d.ts +1 -1
  32. package/types/frames/frame-client.d.ts +26 -0
  33. package/types/frames/frame-transport.d.ts +1 -1
  34. package/types/frames/serializer.d.ts +18 -160
  35. package/types/serializer-decode.d.ts +182 -0
  36. package/types/serializer.d.ts +18 -160
  37. package/types/server-functions/client.d.ts +1 -1
  38. package/types/server-functions/server.d.ts +1 -1
  39. package/types/server-functions/shared.d.ts +57 -1
  40. package/types/server.d.ts +21 -1
  41. package/types-cjs/client.d.cts +23 -1
  42. package/types-cjs/cookies.d.cts +93 -0
  43. package/types-cjs/core.d.cts +1 -1
  44. package/types-cjs/frames/frame-client.d.cts +26 -0
  45. package/types-cjs/frames/frame-transport.d.cts +1 -1
  46. package/types-cjs/frames/serializer.d.cts +18 -160
  47. package/types-cjs/serializer-decode.d.cts +182 -0
  48. package/types-cjs/serializer.d.cts +18 -160
  49. package/types-cjs/server-functions/client.d.cts +1 -1
  50. package/types-cjs/server-functions/server.d.cts +1 -1
  51. package/types-cjs/server-functions/shared.d.cts +57 -1
  52. package/types-cjs/server.d.cts +21 -1
@@ -0,0 +1,182 @@
1
+ // The DECODE half of the serialization surface (published as
2
+ // `@solidjs/web/serialization/decode`): what reading a serialized payload
3
+ // needs — `fromCrossJSON`-backed deserializers and the shared plugin set —
4
+ // with none of the encode machinery. Lazy client consumers (the frames
5
+ // data tables, `deserializeStream`) load this module so the encode half
6
+ // never ships to a browser that only reads. The full serializer.d.ts
7
+ // re-exports everything here; see its banner for the stability contract
8
+ // (integration-facing, exempt from the 2.0 stability guarantee).
9
+ // ---- Plugin types ----
10
+ //
11
+ // Declared here by hand (seroval's published d.ts use extensionless
12
+ // ESM-relative imports that `moduleResolution: "nodenext"` cannot follow —
13
+ // a bare type re-export would silently degrade the surface to `any` under
14
+ // skipLibCheck, and an import would make every entry whose types reach
15
+ // this module — the MAIN client entry included, via the server-function
16
+ // seam's `JSONCodecOptions` — unimportable from a strict Node16 CJS
17
+ // consumer). The declarations mirror seroval ~1.5 exactly; the `~` pin is
18
+ // what makes mirroring safe. Plugin AUTHORING (`createPlugin`,
19
+ // `OpaqueReference`) lives on the full serialization entry.
20
+
21
+ /**
22
+ * Seroval's node shape — the intermediate representation `serializeJSON`
23
+ * emits and `createJSONDeserializer` consumes. Safe to `JSON.stringify`.
24
+ * Declared by hand like the plugin types below (same rationale): the
25
+ * observable envelope — a numeric type tag, an optional reference id —
26
+ * with the rest owned by the codec. Real seroval nodes satisfy it; treat
27
+ * it as an opaque token.
28
+ *
29
+ * Integration-facing; may change (see the entry banner).
30
+ */
31
+ export interface SerovalNode {
32
+ /** Node type tag (seroval-internal enum). */
33
+ t: number;
34
+ /** Reference id, when the node participates in cross-referencing. */
35
+ i?: number | undefined;
36
+ [key: string]: unknown;
37
+ }
38
+
39
+ /** Per-plugin bookkeeping seroval hands each plugin callback. */
40
+ export interface PluginData {
41
+ id: number;
42
+ }
43
+
44
+ /**
45
+ * The shape of a plugin's parsed payload: a map of `SerovalNode`s produced
46
+ * by the parse contexts, consumed by `serialize`/`deserialize`.
47
+ */
48
+ export type PluginInfo = { [key: string]: SerovalNode };
49
+
50
+ /** Parse context for `parse.sync`: turns child values into nodes. */
51
+ export interface SyncParsePluginContext {
52
+ parse<T>(current: T): SerovalNode;
53
+ }
54
+
55
+ /** Parse context for `parse.async`: like sync, but child parses await. */
56
+ export interface AsyncParsePluginContext {
57
+ parse<T>(current: T): Promise<SerovalNode>;
58
+ }
59
+
60
+ /**
61
+ * Parse context for `parse.stream`: sync parsing plus the streaming
62
+ * lifecycle (pending-state tracking, late node emission, cleanup).
63
+ */
64
+ export interface StreamParsePluginContext {
65
+ parse<T>(current: T): SerovalNode;
66
+ parseWithError<T>(current: T): SerovalNode | undefined;
67
+ isAlive(): boolean;
68
+ pushPendingState(): void;
69
+ popPendingState(): void;
70
+ onParse(node: SerovalNode): void;
71
+ onError(error: unknown): void;
72
+ addCleanup(callback: () => void): void;
73
+ }
74
+
75
+ /** Serialize context: renders child nodes to JS source. */
76
+ export interface SerializePluginContext {
77
+ serialize(node: SerovalNode): string;
78
+ }
79
+
80
+ /** Deserialize context: revives child nodes to runtime values. */
81
+ export interface DeserializePluginContext {
82
+ deserialize<T>(node: SerovalNode): T;
83
+ }
84
+
85
+ /**
86
+ * A Seroval plugin usable with the web serializers — teaches the codec how
87
+ * to encode/decode a custom value type (`Value` is the value it matches,
88
+ * `Info` its parsed payload). Supply matching plugins on both peers of a
89
+ * transport. Bare `SerializerPlugin` (both parameters defaulted to `any`)
90
+ * is the list-element type every `plugins` option accepts.
91
+ *
92
+ * Integration-facing; may change (see the entry banner).
93
+ */
94
+ export interface SerializerPlugin<Value = any, Info extends PluginInfo = any> {
95
+ /** A unique string identifying the plugin — namespace it (`"app/Thing"`). */
96
+ tag: string;
97
+ /** Dependency plugins, resolved ahead of this one. */
98
+ extends?: SerializerPlugin[];
99
+ /** Whether `value` is this plugin's to encode. */
100
+ test(value: unknown): boolean;
101
+ /** Parsing modes — provide the ones the transports you target use. */
102
+ parse: {
103
+ sync?: (value: Value, ctx: SyncParsePluginContext, data: PluginData) => Info;
104
+ async?: (value: Value, ctx: AsyncParsePluginContext, data: PluginData) => Promise<Info>;
105
+ stream?: (value: Value, ctx: StreamParsePluginContext, data: PluginData) => Info;
106
+ };
107
+ /** Renders the parsed payload as JS source (script-injection form). */
108
+ serialize(node: Info, ctx: SerializePluginContext, data: PluginData): string;
109
+ /** Revives the parsed payload back into the runtime value. */
110
+ deserialize(node: Info, ctx: DeserializePluginContext, data: PluginData): Value;
111
+ }
112
+
113
+ /**
114
+ * Baseline plugin set for serializing web-platform values (AbortSignal,
115
+ * Event, FormData, Headers, ReadableStream, Request, Response, URL, ...).
116
+ * Applied by every serializer in this module; custom plugins compose ahead
117
+ * of it via `resolveSerializerPlugins`.
118
+ *
119
+ * Integration-facing; may change (see the entry banner).
120
+ */
121
+ export const DEFAULT_WEB_PLUGINS: readonly SerializerPlugin[];
122
+
123
+ /**
124
+ * Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
125
+ * first so they can shadow a default for values both would match. Returns a
126
+ * fresh array; the defaults are never mutated. Useful when handing a full
127
+ * plugin list to another serialization layer.
128
+ *
129
+ * Integration-facing; may change (see the entry banner).
130
+ */
131
+ export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
132
+
133
+ /**
134
+ * Options shared by both halves of the JSON codec. All of them must match
135
+ * on the serializing and deserializing peer or payloads will not
136
+ * round-trip — for server functions, set them once through the
137
+ * client/server `codec` config option.
138
+ *
139
+ * Integration-facing; may change (see the entry banner).
140
+ */
141
+ export interface JSONCodecOptions {
142
+ /** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. Must match on both peers. */
143
+ plugins?: SerializerPlugin[];
144
+ /**
145
+ * Seroval feature bitflags to exclude. Defaults to disabling `RegExp`
146
+ * (payloads may come from an untrusted peer). Must match on both peers.
147
+ * Outside development, the encoding side additionally strips
148
+ * `Error.prototype.stack` on top of any override — serialized stacks leak
149
+ * server paths to the client. Decoding stays permissive, so payloads from
150
+ * a development peer still round-trip.
151
+ */
152
+ disabledFeatures?: number;
153
+ /** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
154
+ depthLimit?: number;
155
+ }
156
+
157
+ /**
158
+ * Creates the decoding counterpart of `serializeJSON`. Cross-references
159
+ * between chunks resolve through state shared across calls, so all chunks
160
+ * from one stream must go through the same deserializer instance. The first
161
+ * chunk's return value is the decoded source value; feeding later chunks
162
+ * settles the async values referenced inside it.
163
+ *
164
+ * Integration-facing; may change (see the entry banner).
165
+ */
166
+ export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
167
+
168
+ /**
169
+ * A resident, response-scoped decode table over the keyed JSON codec: apply
170
+ * each frame `data` chunk with `apply`, resolve `{ $ref }` slot args with
171
+ * `resolve`. The frames client host wires one per response
172
+ * (`applyData: c => table.apply(c)`).
173
+ *
174
+ * Integration-facing; may change (see the entry banner). This serialization
175
+ * entry is the single home of the data table — the frames client consumes
176
+ * it internally rather than re-exporting it.
177
+ */
178
+ export interface JSONDataTable {
179
+ apply(chunk: { key?: string; node?: unknown; initial?: boolean }): void;
180
+ resolve<T = unknown>(ref: { $ref: string }): T;
181
+ }
182
+ export function createJSONDataTable(options?: JSONCodecOptions): JSONDataTable;
@@ -1,55 +1,35 @@
1
1
  'use strict';
2
2
 
3
- var seroval = require('seroval');
4
- var web = require('seroval-plugins/web');
5
-
6
3
  const REVALIDATE_HEADER = "X-Revalidate";
7
4
 
8
- seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
9
- const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : seroval.Feature.ErrorPrototypeStack;
10
- const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
11
- web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
12
- web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin]);
13
- function resolveSerializerPlugins(customPlugins) {
14
- return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
15
- }
16
- const JSON_CODEC_DISABLED_FEATURES = seroval.Feature.RegExp;
17
- const JSON_CODEC_DEPTH_LIMIT = 64;
18
- function resolveCodecOptions({
19
- plugins,
20
- disabledFeatures,
21
- depthLimit
22
- } = {}) {
23
- return {
24
- plugins: resolveSerializerPlugins(plugins),
25
- disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
26
- depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit
27
- };
5
+ const SERVER_FUNCTION_METADATA = Symbol.for("solid.ServerFunctionMetadata");
6
+ function getServerFunctionMetadata(fn) {
7
+ if (typeof fn !== "function") return undefined;
8
+ return fn[SERVER_FUNCTION_METADATA] || undefined;
28
9
  }
29
- function serializeJSON(value, {
30
- onParse,
31
- onDone,
32
- onError,
33
- ...codecOptions
34
- }) {
35
- const resolved = resolveCodecOptions(codecOptions);
36
- return seroval.toCrossJSONStream(value, {
37
- onParse,
38
- onDone,
39
- onError,
40
- ...resolved,
41
- disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures()
42
- });
10
+ function isServerFunction(fn) {
11
+ return typeof fn === "function" && !!fn[SERVER_FUNCTION_METADATA];
43
12
  }
44
- function createJSONDeserializer(options) {
45
- const refs = new Map();
46
- const resolved = resolveCodecOptions(options);
47
- return function deserializeJSONChunk(node) {
48
- return seroval.fromCrossJSON(node, {
49
- refs,
50
- ...resolved
51
- });
52
- };
13
+ function withMeta(fn, meta) {
14
+ const metadata = getServerFunctionMetadata(fn);
15
+ if (!metadata) {
16
+ throw new Error("withMeta expects a server function reference");
17
+ }
18
+ Object.assign(metadata, meta);
19
+ return fn;
20
+ }
21
+ const SERVER_FUNCTION_RPC = Symbol.for("solid.ServerFunctionRPC");
22
+ function provideServerFunctionRPC(rpc) {
23
+ globalThis[SERVER_FUNCTION_RPC] || (globalThis[SERVER_FUNCTION_RPC] = rpc);
24
+ }
25
+
26
+ const FLASH_COOKIE = "flash";
27
+ const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
28
+ function hasFlashCookie(cookieHeader) {
29
+ return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
30
+ }
31
+ function clearFlashCookie() {
32
+ return `${FLASH_COOKIE}=; Max-Age=0; Path=/`;
53
33
  }
54
34
 
55
35
  const codecConfig = {
@@ -117,22 +97,6 @@ function stableString(value, seen) {
117
97
  }
118
98
  return out + "}";
119
99
  }
120
- const SERVER_FUNCTION_METADATA = Symbol.for("solid.ServerFunctionMetadata");
121
- function getServerFunctionMetadata(fn) {
122
- if (typeof fn !== "function") return undefined;
123
- return fn[SERVER_FUNCTION_METADATA] || undefined;
124
- }
125
- function isServerFunction(fn) {
126
- return typeof fn === "function" && !!fn[SERVER_FUNCTION_METADATA];
127
- }
128
- function withMeta(fn, meta) {
129
- const metadata = getServerFunctionMetadata(fn);
130
- if (!metadata) {
131
- throw new Error("withMeta expects a server function reference");
132
- }
133
- Object.assign(metadata, meta);
134
- return fn;
135
- }
136
100
  const FUNCTION_HEADER = "X-Server-Function-Id";
137
101
  const ERROR_HEADER = "X-Server-Function-Error";
138
102
  const ERROR_HEADER_MARKER = "=?1?";
@@ -163,14 +127,6 @@ const INSTANCE_HEADER = "X-Server-Function-Instance";
163
127
  const BODY_FORMAT_HEADER = "X-Server-Function-Format";
164
128
  const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
165
129
  const FILE_FORM_KEY = "__server_function_file__";
166
- const FLASH_COOKIE = "flash";
167
- const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
168
- function hasFlashCookie(cookieHeader) {
169
- return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
170
- }
171
- function clearFlashCookie() {
172
- return `${FLASH_COOKIE}=; Max-Age=0; Path=/`;
173
- }
174
130
  const BodyFormat = {
175
131
  Serialized: "0",
176
132
  String: "1",
@@ -182,6 +138,38 @@ const BodyFormat = {
182
138
  Uint8Array: "7",
183
139
  Json: "8"
184
140
  };
141
+ const JSON_SAFE_DEPTH_LIMIT = 10000;
142
+ const EXIT = {};
143
+ function isJSONSafe(value) {
144
+ const stack = [value];
145
+ const ancestors = new Set();
146
+ while (stack.length) {
147
+ const v = stack.pop();
148
+ if (v === EXIT) {
149
+ ancestors.delete(stack.pop());
150
+ continue;
151
+ }
152
+ if (v === null) continue;
153
+ const t = typeof v;
154
+ if (t === "string" || t === "boolean") continue;
155
+ if (t === "number") {
156
+ if (!Number.isFinite(v)) return false;
157
+ continue;
158
+ }
159
+ if (t !== "object") return false;
160
+ if (ancestors.has(v) || ancestors.size >= JSON_SAFE_DEPTH_LIMIT) return false;
161
+ ancestors.add(v);
162
+ stack.push(v, EXIT);
163
+ if (Array.isArray(v)) {
164
+ for (let i = 0; i < v.length; i++) stack.push(v[i]);
165
+ } else {
166
+ const proto = Object.getPrototypeOf(v);
167
+ if (proto !== Object.prototype && proto !== null) return false;
168
+ for (const k in v) stack.push(v[k]);
169
+ }
170
+ }
171
+ return true;
172
+ }
185
173
  function getHeadersAndBody(body) {
186
174
  switch (true) {
187
175
  case typeof body === "string":
@@ -341,7 +329,10 @@ class ChunkReader {
341
329
  }
342
330
  function serializeStream(value, codecOptions) {
343
331
  return new ReadableStream({
344
- start(controller) {
332
+ async start(controller) {
333
+ const {
334
+ serializeJSON
335
+ } = await import('@solidjs/web/serialization');
345
336
  serializeJSON(value, {
346
337
  ...codecOptions,
347
338
  onParse(node) {
@@ -368,6 +359,9 @@ async function deserializeStream(source, codecOptions) {
368
359
  const reader = new ChunkReader(source.body);
369
360
  const result = await reader.next();
370
361
  if (!result.done) {
362
+ const {
363
+ createJSONDeserializer
364
+ } = await import('@solidjs/web/serialization/decode');
371
365
  const deserializeChunk = createJSONDeserializer(codecOptions);
372
366
  function interpretChunk(chunk) {
373
367
  return deserializeChunk(JSON.parse(chunk));
@@ -400,21 +394,6 @@ const config = {
400
394
  responseHandler: undefined,
401
395
  serializeArgs: undefined
402
396
  };
403
- function isJSONSafe(value) {
404
- if (value === null) return true;
405
- const t = typeof value;
406
- if (t === "string" || t === "boolean") return true;
407
- if (t === "number") return Number.isFinite(value);
408
- if (t !== "object") return false;
409
- if (Array.isArray(value)) {
410
- for (const v of value) if (!isJSONSafe(v)) return false;
411
- return true;
412
- }
413
- const proto = Object.getPrototypeOf(value);
414
- if (proto !== Object.prototype && proto !== null) return false;
415
- for (const k in value) if (!isJSONSafe(value[k])) return false;
416
- return true;
417
- }
418
397
  function serializeArguments(args) {
419
398
  if (!config.serializeArgs) {
420
399
  throw new Error("Server function arguments are sent as JSON by default and these " + "arguments are not JSON-serializable. Call enableRichArguments() " + '(from "@solidjs/web/server-functions/rich-args") once at startup ' + "to send Dates, Maps, Sets, typed arrays, etc. through the codec — " + "or pass a single Blob/FormData/File argument, which has a native " + "HTTP encoding.");
@@ -435,6 +414,15 @@ function configureServerFunctionsClient({
435
414
  if (serializeArgs !== undefined) config.serializeArgs = serializeArgs;
436
415
  }
437
416
  let INSTANCE = 0;
417
+ let rpcProvided = false;
418
+ function provideRPC() {
419
+ if (rpcProvided) return;
420
+ rpcProvided = true;
421
+ provideServerFunctionRPC({
422
+ GET,
423
+ decodeResponse
424
+ });
425
+ }
438
426
  async function createRequest(base, id, instance, options, meta) {
439
427
  const headers = {
440
428
  ...options.headers,
@@ -474,31 +462,37 @@ async function initializeResponse(base, id, instance, options, args, meta) {
474
462
  }, meta);
475
463
  }
476
464
  }
477
- if (isJSONSafe(args)) {
478
- return createRequest(base, id, instance, {
479
- ...options,
480
- body: JSON.stringify(args),
481
- headers: {
482
- ...options.headers,
483
- "Content-Type": "application/json",
484
- [BODY_FORMAT_HEADER]: BodyFormat.Json
485
- }
486
- }, meta);
487
- }
488
- if (args.length > 1) {
489
- const trailing = getHeadersAndBody(args[args.length - 1]);
490
- const leading = args.slice(0, -1).map(arg => arg === undefined ? null : arg);
491
- if (trailing && isJSONSafe(leading)) {
492
- const target = base + (base.includes("?") ? "&" : "?") + "args=" + encodeURIComponent(JSON.stringify(leading));
493
- return createRequest(target, id, instance, {
465
+ try {
466
+ if (isJSONSafe(args)) {
467
+ return createRequest(base, id, instance, {
494
468
  ...options,
495
- body: trailing.body,
469
+ body: JSON.stringify(args),
496
470
  headers: {
497
471
  ...options.headers,
498
- ...trailing.headers
472
+ "Content-Type": "application/json",
473
+ [BODY_FORMAT_HEADER]: BodyFormat.Json
499
474
  }
500
475
  }, meta);
501
476
  }
477
+ } catch {
478
+ }
479
+ if (args.length > 1) {
480
+ try {
481
+ const trailing = getHeadersAndBody(args[args.length - 1]);
482
+ const leading = args.slice(0, -1).map(arg => arg === undefined ? null : arg);
483
+ if (trailing && isJSONSafe(leading)) {
484
+ const target = base + (base.includes("?") ? "&" : "?") + "args=" + encodeURIComponent(JSON.stringify(leading));
485
+ return createRequest(target, id, instance, {
486
+ ...options,
487
+ body: trailing.body,
488
+ headers: {
489
+ ...options.headers,
490
+ ...trailing.headers
491
+ }
492
+ }, meta);
493
+ }
494
+ } catch {
495
+ }
502
496
  }
503
497
  return createRequest(base, id, instance, {
504
498
  ...options,
@@ -550,6 +544,7 @@ async function fetchServerFunction(base, id, options, args, meta, callArgs = arg
550
544
  return result;
551
545
  }
552
546
  function createServerReference(id, name, base) {
547
+ provideRPC();
553
548
  const metadata = name === undefined ? {} : {
554
549
  name
555
550
  };
@@ -580,6 +575,7 @@ function GET(fn) {
580
575
  if (!isServerFunction(fn)) {
581
576
  throw new Error("GET expects a server function reference");
582
577
  }
578
+ provideRPC();
583
579
  const id = fn.id;
584
580
  const metadata = {
585
581
  ...getServerFunctionMetadata(fn)