@webjsdev/core 0.7.13 → 0.7.15
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/webjs-core-browser.js +3 -3
- package/dist/webjs-core-browser.js.map +2 -2
- package/dist/webjs-core-testing.js +15 -15
- package/dist/webjs-core-testing.js.map +2 -2
- package/dist/webjs-core.js +3 -3
- package/dist/webjs-core.js.map +2 -2
- package/package.json +2 -2
- package/src/component.d.ts +7 -3
- package/src/nav.d.ts +1 -1
- package/src/nav.js +22 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webjsdev/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "webjs core runtime - html/css tags, WebComponent base, isomorphic renderers",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"prepare": "node -e \"require('fs').existsSync('../../scripts/build-framework-dist.js') && require('fs').existsSync('./src/html.js') && require('child_process').execSync('npm run build:dist', {stdio:'inherit'})\""
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"esbuild": "^0.
|
|
78
|
+
"esbuild": "^0.25.0"
|
|
79
79
|
},
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
package/src/component.d.ts
CHANGED
|
@@ -114,7 +114,11 @@ export abstract class WebComponent extends HTMLElement {
|
|
|
114
114
|
/** Optional render-error boundary inside the component. */
|
|
115
115
|
renderError?(error: Error): TemplateResult | void;
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
// Concrete on the base (component.js implements all three), so a subclass
|
|
118
|
+
// override can call `super.connectedCallback()` etc. without a
|
|
119
|
+
// possibly-undefined error (#433). NOT optional, unlike the subclass-only
|
|
120
|
+
// hooks above (firstUpdated / renderError).
|
|
121
|
+
connectedCallback(): void;
|
|
122
|
+
disconnectedCallback(): void;
|
|
123
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
120
124
|
}
|
package/src/nav.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export function notFound(): never;
|
|
2
|
-
export function redirect(url: string, status?: number): never;
|
|
2
|
+
export function redirect(url: string, status?: number | { status?: number }): never;
|
|
3
3
|
export function isNotFound(e: unknown): boolean;
|
|
4
4
|
export function isRedirect(e: unknown): boolean;
|
package/src/nav.js
CHANGED
|
@@ -22,15 +22,34 @@ export function notFound() {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
+
* Throw a redirect sentinel the SSR pipeline catches and turns into a 3xx.
|
|
26
|
+
*
|
|
27
|
+
* The status is OPTIONAL and, when omitted, is chosen by the catching site so
|
|
28
|
+
* each kind of redirect gets the conventional code:
|
|
29
|
+
* - thrown during a GET page/layout render (a gating redirect like an auth
|
|
30
|
+
* bounce to `/login`): 302 Found, the conventional GET-to-GET code.
|
|
31
|
+
* - thrown from a server action (a POST): 307 Temporary Redirect, which is
|
|
32
|
+
* method-preserving so the action's intent survives. (The PRG success
|
|
33
|
+
* path uses 303 separately.)
|
|
34
|
+
* Pass an explicit status to override: `redirect('/x', 308)` (permanent) or the
|
|
35
|
+
* options form `redirect('/x', { status: 301 })`. An explicit status wins at
|
|
36
|
+
* every catching site.
|
|
37
|
+
*
|
|
25
38
|
* @param {string} url
|
|
26
|
-
* @param {number} [status]
|
|
39
|
+
* @param {number | { status?: number }} [status] explicit status (number) or
|
|
40
|
+
* `{ status }`; omit to let the catching site pick (302 for a GET gate, 307
|
|
41
|
+
* for an action).
|
|
27
42
|
* @returns {never}
|
|
28
43
|
*/
|
|
29
|
-
export function redirect(url, status
|
|
44
|
+
export function redirect(url, status) {
|
|
45
|
+
const code = typeof status === 'object' && status !== null ? status.status : status;
|
|
30
46
|
const err = new Error(`webjs: redirect(${url})`);
|
|
31
47
|
/** @type any */ (err).__webjs = REDIRECT;
|
|
32
48
|
/** @type any */ (err).url = url;
|
|
33
|
-
|
|
49
|
+
// Left undefined when the caller did not specify one, so the catching site
|
|
50
|
+
// can apply its convention (302 GET gate vs 307 action). A caller-supplied
|
|
51
|
+
// code is stored verbatim and overrides that convention.
|
|
52
|
+
/** @type any */ (err).status = typeof code === 'number' ? code : undefined;
|
|
34
53
|
throw err;
|
|
35
54
|
}
|
|
36
55
|
|