@solidjs/web 2.0.0-beta.28 → 2.0.0-beta.29

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 (43) hide show
  1. package/dist/dev.cjs +40 -2
  2. package/dist/dev.js +39 -4
  3. package/dist/server.cjs +90 -31
  4. package/dist/server.js +89 -33
  5. package/dist/web.cjs +40 -2
  6. package/dist/web.js +39 -4
  7. package/frames/dist/client.cjs +370 -209
  8. package/frames/dist/client.dev.cjs +370 -210
  9. package/frames/dist/client.dev.js +371 -211
  10. package/frames/dist/client.js +371 -210
  11. package/frames/dist/server.cjs +351 -69
  12. package/frames/dist/server.js +351 -70
  13. package/package.json +3 -3
  14. package/server-functions/dist/client.cjs +87 -3
  15. package/server-functions/dist/client.js +80 -4
  16. package/server-functions/dist/server.cjs +52 -17
  17. package/server-functions/dist/server.js +51 -17
  18. package/types/client.d.ts +15 -0
  19. package/types/core.d.ts +1 -1
  20. package/types/frames/client.d.ts +7 -5
  21. package/types/frames/frame-client.d.ts +17 -0
  22. package/types/frames/frame-sink.d.ts +29 -6
  23. package/types/frames/frame-transport.d.ts +76 -12
  24. package/types/frames/server.d.ts +1 -1
  25. package/types/index.d.ts +74 -0
  26. package/types/server-functions/client.d.ts +24 -0
  27. package/types/server-functions/server.d.ts +75 -16
  28. package/types/server-functions/shared.d.ts +9 -0
  29. package/types/server-mock.d.ts +6 -2
  30. package/types/server.d.ts +39 -1
  31. package/types-cjs/client.d.cts +15 -0
  32. package/types-cjs/core.d.cts +1 -1
  33. package/types-cjs/frames/client.d.cts +7 -5
  34. package/types-cjs/frames/frame-client.d.cts +17 -0
  35. package/types-cjs/frames/frame-sink.d.cts +29 -6
  36. package/types-cjs/frames/frame-transport.d.cts +76 -12
  37. package/types-cjs/frames/server.d.cts +1 -1
  38. package/types-cjs/index.d.cts +74 -0
  39. package/types-cjs/server-functions/client.d.cts +24 -0
  40. package/types-cjs/server-functions/server.d.cts +75 -16
  41. package/types-cjs/server-functions/shared.d.cts +9 -0
  42. package/types-cjs/server-mock.d.cts +6 -2
  43. package/types-cjs/server.d.cts +39 -1
