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