@sveltejs/kit 3.0.0-next.24 → 3.0.0-next.27
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 +16 -10
- package/src/constants.js +6 -0
- package/src/core/adapt/builder.js +128 -33
- package/src/core/adapt/index.js +3 -0
- package/src/core/config/index.js +4 -7
- package/src/core/env.js +39 -14
- package/src/core/generate_manifest/index.js +42 -43
- package/src/core/postbuild/analyse.js +4 -4
- package/src/core/postbuild/fallback.js +1 -1
- package/src/core/postbuild/prerender.js +4 -4
- package/src/core/sync/create_manifest_data/index.js +0 -1
- package/src/core/sync/write_app_manifest.js +3 -2
- package/src/core/sync/write_server.js +3 -17
- package/src/core/utils.js +10 -0
- package/src/exports/adapter.js +22 -0
- package/src/exports/public.d.ts +101 -49
- package/src/exports/vite/build/index.js +1173 -0
- package/src/exports/vite/build/remote.js +4 -4
- package/src/exports/vite/build/service-worker.js +98 -0
- package/src/exports/vite/dev/generate_manifest.js +308 -0
- package/src/exports/vite/dev/index.js +40 -282
- package/src/exports/vite/index.js +156 -1717
- package/src/exports/vite/plugins/env-vars.js +53 -34
- package/src/exports/vite/plugins/guard.js +217 -0
- package/src/exports/vite/plugins/remote.js +237 -0
- package/src/exports/vite/preview/index.js +8 -8
- package/src/exports/vite/static_analysis/index.js +15 -15
- package/src/exports/vite/utils.js +98 -1
- package/src/runner.js +4 -3
- package/src/runtime/app/paths/server.js +2 -2
- package/src/runtime/app/server/index.js +3 -3
- package/src/runtime/app/server/public.d.ts +114 -57
- package/src/runtime/app/server/remote/query.js +2 -2
- package/src/runtime/app/server/remote/requested.js +31 -15
- package/src/runtime/app/state/client.svelte.js +3 -1
- package/src/runtime/client/client.js +43 -198
- package/src/runtime/client/fetcher.js +6 -6
- package/src/runtime/client/focus.js +120 -0
- package/src/runtime/client/remote-functions/command.svelte.js +20 -9
- package/src/runtime/client/remote-functions/form.svelte.js +12 -7
- package/src/runtime/client/remote-functions/query/instance.svelte.js +19 -5
- package/src/runtime/client/remote-functions/shared.svelte.js +22 -1
- package/src/runtime/client/scroll.js +39 -0
- package/src/runtime/client/utils.js +28 -0
- package/src/runtime/form-utils.js +254 -264
- package/src/runtime/server/data/index.js +14 -36
- package/src/runtime/server/errors.js +7 -10
- package/src/runtime/server/fetch.js +21 -25
- package/src/runtime/server/index.js +35 -31
- package/src/runtime/server/internal.js +34 -5
- package/src/runtime/server/page/actions.js +6 -8
- package/src/runtime/server/page/data_serializer.js +6 -10
- package/src/runtime/server/page/index.js +18 -28
- package/src/runtime/server/page/load_data.js +2 -2
- package/src/runtime/server/page/render.js +22 -40
- package/src/runtime/server/page/respond_with_error.js +10 -13
- package/src/runtime/server/page/server_routing.js +21 -27
- package/src/runtime/server/remote-functions.js +136 -136
- package/src/runtime/server/respond.js +66 -64
- package/src/runtime/server/state.js +2 -0
- package/src/runtime/server/utils.js +4 -11
- package/src/runtime/shared.js +9 -0
- package/src/runtime/utils.js +41 -0
- package/src/types/ambient-private.d.ts +1 -2
- package/src/types/global-private.d.ts +8 -0
- package/src/types/internal.d.ts +56 -17
- package/src/utils/filesystem.js +44 -28
- package/src/utils/streaming.js +5 -15
- package/src/version.js +1 -1
- package/types/index.d.ts +235 -93
- package/types/index.d.ts.map +9 -2
package/src/utils/filesystem.js
CHANGED
|
@@ -16,46 +16,58 @@ export function copy(source, target, opts = {}) {
|
|
|
16
16
|
/** @type {string[]} */
|
|
17
17
|
const files = [];
|
|
18
18
|
|
|
19
|
-
const prefix = posixify(target) + '/';
|
|
20
|
-
|
|
21
19
|
const regex = opts.replace
|
|
22
20
|
? new RegExp(`\\b(${Object.keys(opts.replace).join('|')})\\b`, 'g')
|
|
23
21
|
: null;
|
|
24
22
|
|
|
23
|
+
/** @type {string | undefined} */
|
|
24
|
+
let created;
|
|
25
|
+
|
|
25
26
|
/**
|
|
26
27
|
* @param {string} from
|
|
27
28
|
* @param {string} to
|
|
29
|
+
* @param {string} file posix path of `to` relative to `target`, empty when copying a single file
|
|
30
|
+
* @param {boolean} is_directory
|
|
28
31
|
*/
|
|
29
|
-
function go(from, to) {
|
|
32
|
+
function go(from, to, file, is_directory) {
|
|
30
33
|
if (opts.filter && !opts.filter(path.basename(from))) return;
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (opts.replace) {
|
|
42
|
-
const data = fs.readFileSync(from, 'utf-8');
|
|
43
|
-
fs.writeFileSync(
|
|
44
|
-
to,
|
|
45
|
-
data.replace(
|
|
46
|
-
/** @type {RegExp} */ (regex),
|
|
47
|
-
(_match, key) => /** @type {Record<string, string>} */ (opts.replace)[key]
|
|
48
|
-
)
|
|
35
|
+
if (is_directory) {
|
|
36
|
+
for (const entry of fs.readdirSync(from, { withFileTypes: true })) {
|
|
37
|
+
const child = path.join(from, entry.name);
|
|
38
|
+
go(
|
|
39
|
+
child,
|
|
40
|
+
path.join(to, entry.name),
|
|
41
|
+
file ? `${file}/${entry.name}` : entry.name,
|
|
42
|
+
entry.isSymbolicLink() ? fs.statSync(child).isDirectory() : entry.isDirectory()
|
|
49
43
|
);
|
|
50
|
-
} else {
|
|
51
|
-
fs.copyFileSync(from, to);
|
|
52
44
|
}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
53
47
|
|
|
54
|
-
|
|
48
|
+
const dir = path.dirname(to);
|
|
49
|
+
if (dir !== created) {
|
|
50
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
51
|
+
created = dir;
|
|
55
52
|
}
|
|
53
|
+
|
|
54
|
+
if (opts.replace) {
|
|
55
|
+
const data = fs.readFileSync(from, 'utf-8');
|
|
56
|
+
fs.writeFileSync(
|
|
57
|
+
to,
|
|
58
|
+
data.replace(
|
|
59
|
+
/** @type {RegExp} */ (regex),
|
|
60
|
+
(_match, key) => /** @type {Record<string, string>} */ (opts.replace)[key]
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
} else {
|
|
64
|
+
fs.copyFileSync(from, to);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
files.push(file || posixify(path.basename(to)));
|
|
56
68
|
}
|
|
57
69
|
|
|
58
|
-
go(source, target);
|
|
70
|
+
go(source, target, '', fs.statSync(source).isDirectory());
|
|
59
71
|
|
|
60
72
|
return files;
|
|
61
73
|
}
|
|
@@ -67,9 +79,13 @@ export function copy(source, target, opts = {}) {
|
|
|
67
79
|
* @returns {Generator<string>} the posix paths of all found files, relative to `cwd`
|
|
68
80
|
*/
|
|
69
81
|
export function* walk(cwd, dir = '') {
|
|
70
|
-
for (const
|
|
71
|
-
const joined = dir ? `${dir}/${
|
|
72
|
-
|
|
82
|
+
for (const entry of fs.readdirSync(path.join(cwd, dir), { withFileTypes: true })) {
|
|
83
|
+
const joined = dir ? `${dir}/${entry.name}` : entry.name;
|
|
84
|
+
const is_directory = entry.isSymbolicLink()
|
|
85
|
+
? fs.statSync(path.join(cwd, joined)).isDirectory()
|
|
86
|
+
: entry.isDirectory();
|
|
87
|
+
|
|
88
|
+
if (is_directory) {
|
|
73
89
|
yield* walk(cwd, joined);
|
|
74
90
|
} else {
|
|
75
91
|
yield joined;
|
|
@@ -103,7 +119,7 @@ export function relative_path(from, to) {
|
|
|
103
119
|
/**
|
|
104
120
|
* Given an entry point like [cwd]/src/hooks, returns a filename like [cwd]/src/hooks.js or [cwd]/src/hooks/index.js
|
|
105
121
|
* @param {string} entry
|
|
106
|
-
* @returns {string|null}
|
|
122
|
+
* @returns {string | null}
|
|
107
123
|
*/
|
|
108
124
|
export function resolve_entry(entry) {
|
|
109
125
|
if (fs.existsSync(entry)) {
|
package/src/utils/streaming.js
CHANGED
|
@@ -10,26 +10,16 @@ import { noop } from './functions.js';
|
|
|
10
10
|
*/
|
|
11
11
|
export function create_async_iterator() {
|
|
12
12
|
let resolved = -1;
|
|
13
|
-
let returned = -1;
|
|
14
13
|
|
|
15
14
|
/** @type {PromiseWithResolvers<T>[]} */
|
|
16
15
|
const deferred = [];
|
|
17
16
|
|
|
18
17
|
return {
|
|
19
|
-
iterate
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const next = deferred[++returned];
|
|
25
|
-
if (!next) return { value: null, done: true };
|
|
26
|
-
|
|
27
|
-
const value = await next.promise;
|
|
28
|
-
return { value: transform(value), done: false };
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
};
|
|
18
|
+
async *iterate(transform = (x) => x) {
|
|
19
|
+
// `deferred` can grow while we iterate, as resolved values may add further promises
|
|
20
|
+
for (let i = 0; i < deferred.length; i += 1) {
|
|
21
|
+
yield transform(await deferred[i].promise);
|
|
22
|
+
}
|
|
33
23
|
},
|
|
34
24
|
add: (promise) => {
|
|
35
25
|
const next = Promise.withResolvers();
|
package/src/version.js
CHANGED