valyrian.js 7.2.11 → 8.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 +6 -6
- package/dist/flux-store/index.d.ts +32 -0
- package/dist/flux-store/index.d.ts.map +1 -0
- package/dist/flux-store/index.js +258 -0
- package/dist/flux-store/index.js.map +7 -0
- package/dist/flux-store/index.min.js +1 -0
- package/dist/flux-store/index.min.js.map +1 -0
- package/dist/flux-store/index.mjs +237 -0
- package/dist/flux-store/index.mjs.map +7 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +42 -75
- package/dist/hooks/index.js.map +2 -2
- package/dist/hooks/index.min.js +1 -0
- package/dist/hooks/index.min.js.map +1 -0
- package/dist/hooks/index.mjs +43 -76
- package/dist/hooks/index.mjs.map +2 -2
- package/dist/index.d.ts +52 -54
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +397 -328
- package/dist/index.js.map +3 -3
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +397 -328
- package/dist/index.mjs.map +3 -3
- package/dist/native-store/index.d.ts +14 -0
- package/dist/native-store/index.d.ts.map +1 -0
- package/dist/native-store/index.js +103 -0
- package/dist/native-store/index.js.map +7 -0
- package/dist/native-store/index.min.js +1 -0
- package/dist/native-store/index.min.js.map +1 -0
- package/dist/native-store/index.mjs +82 -0
- package/dist/native-store/index.mjs.map +7 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +223 -86
- package/dist/node/index.js.map +4 -4
- package/dist/node/index.mjs +223 -86
- package/dist/node/index.mjs.map +4 -4
- package/dist/node/node.sw.js +152 -0
- package/dist/node/utils/inline.d.ts.map +1 -1
- package/dist/node/utils/node.sw.js +152 -0
- package/dist/node/utils/session-storage.d.ts +22 -0
- package/dist/node/utils/session-storage.d.ts.map +1 -0
- package/dist/node/utils/sw.d.ts.map +1 -1
- package/dist/node/utils/tree-adapter.d.ts +9 -0
- package/dist/node/utils/tree-adapter.d.ts.map +1 -1
- package/dist/pulse-store/index.d.ts +13 -0
- package/dist/pulse-store/index.d.ts.map +1 -0
- package/dist/pulse-store/index.js +143 -0
- package/dist/pulse-store/index.js.map +7 -0
- package/dist/pulse-store/index.min.js +1 -0
- package/dist/pulse-store/index.min.js.map +1 -0
- package/dist/pulse-store/index.mjs +122 -0
- package/dist/pulse-store/index.mjs.map +7 -0
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js +68 -89
- package/dist/request/index.js.map +2 -2
- package/dist/request/index.min.js +1 -0
- package/dist/request/index.min.js.map +1 -0
- package/dist/request/index.mjs +68 -89
- package/dist/request/index.mjs.map +2 -2
- package/dist/router/index.d.ts +32 -31
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +256 -104
- package/dist/router/index.js.map +3 -3
- package/dist/router/index.min.js +1 -0
- package/dist/router/index.min.js.map +1 -0
- package/dist/router/index.mjs +256 -104
- package/dist/router/index.mjs.map +3 -3
- package/dist/signals/index.d.ts +6 -0
- package/dist/signals/index.d.ts.map +1 -0
- package/dist/signals/index.js +92 -0
- package/dist/signals/index.js.map +7 -0
- package/dist/signals/index.min.js +1 -0
- package/dist/signals/index.min.js.map +1 -0
- package/dist/signals/index.mjs +71 -0
- package/dist/signals/index.mjs.map +7 -0
- package/dist/suspense/index.d.ts +6 -0
- package/dist/suspense/index.d.ts.map +1 -0
- package/dist/suspense/index.js +67 -0
- package/dist/suspense/index.js.map +7 -0
- package/dist/suspense/index.min.js +1 -0
- package/dist/suspense/index.min.js.map +1 -0
- package/dist/suspense/index.mjs +46 -0
- package/dist/suspense/index.mjs.map +7 -0
- package/dist/sw/index.min.js +1 -0
- package/dist/sw/index.min.js.map +1 -0
- package/dist/translate/index.d.ts +19 -0
- package/dist/translate/index.d.ts.map +1 -0
- package/dist/translate/index.js +150 -0
- package/dist/translate/index.js.map +7 -0
- package/dist/translate/index.min.js +1 -0
- package/dist/translate/index.min.js.map +1 -0
- package/dist/translate/index.mjs +129 -0
- package/dist/translate/index.mjs.map +7 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/deep-freeze.d.ts +3 -0
- package/dist/utils/deep-freeze.d.ts.map +1 -0
- package/dist/utils/getter-setter.d.ts +3 -0
- package/dist/utils/getter-setter.d.ts.map +1 -0
- package/dist/utils/has-changed.d.ts +2 -0
- package/dist/utils/has-changed.d.ts.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +138 -0
- package/dist/utils/index.js.map +7 -0
- package/dist/utils/index.min.js +1 -0
- package/dist/utils/index.min.js.map +1 -0
- package/dist/utils/index.mjs +115 -0
- package/dist/utils/index.mjs.map +7 -0
- package/lib/flux-store/index.ts +301 -0
- package/lib/hooks/index.ts +52 -101
- package/lib/index.ts +479 -719
- package/lib/native-store/index.ts +106 -0
- package/lib/node/index.ts +5 -3
- package/lib/node/utils/icons.ts +5 -5
- package/lib/node/utils/inline.ts +17 -17
- package/lib/node/utils/node.sw.js +152 -0
- package/lib/node/utils/session-storage.ts +117 -0
- package/lib/node/utils/sw.ts +35 -11
- package/lib/node/utils/tree-adapter.ts +99 -52
- package/lib/pulse-store/index.ts +181 -0
- package/lib/request/index.ts +86 -116
- package/lib/router/index.ts +358 -170
- package/lib/signals/index.ts +98 -0
- package/lib/suspense/index.ts +57 -0
- package/lib/translate/index.ts +156 -0
- package/lib/utils/deep-freeze.ts +54 -0
- package/lib/utils/getter-setter.ts +40 -0
- package/lib/utils/has-changed.ts +43 -0
- package/lib/utils/index.ts +3 -0
- package/package.json +38 -50
- package/tsconfig.json +1 -1
- package/dist/dataset/index.d.ts +0 -24
- package/dist/dataset/index.d.ts.map +0 -1
- package/dist/dataset/index.js +0 -178
- package/dist/dataset/index.js.map +0 -7
- package/dist/dataset/index.mjs +0 -157
- package/dist/dataset/index.mjs.map +0 -7
- package/dist/node/node.sw.tpl +0 -133
- package/dist/node/utils/node.sw.tpl +0 -133
- package/dist/proxy-signal/index.d.ts +0 -23
- package/dist/proxy-signal/index.d.ts.map +0 -1
- package/dist/proxy-signal/index.js +0 -138
- package/dist/proxy-signal/index.js.map +0 -7
- package/dist/proxy-signal/index.mjs +0 -117
- package/dist/proxy-signal/index.mjs.map +0 -7
- package/dist/signal/index.d.ts +0 -20
- package/dist/signal/index.d.ts.map +0 -1
- package/dist/signal/index.js +0 -95
- package/dist/signal/index.js.map +0 -7
- package/dist/signal/index.mjs +0 -74
- package/dist/signal/index.mjs.map +0 -7
- package/dist/store/index.d.ts +0 -16
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js +0 -93
- package/dist/store/index.js.map +0 -7
- package/dist/store/index.mjs +0 -72
- package/dist/store/index.mjs.map +0 -7
- package/lib/dataset/index.ts +0 -193
- package/lib/index.d.ts +0 -0
- package/lib/interfaces.ts.bak +0 -141
- package/lib/node/utils/node.sw.tpl +0 -133
- package/lib/proxy-signal/index.ts +0 -187
- package/lib/signal/index.ts +0 -161
- package/lib/store/index.ts +0 -101
package/dist/node/index.js
CHANGED
|
@@ -88,6 +88,13 @@ var Node = class _Node {
|
|
|
88
88
|
set parentNode(node) {
|
|
89
89
|
this.parent_node = node;
|
|
90
90
|
}
|
|
91
|
+
#dataset = {};
|
|
92
|
+
get dataset() {
|
|
93
|
+
return this.#dataset;
|
|
94
|
+
}
|
|
95
|
+
set dataset(value) {
|
|
96
|
+
this.#dataset = value;
|
|
97
|
+
}
|
|
91
98
|
constructor() {
|
|
92
99
|
}
|
|
93
100
|
appendChild(node) {
|
|
@@ -103,7 +110,7 @@ var Node = class _Node {
|
|
|
103
110
|
node.parentNode && node.parentNode.removeChild(node);
|
|
104
111
|
node.parentNode = this;
|
|
105
112
|
if (child) {
|
|
106
|
-
|
|
113
|
+
const idx = this.childNodes.indexOf(child);
|
|
107
114
|
this.childNodes.splice(idx, 0, node);
|
|
108
115
|
} else {
|
|
109
116
|
this.childNodes.push(node);
|
|
@@ -120,18 +127,21 @@ var Node = class _Node {
|
|
|
120
127
|
}
|
|
121
128
|
removeChild(child) {
|
|
122
129
|
if (child && child.parentNode === this) {
|
|
123
|
-
|
|
130
|
+
const idx = this.childNodes.indexOf(child);
|
|
124
131
|
this.childNodes.splice(idx, 1);
|
|
125
132
|
child.parentNode = null;
|
|
126
133
|
}
|
|
127
134
|
return child;
|
|
128
135
|
}
|
|
136
|
+
remove() {
|
|
137
|
+
return this.parentNode ? this.parentNode.removeChild(this) : this;
|
|
138
|
+
}
|
|
129
139
|
cloneNode(deep) {
|
|
130
140
|
if (this.nodeType === 3) {
|
|
131
141
|
return new Text(this.nodeValue);
|
|
132
142
|
}
|
|
133
143
|
if (this.nodeType === 1) {
|
|
134
|
-
|
|
144
|
+
const node2 = new Element();
|
|
135
145
|
node2.nodeType = this.nodeType;
|
|
136
146
|
this.nodeName = this.nodeName;
|
|
137
147
|
if (this.attributes) {
|
|
@@ -139,6 +149,9 @@ var Node = class _Node {
|
|
|
139
149
|
node2.setAttribute(this.attributes[i].nodeName, this.attributes[i].nodeValue);
|
|
140
150
|
}
|
|
141
151
|
}
|
|
152
|
+
for (const key in this.dataset) {
|
|
153
|
+
node2.dataset[key] = this.dataset[key];
|
|
154
|
+
}
|
|
142
155
|
if (deep) {
|
|
143
156
|
for (let i = 0, l = this.childNodes.length; i < l; i++) {
|
|
144
157
|
node2.appendChild(this.childNodes[i].cloneNode(deep));
|
|
@@ -146,13 +159,13 @@ var Node = class _Node {
|
|
|
146
159
|
}
|
|
147
160
|
return node2;
|
|
148
161
|
}
|
|
149
|
-
|
|
162
|
+
const node = new _Node();
|
|
150
163
|
node.nodeType = this.nodeType;
|
|
151
164
|
node.nodeName = this.nodeName;
|
|
152
165
|
return node;
|
|
153
166
|
}
|
|
154
167
|
setAttribute(name, value) {
|
|
155
|
-
|
|
168
|
+
const attr = {
|
|
156
169
|
nodeName: name,
|
|
157
170
|
nodeValue: value
|
|
158
171
|
};
|
|
@@ -274,8 +287,8 @@ var Text = class extends Node {
|
|
|
274
287
|
};
|
|
275
288
|
function updateElementStyles(element, state) {
|
|
276
289
|
let str = "";
|
|
277
|
-
for (
|
|
278
|
-
|
|
290
|
+
for (const key in state) {
|
|
291
|
+
const value = state[key];
|
|
279
292
|
if (typeof value !== "undefined" && value !== null && String(value).length > 0) {
|
|
280
293
|
str += `${key}: ${state[key]};`;
|
|
281
294
|
}
|
|
@@ -323,26 +336,46 @@ var Element = class extends Node {
|
|
|
323
336
|
}
|
|
324
337
|
throw new Error("Cannot set style");
|
|
325
338
|
}
|
|
339
|
+
get className() {
|
|
340
|
+
return this.getAttribute("class") || "";
|
|
341
|
+
}
|
|
342
|
+
set className(value) {
|
|
343
|
+
if (value == null || value === false) {
|
|
344
|
+
this.removeAttribute("class");
|
|
345
|
+
} else {
|
|
346
|
+
this.setAttribute("class", String(value));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
326
349
|
classList = {
|
|
327
350
|
toggle: (item, force) => {
|
|
328
351
|
if (item) {
|
|
329
|
-
|
|
330
|
-
|
|
352
|
+
const classes = (this.className || "").split(" ");
|
|
353
|
+
const itemIndex = classes.indexOf(item);
|
|
331
354
|
if (force && itemIndex === -1) {
|
|
332
355
|
classes.push(item);
|
|
333
356
|
}
|
|
334
357
|
if (!force && itemIndex !== -1) {
|
|
335
358
|
classes.splice(itemIndex, 1);
|
|
336
359
|
}
|
|
337
|
-
|
|
360
|
+
const final = classes.join(" ").trim();
|
|
338
361
|
if (final.length) {
|
|
339
|
-
this.
|
|
362
|
+
this.className = classes.join(" ").trim();
|
|
340
363
|
} else {
|
|
341
|
-
this.
|
|
364
|
+
this.className = false;
|
|
342
365
|
}
|
|
343
366
|
}
|
|
344
367
|
}
|
|
345
368
|
};
|
|
369
|
+
get id() {
|
|
370
|
+
return this.getAttribute("id") || "";
|
|
371
|
+
}
|
|
372
|
+
set id(value) {
|
|
373
|
+
if (value == null || value === false) {
|
|
374
|
+
this.removeAttribute("id");
|
|
375
|
+
} else {
|
|
376
|
+
this.setAttribute("id", String(value));
|
|
377
|
+
}
|
|
378
|
+
}
|
|
346
379
|
set textContent(text) {
|
|
347
380
|
this.nodeValue = String(text);
|
|
348
381
|
this.childNodes = this.nodeValue ? [new Text(this.nodeValue)] : [];
|
|
@@ -365,7 +398,7 @@ var Element = class extends Node {
|
|
|
365
398
|
}
|
|
366
399
|
set innerHTML(html) {
|
|
367
400
|
this.textContent = "";
|
|
368
|
-
|
|
401
|
+
const result = htmlToDom(html);
|
|
369
402
|
if (result instanceof DocumentFragment) {
|
|
370
403
|
for (let i = 0, l = result.childNodes.length; i < l; i++) {
|
|
371
404
|
this.appendChild(result.childNodes[i]);
|
|
@@ -390,17 +423,19 @@ var Document = class extends Element {
|
|
|
390
423
|
super();
|
|
391
424
|
this.nodeType = 9;
|
|
392
425
|
this.nodeName = "#document";
|
|
426
|
+
this.body = this.createElement("body");
|
|
393
427
|
}
|
|
428
|
+
body;
|
|
394
429
|
createDocumentFragment() {
|
|
395
430
|
return new DocumentFragment();
|
|
396
431
|
}
|
|
397
432
|
createElement(type) {
|
|
398
|
-
|
|
433
|
+
const element = new Element();
|
|
399
434
|
element.nodeName = type.toUpperCase();
|
|
400
435
|
return element;
|
|
401
436
|
}
|
|
402
437
|
createElementNS(ns, type) {
|
|
403
|
-
|
|
438
|
+
const element = this.createElement(type);
|
|
404
439
|
element.baseURI = ns;
|
|
405
440
|
return element;
|
|
406
441
|
}
|
|
@@ -430,7 +465,7 @@ function domToHtml(dom) {
|
|
|
430
465
|
return dom.textContent;
|
|
431
466
|
}
|
|
432
467
|
if (dom.nodeType === 1) {
|
|
433
|
-
|
|
468
|
+
const name = dom.nodeName.toLowerCase();
|
|
434
469
|
let str = "<" + name;
|
|
435
470
|
for (let i = 0, l = dom.attributes.length; i < l; i++) {
|
|
436
471
|
str += " " + dom.attributes[i].nodeName + '="' + dom.attributes[i].nodeValue + '"';
|
|
@@ -439,7 +474,7 @@ function domToHtml(dom) {
|
|
|
439
474
|
str += ">";
|
|
440
475
|
if (dom.childNodes && dom.childNodes.length > 0) {
|
|
441
476
|
for (let i = 0, l = dom.childNodes.length; i < l; i++) {
|
|
442
|
-
|
|
477
|
+
const child = domToHtml(dom.childNodes[i]);
|
|
443
478
|
if (child) {
|
|
444
479
|
str += child;
|
|
445
480
|
}
|
|
@@ -469,9 +504,9 @@ ${spaces}"${item.nodeValue}"`;
|
|
|
469
504
|
let str = `
|
|
470
505
|
${spaces}v("${item.nodeName}", `;
|
|
471
506
|
if (item.attributes) {
|
|
472
|
-
|
|
507
|
+
const attrs = {};
|
|
473
508
|
for (let i = 0, l = item.attributes.length; i < l; i++) {
|
|
474
|
-
|
|
509
|
+
const attr = item.attributes[i];
|
|
475
510
|
attrs[attr.nodeName] = attr.nodeValue;
|
|
476
511
|
}
|
|
477
512
|
str += JSON.stringify(attrs);
|
|
@@ -489,14 +524,14 @@ ${spaces}`;
|
|
|
489
524
|
}).join(",");
|
|
490
525
|
}
|
|
491
526
|
function findTexts(item, html) {
|
|
492
|
-
|
|
527
|
+
const newChildren = [];
|
|
493
528
|
if (item.children.length) {
|
|
494
529
|
for (let i = 0; i < item.children.length; i++) {
|
|
495
|
-
|
|
496
|
-
|
|
530
|
+
const child = item.children[i];
|
|
531
|
+
const nextChild = item.children[i + 1];
|
|
497
532
|
if (i === 0 && child.startsAt > item.contentStartsAt) {
|
|
498
|
-
|
|
499
|
-
|
|
533
|
+
const childContent = html.substring(item.contentStartsAt, child.startsAt);
|
|
534
|
+
const childText = {
|
|
500
535
|
tagName: "#text",
|
|
501
536
|
startsAt: item.contentStartsAt,
|
|
502
537
|
endsAt: item.contentStartsAt + childContent.length,
|
|
@@ -510,8 +545,8 @@ function findTexts(item, html) {
|
|
|
510
545
|
}
|
|
511
546
|
newChildren.push(child);
|
|
512
547
|
if (nextChild && child.endsAt < nextChild.startsAt) {
|
|
513
|
-
|
|
514
|
-
|
|
548
|
+
const childContent = html.substring(child.endsAt, nextChild.startsAt);
|
|
549
|
+
const childText = {
|
|
515
550
|
tagName: "#text",
|
|
516
551
|
startsAt: child.endsAt,
|
|
517
552
|
endsAt: child.endsAt + childContent.length,
|
|
@@ -524,8 +559,8 @@ function findTexts(item, html) {
|
|
|
524
559
|
newChildren.push(childText);
|
|
525
560
|
}
|
|
526
561
|
if (!nextChild && child.endsAt < item.contentEndsAt) {
|
|
527
|
-
|
|
528
|
-
|
|
562
|
+
const childContent = html.substring(child.endsAt, item.contentEndsAt);
|
|
563
|
+
const childText = {
|
|
529
564
|
tagName: "#text",
|
|
530
565
|
startsAt: child.endsAt,
|
|
531
566
|
endsAt: child.endsAt + childContent.length,
|
|
@@ -541,9 +576,9 @@ function findTexts(item, html) {
|
|
|
541
576
|
}
|
|
542
577
|
}
|
|
543
578
|
if (!item.children.length) {
|
|
544
|
-
|
|
579
|
+
const childContent = html.substring(item.contentStartsAt, item.contentEndsAt);
|
|
545
580
|
if (childContent.length) {
|
|
546
|
-
|
|
581
|
+
const childText = {
|
|
547
582
|
tagName: "#text",
|
|
548
583
|
startsAt: item.contentStartsAt,
|
|
549
584
|
endsAt: item.contentEndsAt,
|
|
@@ -564,11 +599,11 @@ function convertToDom(item) {
|
|
|
564
599
|
node = document.createTextNode(item.nodeValue);
|
|
565
600
|
} else {
|
|
566
601
|
node = item.tagName === "#document-fragment" ? document.createDocumentFragment() : document.createElement(item.tagName);
|
|
567
|
-
for (
|
|
602
|
+
for (const key in item.attributes) {
|
|
568
603
|
node.setAttribute(key, item.attributes[key]);
|
|
569
604
|
}
|
|
570
605
|
for (let i = 0; i < item.children.length; i++) {
|
|
571
|
-
|
|
606
|
+
const child = convertToDom(item.children[i]);
|
|
572
607
|
node.appendChild(child);
|
|
573
608
|
}
|
|
574
609
|
}
|
|
@@ -576,24 +611,24 @@ function convertToDom(item) {
|
|
|
576
611
|
}
|
|
577
612
|
function getObjectIndexTree(html) {
|
|
578
613
|
let item;
|
|
579
|
-
|
|
580
|
-
|
|
614
|
+
const regex = RegExp("<([^>|^!]+)>", "g");
|
|
615
|
+
const items = [];
|
|
581
616
|
while (item = regex.exec(html)) {
|
|
582
617
|
if (item[0].startsWith("</")) {
|
|
583
|
-
|
|
618
|
+
const lastOpenedItem = [...items].reverse().find((item2) => item2.endsAt === null);
|
|
584
619
|
if (lastOpenedItem) {
|
|
585
620
|
lastOpenedItem.endsAt = item.index + item[0].length;
|
|
586
621
|
lastOpenedItem.contentEndsAt = item.index;
|
|
587
|
-
|
|
622
|
+
const parent = [...items].reverse().find((item2) => item2.endsAt === null);
|
|
588
623
|
if (parent) {
|
|
589
|
-
|
|
624
|
+
const index = items.indexOf(lastOpenedItem);
|
|
590
625
|
items.splice(index, 1);
|
|
591
626
|
parent.children.push(lastOpenedItem);
|
|
592
627
|
}
|
|
593
628
|
}
|
|
594
629
|
continue;
|
|
595
630
|
}
|
|
596
|
-
|
|
631
|
+
const element = {
|
|
597
632
|
tagName: item[1].split(" ")[0],
|
|
598
633
|
startsAt: item.index,
|
|
599
634
|
endsAt: null,
|
|
@@ -604,9 +639,9 @@ function getObjectIndexTree(html) {
|
|
|
604
639
|
nodeValue: null
|
|
605
640
|
};
|
|
606
641
|
let string = (item[1] || "").substring(element.tagName.length + 1).replace(/\/$/g, "");
|
|
607
|
-
|
|
642
|
+
const attributesWithValues = string.match(/\S+="[^"]+"/g);
|
|
608
643
|
if (attributesWithValues) {
|
|
609
|
-
for (
|
|
644
|
+
for (const attribute of attributesWithValues) {
|
|
610
645
|
const [name, ...value] = attribute.trim().split("=");
|
|
611
646
|
string = string.replace(attribute, "");
|
|
612
647
|
if (value) {
|
|
@@ -614,9 +649,9 @@ function getObjectIndexTree(html) {
|
|
|
614
649
|
}
|
|
615
650
|
}
|
|
616
651
|
}
|
|
617
|
-
|
|
652
|
+
const attributesWithBooleanValues = string.match(/\s\S+=[^"]+/g);
|
|
618
653
|
if (attributesWithBooleanValues) {
|
|
619
|
-
for (
|
|
654
|
+
for (const attribute of attributesWithBooleanValues) {
|
|
620
655
|
const [name, ...value] = attribute.trim().split("=");
|
|
621
656
|
string = string.replace(attribute, "");
|
|
622
657
|
if (value) {
|
|
@@ -624,9 +659,9 @@ function getObjectIndexTree(html) {
|
|
|
624
659
|
}
|
|
625
660
|
}
|
|
626
661
|
}
|
|
627
|
-
|
|
662
|
+
const attributesWithEmptyValues = string.match(/\s?\S+/g);
|
|
628
663
|
if (attributesWithEmptyValues) {
|
|
629
|
-
for (
|
|
664
|
+
for (const attribute of attributesWithEmptyValues) {
|
|
630
665
|
const name = attribute.trim();
|
|
631
666
|
element.attributes[name] = true;
|
|
632
667
|
}
|
|
@@ -634,7 +669,7 @@ function getObjectIndexTree(html) {
|
|
|
634
669
|
if (item[0].endsWith("/>")) {
|
|
635
670
|
element.endsAt = element.startsAt + item[0].length;
|
|
636
671
|
element.contentStartsAt = element.contentEndsAt = element.endsAt;
|
|
637
|
-
|
|
672
|
+
const parent = [...items].reverse().find((item2) => item2.endsAt === null);
|
|
638
673
|
if (parent) {
|
|
639
674
|
parent.children.push(element);
|
|
640
675
|
continue;
|
|
@@ -642,7 +677,7 @@ function getObjectIndexTree(html) {
|
|
|
642
677
|
}
|
|
643
678
|
items.push(element);
|
|
644
679
|
}
|
|
645
|
-
|
|
680
|
+
const fragmentItem = {
|
|
646
681
|
tagName: "#document-fragment",
|
|
647
682
|
startsAt: 0,
|
|
648
683
|
endsAt: html.length,
|
|
@@ -657,21 +692,21 @@ function getObjectIndexTree(html) {
|
|
|
657
692
|
}
|
|
658
693
|
function htmlToDom(html) {
|
|
659
694
|
const openingTag = html.match(/<[^>]+>/g);
|
|
660
|
-
|
|
695
|
+
const document2 = new Document();
|
|
661
696
|
if (!openingTag) {
|
|
662
|
-
|
|
697
|
+
const documentFragment = document2.createDocumentFragment();
|
|
663
698
|
documentFragment.appendChild(document2.createTextNode(html));
|
|
664
699
|
return documentFragment;
|
|
665
700
|
}
|
|
666
|
-
|
|
701
|
+
const fragment = getObjectIndexTree(html);
|
|
667
702
|
if (fragment.childNodes.length > 1) {
|
|
668
703
|
return fragment;
|
|
669
704
|
}
|
|
670
705
|
return fragment.childNodes[0];
|
|
671
706
|
}
|
|
672
707
|
function htmlToHyperscript(html) {
|
|
673
|
-
|
|
674
|
-
|
|
708
|
+
const domTree = htmlToDom(html);
|
|
709
|
+
const hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);
|
|
675
710
|
return `[${hyperscript}
|
|
676
711
|
]`;
|
|
677
712
|
}
|
|
@@ -684,7 +719,7 @@ var import_form_data = __toESM(require("form-data"));
|
|
|
684
719
|
// lib/node/utils/icons.ts
|
|
685
720
|
var import_fs = __toESM(require("fs"));
|
|
686
721
|
async function icons(source, configuration) {
|
|
687
|
-
|
|
722
|
+
const options = {
|
|
688
723
|
...icons.options,
|
|
689
724
|
...configuration || {}
|
|
690
725
|
};
|
|
@@ -696,17 +731,17 @@ async function icons(source, configuration) {
|
|
|
696
731
|
}
|
|
697
732
|
const { favicons } = await import("favicons");
|
|
698
733
|
try {
|
|
699
|
-
|
|
734
|
+
const response = await favicons(source, options);
|
|
700
735
|
if (options.iconsPath) {
|
|
701
|
-
for (
|
|
736
|
+
for (const i in response.images) {
|
|
702
737
|
import_fs.default.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);
|
|
703
738
|
}
|
|
704
|
-
for (
|
|
739
|
+
for (const i in response.files) {
|
|
705
740
|
import_fs.default.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);
|
|
706
741
|
}
|
|
707
742
|
}
|
|
708
743
|
if (options.linksViewPath) {
|
|
709
|
-
|
|
744
|
+
const html = `
|
|
710
745
|
function Links(){
|
|
711
746
|
return ${htmlToHyperscript(response.html.join(""))};
|
|
712
747
|
}
|
|
@@ -761,12 +796,12 @@ var import_esbuild = __toESM(require("esbuild"));
|
|
|
761
796
|
var import_fs2 = __toESM(require("fs"));
|
|
762
797
|
async function inline(file, options = {}) {
|
|
763
798
|
if (typeof file === "string") {
|
|
764
|
-
|
|
799
|
+
const ext = file.split(".").pop();
|
|
765
800
|
if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {
|
|
766
801
|
if (/(ts|tsx)/.test(ext) && !options.noValidate) {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
802
|
+
const declarationDir = options.declarationDir;
|
|
803
|
+
const emitDeclaration = !!declarationDir;
|
|
804
|
+
const tscProgOptions = {
|
|
770
805
|
basePath: process.cwd(),
|
|
771
806
|
// always required, used for relative paths
|
|
772
807
|
configFilePath: "tsconfig.json",
|
|
@@ -799,7 +834,7 @@ async function inline(file, options = {}) {
|
|
|
799
834
|
console.log("tsc", tscProgOptions);
|
|
800
835
|
tsc.build(tscProgOptions);
|
|
801
836
|
}
|
|
802
|
-
|
|
837
|
+
const esbuildOptions = {
|
|
803
838
|
entryPoints: [file],
|
|
804
839
|
bundle: "bundle" in options ? options.bundle : true,
|
|
805
840
|
sourcemap: "external",
|
|
@@ -817,13 +852,13 @@ async function inline(file, options = {}) {
|
|
|
817
852
|
},
|
|
818
853
|
...options.esbuild || {}
|
|
819
854
|
};
|
|
820
|
-
|
|
855
|
+
const result = await import_esbuild.default.build(esbuildOptions);
|
|
821
856
|
if (result.outputFiles?.length !== 2) {
|
|
822
857
|
throw new Error(result.errors.join("\n"));
|
|
823
858
|
}
|
|
824
859
|
if (options.compact) {
|
|
825
860
|
const terser = await import("terser");
|
|
826
|
-
|
|
861
|
+
const result2 = await terser.minify(result.outputFiles[1].text, {
|
|
827
862
|
sourceMap: {
|
|
828
863
|
content: result.outputFiles[0].text.toString()
|
|
829
864
|
},
|
|
@@ -839,16 +874,16 @@ async function inline(file, options = {}) {
|
|
|
839
874
|
if (!result2.code || !result2.map) {
|
|
840
875
|
throw new Error("Unknown error");
|
|
841
876
|
}
|
|
842
|
-
|
|
843
|
-
|
|
877
|
+
const mapBase64 = Buffer.from(result2.map.toString()).toString("base64");
|
|
878
|
+
const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;
|
|
844
879
|
return { raw: result2.code, map: suffix, file };
|
|
845
880
|
} else {
|
|
846
|
-
|
|
847
|
-
|
|
881
|
+
const mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString("base64");
|
|
882
|
+
const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;
|
|
848
883
|
return { raw: result.outputFiles[1].text, map: suffix, file };
|
|
849
884
|
}
|
|
850
885
|
} else if (ext && /(css|scss|styl)/.test(ext)) {
|
|
851
|
-
|
|
886
|
+
const result = await new import_clean_css.default({
|
|
852
887
|
sourceMap: true,
|
|
853
888
|
level: {
|
|
854
889
|
1: {
|
|
@@ -870,15 +905,15 @@ async function inline(file, options = {}) {
|
|
|
870
905
|
}
|
|
871
906
|
}
|
|
872
907
|
inline.uncss = async function(renderedHtml, css, options = {}) {
|
|
873
|
-
|
|
874
|
-
|
|
908
|
+
const html = await Promise.all(renderedHtml);
|
|
909
|
+
const contents = html.map((item) => {
|
|
875
910
|
return {
|
|
876
911
|
raw: item,
|
|
877
912
|
extension: "html"
|
|
878
913
|
};
|
|
879
914
|
});
|
|
880
|
-
|
|
881
|
-
|
|
915
|
+
const purgecss = new import_purgecss.PurgeCSS();
|
|
916
|
+
const output = await purgecss.purge({
|
|
882
917
|
fontFace: true,
|
|
883
918
|
keyframes: true,
|
|
884
919
|
variables: true,
|
|
@@ -887,7 +922,7 @@ inline.uncss = async function(renderedHtml, css, options = {}) {
|
|
|
887
922
|
content: contents,
|
|
888
923
|
css: [{ raw: css }]
|
|
889
924
|
});
|
|
890
|
-
|
|
925
|
+
const cleanCss = await new import_clean_css.default({
|
|
891
926
|
sourceMap: false,
|
|
892
927
|
level: {
|
|
893
928
|
1: {
|
|
@@ -907,17 +942,15 @@ inline.uncss = async function(renderedHtml, css, options = {}) {
|
|
|
907
942
|
var import_fs3 = __toESM(require("fs"));
|
|
908
943
|
var import_path = __toESM(require("path"));
|
|
909
944
|
function sw(file, options = {}) {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
options
|
|
920
|
-
);
|
|
945
|
+
const swfiletemplate = import_path.default.resolve(__dirname, "./node.sw.js");
|
|
946
|
+
const swTpl = import_fs3.default.readFileSync(swfiletemplate, "utf8");
|
|
947
|
+
const opt = {
|
|
948
|
+
version: "v1::",
|
|
949
|
+
name: "Valyrian.js",
|
|
950
|
+
urls: ["/"],
|
|
951
|
+
debug: false,
|
|
952
|
+
...options
|
|
953
|
+
};
|
|
921
954
|
let contents = swTpl.replace("v1::", "v" + opt.version + "::").replace("Valyrian.js", opt.name).replace("['/']", '["' + opt.urls.join('","') + '"]');
|
|
922
955
|
if (!opt.debug) {
|
|
923
956
|
contents = contents.replace("console.log", "() => {}");
|
|
@@ -925,12 +958,116 @@ function sw(file, options = {}) {
|
|
|
925
958
|
import_fs3.default.writeFileSync(file, contents, "utf8");
|
|
926
959
|
}
|
|
927
960
|
|
|
961
|
+
// lib/node/utils/session-storage.ts
|
|
962
|
+
var import_fs4 = __toESM(require("fs"));
|
|
963
|
+
var import_path2 = __toESM(require("path"));
|
|
964
|
+
var SessionStorage = class {
|
|
965
|
+
storage;
|
|
966
|
+
limit;
|
|
967
|
+
persist;
|
|
968
|
+
filePath;
|
|
969
|
+
directory = ".session-storage";
|
|
970
|
+
constructor({ persist = false, filePath = "./sessionData.json" } = {}) {
|
|
971
|
+
this.storage = {};
|
|
972
|
+
this.limit = 5 * 1024 * 1024;
|
|
973
|
+
this.persist = persist;
|
|
974
|
+
this.filePath = import_path2.default.resolve(this.directory, filePath);
|
|
975
|
+
if (!import_fs4.default.existsSync(this.directory)) {
|
|
976
|
+
import_fs4.default.mkdirSync(this.directory, { recursive: true });
|
|
977
|
+
}
|
|
978
|
+
if (this.persist) {
|
|
979
|
+
this.loadFromFile();
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
// Calculate total size in bytes of stored data
|
|
983
|
+
getStorageSize() {
|
|
984
|
+
return new TextEncoder().encode(JSON.stringify(this.storage)).length;
|
|
985
|
+
}
|
|
986
|
+
// Check if storage limit is exceeded
|
|
987
|
+
checkSizeLimit() {
|
|
988
|
+
const size = this.getStorageSize();
|
|
989
|
+
if (size > this.limit) {
|
|
990
|
+
throw new DOMException("Storage limit exceeded", "QuotaExceededError");
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
// Store value under the specified key
|
|
994
|
+
setItem(key, value) {
|
|
995
|
+
if (key === null || key === void 0) {
|
|
996
|
+
throw new TypeError("Failed to execute 'setItem' on 'Storage': 1 argument required, but only 0 present.");
|
|
997
|
+
}
|
|
998
|
+
if (value === null) {
|
|
999
|
+
value = "null";
|
|
1000
|
+
} else if (value === void 0) {
|
|
1001
|
+
value = "undefined";
|
|
1002
|
+
}
|
|
1003
|
+
this.storage[key] = String(value);
|
|
1004
|
+
this.checkSizeLimit();
|
|
1005
|
+
if (this.persist) {
|
|
1006
|
+
this.saveToFile();
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
// Retrieve value stored under the specified key
|
|
1010
|
+
getItem(key) {
|
|
1011
|
+
if (key === null || key === void 0) {
|
|
1012
|
+
throw new TypeError("Failed to execute 'getItem' on 'Storage': 1 argument required, but only 0 present.");
|
|
1013
|
+
}
|
|
1014
|
+
return this.storage[key] || null;
|
|
1015
|
+
}
|
|
1016
|
+
// Remove the value under the specified key
|
|
1017
|
+
removeItem(key) {
|
|
1018
|
+
if (key === null || key === void 0) {
|
|
1019
|
+
throw new TypeError("Failed to execute 'removeItem' on 'Storage': 1 argument required, but only 0 present.");
|
|
1020
|
+
}
|
|
1021
|
+
delete this.storage[key];
|
|
1022
|
+
if (this.persist) {
|
|
1023
|
+
this.saveToFile();
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
// Clear all stored values
|
|
1027
|
+
clear() {
|
|
1028
|
+
this.storage = {};
|
|
1029
|
+
if (this.persist) {
|
|
1030
|
+
this.saveToFile();
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
// Return the number of stored items
|
|
1034
|
+
get length() {
|
|
1035
|
+
return Object.keys(this.storage).length;
|
|
1036
|
+
}
|
|
1037
|
+
// Return the key at the specified index
|
|
1038
|
+
key(index) {
|
|
1039
|
+
const keys = Object.keys(this.storage);
|
|
1040
|
+
return keys[index] || null;
|
|
1041
|
+
}
|
|
1042
|
+
// Save data to a file (only if persistence is enabled)
|
|
1043
|
+
saveToFile() {
|
|
1044
|
+
try {
|
|
1045
|
+
import_fs4.default.writeFileSync(this.filePath, JSON.stringify(this.storage), "utf-8");
|
|
1046
|
+
} catch (error) {
|
|
1047
|
+
throw new Error(`Error saving data to file: ${error.message}`);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
// Load data from a file (only if persistence is enabled)
|
|
1051
|
+
loadFromFile() {
|
|
1052
|
+
try {
|
|
1053
|
+
if (import_fs4.default.existsSync(this.filePath)) {
|
|
1054
|
+
const data = import_fs4.default.readFileSync(this.filePath, "utf-8");
|
|
1055
|
+
this.storage = JSON.parse(data || "{}");
|
|
1056
|
+
}
|
|
1057
|
+
} catch (error) {
|
|
1058
|
+
throw new Error(`Error loading data from file: ${error.message}`);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
|
|
928
1063
|
// lib/node/index.ts
|
|
929
1064
|
global.FormData = import_form_data.default;
|
|
930
1065
|
global.document = document;
|
|
1066
|
+
global.sessionStorage = new SessionStorage();
|
|
1067
|
+
global.localStorage = new SessionStorage();
|
|
931
1068
|
function render(...args) {
|
|
932
|
-
|
|
933
|
-
|
|
1069
|
+
const Component = () => args;
|
|
1070
|
+
const result = (0, import_valyrian.mount)("div", Component);
|
|
934
1071
|
(0, import_valyrian.unmount)();
|
|
935
1072
|
return result;
|
|
936
1073
|
}
|