@solidjs/web 2.0.0-rc.16 → 2.0.0-rc.17

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.
@@ -1325,6 +1325,45 @@ function namesRefusedType(payload) {
1325
1325
  for (const tag of REFUSED_TAGS) if (payload.includes(`"c":"${tag}"`)) return true;
1326
1326
  return false;
1327
1327
  }
1328
+ function withArgumentPlugins(argumentCodec, extra) {
1329
+ return {
1330
+ ...argumentCodec,
1331
+ [RESOLVED_PLUGINS]: [...extra, ...argumentCodec[RESOLVED_PLUGINS]]
1332
+ };
1333
+ }
1334
+
1335
+ const UPLOAD_ARGS_PART = "args";
1336
+ const UPLOAD_FILE_PART = "file";
1337
+ const UPLOAD_TAG = "solid/server-function-upload";
1338
+ function isBlob(value) {
1339
+ if (typeof Blob !== "undefined" && value instanceof Blob) return true;
1340
+ return typeof value === "object" && value !== null && typeof value.size === "number" && typeof value.type === "string" && typeof value.arrayBuffer === "function" && typeof value.slice === "function";
1341
+ }
1342
+ function malformed() {
1343
+ return new TypeError("Malformed server function upload");
1344
+ }
1345
+ function createUploadDeserializer(form) {
1346
+ const refuse = () => {
1347
+ throw malformed();
1348
+ };
1349
+ return {
1350
+ tag: UPLOAD_TAG,
1351
+ test: () => false,
1352
+ parse: {
1353
+ sync: refuse,
1354
+ async: refuse,
1355
+ stream: refuse
1356
+ },
1357
+ serialize: refuse,
1358
+ deserialize: (node, ctx) => {
1359
+ const index = ctx.deserialize(node.i);
1360
+ if (typeof index !== "number" || !Number.isSafeInteger(index) || index < 0) refuse();
1361
+ const part = form.get(UPLOAD_FILE_PART + index);
1362
+ if (!isBlob(part)) refuse();
1363
+ return part;
1364
+ }
1365
+ };
1366
+ }
1328
1367
 
