@solidjs/web 2.0.0-beta.27 → 2.0.0-beta.28
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.
- package/dist/server.cjs +23 -6
- package/dist/server.js +23 -6
- package/frames/dist/server.cjs +22 -5
- package/frames/dist/server.js +22 -5
- package/package.json +3 -3
- package/server-functions/dist/client.cjs +13 -0
- package/server-functions/dist/client.js +13 -1
- package/server-functions/dist/server.cjs +33 -0
- package/server-functions/dist/server.js +33 -1
- package/types/frames/client.d.ts +1 -0
- package/types/frames/server.d.ts +28 -0
- package/types/server-functions/client.d.ts +1 -0
- package/types/server-functions/server.d.ts +30 -2
- package/types/server-functions/shared.d.ts +13 -0
- package/types-cjs/frames/client.d.cts +1 -0
- package/types-cjs/frames/server.d.cts +28 -0
- package/types-cjs/server-functions/client.d.cts +1 -0
- package/types-cjs/server-functions/server.d.cts +30 -2
- package/types-cjs/server-functions/shared.d.cts +13 -0
package/dist/server.cjs
CHANGED
|
@@ -199,7 +199,24 @@ function createAssetTracking() {
|
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function warnUnresolvedModuleAssets(moduleUrl, warned) {
|
|
203
|
+
if (warned.has(moduleUrl)) return;
|
|
204
|
+
warned.add(moduleUrl);
|
|
205
|
+
console.error(`Asset manifest returned no client assets for module "${moduleUrl}". ` + "If this module is a server-rendered lazy() component, its entry will be missing from " + "the serialized hydration asset map, the client will be unable to preload it, and " + "hydration will fail with 'lazy() module \"…\" was not preloaded before hydration'. " + "This means the integration's asset resolver (dev manifest bridge or build client " + "manifest) failed to answer for this module — check the integration's server logs, " + "restart the dev server, or verify the module is included in the client build.");
|
|
206
|
+
}
|
|
207
|
+
function guardResolvedAssets(moduleUrl, result, warned) {
|
|
208
|
+
if (result && typeof result.then === "function") {
|
|
209
|
+
return result.then(assets => {
|
|
210
|
+
if (!assets || !assets.js || !assets.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
211
|
+
return assets;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
if (!result || !result.js || !result.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
function applyAssetTracking(context, tracking, manifest, noScripts) {
|
|
218
|
+
const warned = new Set();
|
|
219
|
+
const guard = noScripts ? resolve => resolve : resolve => moduleUrl => guardResolvedAssets(moduleUrl, resolve(moduleUrl), warned);
|
|
203
220
|
Object.defineProperty(context, "_currentBoundaryId", {
|
|
204
221
|
get() {
|
|
205
222
|
return tracking.currentBoundaryId;
|
|
@@ -213,15 +230,15 @@ function applyAssetTracking(context, tracking, manifest) {
|
|
|
213
230
|
context.registerModule = tracking.registerModule;
|
|
214
231
|
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
215
232
|
if (typeof manifest === "function") {
|
|
216
|
-
context.resolveAssets = manifest;
|
|
233
|
+
context.resolveAssets = guard(manifest);
|
|
217
234
|
} else if (manifest && typeof manifest.resolve === "function") {
|
|
218
|
-
context.resolveAssets = key => manifest.resolve(key);
|
|
235
|
+
context.resolveAssets = guard(key => manifest.resolve(key));
|
|
219
236
|
if (typeof manifest.resolveSync === "function") {
|
|
220
237
|
context.resolveAssetsSync = key => manifest.resolveSync(key);
|
|
221
238
|
}
|
|
222
239
|
} else if (manifest) {
|
|
223
240
|
const resolve = moduleUrl => resolveAssets(moduleUrl, manifest);
|
|
224
|
-
context.resolveAssets = resolve;
|
|
241
|
+
context.resolveAssets = guard(resolve);
|
|
225
242
|
context.resolveAssetsSync = resolve;
|
|
226
243
|
}
|
|
227
244
|
}
|
|
@@ -277,7 +294,7 @@ function renderToString(code, options = {}) {
|
|
|
277
294
|
tracking.emittedAssets.add(value);
|
|
278
295
|
}
|
|
279
296
|
};
|
|
280
|
-
applyAssetTracking(solidJs.sharedConfig.context, tracking, manifest);
|
|
297
|
+
applyAssetTracking(solidJs.sharedConfig.context, tracking, manifest, noScripts);
|
|
281
298
|
registerEntryAssets(manifest);
|
|
282
299
|
let html = solidJs.createRoot(d => {
|
|
283
300
|
setTimeout(d);
|
|
@@ -565,7 +582,7 @@ function renderToStream(code, options = {}) {
|
|
|
565
582
|
});
|
|
566
583
|
}
|
|
567
584
|
};
|
|
568
|
-
applyAssetTracking(context, tracking, manifest);
|
|
585
|
+
applyAssetTracking(context, tracking, manifest, noScripts);
|
|
569
586
|
registerEntryAssets(manifest);
|
|
570
587
|
let html = solidJs.createRoot(d => {
|
|
571
588
|
dispose = d;
|
package/dist/server.js
CHANGED
|
@@ -198,7 +198,24 @@ function createAssetTracking() {
|
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function warnUnresolvedModuleAssets(moduleUrl, warned) {
|
|
202
|
+
if (warned.has(moduleUrl)) return;
|
|
203
|
+
warned.add(moduleUrl);
|
|
204
|
+
console.error(`Asset manifest returned no client assets for module "${moduleUrl}". ` + "If this module is a server-rendered lazy() component, its entry will be missing from " + "the serialized hydration asset map, the client will be unable to preload it, and " + "hydration will fail with 'lazy() module \"…\" was not preloaded before hydration'. " + "This means the integration's asset resolver (dev manifest bridge or build client " + "manifest) failed to answer for this module — check the integration's server logs, " + "restart the dev server, or verify the module is included in the client build.");
|
|
205
|
+
}
|
|
206
|
+
function guardResolvedAssets(moduleUrl, result, warned) {
|
|
207
|
+
if (result && typeof result.then === "function") {
|
|
208
|
+
return result.then(assets => {
|
|
209
|
+
if (!assets || !assets.js || !assets.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
210
|
+
return assets;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (!result || !result.js || !result.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
function applyAssetTracking(context, tracking, manifest, noScripts) {
|
|
217
|
+
const warned = new Set();
|
|
218
|
+
const guard = noScripts ? resolve => resolve : resolve => moduleUrl => guardResolvedAssets(moduleUrl, resolve(moduleUrl), warned);
|
|
202
219
|
Object.defineProperty(context, "_currentBoundaryId", {
|
|
203
220
|
get() {
|
|
204
221
|
return tracking.currentBoundaryId;
|
|
@@ -212,15 +229,15 @@ function applyAssetTracking(context, tracking, manifest) {
|
|
|
212
229
|
context.registerModule = tracking.registerModule;
|
|
213
230
|
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
214
231
|
if (typeof manifest === "function") {
|
|
215
|
-
context.resolveAssets = manifest;
|
|
232
|
+
context.resolveAssets = guard(manifest);
|
|
216
233
|
} else if (manifest && typeof manifest.resolve === "function") {
|
|
217
|
-
context.resolveAssets = key => manifest.resolve(key);
|
|
234
|
+
context.resolveAssets = guard(key => manifest.resolve(key));
|
|
218
235
|
if (typeof manifest.resolveSync === "function") {
|
|
219
236
|
context.resolveAssetsSync = key => manifest.resolveSync(key);
|
|
220
237
|
}
|
|
221
238
|
} else if (manifest) {
|
|
222
239
|
const resolve = moduleUrl => resolveAssets(moduleUrl, manifest);
|
|
223
|
-
context.resolveAssets = resolve;
|
|
240
|
+
context.resolveAssets = guard(resolve);
|
|
224
241
|
context.resolveAssetsSync = resolve;
|
|
225
242
|
}
|
|
226
243
|
}
|
|
@@ -276,7 +293,7 @@ function renderToString(code, options = {}) {
|
|
|
276
293
|
tracking.emittedAssets.add(value);
|
|
277
294
|
}
|
|
278
295
|
};
|
|
279
|
-
applyAssetTracking(sharedConfig.context, tracking, manifest);
|
|
296
|
+
applyAssetTracking(sharedConfig.context, tracking, manifest, noScripts);
|
|
280
297
|
registerEntryAssets(manifest);
|
|
281
298
|
let html = createRoot(d => {
|
|
282
299
|
setTimeout(d);
|
|
@@ -564,7 +581,7 @@ function renderToStream(code, options = {}) {
|
|
|
564
581
|
});
|
|
565
582
|
}
|
|
566
583
|
};
|
|
567
|
-
applyAssetTracking(context, tracking, manifest);
|
|
584
|
+
applyAssetTracking(context, tracking, manifest, noScripts);
|
|
568
585
|
registerEntryAssets(manifest);
|
|
569
586
|
let html = createRoot(d => {
|
|
570
587
|
dispose = d;
|
package/frames/dist/server.cjs
CHANGED
|
@@ -220,7 +220,24 @@ function createAssetTracking() {
|
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function warnUnresolvedModuleAssets(moduleUrl, warned) {
|
|
224
|
+
if (warned.has(moduleUrl)) return;
|
|
225
|
+
warned.add(moduleUrl);
|
|
226
|
+
console.error(`Asset manifest returned no client assets for module "${moduleUrl}". ` + "If this module is a server-rendered lazy() component, its entry will be missing from " + "the serialized hydration asset map, the client will be unable to preload it, and " + "hydration will fail with 'lazy() module \"…\" was not preloaded before hydration'. " + "This means the integration's asset resolver (dev manifest bridge or build client " + "manifest) failed to answer for this module — check the integration's server logs, " + "restart the dev server, or verify the module is included in the client build.");
|
|
227
|
+
}
|
|
228
|
+
function guardResolvedAssets(moduleUrl, result, warned) {
|
|
229
|
+
if (result && typeof result.then === "function") {
|
|
230
|
+
return result.then(assets => {
|
|
231
|
+
if (!assets || !assets.js || !assets.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
232
|
+
return assets;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
if (!result || !result.js || !result.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
function applyAssetTracking(context, tracking, manifest, noScripts) {
|
|
239
|
+
const warned = new Set();
|
|
240
|
+
const guard = noScripts ? resolve => resolve : resolve => moduleUrl => guardResolvedAssets(moduleUrl, resolve(moduleUrl), warned);
|
|
224
241
|
Object.defineProperty(context, "_currentBoundaryId", {
|
|
225
242
|
get() {
|
|
226
243
|
return tracking.currentBoundaryId;
|
|
@@ -234,15 +251,15 @@ function applyAssetTracking(context, tracking, manifest) {
|
|
|
234
251
|
context.registerModule = tracking.registerModule;
|
|
235
252
|
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
236
253
|
if (typeof manifest === "function") {
|
|
237
|
-
context.resolveAssets = manifest;
|
|
254
|
+
context.resolveAssets = guard(manifest);
|
|
238
255
|
} else if (manifest && typeof manifest.resolve === "function") {
|
|
239
|
-
context.resolveAssets = key => manifest.resolve(key);
|
|
256
|
+
context.resolveAssets = guard(key => manifest.resolve(key));
|
|
240
257
|
if (typeof manifest.resolveSync === "function") {
|
|
241
258
|
context.resolveAssetsSync = key => manifest.resolveSync(key);
|
|
242
259
|
}
|
|
243
260
|
} else if (manifest) {
|
|
244
261
|
const resolve = moduleUrl => resolveAssets(moduleUrl, manifest);
|
|
245
|
-
context.resolveAssets = resolve;
|
|
262
|
+
context.resolveAssets = guard(resolve);
|
|
246
263
|
context.resolveAssetsSync = resolve;
|
|
247
264
|
}
|
|
248
265
|
}
|
|
@@ -521,7 +538,7 @@ function renderToStream(code, options = {}) {
|
|
|
521
538
|
});
|
|
522
539
|
}
|
|
523
540
|
};
|
|
524
|
-
applyAssetTracking(context, tracking, manifest);
|
|
541
|
+
applyAssetTracking(context, tracking, manifest, noScripts);
|
|
525
542
|
registerEntryAssets(manifest);
|
|
526
543
|
let html = solidJs.createRoot(d => {
|
|
527
544
|
dispose = d;
|
package/frames/dist/server.js
CHANGED
|
@@ -218,7 +218,24 @@ function createAssetTracking() {
|
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function warnUnresolvedModuleAssets(moduleUrl, warned) {
|
|
222
|
+
if (warned.has(moduleUrl)) return;
|
|
223
|
+
warned.add(moduleUrl);
|
|
224
|
+
console.error(`Asset manifest returned no client assets for module "${moduleUrl}". ` + "If this module is a server-rendered lazy() component, its entry will be missing from " + "the serialized hydration asset map, the client will be unable to preload it, and " + "hydration will fail with 'lazy() module \"…\" was not preloaded before hydration'. " + "This means the integration's asset resolver (dev manifest bridge or build client " + "manifest) failed to answer for this module — check the integration's server logs, " + "restart the dev server, or verify the module is included in the client build.");
|
|
225
|
+
}
|
|
226
|
+
function guardResolvedAssets(moduleUrl, result, warned) {
|
|
227
|
+
if (result && typeof result.then === "function") {
|
|
228
|
+
return result.then(assets => {
|
|
229
|
+
if (!assets || !assets.js || !assets.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
230
|
+
return assets;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (!result || !result.js || !result.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
function applyAssetTracking(context, tracking, manifest, noScripts) {
|
|
237
|
+
const warned = new Set();
|
|
238
|
+
const guard = noScripts ? resolve => resolve : resolve => moduleUrl => guardResolvedAssets(moduleUrl, resolve(moduleUrl), warned);
|
|
222
239
|
Object.defineProperty(context, "_currentBoundaryId", {
|
|
223
240
|
get() {
|
|
224
241
|
return tracking.currentBoundaryId;
|
|
@@ -232,15 +249,15 @@ function applyAssetTracking(context, tracking, manifest) {
|
|
|
232
249
|
context.registerModule = tracking.registerModule;
|
|
233
250
|
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
234
251
|
if (typeof manifest === "function") {
|
|
235
|
-
context.resolveAssets = manifest;
|
|
252
|
+
context.resolveAssets = guard(manifest);
|
|
236
253
|
} else if (manifest && typeof manifest.resolve === "function") {
|
|
237
|
-
context.resolveAssets = key => manifest.resolve(key);
|
|
254
|
+
context.resolveAssets = guard(key => manifest.resolve(key));
|
|
238
255
|
if (typeof manifest.resolveSync === "function") {
|
|
239
256
|
context.resolveAssetsSync = key => manifest.resolveSync(key);
|
|
240
257
|
}
|
|
241
258
|
} else if (manifest) {
|
|
242
259
|
const resolve = moduleUrl => resolveAssets(moduleUrl, manifest);
|
|
243
|
-
context.resolveAssets = resolve;
|
|
260
|
+
context.resolveAssets = guard(resolve);
|
|
244
261
|
context.resolveAssetsSync = resolve;
|
|
245
262
|
}
|
|
246
263
|
}
|
|
@@ -519,7 +536,7 @@ function renderToStream(code, options = {}) {
|
|
|
519
536
|
});
|
|
520
537
|
}
|
|
521
538
|
};
|
|
522
|
-
applyAssetTracking(context, tracking, manifest);
|
|
539
|
+
applyAssetTracking(context, tracking, manifest, noScripts);
|
|
523
540
|
registerEntryAssets(manifest);
|
|
524
541
|
let html = createRoot(d => {
|
|
525
542
|
dispose = d;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/web",
|
|
3
3
|
"description": "Solid's web runtime: client rendering, hydration, SSR, and DOM-specific control flow (Portal, Dynamic).",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.28",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -316,10 +316,10 @@
|
|
|
316
316
|
"seroval-plugins": "~1.5.4"
|
|
317
317
|
},
|
|
318
318
|
"peerDependencies": {
|
|
319
|
-
"solid-js": "^2.0.0-beta.
|
|
319
|
+
"solid-js": "^2.0.0-beta.28"
|
|
320
320
|
},
|
|
321
321
|
"devDependencies": {
|
|
322
|
-
"solid-js": "2.0.0-beta.
|
|
322
|
+
"solid-js": "2.0.0-beta.28"
|
|
323
323
|
},
|
|
324
324
|
"scripts": {
|
|
325
325
|
"build": "npm-run-all -nl build:clean types:copy-jsx build:js",
|
|
@@ -287,6 +287,18 @@ async function decodeResponse(response, codecOptions) {
|
|
|
287
287
|
if (!response.body) return undefined;
|
|
288
288
|
return await extractBody(response, codecOptions === undefined ? codecConfig.codec : codecOptions);
|
|
289
289
|
}
|
|
290
|
+
async function decodeResponsePayload(response, codecOptions) {
|
|
291
|
+
const decoded = await decodeResponse(response, codecOptions);
|
|
292
|
+
if (decoded !== undefined && response.headers.has(SINGLE_FLIGHT_HEADER)) {
|
|
293
|
+
return {
|
|
294
|
+
value: decoded.value,
|
|
295
|
+
flightData: decoded.data
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
value: decoded
|
|
300
|
+
};
|
|
301
|
+
}
|
|
290
302
|
|
|
291
303
|
const config = {
|
|
292
304
|
endpoint: "/_server",
|
|
@@ -507,6 +519,7 @@ exports.configureServerFunctionsClient = configureServerFunctionsClient;
|
|
|
507
519
|
exports.createServerReference = createServerReference;
|
|
508
520
|
exports.decodeErrorHeaderValue = decodeErrorHeaderValue;
|
|
509
521
|
exports.decodeResponse = decodeResponse;
|
|
522
|
+
exports.decodeResponsePayload = decodeResponsePayload;
|
|
510
523
|
exports.encodeErrorHeaderValue = encodeErrorHeaderValue;
|
|
511
524
|
exports.getServerFunctionMetadata = getServerFunctionMetadata;
|
|
512
525
|
exports.hasFlashCookie = hasFlashCookie;
|
|
@@ -285,6 +285,18 @@ async function decodeResponse(response, codecOptions) {
|
|
|
285
285
|
if (!response.body) return undefined;
|
|
286
286
|
return await extractBody(response, codecOptions === undefined ? codecConfig.codec : codecOptions);
|
|
287
287
|
}
|
|
288
|
+
async function decodeResponsePayload(response, codecOptions) {
|
|
289
|
+
const decoded = await decodeResponse(response, codecOptions);
|
|
290
|
+
if (decoded !== undefined && response.headers.has(SINGLE_FLIGHT_HEADER)) {
|
|
291
|
+
return {
|
|
292
|
+
value: decoded.value,
|
|
293
|
+
flightData: decoded.data
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
value: decoded
|
|
298
|
+
};
|
|
299
|
+
}
|
|
288
300
|
|
|
289
301
|
const config = {
|
|
290
302
|
endpoint: "/_server",
|
|
@@ -494,4 +506,4 @@ function registerServerReference() {
|
|
|
494
506
|
throw new Error("registerServerReference must not be called in the client build");
|
|
495
507
|
}
|
|
496
508
|
|
|
497
|
-
export { ERROR_HEADER, FLASH_COOKIE, FUNCTION_HEADER, GET, INSTANCE_HEADER, SINGLE_FLIGHT_HEADER, clearFlashCookie, configureServerFunctionsClient, createServerReference, decodeErrorHeaderValue, decodeResponse, encodeErrorHeaderValue, getServerFunctionMetadata, hasFlashCookie, isServerFunction, registerServerReference, subscribeFlightData, withMeta };
|
|
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 };
|
|
@@ -8,6 +8,7 @@ const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
|
8
8
|
function isResponseEnvelope(value) {
|
|
9
9
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
10
10
|
}
|
|
11
|
+
const REVALIDATE_HEADER = "X-Revalidate";
|
|
11
12
|
|
|
12
13
|
seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
|
|
13
14
|
const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : seroval.Feature.ErrorPrototypeStack;
|
|
@@ -343,6 +344,18 @@ async function decodeResponse(response, codecOptions) {
|
|
|
343
344
|
if (!response.body) return undefined;
|
|
344
345
|
return await extractBody(response, codecOptions === undefined ? codecConfig.codec : codecOptions);
|
|
345
346
|
}
|
|
347
|
+
async function decodeResponsePayload(response, codecOptions) {
|
|
348
|
+
const decoded = await decodeResponse(response, codecOptions);
|
|
349
|
+
if (decoded !== undefined && response.headers.has(SINGLE_FLIGHT_HEADER)) {
|
|
350
|
+
return {
|
|
351
|
+
value: decoded.value,
|
|
352
|
+
flightData: decoded.data
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
value: decoded
|
|
357
|
+
};
|
|
358
|
+
}
|
|
346
359
|
|
|
347
360
|
function encodeInputValue(value) {
|
|
348
361
|
if (value instanceof FormData) return {
|
|
@@ -532,6 +545,8 @@ async function parseArguments(request, url, instance, codec) {
|
|
|
532
545
|
return parsed;
|
|
533
546
|
}
|
|
534
547
|
async function foldFlightData(hook, event, headers, outcome) {
|
|
548
|
+
if (outcome.value instanceof Response && outcome.value.body) return outcome.value;
|
|
549
|
+
digestOutcome(event, outcome);
|
|
535
550
|
const data = await hook(event, outcome);
|
|
536
551
|
if (data === undefined) return outcome.value;
|
|
537
552
|
headers.set(SINGLE_FLIGHT_HEADER, "true");
|
|
@@ -540,6 +555,23 @@ async function foldFlightData(hook, event, headers, outcome) {
|
|
|
540
555
|
data
|
|
541
556
|
};
|
|
542
557
|
}
|
|
558
|
+
function digestOutcome(event, outcome) {
|
|
559
|
+
const {
|
|
560
|
+
request,
|
|
561
|
+
response
|
|
562
|
+
} = outcome;
|
|
563
|
+
outcome.revalidateKeys = response?.headers.get(REVALIDATE_HEADER)?.split(",");
|
|
564
|
+
outcome.foldedHeaders = foldSetCookies(request.headers, [...(event.response?.headers?.getSetCookie() ?? []), ...(response?.headers?.getSetCookie() ?? [])]);
|
|
565
|
+
try {
|
|
566
|
+
const referrer = request.headers.get("referer");
|
|
567
|
+
if (referrer) {
|
|
568
|
+
const location = response?.headers.get("Location");
|
|
569
|
+
const target = location ? new URL(location, request.url) : new URL(referrer);
|
|
570
|
+
if (target.origin === new URL(request.url).origin) outcome.targetUrl = target.toString();
|
|
571
|
+
}
|
|
572
|
+
} catch {
|
|
573
|
+
}
|
|
574
|
+
}
|
|
543
575
|
function parseSetCookie(setCookie) {
|
|
544
576
|
const [pair, ...attributes] = setCookie.split(";");
|
|
545
577
|
const eq = pair.indexOf("=");
|
|
@@ -821,6 +853,7 @@ exports.createServerReference = createServerReference;
|
|
|
821
853
|
exports.decodeErrorHeaderValue = decodeErrorHeaderValue;
|
|
822
854
|
exports.decodeFlashCookie = decodeFlashCookie;
|
|
823
855
|
exports.decodeResponse = decodeResponse;
|
|
856
|
+
exports.decodeResponsePayload = decodeResponsePayload;
|
|
824
857
|
exports.encodeErrorHeaderValue = encodeErrorHeaderValue;
|
|
825
858
|
exports.encodeFlashCookie = encodeFlashCookie;
|
|
826
859
|
exports.foldSetCookies = foldSetCookies;
|
|
@@ -6,6 +6,7 @@ const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
|
6
6
|
function isResponseEnvelope(value) {
|
|
7
7
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
8
8
|
}
|
|
9
|
+
const REVALIDATE_HEADER = "X-Revalidate";
|
|
9
10
|
|
|
10
11
|
Feature.AggregateError | Feature.BigIntTypedArray;
|
|
11
12
|
const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : Feature.ErrorPrototypeStack;
|
|
@@ -341,6 +342,18 @@ async function decodeResponse(response, codecOptions) {
|
|
|
341
342
|
if (!response.body) return undefined;
|
|
342
343
|
return await extractBody(response, codecOptions === undefined ? codecConfig.codec : codecOptions);
|
|
343
344
|
}
|
|
345
|
+
async function decodeResponsePayload(response, codecOptions) {
|
|
346
|
+
const decoded = await decodeResponse(response, codecOptions);
|
|
347
|
+
if (decoded !== undefined && response.headers.has(SINGLE_FLIGHT_HEADER)) {
|
|
348
|
+
return {
|
|
349
|
+
value: decoded.value,
|
|
350
|
+
flightData: decoded.data
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
return {
|
|
354
|
+
value: decoded
|
|
355
|
+
};
|
|
356
|
+
}
|
|
344
357
|
|
|
345
358
|
function encodeInputValue(value) {
|
|
346
359
|
if (value instanceof FormData) return {
|
|
@@ -530,6 +543,8 @@ async function parseArguments(request, url, instance, codec) {
|
|
|
530
543
|
return parsed;
|
|
531
544
|
}
|
|
532
545
|
async function foldFlightData(hook, event, headers, outcome) {
|
|
546
|
+
if (outcome.value instanceof Response && outcome.value.body) return outcome.value;
|
|
547
|
+
digestOutcome(event, outcome);
|
|
533
548
|
const data = await hook(event, outcome);
|
|
534
549
|
if (data === undefined) return outcome.value;
|
|
535
550
|
headers.set(SINGLE_FLIGHT_HEADER, "true");
|
|
@@ -538,6 +553,23 @@ async function foldFlightData(hook, event, headers, outcome) {
|
|
|
538
553
|
data
|
|
539
554
|
};
|
|
540
555
|
}
|
|
556
|
+
function digestOutcome(event, outcome) {
|
|
557
|
+
const {
|
|
558
|
+
request,
|
|
559
|
+
response
|
|
560
|
+
} = outcome;
|
|
561
|
+
outcome.revalidateKeys = response?.headers.get(REVALIDATE_HEADER)?.split(",");
|
|
562
|
+
outcome.foldedHeaders = foldSetCookies(request.headers, [...(event.response?.headers?.getSetCookie() ?? []), ...(response?.headers?.getSetCookie() ?? [])]);
|
|
563
|
+
try {
|
|
564
|
+
const referrer = request.headers.get("referer");
|
|
565
|
+
if (referrer) {
|
|
566
|
+
const location = response?.headers.get("Location");
|
|
567
|
+
const target = location ? new URL(location, request.url) : new URL(referrer);
|
|
568
|
+
if (target.origin === new URL(request.url).origin) outcome.targetUrl = target.toString();
|
|
569
|
+
}
|
|
570
|
+
} catch {
|
|
571
|
+
}
|
|
572
|
+
}
|
|
541
573
|
function parseSetCookie(setCookie) {
|
|
542
574
|
const [pair, ...attributes] = setCookie.split(";");
|
|
543
575
|
const eq = pair.indexOf("=");
|
|
@@ -806,4 +838,4 @@ async function handleServerFunctionRequest(request, options = {}) {
|
|
|
806
838
|
}
|
|
807
839
|
}
|
|
808
840
|
|
|
809
|
-
export { ERROR_HEADER, FLASH_COOKIE, FUNCTION_HEADER, GET, INSTANCE_HEADER, SINGLE_FLIGHT_HEADER, clearFlashCookie, configureServerFunctionsServer, createNoJSHandler, createServerReference, decodeErrorHeaderValue, decodeFlashCookie, decodeResponse, encodeErrorHeaderValue, encodeFlashCookie, foldSetCookies, getServerFunction, getServerFunctionMeta, getServerFunctionMetadata, handleServerFunctionRequest, hasFlashCookie, isServerFunction, registerServerFunction, registerServerReference, subscribeFlightData, withMeta };
|
|
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 };
|
package/types/frames/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { createFrame, createFrameHost, createFrameElement, FRAME_APPLIED_EVENT } from "./frame-client.js";
|
|
2
2
|
export { FRAME_STREAM_HEADER, applyFrameResponse, isFrameStreamResponse, createServerComponentHandler } from "./frame-transport.js";
|
|
3
3
|
export { createJSONDataTable } from "./serializer.js";
|
|
4
|
+
export type { Slot } from "./server.js";
|
|
4
5
|
export declare function getFrameHost(): any;
|
|
5
6
|
/**
|
|
6
7
|
* Installs the server-component transport policy on the server-function
|
package/types/frames/server.d.ts
CHANGED
|
@@ -1,2 +1,30 @@
|
|
|
1
|
+
import type { Element as SolidElement } from "solid-js";
|
|
2
|
+
/**
|
|
3
|
+
* A client position in a server component: a prop the server renders (as JSX
|
|
4
|
+
* or by calling it) where client-owned markup belongs. `P` is the client
|
|
5
|
+
* component's own props, so a server component can reference the client
|
|
6
|
+
* component's type directly instead of restating it.
|
|
7
|
+
*
|
|
8
|
+
* Arguments are classified by VALUE, not by name — any prop may carry any of
|
|
9
|
+
* these:
|
|
10
|
+
*
|
|
11
|
+
* - primitives ride the chunk;
|
|
12
|
+
* - server JSX streams as a nested region (html once, never data);
|
|
13
|
+
* - anything else serializes as a data record.
|
|
14
|
+
*
|
|
15
|
+
* Async server JSX in an argument needs its own boundary: the region is
|
|
16
|
+
* emitted as one finished string, so a bare async read has no fallback to
|
|
17
|
+
* show and no fragment to reveal into.
|
|
18
|
+
*
|
|
19
|
+
* `$key` names the occurrence so client state follows an entity across
|
|
20
|
+
* responses rather than being positional — the slot-level analogue of `For`'s
|
|
21
|
+
* `keyed`, for when references can't carry identity because every response
|
|
22
|
+
* re-creates everything. It is occurrence identity, not client data: it is
|
|
23
|
+
* stripped before the client component sees its props. Positional identity is
|
|
24
|
+
* the right default; `$key` matters when a live list reorders.
|
|
25
|
+
*/
|
|
26
|
+
export type Slot<P = {}> = (props: P & {
|
|
27
|
+
$key?: string | number;
|
|
28
|
+
}) => SolidElement;
|
|
1
29
|
export { renderToFrameStream, renderServerComponent, serverComponentResponse, frameTransformResult, createFrameSink, frameTransformDirectResult, ServerComponentPlugin, SERVER_COMPONENT_BOOTSTRAP } from "./frame-sink.js";
|
|
2
30
|
export { FRAME_STREAM_HEADER, isFrameStreamResponse } from "./frame-transport.js";
|
|
@@ -11,6 +11,7 @@ export {
|
|
|
11
11
|
clearFlashCookie,
|
|
12
12
|
decodeErrorHeaderValue,
|
|
13
13
|
decodeResponse,
|
|
14
|
+
decodeResponsePayload,
|
|
14
15
|
encodeErrorHeaderValue,
|
|
15
16
|
getServerFunctionMetadata,
|
|
16
17
|
hasFlashCookie,
|
|
@@ -68,6 +69,29 @@ export interface ServerFunctionOutcome {
|
|
|
68
69
|
request: Request;
|
|
69
70
|
/** Whether the result was thrown rather than returned. */
|
|
70
71
|
thrown: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The URL the client will show after the mutation — the redirect
|
|
74
|
+
* `Location` when the outcome carries one (resolved against the request
|
|
75
|
+
* URL, as a browser would), the referring page otherwise. Undefined
|
|
76
|
+
* without a usable referer (a non-browser caller has no page to produce
|
|
77
|
+
* data for) and for redirects leaving the app's origin: produce no data
|
|
78
|
+
* when this is undefined.
|
|
79
|
+
*/
|
|
80
|
+
targetUrl: string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* The outcome's `X-Revalidate` keys, split — the invalidation scope the
|
|
83
|
+
* mutation declared. Undefined when the outcome carries none (integrations
|
|
84
|
+
* typically collect everything for the target in that case).
|
|
85
|
+
*/
|
|
86
|
+
revalidateKeys: string[] | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* The request headers with the mutation's cookie effects applied: the
|
|
89
|
+
* event response's `Set-Cookie`s (set during the call), then the
|
|
90
|
+
* outcome's own (e.g. `redirect(to, { headers })`), later winning on
|
|
91
|
+
* conflict, deletions honored. Build the data-collection request from
|
|
92
|
+
* these so re-run reads observe post-mutation cookie state.
|
|
93
|
+
*/
|
|
94
|
+
foldedHeaders: Headers;
|
|
71
95
|
}
|
|
72
96
|
|
|
73
97
|
/**
|
|
@@ -82,8 +106,12 @@ export interface ServerFunctionOutcome {
|
|
|
82
106
|
* Runs after `transformResult`, only for scripted calls that sent
|
|
83
107
|
* `SINGLE_FLIGHT_HEADER` on the request, on returned results and thrown
|
|
84
108
|
* `Response`/`ResponseEnvelope` control-flow signals alike (plain thrown
|
|
85
|
-
* errors never collect
|
|
86
|
-
*
|
|
109
|
+
* errors never collect, and neither do raw body-carrying `Response` values
|
|
110
|
+
* — those are the caller's verbatim payload). The handler owns the
|
|
111
|
+
* enveloping: contributed data ships as `{ value, data }` under the
|
|
112
|
+
* single-flight response header. The generic halves of collection arrive
|
|
113
|
+
* pre-digested on the outcome (`targetUrl`, `revalidateKeys`,
|
|
114
|
+
* `foldedHeaders`); the hook supplies only the data strategy.
|
|
87
115
|
*/
|
|
88
116
|
export type CollectFlightDataHook = (
|
|
89
117
|
event: ServerFunctionEvent,
|
|
@@ -405,6 +405,19 @@ export function decodeResponse<T = unknown>(
|
|
|
405
405
|
codecOptions?: JSONCodecOptions
|
|
406
406
|
): Promise<T | undefined>;
|
|
407
407
|
|
|
408
|
+
/**
|
|
409
|
+
* `decodeResponse` plus the single-flight envelope split: when the response
|
|
410
|
+
* carries the single-flight header the decoded `{ value, data }` payload is
|
|
411
|
+
* unwrapped into `{ value, flightData }`; otherwise the decoded body (or
|
|
412
|
+
* undefined for body-less responses) rides as `{ value }`. Integrations
|
|
413
|
+
* that apply response metadata themselves use this so the payload shape
|
|
414
|
+
* stays core's own.
|
|
415
|
+
*/
|
|
416
|
+
export function decodeResponsePayload<T = unknown, D = unknown>(
|
|
417
|
+
response: Response,
|
|
418
|
+
codecOptions?: JSONCodecOptions
|
|
419
|
+
): Promise<{ value: T | undefined; flightData?: D }>;
|
|
420
|
+
|
|
408
421
|
/**
|
|
409
422
|
* Frame one payload for the server-function wire: a `;0x<len32>;` length
|
|
410
423
|
* prefix followed by the utf-8 data. Both transports (server-function
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { createFrame, createFrameHost, createFrameElement, FRAME_APPLIED_EVENT } from "./frame-client.cjs";
|
|
2
2
|
export { FRAME_STREAM_HEADER, applyFrameResponse, isFrameStreamResponse, createServerComponentHandler } from "./frame-transport.cjs";
|
|
3
3
|
export { createJSONDataTable } from "./serializer.cjs";
|
|
4
|
+
export type { Slot } from "./server.cjs";
|
|
4
5
|
export declare function getFrameHost(): any;
|
|
5
6
|
/**
|
|
6
7
|
* Installs the server-component transport policy on the server-function
|
|
@@ -1,2 +1,30 @@
|
|
|
1
|
+
import type { Element as SolidElement } from "solid-js";
|
|
2
|
+
/**
|
|
3
|
+
* A client position in a server component: a prop the server renders (as JSX
|
|
4
|
+
* or by calling it) where client-owned markup belongs. `P` is the client
|
|
5
|
+
* component's own props, so a server component can reference the client
|
|
6
|
+
* component's type directly instead of restating it.
|
|
7
|
+
*
|
|
8
|
+
* Arguments are classified by VALUE, not by name — any prop may carry any of
|
|
9
|
+
* these:
|
|
10
|
+
*
|
|
11
|
+
* - primitives ride the chunk;
|
|
12
|
+
* - server JSX streams as a nested region (html once, never data);
|
|
13
|
+
* - anything else serializes as a data record.
|
|
14
|
+
*
|
|
15
|
+
* Async server JSX in an argument needs its own boundary: the region is
|
|
16
|
+
* emitted as one finished string, so a bare async read has no fallback to
|
|
17
|
+
* show and no fragment to reveal into.
|
|
18
|
+
*
|
|
19
|
+
* `$key` names the occurrence so client state follows an entity across
|
|
20
|
+
* responses rather than being positional — the slot-level analogue of `For`'s
|
|
21
|
+
* `keyed`, for when references can't carry identity because every response
|
|
22
|
+
* re-creates everything. It is occurrence identity, not client data: it is
|
|
23
|
+
* stripped before the client component sees its props. Positional identity is
|
|
24
|
+
* the right default; `$key` matters when a live list reorders.
|
|
25
|
+
*/
|
|
26
|
+
export type Slot<P = {}> = (props: P & {
|
|
27
|
+
$key?: string | number;
|
|
28
|
+
}) => SolidElement;
|
|
1
29
|
export { renderToFrameStream, renderServerComponent, serverComponentResponse, frameTransformResult, createFrameSink, frameTransformDirectResult, ServerComponentPlugin, SERVER_COMPONENT_BOOTSTRAP } from "./frame-sink.cjs";
|
|
2
30
|
export { FRAME_STREAM_HEADER, isFrameStreamResponse } from "./frame-transport.cjs";
|
|
@@ -11,6 +11,7 @@ export {
|
|
|
11
11
|
clearFlashCookie,
|
|
12
12
|
decodeErrorHeaderValue,
|
|
13
13
|
decodeResponse,
|
|
14
|
+
decodeResponsePayload,
|
|
14
15
|
encodeErrorHeaderValue,
|
|
15
16
|
getServerFunctionMetadata,
|
|
16
17
|
hasFlashCookie,
|
|
@@ -68,6 +69,29 @@ export interface ServerFunctionOutcome {
|
|
|
68
69
|
request: Request;
|
|
69
70
|
/** Whether the result was thrown rather than returned. */
|
|
70
71
|
thrown: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The URL the client will show after the mutation — the redirect
|
|
74
|
+
* `Location` when the outcome carries one (resolved against the request
|
|
75
|
+
* URL, as a browser would), the referring page otherwise. Undefined
|
|
76
|
+
* without a usable referer (a non-browser caller has no page to produce
|
|
77
|
+
* data for) and for redirects leaving the app's origin: produce no data
|
|
78
|
+
* when this is undefined.
|
|
79
|
+
*/
|
|
80
|
+
targetUrl: string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* The outcome's `X-Revalidate` keys, split — the invalidation scope the
|
|
83
|
+
* mutation declared. Undefined when the outcome carries none (integrations
|
|
84
|
+
* typically collect everything for the target in that case).
|
|
85
|
+
*/
|
|
86
|
+
revalidateKeys: string[] | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* The request headers with the mutation's cookie effects applied: the
|
|
89
|
+
* event response's `Set-Cookie`s (set during the call), then the
|
|
90
|
+
* outcome's own (e.g. `redirect(to, { headers })`), later winning on
|
|
91
|
+
* conflict, deletions honored. Build the data-collection request from
|
|
92
|
+
* these so re-run reads observe post-mutation cookie state.
|
|
93
|
+
*/
|
|
94
|
+
foldedHeaders: Headers;
|
|
71
95
|
}
|
|
72
96
|
|
|
73
97
|
/**
|
|
@@ -82,8 +106,12 @@ export interface ServerFunctionOutcome {
|
|
|
82
106
|
* Runs after `transformResult`, only for scripted calls that sent
|
|
83
107
|
* `SINGLE_FLIGHT_HEADER` on the request, on returned results and thrown
|
|
84
108
|
* `Response`/`ResponseEnvelope` control-flow signals alike (plain thrown
|
|
85
|
-
* errors never collect
|
|
86
|
-
*
|
|
109
|
+
* errors never collect, and neither do raw body-carrying `Response` values
|
|
110
|
+
* — those are the caller's verbatim payload). The handler owns the
|
|
111
|
+
* enveloping: contributed data ships as `{ value, data }` under the
|
|
112
|
+
* single-flight response header. The generic halves of collection arrive
|
|
113
|
+
* pre-digested on the outcome (`targetUrl`, `revalidateKeys`,
|
|
114
|
+
* `foldedHeaders`); the hook supplies only the data strategy.
|
|
87
115
|
*/
|
|
88
116
|
export type CollectFlightDataHook = (
|
|
89
117
|
event: ServerFunctionEvent,
|
|
@@ -405,6 +405,19 @@ export function decodeResponse<T = unknown>(
|
|
|
405
405
|
codecOptions?: JSONCodecOptions
|
|
406
406
|
): Promise<T | undefined>;
|
|
407
407
|
|
|
408
|
+
/**
|
|
409
|
+
* `decodeResponse` plus the single-flight envelope split: when the response
|
|
410
|
+
* carries the single-flight header the decoded `{ value, data }` payload is
|
|
411
|
+
* unwrapped into `{ value, flightData }`; otherwise the decoded body (or
|
|
412
|
+
* undefined for body-less responses) rides as `{ value }`. Integrations
|
|
413
|
+
* that apply response metadata themselves use this so the payload shape
|
|
414
|
+
* stays core's own.
|
|
415
|
+
*/
|
|
416
|
+
export function decodeResponsePayload<T = unknown, D = unknown>(
|
|
417
|
+
response: Response,
|
|
418
|
+
codecOptions?: JSONCodecOptions
|
|
419
|
+
): Promise<{ value: T | undefined; flightData?: D }>;
|
|
420
|
+
|
|
408
421
|
/**
|
|
409
422
|
* Frame one payload for the server-function wire: a `;0x<len32>;` length
|
|
410
423
|
* prefix followed by the utf-8 data. Both transports (server-function
|