@sveltejs/kit 2.64.0 → 2.65.0
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/package.json +2 -2
- package/src/core/postbuild/analyse.js +0 -5
- package/src/core/postbuild/prerender.js +2 -0
- package/src/exports/public.d.ts +1 -1
- package/src/exports/vite/build/build_server.js +43 -57
- package/src/exports/vite/build/utils.js +0 -8
- package/src/exports/vite/index.js +226 -178
- package/src/runtime/app/server/remote/command.js +0 -3
- package/src/runtime/app/server/remote/form.js +18 -13
- package/src/runtime/app/server/remote/prerender.js +28 -34
- package/src/runtime/app/server/remote/query.js +105 -94
- package/src/runtime/app/server/remote/requested.js +14 -10
- package/src/runtime/app/server/remote/shared.js +25 -18
- package/src/runtime/client/client.js +19 -13
- package/src/runtime/client/remote-functions/command.svelte.js +5 -30
- package/src/runtime/client/remote-functions/form.svelte.js +62 -82
- package/src/runtime/client/remote-functions/prerender.svelte.js +14 -6
- package/src/runtime/client/remote-functions/query/index.js +6 -14
- package/src/runtime/client/remote-functions/query/instance.svelte.js +20 -0
- package/src/runtime/client/remote-functions/query/proxy.js +3 -3
- package/src/runtime/client/remote-functions/query-batch.svelte.js +59 -68
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +20 -6
- package/src/runtime/client/remote-functions/shared.svelte.js +76 -59
- package/src/runtime/server/page/render.js +20 -80
- package/src/runtime/server/page/server_routing.js +20 -15
- package/src/runtime/server/remote.js +296 -204
- package/src/runtime/server/respond.js +4 -2
- package/src/runtime/shared.js +0 -15
- package/src/types/global-private.d.ts +3 -3
- package/src/types/internal.d.ts +53 -34
- package/src/version.js +1 -1
- package/types/index.d.ts +4 -4
- package/types/index.d.ts.map +1 -1
|
@@ -26,7 +26,7 @@ import { load_svelte_config, process_config } from '../../core/config/index.js';
|
|
|
26
26
|
import { generate_manifest } from '../../core/generate_manifest/index.js';
|
|
27
27
|
import { build_server_nodes } from './build/build_server.js';
|
|
28
28
|
import { build_service_worker } from './build/build_service_worker.js';
|
|
29
|
-
import {
|
|
29
|
+
import { find_deps, resolve_symlinks } from './build/utils.js';
|
|
30
30
|
import { dev } from './dev/index.js';
|
|
31
31
|
import { preview } from './preview/index.js';
|
|
32
32
|
import { error_for_missing_config, get_config_aliases, get_env, normalize_id } from './utils.js';
|
|
@@ -1034,18 +1034,20 @@ async function kit({ svelte_config }) {
|
|
|
1034
1034
|
// see the kit.output.preloadStrategy option for details on why we have multiple options here
|
|
1035
1035
|
const ext = kit.output.preloadStrategy === 'preload-mjs' ? 'mjs' : 'js';
|
|
1036
1036
|
|
|
1037
|
-
// We could always use a relative asset base path here, but it's better for performance not to.
|
|
1038
|
-
// E.g. Vite generates `new URL('/asset.png', import.meta).href` for a relative path vs just '/asset.png'.
|
|
1039
|
-
// That's larger and takes longer to run and also causes an HTML diff between SSR and client
|
|
1040
|
-
// causing us to do a more expensive hydration check.
|
|
1041
|
-
const client_base =
|
|
1042
|
-
kit.paths.relative !== false || kit.paths.assets ? './' : kit_paths_base;
|
|
1043
|
-
|
|
1044
1037
|
const inline = !ssr && svelte_config.kit.output.bundleStrategy === 'inline';
|
|
1045
1038
|
const split = ssr || svelte_config.kit.output.bundleStrategy === 'split';
|
|
1046
1039
|
|
|
1040
|
+
/** @type {string} */
|
|
1041
|
+
const base = (kit.paths.assets || kit.paths.base) + '/';
|
|
1042
|
+
const root_to_assets = prefix + '/assets/';
|
|
1043
|
+
const assets_to_root =
|
|
1044
|
+
prefix
|
|
1045
|
+
.split('/')
|
|
1046
|
+
.map(() => '..')
|
|
1047
|
+
.join('/') + '/../';
|
|
1048
|
+
|
|
1047
1049
|
new_config = {
|
|
1048
|
-
base:
|
|
1050
|
+
base: './',
|
|
1049
1051
|
build: {
|
|
1050
1052
|
copyPublicDir: !ssr,
|
|
1051
1053
|
cssCodeSplit: svelte_config.kit.output.bundleStrategy !== 'inline',
|
|
@@ -1094,6 +1096,32 @@ async function kit({ svelte_config }) {
|
|
|
1094
1096
|
hoistTransitiveImports: false
|
|
1095
1097
|
}
|
|
1096
1098
|
}
|
|
1099
|
+
},
|
|
1100
|
+
experimental: {
|
|
1101
|
+
// Allows us to use relative paths in as many places as we can
|
|
1102
|
+
renderBuiltUrl(filename, { ssr, hostType }) {
|
|
1103
|
+
if (hostType === 'js') {
|
|
1104
|
+
// SSR builds should use an absolute path in JS modules to
|
|
1105
|
+
// match the default Vite behaviour
|
|
1106
|
+
if (ssr) return base + filename;
|
|
1107
|
+
|
|
1108
|
+
// We could always use a relative asset base path here, but it's better for performance not to.
|
|
1109
|
+
// E.g. Vite generates `new URL('/asset.png', import.meta).href` for a relative path vs just '/asset.png'.
|
|
1110
|
+
// That's larger and takes longer to run and also causes an HTML diff between SSR and client
|
|
1111
|
+
// causing us to do a more expensive hydration check.
|
|
1112
|
+
return {
|
|
1113
|
+
relative: kit.paths.relative !== false || !!kit.paths.assets
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
// _app/immutable/assets files
|
|
1118
|
+
if (filename.startsWith(root_to_assets)) {
|
|
1119
|
+
return `./${filename.slice(root_to_assets.length)}`;
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
// static dir files
|
|
1123
|
+
return assets_to_root + filename;
|
|
1124
|
+
}
|
|
1097
1125
|
}
|
|
1098
1126
|
};
|
|
1099
1127
|
|
|
@@ -1217,6 +1245,20 @@ async function kit({ svelte_config }) {
|
|
|
1217
1245
|
})};\n`
|
|
1218
1246
|
);
|
|
1219
1247
|
|
|
1248
|
+
const server_chunks = Object.values(server_bundle);
|
|
1249
|
+
const assets_path = `${kit.appDir}/immutable/assets`;
|
|
1250
|
+
|
|
1251
|
+
// first, build server nodes without the client manifest so we can analyse it
|
|
1252
|
+
build_server_nodes(
|
|
1253
|
+
out,
|
|
1254
|
+
kit,
|
|
1255
|
+
manifest_data,
|
|
1256
|
+
server_manifest,
|
|
1257
|
+
null,
|
|
1258
|
+
assets_path,
|
|
1259
|
+
server_chunks
|
|
1260
|
+
);
|
|
1261
|
+
|
|
1220
1262
|
log.info('Analysing routes');
|
|
1221
1263
|
|
|
1222
1264
|
const { metadata } = await analyse({
|
|
@@ -1242,191 +1284,199 @@ async function kit({ svelte_config }) {
|
|
|
1242
1284
|
metadata.nodes
|
|
1243
1285
|
);
|
|
1244
1286
|
|
|
1245
|
-
secondary_build_started = true;
|
|
1246
|
-
|
|
1247
|
-
let client_chunks;
|
|
1248
|
-
|
|
1249
|
-
try {
|
|
1250
|
-
const bundle = /** @type {import('vite').Rollup.RollupOutput} */ (
|
|
1251
|
-
await vite.build({
|
|
1252
|
-
configFile: vite_config.configFile,
|
|
1253
|
-
// CLI args
|
|
1254
|
-
mode: vite_config_env.mode,
|
|
1255
|
-
logLevel: vite_config.logLevel,
|
|
1256
|
-
clearScreen: vite_config.clearScreen,
|
|
1257
|
-
build: {
|
|
1258
|
-
minify: initial_config.build?.minify,
|
|
1259
|
-
assetsInlineLimit: vite_config.build.assetsInlineLimit,
|
|
1260
|
-
sourcemap: vite_config.build.sourcemap
|
|
1261
|
-
},
|
|
1262
|
-
optimizeDeps: {
|
|
1263
|
-
force: vite_config.optimizeDeps.force
|
|
1264
|
-
}
|
|
1265
|
-
})
|
|
1266
|
-
);
|
|
1267
|
-
|
|
1268
|
-
client_chunks = bundle.output;
|
|
1269
|
-
} catch (e) {
|
|
1270
|
-
const error =
|
|
1271
|
-
e instanceof Error ? e : new Error(/** @type {any} */ (e).message ?? e ?? '<unknown>');
|
|
1272
|
-
|
|
1273
|
-
// without this, errors that occur during the secondary build
|
|
1274
|
-
// will be logged twice
|
|
1275
|
-
throw stackless(error.stack ?? error.message);
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
// We use `build.ssrEmitAssets` so that asset URLs created from
|
|
1279
|
-
// imports in server-only modules correspond to files in the build,
|
|
1280
|
-
// but we don't want to copy over CSS imports as these are already
|
|
1281
|
-
// accounted for in the client bundle. In most cases it would be
|
|
1282
|
-
// a no-op, but for SSR builds `url(...)` paths are handled
|
|
1283
|
-
// differently (relative for client, absolute for server)
|
|
1284
|
-
// resulting in different hashes, and thus duplication
|
|
1285
|
-
const ssr_stylesheets = new Set(
|
|
1286
|
-
Object.values(server_manifest)
|
|
1287
|
-
.map((chunk) => chunk.css ?? [])
|
|
1288
|
-
.flat()
|
|
1289
|
-
);
|
|
1290
|
-
|
|
1291
|
-
const assets_path = `${kit.appDir}/immutable/assets`;
|
|
1292
1287
|
const server_assets = `${out}/server/${assets_path}`;
|
|
1293
1288
|
const client_assets = `${out}/client/${assets_path}`;
|
|
1294
1289
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
const dest = `${client_assets}/${file}`;
|
|
1290
|
+
const skip_client_build = manifest_data.nodes.every(
|
|
1291
|
+
(node) => node.page_options?.csr === false
|
|
1292
|
+
);
|
|
1299
1293
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1294
|
+
/** @type {Manifest | null} */
|
|
1295
|
+
let client_manifest = null;
|
|
1296
|
+
|
|
1297
|
+
if (!skip_client_build) {
|
|
1298
|
+
let client_chunks;
|
|
1299
|
+
|
|
1300
|
+
try {
|
|
1301
|
+
secondary_build_started = true;
|
|
1302
|
+
|
|
1303
|
+
const bundle = /** @type {import('vite').Rollup.RollupOutput} */ (
|
|
1304
|
+
await vite.build({
|
|
1305
|
+
configFile: vite_config.configFile,
|
|
1306
|
+
// CLI args
|
|
1307
|
+
mode: vite_config_env.mode,
|
|
1308
|
+
logLevel: vite_config.logLevel,
|
|
1309
|
+
clearScreen: vite_config.clearScreen,
|
|
1310
|
+
build: {
|
|
1311
|
+
minify: initial_config.build?.minify,
|
|
1312
|
+
assetsInlineLimit: vite_config.build.assetsInlineLimit,
|
|
1313
|
+
sourcemap: vite_config.build.sourcemap
|
|
1314
|
+
},
|
|
1315
|
+
optimizeDeps: {
|
|
1316
|
+
force: vite_config.optimizeDeps.force
|
|
1317
|
+
}
|
|
1318
|
+
})
|
|
1319
|
+
);
|
|
1303
1320
|
|
|
1304
|
-
|
|
1305
|
-
// make absolute paths in CSS relative, for portability
|
|
1306
|
-
const content = fs
|
|
1307
|
-
.readFileSync(src, 'utf-8')
|
|
1308
|
-
.replaceAll(`${kit.paths.base}/${assets_path}`, '.');
|
|
1321
|
+
secondary_build_started = false;
|
|
1309
1322
|
|
|
1310
|
-
|
|
1311
|
-
|
|
1323
|
+
client_chunks = bundle.output;
|
|
1324
|
+
} catch (e) {
|
|
1325
|
+
const error =
|
|
1326
|
+
e instanceof Error
|
|
1327
|
+
? e
|
|
1328
|
+
: new Error(/** @type {any} */ (e).message ?? e ?? '<unknown>');
|
|
1312
1329
|
|
|
1313
|
-
|
|
1330
|
+
// without this, errors that occur during the secondary build
|
|
1331
|
+
// will be logged twice
|
|
1332
|
+
throw stackless(error.stack ?? error.message);
|
|
1314
1333
|
}
|
|
1315
|
-
}
|
|
1316
1334
|
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
const app = deps_of(`${out_dir}/generated/client-optimized/app.js`);
|
|
1330
|
-
|
|
1331
|
-
build_data.client = {
|
|
1332
|
-
start: start.file,
|
|
1333
|
-
app: app.file,
|
|
1334
|
-
imports: [...start.imports, ...app.imports],
|
|
1335
|
-
stylesheets: [...start.stylesheets, ...app.stylesheets],
|
|
1336
|
-
fonts: [...start.fonts, ...app.fonts],
|
|
1337
|
-
uses_env_dynamic_public: client_chunks.some(
|
|
1338
|
-
(chunk) => chunk.type === 'chunk' && chunk.modules[env_dynamic_public]
|
|
1339
|
-
)
|
|
1340
|
-
};
|
|
1335
|
+
// We use `build.ssrEmitAssets` so that asset URLs created from
|
|
1336
|
+
// imports in server-only modules correspond to files in the build,
|
|
1337
|
+
// but we don't want to copy over CSS imports as these are already
|
|
1338
|
+
// accounted for in the client bundle. In most cases it would be
|
|
1339
|
+
// a no-op, but for SSR builds `url(...)` paths are handled
|
|
1340
|
+
// differently (relative for client, absolute for server)
|
|
1341
|
+
// resulting in different hashes, and thus duplication
|
|
1342
|
+
const ssr_stylesheets = new Set(
|
|
1343
|
+
Object.values(server_manifest)
|
|
1344
|
+
.map((chunk) => chunk.css ?? [])
|
|
1345
|
+
.flat()
|
|
1346
|
+
);
|
|
1341
1347
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
if (
|
|
1348
|
-
|
|
1349
|
-
const deps = deps_of(entry, true);
|
|
1350
|
-
const file = resolve_symlinks(
|
|
1351
|
-
client_manifest,
|
|
1352
|
-
`${out_dir}/generated/client-optimized/nodes/${i}.js`
|
|
1353
|
-
).chunk.file;
|
|
1354
|
-
|
|
1355
|
-
return { file, css: deps.stylesheets };
|
|
1348
|
+
if (fs.existsSync(server_assets)) {
|
|
1349
|
+
for (const file of fs.readdirSync(server_assets)) {
|
|
1350
|
+
const src = `${server_assets}/${file}`;
|
|
1351
|
+
const dest = `${client_assets}/${file}`;
|
|
1352
|
+
|
|
1353
|
+
if (fs.existsSync(dest) || ssr_stylesheets.has(`${assets_path}/${file}`)) {
|
|
1354
|
+
continue;
|
|
1356
1355
|
}
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
build_data.client.routes = compact(
|
|
1362
|
-
manifest_data.routes.map((route) => {
|
|
1363
|
-
if (!route.page) return;
|
|
1364
|
-
|
|
1365
|
-
return {
|
|
1366
|
-
id: route.id,
|
|
1367
|
-
pattern: route.pattern,
|
|
1368
|
-
params: route.params,
|
|
1369
|
-
layouts: route.page.layouts.map((l) =>
|
|
1370
|
-
l !== undefined ? [metadata.nodes[l].has_server_load, l] : undefined
|
|
1371
|
-
),
|
|
1372
|
-
errors: route.page.errors,
|
|
1373
|
-
leaf: [metadata.nodes[route.page.leaf].has_server_load, route.page.leaf]
|
|
1374
|
-
};
|
|
1375
|
-
})
|
|
1376
|
-
);
|
|
1356
|
+
|
|
1357
|
+
copy(src, dest);
|
|
1358
|
+
}
|
|
1377
1359
|
}
|
|
1378
|
-
} else {
|
|
1379
|
-
const start = deps_of(`${runtime_directory}/client/bundle.js`);
|
|
1380
|
-
|
|
1381
|
-
build_data.client = {
|
|
1382
|
-
start: start.file,
|
|
1383
|
-
imports: start.imports,
|
|
1384
|
-
stylesheets: start.stylesheets,
|
|
1385
|
-
fonts: start.fonts,
|
|
1386
|
-
uses_env_dynamic_public: client_chunks.some(
|
|
1387
|
-
(chunk) => chunk.type === 'chunk' && chunk.modules[env_dynamic_public]
|
|
1388
|
-
)
|
|
1389
|
-
};
|
|
1390
1360
|
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1361
|
+
/** @type {Manifest} */
|
|
1362
|
+
const manifest = (client_manifest = JSON.parse(
|
|
1363
|
+
read(`${out}/client/.vite/manifest.json`)
|
|
1364
|
+
));
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* @param {string} entry
|
|
1368
|
+
* @param {boolean} [add_dynamic_css]
|
|
1369
|
+
*/
|
|
1370
|
+
const deps_of = (entry, add_dynamic_css = false) =>
|
|
1371
|
+
find_deps(manifest, posixify(path.relative('.', entry)), add_dynamic_css);
|
|
1372
|
+
|
|
1373
|
+
if (svelte_config.kit.output.bundleStrategy === 'split') {
|
|
1374
|
+
const start = deps_of(`${runtime_directory}/client/entry.js`);
|
|
1375
|
+
const app = deps_of(`${out_dir}/generated/client-optimized/app.js`);
|
|
1376
|
+
|
|
1377
|
+
build_data.client = {
|
|
1378
|
+
start: start.file,
|
|
1379
|
+
app: app.file,
|
|
1380
|
+
imports: [...start.imports, ...app.imports],
|
|
1381
|
+
stylesheets: [...start.stylesheets, ...app.stylesheets],
|
|
1382
|
+
fonts: [...start.fonts, ...app.fonts],
|
|
1383
|
+
uses_env_dynamic_public: client_chunks.some(
|
|
1384
|
+
(chunk) => chunk.type === 'chunk' && chunk.modules[env_dynamic_public]
|
|
1398
1385
|
)
|
|
1399
|
-
|
|
1386
|
+
};
|
|
1400
1387
|
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1388
|
+
// In case of server-side route resolution, we create a purpose-built route manifest that is
|
|
1389
|
+
// similar to that on the client, with as much information computed upfront so that we
|
|
1390
|
+
// don't need to include any code of the actual routes in the server bundle.
|
|
1391
|
+
if (svelte_config.kit.router.resolution === 'server') {
|
|
1392
|
+
const nodes = manifest_data.nodes.map((node, i) => {
|
|
1393
|
+
if (node.component || node.universal) {
|
|
1394
|
+
const entry = `${out_dir}/generated/client-optimized/nodes/${i}.js`;
|
|
1395
|
+
const deps = deps_of(entry, true);
|
|
1396
|
+
const file = resolve_symlinks(
|
|
1397
|
+
manifest,
|
|
1398
|
+
`${out_dir}/generated/client-optimized/nodes/${i}.js`
|
|
1399
|
+
).chunk.file;
|
|
1400
|
+
|
|
1401
|
+
return { file, css: deps.stylesheets };
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
build_data.client.nodes = nodes.map((node) => node?.file);
|
|
1405
|
+
build_data.client.css = nodes.map((node) => node?.css);
|
|
1406
|
+
|
|
1407
|
+
build_data.client.routes = compact(
|
|
1408
|
+
manifest_data.routes.map((route) => {
|
|
1409
|
+
if (!route.page) return;
|
|
1410
|
+
|
|
1411
|
+
return {
|
|
1412
|
+
id: route.id,
|
|
1413
|
+
pattern: route.pattern,
|
|
1414
|
+
params: route.params,
|
|
1415
|
+
layouts: route.page.layouts.map((l) =>
|
|
1416
|
+
l !== undefined ? [metadata.nodes[l].has_server_load, l] : undefined
|
|
1417
|
+
),
|
|
1418
|
+
errors: route.page.errors,
|
|
1419
|
+
leaf: [metadata.nodes[route.page.leaf].has_server_load, route.page.leaf]
|
|
1420
|
+
};
|
|
1421
|
+
})
|
|
1422
|
+
);
|
|
1423
|
+
}
|
|
1424
|
+
} else {
|
|
1425
|
+
const start = deps_of(`${runtime_directory}/client/bundle.js`);
|
|
1426
|
+
|
|
1427
|
+
build_data.client = {
|
|
1428
|
+
start: start.file,
|
|
1429
|
+
imports: start.imports,
|
|
1430
|
+
stylesheets: start.stylesheets,
|
|
1431
|
+
fonts: start.fonts,
|
|
1432
|
+
uses_env_dynamic_public: client_chunks.some(
|
|
1433
|
+
(chunk) => chunk.type === 'chunk' && chunk.modules[env_dynamic_public]
|
|
1434
|
+
)
|
|
1404
1435
|
};
|
|
1436
|
+
|
|
1437
|
+
if (svelte_config.kit.output.bundleStrategy === 'inline') {
|
|
1438
|
+
const style = /** @type {import('vite').Rollup.OutputAsset} */ (
|
|
1439
|
+
client_chunks.find(
|
|
1440
|
+
(chunk) =>
|
|
1441
|
+
chunk.type === 'asset' &&
|
|
1442
|
+
chunk.names.length === 1 &&
|
|
1443
|
+
chunk.names[0] === 'style.css'
|
|
1444
|
+
)
|
|
1445
|
+
);
|
|
1446
|
+
|
|
1447
|
+
build_data.client.inline = {
|
|
1448
|
+
script: read(`${out}/client/${start.file}`),
|
|
1449
|
+
style: /** @type {string | undefined} */ (style?.source)
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1405
1452
|
}
|
|
1406
|
-
}
|
|
1407
1453
|
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1454
|
+
// regenerate manifest now that we have client entry...
|
|
1455
|
+
fs.writeFileSync(
|
|
1456
|
+
manifest_path,
|
|
1457
|
+
`export const manifest = ${generate_manifest({
|
|
1458
|
+
build_data,
|
|
1459
|
+
prerendered: [],
|
|
1460
|
+
relative_path: '.',
|
|
1461
|
+
routes: manifest_data.routes,
|
|
1462
|
+
remotes
|
|
1463
|
+
})};\n`
|
|
1464
|
+
);
|
|
1419
1465
|
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1466
|
+
// regenerate nodes with the client manifest...
|
|
1467
|
+
build_server_nodes(
|
|
1468
|
+
out,
|
|
1469
|
+
kit,
|
|
1470
|
+
manifest_data,
|
|
1471
|
+
server_manifest,
|
|
1472
|
+
manifest,
|
|
1473
|
+
assets_path,
|
|
1474
|
+
client_chunks
|
|
1475
|
+
);
|
|
1476
|
+
} else {
|
|
1477
|
+
copy(server_assets, client_assets);
|
|
1478
|
+
copy(kit.files.assets, `${out}/client`);
|
|
1479
|
+
}
|
|
1430
1480
|
|
|
1431
1481
|
// ...and prerender
|
|
1432
1482
|
const { prerendered, prerender_map } = await prerender({
|
|
@@ -1479,7 +1529,7 @@ async function kit({ svelte_config }) {
|
|
|
1479
1529
|
manifest_data,
|
|
1480
1530
|
service_worker_entry_file,
|
|
1481
1531
|
prerendered,
|
|
1482
|
-
client_manifest,
|
|
1532
|
+
client_manifest ?? server_manifest,
|
|
1483
1533
|
explicit_env_config
|
|
1484
1534
|
);
|
|
1485
1535
|
}
|
|
@@ -1514,8 +1564,6 @@ async function kit({ svelte_config }) {
|
|
|
1514
1564
|
`See ${link} to learn how to configure your app to run on the platform of your choosing`
|
|
1515
1565
|
);
|
|
1516
1566
|
}
|
|
1517
|
-
|
|
1518
|
-
secondary_build_started = false;
|
|
1519
1567
|
};
|
|
1520
1568
|
}
|
|
1521
1569
|
},
|
|
@@ -77,9 +77,6 @@ export function command(validate_or_fn, maybe_fn) {
|
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
state.remote.refreshes ??= new Map();
|
|
81
|
-
state.remote.reconnects ??= new Map();
|
|
82
|
-
|
|
83
80
|
const promise = Promise.resolve(
|
|
84
81
|
run_remote_function(event, state, true, () => validate(arg), fn)
|
|
85
82
|
);
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
normalize_issue,
|
|
12
12
|
flatten_issues
|
|
13
13
|
} from '../../../form-utils.js';
|
|
14
|
-
import { get_cache, run_remote_function } from './shared.js';
|
|
14
|
+
import { get_cache, get_implicit_lookup, run_remote_function } from './shared.js';
|
|
15
15
|
import { ValidationError } from '@sveltejs/kit/internal';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -136,9 +136,6 @@ export function form(validate_or_fn, maybe_fn) {
|
|
|
136
136
|
data = validated.value;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
state.remote.refreshes ??= new Map();
|
|
140
|
-
state.remote.reconnects ??= new Map();
|
|
141
|
-
|
|
142
139
|
const issue = create_issues();
|
|
143
140
|
|
|
144
141
|
try {
|
|
@@ -161,7 +158,12 @@ export function form(validate_or_fn, maybe_fn) {
|
|
|
161
158
|
// We don't need to care about args or deduplicating calls, because uneval results are only relevant in full page reloads
|
|
162
159
|
// where only one form submission is active at the same time
|
|
163
160
|
if (!event.isRemoteRequest) {
|
|
164
|
-
get_cache(__, state)
|
|
161
|
+
const cache = get_cache(__, state);
|
|
162
|
+
cache[''] ??= output;
|
|
163
|
+
|
|
164
|
+
// register under the client-side action id so the output is serialized
|
|
165
|
+
// into the page, allowing the hydrated client to restore `result`/`issues`/`input`
|
|
166
|
+
get_implicit_lookup(__, state)[__.action_id ?? __.id] = () => cache[''];
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
return output;
|
|
@@ -177,28 +179,30 @@ export function form(validate_or_fn, maybe_fn) {
|
|
|
177
179
|
|
|
178
180
|
Object.defineProperty(instance, 'fields', {
|
|
179
181
|
get() {
|
|
182
|
+
// the form instance is created once per module and shared across requests,
|
|
183
|
+
// so the current request's state has to be resolved at access time
|
|
180
184
|
return create_field_proxy(
|
|
181
185
|
{},
|
|
182
|
-
() => get_cache(__)?.['']?.
|
|
186
|
+
() => get_cache(__, get_request_store().state)?.['']?.input ?? {},
|
|
183
187
|
(path, value) => {
|
|
184
|
-
const cache = get_cache(__);
|
|
188
|
+
const cache = get_cache(__, get_request_store().state);
|
|
185
189
|
const entry = cache[''];
|
|
186
190
|
|
|
187
|
-
if (entry?.
|
|
191
|
+
if (entry?.submission) {
|
|
188
192
|
// don't override a submission
|
|
189
193
|
return;
|
|
190
194
|
}
|
|
191
195
|
|
|
192
196
|
if (path.length === 0) {
|
|
193
|
-
(cache[''] ??= {
|
|
197
|
+
(cache[''] ??= {}).input = value;
|
|
194
198
|
return;
|
|
195
199
|
}
|
|
196
200
|
|
|
197
|
-
const input = entry?.
|
|
201
|
+
const input = entry?.input ?? {};
|
|
198
202
|
deep_set(input, path.map(String), value);
|
|
199
|
-
(cache[''] ??= {
|
|
203
|
+
(cache[''] ??= {}).input = input;
|
|
200
204
|
},
|
|
201
|
-
() => flatten_issues(get_cache(__)?.['']?.
|
|
205
|
+
() => flatten_issues(get_cache(__, get_request_store().state)?.['']?.issues ?? [])
|
|
202
206
|
);
|
|
203
207
|
}
|
|
204
208
|
});
|
|
@@ -220,7 +224,7 @@ export function form(validate_or_fn, maybe_fn) {
|
|
|
220
224
|
Object.defineProperty(instance, 'result', {
|
|
221
225
|
get() {
|
|
222
226
|
try {
|
|
223
|
-
return get_cache(__)?.['']?.
|
|
227
|
+
return get_cache(__, get_request_store().state)?.['']?.result;
|
|
224
228
|
} catch {
|
|
225
229
|
return undefined;
|
|
226
230
|
}
|
|
@@ -264,6 +268,7 @@ export function form(validate_or_fn, maybe_fn) {
|
|
|
264
268
|
if (!instance) {
|
|
265
269
|
instance = create_instance(key);
|
|
266
270
|
instance.__.id = `${__.id}/${encodeURIComponent(JSON.stringify(key))}`;
|
|
271
|
+
instance.__.action_id = `${__.id}/${JSON.stringify(key)}`;
|
|
267
272
|
instance.__.name = __.name;
|
|
268
273
|
|
|
269
274
|
state.remote.forms.set(cache_key, instance);
|