vasille-web 3.2.1 → 4.1.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/README.md +15 -14
- package/fake-types/index.d.ts +145 -104
- package/lib/bin.js +33 -0
- package/lib/index.js +57 -10
- package/package.json +12 -9
- package/spec/css.d.ts +3 -3
- package/types/bin.d.ts +2 -0
- package/types/index.d.ts +12 -8
- package/types/jsx-runtime.d.ts +4 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Vasille
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
|
-
`Vasille Web` is a front-end framework, which is developed to provide
|
|
5
|
+
`Vasille Web` is a front-end framework, which is developed to provide bulletproof frontends.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/vasille)
|
|
8
8
|
|
|
@@ -32,19 +32,9 @@ Create an app from a template
|
|
|
32
32
|
$ npm create vasille
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
Alternative method to create a TypeScript app.
|
|
36
|
-
```bash
|
|
37
|
-
$ npx degit vasille-js/example-typescript my-project
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Alternative method to create a JavaScript app.
|
|
41
|
-
```bash
|
|
42
|
-
$ npx degit vasille-js/example-javascript my-project
|
|
43
|
-
```
|
|
44
|
-
|
|
45
35
|
### Full documentation:
|
|
46
|
-
* [Learn `Vasille` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/
|
|
47
|
-
* [Vasille Router Documentation](https://github.com/vasille-js/vasille-js/blob/
|
|
36
|
+
* [Learn `Vasille` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/v4/doc/V4-API.md)
|
|
37
|
+
* [Vasille Router Documentation](https://github.com/vasille-js/vasille-js/blob/v4/doc/Router-API.md)
|
|
48
38
|
|
|
49
39
|
### Examples
|
|
50
40
|
* [TypeScript Example](https://github.com/vasille-js/example-typescript)
|
|
@@ -107,9 +97,20 @@ All of these are supported:
|
|
|
107
97
|
* [x] `100%` Test Coverage fot babel plugin.
|
|
108
98
|
* [x] Add CSS support (define styles in components).
|
|
109
99
|
* [x] Add router.
|
|
100
|
+
* [x] Add SSG (static site generation).
|
|
110
101
|
* [ ] Add SSR (server side rendering).
|
|
111
102
|
* [ ] Develop tools extension for debugging.
|
|
112
103
|
|
|
104
|
+
## Change log
|
|
105
|
+
|
|
106
|
+
### 4.0.0
|
|
107
|
+
|
|
108
|
+
Initial version of the framework with file based routing and building scripts (`vasille-web dev` and `vasille-web build spa`).
|
|
109
|
+
|
|
110
|
+
## 4.1.0
|
|
111
|
+
|
|
112
|
+
Added SSG (static site generation) as build option `vasille-web build static`.
|
|
113
|
+
|
|
113
114
|
## Questions
|
|
114
115
|
|
|
115
116
|
If you have questions, feel free to contact the maintainer of the project:
|
package/fake-types/index.d.ts
CHANGED
|
@@ -1,78 +1,83 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { App } from "vasille";
|
|
2
2
|
import type { TagOptions } from "vasille/web-runner";
|
|
3
3
|
import type { StyleProps } from "../spec/css.d.ts";
|
|
4
4
|
import type { ScreenProps } from "vasille-router";
|
|
5
5
|
import type { Router } from "vasille-router/web-router";
|
|
6
6
|
|
|
7
|
+
export type { FallbackScreenProps, ErrorScreenProps } from "vasille-router";
|
|
8
|
+
|
|
9
|
+
/** Set a handler for component errors */
|
|
10
|
+
export declare function setErrorHandler(handler: (e: unknown) => void): void;
|
|
11
|
+
|
|
7
12
|
declare interface Params {
|
|
8
|
-
slot
|
|
13
|
+
slot(...args: unknown[]): unknown;
|
|
9
14
|
}
|
|
10
15
|
|
|
11
|
-
declare type Composed<In extends
|
|
12
|
-
$: (In
|
|
13
|
-
callback?(data: Out
|
|
16
|
+
declare type Composed<In extends object, Out> = (
|
|
17
|
+
$: (Required<In> extends Params ? Omit<In, "slot"> & { slot?: unknown } : In) & {
|
|
18
|
+
callback?(data: Out): void;
|
|
14
19
|
},
|
|
15
|
-
slot?: In["slot"],
|
|
16
20
|
) => void;
|
|
17
|
-
declare type ComposedNoCallback<In extends
|
|
18
|
-
$: In
|
|
19
|
-
slot?: In["slot"],
|
|
21
|
+
declare type ComposedNoCallback<In extends object, Out> = (
|
|
22
|
+
$: Required<In> extends Params ? Omit<In, "slot"> & { slot?: unknown } : In,
|
|
20
23
|
) => void;
|
|
21
24
|
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
/** Composes a component (v3), which can receive external reactive values via props */
|
|
26
|
+
export declare function compose<In extends object, Out extends NonNullable<unknown>>(
|
|
27
|
+
renderer: (input: In) => Out,
|
|
28
|
+
): Composed<In, Out>;
|
|
26
29
|
export declare function compose<In extends object>(renderer: (input: In) => void): ComposedNoCallback<In, void>;
|
|
27
|
-
export declare function compose<In extends object, Out>(renderer: (input: In) => Out): Composed<In, Out>;
|
|
28
30
|
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
/** Composes a component (v4), which can receive external reactive values via props */
|
|
32
|
+
export declare function component<In extends object, Out extends NonNullable<unknown>>(
|
|
33
|
+
renderer: (input: In) => Out,
|
|
34
|
+
): Composed<In, Out>;
|
|
35
|
+
export declare function component<In extends object>(renderer: (input: In) => void): ComposedNoCallback<In, void>;
|
|
36
|
+
|
|
37
|
+
/** Composes a view, which can receive external reactive values via props */
|
|
38
|
+
export declare function view<Out extends NonNullable<unknown>>(
|
|
39
|
+
renderer: () => Out,
|
|
40
|
+
): Composed<NonNullable<unknown>, Out>;
|
|
41
|
+
export declare function view<In extends object, Out extends NonNullable<unknown>>(
|
|
42
|
+
renderer: (input: In) => Out,
|
|
43
|
+
): Composed<In, Out>;
|
|
33
44
|
export declare function view(renderer: () => void): ComposedNoCallback<NonNullable<unknown>, void>;
|
|
34
45
|
export declare function view<In extends object>(renderer: (input: In) => void): ComposedNoCallback<In, void>;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*/
|
|
42
|
-
export declare function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export declare function mvvmView<In extends object, Out>(renderer: (input: In) => Out): Composed<In, Out>;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* create an MVC view, which can receive models from the parent component
|
|
51
|
-
* @param renderer is the view constructor
|
|
52
|
-
*/
|
|
53
|
-
export declare function mvcView<In extends object>(renderer: (input: In) => void): ComposedNoCallback<In, void>;
|
|
54
|
-
export declare function mvcView<In extends object, Out>(renderer: (input: In) => Out): Composed<In, Out>;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* create a hybrid view, which can receive external models and reactive values
|
|
58
|
-
* @param renderer is the view constructor
|
|
59
|
-
*/
|
|
60
|
-
export declare function hybridView<Models extends object, Props extends object>(
|
|
61
|
-
renderer: (models: Models, props: Props) => void,
|
|
62
|
-
): ComposedNoCallback<Models & Props, void>;
|
|
63
|
-
export declare function hybridView<Models extends object, Props extends object, Out>(
|
|
64
|
-
renderer: (models: Models, props: Props) => Out,
|
|
65
|
-
): Composed<Models & Props, Out>;
|
|
66
|
-
|
|
67
|
-
export declare function value<T>(v: T): T;
|
|
46
|
+
|
|
47
|
+
/** A Vasille.JS App screen */
|
|
48
|
+
type Screen<Route extends string> = (input: ScreenProps<Route>) => Promise<void>;
|
|
49
|
+
|
|
50
|
+
/** Composes a screen, the router navigates between screens */
|
|
51
|
+
export declare function screen<Route extends string>(renderer: Screen<Route>): Screen<Route>;
|
|
52
|
+
/** Composes a page, the file-based router navigates between pages (used for tests only) */
|
|
53
|
+
export declare function page<Route extends string>(renderer: Screen<Route>): Screen<Route>;
|
|
54
|
+
|
|
55
|
+
/** Returns the raw value of expression */
|
|
56
|
+
export declare function raw<T>(v: T): T;
|
|
57
|
+
/** Returns a reactive value of expression */
|
|
68
58
|
export declare function ref<T>(v: T): T;
|
|
59
|
+
/** Returns a reactive-computed form of expression */
|
|
69
60
|
export declare function bind<T>(v: T): T;
|
|
61
|
+
/** Returns a reactive-computed form of returned value */
|
|
70
62
|
export declare function calculate<T>(fn: () => T): T;
|
|
71
|
-
|
|
72
|
-
export declare function
|
|
73
|
-
|
|
74
|
-
export declare function
|
|
63
|
+
/** Runs the function each time when a dependency is changed */
|
|
64
|
+
export declare function watch(f: () => void): void;
|
|
65
|
+
/** Returns a view-model bind, which send data only forward */
|
|
66
|
+
export declare function forward<T>(v: T): T;
|
|
67
|
+
/** Returns a view-model bind, which send data only backward */
|
|
68
|
+
export declare function backward<T>(v: T): T;
|
|
69
|
+
/** Returns an array model of the array */
|
|
70
|
+
export declare function arrayModel<T>(v?: T[]): T[];
|
|
71
|
+
/** Returns a set model of array values */
|
|
72
|
+
export declare function setModel<T>(v?: T[]): Set<T>;
|
|
73
|
+
/** Returns a map model of map data */
|
|
74
|
+
export declare function mapModel<K, T>(v?: [K, T][]): Map<K, T>;
|
|
75
|
+
|
|
76
|
+
/** Awaits async data in a sync component */
|
|
77
|
+
export declare function awaited<T>(target: Promise<T>): [unknown, T | undefined, () => void];
|
|
78
|
+
export declare function awaited<T>(target: () => Promise<T>): [unknown, T | undefined, () => void];
|
|
75
79
|
|
|
80
|
+
/** Mounts a slot parameter of the component */
|
|
76
81
|
export declare function Slot(options: { model?: () => void; slot?: () => void }): void;
|
|
77
82
|
export declare function Slot<Props extends object>(
|
|
78
83
|
options: {
|
|
@@ -81,52 +86,89 @@ export declare function Slot<Props extends object>(
|
|
|
81
86
|
} & Props,
|
|
82
87
|
): void;
|
|
83
88
|
|
|
84
|
-
|
|
89
|
+
/** Renders content conditionally */
|
|
90
|
+
export declare function If(props: { $condition: unknown; slot?: unknown }): void;
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
/** Renders content conditionally, use strict after `<If/>` */
|
|
93
|
+
export declare function ElseIf(props: { $condition: unknown; slot?: unknown }): void;
|
|
87
94
|
|
|
95
|
+
/** Renders content conditionally, use strict after `<If/>` or `<ElseIf/>` */
|
|
88
96
|
export declare function Else(props: { slot?: unknown }): void;
|
|
89
97
|
|
|
90
|
-
|
|
91
|
-
export declare function For<T>(props: {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
/** Renders content several times using a model (array, map or set) */
|
|
99
|
+
export declare function For<T>(props: {
|
|
100
|
+
of: readonly DeepReadonly<T>[];
|
|
101
|
+
slot?: (value: DeepReadonly<T>) => void;
|
|
102
|
+
}): void;
|
|
103
|
+
export declare function For<T>(props: {
|
|
104
|
+
of: ReadonlySet<DeepReadonly<T>>;
|
|
105
|
+
slot?: (value: DeepReadonly<T>) => void;
|
|
106
|
+
}): void;
|
|
107
|
+
export declare function For<K, T>(props: {
|
|
108
|
+
of: ReadonlyMap<DeepReadonly<K>, DeepReadonly<T>>;
|
|
109
|
+
slot?: (value: DeepReadonly<T>, index: DeepReadonly<K>) => void;
|
|
110
|
+
}): void;
|
|
111
|
+
|
|
112
|
+
/** Refresh the content each time then the reactive model is updated */
|
|
113
|
+
export declare function Watch<T>(props: { $model: T; slot?: (value: T) => void }): void;
|
|
114
|
+
|
|
115
|
+
/** Create a debug comment in DOM */
|
|
116
|
+
export declare function Debug(props: { $model: unknown }): void;
|
|
117
|
+
|
|
118
|
+
/** Render content after a while */
|
|
98
119
|
export declare function Delay(props: { time?: number; slot?: unknown }): void;
|
|
99
120
|
|
|
100
|
-
export
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
export type DeepReadonly<T> =
|
|
122
|
+
T extends Map<infer K, infer V>
|
|
123
|
+
? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>
|
|
124
|
+
: T extends ReadonlyMap<infer K, infer V>
|
|
125
|
+
? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>
|
|
126
|
+
: T extends WeakMap<infer K, infer V>
|
|
127
|
+
? WeakMap<DeepReadonly<K>, DeepReadonly<V>>
|
|
128
|
+
: T extends Set<infer U>
|
|
129
|
+
? ReadonlySet<DeepReadonly<U>>
|
|
130
|
+
: T extends ReadonlySet<infer U>
|
|
131
|
+
? ReadonlySet<DeepReadonly<U>>
|
|
132
|
+
: T extends WeakSet<infer U>
|
|
133
|
+
? WeakSet<DeepReadonly<U>>
|
|
134
|
+
: T extends Promise<infer U>
|
|
135
|
+
? Promise<DeepReadonly<U>>
|
|
136
|
+
: T extends (...args: unknown[]) => unknown
|
|
137
|
+
? T
|
|
138
|
+
: T extends {}
|
|
139
|
+
? { readonly [K in keyof T]: DeepReadonly<T[K]> }
|
|
140
|
+
: T;
|
|
141
|
+
|
|
142
|
+
/** Stores a singleton state to memory */
|
|
143
|
+
export declare function store<Return extends object>(fn: () => Return): DeepReadonly<Return>;
|
|
144
|
+
|
|
145
|
+
/** Creates a model (state) constructor */
|
|
146
|
+
export declare function model<Return extends object>(fn: () => Return): () => DeepReadonly<Return>;
|
|
147
|
+
export declare function model<Input extends object, Return extends object>(
|
|
111
148
|
fn: (input: Input) => Return,
|
|
112
|
-
): (input: Input) => Return
|
|
113
|
-
|
|
114
|
-
export { $ } from "vasille-jsx";
|
|
149
|
+
): (input: Input) => DeepReadonly<Return>;
|
|
115
150
|
|
|
116
151
|
export { QueryParams, ScreenProps, RouteParameters } from "vasille-router";
|
|
117
152
|
export { Router, NavigationMode } from "vasille-router/web-router";
|
|
118
153
|
|
|
154
|
+
/** Applies the value to theme `name` */
|
|
119
155
|
export declare function theme<T>(name: string, value: T): T;
|
|
156
|
+
/** Applies the value to dark theme */
|
|
120
157
|
export declare function dark<T>($: T): T;
|
|
121
|
-
|
|
158
|
+
/** Applies the value to mobile devices */
|
|
122
159
|
export declare function mobile<T>($: T): T;
|
|
160
|
+
/** Applies the value to tablet devices */
|
|
123
161
|
export declare function tablet<T>($: T): T;
|
|
162
|
+
/** Applies the value to laptop devices */
|
|
124
163
|
export declare function laptop<T>($: T): T;
|
|
164
|
+
/** Applies the value when user prefers dark theme */
|
|
125
165
|
export declare function prefersDark<T>($: T): T;
|
|
166
|
+
/** Applies the value when user prefers light theme */
|
|
126
167
|
export declare function prefersLight<T>($: T): T;
|
|
127
168
|
|
|
128
169
|
export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "vasille-css";
|
|
129
170
|
|
|
171
|
+
/** Creates a local style sheet */
|
|
130
172
|
export declare const styleSheet: <
|
|
131
173
|
T extends {
|
|
132
174
|
[className: string]: {
|
|
@@ -140,6 +182,7 @@ export declare const styleSheet: <
|
|
|
140
182
|
input: T,
|
|
141
183
|
) => { [K in keyof T]: string };
|
|
142
184
|
|
|
185
|
+
/** Mounts a Vasille.JS component to page */
|
|
143
186
|
export declare function mount<T>(
|
|
144
187
|
element: Element,
|
|
145
188
|
component: ($: T) => void,
|
|
@@ -147,10 +190,6 @@ export declare function mount<T>(
|
|
|
147
190
|
debugUi?: boolean,
|
|
148
191
|
): App<Node, Element, TagOptions>;
|
|
149
192
|
|
|
150
|
-
type Screen<Route extends string> = (input: ScreenProps<Route>) => Promise<void>;
|
|
151
|
-
|
|
152
|
-
export declare function screen<Route extends string>(renderer: Screen<Route>): Screen<Route>;
|
|
153
|
-
|
|
154
193
|
interface RouterInitialization<Routes extends string> {
|
|
155
194
|
routes: {
|
|
156
195
|
[K in Routes]: {
|
|
@@ -165,33 +204,35 @@ interface RouterInitialization<Routes extends string> {
|
|
|
165
204
|
loadingOverlay?(props: object): void;
|
|
166
205
|
}
|
|
167
206
|
|
|
207
|
+
/** Starts a route app */
|
|
168
208
|
export declare function routerApp<Routes extends string>(
|
|
169
209
|
init: RouterInitialization<Routes>,
|
|
170
210
|
element?: Element,
|
|
171
211
|
debugUi?: boolean,
|
|
172
212
|
): App<Node, Element, TagOptions>;
|
|
173
213
|
|
|
174
|
-
|
|
214
|
+
/** Run a function before component mount */
|
|
215
|
+
export declare function beforeMount(fn: () => void): void;
|
|
175
216
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
export interface BridgeValue<T> {
|
|
179
|
-
[VasilleKey]: T;
|
|
180
|
-
}
|
|
217
|
+
/** Run a function after component mount */
|
|
218
|
+
export declare function afterMount(fn: () => void): void;
|
|
181
219
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
bind<T>(v: T): BridgeValue<T>;
|
|
185
|
-
calculate<T>(fn: () => T): BridgeValue<T>;
|
|
186
|
-
watch(fn: () => void): void;
|
|
187
|
-
arrayModel<T>(arr?: T[]): ArrayModel<T>;
|
|
188
|
-
setModel<T>(data?: T[]): SetModel<T>;
|
|
189
|
-
mapModel<K, T>(data?: [K, T][]): MapModel<K, T>;
|
|
190
|
-
reactiveObject<T extends object>(obj: T): { [K in keyof T]: BridgeValue<T[K]> };
|
|
191
|
-
value<T>(of: BridgeValue<T>): T;
|
|
192
|
-
setValue<T>(of: BridgeValue<T>, value: T): T;
|
|
193
|
-
stored<T>(v: T | IValue<T> | BridgeValue<T>): T;
|
|
194
|
-
destroy(v: BridgeValue<unknown>): void;
|
|
195
|
-
};
|
|
220
|
+
/** Run a function before component destroy */
|
|
221
|
+
export declare function beforeDestroy(fn: () => void): void;
|
|
196
222
|
|
|
223
|
+
/** Returns the current used router */
|
|
197
224
|
export declare function router(): Router<string> | undefined;
|
|
225
|
+
|
|
226
|
+
/** Composes a modal window (v4+) */
|
|
227
|
+
export declare function modal<T extends object>(modal: (input: T) => void): (input: T) => void;
|
|
228
|
+
|
|
229
|
+
/** Describes properties of a prompt window */
|
|
230
|
+
export interface PromptProps<T> {
|
|
231
|
+
resolve(data: T): void;
|
|
232
|
+
reject(err: unknown): void;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Composes a function which will show a prompt on call */
|
|
236
|
+
export declare function prompt<T, Input extends PromptProps<T> = PromptProps<T>>(
|
|
237
|
+
modal: (input: Input) => void,
|
|
238
|
+
): (input: Omit<Input, keyof PromptProps<unknown>>, timeout?: number) => Promise<T>;
|
package/lib/bin.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cwd, exit } from "node:process";
|
|
3
|
+
import { readFileSync } from "fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
const packageJsonPath = path.join(cwd(), "./package.json");
|
|
6
|
+
let content = undefined;
|
|
7
|
+
try {
|
|
8
|
+
content = readFileSync(packageJsonPath, "utf8");
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
console.error("Failed to read package.json", e);
|
|
12
|
+
exit(1);
|
|
13
|
+
}
|
|
14
|
+
let parsed;
|
|
15
|
+
try {
|
|
16
|
+
parsed = JSON.parse(content);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
console.error("Failed to parse package.json", e);
|
|
20
|
+
exit(2);
|
|
21
|
+
}
|
|
22
|
+
if (parsed &&
|
|
23
|
+
typeof parsed === "object" &&
|
|
24
|
+
"devDependencies" in parsed &&
|
|
25
|
+
parsed.devDependencies &&
|
|
26
|
+
typeof parsed.devDependencies === "object" &&
|
|
27
|
+
"vasille-web-cli" in parsed.devDependencies) {
|
|
28
|
+
import(path.join(cwd(), "./node_modules/vasille-web-cli/bin/run.js"));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.info("Vasille Web CLI is not installed. Please run `npm install --save-dev vasille-web-cli`");
|
|
32
|
+
exit(1);
|
|
33
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,20 +1,67 @@
|
|
|
1
|
+
import { Portal, reportError } from "vasille";
|
|
1
2
|
import { Runner } from "vasille/web-runner";
|
|
2
3
|
import { mount as coreMount } from "vasille-jsx";
|
|
3
|
-
import { mvvmView as coreMvvmView } from "vasille-jsx";
|
|
4
4
|
import { styleSheet as coreStyleSheet } from "vasille-css";
|
|
5
5
|
import { routeApp as coreRouteApp } from "vasille-router/web-router";
|
|
6
|
-
export {
|
|
7
|
-
export { screen } from "vasille-router";
|
|
6
|
+
export { view, view as component, view as compose, forward, backward, ensure, ref, expr, expr as bind, expr as calculate, expr as watch, set, Debug, Delay, For, Slot, Watch, awaited, store, model, setModel, mapModel, arrayModel, Switch, setErrorHandler, match, } from "vasille-jsx";
|
|
7
|
+
export { screen, screen as page, } from "vasille-router";
|
|
8
8
|
export { Router, routeApp } from "vasille-router/web-router";
|
|
9
|
+
export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "vasille-css";
|
|
9
10
|
export const styleSheet = coreStyleSheet;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return coreMvvmView(renderer, name);
|
|
11
|
+
function createPortal(node) {
|
|
12
|
+
const portal = new Portal({ node: document.body }, node.runner);
|
|
13
|
+
node.create(portal);
|
|
14
|
+
return portal;
|
|
15
15
|
}
|
|
16
|
-
export function
|
|
17
|
-
return
|
|
16
|
+
export function modal(modal) {
|
|
17
|
+
return function (props, node) {
|
|
18
|
+
if (!node) {
|
|
19
|
+
throw new Error("Vasille: Modal context is missing");
|
|
20
|
+
}
|
|
21
|
+
const portal = createPortal(node);
|
|
22
|
+
try {
|
|
23
|
+
modal(portal, props);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
reportError(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function prompt(modal) {
|
|
31
|
+
return function (node, input, timeout) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const portal = createPortal(node);
|
|
34
|
+
const timer = timeout &&
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
destroy();
|
|
37
|
+
reject(new Error("Timeout"));
|
|
38
|
+
}, timeout);
|
|
39
|
+
function destroy() {
|
|
40
|
+
timer && clearTimeout(timer);
|
|
41
|
+
portal.destroy();
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
modal(portal, {
|
|
45
|
+
...input,
|
|
46
|
+
resolve(value) {
|
|
47
|
+
destroy();
|
|
48
|
+
resolve(value);
|
|
49
|
+
},
|
|
50
|
+
reject(error) {
|
|
51
|
+
destroy();
|
|
52
|
+
reject(error);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
destroy();
|
|
58
|
+
reject(e);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function mount(element, component, input, debugUi) {
|
|
64
|
+
return coreMount(element, component, new Runner(debugUi ?? false, window.document), input);
|
|
18
65
|
}
|
|
19
66
|
export function routerApp(init, element, debugUi) {
|
|
20
67
|
return coreRouteApp(element ?? document.body, window, window.location, init, debugUi);
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vasille-web",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "The
|
|
3
|
+
"version": "4.1.0",
|
|
4
|
+
"description": "The same framework which is designed to build bulletproof frontends.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"vasille-web": "./lib/bin.js"
|
|
9
|
+
},
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
9
12
|
"types": "./fake-types/index.d.ts",
|
|
@@ -22,8 +25,7 @@
|
|
|
22
25
|
"prepack": "cp -f ../README.md ./README.md",
|
|
23
26
|
"prettier": "prettier src fake-types --write",
|
|
24
27
|
"build": "tsc --build tsconfig.json",
|
|
25
|
-
"check-types": "tsc --noEmit --lib es2020 --types web --moduleResolution Node16 --module Node16 ./fake-types/index.d.ts"
|
|
26
|
-
"update-types": "tsc --build tsconfig-types.json"
|
|
28
|
+
"check-types": "tsc --noEmit --lib es2020 --types web --moduleResolution Node16 --module Node16 ./fake-types/index.d.ts"
|
|
27
29
|
},
|
|
28
30
|
"type": "module",
|
|
29
31
|
"repository": {
|
|
@@ -45,14 +47,15 @@
|
|
|
45
47
|
"homepage": "https://github.com/vasille-js/vasille-js#readme",
|
|
46
48
|
"dependencies": {
|
|
47
49
|
"csstype": "^3.1.3",
|
|
48
|
-
"vasille": "^
|
|
49
|
-
"vasille-css": "^
|
|
50
|
-
"vasille-jsx": "^
|
|
51
|
-
"vasille-router": "^
|
|
50
|
+
"vasille": "^4.1.0",
|
|
51
|
+
"vasille-css": "^4.1.0",
|
|
52
|
+
"vasille-jsx": "^4.1.0",
|
|
53
|
+
"vasille-router": "^4.0.0"
|
|
52
54
|
},
|
|
53
55
|
"devDependencies": {
|
|
54
|
-
"
|
|
56
|
+
"@types/node": "^24.3.0",
|
|
55
57
|
"@types/web": "^0.0.256",
|
|
58
|
+
"prettier": "^3.6.2",
|
|
56
59
|
"typescript": "^5.8.3"
|
|
57
60
|
}
|
|
58
61
|
}
|
package/spec/css.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {ObsoletePropertiesHyphen, StandardPropertiesHyphen, VendorPropertiesHyphen} from "csstype";
|
|
2
2
|
|
|
3
|
-
export type RawStyleProps = StandardPropertiesHyphen<string | number | number[]
|
|
4
|
-
VendorPropertiesHyphen<string | number | number[]
|
|
5
|
-
ObsoletePropertiesHyphen<string | number | number[]
|
|
3
|
+
export type RawStyleProps = StandardPropertiesHyphen<string | number | number[]> &
|
|
4
|
+
VendorPropertiesHyphen<string | number | number[]> &
|
|
5
|
+
ObsoletePropertiesHyphen<string | number | number[]> &
|
|
6
6
|
{[variable: `--${string}`]: string};
|
|
7
7
|
export type StyleProps = {[K in keyof RawStyleProps]: RawStyleProps[K] | RawStyleProps[K][] };
|
package/types/bin.d.ts
ADDED
package/types/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Fragment } from "vasille";
|
|
2
2
|
import { StyleProps } from "../spec/css.js";
|
|
3
3
|
import { TagOptions } from "vasille/web-runner";
|
|
4
|
-
import { Composed as CoreComposed } from "vasille-jsx";
|
|
5
4
|
import { WebRouterInitialization } from "vasille-router/web-router";
|
|
6
|
-
export {
|
|
7
|
-
export { QueryParams, ScreenProps, RouteParameters, screen } from "vasille-router";
|
|
8
|
-
export { Router, WebRouterInitialization, NavigationMode, routeApp } from "vasille-router/web-router";
|
|
9
|
-
export
|
|
5
|
+
export { view, view as component, view as compose, forward, backward, ensure, ref, expr, expr as bind, expr as calculate, expr as watch, set, Debug, Delay, For, Slot, Watch, awaited, store, model, setModel, mapModel, arrayModel, Switch, setErrorHandler, match, } from "vasille-jsx";
|
|
6
|
+
export { type QueryParams, type ScreenProps, type RouteParameters, screen, screen as page, type FallbackScreenProps, type ErrorScreenProps, } from "vasille-router";
|
|
7
|
+
export { Router, type WebRouterInitialization, type NavigationMode, routeApp } from "vasille-router/web-router";
|
|
8
|
+
export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "vasille-css";
|
|
10
9
|
export declare const styleSheet: <T extends {
|
|
11
10
|
[className: string]: {
|
|
12
11
|
[media: `@${string}`]: {
|
|
@@ -15,6 +14,11 @@ export declare const styleSheet: <T extends {
|
|
|
15
14
|
[state: `:${string}`]: StyleProps;
|
|
16
15
|
} & StyleProps;
|
|
17
16
|
}>(input: T) => { [K in keyof T]: string; };
|
|
18
|
-
export declare function
|
|
19
|
-
export
|
|
20
|
-
|
|
17
|
+
export declare function modal<T extends object>(modal: (node: Fragment<Node, Element, TagOptions>, input: T) => void): (input: T, node: Fragment<Node, Element, TagOptions>) => void;
|
|
18
|
+
export interface PromptProps {
|
|
19
|
+
resolve(data: unknown): void;
|
|
20
|
+
reject(err: unknown): void;
|
|
21
|
+
}
|
|
22
|
+
export declare function prompt<T extends PromptProps>(modal: (node: Fragment<Node, Element, TagOptions>, input: T) => void): (node: Fragment<Node, Element, TagOptions>, input: T, timeout?: number) => Promise<unknown>;
|
|
23
|
+
export declare function mount<T>(element: Element, component: ($: T) => void, input: T, debugUi?: boolean): import("vasille").App<Node, Element, TagOptions, object>;
|
|
24
|
+
export declare function routerApp<Routes extends string>(init: WebRouterInitialization<Routes>, element?: Element, debugUi?: boolean): import("vasille").App<Node, Element, TagOptions, object>;
|
package/types/jsx-runtime.d.ts
CHANGED
|
@@ -3,12 +3,15 @@ import type { HtmlTagMap } from "../spec/html.d.ts";
|
|
|
3
3
|
type prefixedObject<T, P extends string> = {
|
|
4
4
|
[K in keyof T as K extends string ? `${P}${K}` : never]?: T[K];
|
|
5
5
|
};
|
|
6
|
+
type EventHandlers<T> = {
|
|
7
|
+
[K in keyof T]: T[K] | [T[K], boolean | AddEventListenerOptions];
|
|
8
|
+
};
|
|
6
9
|
type HtmlInput<K extends keyof HTMLElementTagNameMap & keyof HtmlTagMap> = {
|
|
7
10
|
callback?: (node: HTMLElementTagNameMap[K]) => unknown;
|
|
8
11
|
class?: (string | Record<string, boolean> | false)[] | string;
|
|
9
12
|
style?: RawStyleProps | string;
|
|
10
13
|
slot?: unknown;
|
|
11
|
-
} & Partial<HtmlTagMap[K]["attrs"]> & prefixedObject<HtmlTagMap[K]["events"]
|
|
14
|
+
} & Partial<HtmlTagMap[K]["attrs"]> & prefixedObject<EventHandlers<HtmlTagMap[K]["events"]>, "on"> & Partial<prefixedObject<HtmlTagMap[K]["props"], "bind:">>;
|
|
12
15
|
export declare namespace JSX {
|
|
13
16
|
type ElementType = keyof IntrinsicElements | ((props?: object) => void);
|
|
14
17
|
type Element = never;
|