vasille-css 5.0.0 → 7.0.0-rc.2

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
@@ -2,9 +2,11 @@
2
2
 
3
3
  ![Vasille.js logo](https://raw.githubusercontent.com/vasille-js/vasille-js/refs/heads/v5/doc/img/logo.png)
4
4
 
5
- `SteelFrameKit` is a front-end development kit, 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
 
@@ -19,14 +21,15 @@
19
21
  - [How POWERFUL is SteelFrameKit](#how-powerful-is-steelframekit)
20
22
  - [Road map](#road-map)
21
23
  - [Change log](#change-log)
22
- - [5.0.0](#500)
23
- - [4.3.0](#430)
24
- - [4.2.0](#420)
25
- - [4.1.0](#410)
26
- - [4.0.0](#400)
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)
27
31
  - [Questions](#questions)
28
32
 
29
-
30
33
  <hr>
31
34
 
32
35
  ## Installation
@@ -44,37 +47,41 @@ $ npm create steel-frame
44
47
  ```
45
48
 
46
49
  ### Full documentation:
47
- * [Learn `SteelFrameKit` in 5 minutes](https://github.com/vasille-js/vasille-js/blob/v4/doc/V4-API.md)
48
- * [Router Documentation](https://github.com/vasille-js/vasille-js/blob/v4/doc/Router-API.md)
49
- * [Compostion functions](https://github.com/vasille-js/vasille-js/blob/v4/doc/Compositions.md)
50
- * [Dependency injection](https://github.com/vasille-js/vasille-js/blob/v4/doc/Context.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)
51
55
 
52
56
  ### Examples
53
- * [TypeScript Example](https://github.com/vasille-js/example-typescript)
54
- * [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)
55
60
 
56
61
  <hr>
57
62
 
58
63
  ## How SAFE is SteelFrameKit
59
64
 
60
65
  The safe of your application is ensured by
61
- * `100%` coverage of code by unit tests.
66
+
67
+ - `100%` coverage of code by unit tests.
62
68
  Each function, each branch is working as designed.
63
- * OOP, DRY, KISS and SOLID principles are applied.
64
- * `strong typing` makes your javascript/typescript code safe as C++ code.
65
- All entities of `SteelFrameKit` core library are strongly typed, including:
66
- * data fields & properties.
67
- * computed properties (function parameters and result).
68
- * methods.
69
- * events (defined handlers & event emit).
70
- * DOM events & DOM operation (attributing, styling, etc.).
71
- * slots of components.
72
- * references to children.
73
- * No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
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.
74
80
 
75
81
  ## How INTUITIVE is SteelFrameKit
76
82
 
77
83
  There is the "Hello World":
84
+
78
85
  ```typescript jsx
79
86
  import { compose, mount } from "steel-frame";
80
87
 
@@ -88,57 +95,86 @@ mount(document.body, App, {});
88
95
  ## How POWERFUL is SteelFrameKit
89
96
 
90
97
  All of these are supported:
91
- * Components.
92
- * Reactive values (observables).
93
- * Inline computed values.
94
- * Multiline computed values.
95
- * HTML & SVG tags.
96
- * Component custom slots.
97
- * 2-way data binding in components.
98
- * Logic block (if, else).
99
- * Loops (array, map, set).
100
- * Dependency injection.
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.
101
109
 
102
110
  <hr>
103
111
 
104
112
  ## Road map
105
113
 
106
- * [x] Update the `core` library to version 3.0.
107
- * [x] `100%` Test Coverage for core Library v3.
108
- * [x] Develop the `JSX` library.
109
- * [x] `100%` Test Coverage for the JSX library.
110
- * [x] Develop the `Babel Plugin`.
111
- * [x] `100%` Test Coverage fot babel plugin.
112
- * [x] Add CSS support (define styles in components).
113
- * [x] Add router.
114
- * [x] Add SSG (static site generation).
115
- * [ ] Develop tools extension for debugging (WIP).
116
- * [ ] Add SSR (server side rendering).
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).
117
124
 
118
125
  ## Change log
119
126
 
120
- ### 5.0.0
127
+ We respect semantic versioning:
128
+
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.
132
+
133
+ ### 7.0
134
+
135
+ - WIP
136
+
137
+ ### 6.0 RC (never released)
138
+
139
+ - Add `QueueRenderer`, `ArrayView`, `ArrayModelView`, `SetModelView`, `MapModelView`, `Iterate` and `ForEach` components.
140
+ - `const a = []` is not implicit array model, use explicit `arrayModel`. **[API change]**
141
+
142
+ ### 5.0 - 5.1
121
143
 
122
- Add support for context and dependencies injection.
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._
123
151
 
124
- ### 4.3.0
152
+ ### 4.0 - 4.3
125
153
 
126
- Add new function `safe` which make functions safe, errors are reported automatically.
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.
127
159
 
128
- ### 4.2.0
160
+ ### 3.0 - 3.2
129
161
 
130
- Add support for inlined conditions in JSX, binary `&&` and ternary `?:` operator.
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`.
131
165
 
132
- ### 4.1.0
166
+ ### 2.0 - 2.3
133
167
 
134
- Added SSG (static site generation) as build option `sf build static`.
168
+ - Introduces components compilation via a typescript plugin. **[API change]**
169
+ - New developement direction: `write less, do more`.
135
170
 
136
- ### 4.0.0
171
+ ### 1.0 - 1.2
137
172
 
138
- Initial version of the framework with file based routing and building scripts (`sf dev` and `sf build spa`).
173
+ - Initial version of a core library.
174
+ - Developemnt direction: `performance-first`.
139
175
 
140
176
  ## Questions
141
177
 
142
178
  If you have questions, feel free to contact the maintainer of the project:
143
179
 
144
- * [Author's Email](mailto:vas.lixcode@gmail.com)
180
+ - [Author's Email](mailto:vas.lixcode@gmail.com)
package/lib/dev.js CHANGED
@@ -1,26 +1,10 @@
1
- import { insertRule } from "./lib.js";
2
- let index = 0;
3
- export function devStyleSheet(styles) {
4
- const result = {};
5
- for (const key in styles) {
6
- Object.defineProperty(result, key, {
7
- get() {
8
- const className = `vasille-${++index}-${key}`;
9
- for (const item of styles[key]) {
10
- if (item instanceof Array) {
11
- const [target, rule] = item;
12
- insertRule(target, rule.replace("{}", className));
13
- }
14
- else {
15
- insertRule(0, item.replace("{}", className));
16
- }
17
- }
18
- styles[key].splice(0);
19
- Object.defineProperty(result, key, { value: className });
20
- return className;
21
- },
22
- configurable: true,
23
- });
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}`;
24
9
  }
25
- return result;
26
10
  }
package/lib/index.js CHANGED
@@ -1,6 +1,45 @@
1
1
  import { insertRule } from "./lib.js";
2
2
  export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "./lib.js";
3
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
+ this.insertRule(item, className);
16
+ }
17
+ this.styles.splice(0);
18
+ return (this.className = className);
19
+ }
20
+ generateClassName() {
21
+ return `vasille-${++index}`;
22
+ }
23
+ insertRule(rule, className) {
24
+ if (rule instanceof Array) {
25
+ insertRule(rule[0], rule[1].replace("{}", className));
26
+ }
27
+ else {
28
+ insertRule(0, rule.replace("{}", className));
29
+ }
30
+ }
31
+ }
32
+ export class SafeCssStyleInjector extends CssStyleInjector {
33
+ insertRule(rule, className) {
34
+ try {
35
+ super.insertRule(rule, className);
36
+ }
37
+ catch (e) {
38
+ // ignore any style related errors
39
+ void e;
40
+ }
41
+ }
42
+ }
4
43
  /**
5
44
  * Inserts stylesheet to document
6
45
  * @param styles CSS styles based on classes
@@ -8,24 +47,7 @@ let index = 1;
8
47
  export function styleSheet(styles) {
9
48
  const result = {};
10
49
  for (const key in styles) {
11
- Object.defineProperty(result, key, {
12
- get() {
13
- const className = `vasille-${++index}`;
14
- for (const item of styles[key]) {
15
- if (item instanceof Array) {
16
- const [target, rule] = item;
17
- insertRule(target, rule.replace("{}", className));
18
- }
19
- else {
20
- insertRule(0, item.replace("{}", className));
21
- }
22
- }
23
- styles[key].splice(0);
24
- Object.defineProperty(result, key, { value: className });
25
- return className;
26
- },
27
- configurable: true,
28
- });
50
+ result[key] = new SafeCssStyleInjector(styles[key]);
29
51
  }
30
52
  return result;
31
53
  }
package/lib/lib.js CHANGED
@@ -22,7 +22,7 @@ function createStyleSheet(media) {
22
22
  document.head.append(style);
23
23
  return style.sheet;
24
24
  }
25
- export function insertRule(target, rule) {
25
+ export function getStyleSheet(target) {
26
26
  let sheet;
27
27
  switch (target) {
28
28
  case 0:
@@ -68,6 +68,10 @@ export function insertRule(target, rule) {
68
68
  sheet = light;
69
69
  break;
70
70
  }
71
+ return sheet;
72
+ }
73
+ export function insertRule(target, rule) {
74
+ const sheet = getStyleSheet(target);
71
75
  /* istanbul ignore else */
72
76
  if (sheet) {
73
77
  sheet.insertRule(rule, sheet.cssRules.length);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vasille-css",
3
- "version": "5.0.0",
4
- "description": "The same framework which is designed to build bulletproof frontends (CSS style library)",
3
+ "version": "7.0.0-rc.2",
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": {
package/types/dev.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export declare function devStyleSheet<T extends {
2
- [k: string]: (string | [number, string])[];
3
- }>(styles: T): {
4
- [K in keyof T]: string;
5
- };
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
+ }
package/types/index.d.ts CHANGED
@@ -1,4 +1,15 @@
1
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
+ protected insertRule(rule: string | [number, string], className: string): void;
9
+ }
10
+ export declare class SafeCssStyleInjector extends CssStyleInjector {
11
+ protected insertRule(rule: string | [number, string], className: string): void;
12
+ }
2
13
  /**
3
14
  * Inserts stylesheet to document
4
15
  * @param styles CSS styles based on classes
@@ -6,5 +17,5 @@ export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "./lib.j
6
17
  export declare function styleSheet<T extends {
7
18
  [k: string]: (string | [number, string])[];
8
19
  }>(styles: T): {
9
- [K in keyof T]: string;
20
+ [K in keyof T]: CssStyleInjector;
10
21
  };
package/types/lib.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare function setMobileMaxWidth(value: number): void;
2
2
  export declare function setTabletMaxWidth(value: number): void;
3
3
  export declare function setLaptopMaxWidth(value: number): void;
4
+ export declare function getStyleSheet(target: number): CSSStyleSheet | undefined;
4
5
  export declare function insertRule(target: number, rule: string): void;