@rettangoli/fe 1.0.3 → 1.0.4
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 +1 -2
- package/package.json +4 -4
- package/src/cli/examples.js +1 -3
- package/src/common.js +1 -64
- package/src/parser.js +1 -1
- package/src/utils/flattenArrays.js +23 -0
package/README.md
CHANGED
|
@@ -35,7 +35,6 @@ rtgl fe watch # Start dev server
|
|
|
35
35
|
- [Snabbdom](https://github.com/snabbdom/snabbdom) - Virtual DOM
|
|
36
36
|
- [Immer](https://github.com/immerjs/immer) - Immutable state management
|
|
37
37
|
- [Jempl](https://github.com/yuusoft-org/jempl) - Template engine
|
|
38
|
-
- [RxJS](https://github.com/ReactiveX/rxjs) - Reactive programming
|
|
39
38
|
|
|
40
39
|
**Build & Development:**
|
|
41
40
|
- [Vite](https://vite.dev/) - Dev server and production bundling
|
|
@@ -196,7 +195,7 @@ Use this workflow:
|
|
|
196
195
|
Docker image:
|
|
197
196
|
|
|
198
197
|
```bash
|
|
199
|
-
IMAGE="han4wluc/rtgl:playwright-v1.57.0-rtgl-v1.0.
|
|
198
|
+
IMAGE="han4wluc/rtgl:playwright-v1.57.0-rtgl-v1.0.10"
|
|
200
199
|
```
|
|
201
200
|
|
|
202
201
|
Dashboard suite:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rettangoli/fe",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Frontend framework for building reactive web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
],
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "
|
|
21
|
+
"url": "https://github.com/yuusoft-org/rettangoli",
|
|
22
|
+
"directory": "packages/rettangoli-fe"
|
|
22
23
|
},
|
|
23
24
|
"license": "MIT",
|
|
24
25
|
"exports": {
|
|
@@ -32,9 +33,8 @@
|
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"immer": "^10.1.1",
|
|
35
|
-
"jempl": "0.
|
|
36
|
+
"jempl": "1.0.1",
|
|
36
37
|
"js-yaml": "^4.1.0",
|
|
37
|
-
"rxjs": "^7.8.2",
|
|
38
38
|
"snabbdom": "^3.6.2",
|
|
39
39
|
"vite": "^6.3.5"
|
|
40
40
|
},
|
package/src/cli/examples.js
CHANGED
|
@@ -3,9 +3,7 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
3
3
|
import { load as loadYaml, loadAll } from "js-yaml";
|
|
4
4
|
import { render, parse } from "jempl";
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
flattenArrays,
|
|
8
|
-
} from "../common.js";
|
|
6
|
+
import { flattenArrays } from "../utils/flattenArrays.js";
|
|
9
7
|
import { extractCategoryAndComponent } from "../commonBuild.js";
|
|
10
8
|
import { getAllFiles } from "../commonBuild.js";
|
|
11
9
|
import path, { dirname } from "node:path";
|
package/src/common.js
CHANGED
|
@@ -1,36 +1,3 @@
|
|
|
1
|
-
import { Subject } from "rxjs";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A custom subject that can be used to dispatch actions and subscribe to them
|
|
5
|
-
* You can think of this as a bus for all frontend events and communication
|
|
6
|
-
*
|
|
7
|
-
* Example:
|
|
8
|
-
* const subject = new CustomSubject();
|
|
9
|
-
*
|
|
10
|
-
* const subscription = subject.subscribe(({ action, payload }) => {
|
|
11
|
-
* // handle action and payload
|
|
12
|
-
* });
|
|
13
|
-
*
|
|
14
|
-
* subject.dispatch("action", { payload: "payload" });
|
|
15
|
-
*
|
|
16
|
-
* subscription.unsubscribe();
|
|
17
|
-
*/
|
|
18
|
-
export class CustomSubject {
|
|
19
|
-
_subject = new Subject();
|
|
20
|
-
pipe = (...args) => {
|
|
21
|
-
return this._subject.pipe(...args);
|
|
22
|
-
};
|
|
23
|
-
dispatch = (action, payload) => {
|
|
24
|
-
this._subject.next({
|
|
25
|
-
action,
|
|
26
|
-
payload: payload || {},
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
dispatchCall = (action, payload) => {
|
|
30
|
-
return () => this.dispatch(action, payload || {});
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
1
|
const getQueryParamsObject = () => {
|
|
35
2
|
const queryParams = new URLSearchParams(window.location.search + "");
|
|
36
3
|
const paramsObject = {};
|
|
@@ -164,34 +131,4 @@ export function createHttpClient(config) {
|
|
|
164
131
|
return httpClient;
|
|
165
132
|
}
|
|
166
133
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
// Helper function to flatten arrays while preserving object structure
|
|
173
|
-
export const flattenArrays = (items) => {
|
|
174
|
-
if (!Array.isArray(items)) {
|
|
175
|
-
return items;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return items.reduce((acc, item) => {
|
|
179
|
-
if (Array.isArray(item)) {
|
|
180
|
-
// Recursively flatten nested arrays
|
|
181
|
-
acc.push(...flattenArrays(item));
|
|
182
|
-
} else {
|
|
183
|
-
// If it's an object with nested arrays, process those too
|
|
184
|
-
if (item && typeof item === "object") {
|
|
185
|
-
const entries = Object.entries(item);
|
|
186
|
-
if (entries.length > 0) {
|
|
187
|
-
const [key, value] = entries[0];
|
|
188
|
-
if (Array.isArray(value)) {
|
|
189
|
-
item = { [key]: flattenArrays(value) };
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
acc.push(item);
|
|
194
|
-
}
|
|
195
|
-
return acc;
|
|
196
|
-
}, []);
|
|
197
|
-
};
|
|
134
|
+
export { flattenArrays } from "./utils/flattenArrays.js";
|
package/src/parser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseAndRender as jemplParseAndRender, render as jemplRender } from "jempl";
|
|
2
2
|
|
|
3
|
-
import { flattenArrays } from
|
|
3
|
+
import { flattenArrays } from "./utils/flattenArrays.js";
|
|
4
4
|
import { parseNodeBindings } from './core/view/bindings.js';
|
|
5
5
|
import {
|
|
6
6
|
createRefMatchers,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const flattenArrays = (items) => {
|
|
2
|
+
if (!Array.isArray(items)) {
|
|
3
|
+
return items;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return items.reduce((acc, item) => {
|
|
7
|
+
if (Array.isArray(item)) {
|
|
8
|
+
acc.push(...flattenArrays(item));
|
|
9
|
+
} else {
|
|
10
|
+
if (item && typeof item === "object") {
|
|
11
|
+
const entries = Object.entries(item);
|
|
12
|
+
if (entries.length > 0) {
|
|
13
|
+
const [key, value] = entries[0];
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
item = { [key]: flattenArrays(value) };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
acc.push(item);
|
|
20
|
+
}
|
|
21
|
+
return acc;
|
|
22
|
+
}, []);
|
|
23
|
+
};
|