1329
1368
  const config = {
1330
1369
  provideEvent: undefined,
@@ -1767,6 +1806,7 @@ function live(fn) {
1767
1806
  if (!isServerFunction(fn) || typeof fn.id !== "string") {
1768
1807
  throw new Error("live expects a server function reference");
1769
1808
  }
1809
+ if (getServerFunctionMetadata(fn)?.method !== "GET") fn = GET(fn);
1770
1810
  const metadata = {
1771
1811
  ...getServerFunctionMetadata(fn),
1772
1812
  live: true
@@ -1781,6 +1821,18 @@ function live(fn) {
1781
1821
  });
1782
1822
  return wrapped;
1783
1823
  }
1824
+ function broadcast(fn) {
1825
+ const ref = live(fn);
1826
+ ref[SERVER_FUNCTION_METADATA].broadcast = true;
1827
+ BROADCASTS.add(fn.id);
1828
+ return ref;
1829
+ }
1830
+ function encodedArguments(request, argsEncoding, argumentBytes) {
1831
+ if (request.method !== "POST") return argsEncoding || "";
1832
+ if (!argumentBytes) return undefined;
1833
+ return (request.headers.get("content-type") || "") + "\0" + (argsEncoding || "") + "\0" + new TextDecoder("latin1").decode(argumentBytes);
1834
+ }
1835
+ const BROADCASTS = new Set();
1784
1836
  function brandLive(answer) {
1785
1837
  if (typeof answer === "function" || answer !== null && typeof answer === "object" && answer[Symbol.asyncIterator]) {
1786
1838
  answer[LIVE_SOURCE] = true;
@@ -1957,7 +2009,17 @@ async function parseArguments(request, url, scripted, codec, buffered) {
1957
2009
  if (bodyFormat === BodyFormat.Serialized) {
1958
2010
  let argumentCodec = argumentCodecFor(codec);
1959
2011
  if (argumentCodec instanceof Promise) argumentCodec = await argumentCodec;
1960
- decoded = await decodeArguments(wire => extractBody(body, argumentCodec, wire), buffered);
2012
+ if ((request.headers.get("content-type") || "").startsWith("multipart/form-data")) {
2013
+ const form = await body.formData();
2014
+ const encoded = form.get(UPLOAD_ARGS_PART);
2015
+ if (typeof encoded !== "string") {
2016
+ throw new TypeError("Malformed server function upload");
2017
+ }
2018
+ const uploadCodec = withArgumentPlugins(argumentCodec, [createUploadDeserializer(form)]);
2019
+ decoded = await decodeArguments(wire => deserializeStream(new Response(encoded), uploadCodec, wire), encoded);
2020
+ } else {
2021
+ decoded = await decodeArguments(wire => extractBody(body, argumentCodec, wire), buffered);
2022
+ }
1961
2023
  } else {
1962
2024
  decoded = await extractBody(body, codec);
1963
2025
  }
@@ -3062,9 +3124,12 @@ async function handleServerFunctionRequest(request, options = {}) {
3062
3124
  const dispatch = async () => {
3063
3125
  try {
3064
3126
  const invokeOnce = async () => {
3127
+ const shared = !!live && BROADCASTS.has(functionId);
3065
3128
  INVOCATIONS.set(event, {
3066
3129
  id: functionId,
3067
- live: !!live
3130
+ live: !!live,
3131
+ broadcast: shared || undefined,
3132
+ shareKey: shared ? encodedArguments(request, argsEncoding, argumentBytes) : undefined
3068
3133
  });
3069
3134
  const run = () => serverFunction(...parsed);
3070
3135
  return observeInvocation({
@@ -3314,4 +3379,4 @@ function finalizeTransportResponse(response, method) {
3314
3379
  return response;
3315
3380
  }
3316
3381
 
3317
- export { ChunkReader, ERROR_HEADER, FLASH_COOKIE, GENERIC_SERVER_ERROR_MESSAGE, GET, REDIRECT_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, UNKNOWN_HEADER, armLiveBody, clearFlashCookie, configureServerFunctionsServer, createChunk, createEventChunk, createNoJSHandler, createServerReference, decodeErrorHeaderValue, decodeFlashCookie, decodeRedirectHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, encodeFlashCookie, foldSetCookies, frameAddress, getEventServerFunctionInvocation, getServerFunction, getServerFunctionInvocation, getServerFunctionMetadata, guardFailures, handleServerFunctionRequest, hasFlashCookie, invoke, isServerFunction, live, parseServerFunctionActionUrl, registerFlightDataSource, registerServerFunction, registerServerReference, sanitizeServerError, serializeResponseStream, serializeStream, serverFunctionActionUrl, serverFunctionUrl, setServerFunctionsDev, subscribeFlightData, textDigest, withMeta };
3382
+ export { ChunkReader, ERROR_HEADER, FLASH_COOKIE, GENERIC_SERVER_ERROR_MESSAGE, GET, REDIRECT_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, UNKNOWN_HEADER, armLiveBody, broadcast, clearFlashCookie, configureServerFunctionsServer, createChunk, createEventChunk, createNoJSHandler, createServerReference, decodeErrorHeaderValue, decodeFlashCookie, decodeRedirectHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, encodeFlashCookie, foldSetCookies, frameAddress, getEventServerFunctionInvocation, getServerFunction, getServerFunctionInvocation, getServerFunctionMetadata, guardFailures, handleServerFunctionRequest, hasFlashCookie, invoke, isServerFunction, live, parseServerFunctionActionUrl, registerFlightDataSource, registerServerFunction, registerServerReference, sanitizeServerError, serializeResponseStream, serializeStream, serverFunctionActionUrl, serverFunctionUrl, setServerFunctionsDev, subscribeFlightData, textDigest, withMeta };
@@ -1243,6 +1243,45 @@ function namesRefusedType(payload) {
1243
1243
  for (const tag of REFUSED_TAGS) if (payload.includes(`"c":"${tag}"`)) return true;
1244
1244
  return false;
1245
1245
  }
1246
+ function withArgumentPlugins(argumentCodec, extra) {
1247
+ return {
1248
+ ...argumentCodec,
1249
+ [RESOLVED_PLUGINS]: [...extra, ...argumentCodec[RESOLVED_PLUGINS]]
1250
+ };
1251
+ }
1252
+
1253
+ const UPLOAD_ARGS_PART = "args";
1254
+ const UPLOAD_FILE_PART = "file";
1255
+ const UPLOAD_TAG = "solid/server-function-upload";
1256
+ function isBlob(value) {
1257
+ if (typeof Blob !== "undefined" && value instanceof Blob) return true;
1258
+ return typeof value === "object" && value !== null && typeof value.size === "number" && typeof value.type === "string" && typeof value.arrayBuffer === "function" && typeof value.slice === "function";
1259
+ }
1260
+ function malformed() {
1261
+ return new TypeError("Malformed server function upload");
1262
+ }
1263
+ function createUploadDeserializer(form) {
1264
+ const refuse = () => {
1265
+ throw malformed();
1266
+ };
1267
+ return {
1268
+ tag: UPLOAD_TAG,
1269
+ test: () => false,
1270
+ parse: {
1271
+ sync: refuse,
1272
+ async: refuse,
1273
+ stream: refuse
1274
+ },
1275
+ serialize: refuse,
1276
+ deserialize: (node, ctx) => {
1277
+ const index = ctx.deserialize(node.i);
1278
+ if (typeof index !== "number" || !Number.isSafeInteger(index) || index < 0) refuse();
1279
+ const part = form.get(UPLOAD_FILE_PART + index);
1280
+ if (!isBlob(part)) refuse();
1281
+ return part;
1282
+ }
1283
+ };
1284
+ }
1246
1285
 
1247
1286
  const config = {
1248
1287
  provideEvent: undefined,
@@ -1685,6 +1724,7 @@ function live(fn) {
1685
1724
  if (!isServerFunction(fn) || typeof fn.id !== "string") {
1686
1725
  throw new Error("live expects a server function reference");
1687
1726
  }
1727
+ if (getServerFunctionMetadata(fn)?.method !== "GET") fn = GET(fn);
1688
1728
  const metadata = {
1689
1729
  ...getServerFunctionMetadata(fn),
1690
1730
  live: true
@@ -1699,6 +1739,18 @@ function live(fn) {
1699
1739
  });
1700
1740
  return wrapped;
1701
1741
  }
1742
+ function broadcast(fn) {
1743
+ const ref = live(fn);
1744
+ ref[SERVER_FUNCTION_METADATA].broadcast = true;
1745
+ BROADCASTS.add(fn.id);
1746
+ return ref;
1747
+ }
1748
+ function encodedArguments(request, argsEncoding, argumentBytes) {
1749
+ if (request.method !== "POST") return argsEncoding || "";
1750
+ if (!argumentBytes) return undefined;
1751
+ return (request.headers.get("content-type") || "") + "\0" + (argsEncoding || "") + "\0" + new TextDecoder("latin1").decode(argumentBytes);
1752
+ }
1753
+ const BROADCASTS = new Set();
1702
1754
  function brandLive(answer) {
1703
1755
  if (typeof answer === "function" || answer !== null && typeof answer === "object" && answer[Symbol.asyncIterator]) {
1704
1756
  answer[LIVE_SOURCE] = true;
@@ -1875,7 +1927,17 @@ async function parseArguments(request, url, scripted, codec, buffered) {
1875
1927
  if (bodyFormat === BodyFormat.Serialized) {
1876
1928
  let argumentCodec = argumentCodecFor(codec);
1877
1929
  if (argumentCodec instanceof Promise) argumentCodec = await argumentCodec;
1878
- decoded = await decodeArguments(wire => extractBody(body, argumentCodec, wire), buffered);
1930
+ if ((request.headers.get("content-type") || "").startsWith("multipart/form-data")) {
1931
+ const form = await body.formData();
1932
+ const encoded = form.get(UPLOAD_ARGS_PART);
1933
+ if (typeof encoded !== "string") {
1934
+ throw new TypeError("Malformed server function upload");
1935
+ }
1936
+ const uploadCodec = withArgumentPlugins(argumentCodec, [createUploadDeserializer(form)]);
1937
+ decoded = await decodeArguments(wire => deserializeStream(new Response(encoded), uploadCodec, wire), encoded);
1938
+ } else {
1939
+ decoded = await decodeArguments(wire => extractBody(body, argumentCodec, wire), buffered);
1940
+ }
1879
1941
  } else {
1880
1942
  decoded = await extractBody(body, codec);
1881
1943
  }
@@ -2969,9 +3031,12 @@ async function handleServerFunctionRequest(request, options = {}) {
2969
3031
  const dispatch = async () => {
2970
3032
  try {
2971
3033
  const invokeOnce = async () => {
3034
+ const shared = !!live && BROADCASTS.has(functionId);
2972
3035
  INVOCATIONS.set(event, {
2973
3036
  id: functionId,
2974
- live: !!live
3037
+ live: !!live,
3038
+ broadcast: shared || undefined,
3039
+ shareKey: shared ? encodedArguments(request, argsEncoding, argumentBytes) : undefined
2975
3040
  });
2976
3041
  const run = () => serverFunction(...parsed);
2977
3042
  return observeInvocation({
@@ -3221,4 +3286,4 @@ function finalizeTransportResponse(response, method) {
3221
3286
  return response;
3222
3287
  }
3223
3288
 
3224
- export { ChunkReader, ERROR_HEADER, FLASH_COOKIE, GENERIC_SERVER_ERROR_MESSAGE, GET, REDIRECT_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, UNKNOWN_HEADER, armLiveBody, clearFlashCookie, configureServerFunctionsServer, createChunk, createEventChunk, createNoJSHandler, createServerReference, decodeErrorHeaderValue, decodeFlashCookie, decodeRedirectHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, encodeFlashCookie, foldSetCookies, frameAddress, getEventServerFunctionInvocation, getServerFunction, getServerFunctionInvocation, getServerFunctionMetadata, guardFailures, handleServerFunctionRequest, hasFlashCookie, invoke, isServerFunction, live, parseServerFunctionActionUrl, registerFlightDataSource, registerServerFunction, registerServerReference, sanitizeServerError, serializeResponseStream, serializeStream, serverFunctionActionUrl, serverFunctionUrl, setServerFunctionsDev, subscribeFlightData, textDigest, withMeta };
3289
+ export { ChunkReader, ERROR_HEADER, FLASH_COOKIE, GENERIC_SERVER_ERROR_MESSAGE, GET, REDIRECT_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, UNKNOWN_HEADER, armLiveBody, broadcast, clearFlashCookie, configureServerFunctionsServer, createChunk, createEventChunk, createNoJSHandler, createServerReference, decodeErrorHeaderValue, decodeFlashCookie, decodeRedirectHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, encodeFlashCookie, foldSetCookies, frameAddress, getEventServerFunctionInvocation, getServerFunction, getServerFunctionInvocation, getServerFunctionMetadata, guardFailures, handleServerFunctionRequest, hasFlashCookie, invoke, isServerFunction, live, parseServerFunctionActionUrl, registerFlightDataSource, registerServerFunction, registerServerReference, sanitizeServerError, serializeResponseStream, serializeStream, serverFunctionActionUrl, serverFunctionUrl, setServerFunctionsDev, subscribeFlightData, textDigest, withMeta };
@@ -1295,6 +1295,45 @@ function namesRefusedType(payload) {
1295
1295
  for (const tag of REFUSED_TAGS) if (payload.includes(`"c":"${tag}"`)) return true;
1296
1296
  return false;
1297
1297
  }
1298
+ function withArgumentPlugins(argumentCodec, extra) {
1299
+ return {
1300
+ ...argumentCodec,
1301
+ [RESOLVED_PLUGINS]: [...extra, ...argumentCodec[RESOLVED_PLUGINS]]
1302
+ };
1303
+ }
1304
+
1305
+ const UPLOAD_ARGS_PART = "args";
1306
+ const UPLOAD_FILE_PART = "file";
1307
+ const UPLOAD_TAG = "solid/server-function-upload";
1308
+ function isBlob(value) {
1309
+ if (typeof Blob !== "undefined" && value instanceof Blob) return true;
1310
+ return typeof value === "object" && value !== null && typeof value.size === "number" && typeof value.type === "string" && typeof value.arrayBuffer === "function" && typeof value.slice === "function";
1311
+ }
1312
+ function malformed() {
1313
+ return new TypeError("Malformed server function upload");
1314
+ }
1315
+ function createUploadDeserializer(form) {
1316
+ const refuse = () => {
1317
+ throw malformed();
1318
+ };
1319
+ return {
1320
+ tag: UPLOAD_TAG,
1321
+ test: () => false,
1322
+ parse: {
1323
+ sync: refuse,
1324
+ async: refuse,
1325
+ stream: refuse
1326
+ },
1327
+ serialize: refuse,
1328
+ deserialize: (node, ctx) => {
1329
+ const index = ctx.deserialize(node.i);
1330
+ if (typeof index !== "number" || !Number.isSafeInteger(index) || index < 0) refuse();
1331
+ const part = form.get(UPLOAD_FILE_PART + index);
1332
+ if (!isBlob(part)) refuse();
1333
+ return part;
1334
+ }
1335
+ };
1336
+ }
1298
1337
 
1299
1338
  const config = {
1300
1339
  provideEvent: undefined,
@@ -1737,6 +1776,7 @@ function live(fn) {
1737
1776
  if (!isServerFunction(fn) || typeof fn.id !== "string") {
1738
1777
  throw new Error("live expects a server function reference");
1739
1778
  }
1779
+ if (getServerFunctionMetadata(fn)?.method !== "GET") fn = GET(fn);
1740
1780
  const metadata = {
1741
1781
  ...getServerFunctionMetadata(fn),
1742
1782
  live: true
@@ -1751,6 +1791,18 @@ function live(fn) {
1751
1791
  });
1752
1792
  return wrapped;
1753
1793
  }
1794
+ function broadcast(fn) {
1795
+ const ref = live(fn);
1796
+ ref[SERVER_FUNCTION_METADATA].broadcast = true;
1797
+ BROADCASTS.add(fn.id);
1798
+ return ref;
1799
+ }
1800
+ function encodedArguments(request, argsEncoding, argumentBytes) {
1801
+ if (request.method !== "POST") return argsEncoding || "";
1802
+ if (!argumentBytes) return undefined;
1803
+ return (request.headers.get("content-type") || "") + "\0" + (argsEncoding || "") + "\0" + new TextDecoder("latin1").decode(argumentBytes);
1804
+ }
1805
+ const BROADCASTS = new Set();
1754
1806
  function brandLive(answer) {
1755
1807
  if (typeof answer === "function" || answer !== null && typeof answer === "object" && answer[Symbol.asyncIterator]) {
1756
1808
  answer[LIVE_SOURCE] = true;
@@ -1927,7 +1979,17 @@ async function parseArguments(request, url, scripted, codec, buffered) {
1927
1979
  if (bodyFormat === BodyFormat.Serialized) {
1928
1980
  let argumentCodec = argumentCodecFor(codec);
1929
1981
  if (argumentCodec instanceof Promise) argumentCodec = await argumentCodec;
1930
- decoded = await decodeArguments(wire => extractBody(body, argumentCodec, wire), buffered);
1982
+ if ((request.headers.get("content-type") || "").startsWith("multipart/form-data")) {
1983
+ const form = await body.formData();
1984
+ const encoded = form.get(UPLOAD_ARGS_PART);
1985
+ if (typeof encoded !== "string") {
1986
+ throw new TypeError("Malformed server function upload");
1987
+ }
1988
+ const uploadCodec = withArgumentPlugins(argumentCodec, [createUploadDeserializer(form)]);
1989
+ decoded = await decodeArguments(wire => deserializeStream(new Response(encoded), uploadCodec, wire), encoded);
1990
+ } else {
1991
+ decoded = await decodeArguments(wire => extractBody(body, argumentCodec, wire), buffered);
1992
+ }
1931
1993
  } else {
1932
1994
  decoded = await extractBody(body, codec);
1933
1995
  }
@@ -3032,9 +3094,12 @@ async function handleServerFunctionRequest(request, options = {}) {
3032
3094
  const dispatch = async () => {
3033
3095
  try {
3034
3096
  const invokeOnce = async () => {
3097
+ const shared = !!live && BROADCASTS.has(functionId);
3035
3098
  INVOCATIONS.set(event, {
3036
3099
  id: functionId,
3037
- live: !!live
3100
+ live: !!live,
3101
+ broadcast: shared || undefined,
3102
+ shareKey: shared ? encodedArguments(request, argsEncoding, argumentBytes) : undefined
3038
3103
  });
3039
3104
  const run = () => serverFunction(...parsed);
3040
3105
  return observeInvocation({
@@ -3284,4 +3349,4 @@ function finalizeTransportResponse(response, method) {
3284
3349
  return response;
3285
3350
  }
3286
3351
 
3287
- export { ChunkReader, ERROR_HEADER, FLASH_COOKIE, GENERIC_SERVER_ERROR_MESSAGE, GET, REDIRECT_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, UNKNOWN_HEADER, armLiveBody, clearFlashCookie, configureServerFunctionsServer, createChunk, createEventChunk, createNoJSHandler, createServerReference, decodeErrorHeaderValue, decodeFlashCookie, decodeRedirectHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, encodeFlashCookie, foldSetCookies, frameAddress, getEventServerFunctionInvocation, getServerFunction, getServerFunctionInvocation, getServerFunctionMetadata, guardFailures, handleServerFunctionRequest, hasFlashCookie, invoke, isServerFunction, live, parseServerFunctionActionUrl, registerFlightDataSource, registerServerFunction, registerServerReference, sanitizeServerError, serializeResponseStream, serializeStream, serverFunctionActionUrl, serverFunctionUrl, setServerFunctionsDev, subscribeFlightData, textDigest, withMeta };
3352
+ export { ChunkReader, ERROR_HEADER, FLASH_COOKIE, GENERIC_SERVER_ERROR_MESSAGE, GET, REDIRECT_HEADER, SERVER_FUNCTION_INVOKE, SINGLE_FLIGHT_HEADER, UNKNOWN_HEADER, armLiveBody, broadcast, clearFlashCookie, configureServerFunctionsServer, createChunk, createEventChunk, createNoJSHandler, createServerReference, decodeErrorHeaderValue, decodeFlashCookie, decodeRedirectHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, encodeFlashCookie, foldSetCookies, frameAddress, getEventServerFunctionInvocation, getServerFunction, getServerFunctionInvocation, getServerFunctionMetadata, guardFailures, handleServerFunctionRequest, hasFlashCookie, invoke, isServerFunction, live, parseServerFunctionActionUrl, registerFlightDataSource, registerServerFunction, registerServerReference, sanitizeServerError, serializeResponseStream, serializeStream, serverFunctionActionUrl, serverFunctionUrl, setServerFunctionsDev, subscribeFlightData, textDigest, withMeta };
package/types/client.d.ts CHANGED
@@ -203,6 +203,18 @@ export declare function unregisterDelegatedContainer(container: MountableElement
203
203
  export declare function dispatchAsInteraction<T>(e: Event, fn: () => T): T;
204
204
  export declare function getDelegatedRoot(node: MountableElement): MountableElement | undefined;
205
205
  export declare function setProperty(node: Element, name: string, value: any): void;
206
+ /**
207
+ * A stateful DOM property write (`input.value`, `input.checked`,
208
+ * `option.selected`, `video.muted`, ...) from dev-compiled, non-hydratable
209
+ * DOM output: exactly `node[name] = value`, which is what production
210
+ * output inlines. The dev runtime checks it first and warns
211
+ * (`UNCOMMITTED_INPUT_OVERWRITTEN`) when it re-applies an unchanged bound
212
+ * value over an edit the user never committed to the signal. Production
213
+ * compile output never imports it, so it tree-shakes away.
214
+ *
215
+ * @internal Compiler output only.
216
+ */
217
+ export declare function setStatefulProperty(node: Element, name: string, value: any): void;
206
218
  /**
207
219
  * Options for `registerElementClaim`.
208
220
  * @internal
@@ -60,5 +60,21 @@ export declare function unscopedHoleAllocatedIds(before: string, after: string,
60
60
  * text. Reported once per attribute name so a row template reports once.
61
61
  */
62
62
  export declare function lowercaseEventAttribute(name: string, node: Element): void;
63
+ /**
64
+ * Dev CHECK, before every compiled or spread write of a stateful DOM
65
+ * property (`input.value`, `input.checked`, `option.selected`,
66
+ * `video.muted`, ...): Solid is about to write the same value it wrote last
67
+ * time, but the element no longer holds what that write left there. Nothing
68
+ * Solid wrote changed it, so the user did — typed, clicked, toggled — and
69
+ * that edit never reached the bound signal; the write is about to erase it.
70
+ * The write re-applies an unchanged value because the binding re-ran
71
+ * without its value changing: another binding in the same template effect
72
+ * changed, a spread re-ran, or the source fired with an equal value
73
+ * (`equals: false`). Warns once per element and property; the write itself
74
+ * goes ahead unchanged. Pair with `recordStatefulWrite` after the write.
75
+ */
76
+ export declare function checkStatefulWrite(node: Element, prop: string, value: unknown): void;
77
+ /** Dev: remembers what a stateful write left on the element (see `checkStatefulWrite`). */
78
+ export declare function recordStatefulWrite(node: Element, prop: string, value: unknown): void;
63
79
  /** `Name: message` for an Error, `String(value)` otherwise. */
64
80
  export declare function errorText(error: unknown): string;
@@ -17,5 +17,14 @@ export declare function argumentDecodeCodec(codec: any, defaults: any): any;
17
17
  * JSON string the quotes would be escaped, so payload data cannot spell it.
18
18
  */
19
19
  export declare function namesRefusedType(payload: any): boolean;
20
- /** The configured codec options with encode-side refusals ahead of every plugin. */
21
- export declare function argumentEncodeCodec(codec: any): any;
20
+ /**
21
+ * The configured codec options with encode-side refusals ahead of every
22
+ * plugin. `extra` holds plugins for one call (the upload serializer), which
23
+ * go first.
24
+ */
25
+ export declare function argumentEncodeCodec(codec: any, extra?: any[]): any;
26
+ /**
27
+ * Decode options from `argumentDecodeCodec` with plugins for one request
28
+ * (the upload deserializer) ahead of the resolved list.
29
+ */
30
+ export declare function withArgumentPlugins(argumentCodec: any, extra: any): any;
@@ -179,9 +179,11 @@ export interface ServerFunctionsClientConfig {
179
179
  * Encoder for argument lists JSON can't carry faithfully. JSON-safe args
180
180
  * always go as plain JSON (no codec in the bundle); anything else throws
181
181
  * unless this is set. Installed by `enableRichArguments()` from the
182
- * rich-args entry — set directly only for custom wire encodings.
182
+ * rich-args entry — set directly only for custom wire encodings. A
183
+ * `FormData` answer is sent as an upload: the codec output in its `args`
184
+ * field and each file in a `file<index>` part.
183
185
  */
184
- serializeArgs?(args: unknown[]): string | Promise<string>;
186
+ serializeArgs?(args: unknown[]): string | FormData | Promise<string | FormData>;
185
187
  }
186
188
  /** Wire-state transitions a live call's iterable can report. */
187
189
  export type LiveSourceStatus = "connected" | "reconnecting" | "closed";
@@ -227,7 +229,7 @@ export interface ServerFunctionInvocation {
227
229
  * <link rel="preload" as="fetch" crossorigin href={serverFunctionUrl(getUser, id)} />
228
230
  * ```
229
231
  *
230
- * A `live(GET(fn))` reference's call connects at the live address, so that
232
+ * A `live(fn)` reference's call connects at the live address, so that
231
233
  * is the url returned for one (`<endpoint>/live/<id>[?args=...]`): a
232
234
  * standing event stream of the answer — fetch it by hand (`curl -N`) to
233
235
  * watch it; do not preload or prefetch it, which would open a stream
@@ -251,6 +253,12 @@ export interface LiveServerFunction<A extends readonly any[] = any[], R = any> {
251
253
  /** URL invoking this function directly over HTTP. */
252
254
  readonly url: string;
253
255
  }
256
+ /**
257
+ * Declares a live server function whose answer is the same for every
258
+ * viewer: on the client exactly `live(fn)` — the sharing is the server's.
259
+ * @experimental
260
+ */
261
+ export declare function broadcast<A extends readonly any[], R>(fn: (...args: A) => R): LiveServerFunction<A, Awaited<R>>;
254
262
  /**
255
263
  * Declares a value-shaped live source: a server function returning an async
256
264
  * iterable whose yields are successive VALUES of one logical query, with the
@@ -261,7 +269,8 @@ export interface LiveServerFunction<A extends readonly any[] = any[], R = any> {
261
269
  * first-connect failures reject like a normal call, and `break` aborts the
262
270
  * in-flight request. Live calls are reads and never opt into single-flight
263
271
  * enveloping. Wire state, if wanted, rides the returned iterable's
264
- * `onstatus` hook. Compose with `GET` inside-out: `live(GET(fn))`.
272
+ * `onstatus` hook. Implies `GET` (a live source is a read); an explicit
273
+ * `live(GET(fn))` is equivalent.
265
274
  */
266
275
  export declare function live<A extends readonly any[], R>(fn: (...args: A) => R): LiveServerFunction<A, Awaited<R>>;
267
276
  export declare function registerServerReference(): never;
@@ -394,6 +394,14 @@ export interface ServerFunctionInvocation {
394
394
  * `false` for the data and bare addresses, and for in-process calls.
395
395
  */
396
396
  live: boolean;
397
+ /** A live call to a `broadcast` declaration: its answer is shared. */
398
+ broadcast?: boolean;
399
+ /**
400
+ * For a broadcast call, the arguments as they arrived on the wire: callers
401
+ * whose encodings are equal share one render. Absent when the encoding
402
+ * wasn't kept (an unbuffered body), and then the call is not shared.
403
+ */
404
+ shareKey?: string;
397
405
  }
398
406
  /**
399
407
  * Hooks layering framework policy onto `handleServerFunctionRequest`.
@@ -519,6 +527,15 @@ export declare function registerServerReference<T extends any[], R>(id: string,
519
527
  export declare function createServerReference<T extends any[], R>(reference: ServerFunctionReference<T, R>): (...args: T) => R;
520
528
  export declare function GET<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, Awaited<R>>;
521
529
  export declare function live<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, LiveSource<Awaited<R>>>;
530
+ /**
531
+ * Declares a live server function whose answer is the same for every
532
+ * viewer: implies `live` and `GET`, and at the live address every caller
533
+ * with the same arguments shares ONE render (frames server half). The
534
+ * outer body still runs per call — a gate (auth, redirects) — but what it
535
+ * returns is the shared answer's to render.
536
+ * @experimental
537
+ */
538
+ export declare function broadcast<A extends readonly any[], R>(fn: (...args: A) => R): ServerFunction<A, LiveSource<Awaited<R>>>;
522
539
  export declare function getServerFunctionInvocation(): ServerFunctionInvocation | undefined;
523
540
  export declare function getEventServerFunctionInvocation(event: RequestEvent | undefined): ServerFunctionInvocation | undefined;
524
541
  export declare function foldSetCookies(headers: Headers, setCookies: readonly string[]): Headers;
@@ -0,0 +1,50 @@
1
+ export declare const UPLOAD_ARGS_PART = "args";
2
+ export declare const UPLOAD_FILE_PART = "file";
3
+ /**
4
+ * True for a file or a blob. One from another frame is an instance of that
5
+ * frame's `Blob`, so its shape tells instead.
6
+ */
7
+ declare function isBlob(value: any): boolean;
8
+ /**
9
+ * The client half. Each file or blob in the arguments serializes as its
10
+ * index in `files`. A file that appears twice is pushed once, so it arrives
11
+ * as one value.
12
+ */
13
+ export declare function createUploadSerializer(files: any): {
14
+ tag: string;
15
+ test: typeof isBlob;
16
+ parse: {
17
+ sync: (value: any, ctx: any) => {
18
+ i: any;
19
+ };
20
+ async: (value: any, ctx: any) => Promise<{
21
+ i: any;
22
+ }>;
23
+ stream: (value: any, ctx: any) => {
24
+ i: any;
25
+ };
26
+ };
27
+ serialize: (node: any, ctx: any) => any;
28
+ deserialize: () => never;
29
+ };
30
+ /**
31
+ * The server half, made for one request. Each index turns back into its
32
+ * part of `form`. A bad index or a missing part fails the decode.
33
+ */
34
+ export declare function createUploadDeserializer(form: any): {
35
+ tag: string;
36
+ test: () => boolean;
37
+ parse: {
38
+ sync: () => never;
39
+ async: () => never;
40
+ stream: () => never;
41
+ };
42
+ serialize: () => never;
43
+ deserialize: (node: any, ctx: any) => any;
44
+ };
45
+ /**
46
+ * The request body for a call with files. `FormData` only takes blobs of its
47
+ * own frame, so a blob from another frame is copied first.
48
+ */
49
+ export declare function createUploadBody(serialized: any, files: any): Promise<FormData>;
50
+ export {};
package/types/server.d.ts CHANGED
@@ -689,5 +689,5 @@ export declare function claimElement<T extends Element>(node: T, owner?: Owner |
689
689
  export declare function claimElementTree<T extends Node>(root: T): T;
690
690
  /** Server: `fn()`. No event is dispatched during SSR, so there is no interaction to join. */
691
691
  export declare function dispatchAsInteraction<T>(_e: Event, fn: () => T): T;
692
- export { notSup as style, notSup as insert, notSup as spread, notSup as delegateEvents, notSup as registerDelegatedRoot, notSup as unregisterDelegatedRoot, notSup as registerDelegatedContainer, notSup as unregisterDelegatedContainer, notSup as getDelegatedRoot, notSup as dynamicProperty, notSup as setAttribute, notSup as setAttributeNS, notSup as addEvent, notSup as render, notSup as template, notSup as setProperty, notSup as className, notSup as assign, notSup as hydrate, notSup as getNextElement, notSup as getNextMatch, notSup as getNextMarker, notSup as runHydrationEvents, notSup as ref, notSup as setStyleProperty, notSup as readShallow, notSup as acquireAsset };
692
+ export { notSup as style, notSup as insert, notSup as spread, notSup as delegateEvents, notSup as registerDelegatedRoot, notSup as unregisterDelegatedRoot, notSup as registerDelegatedContainer, notSup as unregisterDelegatedContainer, notSup as getDelegatedRoot, notSup as dynamicProperty, notSup as setAttribute, notSup as setAttributeNS, notSup as addEvent, notSup as render, notSup as template, notSup as setProperty, notSup as setStatefulProperty, notSup as className, notSup as assign, notSup as hydrate, notSup as getNextElement, notSup as getNextMatch, notSup as getNextMarker, notSup as runHydrationEvents, notSup as ref, notSup as setStyleProperty, notSup as readShallow, notSup as acquireAsset };
693
693
  declare function notSup(): void;