vasille-css 4.1.0 → 7.0.0-rc.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,69 +1,89 @@
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=round-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)
17
-
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
+ - [7.0](#70)
25
+ - [6.0 RC (never released)](#60-rc-never-released)
26
+ - [5.0 - 5.1](#50---51)
27
+ - [4.0 - 4.3](#40---43)
28
+ - [3.0 - 3.2](#30---32)
29
+ - [2.0 - 2.3](#20---23)
30
+ - [1.0 - 1.2](#10---12)
31
+ - [Questions](#questions)
18
32
 
19
33
  <hr>
20
34
 
21
35
  ## Installation
22
36
 
23
37
  ```
24
- npm install vasille-web --save
38
+ npm install steel-frame --save
25
39
  ```
26
40
 
27
- ## How to use Vasille
41
+ ## How to use SteelFramekit
28
42
 
29
43
  Create an app from a template
30
44
 
31
45
  ```bash
32
- $ npm create vasille
46
+ $ npm create steel-frame
33
47
  ```
34
48
 
35
49
  ### 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)
50
+
51
+ - [Learn `SteelFrameKit` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/v5/doc/V4-API.md)
52
+ - [Router Documentation](https://github.com/vasille-js/vasille-js/blob/v5/doc/Router-API.md)
53
+ - [Compostion functions](https://github.com/vasille-js/vasille-js/blob/v5/doc/Compositions.md)
54
+ - [Dependency injection](https://github.com/vasille-js/vasille-js/blob/v5/doc/Context.md)
38
55
 
39
56
  ### Examples
40
- * [TypeScript Example](https://github.com/vasille-js/example-typescript)
41
- * [JavaScript Example](https://github.com/vasille-js/example-javascript)
57
+
58
+ - [TypeScript Example](https://github.com/vasille-js/example-typescript)
59
+ - [JavaScript Example](https://github.com/vasille-js/example-javascript)
42
60
 
43
61
  <hr>
44
62
 
45
- ## How SAFE is Vasille
63
+ ## How SAFE is SteelFrameKit
46
64
 
47
65
  The safe of your application is ensured by
48
- * `100%` coverage of code by unit tests.
66
+
67
+ - `100%` coverage of code by unit tests.
49
68
  Each function, each branch is working as designed.
50
- * OOP, DRY, KISS and SOLID principles are applied.
51
- * `strong typing` makes your javascript/typescript code safe as C++ code.
52
- All entities of `vasille` core library are strongly typed, including:
53
- * data fields & properties.
54
- * computed properties (function parameters and result).
55
- * methods.
56
- * events (defined handlers & event emit).
57
- * DOM events & DOM operation (attributing, styling, etc.).
58
- * slots of components.
59
- * references to children.
60
- * No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
61
-
62
- ## How INTUITIVE is Vasille
69
+ - OOP, DRY, KISS and SOLID principles are applied.
70
+ - `strong typing` makes your code safe.
71
+ All entities of `SteelFrameKit` core library are strongly typed, including:
72
+ - data fields & properties.
73
+ - computed properties (function parameters and result).
74
+ - methods.
75
+ - events (defined handlers & event emit).
76
+ - DOM events & DOM operation (attributing, styling, etc.).
77
+ - slots of components.
78
+ - references to children.
79
+ - No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
80
+
81
+ ## How INTUITIVE is SteelFrameKit
63
82
 
64
83
  There is the "Hello World":
84
+
65
85
  ```typescript jsx
66
- import { compose, mount } from "vasille-dx";
86
+ import { compose, mount } from "steel-frame";
67
87
 
68
88
  const App = compose(() => {
69
89
  <p>Hello world</p>;
@@ -72,52 +92,89 @@ const App = compose(() => {
72
92
  mount(document.body, App, {});
73
93
  ```
74
94
 
75
- ## How POWERFUL is Vasille
95
+ ## How POWERFUL is SteelFrameKit
76
96
 
77
97
  All of these are supported:
78
- * Components.
79
- * Reactive values (observables).
80
- * Inline computed values.
81
- * Multiline computed values.
82
- * HTML & SVG tags.
83
- * Component custom slots.
84
- * 2-way data binding in components.
85
- * Logic block (if, else).
86
- * Loops (array, map, set).
98
+
99
+ - Components.
100
+ - Reactive values (observables).
101
+ - Inline computed values.
102
+ - Multiline computed values.
103
+ - HTML tags.
104
+ - Component custom slots.
105
+ - 2-way data binding in components.
106
+ - Logic block (if, else).
107
+ - Loops (array, map, set).
108
+ - Dependency injection.
87
109
 
88
110
  <hr>
89
111
 
90
112
  ## Road map
91
113
 
92
- * [x] Update the `Vasille Core` library to version 3.0.
93
- * [x] `100%` Test Coverage for core Library v3.
94
- * [x] Develop the `Vasille JSX` library.
95
- * [x] `100%` Test Coverage for the JSX library.
96
- * [x] Develop the `Vasille Babel Plugin`.
97
- * [x] `100%` Test Coverage fot babel plugin.
98
- * [x] Add CSS support (define styles in components).
99
- * [x] Add router.
100
- * [x] Add SSG (static site generation).
101
- * [ ] Add SSR (server side rendering).
102
- * [ ] Develop tools extension for debugging.
114
+ - [x] `100%` Test Coverage for core Library v3.
115
+ - [x] Develop the `JSX` library.
116
+ - [x] `100%` Test Coverage for the JSX library.
117
+ - [x] Develop the `Babel Plugin`.
118
+ - [x] `100%` Test Coverage fot babel plugin.
119
+ - [x] Add CSS support (define styles in components).
120
+ - [x] Add router.
121
+ - [x] Add SSG (static site generation).
122
+ - [ ] Develop tools extension for debugging (WIP).
123
+ - [ ] Add SSR (server side rendering).
103
124
 
104
125
  ## Change log
105
126
 
106
- ### 4.0.0
127
+ We respect semantic versioning:
107
128
 
108
- Initial version of the framework with file based routing and building scripts (`vasille-web dev` and `vasille-web build spa`).
129
+ - A major version is increased when we make incompatible API changes.
130
+ - A minor version is increased when we add functionality.
131
+ - Patch version is increased when we fix bugs.
109
132
 
110
- ## 4.1.0
133
+ ### 7.0
111
134
 
112
- Added SSG (static site generation) as build option `vasille-web build static`.
135
+ - WIP
113
136
 
114
- ## Questions
137
+ ### 6.0 RC (never released)
115
138
 
116
- If you have questions, feel free to contact the maintainer of the project:
139
+ - Add `QueueRenderer`, `ArrayView`, `ArrayModelView`, `SetModelView`, `MapModelView`, `Iterate` and `ForEach` components.
140
+ - `const a = []` is not implicit array model, use explicit `arrayModel`. **[API change]**
117
141
 
118
- * [Author's Email](mailto:vas.lixcode@gmail.com)
119
- * [Author's Telegram](https://t.me/lixcode)
142
+ ### 5.0 - 5.1
120
143
 
121
- <hr>
144
+ - Add support for context and dependencies injection.
145
+ - New developement direction: `fault tolerant`.
146
+ - Renamed to `steel-frame`. **[API change]**
147
+ - Removed `forward` and `backward` functions. **[API change]**
148
+ - Removed `Debug` component. **[API change]**
149
+ - Add support for web components compile target `web build components`.
150
+ _Web components as custom tags are supported in any version._
151
+
152
+ ### 4.0 - 4.3
153
+
154
+ - Initial version of the framework with file based routing and building scripts (`web dev` and `web build spa`).
155
+ - Reactive values naming switched to `$` prefix. **[API change]**
156
+ - `4.1` Added SSG (static site generation) as build option `web build static`.
157
+ - `4.2` Add support for inlined conditions in JSX, binary `&&` and ternary `?:` operator.
158
+ - `4.3` Add new function `safe` which make functions safe, errors are reported automatically.
159
+
160
+ ### 3.0 - 3.2
161
+
162
+ - Switch to a babel plugin to compile components code. **[API change]**
163
+ - 100% of the code has been covered with unit tests.
164
+ - New developement direction: `keep it simple`.
165
+
166
+ ### 2.0 - 2.3
167
+
168
+ - Introduces components compilation via a typescript plugin. **[API change]**
169
+ - New developement direction: `write less, do more`.
170
+
171
+ ### 1.0 - 1.2
172
+
173
+ - Initial version of a core library.
174
+ - Developemnt direction: `performance-first`.
175
+
176
+ ## Questions
177
+
178
+ If you have questions, feel free to contact the maintainer of the project:
122
179
 
123
- **Made in Moldova** 🇲🇩
180
+ - [Author's Email](mailto:vas.lixcode@gmail.com)
package/lib/dev.js ADDED
@@ -0,0 +1,17 @@
1
+ import { CssStyleInjector } from "./index.js";
2
+ export class DevCssStyleInjector extends CssStyleInjector {
3
+ constructor(key, styles) {
4
+ super(styles);
5
+ this.key = key;
6
+ }
7
+ generateClassName() {
8
+ return `${super.generateClassName()}-${this.key}`;
9
+ }
10
+ }
11
+ export function devStyleSheet(styles) {
12
+ const result = {};
13
+ for (const key in styles) {
14
+ result[key] = new DevCssStyleInjector(key, styles[key]);
15
+ }
16
+ return result;
17
+ }
package/lib/index.js CHANGED
@@ -1,73 +1,30 @@
1
- let common;
2
- let mobile;
3
- let tablet;
4
- let desktop;
5
- let dark;
6
- let light;
7
- let mobileMaxWidth = 440;
8
- let tabletMaxWidth = 880;
9
- let laptopMaxWidth = 1320;
10
- let index = Math.floor(Math.random() * 10);
11
- export function setMobileMaxWidth(value) {
12
- mobileMaxWidth = value;
13
- }
14
- export function setTabletMaxWidth(value) {
15
- tabletMaxWidth = value;
16
- }
17
- export function setLaptopMaxWidth(value) {
18
- laptopMaxWidth = value;
19
- }
20
- export function setIndex(value) {
21
- index = value;
22
- }
23
- function createStyleSheet(media) {
24
- const style = document.createElement("style");
25
- style.media = media;
26
- document.head.append(style);
27
- return style.sheet;
28
- }
29
- function insertRule(target, rule) {
30
- let sheet;
31
- switch (target) {
32
- case 1:
33
- /* istanbul ignore else */
34
- if (!mobile) {
35
- mobile = createStyleSheet(`(max-width:${mobileMaxWidth}px)`);
36
- }
37
- sheet = mobile;
38
- break;
39
- case 2:
40
- /* istanbul ignore else */
41
- if (!tablet) {
42
- tablet = createStyleSheet(`(min-width:${mobileMaxWidth}px) and (max-width:${tabletMaxWidth}px)`);
43
- }
44
- sheet = tablet;
45
- break;
46
- case 3:
47
- /* istanbul ignore else */
48
- if (!desktop) {
49
- desktop = createStyleSheet(`(min-width:${tabletMaxWidth}px) and (max-width:${laptopMaxWidth}px)`);
50
- }
51
- sheet = desktop;
52
- break;
53
- case 4:
54
- /* istanbul ignore else */
55
- if (!dark) {
56
- dark = createStyleSheet("(prefers-color-scheme:dark)");
1
+ import { insertRule } from "./lib.js";
2
+ export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "./lib.js";
3
+ let index = 1;
4
+ export class CssStyleInjector {
5
+ constructor(styles) {
6
+ this.className = null;
7
+ this.styles = styles;
8
+ }
9
+ inject() {
10
+ if (this.className) {
11
+ return this.className;
12
+ }
13
+ const className = this.generateClassName();
14
+ for (const item of this.styles) {
15
+ if (item instanceof Array) {
16
+ const [target, rule] = item;
17
+ insertRule(target, rule.replace("{}", className));
57
18
  }
58
- sheet = dark;
59
- break;
60
- case 5:
61
- /* istanbul ignore else */
62
- if (!light) {
63
- light = createStyleSheet("(prefers-color-scheme:light)");
19
+ else {
20
+ insertRule(0, item.replace("{}", className));
64
21
  }
65
- sheet = light;
66
- break;
22
+ }
23
+ this.styles.splice(0);
24
+ return (this.className = className);
67
25
  }
68
- /* istanbul ignore else */
69
- if (sheet) {
70
- sheet.insertRule(rule, sheet.cssRules.length);
26
+ generateClassName() {
27
+ return `vasille-${++index}`;
71
28
  }
72
29
  }
73
30
  /**
@@ -77,28 +34,7 @@ function insertRule(target, rule) {
77
34
  export function styleSheet(styles) {
78
35
  const result = {};
79
36
  for (const key in styles) {
80
- Object.defineProperty(result, key, {
81
- get() {
82
- const className = `vasille-${++index}`;
83
- for (const item of styles[key]) {
84
- if (item instanceof Array) {
85
- const [target, rule] = item;
86
- insertRule(target, rule.replace("{}", className));
87
- }
88
- else {
89
- /* istanbul ignore else */
90
- if (!common) {
91
- common = createStyleSheet("");
92
- }
93
- common.insertRule(item.replace("{}", className), common.cssRules.length);
94
- }
95
- }
96
- styles[key].splice(0);
97
- Object.defineProperty(result, key, { value: className });
98
- return className;
99
- },
100
- configurable: true,
101
- });
37
+ result[key] = new CssStyleInjector(styles[key]);
102
38
  }
103
39
  return result;
104
40
  }
package/lib/lib.js ADDED
@@ -0,0 +1,75 @@
1
+ let common;
2
+ let mobile;
3
+ let tablet;
4
+ let desktop;
5
+ let dark;
6
+ let light;
7
+ let mobileMaxWidth = 440;
8
+ let tabletMaxWidth = 880;
9
+ let laptopMaxWidth = 1320;
10
+ export function setMobileMaxWidth(value) {
11
+ mobileMaxWidth = value;
12
+ }
13
+ export function setTabletMaxWidth(value) {
14
+ tabletMaxWidth = value;
15
+ }
16
+ export function setLaptopMaxWidth(value) {
17
+ laptopMaxWidth = value;
18
+ }
19
+ function createStyleSheet(media) {
20
+ const style = document.createElement("style");
21
+ style.media = media;
22
+ document.head.append(style);
23
+ return style.sheet;
24
+ }
25
+ export function insertRule(target, rule) {
26
+ let sheet;
27
+ switch (target) {
28
+ case 0:
29
+ /* istanbul ignore else */
30
+ if (!common) {
31
+ common = createStyleSheet("");
32
+ }
33
+ sheet = common;
34
+ break;
35
+ case 1:
36
+ /* istanbul ignore else */
37
+ if (!mobile) {
38
+ mobile = createStyleSheet(`(max-width:${mobileMaxWidth}px)`);
39
+ }
40
+ sheet = mobile;
41
+ break;
42
+ case 2:
43
+ /* istanbul ignore else */
44
+ if (!tablet) {
45
+ tablet = createStyleSheet(`(min-width:${mobileMaxWidth}px) and (max-width:${tabletMaxWidth}px)`);
46
+ }
47
+ sheet = tablet;
48
+ break;
49
+ case 3:
50
+ /* istanbul ignore else */
51
+ if (!desktop) {
52
+ desktop = createStyleSheet(`(min-width:${tabletMaxWidth}px) and (max-width:${laptopMaxWidth}px)`);
53
+ }
54
+ sheet = desktop;
55
+ break;
56
+ case 4:
57
+ /* istanbul ignore else */
58
+ if (!dark) {
59
+ dark = createStyleSheet("(prefers-color-scheme:dark)");
60
+ }
61
+ sheet = dark;
62
+ break;
63
+ case 5:
64
+ /* istanbul ignore else */
65
+ if (!light) {
66
+ light = createStyleSheet("(prefers-color-scheme:light)");
67
+ }
68
+ sheet = light;
69
+ break;
70
+ }
71
+ /* istanbul ignore else */
72
+ if (sheet) {
73
+ sheet.insertRule(rule, sheet.cssRules.length);
74
+ }
75
+ }
package/package.json CHANGED
@@ -1,14 +1,22 @@
1
1
  {
2
2
  "name": "vasille-css",
3
- "version": "4.1.0",
4
- "description": "The same framework which is designed to build bulletproof frontends (CSS style library)",
3
+ "version": "7.0.0-rc.1",
4
+ "description": "The same devkit which is designed to build fault tolerant frontends (CSS style library)",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./types/index.d.ts",
7
7
  "exports": {
8
- "types": "./types/index.d.ts",
9
- "import": "./lib/index.js",
10
- "browser": "./lib/index.js",
11
- "node": "./lib/index.js"
8
+ ".": {
9
+ "types": "./types/index.d.ts",
10
+ "import": "./lib/index.js",
11
+ "browser": "./lib/index.js",
12
+ "node": "./lib/index.js"
13
+ },
14
+ "./dev": {
15
+ "types": "./types/dev.d.ts",
16
+ "import": "./lib/dev.js",
17
+ "browser": "./lib/dev.js",
18
+ "node": "./lib/dev.js"
19
+ }
12
20
  },
13
21
  "type": "module",
14
22
  "scripts": {
package/types/dev.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { CssStyleInjector } from "./index.js";
2
+ export declare class DevCssStyleInjector extends CssStyleInjector {
3
+ protected key: string;
4
+ constructor(key: string, styles: (string | [number, string])[]);
5
+ protected generateClassName(): string;
6
+ }
7
+ export declare function devStyleSheet<T extends {
8
+ [k: string]: (string | [number, string])[];
9
+ }>(styles: T): {
10
+ [K in keyof T]: DevCssStyleInjector;
11
+ };
package/types/index.d.ts CHANGED
@@ -1,7 +1,11 @@
1
- export declare function setMobileMaxWidth(value: number): void;
2
- export declare function setTabletMaxWidth(value: number): void;
3
- export declare function setLaptopMaxWidth(value: number): void;
4
- export declare function setIndex(value: number): void;
1
+ export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "./lib.js";
2
+ export declare class CssStyleInjector {
3
+ protected className: string | null;
4
+ protected styles: (string | [number, string])[];
5
+ constructor(styles: (string | [number, string])[]);
6
+ inject(): string;
7
+ protected generateClassName(): string;
8
+ }
5
9
  /**
6
10
  * Inserts stylesheet to document
7
11
  * @param styles CSS styles based on classes
@@ -9,5 +13,5 @@ export declare function setIndex(value: number): void;
9
13
  export declare function styleSheet<T extends {
10
14
  [k: string]: (string | [number, string])[];
11
15
  }>(styles: T): {
12
- [K in keyof T]: string;
16
+ [K in keyof T]: CssStyleInjector;
13
17
  };
package/types/lib.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare function setMobileMaxWidth(value: number): void;
2
+ export declare function setTabletMaxWidth(value: number): void;
3
+ export declare function setLaptopMaxWidth(value: number): void;
4
+ export declare function insertRule(target: number, rule: string): void;