@@ -40,6 +40,9 @@ const codecConfig = {
40
40
  function configureServerFunctionsCodec(codec) {
41
41
  codecConfig.codec = codec;
42
42
  }
43
+ function getServerFunctionsCodec() {
44
+ return codecConfig.codec;
45
+ }
43
46
  const flightConfig = {
44
47
  consumer: undefined
45
48
  };
@@ -52,6 +55,50 @@ function subscribeFlightData(consumer) {
52
55
  function getFlightDataConsumer() {
53
56
  return flightConfig.consumer;
54
57
  }
58
+ function frameAddress(id, args) {
59
+ return args && args.length ? id + ":" + hashArguments(args) : id;
60
+ }
61
+ function hashArguments(args) {
62
+ let hash = 0;
63
+ const text = stableString(args);
64
+ for (let i = 0; i < text.length; i++) {
65
+ hash = (hash << 5) - hash + text.charCodeAt(i);
66
+ hash |= 0;
67
+ }
68
+ return (hash >>> 0).toString(36);
69
+ }
70
+ function stableString(value, seen) {
71
+ if (value === null || typeof value !== "object") {
72
+ return typeof value === "bigint" ? value + "n" : String(value);
73
+ }
74
+ if (value instanceof Date) return "Date:" + value.getTime();
75
+ seen || (seen = new Set());
76
+ if (seen.has(value)) return "~";
77
+ seen.add(value);
78
+ if (value instanceof Map) {
79
+ const entries = [];
80
+ for (const [k, v] of value) {
81
+ entries.push(stableString(k, seen) + "=>" + stableString(v, seen));
82
+ }
83
+ return "Map{" + entries.sort().join(",") + "}";
84
+ }
85
+ if (value instanceof Set) {
86
+ const members = [];
87
+ for (const v of value) members.push(stableString(v, seen));
88
+ return "Set{" + members.sort().join(",") + "}";
89
+ }
90
+ if (Array.isArray(value)) {
91
+ let out = "[";
92
+ for (let i = 0; i < value.length; i++) out += (i ? "," : "") + stableString(value[i], seen);
93
+ return out + "]";
94
+ }
95
+ const keys = Object.keys(value).sort();
96
+ let out = "{";
97
+ for (let i = 0; i < keys.length; i++) {
98
+ out += (i ? "," : "") + keys[i] + ":" + stableString(value[keys[i]], seen);
99
+ }
100
+ return out + "}";
101
+ }
55
102
  const SERVER_FUNCTION_METADATA = Symbol.for("solid.ServerFunctionMetadata");
56
103
  function getServerFunctionMetadata(fn) {
57
104
  if (typeof fn !== "function") return undefined;
@@ -209,6 +256,17 @@ async function extractBody(source, codecOptions) {
209
256
  }
210
257
  return undefined;
211
258
  }
259
+ function createChunk(data) {
260
+ const encodeData = new TextEncoder().encode(data);
261
+ const bytes = encodeData.length;
262
+ const baseHex = bytes.toString(16);
263
+ const totalHex = "00000000".substring(0, 8 - baseHex.length) + baseHex;
264
+ const head = new TextEncoder().encode(`;0x${totalHex};`);
265
+ const chunk = new Uint8Array(12 + bytes);
266
+ chunk.set(head);
267
+ chunk.set(encodeData, 12);
268
+ return chunk;
269
+ }
212
270
  class ChunkReader {
213
271
  constructor(stream) {
214
272
  this.reader = stream.getReader();
@@ -389,6 +447,21 @@ async function initializeResponse(base, id, instance, options, args, meta) {
389
447
  }
390
448
  }, meta);
391
449
  }
450
+ if (args.length > 1) {
451
+ const trailing = getHeadersAndBody(args[args.length - 1]);
452
+ const leading = args.slice(0, -1).map(arg => arg === undefined ? null : arg);
453
+ if (trailing && isJSONSafe(leading)) {
454
+ const target = base + (base.includes("?") ? "&" : "?") + "args=" + encodeURIComponent(JSON.stringify(leading));
455
+ return createRequest(target, id, instance, {
456
+ ...options,
457
+ body: trailing.body,
458
+ headers: {
459
+ ...options.headers,
460
+ ...trailing.headers
461
+ }
462
+ }, meta);
463
+ }
464
+ }
392
465
  return createRequest(base, id, instance, {
393
466
  ...options,
394
467
  body: await serializeArguments(args),
@@ -399,7 +472,7 @@ async function initializeResponse(base, id, instance, options, args, meta) {
399
472
  }
400
473
  }, meta);
401
474
  }
