valyrian.js 7.2.10 → 7.2.12
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/dataset/index.d.ts +2 -2
- package/dist/dataset/index.d.ts.map +1 -1
- package/dist/dataset/index.js +21 -21
- package/dist/dataset/index.js.map +2 -2
- package/dist/dataset/index.mjs +22 -22
- package/dist/dataset/index.mjs.map +2 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +17 -32
- package/dist/hooks/index.js.map +3 -3
- package/dist/hooks/index.mjs +17 -32
- package/dist/hooks/index.mjs.map +3 -3
- package/dist/index.d.ts +49 -53
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +378 -326
- 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 +378 -326
- package/dist/index.mjs.map +3 -3
- package/dist/node/index.js +115 -88
- package/dist/node/index.js.map +2 -2
- package/dist/node/index.mjs +115 -88
- package/dist/node/index.mjs.map +2 -2
- package/dist/node/utils/tree-adapter.d.ts +5 -0
- package/dist/node/utils/tree-adapter.d.ts.map +1 -1
- package/dist/proxy-signal/index.js +10 -10
- package/dist/proxy-signal/index.js.map +2 -2
- package/dist/proxy-signal/index.mjs +10 -10
- package/dist/proxy-signal/index.mjs.map +2 -2
- package/dist/request/index.js +16 -16
- package/dist/request/index.js.map +2 -2
- package/dist/request/index.mjs +16 -16
- package/dist/request/index.mjs.map +2 -2
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +21 -20
- package/dist/router/index.js.map +2 -2
- package/dist/router/index.mjs +21 -20
- package/dist/router/index.mjs.map +2 -2
- package/dist/signal/index.d.ts +7 -18
- package/dist/signal/index.d.ts.map +1 -1
- package/dist/signal/index.js +29 -48
- package/dist/signal/index.js.map +3 -3
- package/dist/signal/index.mjs +31 -50
- package/dist/signal/index.mjs.map +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/index.js.map +2 -2
- package/dist/store/index.mjs +2 -2
- package/dist/store/index.mjs.map +2 -2
- package/lib/dataset/index.ts +25 -25
- package/lib/hooks/index.ts +25 -54
- package/lib/index.ts +465 -715
- package/lib/node/index.ts +2 -2
- package/lib/node/utils/icons.ts +5 -5
- package/lib/node/utils/inline.ts +17 -17
- package/lib/node/utils/sw.ts +3 -3
- package/lib/node/utils/tree-adapter.ts +95 -62
- package/lib/proxy-signal/index.ts +10 -10
- package/lib/request/index.ts +16 -16
- package/lib/router/index.ts +21 -20
- package/lib/signal/index.ts +56 -131
- package/lib/store/index.ts +2 -2
- package/package.json +10 -3
- package/lib/index.d.ts +0 -0
- package/lib/interfaces.ts.bak +0 -141
package/dist/node/index.js
CHANGED
|
@@ -91,24 +91,28 @@ var Node = class _Node {
|
|
|
91
91
|
constructor() {
|
|
92
92
|
}
|
|
93
93
|
appendChild(node) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
if (node) {
|
|
95
|
+
node.parentNode && node.parentNode.removeChild(node);
|
|
96
|
+
this.childNodes.push(node);
|
|
97
|
+
node.parentNode = this;
|
|
98
|
+
}
|
|
97
99
|
return node;
|
|
98
100
|
}
|
|
99
101
|
insertBefore(node, child) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
if (node) {
|
|
103
|
+
node.parentNode && node.parentNode.removeChild(node);
|
|
104
|
+
node.parentNode = this;
|
|
105
|
+
if (child) {
|
|
106
|
+
const idx = this.childNodes.indexOf(child);
|
|
107
|
+
this.childNodes.splice(idx, 0, node);
|
|
108
|
+
} else {
|
|
109
|
+
this.childNodes.push(node);
|
|
110
|
+
}
|
|
107
111
|
}
|
|
108
112
|
return node;
|
|
109
113
|
}
|
|
110
114
|
replaceChild(node, child) {
|
|
111
|
-
if (child && child.parentNode === this) {
|
|
115
|
+
if (node && child && child.parentNode === this) {
|
|
112
116
|
this.insertBefore(node, child);
|
|
113
117
|
child.parentNode && child.parentNode.removeChild(child);
|
|
114
118
|
}
|
|
@@ -116,18 +120,21 @@ var Node = class _Node {
|
|
|
116
120
|
}
|
|
117
121
|
removeChild(child) {
|
|
118
122
|
if (child && child.parentNode === this) {
|
|
119
|
-
|
|
123
|
+
const idx = this.childNodes.indexOf(child);
|
|
120
124
|
this.childNodes.splice(idx, 1);
|
|
121
125
|
child.parentNode = null;
|
|
122
126
|
}
|
|
123
127
|
return child;
|
|
124
128
|
}
|
|
129
|
+
remove() {
|
|
130
|
+
return this.parentNode ? this.parentNode.removeChild(this) : this;
|
|
131
|
+
}
|
|
125
132
|
cloneNode(deep) {
|
|
126
133
|
if (this.nodeType === 3) {
|
|
127
134
|
return new Text(this.nodeValue);
|
|
128
135
|
}
|
|
129
136
|
if (this.nodeType === 1) {
|
|
130
|
-
|
|
137
|
+
const node2 = new Element();
|
|
131
138
|
node2.nodeType = this.nodeType;
|
|
132
139
|
this.nodeName = this.nodeName;
|
|
133
140
|
if (this.attributes) {
|
|
@@ -142,13 +149,13 @@ var Node = class _Node {
|
|
|
142
149
|
}
|
|
143
150
|
return node2;
|
|
144
151
|
}
|
|
145
|
-
|
|
152
|
+
const node = new _Node();
|
|
146
153
|
node.nodeType = this.nodeType;
|
|
147
154
|
node.nodeName = this.nodeName;
|
|
148
155
|
return node;
|
|
149
156
|
}
|
|
150
157
|
setAttribute(name, value) {
|
|
151
|
-
|
|
158
|
+
const attr = {
|
|
152
159
|
nodeName: name,
|
|
153
160
|
nodeValue: value
|
|
154
161
|
};
|
|
@@ -270,8 +277,8 @@ var Text = class extends Node {
|
|
|
270
277
|
};
|
|
271
278
|
function updateElementStyles(element, state) {
|
|
272
279
|
let str = "";
|
|
273
|
-
for (
|
|
274
|
-
|
|
280
|
+
for (const key in state) {
|
|
281
|
+
const value = state[key];
|
|
275
282
|
if (typeof value !== "undefined" && value !== null && String(value).length > 0) {
|
|
276
283
|
str += `${key}: ${state[key]};`;
|
|
277
284
|
}
|
|
@@ -319,26 +326,46 @@ var Element = class extends Node {
|
|
|
319
326
|
}
|
|
320
327
|
throw new Error("Cannot set style");
|
|
321
328
|
}
|
|
329
|
+
get className() {
|
|
330
|
+
return this.getAttribute("class") || "";
|
|
331
|
+
}
|
|
332
|
+
set className(value) {
|
|
333
|
+
if (value == null || value === false) {
|
|
334
|
+
this.removeAttribute("class");
|
|
335
|
+
} else {
|
|
336
|
+
this.setAttribute("class", String(value));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
322
339
|
classList = {
|
|
323
340
|
toggle: (item, force) => {
|
|
324
341
|
if (item) {
|
|
325
|
-
|
|
326
|
-
|
|
342
|
+
const classes = (this.className || "").split(" ");
|
|
343
|
+
const itemIndex = classes.indexOf(item);
|
|
327
344
|
if (force && itemIndex === -1) {
|
|
328
345
|
classes.push(item);
|
|
329
346
|
}
|
|
330
347
|
if (!force && itemIndex !== -1) {
|
|
331
348
|
classes.splice(itemIndex, 1);
|
|
332
349
|
}
|
|
333
|
-
|
|
350
|
+
const final = classes.join(" ").trim();
|
|
334
351
|
if (final.length) {
|
|
335
|
-
this.
|
|
352
|
+
this.className = classes.join(" ").trim();
|
|
336
353
|
} else {
|
|
337
|
-
this.
|
|
354
|
+
this.className = false;
|
|
338
355
|
}
|
|
339
356
|
}
|
|
340
357
|
}
|
|
341
358
|
};
|
|
359
|
+
get id() {
|
|
360
|
+
return this.getAttribute("id") || "";
|
|
361
|
+
}
|
|
362
|
+
set id(value) {
|
|
363
|
+
if (value == null || value === false) {
|
|
364
|
+
this.removeAttribute("id");
|
|
365
|
+
} else {
|
|
366
|
+
this.setAttribute("id", String(value));
|
|
367
|
+
}
|
|
368
|
+
}
|
|
342
369
|
set textContent(text) {
|
|
343
370
|
this.nodeValue = String(text);
|
|
344
371
|
this.childNodes = this.nodeValue ? [new Text(this.nodeValue)] : [];
|
|
@@ -361,7 +388,7 @@ var Element = class extends Node {
|
|
|
361
388
|
}
|
|
362
389
|
set innerHTML(html) {
|
|
363
390
|
this.textContent = "";
|
|
364
|
-
|
|
391
|
+
const result = htmlToDom(html);
|
|
365
392
|
if (result instanceof DocumentFragment) {
|
|
366
393
|
for (let i = 0, l = result.childNodes.length; i < l; i++) {
|
|
367
394
|
this.appendChild(result.childNodes[i]);
|
|
@@ -391,12 +418,12 @@ var Document = class extends Element {
|
|
|
391
418
|
return new DocumentFragment();
|
|
392
419
|
}
|
|
393
420
|
createElement(type) {
|
|
394
|
-
|
|
421
|
+
const element = new Element();
|
|
395
422
|
element.nodeName = type.toUpperCase();
|
|
396
423
|
return element;
|
|
397
424
|
}
|
|
398
425
|
createElementNS(ns, type) {
|
|
399
|
-
|
|
426
|
+
const element = this.createElement(type);
|
|
400
427
|
element.baseURI = ns;
|
|
401
428
|
return element;
|
|
402
429
|
}
|
|
@@ -426,7 +453,7 @@ function domToHtml(dom) {
|
|
|
426
453
|
return dom.textContent;
|
|
427
454
|
}
|
|
428
455
|
if (dom.nodeType === 1) {
|
|
429
|
-
|
|
456
|
+
const name = dom.nodeName.toLowerCase();
|
|
430
457
|
let str = "<" + name;
|
|
431
458
|
for (let i = 0, l = dom.attributes.length; i < l; i++) {
|
|
432
459
|
str += " " + dom.attributes[i].nodeName + '="' + dom.attributes[i].nodeValue + '"';
|
|
@@ -435,7 +462,7 @@ function domToHtml(dom) {
|
|
|
435
462
|
str += ">";
|
|
436
463
|
if (dom.childNodes && dom.childNodes.length > 0) {
|
|
437
464
|
for (let i = 0, l = dom.childNodes.length; i < l; i++) {
|
|
438
|
-
|
|
465
|
+
const child = domToHtml(dom.childNodes[i]);
|
|
439
466
|
if (child) {
|
|
440
467
|
str += child;
|
|
441
468
|
}
|
|
@@ -465,9 +492,9 @@ ${spaces}"${item.nodeValue}"`;
|
|
|
465
492
|
let str = `
|
|
466
493
|
${spaces}v("${item.nodeName}", `;
|
|
467
494
|
if (item.attributes) {
|
|
468
|
-
|
|
495
|
+
const attrs = {};
|
|
469
496
|
for (let i = 0, l = item.attributes.length; i < l; i++) {
|
|
470
|
-
|
|
497
|
+
const attr = item.attributes[i];
|
|
471
498
|
attrs[attr.nodeName] = attr.nodeValue;
|
|
472
499
|
}
|
|
473
500
|
str += JSON.stringify(attrs);
|
|
@@ -485,14 +512,14 @@ ${spaces}`;
|
|
|
485
512
|
}).join(",");
|
|
486
513
|
}
|
|
487
514
|
function findTexts(item, html) {
|
|
488
|
-
|
|
515
|
+
const newChildren = [];
|
|
489
516
|
if (item.children.length) {
|
|
490
517
|
for (let i = 0; i < item.children.length; i++) {
|
|
491
|
-
|
|
492
|
-
|
|
518
|
+
const child = item.children[i];
|
|
519
|
+
const nextChild = item.children[i + 1];
|
|
493
520
|
if (i === 0 && child.startsAt > item.contentStartsAt) {
|
|
494
|
-
|
|
495
|
-
|
|
521
|
+
const childContent = html.substring(item.contentStartsAt, child.startsAt);
|
|
522
|
+
const childText = {
|
|
496
523
|
tagName: "#text",
|
|
497
524
|
startsAt: item.contentStartsAt,
|
|
498
525
|
endsAt: item.contentStartsAt + childContent.length,
|
|
@@ -506,8 +533,8 @@ function findTexts(item, html) {
|
|
|
506
533
|
}
|
|
507
534
|
newChildren.push(child);
|
|
508
535
|
if (nextChild && child.endsAt < nextChild.startsAt) {
|
|
509
|
-
|
|
510
|
-
|
|
536
|
+
const childContent = html.substring(child.endsAt, nextChild.startsAt);
|
|
537
|
+
const childText = {
|
|
511
538
|
tagName: "#text",
|
|
512
539
|
startsAt: child.endsAt,
|
|
513
540
|
endsAt: child.endsAt + childContent.length,
|
|
@@ -520,8 +547,8 @@ function findTexts(item, html) {
|
|
|
520
547
|
newChildren.push(childText);
|
|
521
548
|
}
|
|
522
549
|
if (!nextChild && child.endsAt < item.contentEndsAt) {
|
|
523
|
-
|
|
524
|
-
|
|
550
|
+
const childContent = html.substring(child.endsAt, item.contentEndsAt);
|
|
551
|
+
const childText = {
|
|
525
552
|
tagName: "#text",
|
|
526
553
|
startsAt: child.endsAt,
|
|
527
554
|
endsAt: child.endsAt + childContent.length,
|
|
@@ -537,9 +564,9 @@ function findTexts(item, html) {
|
|
|
537
564
|
}
|
|
538
565
|
}
|
|
539
566
|
if (!item.children.length) {
|
|
540
|
-
|
|
567
|
+
const childContent = html.substring(item.contentStartsAt, item.contentEndsAt);
|
|
541
568
|
if (childContent.length) {
|
|
542
|
-
|
|
569
|
+
const childText = {
|
|
543
570
|
tagName: "#text",
|
|
544
571
|
startsAt: item.contentStartsAt,
|
|
545
572
|
endsAt: item.contentEndsAt,
|
|
@@ -560,11 +587,11 @@ function convertToDom(item) {
|
|
|
560
587
|
node = document.createTextNode(item.nodeValue);
|
|
561
588
|
} else {
|
|
562
589
|
node = item.tagName === "#document-fragment" ? document.createDocumentFragment() : document.createElement(item.tagName);
|
|
563
|
-
for (
|
|
590
|
+
for (const key in item.attributes) {
|
|
564
591
|
node.setAttribute(key, item.attributes[key]);
|
|
565
592
|
}
|
|
566
593
|
for (let i = 0; i < item.children.length; i++) {
|
|
567
|
-
|
|
594
|
+
const child = convertToDom(item.children[i]);
|
|
568
595
|
node.appendChild(child);
|
|
569
596
|
}
|
|
570
597
|
}
|
|
@@ -572,24 +599,24 @@ function convertToDom(item) {
|
|
|
572
599
|
}
|
|
573
600
|
function getObjectIndexTree(html) {
|
|
574
601
|
let item;
|
|
575
|
-
|
|
576
|
-
|
|
602
|
+
const regex = RegExp("<([^>|^!]+)>", "g");
|
|
603
|
+
const items = [];
|
|
577
604
|
while (item = regex.exec(html)) {
|
|
578
605
|
if (item[0].startsWith("</")) {
|
|
579
|
-
|
|
606
|
+
const lastOpenedItem = [...items].reverse().find((item2) => item2.endsAt === null);
|
|
580
607
|
if (lastOpenedItem) {
|
|
581
608
|
lastOpenedItem.endsAt = item.index + item[0].length;
|
|
582
609
|
lastOpenedItem.contentEndsAt = item.index;
|
|
583
|
-
|
|
610
|
+
const parent = [...items].reverse().find((item2) => item2.endsAt === null);
|
|
584
611
|
if (parent) {
|
|
585
|
-
|
|
612
|
+
const index = items.indexOf(lastOpenedItem);
|
|
586
613
|
items.splice(index, 1);
|
|
587
614
|
parent.children.push(lastOpenedItem);
|
|
588
615
|
}
|
|
589
616
|
}
|
|
590
617
|
continue;
|
|
591
618
|
}
|
|
592
|
-
|
|
619
|
+
const element = {
|
|
593
620
|
tagName: item[1].split(" ")[0],
|
|
594
621
|
startsAt: item.index,
|
|
595
622
|
endsAt: null,
|
|
@@ -600,9 +627,9 @@ function getObjectIndexTree(html) {
|
|
|
600
627
|
nodeValue: null
|
|
601
628
|
};
|
|
602
629
|
let string = (item[1] || "").substring(element.tagName.length + 1).replace(/\/$/g, "");
|
|
603
|
-
|
|
630
|
+
const attributesWithValues = string.match(/\S+="[^"]+"/g);
|
|
604
631
|
if (attributesWithValues) {
|
|
605
|
-
for (
|
|
632
|
+
for (const attribute of attributesWithValues) {
|
|
606
633
|
const [name, ...value] = attribute.trim().split("=");
|
|
607
634
|
string = string.replace(attribute, "");
|
|
608
635
|
if (value) {
|
|
@@ -610,9 +637,9 @@ function getObjectIndexTree(html) {
|
|
|
610
637
|
}
|
|
611
638
|
}
|
|
612
639
|
}
|
|
613
|
-
|
|
640
|
+
const attributesWithBooleanValues = string.match(/\s\S+=[^"]+/g);
|
|
614
641
|
if (attributesWithBooleanValues) {
|
|
615
|
-
for (
|
|
642
|
+
for (const attribute of attributesWithBooleanValues) {
|
|
616
643
|
const [name, ...value] = attribute.trim().split("=");
|
|
617
644
|
string = string.replace(attribute, "");
|
|
618
645
|
if (value) {
|
|
@@ -620,9 +647,9 @@ function getObjectIndexTree(html) {
|
|
|
620
647
|
}
|
|
621
648
|
}
|
|
622
649
|
}
|
|
623
|
-
|
|
650
|
+
const attributesWithEmptyValues = string.match(/\s?\S+/g);
|
|
624
651
|
if (attributesWithEmptyValues) {
|
|
625
|
-
for (
|
|
652
|
+
for (const attribute of attributesWithEmptyValues) {
|
|
626
653
|
const name = attribute.trim();
|
|
627
654
|
element.attributes[name] = true;
|
|
628
655
|
}
|
|
@@ -630,7 +657,7 @@ function getObjectIndexTree(html) {
|
|
|
630
657
|
if (item[0].endsWith("/>")) {
|
|
631
658
|
element.endsAt = element.startsAt + item[0].length;
|
|
632
659
|
element.contentStartsAt = element.contentEndsAt = element.endsAt;
|
|
633
|
-
|
|
660
|
+
const parent = [...items].reverse().find((item2) => item2.endsAt === null);
|
|
634
661
|
if (parent) {
|
|
635
662
|
parent.children.push(element);
|
|
636
663
|
continue;
|
|
@@ -638,7 +665,7 @@ function getObjectIndexTree(html) {
|
|
|
638
665
|
}
|
|
639
666
|
items.push(element);
|
|
640
667
|
}
|
|
641
|
-
|
|
668
|
+
const fragmentItem = {
|
|
642
669
|
tagName: "#document-fragment",
|
|
643
670
|
startsAt: 0,
|
|
644
671
|
endsAt: html.length,
|
|
@@ -653,21 +680,21 @@ function getObjectIndexTree(html) {
|
|
|
653
680
|
}
|
|
654
681
|
function htmlToDom(html) {
|
|
655
682
|
const openingTag = html.match(/<[^>]+>/g);
|
|
656
|
-
|
|
683
|
+
const document2 = new Document();
|
|
657
684
|
if (!openingTag) {
|
|
658
|
-
|
|
685
|
+
const documentFragment = document2.createDocumentFragment();
|
|
659
686
|
documentFragment.appendChild(document2.createTextNode(html));
|
|
660
687
|
return documentFragment;
|
|
661
688
|
}
|
|
662
|
-
|
|
689
|
+
const fragment = getObjectIndexTree(html);
|
|
663
690
|
if (fragment.childNodes.length > 1) {
|
|
664
691
|
return fragment;
|
|
665
692
|
}
|
|
666
693
|
return fragment.childNodes[0];
|
|
667
694
|
}
|
|
668
695
|
function htmlToHyperscript(html) {
|
|
669
|
-
|
|
670
|
-
|
|
696
|
+
const domTree = htmlToDom(html);
|
|
697
|
+
const hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);
|
|
671
698
|
return `[${hyperscript}
|
|
672
699
|
]`;
|
|
673
700
|
}
|
|
@@ -680,7 +707,7 @@ var import_form_data = __toESM(require("form-data"));
|
|
|
680
707
|
// lib/node/utils/icons.ts
|
|
681
708
|
var import_fs = __toESM(require("fs"));
|
|
682
709
|
async function icons(source, configuration) {
|
|
683
|
-
|
|
710
|
+
const options = {
|
|
684
711
|
...icons.options,
|
|
685
712
|
...configuration || {}
|
|
686
713
|
};
|
|
@@ -692,17 +719,17 @@ async function icons(source, configuration) {
|
|
|
692
719
|
}
|
|
693
720
|
const { favicons } = await import("favicons");
|
|
694
721
|
try {
|
|
695
|
-
|
|
722
|
+
const response = await favicons(source, options);
|
|
696
723
|
if (options.iconsPath) {
|
|
697
|
-
for (
|
|
724
|
+
for (const i in response.images) {
|
|
698
725
|
import_fs.default.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);
|
|
699
726
|
}
|
|
700
|
-
for (
|
|
727
|
+
for (const i in response.files) {
|
|
701
728
|
import_fs.default.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);
|
|
702
729
|
}
|
|
703
730
|
}
|
|
704
731
|
if (options.linksViewPath) {
|
|
705
|
-
|
|
732
|
+
const html = `
|
|
706
733
|
function Links(){
|
|
707
734
|
return ${htmlToHyperscript(response.html.join(""))};
|
|
708
735
|
}
|
|
@@ -757,12 +784,12 @@ var import_esbuild = __toESM(require("esbuild"));
|
|
|
757
784
|
var import_fs2 = __toESM(require("fs"));
|
|
758
785
|
async function inline(file, options = {}) {
|
|
759
786
|
if (typeof file === "string") {
|
|
760
|
-
|
|
787
|
+
const ext = file.split(".").pop();
|
|
761
788
|
if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {
|
|
762
789
|
if (/(ts|tsx)/.test(ext) && !options.noValidate) {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
790
|
+
const declarationDir = options.declarationDir;
|
|
791
|
+
const emitDeclaration = !!declarationDir;
|
|
792
|
+
const tscProgOptions = {
|
|
766
793
|
basePath: process.cwd(),
|
|
767
794
|
// always required, used for relative paths
|
|
768
795
|
configFilePath: "tsconfig.json",
|
|
@@ -795,7 +822,7 @@ async function inline(file, options = {}) {
|
|
|
795
822
|
console.log("tsc", tscProgOptions);
|
|
796
823
|
tsc.build(tscProgOptions);
|
|
797
824
|
}
|
|
798
|
-
|
|
825
|
+
const esbuildOptions = {
|
|
799
826
|
entryPoints: [file],
|
|
800
827
|
bundle: "bundle" in options ? options.bundle : true,
|
|
801
828
|
sourcemap: "external",
|
|
@@ -813,13 +840,13 @@ async function inline(file, options = {}) {
|
|
|
813
840
|
},
|
|
814
841
|
...options.esbuild || {}
|
|
815
842
|
};
|
|
816
|
-
|
|
843
|
+
const result = await import_esbuild.default.build(esbuildOptions);
|
|
817
844
|
if (result.outputFiles?.length !== 2) {
|
|
818
845
|
throw new Error(result.errors.join("\n"));
|
|
819
846
|
}
|
|
820
847
|
if (options.compact) {
|
|
821
848
|
const terser = await import("terser");
|
|
822
|
-
|
|
849
|
+
const result2 = await terser.minify(result.outputFiles[1].text, {
|
|
823
850
|
sourceMap: {
|
|
824
851
|
content: result.outputFiles[0].text.toString()
|
|
825
852
|
},
|
|
@@ -835,16 +862,16 @@ async function inline(file, options = {}) {
|
|
|
835
862
|
if (!result2.code || !result2.map) {
|
|
836
863
|
throw new Error("Unknown error");
|
|
837
864
|
}
|
|
838
|
-
|
|
839
|
-
|
|
865
|
+
const mapBase64 = Buffer.from(result2.map.toString()).toString("base64");
|
|
866
|
+
const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;
|
|
840
867
|
return { raw: result2.code, map: suffix, file };
|
|
841
868
|
} else {
|
|
842
|
-
|
|
843
|
-
|
|
869
|
+
const mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString("base64");
|
|
870
|
+
const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;
|
|
844
871
|
return { raw: result.outputFiles[1].text, map: suffix, file };
|
|
845
872
|
}
|
|
846
873
|
} else if (ext && /(css|scss|styl)/.test(ext)) {
|
|
847
|
-
|
|
874
|
+
const result = await new import_clean_css.default({
|
|
848
875
|
sourceMap: true,
|
|
849
876
|
level: {
|
|
850
877
|
1: {
|
|
@@ -866,15 +893,15 @@ async function inline(file, options = {}) {
|
|
|
866
893
|
}
|
|
867
894
|
}
|
|
868
895
|
inline.uncss = async function(renderedHtml, css, options = {}) {
|
|
869
|
-
|
|
870
|
-
|
|
896
|
+
const html = await Promise.all(renderedHtml);
|
|
897
|
+
const contents = html.map((item) => {
|
|
871
898
|
return {
|
|
872
899
|
raw: item,
|
|
873
900
|
extension: "html"
|
|
874
901
|
};
|
|
875
902
|
});
|
|
876
|
-
|
|
877
|
-
|
|
903
|
+
const purgecss = new import_purgecss.PurgeCSS();
|
|
904
|
+
const output = await purgecss.purge({
|
|
878
905
|
fontFace: true,
|
|
879
906
|
keyframes: true,
|
|
880
907
|
variables: true,
|
|
@@ -883,7 +910,7 @@ inline.uncss = async function(renderedHtml, css, options = {}) {
|
|
|
883
910
|
content: contents,
|
|
884
911
|
css: [{ raw: css }]
|
|
885
912
|
});
|
|
886
|
-
|
|
913
|
+
const cleanCss = await new import_clean_css.default({
|
|
887
914
|
sourceMap: false,
|
|
888
915
|
level: {
|
|
889
916
|
1: {
|
|
@@ -903,9 +930,9 @@ inline.uncss = async function(renderedHtml, css, options = {}) {
|
|
|
903
930
|
var import_fs3 = __toESM(require("fs"));
|
|
904
931
|
var import_path = __toESM(require("path"));
|
|
905
932
|
function sw(file, options = {}) {
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
933
|
+
const swfiletemplate = import_path.default.resolve(__dirname, "./node.sw.tpl");
|
|
934
|
+
const swTpl = import_fs3.default.readFileSync(swfiletemplate, "utf8");
|
|
935
|
+
const opt = Object.assign(
|
|
909
936
|
{
|
|
910
937
|
version: "v1::",
|
|
911
938
|
name: "Valyrian.js",
|
|
@@ -925,8 +952,8 @@ function sw(file, options = {}) {
|
|
|
925
952
|
global.FormData = import_form_data.default;
|
|
926
953
|
global.document = document;
|
|
927
954
|
function render(...args) {
|
|
928
|
-
|
|
929
|
-
|
|
955
|
+
const Component = () => args;
|
|
956
|
+
const result = (0, import_valyrian.mount)("div", Component);
|
|
930
957
|
(0, import_valyrian.unmount)();
|
|
931
958
|
return result;
|
|
932
959
|
}
|