MCPcopy
hub / github.com/sveltejs/kit / wrapper

Function wrapper

packages/kit/src/runtime/app/server/remote/command.js:67–86  ·  view source on GitHub ↗
(arg)

Source from the content-addressed store, hash-verified

65
66 /** @type {RemoteCommand<Input, Output> & { __: RemoteInfo }} */
67 const wrapper = (arg) => {
68 const event = getRequestEvent();
69
70 if (!event.isRemoteRequest) {
71 throw new Error(
72 `Cannot call a command (\`${__.name}(${maybe_fn ? '...' : ''})\`) during server-side rendering`
73 );
74 }
75
76 get_event_state(event).refreshes ??= {};
77
78 const promise = Promise.resolve(run_remote_function(event, true, arg, validate, fn));
79
80 // @ts-expect-error
81 promise.updates = () => {
82 throw new Error(`Cannot call '${__.name}(...).updates(...)' on the server`);
83 };
84
85 return /** @type {ReturnType<RemoteCommand<Input, Output>>} */ (promise);
86 };
87
88 Object.defineProperty(wrapper, '__', { value: __ });
89

Callers

nothing calls this directly

Calls 3

getRequestEventFunction · 0.90
get_event_stateFunction · 0.90
run_remote_functionFunction · 0.90

Tested by

no test coverage detected