vasille-web 4.3.1 → 5.0.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 +43 -31
- package/lib/dev.js +25 -0
- package/lib/index.js +12 -12
- package/lib/spec/css.js +1 -0
- package/lib/spec/html.js +1 -0
- package/package.json +16 -12
- package/types/dev.d.ts +9 -0
- package/types/index.d.ts +10 -17
- package/types/jsx-runtime.d.ts +3 -3
- package/types/spec/css.d.ts +7 -0
- package/{spec → types/spec}/html.d.ts +121 -211
- package/fake-types/index.d.ts +0 -213
- package/lib/bin.js +0 -33
- package/spec/css.d.ts +0 -7
- package/types/bin.d.ts +0 -2
package/fake-types/index.d.ts
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { App, Destroyable } from "vasille";
|
|
2
|
-
import type { TagOptions } from "vasille/web-runner";
|
|
3
|
-
import type { StyleProps } from "../spec/css.d.ts";
|
|
4
|
-
import type { ScreenProps } from "vasille-router";
|
|
5
|
-
import type { Router } from "vasille-router/web-router";
|
|
6
|
-
|
|
7
|
-
export type { RawStyleProps as StyleProps } from "../spec/css.d.ts";
|
|
8
|
-
export type ClassItem = string | Record<string, boolean> | false;
|
|
9
|
-
export type { FallbackScreenProps, ErrorScreenProps } from "vasille-router";
|
|
10
|
-
export { safe } from "vasille";
|
|
11
|
-
|
|
12
|
-
/** Set a handler for component errors */
|
|
13
|
-
export declare function setErrorHandler(handler: (e: unknown) => void): void;
|
|
14
|
-
|
|
15
|
-
declare interface Params {
|
|
16
|
-
slot(...args: unknown[]): unknown;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare type Composed<In extends object, Out> = (
|
|
20
|
-
$: (Required<In> extends Params ? Omit<In, "slot"> & { slot?: unknown } : In) & {
|
|
21
|
-
callback?(data: Out): void;
|
|
22
|
-
},
|
|
23
|
-
) => void;
|
|
24
|
-
declare type ComposedNoCallback<In extends object, Out> = (
|
|
25
|
-
$: Required<In> extends Params ? Omit<In, "slot"> & { slot?: unknown } : In,
|
|
26
|
-
) => void;
|
|
27
|
-
|
|
28
|
-
/** Composes a component (v3), which can receive external reactive values via props */
|
|
29
|
-
export declare function compose<In extends object, Out extends NonNullable<unknown>>(
|
|
30
|
-
renderer: (input: In) => Out,
|
|
31
|
-
): Composed<In, Out>;
|
|
32
|
-
export declare function compose<In extends object>(renderer: (input: In) => void): ComposedNoCallback<In, void>;
|
|
33
|
-
|
|
34
|
-
/** Composes a component (v4), which can receive external reactive values via props */
|
|
35
|
-
export declare function component<In extends object, Out extends NonNullable<unknown>>(
|
|
36
|
-
renderer: (input: In) => Out,
|
|
37
|
-
): Composed<In, Out>;
|
|
38
|
-
export declare function component<In extends object>(renderer: (input: In) => void): ComposedNoCallback<In, void>;
|
|
39
|
-
|
|
40
|
-
/** Composes a view, which can receive external reactive values via props */
|
|
41
|
-
export declare function view<Out extends NonNullable<unknown>>(
|
|
42
|
-
renderer: () => Out,
|
|
43
|
-
): Composed<NonNullable<unknown>, Out>;
|
|
44
|
-
export declare function view<In extends object, Out extends NonNullable<unknown>>(
|
|
45
|
-
renderer: (input: In) => Out,
|
|
46
|
-
): Composed<In, Out>;
|
|
47
|
-
export declare function view(renderer: () => void): ComposedNoCallback<NonNullable<unknown>, void>;
|
|
48
|
-
export declare function view<In extends object>(renderer: (input: In) => void): ComposedNoCallback<In, void>;
|
|
49
|
-
|
|
50
|
-
/** A Vasille.JS App screen */
|
|
51
|
-
type Screen<Route extends string> = (input: ScreenProps<Route>) => Promise<void>;
|
|
52
|
-
|
|
53
|
-
/** Composes a screen, the router navigates between screens */
|
|
54
|
-
export declare function screen<Route extends string>(renderer: Screen<Route>): Screen<Route>;
|
|
55
|
-
/** Composes a page, the file-based router navigates between pages (used for tests only) */
|
|
56
|
-
export declare function page<Route extends string>(renderer: Screen<Route>): Screen<Route>;
|
|
57
|
-
|
|
58
|
-
/** Returns the raw value of expression */
|
|
59
|
-
export declare function raw<T>(v: T): T;
|
|
60
|
-
/** Returns a reactive value of expression */
|
|
61
|
-
export declare function ref<T>(v: T): T;
|
|
62
|
-
/** Returns a reactive-computed form of expression */
|
|
63
|
-
export declare function bind<T>(v: T): T;
|
|
64
|
-
/** Returns a reactive-computed form of returned value */
|
|
65
|
-
export declare function calculate<T>(fn: () => T): T;
|
|
66
|
-
/** Runs the function each time when a dependency is changed */
|
|
67
|
-
export declare function watch(f: () => void): void;
|
|
68
|
-
/** Returns a view-model bind, which send data only forward */
|
|
69
|
-
export declare function forward<T>(v: T): T;
|
|
70
|
-
/** Returns a view-model bind, which send data only backward */
|
|
71
|
-
export declare function backward<T>(v: T): T;
|
|
72
|
-
/** Returns an array model of the array */
|
|
73
|
-
export declare function arrayModel<T>(v?: T[]): T[];
|
|
74
|
-
/** Returns a set model of array values */
|
|
75
|
-
export declare function setModel<T>(v?: T[]): Set<T>;
|
|
76
|
-
/** Returns a map model of map data */
|
|
77
|
-
export declare function mapModel<K, T>(v?: [K, T][]): Map<K, T>;
|
|
78
|
-
|
|
79
|
-
/** Awaits async data in a sync component */
|
|
80
|
-
export declare function awaited<T>(target: Promise<T>): [unknown, T | undefined, () => void];
|
|
81
|
-
export declare function awaited<T>(target: () => Promise<T>): [unknown, T | undefined, () => void];
|
|
82
|
-
|
|
83
|
-
/** Mounts a slot parameter of the component */
|
|
84
|
-
export declare function Slot(options: { model?: () => void; slot?: () => void }): void;
|
|
85
|
-
export declare function Slot<Props extends object>(
|
|
86
|
-
options: {
|
|
87
|
-
model?: (props: Props) => void;
|
|
88
|
-
slot?: () => void;
|
|
89
|
-
} & Props,
|
|
90
|
-
): void;
|
|
91
|
-
|
|
92
|
-
/** Renders content conditionally */
|
|
93
|
-
export declare function If(props: { $condition: unknown; slot?: unknown }): void;
|
|
94
|
-
|
|
95
|
-
/** Renders content conditionally, use strict after `<If/>` */
|
|
96
|
-
export declare function ElseIf(props: { $condition: unknown; slot?: unknown }): void;
|
|
97
|
-
|
|
98
|
-
/** Renders content conditionally, use strict after `<If/>` or `<ElseIf/>` */
|
|
99
|
-
export declare function Else(props: { slot?: unknown }): void;
|
|
100
|
-
|
|
101
|
-
/** Renders content several times using a model (array, map or set) */
|
|
102
|
-
export declare function For<T>(props: { of: readonly T[]; slot?: (value: T) => void }): void;
|
|
103
|
-
export declare function For<T>(props: { of: ReadonlySet<T>; slot?: (value: T) => void }): void;
|
|
104
|
-
export declare function For<K, T>(props: { of: ReadonlyMap<K, T>; slot?: (value: T, index: K) => void }): void;
|
|
105
|
-
|
|
106
|
-
/** Refresh the content each time then the reactive model is updated */
|
|
107
|
-
export declare function Watch<T>(props: { $model: T; slot?: (value: T) => void }): void;
|
|
108
|
-
|
|
109
|
-
/** Create a debug comment in DOM */
|
|
110
|
-
export declare function Debug(props: { $model: unknown }): void;
|
|
111
|
-
|
|
112
|
-
/** Render content after a while */
|
|
113
|
-
export declare function Delay(props: { time?: number; slot?: unknown }): void;
|
|
114
|
-
|
|
115
|
-
/** Stores a singleton state to memory */
|
|
116
|
-
export declare function store<Return extends object>(fn: () => Return): Return;
|
|
117
|
-
|
|
118
|
-
/** Creates a model (state) constructor */
|
|
119
|
-
export declare function model<Return extends object>(fn: () => Return): () => Return & Destroyable;
|
|
120
|
-
export declare function model<Input extends object, Return extends object>(
|
|
121
|
-
fn: (input: Input) => Return,
|
|
122
|
-
): (input: Input) => Return & Destroyable;
|
|
123
|
-
|
|
124
|
-
export { QueryParams, ScreenProps, RouteParameters } from "vasille-router";
|
|
125
|
-
export { Router, NavigationMode } from "vasille-router/web-router";
|
|
126
|
-
|
|
127
|
-
/** Applies the value to theme `name` */
|
|
128
|
-
export declare function theme<T>(name: string, value: T): T;
|
|
129
|
-
/** Applies the value to dark theme */
|
|
130
|
-
export declare function dark<T>($: T): T;
|
|
131
|
-
/** Applies the value to mobile devices */
|
|
132
|
-
export declare function mobile<T>($: T): T;
|
|
133
|
-
/** Applies the value to tablet devices */
|
|
134
|
-
export declare function tablet<T>($: T): T;
|
|
135
|
-
/** Applies the value to laptop devices */
|
|
136
|
-
export declare function laptop<T>($: T): T;
|
|
137
|
-
/** Applies the value when user prefers dark theme */
|
|
138
|
-
export declare function prefersDark<T>($: T): T;
|
|
139
|
-
/** Applies the value when user prefers light theme */
|
|
140
|
-
export declare function prefersLight<T>($: T): T;
|
|
141
|
-
|
|
142
|
-
export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "vasille-css";
|
|
143
|
-
|
|
144
|
-
/** Creates a local style sheet */
|
|
145
|
-
export declare const styleSheet: <
|
|
146
|
-
T extends {
|
|
147
|
-
[className: string]: {
|
|
148
|
-
[media: `@${string}`]: {
|
|
149
|
-
[state: `:${string}`]: StyleProps;
|
|
150
|
-
} & StyleProps;
|
|
151
|
-
[state: `:${string}`]: StyleProps;
|
|
152
|
-
} & StyleProps;
|
|
153
|
-
},
|
|
154
|
-
>(
|
|
155
|
-
input: T,
|
|
156
|
-
) => { [K in keyof T]: string };
|
|
157
|
-
|
|
158
|
-
/** Mounts a Vasille.JS component to page */
|
|
159
|
-
export declare function mount<T>(
|
|
160
|
-
element: Element,
|
|
161
|
-
component: ($: T) => void,
|
|
162
|
-
$: T,
|
|
163
|
-
debugUi?: boolean,
|
|
164
|
-
): App<Node, Element, TagOptions>;
|
|
165
|
-
|
|
166
|
-
interface RouterInitialization<Routes extends string> {
|
|
167
|
-
routes: {
|
|
168
|
-
[K in Routes]: {
|
|
169
|
-
screen: Screen<K>;
|
|
170
|
-
minAccessLevel?: number;
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
getAccessLevel?(): Promise<number>;
|
|
174
|
-
fallbackScreen?(arg: { cause: "not-found" | "no-access" }): void;
|
|
175
|
-
errorScreen?(data: { error: unknown }): void;
|
|
176
|
-
loadingScreen?(props: object): void;
|
|
177
|
-
loadingOverlay?(props: object): void;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/** Starts a route app */
|
|
181
|
-
export declare function routerApp<Routes extends string>(
|
|
182
|
-
init: RouterInitialization<Routes>,
|
|
183
|
-
element?: Element,
|
|
184
|
-
debugUi?: boolean,
|
|
185
|
-
): App<Node, Element, TagOptions>;
|
|
186
|
-
|
|
187
|
-
/** Run a function before component mount */
|
|
188
|
-
export declare function beforeMount(fn: () => void): void;
|
|
189
|
-
export declare function beforeMount(fn: () => Promise<void>): void;
|
|
190
|
-
|
|
191
|
-
/** Run a function after component mount */
|
|
192
|
-
export declare function afterMount(fn: () => void): void;
|
|
193
|
-
export declare function afterMount(fn: () => Promise<void>): void;
|
|
194
|
-
|
|
195
|
-
/** Run a function before component destroy */
|
|
196
|
-
export declare function beforeDestroy(fn: () => void): void;
|
|
197
|
-
|
|
198
|
-
/** Returns the current used router */
|
|
199
|
-
export declare function router(): Router<string> | undefined;
|
|
200
|
-
|
|
201
|
-
/** Composes a modal window (v4+) */
|
|
202
|
-
export declare function modal<T extends object>(modal: (input: T) => void): (input: T) => void;
|
|
203
|
-
|
|
204
|
-
/** Describes properties of a prompt window */
|
|
205
|
-
export interface PromptProps<T> {
|
|
206
|
-
resolve(data: T): void;
|
|
207
|
-
reject(err: unknown): void;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/** Composes a function which will show a prompt on call */
|
|
211
|
-
export declare function prompt<T, Input extends PromptProps<T> = PromptProps<T>>(
|
|
212
|
-
modal: (input: Input) => void,
|
|
213
|
-
): (input: Omit<Input, keyof PromptProps<unknown>>, timeout?: number) => Promise<T>;
|
package/lib/bin.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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/spec/css.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type {ObsoletePropertiesHyphen, StandardPropertiesHyphen, VendorPropertiesHyphen} from "csstype";
|
|
2
|
-
|
|
3
|
-
export type RawStyleProps = StandardPropertiesHyphen<string | number | number[]> &
|
|
4
|
-
VendorPropertiesHyphen<string | number | number[]> &
|
|
5
|
-
ObsoletePropertiesHyphen<string | number | number[]> &
|
|
6
|
-
{[variable: `--${string}`]: string};
|
|
7
|
-
export type StyleProps = {[K in keyof RawStyleProps]: RawStyleProps[K] | RawStyleProps[K][] };
|
package/types/bin.d.ts
DELETED