vasille-web 4.3.2 → 5.0.1

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 CHANGED
@@ -1,19 +1,32 @@
1
- # Vasille
1
+ # Steel Frame
2
2
 
3
- ![Vasille.js logo](https://raw.githubusercontent.com/vasille-js/vasille-js/refs/heads/v4/doc/img/logo.png)
3
+ ![Vasille.js logo](https://raw.githubusercontent.com/vasille-js/vasille-js/refs/heads/v5/doc/img/logo.png)
4
4
 
5
- `Vasille Web` is a front-end framework, which is developed to provide bulletproof frontends.
5
+ `SteelFrameKit` is a front-end development kit, which is developed to provide fault tolerant web applications.
6
6
 
7
- [![npm](https://img.shields.io/npm/v/vasille?style=flat-square)](https://www.npmjs.com/package/vasille)
7
+ [![npm](https://img.shields.io/npm/v/steel-frame?style=flat-square)](https://www.npmjs.com/package/steel-frame)
8
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/vasille-js/steel-frame)
9
+ [![Coverage Status](https://coveralls.io/repos/github/vasille-js/steel-frame/badge.svg?branch=v5)](https://coveralls.io/github/vasille-js/steel-frame?branch=v5)
8
10
 
9
11
  ## Table of content
10
12
 
11
- * [Installation](#installation)
12
- * [How to use Vasille](#how-to-use-vasille)
13
- * [How SAFE is Vasille](#how-safe-is-vasille)
14
- * [How INTUITIVE is Vasille](#how-intuitive-is-vasille)
15
- * [How POWERFUL is Vasille](#how-powerful-is-vasille)
16
- * [Road Map](#road-map)
13
+ - [Steel Frame](#steel-frame)
14
+ - [Table of content](#table-of-content)
15
+ - [Installation](#installation)
16
+ - [How to use SteelFramekit](#how-to-use-steelframekit)
17
+ - [Full documentation:](#full-documentation)
18
+ - [Examples](#examples)
19
+ - [How SAFE is SteelFrameKit](#how-safe-is-steelframekit)
20
+ - [How INTUITIVE is SteelFrameKit](#how-intuitive-is-steelframekit)
21
+ - [How POWERFUL is SteelFrameKit](#how-powerful-is-steelframekit)
22
+ - [Road map](#road-map)
23
+ - [Change log](#change-log)
24
+ - [5.0](#50)
25
+ - [4.0 - 4.3](#40---43)
26
+ - [3.0 - 3.2](#30---32)
27
+ - [2.0 - 2.3](#20---23)
28
+ - [1.0 - 1.2](#10---12)
29
+ - [Questions](#questions)
17
30
 
18
31
 
19
32
  <hr>
@@ -21,21 +34,22 @@
21
34
  ## Installation
22
35
 
23
36
  ```
24
- npm install vasille-web --save
37
+ npm install steel-frame --save
25
38
  ```
26
39
 
27
- ## How to use Vasille
40
+ ## How to use SteelFramekit
28
41
 
29
42
  Create an app from a template
30
43
 
31
44
  ```bash
32
- $ npm create vasille
45
+ $ npm create steel-frame
33
46
  ```
34
47
 
35
48
  ### Full documentation:
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)
38
- * [Vasille Compostion function](https://github.com/vasille-js/vasille-js/blob/v4/doc/Compositions.md)
49
+ * [Learn `SteelFrameKit` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/v5/doc/V4-API.md)
50
+ * [Router Documentation](https://github.com/vasille-js/vasille-js/blob/v5/doc/Router-API.md)
51
+ * [Compostion functions](https://github.com/vasille-js/vasille-js/blob/v5/doc/Compositions.md)
52
+ * [Dependency injection](https://github.com/vasille-js/vasille-js/blob/v5/doc/Context.md)
39
53
 
40
54
  ### Examples
41
55
  * [TypeScript Example](https://github.com/vasille-js/example-typescript)
@@ -43,14 +57,14 @@ $ npm create vasille
43
57
 
44
58
  <hr>
45
59
 
46
- ## How SAFE is Vasille
60
+ ## How SAFE is SteelFrameKit
47
61
 
48
62
  The safe of your application is ensured by
49
63
  * `100%` coverage of code by unit tests.
50
64
  Each function, each branch is working as designed.
51
65
  * OOP, DRY, KISS and SOLID principles are applied.
52
66
  * `strong typing` makes your javascript/typescript code safe as C++ code.
53
- All entities of `vasille` core library are strongly typed, including:
67
+ All entities of `SteelFrameKit` core library are strongly typed, including:
54
68
  * data fields & properties.
55
69
  * computed properties (function parameters and result).
56
70
  * methods.
@@ -60,11 +74,11 @@ All entities of `vasille` core library are strongly typed, including:
60
74
  * references to children.
61
75
  * No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
62
76
 
63
- ## How INTUITIVE is Vasille
77
+ ## How INTUITIVE is SteelFrameKit
64
78
 
65
79
  There is the "Hello World":
66
80
  ```typescript jsx
67
- import { compose, mount } from "vasille-dx";
81
+ import { compose, mount } from "steel-frame";
68
82
 
69
83
  const App = compose(() => {
70
84
  <p>Hello world</p>;
@@ -73,60 +87,76 @@ const App = compose(() => {
73
87
  mount(document.body, App, {});
74
88
  ```
75
89
 
76
- ## How POWERFUL is Vasille
90
+ ## How POWERFUL is SteelFrameKit
77
91
 
78
92
  All of these are supported:
79
93
  * Components.
80
94
  * Reactive values (observables).
81
95
  * Inline computed values.
82
96
  * Multiline computed values.
83
- * HTML & SVG tags.
97
+ * HTML tags.
84
98
  * Component custom slots.
85
99
  * 2-way data binding in components.
86
100
  * Logic block (if, else).
87
101
  * Loops (array, map, set).
102
+ * Dependency injection.
88
103
 
89
104
  <hr>
90
105
 
91
106
  ## Road map
92
107
 
93
- * [x] Update the `Vasille Core` library to version 3.0.
94
108
  * [x] `100%` Test Coverage for core Library v3.
95
- * [x] Develop the `Vasille JSX` library.
109
+ * [x] Develop the `JSX` library.
96
110
  * [x] `100%` Test Coverage for the JSX library.
97
- * [x] Develop the `Vasille Babel Plugin`.
111
+ * [x] Develop the `Babel Plugin`.
98
112
  * [x] `100%` Test Coverage fot babel plugin.
99
113
  * [x] Add CSS support (define styles in components).
100
114
  * [x] Add router.
101
115
  * [x] Add SSG (static site generation).
116
+ * [ ] Develop tools extension for debugging (WIP).
102
117
  * [ ] Add SSR (server side rendering).
103
- * [ ] Develop tools extension for debugging.
104
118
 
105
119
  ## Change log
106
120
 
107
- ### 4.3.0
121
+ We respect semantic versioning:
122
+ - Major version is increased when we make incompatible API changes.
123
+ - Minor version is increased when we add functionality.
124
+ - Patch version is increased when we fix bugs.
108
125
 
109
- Add new function `safe` which make functions safe, errors are reported automatically.
126
+ ### 5.0
110
127
 
111
- ### 4.2.0
128
+ - Add support for context and dependencies injection.
129
+ - New developement direction: `fault tolerant`.
130
+ - Renamed to `steel-frame`. **[API change]**
131
+ - Removed `forward` and `backward` functions. **[API change]**
132
+ - Removed `Debug` component. **[API change]**
112
133
 
113
- Add support for inlined conditions in JSX, binary `&&` and ternary `?:` operator.
134
+ ### 4.0 - 4.3
114
135
 
115
- ### 4.1.0
136
+ - Initial version of the framework with file based routing and building scripts (`web dev` and `web build spa`).
137
+ - Reactive values naming switched to `$` prefix. **[API change]**
138
+ - `4.1` Added SSG (static site generation) as build option `web build static`.
139
+ - `4.2` Add support for inlined conditions in JSX, binary `&&` and ternary `?:` operator.
140
+ - `4.3` Add new function `safe` which make functions safe, errors are reported automatically.
116
141
 
117
- Added SSG (static site generation) as build option `vasille-web build static`.
142
+ ### 3.0 - 3.2
118
143
 
119
- ### 4.0.0
144
+ - Switch to a babel plugin to compile components code. **[API change]**
145
+ - 100% of code has been covered with unit tests.
146
+ - New developement direction: `keep it simple`.
120
147
 
121
- Initial version of the framework with file based routing and building scripts (`vasille-web dev` and `vasille-web build spa`).
148
+ ### 2.0 - 2.3
149
+
150
+ - Introduces components compilation via a typescript plugin. **[API change]**
151
+ - New developement direction: `write less, do more`.
152
+
153
+ ### 1.0 - 1.2
154
+
155
+ - Initial version of core library.
156
+ - Developemnt direction: `performance-first`.
122
157
 
123
158
  ## Questions
124
159
 
125
160
  If you have questions, feel free to contact the maintainer of the project:
126
161
 
127
162
  * [Author's Email](mailto:vas.lixcode@gmail.com)
128
- * [Author's Telegram](https://t.me/lixcode)
129
-
130
- <hr>
131
-
132
- **Made in Moldova** 🇲🇩
package/lib/index.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import { Portal, reportError } from "vasille";
2
2
  import { Runner } from "vasille/web-runner";
3
3
  import { mount as coreMount } from "vasille-jsx";
4
- import { styleSheet as coreStyleSheet } from "vasille-css";
5
4
  import { routeApp as coreRouteApp } from "vasille-router/web-router";
5
+ export { styleSheet } from "vasille-css";
6
6
  export { safe } from "vasille";
7
- 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, extract, } from "vasille-jsx";
7
+ export { view, view as component, view as compose, ensure, ref, expr, expr as bind, expr as calculate, expr as watch, set, Delay, For, Slot, Watch, awaited, store, model, setModel, mapModel, arrayModel, Switch, setErrorHandler, match, } from "vasille-jsx";
8
8
  export { screen, screen as page, } from "vasille-router";
9
- export { Router, routeApp } from "vasille-router/web-router";
9
+ export { Router } from "vasille-router/web-router";
10
10
  export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "vasille-css";
11
- export const styleSheet = coreStyleSheet;
11
+ export { context, impute, receive, share } from "vasille-context";
12
12
  function createPortal(node) {
13
13
  const portal = new Portal({ node: document.body }, node.runner);
14
14
  node.create(portal);
15
15
  return portal;
16
16
  }
17
- export function modal(modal) {
17
+ export function modal(modal, create = createPortal) {
18
18
  return function (props, node) {
19
19
  if (!node) {
20
20
  throw new Error("Vasille: Modal context is missing");
21
21
  }
22
- const portal = createPortal(node);
22
+ const portal = create(node);
23
23
  try {
24
24
  modal(portal, props);
25
25
  }
@@ -28,10 +28,10 @@ export function modal(modal) {
28
28
  }
29
29
  };
30
30
  }
31
- export function prompt(modal) {
31
+ export function prompt(modal, create = createPortal) {
32
32
  return function (node, input, timeout) {
33
33
  return new Promise((resolve, reject) => {
34
- const portal = createPortal(node);
34
+ const portal = create(node);
35
35
  const timer = timeout &&
36
36
  setTimeout(() => {
37
37
  destroy();
@@ -61,9 +61,9 @@ export function prompt(modal) {
61
61
  });
62
62
  };
63
63
  }
64
- export function mount(element, component, input, debugUi) {
65
- return coreMount(element, component, new Runner(debugUi ?? false, window.document), input);
64
+ export function mount(element, component, input) {
65
+ return coreMount(element, component, new Runner(window.document), input);
66
66
  }
67
- export function routerApp(init, element, debugUi) {
68
- return coreRouteApp(element ?? document.body, window, window.location, init, debugUi);
67
+ export function routerApp(init, element) {
68
+ return coreRouteApp(element ?? document.body, window, window.location, init);
69
69
  }
package/package.json CHANGED
@@ -1,15 +1,12 @@
1
1
  {
2
2
  "name": "vasille-web",
3
- "version": "4.3.2",
3
+ "version": "5.0.1",
4
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
- },
10
7
  "exports": {
11
8
  ".": {
12
- "types": "./fake-types/index.d.ts",
9
+ "types": "./types/index.d.ts",
13
10
  "import": "./lib/index.js",
14
11
  "browser": "./lib/index.js",
15
12
  "node": "./lib/index.js"
@@ -19,13 +16,19 @@
19
16
  "import": "./lib/jsx-runtime.js",
20
17
  "browser": "./lib/jsx-runtime.js",
21
18
  "node": "./lib/jsx-runtime.js"
19
+ },
20
+ "./dev": {
21
+ "types": "./types/dev.d.ts",
22
+ "import": "./lib/dev.js",
23
+ "browser": "./lib/dev.js",
24
+ "node": "./lib/dev.js"
22
25
  }
23
26
  },
24
27
  "scripts": {
25
28
  "prepack": "cp -f ../README.md ./README.md",
26
- "prettier": "prettier src fake-types --write",
27
- "build": "tsc --build tsconfig.json",
28
- "check-types": "tsc --noEmit --lib es2020 --types web --moduleResolution Node16 --module Node16 ./fake-types/index.d.ts"
29
+ "prettier": "prettier src --write",
30
+ "prebuild": "rm -rf lib types",
31
+ "build": "tsc --build tsconfig.json"
29
32
  },
30
33
  "type": "module",
31
34
  "repository": {
@@ -47,10 +50,11 @@
47
50
  "homepage": "https://github.com/vasille-js/vasille-js#readme",
48
51
  "dependencies": {
49
52
  "csstype": "^3.1.3",
50
- "vasille": "^4.3.1",
51
- "vasille-css": "^4.1.0",
52
- "vasille-jsx": "^4.3.4",
53
- "vasille-router": "^4.0.0"
53
+ "vasille": "^5.0.0",
54
+ "vasille-context": "^5.0.0",
55
+ "vasille-css": "^5.0.0",
56
+ "vasille-jsx": "^5.0.0",
57
+ "vasille-router": "^5.0.0"
54
58
  },
55
59
  "devDependencies": {
56
60
  "@types/node": "^24.3.0",
package/types/dev.d.ts CHANGED
@@ -3,7 +3,7 @@ import { TagOptions } from "vasille/web-runner";
3
3
  import { IDevRunner, Inspector, StaticPosition } from "vasille/dev";
4
4
  import { PromptProps } from "./index.js";
5
5
  import { WebRouterInitialization } from "vasille-router/web-router";
6
- export declare function devModal<T extends object>(modalFn: (node: Fragment<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>>, input: T) => void, declaration: StaticPosition, name: string): (input: T, node: Fragment<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>>, usage: StaticPosition | undefined) => void;
6
+ export declare function devModal<T extends object>(modalFn: (node: Fragment<Node, Element, TagOptions>, input: T) => void, declaration: StaticPosition, name: string): (input: T, node: Fragment<Node, Element, TagOptions>, usage: StaticPosition | undefined) => void;
7
7
  export declare function devPrompt<T extends PromptProps>(modal: (node: Fragment<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>>, input: T) => void, declaration: StaticPosition, name: string): (node: Fragment<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>>, input: T, timeout: number | undefined, usage: StaticPosition | undefined) => Promise<unknown>;
8
8
  export declare function devMount<T>(element: Element, component: ($: T) => void, input: T, inspector: Inspector): import("vasille").App<Node, Element, import("vasille/dev").DevTagOptions, import("vasille").Runner<Node, Element, import("vasille/dev").DevTagOptions>>;
9
9
  export declare function devRouterApp<Routes extends string>(init: WebRouterInitialization<Routes>, element: Element, inspector: Inspector): import("vasille").App<Node, Element, import("vasille/dev").DevTagOptions, import("vasille").Runner<Node, Element, import("vasille/dev").DevTagOptions>>;
package/types/index.d.ts CHANGED
@@ -1,27 +1,20 @@
1
- import { Fragment } from "vasille";
2
- import { StyleProps } from "../spec/css.js";
1
+ import { App, Fragment, Portal } from "vasille";
3
2
  import { TagOptions } from "vasille/web-runner";
4
3
  import { WebRouterInitialization } from "vasille-router/web-router";
5
- export type { RawStyleProps as StyleProps } from "../spec/css.js";
4
+ export { styleSheet } from "vasille-css";
5
+ export type { RawStyleProps as StyleProps, StyleSheetProps } from "./spec/css.js";
6
6
  export type { ClassItem } from "./jsx-runtime.js";
7
7
  export { safe } from "vasille";
8
- 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, extract, } from "vasille-jsx";
8
+ export { view, view as component, view as compose, ensure, ref, expr, expr as bind, expr as calculate, expr as watch, set, Delay, For, Slot, Watch, awaited, store, model, setModel, mapModel, arrayModel, Switch, setErrorHandler, match, } from "vasille-jsx";
9
9
  export { type QueryParams, type ScreenProps, type RouteParameters, screen, screen as page, type FallbackScreenProps, type ErrorScreenProps, } from "vasille-router";
10
- export { Router, type WebRouterInitialization, type NavigationMode, routeApp } from "vasille-router/web-router";
10
+ export { Router, type WebRouterInitialization, type NavigationMode } from "vasille-router/web-router";
11
11
  export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "vasille-css";
12
- export declare const styleSheet: <T extends {
13
- [className: string]: {
14
- [media: `@${string}`]: {
15
- [state: `:${string}`]: StyleProps;
16
- } & StyleProps;
17
- [state: `:${string}`]: StyleProps;
18
- } & StyleProps;
19
- }>(input: T) => { [K in keyof T]: string; };
20
- export declare function modal<T extends object>(modal: (node: Fragment<Node, Element, TagOptions>, input: T) => void): (input: T, node: Fragment<Node, Element, TagOptions>) => void;
12
+ export { context, impute, receive, share } from "vasille-context";
13
+ export declare function modal<T extends object>(modal: (node: Fragment<Node, Element, TagOptions>, input: T) => void, create?: (node: Fragment<Node, Element, TagOptions>) => Portal<Node, Element, TagOptions>): (input: T, node: Fragment<Node, Element, TagOptions>) => void;
21
14
  export interface PromptProps {
22
15
  resolve(data: unknown): void;
23
16
  reject(err: unknown): void;
24
17
  }
25
- 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>;
26
- export declare function mount<T>(element: Element, component: ($: T) => void, input: T, debugUi?: boolean): import("vasille").App<Node, Element, TagOptions, object>;
27
- export declare function routerApp<Routes extends string>(init: WebRouterInitialization<Routes>, element?: Element, debugUi?: boolean): import("vasille").App<Node, Element, TagOptions, object>;
18
+ export declare function prompt<T extends PromptProps>(modal: (node: Fragment<Node, Element, TagOptions>, input: T) => void, create?: (node: Fragment<Node, Element, TagOptions>) => Portal<Node, Element, TagOptions>): (node: Fragment<Node, Element, TagOptions>, input: T, timeout?: number) => Promise<unknown>;
19
+ export declare function mount<T>(element: Element, component: ($: T) => void, input: T): App<Node, Element, TagOptions>;
20
+ export declare function routerApp<Routes extends string>(init: WebRouterInitialization<Routes>, element?: Element): App<Node, Element, TagOptions>;
@@ -1,9 +1,10 @@
1
- import type { RawStyleProps } from "../spec/css.d.ts";
2
- import type { HtmlTagMap } from "../spec/html.d.ts";
3
- type prefixedObject<T, P extends string> = {
1
+ import type { RawStyleProps } from "./spec/css.ts";
2
+ import type { HtmlTagMap } from "./spec/html.ts";
3
+ export type { TagEvents, TagAttrs, TagProps } from "./spec/html.ts";
4
+ export type prefixedObject<T, P extends string> = {
4
5
  [K in keyof T as K extends string ? `${P}${K}` : never]?: T[K];
5
6
  };
6
- type EventHandlers<T> = {
7
+ export type EventHandlers<T> = {
7
8
  [K in keyof T]: T[K] | [T[K], boolean | AddEventListenerOptions];
8
9
  };
9
10
  export type ClassItem = string | Record<string, boolean> | false;
@@ -21,7 +22,7 @@ export declare namespace JSX {
21
22
  slot: unknown;
22
23
  }
23
24
  interface IntrinsicElements {
24
- a2: HtmlInput<"a">;
25
+ a: HtmlInput<"a">;
25
26
  abbr: HtmlInput<"abbr">;
26
27
  address: HtmlInput<"address">;
27
28
  area: HtmlInput<"area">;
@@ -133,4 +134,3 @@ export declare namespace JSX {
133
134
  wbr: HtmlInput<"wbr">;
134
135
  }
135
136
  }
136
- export {};
@@ -4,10 +4,10 @@ export interface Tag<Attrs, Events, Props> {
4
4
  events: Events;
5
5
  props: Props;
6
6
  }
7
- type TagEvents<Target> = {
7
+ export type TagEvents<Target> = {
8
8
  [K in keyof HTMLElementEventMap]: EventHandler<HTMLElementEventMap[K], Target> | undefined;
9
9
  };
10
- interface TagAttrs {
10
+ export interface TagAttrs {
11
11
  id: string;
12
12
  accesskey: string;
13
13
  autocapitalize: "off" | "none" | "on" | "sentences" | "words" | "characters";
@@ -27,6 +27,8 @@ interface TagAttrs {
27
27
  itemtype: string;
28
28
  lang: string;
29
29
  nonce: string;
30
+ part: string;
31
+ slot: string;
30
32
  spellcheck: "true" | "false" | "" | boolean;
31
33
  tabindex: number;
32
34
  title: string;
@@ -97,6 +99,7 @@ interface AAttrs extends TagAttrs {
97
99
  hreflang: string;
98
100
  type: string;
99
101
  referrerpolicy: string;
102
+ rel: string;
100
103
  }
101
104
  interface QAttrs extends TagAttrs {
102
105
  cite: string;
@@ -520,7 +523,7 @@ export interface TagEventsProps<T extends Element> {
520
523
  onwaiting?: ((this: T, ev: Event) => any) | null;
521
524
  onwheel?: ((this: T, ev: WheelEvent) => any) | null;
522
525
  }
523
- interface TagProps<T extends Element> extends TagEventsProps<T> {
526
+ export interface TagProps<T extends Element> extends TagEventsProps<T> {
524
527
  autofocus?: boolean;
525
528
  className?: string;
526
529
  nonce?: string | undefined;
@@ -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>;