valyrian.js 6.0.13 → 6.0.14
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/dist/hooks/index.d.ts +1 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +21 -7
- package/dist/hooks/index.mjs +21 -7
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +18 -22
- package/dist/node/index.mjs +18 -22
- package/dist/node/utils/icons.d.ts +1 -1
- package/dist/node/utils/icons.d.ts.map +1 -1
- package/dist/request/index.d.ts +2 -2
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js +1 -2
- package/dist/request/index.min.js +1 -1
- package/dist/request/index.min.js.map +1 -1
- package/dist/request/index.mjs +1 -2
- package/dist/router/index.d.ts +2 -2
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +1 -2
- package/dist/router/index.min.js +1 -1
- package/dist/router/index.min.js.map +1 -1
- package/dist/router/index.mjs +1 -2
- package/dist/signal/index.d.ts.map +1 -1
- package/dist/signal/index.js +10 -0
- package/dist/signal/index.min.js +1 -1
- package/dist/signal/index.min.js.map +1 -1
- package/dist/signal/index.mjs +10 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +7 -3
- package/dist/store/index.min.js +1 -1
- package/dist/store/index.min.js.map +1 -1
- package/dist/store/index.mjs +7 -3
- package/dist/sw/index.d.ts +1 -2
- package/dist/sw/index.d.ts.map +1 -1
- package/dist/sw/index.js +1 -2
- package/dist/sw/index.mjs +1 -2
- package/lib/hooks/index.ts +22 -9
- package/lib/index.ts +1 -3
- package/lib/node/index.ts +1 -1
- package/lib/node/utils/icons.ts +17 -22
- package/lib/request/index.ts +1 -3
- package/lib/router/index.ts +1 -3
- package/lib/signal/index.ts +13 -0
- package/lib/store/index.ts +8 -4
- package/lib/sw/index.ts +1 -3
- package/package.json +16 -16
package/lib/hooks/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Component, Valyrian, ValyrianComponent, VnodeWithDom } from "Valyrian";
|
|
2
2
|
|
|
3
3
|
type LocalValyrian =
|
|
4
|
-
| Valyrian
|
|
5
4
|
| Valyrian
|
|
6
5
|
| {
|
|
7
6
|
current: Valyrian["current"];
|
|
@@ -9,6 +8,7 @@ type LocalValyrian =
|
|
|
9
8
|
onCleanup: Valyrian["onCleanup"];
|
|
10
9
|
onMount: Valyrian["onMount"];
|
|
11
10
|
onUpdate: Valyrian["onUpdate"];
|
|
11
|
+
update: Valyrian["update"];
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
let localValyrian: LocalValyrian = {
|
|
@@ -17,10 +17,11 @@ let localValyrian: LocalValyrian = {
|
|
|
17
17
|
vnode: null,
|
|
18
18
|
oldVnode: null
|
|
19
19
|
},
|
|
20
|
-
onUnmount
|
|
21
|
-
onCleanup
|
|
22
|
-
onMount
|
|
23
|
-
onUpdate
|
|
20
|
+
onUnmount() {},
|
|
21
|
+
onCleanup() {},
|
|
22
|
+
onMount() {},
|
|
23
|
+
onUpdate() {},
|
|
24
|
+
update() {}
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
interface CurrentOnPatch {
|
|
@@ -126,6 +127,12 @@ export const createHook = function createHook({ onCreate, onUpdate, onCleanup, o
|
|
|
126
127
|
};
|
|
127
128
|
} as unknown as CreateHook;
|
|
128
129
|
|
|
130
|
+
let updateTimeout: any;
|
|
131
|
+
function delayedUpdate() {
|
|
132
|
+
clearTimeout(updateTimeout);
|
|
133
|
+
updateTimeout = setTimeout(localValyrian.update);
|
|
134
|
+
}
|
|
135
|
+
|
|
129
136
|
// Use state hook
|
|
130
137
|
export const useState = createHook({
|
|
131
138
|
onCreate: (value) => {
|
|
@@ -133,7 +140,15 @@ export const useState = createHook({
|
|
|
133
140
|
stateObj.value = value;
|
|
134
141
|
stateObj.toJSON = stateObj.toString = stateObj.valueOf = () => (typeof stateObj.value === "function" ? stateObj.value() : stateObj.value);
|
|
135
142
|
|
|
136
|
-
return [
|
|
143
|
+
return [
|
|
144
|
+
stateObj,
|
|
145
|
+
(value: any) => {
|
|
146
|
+
if (stateObj.value !== value) {
|
|
147
|
+
stateObj.value = value;
|
|
148
|
+
delayedUpdate();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
];
|
|
137
152
|
}
|
|
138
153
|
});
|
|
139
154
|
|
|
@@ -235,8 +250,6 @@ export const useMemo = createHook({
|
|
|
235
250
|
}
|
|
236
251
|
});
|
|
237
252
|
|
|
238
|
-
function plugin(v: Valyrian) {
|
|
253
|
+
export function plugin(v: Valyrian) {
|
|
239
254
|
localValyrian = v;
|
|
240
255
|
}
|
|
241
|
-
|
|
242
|
-
export default plugin;
|
package/lib/index.ts
CHANGED
|
@@ -116,7 +116,7 @@ function domToVnode(dom: any): VnodeWithDom {
|
|
|
116
116
|
return vnode as VnodeWithDom;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
const v: Valyrian = (tagOrComponent, props, ...children) => {
|
|
119
|
+
export const v: Valyrian = (tagOrComponent, props, ...children) => {
|
|
120
120
|
if (typeof tagOrComponent === "string") {
|
|
121
121
|
return new Vnode(tagOrComponent, props || {}, children);
|
|
122
122
|
}
|
|
@@ -644,5 +644,3 @@ v.reservedProps = reservedProps;
|
|
|
644
644
|
v.current = current;
|
|
645
645
|
|
|
646
646
|
v.setAttribute = setAttribute;
|
|
647
|
-
|
|
648
|
-
export default v;
|
package/lib/node/index.ts
CHANGED
|
@@ -27,4 +27,4 @@ function render(...args: any[]) {
|
|
|
27
27
|
return result;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export { domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript, inline, sw, icons, render, plugin
|
|
30
|
+
export { domToHtml, domToHyperscript, htmlToDom, htmlToHyperscript, inline, sw, icons, render, plugin };
|
package/lib/node/utils/icons.ts
CHANGED
|
@@ -48,28 +48,21 @@ export async function icons(source: string, configuration?: IconsOptions) {
|
|
|
48
48
|
|
|
49
49
|
const { favicons } = await import("favicons");
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
favicons(source, options
|
|
53
|
-
if (err) {
|
|
54
|
-
process.stdout.write(err.status + "\n"); // HTTP error code (e.g. `200`) or `null`
|
|
55
|
-
process.stdout.write(err.name + "\n"); // Error name e.g. "API Error"
|
|
56
|
-
process.stdout.write(err.message + "\n"); // Error description e.g. "An unknown error has occurred"
|
|
51
|
+
try {
|
|
52
|
+
let response = await favicons(source, options);
|
|
57
53
|
|
|
58
|
-
|
|
54
|
+
if (options.iconsPath) {
|
|
55
|
+
for (let i in response.images) {
|
|
56
|
+
fs.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
fs.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
for (let i in response.files) {
|
|
67
|
-
fs.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);
|
|
68
|
-
}
|
|
59
|
+
for (let i in response.files) {
|
|
60
|
+
fs.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);
|
|
69
61
|
}
|
|
62
|
+
}
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
if (options.linksViewPath) {
|
|
65
|
+
let html = `
|
|
73
66
|
function Links(){
|
|
74
67
|
return ${htmlToHyperscript(response.html.join(""))};
|
|
75
68
|
}
|
|
@@ -78,11 +71,13 @@ export async function icons(source: string, configuration?: IconsOptions) {
|
|
|
78
71
|
module.exports = Links;
|
|
79
72
|
`;
|
|
80
73
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
fs.writeFileSync(`${options.linksViewPath}/links.js`, html);
|
|
75
|
+
}
|
|
76
|
+
} catch (err) {
|
|
77
|
+
process.stdout.write((err as any).status + "\n"); // HTTP error code (e.g. `200`) or `null`
|
|
78
|
+
process.stdout.write((err as any).name + "\n"); // Error name e.g. "API Error"
|
|
79
|
+
process.stdout.write((err as any).message + "\n"); // Error description e.g. "An unknown error has occurred"
|
|
80
|
+
}
|
|
86
81
|
}
|
|
87
82
|
|
|
88
83
|
icons.options = {
|
package/lib/request/index.ts
CHANGED
|
@@ -269,10 +269,8 @@ function Requester(baseUrl = "", options: RequestOptions = { allowedMethods: ["g
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
export const request = Requester();
|
|
272
|
-
const plugin = (v: Valyrian): RequestInterface => {
|
|
272
|
+
export const plugin = (v: Valyrian): RequestInterface => {
|
|
273
273
|
localValyrian = v;
|
|
274
274
|
v.request = request;
|
|
275
275
|
return request;
|
|
276
276
|
};
|
|
277
|
-
|
|
278
|
-
export default plugin;
|
package/lib/router/index.ts
CHANGED
|
@@ -280,7 +280,7 @@ declare module "Valyrian" {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
function plugin(v: Valyrian) {
|
|
283
|
+
export function plugin(v: Valyrian) {
|
|
284
284
|
localValyrian = v;
|
|
285
285
|
localValyrian.mountRouter = (elementContainer, routerOrComponent) => {
|
|
286
286
|
if (routerOrComponent instanceof Router) {
|
|
@@ -304,5 +304,3 @@ function plugin(v: Valyrian) {
|
|
|
304
304
|
};
|
|
305
305
|
return Router;
|
|
306
306
|
}
|
|
307
|
-
|
|
308
|
-
export default plugin;
|
package/lib/signal/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Valyrian } from "Valyrian";
|
|
2
|
+
|
|
1
3
|
/* eslint-disable no-use-before-define */
|
|
2
4
|
interface Cleanup {
|
|
3
5
|
(): void;
|
|
@@ -67,6 +69,16 @@ function createSubscription(signal: Signal, subscriptions: Subscriptions, handle
|
|
|
67
69
|
return subscriptions.get(handler);
|
|
68
70
|
}
|
|
69
71
|
|
|
72
|
+
let localValyrian: Valyrian = {
|
|
73
|
+
update: () => {}
|
|
74
|
+
} as unknown as Valyrian;
|
|
75
|
+
|
|
76
|
+
let updateTimeout: any;
|
|
77
|
+
function delayedUpdate() {
|
|
78
|
+
clearTimeout(updateTimeout);
|
|
79
|
+
updateTimeout = setTimeout(localValyrian.update);
|
|
80
|
+
}
|
|
81
|
+
|
|
70
82
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
71
83
|
export function Signal(value: any): Signal {
|
|
72
84
|
let subscriptions = new Map();
|
|
@@ -124,6 +136,7 @@ export function Signal(value: any): Signal {
|
|
|
124
136
|
let cleanup = handler(val);
|
|
125
137
|
makeUnsubscribe(subscriptions, computed, handler, cleanup);
|
|
126
138
|
}
|
|
139
|
+
delayedUpdate();
|
|
127
140
|
}
|
|
128
141
|
return true;
|
|
129
142
|
}
|
package/lib/store/index.ts
CHANGED
|
@@ -57,6 +57,12 @@ function deepFreeze(obj: any) {
|
|
|
57
57
|
return obj;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
let updateTimeout: any;
|
|
61
|
+
function delayedUpdate() {
|
|
62
|
+
clearTimeout(updateTimeout);
|
|
63
|
+
updateTimeout = setTimeout(localValyrian.update);
|
|
64
|
+
}
|
|
65
|
+
|
|
60
66
|
export const Store = function Store(this: StoreInstance, { state = {}, getters = {}, actions = {}, mutations = {} }: StoreOptions = {}) {
|
|
61
67
|
let frozen = true;
|
|
62
68
|
|
|
@@ -97,7 +103,7 @@ export const Store = function Store(this: StoreInstance, { state = {}, getters =
|
|
|
97
103
|
frozen = false;
|
|
98
104
|
mutations[mutation](this.state, ...args);
|
|
99
105
|
frozen = true;
|
|
100
|
-
|
|
106
|
+
delayedUpdate();
|
|
101
107
|
};
|
|
102
108
|
|
|
103
109
|
this.dispatch = (action, ...args) => {
|
|
@@ -106,7 +112,7 @@ export const Store = function Store(this: StoreInstance, { state = {}, getters =
|
|
|
106
112
|
};
|
|
107
113
|
} as unknown as StoreInstance;
|
|
108
114
|
|
|
109
|
-
function plugin(v: Valyrian, optionsOrStore?: StoreOptions | StoreInstance) {
|
|
115
|
+
export function plugin(v: Valyrian, optionsOrStore?: StoreOptions | StoreInstance) {
|
|
110
116
|
localValyrian = v;
|
|
111
117
|
if (optionsOrStore) {
|
|
112
118
|
v.store = optionsOrStore instanceof Store ? optionsOrStore : new Store(optionsOrStore);
|
|
@@ -117,5 +123,3 @@ function plugin(v: Valyrian, optionsOrStore?: StoreOptions | StoreInstance) {
|
|
|
117
123
|
}
|
|
118
124
|
return Store;
|
|
119
125
|
}
|
|
120
|
-
|
|
121
|
-
export default plugin;
|
package/lib/sw/index.ts
CHANGED
|
@@ -20,10 +20,8 @@ export async function registerSw(file = "./sw.js", options: RegistrationOptions
|
|
|
20
20
|
return navigator.serviceWorker;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const plugin = (v: Valyrian) => {
|
|
23
|
+
export const plugin = (v: Valyrian) => {
|
|
24
24
|
localValyrian = v;
|
|
25
25
|
v.registerSw = registerSw;
|
|
26
26
|
return registerSw;
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
export default plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valyrian.js",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.14",
|
|
4
4
|
"description": "Lightweight steel to forge PWAs. (Minimal Frontend Framework with server side rendering and other capabilities)",
|
|
5
5
|
"repository": "git@github.com:Masquerade-Circus/valyrian.js.git",
|
|
6
6
|
"author": "Masquerade <christian@masquerade-circus.net>",
|
|
@@ -69,40 +69,40 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"clean-css": "^5.2.4",
|
|
72
|
-
"esbuild": "^0.
|
|
73
|
-
"favicons": "^7.0.0
|
|
72
|
+
"esbuild": "^0.15.7",
|
|
73
|
+
"favicons": "^7.0.0",
|
|
74
74
|
"form-data": "^4.0.0",
|
|
75
75
|
"purgecss": "4.1.3",
|
|
76
|
-
"terser": "^5.
|
|
76
|
+
"terser": "^5.15.0",
|
|
77
77
|
"ts-node": "^10.9.1",
|
|
78
78
|
"tsc-prog": "^2.2.1",
|
|
79
79
|
"tslib": "^2.4.0",
|
|
80
|
-
"typescript": "^4.
|
|
80
|
+
"typescript": "^4.8.3"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@release-it/conventional-changelog": "^5.
|
|
83
|
+
"@release-it/conventional-changelog": "^5.1.0",
|
|
84
84
|
"@types/clean-css": "^4.2.5",
|
|
85
|
-
"@types/node": "^18.
|
|
85
|
+
"@types/node": "^18.7.16",
|
|
86
86
|
"@types/node-fetch": "^2.6.2",
|
|
87
|
-
"@types/sharp": "^0.30.
|
|
87
|
+
"@types/sharp": "^0.30.5",
|
|
88
88
|
"@types/source-map": "^0.5.7",
|
|
89
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
90
|
-
"@typescript-eslint/parser": "^5.
|
|
89
|
+
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
|
90
|
+
"@typescript-eslint/parser": "^5.36.2",
|
|
91
91
|
"buffalo-test": "^2.0.0",
|
|
92
92
|
"compression": "^1.7.4",
|
|
93
93
|
"cross-env": "^7.0.3",
|
|
94
94
|
"cz-conventional-changelog": "^3.3.0",
|
|
95
|
-
"dayjs": "^1.11.
|
|
96
|
-
"eslint": "^8.
|
|
97
|
-
"eslint-plugin-sonarjs": "^0.
|
|
98
|
-
"expect": "^
|
|
99
|
-
"fastify": "^4.3
|
|
95
|
+
"dayjs": "^1.11.5",
|
|
96
|
+
"eslint": "^8.23.1",
|
|
97
|
+
"eslint-plugin-sonarjs": "^0.15.0",
|
|
98
|
+
"expect": "^29.0.3",
|
|
99
|
+
"fastify": "^4.5.3",
|
|
100
100
|
"gzip-size": "^7.0.0",
|
|
101
101
|
"mocha": "^10.0.0",
|
|
102
102
|
"nodemon": "^2.0.19",
|
|
103
103
|
"nyc": "^15.1.0",
|
|
104
104
|
"pirates": "^4.0.5",
|
|
105
|
-
"release-it": "^15.1
|
|
105
|
+
"release-it": "^15.4.1",
|
|
106
106
|
"remark-cli": "^11.0.0",
|
|
107
107
|
"remark-toc": "^8.0.1"
|
|
108
108
|
},
|