@sveltejs/kit 1.0.0-next.209 → 1.0.0-next.212
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/assets/kit.js +31 -35
- package/assets/runtime/app/stores.js +3 -3
- package/assets/runtime/internal/start.js +24 -24
- package/dist/chunks/index.js +357 -441
- package/dist/chunks/index2.js +3 -0
- package/dist/chunks/index3.js +41 -37
- package/dist/chunks/index5.js +1 -1
- package/dist/chunks/index7.js +1 -1
- package/dist/cli.js +15 -28
- package/dist/ssr.js +31 -35
- package/package.json +1 -2
- package/types/ambient-modules.d.ts +4 -0
package/assets/kit.js
CHANGED
|
@@ -598,28 +598,26 @@ async function render_response({
|
|
|
598
598
|
navigating: writable(null),
|
|
599
599
|
session
|
|
600
600
|
},
|
|
601
|
-
page: { url, params },
|
|
601
|
+
page: { url, params, status, error },
|
|
602
602
|
components: branch.map(({ node }) => node.module.default)
|
|
603
603
|
};
|
|
604
604
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
};
|
|
605
|
+
// TODO remove this for 1.0
|
|
606
|
+
/**
|
|
607
|
+
* @param {string} property
|
|
608
|
+
* @param {string} replacement
|
|
609
|
+
*/
|
|
610
|
+
const print_error = (property, replacement) => {
|
|
611
|
+
Object.defineProperty(props.page, property, {
|
|
612
|
+
get: () => {
|
|
613
|
+
throw new Error(`$page.${property} has been replaced by $page.url.${replacement}`);
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
};
|
|
618
617
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}
|
|
618
|
+
print_error('origin', 'origin');
|
|
619
|
+
print_error('path', 'pathname');
|
|
620
|
+
print_error('query', 'searchParams');
|
|
623
621
|
|
|
624
622
|
// props_n (instead of props[n]) makes it easy to avoid
|
|
625
623
|
// unnecessary updates for layout components
|
|
@@ -1811,24 +1809,22 @@ async function respond(incoming, options, state = {}) {
|
|
|
1811
1809
|
locals: {}
|
|
1812
1810
|
};
|
|
1813
1811
|
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
};
|
|
1812
|
+
// TODO remove this for 1.0
|
|
1813
|
+
/**
|
|
1814
|
+
* @param {string} property
|
|
1815
|
+
* @param {string} replacement
|
|
1816
|
+
*/
|
|
1817
|
+
const print_error = (property, replacement) => {
|
|
1818
|
+
Object.defineProperty(request, property, {
|
|
1819
|
+
get: () => {
|
|
1820
|
+
throw new Error(`request.${property} has been replaced by request.url.${replacement}`);
|
|
1821
|
+
}
|
|
1822
|
+
});
|
|
1823
|
+
};
|
|
1827
1824
|
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
}
|
|
1825
|
+
print_error('origin', 'origin');
|
|
1826
|
+
print_error('path', 'pathname');
|
|
1827
|
+
print_error('query', 'searchParams');
|
|
1832
1828
|
|
|
1833
1829
|
try {
|
|
1834
1830
|
return await options.hooks.handle({
|
|
@@ -57,7 +57,7 @@ const navigating = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
/** @param {string} verb */
|
|
60
|
-
const
|
|
60
|
+
const throw_error = (verb) => {
|
|
61
61
|
throw new Error(
|
|
62
62
|
ssr
|
|
63
63
|
? `Can only ${verb} session store in browser`
|
|
@@ -77,8 +77,8 @@ const session = {
|
|
|
77
77
|
|
|
78
78
|
return store.subscribe(fn);
|
|
79
79
|
},
|
|
80
|
-
set: () =>
|
|
81
|
-
update: () =>
|
|
80
|
+
set: () => throw_error('set'),
|
|
81
|
+
update: () => throw_error('update')
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
export { getStores, navigating, page, session, stores };
|
|
@@ -563,7 +563,7 @@ class Renderer {
|
|
|
563
563
|
|
|
564
564
|
result = error_args
|
|
565
565
|
? await this._load_error(error_args)
|
|
566
|
-
: await this._get_navigation_result_from_branch({ url, params, branch });
|
|
566
|
+
: await this._get_navigation_result_from_branch({ url, params, branch, status, error });
|
|
567
567
|
} catch (e) {
|
|
568
568
|
if (error) throw e;
|
|
569
569
|
|
|
@@ -800,9 +800,11 @@ class Renderer {
|
|
|
800
800
|
* url: URL;
|
|
801
801
|
* params: Record<string, string>;
|
|
802
802
|
* branch: Array<import('./types').BranchNode | undefined>;
|
|
803
|
+
* status: number;
|
|
804
|
+
* error?: Error;
|
|
803
805
|
* }} opts
|
|
804
806
|
*/
|
|
805
|
-
async _get_navigation_result_from_branch({ url, params, branch }) {
|
|
807
|
+
async _get_navigation_result_from_branch({ url, params, branch, status, error }) {
|
|
806
808
|
const filtered = /** @type {import('./types').BranchNode[] } */ (branch.filter(Boolean));
|
|
807
809
|
const redirect = filtered.find((f) => f.loaded && f.loaded.redirect);
|
|
808
810
|
|
|
@@ -826,26 +828,24 @@ class Renderer {
|
|
|
826
828
|
}
|
|
827
829
|
|
|
828
830
|
if (!this.current.url || url.href !== this.current.url.href) {
|
|
829
|
-
result.props.page = { url, params };
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
};
|
|
831
|
+
result.props.page = { url, params, status, error };
|
|
832
|
+
|
|
833
|
+
// TODO remove this for 1.0
|
|
834
|
+
/**
|
|
835
|
+
* @param {string} property
|
|
836
|
+
* @param {string} replacement
|
|
837
|
+
*/
|
|
838
|
+
const print_error = (property, replacement) => {
|
|
839
|
+
Object.defineProperty(result.props.page, property, {
|
|
840
|
+
get: () => {
|
|
841
|
+
throw new Error(`$page.${property} has been replaced by $page.url.${replacement}`);
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
};
|
|
844
845
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
}
|
|
846
|
+
print_error('origin', 'origin');
|
|
847
|
+
print_error('path', 'pathname');
|
|
848
|
+
print_error('query', 'searchParams');
|
|
849
849
|
}
|
|
850
850
|
|
|
851
851
|
const leaf = filtered[filtered.length - 1];
|
|
@@ -1122,12 +1122,12 @@ class Renderer {
|
|
|
1122
1122
|
}
|
|
1123
1123
|
}
|
|
1124
1124
|
|
|
1125
|
-
return await this._get_navigation_result_from_branch({ url, params, branch });
|
|
1125
|
+
return await this._get_navigation_result_from_branch({ url, params, branch, status, error });
|
|
1126
1126
|
}
|
|
1127
1127
|
|
|
1128
1128
|
/**
|
|
1129
1129
|
* @param {{
|
|
1130
|
-
* status
|
|
1130
|
+
* status: number;
|
|
1131
1131
|
* error: Error;
|
|
1132
1132
|
* url: URL;
|
|
1133
1133
|
* }} opts
|
|
@@ -1155,7 +1155,7 @@ class Renderer {
|
|
|
1155
1155
|
})
|
|
1156
1156
|
];
|
|
1157
1157
|
|
|
1158
|
-
return await this._get_navigation_result_from_branch({ url, params, branch });
|
|
1158
|
+
return await this._get_navigation_result_from_branch({ url, params, branch, status, error });
|
|
1159
1159
|
}
|
|
1160
1160
|
}
|
|
1161
1161
|
|