vasille-css 4.0.0 → 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 CHANGED
@@ -1,19 +1,30 @@
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 bulletproof frontends.
6
6
 
7
7
  [![npm](https://img.shields.io/npm/v/vasille?style=flat-square)](https://www.npmjs.com/package/vasille)
8
8
 
9
9
  ## Table of content
10
10
 
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)
11
+ - [Steel Frame](#steel-frame)
12
+ - [Table of content](#table-of-content)
13
+ - [Installation](#installation)
14
+ - [How to use SteelFramekit](#how-to-use-steelframekit)
15
+ - [Full documentation:](#full-documentation)
16
+ - [Examples](#examples)
17
+ - [How SAFE is SteelFrameKit](#how-safe-is-steelframekit)
18
+ - [How INTUITIVE is SteelFrameKit](#how-intuitive-is-steelframekit)
19
+ - [How POWERFUL is SteelFrameKit](#how-powerful-is-steelframekit)
20
+ - [Road map](#road-map)
21
+ - [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)
27
+ - [Questions](#questions)
17
28
 
18
29
 
19
30
  <hr>
@@ -21,20 +32,22 @@
21
32
  ## Installation
22
33
 
23
34
  ```
24
- npm install vasille-web --save
35
+ npm install steel-frame --save
25
36
  ```
26
37
 
27
- ## How to use Vasille
38
+ ## How to use SteelFramekit
28
39
 
29
40
  Create an app from a template
30
41
 
31
42
  ```bash
32
- $ npm create vasille
43
+ $ npm create steel-frame
33
44
  ```
34
45
 
35
46
  ### 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)
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)
38
51
 
39
52
  ### Examples
40
53
  * [TypeScript Example](https://github.com/vasille-js/example-typescript)
@@ -42,14 +55,14 @@ $ npm create vasille
42
55
 
43
56
  <hr>
44
57
 
45
- ## How SAFE is Vasille
58
+ ## How SAFE is SteelFrameKit
46
59
 
47
60
  The safe of your application is ensured by
48
61
  * `100%` coverage of code by unit tests.
49
62
  Each function, each branch is working as designed.
50
63
  * OOP, DRY, KISS and SOLID principles are applied.
51
64
  * `strong typing` makes your javascript/typescript code safe as C++ code.
52
- All entities of `vasille` core library are strongly typed, including:
65
+ All entities of `SteelFrameKit` core library are strongly typed, including:
53
66
  * data fields & properties.
54
67
  * computed properties (function parameters and result).
55
68
  * methods.
@@ -59,11 +72,11 @@ All entities of `vasille` core library are strongly typed, including:
59
72
  * references to children.
60
73
  * No asynchronous code, when the line of code is executed, the DOM and reactive things are already synced.
61
74
 
62
- ## How INTUITIVE is Vasille
75
+ ## How INTUITIVE is SteelFrameKit
63
76
 
64
77
  There is the "Hello World":
65
78
  ```typescript jsx
66
- import { compose, mount } from "vasille-dx";
79
+ import { compose, mount } from "steel-frame";
67
80
 
68
81
  const App = compose(() => {
69
82
  <p>Hello world</p>;
@@ -72,7 +85,7 @@ const App = compose(() => {
72
85
  mount(document.body, App, {});
73
86
  ```
74
87
 
75
- ## How POWERFUL is Vasille
88
+ ## How POWERFUL is SteelFrameKit
76
89
 
77
90
  All of these are supported:
78
91
  * Components.
@@ -84,30 +97,48 @@ All of these are supported:
84
97
  * 2-way data binding in components.
85
98
  * Logic block (if, else).
86
99
  * Loops (array, map, set).
100
+ * Dependency injection.
87
101
 
88
102
  <hr>
89
103
 
90
104
  ## Road map
91
105
 
92
- * [x] Update the `Vasille Core` library to version 3.0.
106
+ * [x] Update the `core` library to version 3.0.
93
107
  * [x] `100%` Test Coverage for core Library v3.
94
- * [x] Develop the `Vasille JSX` library.
108
+ * [x] Develop the `JSX` library.
95
109
  * [x] `100%` Test Coverage for the JSX library.
96
- * [x] Develop the `Vasille Babel Plugin`.
110
+ * [x] Develop the `Babel Plugin`.
97
111
  * [x] `100%` Test Coverage fot babel plugin.
98
112
  * [x] Add CSS support (define styles in components).
99
113
  * [x] Add router.
100
- * [ ] Add SSG (static site generation).
114
+ * [x] Add SSG (static site generation).
115
+ * [ ] Develop tools extension for debugging (WIP).
101
116
  * [ ] Add SSR (server side rendering).
102
- * [ ] Develop tools extension for debugging.
117
+
118
+ ## Change log
119
+
120
+ ### 5.0.0
121
+
122
+ Add support for context and dependencies injection.
123
+
124
+ ### 4.3.0
125
+
126
+ Add new function `safe` which make functions safe, errors are reported automatically.
127
+
128
+ ### 4.2.0
129
+
130
+ Add support for inlined conditions in JSX, binary `&&` and ternary `?:` operator.
131
+
132
+ ### 4.1.0
133
+
134
+ Added SSG (static site generation) as build option `sf build static`.
135
+
136
+ ### 4.0.0
137
+
138
+ Initial version of the framework with file based routing and building scripts (`sf dev` and `sf build spa`).
103
139
 
104
140
  ## Questions
105
141
 
106
142
  If you have questions, feel free to contact the maintainer of the project:
107
143
 
108
144
  * [Author's Email](mailto:vas.lixcode@gmail.com)
109
- * [Author's Telegram](https://t.me/lixcode)
110
-
111
- <hr>
112
-
113
- **Made in Moldova** 🇲🇩
package/lib/dev.js ADDED
@@ -0,0 +1,26 @@
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
+ });
24
+ }
25
+ return result;
26
+ }
package/lib/index.js CHANGED
@@ -1,75 +1,6 @@
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)");
57
- }
58
- sheet = dark;
59
- break;
60
- case 5:
61
- /* istanbul ignore else */
62
- if (!light) {
63
- light = createStyleSheet("(prefers-color-scheme:light)");
64
- }
65
- sheet = light;
66
- break;
67
- }
68
- /* istanbul ignore else */
69
- if (sheet) {
70
- sheet.insertRule(rule, sheet.cssRules.length);
71
- }
72
- }
1
+ import { insertRule } from "./lib.js";
2
+ export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "./lib.js";
3
+ let index = 1;
73
4
  /**
74
5
  * Inserts stylesheet to document
75
6
  * @param styles CSS styles based on classes
@@ -79,18 +10,14 @@ export function styleSheet(styles) {
79
10
  for (const key in styles) {
80
11
  Object.defineProperty(result, key, {
81
12
  get() {
82
- const className = `v-${++index}`;
13
+ const className = `vasille-${++index}`;
83
14
  for (const item of styles[key]) {
84
15
  if (item instanceof Array) {
85
16
  const [target, rule] = item;
86
17
  insertRule(target, rule.replace("{}", className));
87
18
  }
88
19
  else {
89
- /* istanbul ignore else */
90
- if (!common) {
91
- common = createStyleSheet("");
92
- }
93
- common.insertRule(item.replace("{}", className), common.cssRules.length);
20
+ insertRule(0, item.replace("{}", className));
94
21
  }
95
22
  }
96
23
  styles[key].splice(0);
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.0.0",
4
- "description": "The framework designed to build bulletproof frontends (CSS style library)",
3
+ "version": "5.0.0",
4
+ "description": "The same framework which is designed to build bulletproof 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,5 @@
1
+ export declare function devStyleSheet<T extends {
2
+ [k: string]: (string | [number, string])[];
3
+ }>(styles: T): {
4
+ [K in keyof T]: string;
5
+ };
package/types/index.d.ts CHANGED
@@ -1,7 +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 setIndex(value: number): void;
1
+ export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "./lib.js";
5
2
  /**
6
3
  * Inserts stylesheet to document
7
4
  * @param styles CSS styles based on classes
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;
package/eslint.config.js DELETED
@@ -1,25 +0,0 @@
1
- import compat from "eslint-plugin-compat";
2
- import tseslint from "typescript-eslint";
3
- import { globalIgnores } from "eslint/config";
4
-
5
- export default tseslint.config(
6
- tseslint.configs.base,
7
- {
8
- name: "compat check",
9
- files: ["src/**/*.ts", "src/**/*.tsx"],
10
- plugins: { compat },
11
- rules: {
12
- "compat/compat": "error",
13
- },
14
- settings: {
15
- polyfills: [],
16
- },
17
- languageOptions: {
18
- parserOptions: {
19
- projectService: false,
20
- tsconfigRootDir: import.meta.dirname,
21
- },
22
- },
23
- },
24
- globalIgnores(["node_modules", "lib/**/*", "types", "coverage/**/*"]),
25
- );