@sveltejs/kit 1.0.0-next.41 → 1.0.0-next.410
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/README.md +12 -9
- package/package.json +97 -63
- package/src/cli.js +119 -0
- package/src/core/adapt/builder.js +207 -0
- package/src/core/adapt/index.js +19 -0
- package/src/core/config/index.js +86 -0
- package/src/core/config/options.js +488 -0
- package/src/core/config/types.d.ts +1 -0
- package/src/core/constants.js +3 -0
- package/src/core/generate_manifest/index.js +99 -0
- package/src/core/prerender/crawl.js +194 -0
- package/src/core/prerender/prerender.js +378 -0
- package/src/core/prerender/queue.js +80 -0
- package/src/core/sync/create_manifest_data/index.js +492 -0
- package/src/core/sync/create_manifest_data/types.d.ts +40 -0
- package/src/core/sync/sync.js +59 -0
- package/src/core/sync/utils.js +97 -0
- package/src/core/sync/write_ambient.js +87 -0
- package/src/core/sync/write_client_manifest.js +82 -0
- package/src/core/sync/write_matchers.js +25 -0
- package/src/core/sync/write_root.js +88 -0
- package/src/core/sync/write_tsconfig.js +189 -0
- package/src/core/sync/write_types.js +723 -0
- package/src/core/utils.js +58 -0
- package/src/hooks.js +26 -0
- package/src/index/index.js +45 -0
- package/src/index/private.js +33 -0
- package/src/node/index.js +145 -0
- package/src/node/polyfills.js +40 -0
- package/src/packaging/index.js +218 -0
- package/src/packaging/types.d.ts +8 -0
- package/src/packaging/typescript.js +150 -0
- package/src/packaging/utils.js +143 -0
- package/src/runtime/app/env.js +11 -0
- package/src/runtime/app/navigation.js +22 -0
- package/src/runtime/app/paths.js +1 -0
- package/src/runtime/app/stores.js +94 -0
- package/src/runtime/client/ambient.d.ts +17 -0
- package/src/runtime/client/client.js +1269 -0
- package/src/runtime/client/fetcher.js +60 -0
- package/src/runtime/client/parse.js +36 -0
- package/src/runtime/client/singletons.js +11 -0
- package/src/runtime/client/start.js +48 -0
- package/src/runtime/client/types.d.ts +106 -0
- package/src/runtime/client/utils.js +113 -0
- package/src/runtime/components/error.svelte +16 -0
- package/{assets → src/runtime}/components/layout.svelte +0 -0
- package/src/runtime/env/dynamic/private.js +1 -0
- package/src/runtime/env/dynamic/public.js +1 -0
- package/src/runtime/env-private.js +7 -0
- package/src/runtime/env-public.js +7 -0
- package/src/runtime/env.js +6 -0
- package/src/runtime/hash.js +16 -0
- package/src/runtime/paths.js +11 -0
- package/src/runtime/server/endpoint.js +42 -0
- package/src/runtime/server/index.js +434 -0
- package/src/runtime/server/page/cookie.js +25 -0
- package/src/runtime/server/page/crypto.js +239 -0
- package/src/runtime/server/page/csp.js +249 -0
- package/src/runtime/server/page/fetch.js +265 -0
- package/src/runtime/server/page/index.js +418 -0
- package/src/runtime/server/page/load_data.js +94 -0
- package/src/runtime/server/page/render.js +357 -0
- package/src/runtime/server/page/respond_with_error.js +105 -0
- package/src/runtime/server/page/types.d.ts +44 -0
- package/src/runtime/server/utils.js +116 -0
- package/src/utils/error.js +22 -0
- package/src/utils/escape.js +104 -0
- package/src/utils/filesystem.js +108 -0
- package/src/utils/http.js +55 -0
- package/src/utils/misc.js +1 -0
- package/src/utils/routing.js +107 -0
- package/src/utils/url.js +97 -0
- package/src/vite/build/build_server.js +335 -0
- package/src/vite/build/build_service_worker.js +90 -0
- package/src/vite/build/utils.js +153 -0
- package/src/vite/dev/index.js +565 -0
- package/src/vite/index.js +540 -0
- package/src/vite/preview/index.js +186 -0
- package/src/vite/types.d.ts +3 -0
- package/src/vite/utils.js +335 -0
- package/svelte-kit.js +1 -1
- package/types/ambient.d.ts +368 -0
- package/types/index.d.ts +345 -0
- package/types/internal.d.ts +313 -0
- package/types/private.d.ts +236 -0
- package/CHANGELOG.md +0 -419
- package/assets/components/error.svelte +0 -13
- package/assets/runtime/app/env.js +0 -5
- package/assets/runtime/app/navigation.js +0 -41
- package/assets/runtime/app/paths.js +0 -1
- package/assets/runtime/app/stores.js +0 -93
- package/assets/runtime/chunks/utils.js +0 -19
- package/assets/runtime/internal/singletons.js +0 -23
- package/assets/runtime/internal/start.js +0 -770
- package/assets/runtime/paths.js +0 -12
- package/dist/api.js +0 -28
- package/dist/api.js.map +0 -1
- package/dist/chunks/index.js +0 -3519
- package/dist/chunks/index2.js +0 -587
- package/dist/chunks/index3.js +0 -246
- package/dist/chunks/index4.js +0 -524
- package/dist/chunks/index5.js +0 -761
- package/dist/chunks/index6.js +0 -322
- package/dist/chunks/standard.js +0 -99
- package/dist/chunks/utils.js +0 -83
- package/dist/cli.js +0 -546
- package/dist/cli.js.map +0 -1
- package/dist/create_app.js +0 -592
- package/dist/create_app.js.map +0 -1
- package/dist/index.js +0 -392
- package/dist/index.js.map +0 -1
- package/dist/index2.js +0 -3519
- package/dist/index2.js.map +0 -1
- package/dist/index3.js +0 -320
- package/dist/index3.js.map +0 -1
- package/dist/index4.js +0 -323
- package/dist/index4.js.map +0 -1
- package/dist/index5.js +0 -247
- package/dist/index5.js.map +0 -1
- package/dist/index6.js +0 -761
- package/dist/index6.js.map +0 -1
- package/dist/renderer.js +0 -2499
- package/dist/renderer.js.map +0 -1
- package/dist/ssr.js +0 -2581
- package/dist/standard.js +0 -100
- package/dist/standard.js.map +0 -1
- package/dist/utils.js +0 -84
- package/dist/utils.js.map +0 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
import { posixify, mkdirp, rimraf, walk } from '../utils/filesystem.js';
|
|
5
|
+
import { resolve_lib_alias, write } from './utils.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('types').ValidatedConfig} config
|
|
9
|
+
* @param {string} cwd
|
|
10
|
+
* @param {import('./types').File[]} files
|
|
11
|
+
*/
|
|
12
|
+
export async function emit_dts(config, cwd, files) {
|
|
13
|
+
const tmp = `${config.kit.outDir}/package/types`;
|
|
14
|
+
rimraf(tmp);
|
|
15
|
+
mkdirp(tmp);
|
|
16
|
+
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
const emit = await try_load_svelte2tsx();
|
|
19
|
+
await emit({
|
|
20
|
+
libRoot: config.kit.files.lib,
|
|
21
|
+
svelteShimsPath: require.resolve('svelte2tsx/svelte-shims.d.ts'),
|
|
22
|
+
declarationDir: path.relative(cwd, tmp)
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const handwritten = new Set();
|
|
26
|
+
const excluded = new Set();
|
|
27
|
+
|
|
28
|
+
// remove excluded files, and files that conflict with hand-written .d.ts
|
|
29
|
+
for (const file of files) {
|
|
30
|
+
if (file.name.endsWith('.d.ts')) {
|
|
31
|
+
handwritten.add(file.name);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!file.is_included) {
|
|
35
|
+
excluded.add(file.base + '.d.ts');
|
|
36
|
+
excluded.add(file.base + '.d.mts');
|
|
37
|
+
excluded.add(file.base + '.d.cts');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// resolve $lib alias (TODO others), copy into package dir
|
|
42
|
+
for (const file of walk(tmp)) {
|
|
43
|
+
const normalized = posixify(file);
|
|
44
|
+
|
|
45
|
+
if (handwritten.has(normalized)) {
|
|
46
|
+
console.warn(`Using $lib/${normalized} instead of generated .d.ts file`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// don't overwrite hand-written .d.ts files
|
|
50
|
+
if (excluded.has(normalized)) continue;
|
|
51
|
+
|
|
52
|
+
const source = fs.readFileSync(path.join(tmp, normalized), 'utf8');
|
|
53
|
+
write(
|
|
54
|
+
path.join(config.kit.package.dir, normalized),
|
|
55
|
+
resolve_lib_alias(normalized, source, config)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function try_load_svelte2tsx() {
|
|
61
|
+
const svelte2tsx = await load();
|
|
62
|
+
const emit_dts = svelte2tsx.emitDts;
|
|
63
|
+
if (!emit_dts) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
'You need to install svelte2tsx >=0.4.1 if you want to generate type definitions'
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return emit_dts;
|
|
69
|
+
|
|
70
|
+
async function load() {
|
|
71
|
+
try {
|
|
72
|
+
return await import('svelte2tsx');
|
|
73
|
+
} catch (e) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
'You need svelte2tsx and typescript if you want to generate type definitions. Install it through your package manager, or disable generation which is highly discouraged. See https://kit.svelte.dev/docs/packaging'
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @param {string} filename
|
|
83
|
+
* @param {string} source
|
|
84
|
+
*/
|
|
85
|
+
export async function transpile_ts(filename, source) {
|
|
86
|
+
const ts = await try_load_ts();
|
|
87
|
+
return ts.transpileModule(source, {
|
|
88
|
+
compilerOptions: load_tsconfig(filename, ts),
|
|
89
|
+
fileName: filename
|
|
90
|
+
}).outputText;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function try_load_ts() {
|
|
94
|
+
try {
|
|
95
|
+
return (await import('typescript')).default;
|
|
96
|
+
} catch (e) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
'You need to install TypeScript if you want to transpile TypeScript files and/or generate type definitions'
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {string} filename
|
|
105
|
+
* @param {import('typescript')} ts
|
|
106
|
+
*/
|
|
107
|
+
function load_tsconfig(filename, ts) {
|
|
108
|
+
let config_filename;
|
|
109
|
+
|
|
110
|
+
// ts.findConfigFile is broken (it will favour a distant tsconfig
|
|
111
|
+
// over a near jsconfig, and then only when you call it twice)
|
|
112
|
+
// so we implement it ourselves
|
|
113
|
+
let dir = filename;
|
|
114
|
+
while (dir !== (dir = path.dirname(dir))) {
|
|
115
|
+
const tsconfig = path.join(dir, 'tsconfig.json');
|
|
116
|
+
const jsconfig = path.join(dir, 'jsconfig.json');
|
|
117
|
+
|
|
118
|
+
if (fs.existsSync(tsconfig)) {
|
|
119
|
+
config_filename = tsconfig;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (fs.existsSync(jsconfig)) {
|
|
124
|
+
config_filename = jsconfig;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!config_filename) {
|
|
130
|
+
throw new Error('Failed to locate tsconfig or jsconfig');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const { error, config } = ts.readConfigFile(config_filename, ts.sys.readFile);
|
|
134
|
+
|
|
135
|
+
if (error) {
|
|
136
|
+
throw new Error('Malformed tsconfig\n' + JSON.stringify(error, null, 2));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Do this so TS will not search for initial files which might take a while
|
|
140
|
+
config.include = [];
|
|
141
|
+
config.files = [];
|
|
142
|
+
const { options } = ts.parseJsonConfigFileContent(
|
|
143
|
+
config,
|
|
144
|
+
ts.sys,
|
|
145
|
+
path.dirname(config_filename),
|
|
146
|
+
{ sourceMap: false },
|
|
147
|
+
config_filename
|
|
148
|
+
);
|
|
149
|
+
return options;
|
|
150
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { posixify, mkdirp, walk } from '../utils/filesystem.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the `$lib` alias.
|
|
7
|
+
*
|
|
8
|
+
* TODO: make this more generic to also handle other aliases the user could have defined via
|
|
9
|
+
* `kit.alias`. Also investigate how to do this in a more robust way (right now regex string
|
|
10
|
+
* replacement is used).
|
|
11
|
+
* For more discussion see https://github.com/sveltejs/kit/pull/2453
|
|
12
|
+
*
|
|
13
|
+
* @param {string} file Relative to the lib root
|
|
14
|
+
* @param {string} content
|
|
15
|
+
* @param {import('types').ValidatedConfig} config
|
|
16
|
+
* @returns {string}
|
|
17
|
+
*/
|
|
18
|
+
export function resolve_lib_alias(file, content, config) {
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} match
|
|
21
|
+
* @param {string} _
|
|
22
|
+
* @param {string} import_path
|
|
23
|
+
*/
|
|
24
|
+
const replace_import_path = (match, _, import_path) => {
|
|
25
|
+
if (!import_path.startsWith('$lib/')) {
|
|
26
|
+
return match;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const full_path = path.join(config.kit.files.lib, file);
|
|
30
|
+
const full_import_path = path.join(config.kit.files.lib, import_path.slice('$lib/'.length));
|
|
31
|
+
let resolved = posixify(path.relative(path.dirname(full_path), full_import_path));
|
|
32
|
+
resolved = resolved.startsWith('.') ? resolved : './' + resolved;
|
|
33
|
+
return match.replace(import_path, resolved);
|
|
34
|
+
};
|
|
35
|
+
content = content.replace(/from\s+('|")([^"';,]+?)\1/g, replace_import_path);
|
|
36
|
+
content = content.replace(/import\s*\(\s*('|")([^"';,]+?)\1\s*\)/g, replace_import_path);
|
|
37
|
+
return content;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Strip out lang="X" or type="text/X" tags. Doing it here is only a temporary solution.
|
|
42
|
+
* See https://github.com/sveltejs/kit/issues/2450 for ideas for places where it's handled better.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} content
|
|
45
|
+
*/
|
|
46
|
+
export function strip_lang_tags(content) {
|
|
47
|
+
return content
|
|
48
|
+
.replace(/(<!--[^]*?-->)|(<script[^>]*?)\s(?:type|lang)=(["']).*?\3/g, '$1$2')
|
|
49
|
+
.replace(/(<!--[^]*?-->)|(<style[^>]*?)\s(?:type|lang)=(["']).*?\3/g, '$1$2');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {string} file
|
|
54
|
+
* @param {Parameters<typeof fs.writeFileSync>[1]} contents
|
|
55
|
+
*/
|
|
56
|
+
export function write(file, contents) {
|
|
57
|
+
mkdirp(path.dirname(file));
|
|
58
|
+
fs.writeFileSync(file, contents);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {import('types').ValidatedConfig} config
|
|
63
|
+
* @returns {import('./types').File[]}
|
|
64
|
+
*/
|
|
65
|
+
export function scan(config) {
|
|
66
|
+
return walk(config.kit.files.lib).map((file) => analyze(config, file));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {import('types').ValidatedConfig} config
|
|
71
|
+
* @param {string} file
|
|
72
|
+
* @returns {import('./types').File}
|
|
73
|
+
*/
|
|
74
|
+
export function analyze(config, file) {
|
|
75
|
+
const name = posixify(file);
|
|
76
|
+
|
|
77
|
+
const svelte_extension = config.extensions.find((ext) => name.endsWith(ext));
|
|
78
|
+
|
|
79
|
+
const base = svelte_extension ? name : name.slice(0, -path.extname(name).length);
|
|
80
|
+
|
|
81
|
+
const dest = svelte_extension
|
|
82
|
+
? name.slice(0, -svelte_extension.length) + '.svelte'
|
|
83
|
+
: name.endsWith('.d.ts')
|
|
84
|
+
? name
|
|
85
|
+
: name.endsWith('.ts')
|
|
86
|
+
? name.slice(0, -3) + '.js'
|
|
87
|
+
: name;
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
name,
|
|
91
|
+
dest,
|
|
92
|
+
base,
|
|
93
|
+
is_included: config.kit.package.files(name),
|
|
94
|
+
is_exported: config.kit.package.exports(name),
|
|
95
|
+
is_svelte: !!svelte_extension
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param {string} cwd
|
|
101
|
+
* @param {import('./types').File[]} files
|
|
102
|
+
*/
|
|
103
|
+
export function generate_pkg(cwd, files) {
|
|
104
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));
|
|
105
|
+
|
|
106
|
+
// Remove fields that are specific to the original package.json
|
|
107
|
+
// See: https://pnpm.io/package_json#publishconfigdirectory
|
|
108
|
+
delete pkg.publishConfig?.directory;
|
|
109
|
+
delete pkg.linkDirectory?.directory;
|
|
110
|
+
delete pkg.scripts;
|
|
111
|
+
|
|
112
|
+
pkg.type = 'module';
|
|
113
|
+
|
|
114
|
+
pkg.exports = {
|
|
115
|
+
'./package.json': './package.json',
|
|
116
|
+
...pkg.exports
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** @type {Record<string, string>} */
|
|
120
|
+
const clashes = {};
|
|
121
|
+
|
|
122
|
+
for (const file of files) {
|
|
123
|
+
if (file.is_included && file.is_exported) {
|
|
124
|
+
const original = `$lib/${file.name}`;
|
|
125
|
+
const entry = `./${file.dest}`;
|
|
126
|
+
const key = entry.replace(/\/index\.js$|(\/[^/]+)\.js$/, '$1');
|
|
127
|
+
|
|
128
|
+
if (clashes[key]) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
`Duplicate "${key}" export. Please remove or rename either ${clashes[key]} or ${original}`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!pkg.exports[key]) {
|
|
135
|
+
pkg.exports[key] = entry;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
clashes[key] = original;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return pkg;
|
|
143
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { client } from '../client/singletons.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} name
|
|
5
|
+
*/
|
|
6
|
+
function guard(name) {
|
|
7
|
+
return () => {
|
|
8
|
+
throw new Error(`Cannot call ${name}(...) on the server`);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ssr = import.meta.env.SSR;
|
|
13
|
+
|
|
14
|
+
export const disableScrollHandling = ssr
|
|
15
|
+
? guard('disableScrollHandling')
|
|
16
|
+
: client.disable_scroll_handling;
|
|
17
|
+
export const goto = ssr ? guard('goto') : client.goto;
|
|
18
|
+
export const invalidate = ssr ? guard('invalidate') : client.invalidate;
|
|
19
|
+
export const prefetch = ssr ? guard('prefetch') : client.prefetch;
|
|
20
|
+
export const prefetchRoutes = ssr ? guard('prefetchRoutes') : client.prefetch_routes;
|
|
21
|
+
export const beforeNavigate = ssr ? () => {} : client.before_navigate;
|
|
22
|
+
export const afterNavigate = ssr ? () => {} : client.after_navigate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { base, assets } from '../paths.js';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { getContext } from 'svelte';
|
|
2
|
+
import { browser } from './env.js';
|
|
3
|
+
|
|
4
|
+
// TODO remove this (for 1.0? after 1.0?)
|
|
5
|
+
let warned = false;
|
|
6
|
+
export function stores() {
|
|
7
|
+
if (!warned) {
|
|
8
|
+
console.error('stores() is deprecated; use getStores() instead');
|
|
9
|
+
warned = true;
|
|
10
|
+
}
|
|
11
|
+
return getStores();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @type {import('$app/stores').getStores}
|
|
16
|
+
*/
|
|
17
|
+
export const getStores = () => {
|
|
18
|
+
const stores = getContext('__svelte__');
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
page: {
|
|
22
|
+
subscribe: stores.page.subscribe
|
|
23
|
+
},
|
|
24
|
+
navigating: {
|
|
25
|
+
subscribe: stores.navigating.subscribe
|
|
26
|
+
},
|
|
27
|
+
// TODO remove this (for 1.0? after 1.0?)
|
|
28
|
+
// @ts-expect-error - deprecated, not part of type definitions, but still callable
|
|
29
|
+
get preloading() {
|
|
30
|
+
console.error('stores.preloading is deprecated; use stores.navigating instead');
|
|
31
|
+
return {
|
|
32
|
+
subscribe: stores.navigating.subscribe
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
session: stores.session,
|
|
36
|
+
updated: stores.updated
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** @type {typeof import('$app/stores').page} */
|
|
41
|
+
export const page = {
|
|
42
|
+
/** @param {(value: any) => void} fn */
|
|
43
|
+
subscribe(fn) {
|
|
44
|
+
const store = getStores().page;
|
|
45
|
+
return store.subscribe(fn);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** @type {typeof import('$app/stores').navigating} */
|
|
50
|
+
export const navigating = {
|
|
51
|
+
subscribe(fn) {
|
|
52
|
+
const store = getStores().navigating;
|
|
53
|
+
return store.subscribe(fn);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** @param {string} verb */
|
|
58
|
+
const throw_error = (verb) => {
|
|
59
|
+
throw new Error(
|
|
60
|
+
browser
|
|
61
|
+
? `Cannot ${verb} session store before subscribing`
|
|
62
|
+
: `Can only ${verb} session store in browser`
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** @type {typeof import('$app/stores').session} */
|
|
67
|
+
export const session = {
|
|
68
|
+
subscribe(fn) {
|
|
69
|
+
const store = getStores().session;
|
|
70
|
+
|
|
71
|
+
if (browser) {
|
|
72
|
+
session.set = store.set;
|
|
73
|
+
session.update = store.update;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return store.subscribe(fn);
|
|
77
|
+
},
|
|
78
|
+
set: () => throw_error('set'),
|
|
79
|
+
update: () => throw_error('update')
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** @type {typeof import('$app/stores').updated} */
|
|
83
|
+
export const updated = {
|
|
84
|
+
subscribe(fn) {
|
|
85
|
+
const store = getStores().updated;
|
|
86
|
+
|
|
87
|
+
if (browser) {
|
|
88
|
+
updated.check = store.check;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return store.subscribe(fn);
|
|
92
|
+
},
|
|
93
|
+
check: () => throw_error('check')
|
|
94
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module '__GENERATED__/client-manifest.js' {
|
|
2
|
+
import { CSRPageNodeLoader, ParamMatcher } from 'types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A list of all the error/layout/page nodes used in the app
|
|
6
|
+
*/
|
|
7
|
+
export const nodes: CSRPageNodeLoader[];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A map of `[routeId: string]: [errors, layouts, page]` tuples, which
|
|
11
|
+
* is parsed into an array of routes on startup. The numbers refer to the
|
|
12
|
+
* indices in `nodes`.
|
|
13
|
+
*/
|
|
14
|
+
export const dictionary: Record<string, [number[], number[], number]>;
|
|
15
|
+
|
|
16
|
+
export const matchers: Record<string, ParamMatcher>;
|
|
17
|
+
}
|