402
- async function fetchServerFunction(base, id, options, args, meta) {
475
+ async function fetchServerFunction(base, id, options, args, meta, callArgs = args) {
403
476
  const instance = `server-function:${INSTANCE++}`;
404
477
  const handler = config.responseHandler;
405
478
  const context = handler && handler.capture ? handler.capture({
@@ -411,7 +484,7 @@ async function fetchServerFunction(base, id, options, args, meta) {
411
484
  const handled = handler.handle(response, {
412
485
  id,
413
486
  meta,
414
- args,
487
+ args: callArgs,
415
488
  context
416
489
  });
417
490
  if (handled !== undefined) return handled;
@@ -490,7 +563,7 @@ function GET(fn) {
490
563
  }
491
564
  return fetchServerFunction(base, id, {
492
565
  method: "GET"
493
- }, [], metadata);
566
+ }, [], metadata, args);
494
567
  };
495
568
  wrapped[SERVER_FUNCTION_METADATA] = metadata;
496
569
  wrapped.id = id;
@@ -505,5 +578,8 @@ function GET(fn) {
505
578
  function registerServerReference() {
506
579
  throw new Error("registerServerReference must not be called in the client build");
507
580
  }
581
+ function getServerFunctionInvocation() {
582
+ return undefined;
583
+ }
508
584
 
509
- export { ERROR_HEADER, FLASH_COOKIE, FUNCTION_HEADER, GET, INSTANCE_HEADER, SINGLE_FLIGHT_HEADER, clearFlashCookie, configureServerFunctionsClient, createServerReference, decodeErrorHeaderValue, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, getServerFunctionMetadata, hasFlashCookie, isServerFunction, registerServerReference, subscribeFlightData, withMeta };
585
+ export { ChunkReader, ERROR_HEADER, FLASH_COOKIE, FUNCTION_HEADER, GET, INSTANCE_HEADER, REVALIDATE_HEADER, SINGLE_FLIGHT_HEADER, clearFlashCookie, configureServerFunctionsClient, createChunk, createServerReference, decodeErrorHeaderValue, decodeResponse, decodeResponsePayload, deserializeStream, encodeErrorHeaderValue, frameAddress, getFlightDataConsumer, getServerFunctionInvocation, getServerFunctionMetadata, getServerFunctionsCodec, hasFlashCookie, isServerFunction, registerServerReference, subscribeFlightData, withMeta };
@@ -410,6 +410,7 @@ const config = {
410
410
  provideEvent: undefined,
411
411
  collectFlightData: undefined,
412
412
  transformResult: undefined,
413
+ transformFlightResult: undefined,
413
414
  transformDirectResult: undefined,
414
415
  handleNoJS: undefined,
415
416
  endpoint: "/_server"
@@ -418,6 +419,7 @@ function configureServerFunctionsServer({
418
419
  provideEvent,
419
420
  collectFlightData,
420
421
  transformResult,
422
+ transformFlightResult,
421
423
  transformDirectResult,
422
424
  handleNoJS,
423
425
  endpoint,
@@ -426,6 +428,7 @@ function configureServerFunctionsServer({
426
428
  if (provideEvent !== undefined) config.provideEvent = provideEvent;
427
429
  if (collectFlightData !== undefined) config.collectFlightData = collectFlightData;
428
430
  if (transformResult !== undefined) config.transformResult = transformResult;
431
+ if (transformFlightResult !== undefined) config.transformFlightResult = transformFlightResult;
429
432
  if (transformDirectResult !== undefined) config.transformDirectResult = transformDirectResult;
430
433
  if (handleNoJS !== undefined) config.handleNoJS = handleNoJS;
431
434
  if (endpoint !== undefined) config.endpoint = endpoint;
@@ -439,6 +442,7 @@ function provideEvent(event, fn) {
439
442
  }
440
443
  const REGISTRATIONS = new Map();
441
444
  const METHODS = new Map();
445
+ const INVOCATIONS = new WeakMap();
442
446
  function registerServerFunction(id, callback) {
443
447
  REGISTRATIONS.set(id, callback);
444
448
  return callback;
@@ -482,9 +486,9 @@ function createServerReference({
482
486
  const evt = {
483
487
  ...ogEvt
484
488
  };
485
- evt.locals.serverFunctionMeta = {
489
+ INVOCATIONS.set(evt, {
486
490
  id
487
- };
491
+ });
488
492
  evt.serverOnly = true;
489
493
  const result = provideEvent(evt, () => {
490
494
  return fn.apply(thisArg, args);
@@ -493,11 +497,13 @@ function createServerReference({
493
497
  if (transform && result && typeof result.then === "function") {
494
498
  return result.then(value => transform(value, {
495
499
  id,
500
+ args,
496
501
  event: evt
497
502
  }));
498
503
  }
499
504
  return transform ? transform(result, {
500
505
  id,
506
+ args,
501
507
  event: evt
502
508
  }) : result;
503
509
  }
@@ -512,9 +518,11 @@ function GET(fn) {
512
518
  method: "GET"
513
519
  });
514
520
  }
515
- function getServerFunctionMeta() {
516
- const event = getRequestEvent();
517
- return event && event.locals.serverFunctionMeta;
521
+ function getServerFunctionInvocation() {
522
+ return getEventServerFunctionInvocation(getRequestEvent());
523
+ }
524
+ function getEventServerFunctionInvocation(event) {
525
+ return event && INVOCATIONS.get(event);
518
526
  }
519
527
  function resolveFunctionId(request, url) {
520
528
  const reference = request.headers.get(FUNCTION_HEADER);
@@ -544,12 +552,27 @@ async function parseArguments(request, url, instance, codec) {
544
552
  }
545
553
  return parsed;
546
554
  }
547
- async function foldFlightData(hook, event, headers, outcome) {
555
+ async function foldFlightData(hook, event, headers, outcome, context = {}) {
548
556
  if (outcome.value instanceof Response && outcome.value.body) return outcome.value;
549
557
  digestOutcome(event, outcome);
550
558
  const data = await hook(event, outcome);
551
559
  if (data === undefined) return outcome.value;
552
560
  headers.set(SINGLE_FLIGHT_HEADER, "true");
561
+ if (context.transformFlightResult) {
562
+ const transformed = await context.transformFlightResult(event, {
563
+ value: outcome.value,
564
+ data
565
+ }, context);
566
+ if (transformed !== undefined) {
567
+ for (const cookie of headers.getSetCookie()) transformed.headers.append("Set-Cookie", cookie);
568
+ headers.forEach((value, key) => {
569
+ if (key !== "set-cookie" && !transformed.headers.has(key)) {
570
+ transformed.headers.set(key, value);
571
+ }
572
+ });
573
+ return transformed;
574
+ }
575
+ }
553
576
  return {
554
577
  value: outcome.value,
555
578
  data
@@ -710,22 +733,29 @@ async function handleServerFunctionRequest(request, options = {}) {
710
733
  const provide = options.provideEvent || provideEvent;
711
734
  const flightHook = options.collectFlightData !== undefined ? options.collectFlightData : config.collectFlightData;
712
735
  const transformResult = options.transformResult !== undefined ? options.transformResult : config.transformResult;
736
+ const transformFlightResult = options.transformFlightResult !== undefined ? options.transformFlightResult : config.transformFlightResult;
713
737
  const handleNoJS = options.handleNoJS !== undefined ? options.handleNoJS : config.handleNoJS !== undefined ? config.handleNoJS : isFormPost(request) ? defaultNoJSHandler || (defaultNoJSHandler = createNoJSHandler()) : undefined;
714
738
  const collectsFlight = !!(flightHook && instance && request.headers.has(SINGLE_FLIGHT_HEADER));
715
739
  const parsed = await parseArguments(request, url, instance, codec);
740
+ const flightContext = {
741
+ id: functionId,
742
+ args: parsed,
743
+ instance,
744
+ request,
745
+ collectsFlight,
746
+ codec,
747
+ transformFlightResult
748
+ };
716
749
  const headers = new Headers();
717
750
  try {
718
751
  let result = await provide(event, async () => {
719
- event.locals.serverFunctionMeta = {
752
+ INVOCATIONS.set(event, {
720
753
  id: functionId
721
- };
754
+ });
722
755
  return serverFunction(...parsed);
723
756
  });
724
757
  if (transformResult) {
725
- result = await transformResult(event, result, {
726
- instance,
727
- request
728
- });
758
+ result = await transformResult(event, result, flightContext);
729
759
  }
730
760
  let status = 200;
731
761
  let metadata;
@@ -767,7 +797,8 @@ async function handleServerFunctionRequest(request, options = {}) {
767
797
  response: metadata,
768
798
  request,
769
799
  thrown: false
770
- });
800
+ }, flightContext);
801
+ if (result instanceof Response && result.headers.has("X-Content-Raw")) return result;
771
802
  }
772
803
  if (!instance) {
773
804
  if (handleNoJS) return handleNoJS(result, request, parsed);
@@ -779,8 +810,7 @@ async function handleServerFunctionRequest(request, options = {}) {
779
810
  if (x instanceof Response || isResponseEnvelope(x)) {
780
811
  if (transformResult) {
781
812
  x = await transformResult(event, x, {
782
- instance,
783
- request,
813
+ ...flightContext,
784
814
  thrown: true
785
815
  });
786
816
  }
@@ -818,7 +848,11 @@ async function handleServerFunctionRequest(request, options = {}) {
818
848
  response: metadata,
819
849
  request,
820
850
  thrown: true
821
- });
851
+ }, flightContext);
852
+ if (x instanceof Response && x.headers.has("X-Content-Raw")) {
853
+ x.headers.set(ERROR_HEADER, "true");
854
+ return x;
855
+ }
822
856
  }
823
857
  headers.set(ERROR_HEADER, "true");
824
858
  if (!instance) {
@@ -857,8 +891,9 @@ exports.decodeResponsePayload = decodeResponsePayload;
857
891
  exports.encodeErrorHeaderValue = encodeErrorHeaderValue;
858
892
  exports.encodeFlashCookie = encodeFlashCookie;
859
893
  exports.foldSetCookies = foldSetCookies;
894
+ exports.getEventServerFunctionInvocation = getEventServerFunctionInvocation;
860
895
  exports.getServerFunction = getServerFunction;
861
- exports.getServerFunctionMeta = getServerFunctionMeta;
896
+ exports.getServerFunctionInvocation = getServerFunctionInvocation;
862
897
  exports.getServerFunctionMetadata = getServerFunctionMetadata;
863
898
  exports.handleServerFunctionRequest = handleServerFunctionRequest;
864
899
  exports.hasFlashCookie = hasFlashCookie;
@@ -408,6 +408,7 @@ const config = {
408
408
  provideEvent: undefined,
409
409
  collectFlightData: undefined,
410
410
  transformResult: undefined,
411
+ transformFlightResult: undefined,
411
412
  transformDirectResult: undefined,
412
413
  handleNoJS: undefined,
413
414
  endpoint: "/_server"
@@ -416,6 +417,7 @@ function configureServerFunctionsServer({
416
417
  provideEvent,
417
418
  collectFlightData,
418
419
  transformResult,
420
+ transformFlightResult,
419
421
  transformDirectResult,
420
422
  handleNoJS,
421
423
  endpoint,
@@ -424,6 +426,7 @@ function configureServerFunctionsServer({
424
426
  if (provideEvent !== undefined) config.provideEvent = provideEvent;
425
427
  if (collectFlightData !== undefined) config.collectFlightData = collectFlightData;
426
428
  if (transformResult !== undefined) config.transformResult = transformResult;
429
+ if (transformFlightResult !== undefined) config.transformFlightResult = transformFlightResult;
427
430
  if (transformDirectResult !== undefined) config.transformDirectResult = transformDirectResult;
428
431
  if (handleNoJS !== undefined) config.handleNoJS = handleNoJS;
429
432
  if (endpoint !== undefined) config.endpoint = endpoint;
@@ -437,6 +440,7 @@ function provideEvent(event, fn) {
437
440
  }
438
441
  const REGISTRATIONS = new Map();
439
442
  const METHODS = new Map();
443
+ const INVOCATIONS = new WeakMap();
440
444
  function registerServerFunction(id, callback) {
441
445
  REGISTRATIONS.set(id, callback);
442
446
  return callback;
@@ -480,9 +484,9 @@ function createServerReference({
480
484
  const evt = {
481
485
  ...ogEvt
482
486
  };
483
- evt.locals.serverFunctionMeta = {
487
+ INVOCATIONS.set(evt, {
484
488
  id
485
- };
489
+ });
486
490
  evt.serverOnly = true;
487
491
  const result = provideEvent(evt, () => {
488
492
  return fn.apply(thisArg, args);
@@ -491,11 +495,13 @@ function createServerReference({
491
495
  if (transform && result && typeof result.then === "function") {
492
496
  return result.then(value => transform(value, {
493
497
  id,
498
+ args,
494
499
  event: evt
495
500
  }));
496
501
  }
497
502
  return transform ? transform(result, {
498
503
  id,
504
+ args,
499
505
  event: evt
500
506
  }) : result;
501
507
  }
@@ -510,9 +516,11 @@ function GET(fn) {
510
516
  method: "GET"
511
517
  });
512
518
  }
513
- function getServerFunctionMeta() {
514
- const event = getRequestEvent();
515
- return event && event.locals.serverFunctionMeta;
519
+ function getServerFunctionInvocation() {
520
+ return getEventServerFunctionInvocation(getRequestEvent());
521
+ }
522
+ function getEventServerFunctionInvocation(event) {
523
+ return event && INVOCATIONS.get(event);
516
524
  }
517
525
  function resolveFunctionId(request, url) {
518
526
  const reference = request.headers.get(FUNCTION_HEADER);
@@ -542,12 +550,27 @@ async function parseArguments(request, url, instance, codec) {
542
550
  }
543
551
  return parsed;
544
552
  }
545
- async function foldFlightData(hook, event, headers, outcome) {
553
+ async function foldFlightData(hook, event, headers, outcome, context = {}) {
546
554
  if (outcome.value instanceof Response && outcome.value.body) return outcome.value;
547
555
  digestOutcome(event, outcome);
548
556
  const data = await hook(event, outcome);
549
557
  if (data === undefined) return outcome.value;
550
558
  headers.set(SINGLE_FLIGHT_HEADER, "true");
559
+ if (context.transformFlightResult) {
560
+ const transformed = await context.transformFlightResult(event, {
561
+ value: outcome.value,
562
+ data
563
+ }, context);
564
+ if (transformed !== undefined) {
565
+ for (const cookie of headers.getSetCookie()) transformed.headers.append("Set-Cookie", cookie);
566
+ headers.forEach((value, key) => {
567
+ if (key !== "set-cookie" && !transformed.headers.has(key)) {
568
+ transformed.headers.set(key, value);
569
+ }
570
+ });
571
+ return transformed;
572
+ }
573
+ }
551
574
  return {
552
575
  value: outcome.value,
553
576
  data
@@ -708,22 +731,29 @@ async function handleServerFunctionRequest(request, options = {}) {
708
731
  const provide = options.provideEvent || provideEvent;
709
732
  const flightHook = options.collectFlightData !== undefined ? options.collectFlightData : config.collectFlightData;
710
733
  const transformResult = options.transformResult !== undefined ? options.transformResult : config.transformResult;
734
+ const transformFlightResult = options.transformFlightResult !== undefined ? options.transformFlightResult : config.transformFlightResult;
711
735
  const handleNoJS = options.handleNoJS !== undefined ? options.handleNoJS : config.handleNoJS !== undefined ? config.handleNoJS : isFormPost(request) ? defaultNoJSHandler || (defaultNoJSHandler = createNoJSHandler()) : undefined;
712
736
  const collectsFlight = !!(flightHook && instance && request.headers.has(SINGLE_FLIGHT_HEADER));
713
737
  const parsed = await parseArguments(request, url, instance, codec);
738
+ const flightContext = {
739
+ id: functionId,
740
+ args: parsed,
741
+ instance,
742
+ request,
743
+ collectsFlight,
744
+ codec,
745
+ transformFlightResult
746
+ };
714
747
  const headers = new Headers();
715
748
  try {
716
749
  let result = await provide(event, async () => {
717
- event.locals.serverFunctionMeta = {
750
+ INVOCATIONS.set(event, {
718
751
  id: functionId
719
- };
752
+ });
720
753
  return serverFunction(...parsed);
721
754
  });
722
755
  if (transformResult) {
723
- result = await transformResult(event, result, {
724
- instance,
725
- request
726
- });
756
+ result = await transformResult(event, result, flightContext);
727
757
  }
728
758
  let status = 200;
729
759
  let metadata;
@@ -765,7 +795,8 @@ async function handleServerFunctionRequest(request, options = {}) {
765
795
  response: metadata,
766
796
  request,
767
797
  thrown: false
768
- });
798
+ }, flightContext);
799
+ if (result instanceof Response && result.headers.has("X-Content-Raw")) return result;
769
800
  }
770
801
  if (!instance) {
771
802
  if (handleNoJS) return handleNoJS(result, request, parsed);
@@ -777,8 +808,7 @@ async function handleServerFunctionRequest(request, options = {}) {
777
808
  if (x instanceof Response || isResponseEnvelope(x)) {
778
809
  if (transformResult) {
779
810
  x = await transformResult(event, x, {
780
- instance,
781
- request,
811
+ ...flightContext,
782
812
  thrown: true
783
813
  });
784
814
  }
@@ -816,7 +846,11 @@ async function handleServerFunctionRequest(request, options = {}) {
816
846
  response: metadata,
817
847
  request,
818
848
  thrown: true
819
- });
849
+ }, flightContext);
850
+ if (x instanceof Response && x.headers.has("X-Content-Raw")) {
851
+ x.headers.set(ERROR_HEADER, "true");
852
+ return x;
853
+ }
820
854
  }
821
855
  headers.set(ERROR_HEADER, "true");
822
856
  if (!instance) {
@@ -838,4 +872,4 @@ async function handleServerFunctionRequest(request, options = {}) {
838
872
  }
839
873
  }
840
874
 
841
- export { ERROR_HEADER, FLASH_COOKIE, FUNCTION_HEADER, GET, INSTANCE_HEADER, SINGLE_FLIGHT_HEADER, clearFlashCookie, configureServerFunctionsServer, createNoJSHandler, createServerReference, decodeErrorHeaderValue, decodeFlashCookie, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, encodeFlashCookie, foldSetCookies, getServerFunction, getServerFunctionMeta, getServerFunctionMetadata, handleServerFunctionRequest, hasFlashCookie, isServerFunction, registerServerFunction, registerServerReference, subscribeFlightData, withMeta };
875
+ export { ERROR_HEADER, FLASH_COOKIE, FUNCTION_HEADER, GET, INSTANCE_HEADER, SINGLE_FLIGHT_HEADER, clearFlashCookie, configureServerFunctionsServer, createNoJSHandler, createServerReference, decodeErrorHeaderValue, decodeFlashCookie, decodeResponse, decodeResponsePayload, encodeErrorHeaderValue, encodeFlashCookie, foldSetCookies, getEventServerFunctionInvocation, getServerFunction, getServerFunctionInvocation, getServerFunctionMetadata, handleServerFunctionRequest, hasFlashCookie, isServerFunction, registerServerFunction, registerServerReference, subscribeFlightData, withMeta };
package/types/client.d.ts CHANGED
@@ -148,6 +148,21 @@ export function generateHydrationScript(options?: {
148
148
  eventNames?: string[];
149
149
  }): string;
150
150
  export function Assets(props: { children?: JSX.Element }): JSX.Element;
151
+ /**
152
+ * See the server entry's `ResponseStub` — the shape of the mutable response
153
+ * head integrations expose as `event.response` via module augmentation.
154
+ */
155
+ export interface ResponseStub {
156
+ status?: number;
157
+ statusText?: string;
158
+ headers: Headers;
159
+ /**
160
+ * Set by the integration once the response head has been derived/sent
161
+ * from this stub (status/headers can no longer change); consumers must
162
+ * treat later writes and cleanup-time retractions as no-ops.
163
+ */
164
+ committed?: boolean;
165
+ }
151
166
  export interface RequestEvent {
152
167
  request: Request;
153
168
  locals: Record<string | number | symbol, any>;
package/types/core.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { getOwner, runWithOwner, createComponent, createRoot as root, sharedConfig, untrack, merge as mergeProps, flatten, ssrHandleError, ssrScope, NoHydration, Hydration } from "solid-js";
1
+ export { getOwner, runWithOwner, createComponent, createRoot as root, sharedConfig, untrack, merge as mergeProps, flatten, ssrHandleError, ssrScope, NoHydration, Hydration, runInServerComponentScope } from "solid-js";
2
2
  export declare const effect: (fn: any, effectFn: any, options: any) => void;
3
3
  export declare const memo: (fn: any) => import("solid-js").SourceAccessor<any>;
4
4
  export declare const runWithHydrationScope: (id: any, fn: any) => unknown;
@@ -5,11 +5,13 @@ export type { Slot } from "./server.js";
5
5
  export declare function getFrameHost(): any;
6
6
  /**
7
7
  * Installs the server-component transport policy on the server-function
8
- * client: boundary identity derives from the reactive owner captured at
9
- * each call site (`getOwner`), so distinct `dynamic()` sources get
10
- * independent boundaries with nothing declared, refetches from the same
11
- * source resolve to the identical component, and ownerless calls fall back
12
- * to one boundary per function id.
8
+ * client: boundary identity is the call's intrinsic (function, arguments)
9
+ * address per-args, exactly like the query cache, so a cached component
10
+ * always mounts the boundary showing the call it was cached for. Repeat
11
+ * calls for the same args resolve the identical component (refetches morph
12
+ * in place, cache hits pass `dynamic`'s equals-gate); a source switching
13
+ * args swaps boundaries, re-materialized instantly from the host's
14
+ * retained state.
13
15
  *
14
16
  * Call once in the client entry (an explicit call — the package is
15
17
  * `sideEffects: false`, so a bare import would be tree-shaken away);
@@ -71,6 +71,14 @@ export interface SlotContext {
71
71
  * re-call displaced (e.g. `{$frame}` region ranges) is dropped.
72
72
  */
73
73
  adopted?: boolean;
74
+ /**
75
+ * Whether this occurrence is a render-prop CALL (the producer placed it
76
+ * with arguments — possibly empty — via a slot record) as opposed to a
77
+ * direct-insert position. Consumers cannot tell from the resolved props
78
+ * alone: an argless render prop and a direct insert both arrive as `{}`,
79
+ * but one is a function to invoke and the other a value to place.
80
+ */
81
+ invoked?: boolean;
74
82
  /**
75
83
  * Register cleanup for when this occurrence's range is removed from the
76
84
  * server content, or the owning frame is disposed.
@@ -83,6 +91,15 @@ export interface SlotContext {
83
91
  * in place (zero DOM mutation).
84
92
  */
85
93
  existing: ChildNode[];
94
+ /**
95
+ * The range's own marker comments, when the occurrence has a placed range.
96
+ * A framework binding whose slot content is reactive at the top level (a
97
+ * boundary accessor, changing route children) owns the interior instead of
98
+ * returning nodes: bind before `end` with the framework's insert primitive
99
+ * and return `undefined` — the frame leaves the range alone (server morphs
100
+ * already protect slot ranges).
101
+ */
102
+ range?: { start: Comment; end: Comment };
86
103
  }
87
104
 
88
105
  /**
@@ -126,16 +126,39 @@ export function createDocumentSlotProps(
126
126
  * as `configureServerFunctionsServer({ transformDirectResult })` and a
127
127
  * direct (same-process) server-function result that is a function comes back
128
128
  * as an inline-renderable server component (frame markers + document
129
- * slot props). Non-function results pass through.
129
+ * slot props), branded with its function id and the call's wire address.
130
+ * Non-function results pass through.
130
131
  */
131
- export function frameTransformDirectResult<T>(value: T, options: { id: string }): T;
132
+ export function frameTransformDirectResult<T>(
133
+ value: T,
134
+ options: { id: string; args?: unknown[] }
135
+ ): T;
132
136
 
133
137
  /**
134
- * Seroval plugin for the hydration serializer: writes an inline server
135
- * component as a stable per-function-id placeholder reference
136
- * (`self._$SC.r(id)`) instead of meeting an unserializable function.
138
+ * The frame half of single-flight, as a `transformFlightResult` policy for
139
+ * `handleServerFunctionRequest`: when part of what a mutation invalidated is
140
+ * markup (a component-valued flight-data entry), the frame stream carries
141
+ * the whole payload — each component's content as a region addressed by its
142
+ * call, the `{ value, data }` envelope as `outcome` chunks with the
143
+ * component entries serialized as flight references. Returns `undefined`
144
+ * when nothing invalidated is markup (the response stays the plain
145
+ * single-flight envelope).
137
146
  */
138
- export const ServerComponentPlugin: unknown;
147
+ export function frameTransformFlightResult(
148
+ event: unknown,
149
+ outcome: { value: unknown; data: unknown },
150
+ context?: unknown
151
+ ): Promise<Response | undefined>;
152
+
153
+ // The brands and the codec plugin live with the transport (client bundles
154
+ // resolve flight references against the live registry); re-exported here for
155
+ // server integrations importing the document-SSR surface.
156
+ export {
157
+ SERVER_COMPONENT,
158
+ SERVER_COMPONENT_ADDRESS,
159
+ SERVER_COMPONENT_SOURCE,
160
+ ServerComponentPlugin
161
+ } from "./frame-transport.js";
139
162
 
140
163
  /**
141
164
  * Inline bootstrap for the document shell: installs the `self._$SC`