@govela/app 0.1.2 → 0.2.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/client.d.ts +32 -7
- package/package.json +7 -7
package/client.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
// Types of @govela/app/client
|
|
1
|
+
// Types of @govela/app/client (docs/APP.md).
|
|
2
|
+
|
|
3
|
+
import type { Component, ComponentInstance } from '@govela/runtime';
|
|
4
|
+
import type { MismatchReport } from '@govela/runtime/hydrate';
|
|
2
5
|
|
|
3
6
|
/** The route table of src/_app/routes.js, which vela-app generates. */
|
|
4
7
|
export interface RouteTable {
|
|
@@ -7,12 +10,15 @@ export interface RouteTable {
|
|
|
7
10
|
match(path: string): { route: { id: string }; params: Record<string, string> } | null;
|
|
8
11
|
}
|
|
9
12
|
|
|
10
|
-
/**
|
|
11
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The route prop of route components (R-1). P are the parameters of the
|
|
15
|
+
* path: `Route<Params>` of the route's `$types` (docs/TYPESCRIPT.md TS-8.2).
|
|
16
|
+
*/
|
|
17
|
+
export interface Route<P extends Record<string, string | undefined> = Record<string, string>> {
|
|
12
18
|
id: string;
|
|
13
19
|
url: string;
|
|
14
20
|
path: string;
|
|
15
|
-
params:
|
|
21
|
+
params: P;
|
|
16
22
|
query: Record<string, string>;
|
|
17
23
|
}
|
|
18
24
|
|
|
@@ -37,19 +43,19 @@ export interface BeforeNavigation extends Navigation {
|
|
|
37
43
|
|
|
38
44
|
export interface StartOptions {
|
|
39
45
|
/** The generated app root, src/_app/VelaApp.vela. */
|
|
40
|
-
VelaApp:
|
|
46
|
+
VelaApp: Component<any, any, any>;
|
|
41
47
|
/** The generated route table, src/_app/routes.js. Without it links load documents. */
|
|
42
48
|
routes?: RouteTable;
|
|
43
49
|
/** The element that holds the app root, or its id. */
|
|
44
50
|
root?: string | Element;
|
|
45
51
|
/** Receives hydration mismatch reports. */
|
|
46
|
-
onMismatch?: (report:
|
|
52
|
+
onMismatch?: (report: MismatchReport) => void;
|
|
47
53
|
/** The default prefetch of links; data-vela-preload on a link or an ancestor overrides it. */
|
|
48
54
|
preload?: 'hover' | 'viewport' | 'off';
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
/** Hydrates the server document and installs the router. */
|
|
52
|
-
export function start(options: StartOptions): Promise<{ app:
|
|
58
|
+
export function start(options: StartOptions): Promise<{ app: ComponentInstance; routes?: RouteTable }>;
|
|
53
59
|
|
|
54
60
|
export interface GotoOptions {
|
|
55
61
|
/** Replace the current history entry instead of adding one. */
|
|
@@ -82,3 +88,22 @@ export const protocolVersion: 1;
|
|
|
82
88
|
|
|
83
89
|
/** The request headers of a navigation (N-2). */
|
|
84
90
|
export const headers: Readonly<{ navigate: string; have: string; build: string }>;
|
|
91
|
+
|
|
92
|
+
/** The detail of `vela:form`: a failed form action (`app.Fail`). */
|
|
93
|
+
export interface FormFailure {
|
|
94
|
+
/** The HTTP status of the failure, 400–499. */
|
|
95
|
+
status: number;
|
|
96
|
+
/** The value the action failed with: the page's `form` prop. */
|
|
97
|
+
form: unknown;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare global {
|
|
101
|
+
interface HTMLElementEventMap {
|
|
102
|
+
/** The app root hydrated (start()). */
|
|
103
|
+
'vela:hydrated': CustomEvent<{ app: ComponentInstance }>;
|
|
104
|
+
/** A navigation of the router ended. */
|
|
105
|
+
'vela:navigated': CustomEvent<Navigation>;
|
|
106
|
+
/** A form action failed; the page's `form` prop changed. */
|
|
107
|
+
'vela:form': CustomEvent<FormFailure>;
|
|
108
|
+
}
|
|
109
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@govela/app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Vela App (docs/APP.md): the client router (hydration, data navigation, route matching) and the vela-app command.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"protocol": 1
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@govela/runtime": ">=0.
|
|
39
|
+
"@govela/runtime": ">=0.5.0"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=18"
|
|
43
43
|
},
|
|
44
44
|
"optionalDependencies": {
|
|
45
|
-
"@govela/app-darwin-arm64": "0.
|
|
46
|
-
"@govela/app-darwin-x64": "0.
|
|
47
|
-
"@govela/app-linux-arm64": "0.
|
|
48
|
-
"@govela/app-linux-x64": "0.
|
|
49
|
-
"@govela/app-win32-x64": "0.
|
|
45
|
+
"@govela/app-darwin-arm64": "0.2.0",
|
|
46
|
+
"@govela/app-darwin-x64": "0.2.0",
|
|
47
|
+
"@govela/app-linux-arm64": "0.2.0",
|
|
48
|
+
"@govela/app-linux-x64": "0.2.0",
|
|
49
|
+
"@govela/app-win32-x64": "0.2.0"
|
|
50
50
|
}
|
|
51
51
|
}
|