@zumer/snapdom 1.9.6-dev.0 → 1.9.6-dev.2

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/snapdom.js CHANGED
@@ -1,13 +1,14 @@
1
1
 
2
2
  /*
3
3
  * snapdom
4
- * v.1.9.6-dev.0
4
+ * v.1.9.6-dev.2
5
5
  * Author Juan Martin Muda
6
6
  * License MIT
7
7
  **/
8
8
 
9
9
  (() => {
10
10
  var __defProp = Object.defineProperty;
11
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
12
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
12
13
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
14
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -35,6 +36,12 @@
35
36
  }
36
37
  return target;
37
38
  };
39
+ var __esm = (fn, res) => function __init() {
40
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
41
+ };
42
+ var __commonJS = (cb, mod) => function __require() {
43
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
44
+ };
38
45
  var __async = (__this, __arguments, generator) => {
39
46
  return new Promise((resolve, reject) => {
40
47
  var fulfilled = (value) => {
@@ -57,21 +64,6 @@
57
64
  };
58
65
 
59
66
  // src/core/cache.js
60
- var cache = {
61
- image: /* @__PURE__ */ new Map(),
62
- background: /* @__PURE__ */ new Map(),
63
- resource: /* @__PURE__ */ new Map(),
64
- defaultStyle: /* @__PURE__ */ new Map(),
65
- baseStyle: /* @__PURE__ */ new Map(),
66
- computedStyle: /* @__PURE__ */ new WeakMap(),
67
- font: /* @__PURE__ */ new Set(),
68
- snapshot: /* @__PURE__ */ new WeakMap(),
69
- snapshotKey: /* @__PURE__ */ new Map(),
70
- preStyleMap: /* @__PURE__ */ new Map(),
71
- preStyle: /* @__PURE__ */ new WeakMap(),
72
- preNodeMap: /* @__PURE__ */ new Map(),
73
- reset: resetCache
74
- };
75
67
  function resetCache() {
76
68
  cache.computedStyle = /* @__PURE__ */ new WeakMap();
77
69
  cache.snapshot = /* @__PURE__ */ new WeakMap();
@@ -80,47 +72,28 @@
80
72
  cache.preStyle = /* @__PURE__ */ new WeakMap();
81
73
  cache.preNodeMap.clear();
82
74
  }
75
+ var cache;
76
+ var init_cache = __esm({
77
+ "src/core/cache.js"() {
78
+ cache = {
79
+ image: /* @__PURE__ */ new Map(),
80
+ background: /* @__PURE__ */ new Map(),
81
+ resource: /* @__PURE__ */ new Map(),
82
+ defaultStyle: /* @__PURE__ */ new Map(),
83
+ baseStyle: /* @__PURE__ */ new Map(),
84
+ computedStyle: /* @__PURE__ */ new WeakMap(),
85
+ font: /* @__PURE__ */ new Set(),
86
+ snapshot: /* @__PURE__ */ new WeakMap(),
87
+ snapshotKey: /* @__PURE__ */ new Map(),
88
+ preStyleMap: /* @__PURE__ */ new Map(),
89
+ preStyle: /* @__PURE__ */ new WeakMap(),
90
+ preNodeMap: /* @__PURE__ */ new Map(),
91
+ reset: resetCache
92
+ };
93
+ }
94
+ });
83
95
 
84
96
  // src/utils/cssTools.js
85
- var commonTags = [
86
- "div",
87
- "span",
88
- "p",
89
- "a",
90
- "img",
91
- "ul",
92
- "li",
93
- "button",
94
- "input",
95
- "select",
96
- "textarea",
97
- "label",
98
- "section",
99
- "article",
100
- "header",
101
- "footer",
102
- "nav",
103
- "main",
104
- "aside",
105
- "h1",
106
- "h2",
107
- "h3",
108
- "h4",
109
- "h5",
110
- "h6",
111
- "svg",
112
- "path",
113
- "circle",
114
- "rect",
115
- "line",
116
- "g",
117
- "table",
118
- "thead",
119
- "tbody",
120
- "tr",
121
- "td",
122
- "th"
123
- ];
124
97
  function precacheCommonTags() {
125
98
  for (let tag of commonTags) {
126
99
  getDefaultStyleForTag(tag);
@@ -217,6 +190,51 @@
217
190
  }
218
191
  return classMap;
219
192
  }
193
+ var commonTags;
194
+ var init_cssTools = __esm({
195
+ "src/utils/cssTools.js"() {
196
+ init_cache();
197
+ commonTags = [
198
+ "div",
199
+ "span",
200
+ "p",
201
+ "a",
202
+ "img",
203
+ "ul",
204
+ "li",
205
+ "button",
206
+ "input",
207
+ "select",
208
+ "textarea",
209
+ "label",
210
+ "section",
211
+ "article",
212
+ "header",
213
+ "footer",
214
+ "nav",
215
+ "main",
216
+ "aside",
217
+ "h1",
218
+ "h2",
219
+ "h3",
220
+ "h4",
221
+ "h5",
222
+ "h6",
223
+ "svg",
224
+ "path",
225
+ "circle",
226
+ "rect",
227
+ "line",
228
+ "g",
229
+ "table",
230
+ "thead",
231
+ "tbody",
232
+ "tr",
233
+ "td",
234
+ "th"
235
+ ];
236
+ }
237
+ });
220
238
 
221
239
  // src/utils/helpers.js
222
240
  function inlineSingleBackgroundEntry(_0) {
@@ -452,6 +470,11 @@
452
470
  parts.push(bg.slice(lastIndex).trim());
453
471
  return parts;
454
472
  }
473
+ var init_helpers = __esm({
474
+ "src/utils/helpers.js"() {
475
+ init_cache();
476
+ }
477
+ });
455
478
 
456
479
  // src/modules/styles.js
457
480
  function snapshotComputedStyleFull(style) {
@@ -488,6 +511,13 @@
488
511
  cache.snapshotKey.set(hash, key);
489
512
  cache.preStyleMap.set(clone, key);
490
513
  }
514
+ var init_styles = __esm({
515
+ "src/modules/styles.js"() {
516
+ init_cssTools();
517
+ init_helpers();
518
+ init_cache();
519
+ }
520
+ });
491
521
 
492
522
  // src/core/clone.js
493
523
  function isSlotElement(node) {
@@ -495,137 +525,163 @@
495
525
  }
496
526
  function deepClone(node, compress, options = {}, originalRoot) {
497
527
  var _a, _b;
498
- if (node.nodeType === Node.TEXT_NODE) {
499
- return node.cloneNode(true);
528
+ if (!node) {
529
+ throw new Error("Invalid node: node is null or undefined");
500
530
  }
501
- if (node.nodeType !== Node.ELEMENT_NODE) return node.cloneNode(true);
502
- if (node.getAttribute("data-capture") === "exclude") {
503
- const spacer = document.createElement("div");
504
- const rect = node.getBoundingClientRect();
505
- spacer.style.cssText = `display: inline-block; width: ${rect.width}px; height: ${rect.height}px; visibility: hidden;`;
506
- return spacer;
507
- }
508
- if (options.exclude && Array.isArray(options.exclude)) {
509
- for (const selector of options.exclude) {
531
+ try {
532
+ if (node.nodeType === Node.TEXT_NODE) {
533
+ return node.cloneNode(true);
534
+ }
535
+ if (node.nodeType !== Node.ELEMENT_NODE) {
536
+ return node.cloneNode(true);
537
+ }
538
+ if (node.getAttribute("data-capture") === "exclude") {
539
+ const spacer = document.createElement("div");
540
+ const rect = node.getBoundingClientRect();
541
+ spacer.style.cssText = `display: inline-block; width: ${rect.width}px; height: ${rect.height}px; visibility: hidden;`;
542
+ return spacer;
543
+ }
544
+ if (options.exclude && Array.isArray(options.exclude)) {
545
+ for (const selector of options.exclude) {
546
+ try {
547
+ if ((_a = node.matches) == null ? void 0 : _a.call(node, selector)) {
548
+ const spacer = document.createElement("div");
549
+ const rect = node.getBoundingClientRect();
550
+ spacer.style.cssText = `display: inline-block; width: ${rect.width}px; height: ${rect.height}px; visibility: hidden;`;
551
+ return spacer;
552
+ }
553
+ } catch (err) {
554
+ console.warn(`Invalid selector in exclude option: ${selector}`, err);
555
+ }
556
+ }
557
+ }
558
+ if (typeof options.filter === "function") {
510
559
  try {
511
- if ((_a = node.matches) == null ? void 0 : _a.call(node, selector)) {
560
+ if (!options.filter(node, originalRoot || node)) {
512
561
  const spacer = document.createElement("div");
513
562
  const rect = node.getBoundingClientRect();
514
563
  spacer.style.cssText = `display: inline-block; width: ${rect.width}px; height: ${rect.height}px; visibility: hidden;`;
515
564
  return spacer;
516
565
  }
517
566
  } catch (err) {
518
- console.warn(`Invalid selector in exclude option: ${selector}`, err);
567
+ console.warn("Error in filter function:", err);
519
568
  }
520
569
  }
521
- }
522
- if (typeof options.filter === "function") {
570
+ if (node.tagName === "IFRAME") {
571
+ const fallback = document.createElement("div");
572
+ fallback.textContent = "";
573
+ fallback.style.cssText = `width: ${node.offsetWidth}px; height: ${node.offsetHeight}px; background-image: repeating-linear-gradient(45deg, #ddd, #ddd 5px, #f9f9f9 5px, #f9f9f9 10px);display: flex;align-items: center;justify-content: center;font-size: 12px;color: #555; border: 1px solid #aaa;`;
574
+ return fallback;
575
+ }
576
+ if (node.getAttribute("data-capture") === "placeholder") {
577
+ const clone2 = node.cloneNode(false);
578
+ cache.preNodeMap.set(clone2, node);
579
+ inlineAllStyles(node, clone2, compress);
580
+ const placeholder = document.createElement("div");
581
+ placeholder.textContent = node.getAttribute("data-placeholder-text") || "";
582
+ placeholder.style.cssText = `color: #666;font-size: 12px;text-align: center;line-height: 1.4;padding: 0.5em;box-sizing: border-box;`;
583
+ clone2.appendChild(placeholder);
584
+ return clone2;
585
+ }
586
+ if (node.tagName === "CANVAS") {
587
+ const dataURL = node.toDataURL();
588
+ const img = document.createElement("img");
589
+ img.src = dataURL;
590
+ img.width = node.width;
591
+ img.height = node.height;
592
+ cache.preNodeMap.set(img, node);
593
+ inlineAllStyles(node, img, compress);
594
+ return img;
595
+ }
596
+ let clone;
523
597
  try {
524
- if (!options.filter(node, originalRoot || node)) {
525
- const spacer = document.createElement("div");
526
- const rect = node.getBoundingClientRect();
527
- spacer.style.cssText = `display: inline-block; width: ${rect.width}px; height: ${rect.height}px; visibility: hidden;`;
528
- return spacer;
598
+ clone = node.cloneNode(false);
599
+ if (!clone) {
600
+ throw new Error("Failed to clone node: cloneNode returned null");
529
601
  }
602
+ cache.preNodeMap.set(clone, node);
530
603
  } catch (err) {
531
- console.warn("Error in filter function:", err);
532
- }
533
- }
534
- if (node.tagName === "IFRAME") {
535
- const fallback = document.createElement("div");
536
- fallback.textContent = "";
537
- fallback.style.cssText = `width: ${node.offsetWidth}px; height: ${node.offsetHeight}px; background-image: repeating-linear-gradient(45deg, #ddd, #ddd 5px, #f9f9f9 5px, #f9f9f9 10px);display: flex;align-items: center;justify-content: center;font-size: 12px;color: #555; border: 1px solid #aaa;`;
538
- return fallback;
539
- }
540
- if (node.getAttribute("data-capture") === "placeholder") {
541
- const clone2 = node.cloneNode(false);
542
- cache.preNodeMap.set(clone2, node);
543
- inlineAllStyles(node, clone2, compress);
544
- const placeholder = document.createElement("div");
545
- placeholder.textContent = node.getAttribute("data-placeholder-text") || "";
546
- placeholder.style.cssText = `color: #666;font-size: 12px;text-align: center;line-height: 1.4;padding: 0.5em;box-sizing: border-box;`;
547
- clone2.appendChild(placeholder);
548
- return clone2;
549
- }
550
- if (node.tagName === "CANVAS") {
551
- const dataURL = node.toDataURL();
552
- const img = document.createElement("img");
553
- img.src = dataURL;
554
- img.width = node.width;
555
- img.height = node.height;
556
- img.style.display = "inline-block";
557
- img.style.width = node.style.width || `${node.width}px`;
558
- img.style.height = node.style.height || `${node.height}px`;
559
- return img;
560
- }
561
- const clone = node.cloneNode(false);
562
- cache.preNodeMap.set(clone, node);
563
- if (node instanceof HTMLInputElement) {
564
- clone.value = node.value;
565
- clone.setAttribute("value", node.value);
566
- if (node.checked !== void 0) {
567
- clone.checked = node.checked;
568
- if (node.checked) clone.setAttribute("checked", "");
604
+ console.error("[Snapdom] Failed to clone node:", node, err);
605
+ throw err;
569
606
  }
570
- } else if (node instanceof HTMLTextAreaElement) {
571
- const rect = node.getBoundingClientRect();
572
- clone.textContent = node.value;
573
- clone.style.width = `${rect.width}px`;
574
- clone.style.height = `${rect.height}px`;
575
- } else if (node instanceof HTMLSelectElement) {
576
- clone.value = node.value;
577
- Array.from(clone.options).forEach((opt) => {
578
- if (opt.value === node.value) {
579
- opt.setAttribute("selected", "");
580
- } else {
581
- opt.removeAttribute("selected");
607
+ if (node instanceof HTMLInputElement) {
608
+ clone.value = node.value;
609
+ clone.setAttribute("value", node.value);
610
+ if (node.checked !== void 0) {
611
+ clone.checked = node.checked;
612
+ if (node.checked) clone.setAttribute("checked", "");
582
613
  }
583
- });
584
- }
585
- inlineAllStyles(node, clone, compress);
586
- if (isSlotElement(node)) {
587
- const assigned = ((_b = node.assignedNodes) == null ? void 0 : _b.call(node, { flatten: true })) || [];
588
- const nodesToClone = assigned.length > 0 ? assigned : Array.from(node.childNodes);
589
- const fragment = document.createDocumentFragment();
590
- for (const child of nodesToClone) {
591
- const clonedChild = deepClone(child, compress, options, originalRoot || node);
592
- if (clonedChild) fragment.appendChild(clonedChild);
593
- }
594
- return fragment;
595
- } else if (node instanceof HTMLTextAreaElement) {
596
- } else {
597
- const baseChildren = node.shadowRoot ? node.shadowRoot.childNodes : node.childNodes;
598
- for (const child of baseChildren) {
599
- const clonedChild = deepClone(child, compress, options, originalRoot || node);
600
- if (clonedChild) clone.appendChild(clonedChild);
614
+ } else if (node instanceof HTMLTextAreaElement) {
615
+ const rect = node.getBoundingClientRect();
616
+ clone.textContent = node.value;
617
+ clone.style.width = `${rect.width}px`;
618
+ clone.style.height = `${rect.height}px`;
619
+ } else if (node instanceof HTMLSelectElement) {
620
+ clone.value = node.value;
621
+ Array.from(clone.options).forEach((opt) => {
622
+ if (opt.value === node.value) {
623
+ opt.setAttribute("selected", "");
624
+ } else {
625
+ opt.removeAttribute("selected");
626
+ }
627
+ });
601
628
  }
602
- if (node.shadowRoot && node.childNodes.length > 0 && !node.shadowRoot.querySelector("slot")) {
603
- const lightDomContent = document.createDocumentFragment();
604
- for (const child of node.childNodes) {
605
- const clonedChild = deepClone(child, compress, options, originalRoot || node);
606
- if (clonedChild) lightDomContent.appendChild(clonedChild);
629
+ inlineAllStyles(node, clone, compress);
630
+ try {
631
+ if (isSlotElement(node)) {
632
+ const assigned = ((_b = node.assignedNodes) == null ? void 0 : _b.call(node, { flatten: true })) || [];
633
+ const nodesToClone = assigned.length > 0 ? assigned : Array.from(node.childNodes);
634
+ const fragment = document.createDocumentFragment();
635
+ for (const child of nodesToClone) {
636
+ try {
637
+ const clonedChild = deepClone(child, compress, options, originalRoot || node);
638
+ if (clonedChild) fragment.appendChild(clonedChild);
639
+ } catch (err) {
640
+ console.warn("[Snapdom] Failed to clone slot content:", child, err);
641
+ }
642
+ }
643
+ return fragment;
644
+ } else {
645
+ const baseChildren = node.shadowRoot ? node.shadowRoot.childNodes : node.childNodes;
646
+ for (const child of baseChildren) {
647
+ try {
648
+ const clonedChild = deepClone(child, compress, options, originalRoot || node);
649
+ if (clonedChild) clone.appendChild(clonedChild);
650
+ } catch (err) {
651
+ console.warn("[Snapdom] Failed to clone child node:", child, err);
652
+ }
653
+ }
654
+ if (node.shadowRoot && node.childNodes.length > 0 && !node.shadowRoot.querySelector("slot")) {
655
+ const lightDomContent = document.createDocumentFragment();
656
+ for (const child of node.childNodes) {
657
+ try {
658
+ const clonedChild = deepClone(child, compress, options, originalRoot || node);
659
+ if (clonedChild) lightDomContent.appendChild(clonedChild);
660
+ } catch (err) {
661
+ console.warn("[Snapdom] Failed to clone light DOM child:", child, err);
662
+ }
663
+ }
664
+ clone.appendChild(lightDomContent);
665
+ }
607
666
  }
608
- clone.appendChild(lightDomContent);
667
+ } catch (err) {
668
+ console.error("[Snapdom] Error cloning children:", err);
669
+ throw err;
609
670
  }
671
+ return clone;
672
+ } catch (error) {
673
+ console.error("[Snapdom] Error in deepClone:", error);
674
+ throw error;
610
675
  }
611
- return clone;
612
676
  }
677
+ var init_clone = __esm({
678
+ "src/core/clone.js"() {
679
+ init_styles();
680
+ init_cache();
681
+ }
682
+ });
613
683
 
614
684
  // src/modules/iconFonts.js
615
- var defaultIconFonts = [
616
- // /uicons/i,
617
- /font\s*awesome/i,
618
- /material\s*icons/i,
619
- /ionicons/i,
620
- /glyphicons/i,
621
- /feather/i,
622
- /bootstrap\s*icons/i,
623
- /remix\s*icons/i,
624
- /heroicons/i,
625
- /layui/i,
626
- /lucide/i
627
- ];
628
- var userIconFonts = [];
629
685
  function extendIconFonts(fonts) {
630
686
  const list = Array.isArray(fonts) ? fonts : [fonts];
631
687
  for (const f of list) {
@@ -647,6 +703,25 @@
647
703
  if (/icon/i.test(text) || /glyph/i.test(text) || /symbols/i.test(text) || /feather/i.test(text) || /fontawesome/i.test(text)) return true;
648
704
  return false;
649
705
  }
706
+ var defaultIconFonts, userIconFonts;
707
+ var init_iconFonts = __esm({
708
+ "src/modules/iconFonts.js"() {
709
+ defaultIconFonts = [
710
+ // /uicons/i,
711
+ /font\s*awesome/i,
712
+ /material\s*icons/i,
713
+ /ionicons/i,
714
+ /glyphicons/i,
715
+ /feather/i,
716
+ /bootstrap\s*icons/i,
717
+ /remix\s*icons/i,
718
+ /heroicons/i,
719
+ /layui/i,
720
+ /lucide/i
721
+ ];
722
+ userIconFonts = [];
723
+ }
724
+ });
650
725
 
651
726
  // src/modules/fonts.js
652
727
  function iconToImage(unicodeChar, fontFamily, fontWeight, fontSize = 32, color = "#000") {
@@ -862,6 +937,13 @@
862
937
  return finalCSS;
863
938
  });
864
939
  }
940
+ var init_fonts = __esm({
941
+ "src/modules/fonts.js"() {
942
+ init_helpers();
943
+ init_cache();
944
+ init_iconFonts();
945
+ }
946
+ });
865
947
 
866
948
  // src/modules/pseudo.js
867
949
  function inlinePseudoElements(source, clone, compress, embedFonts = false, useProxy) {
@@ -968,6 +1050,15 @@
968
1050
  }
969
1051
  });
970
1052
  }
1053
+ var init_pseudo = __esm({
1054
+ "src/modules/pseudo.js"() {
1055
+ init_helpers();
1056
+ init_cssTools();
1057
+ init_fonts();
1058
+ init_iconFonts();
1059
+ init_cache();
1060
+ }
1061
+ });
971
1062
 
972
1063
  // src/modules/svgDefs.js
973
1064
  function inlineExternalDef(root) {
@@ -998,12 +1089,17 @@
998
1089
  }
999
1090
  });
1000
1091
  }
1092
+ var init_svgDefs = __esm({
1093
+ "src/modules/svgDefs.js"() {
1094
+ }
1095
+ });
1001
1096
 
1002
1097
  // src/core/prepare.js
1003
1098
  function prepareClone(_0) {
1004
1099
  return __async(this, arguments, function* (element, compress = false, embedFonts = false, options = {}) {
1005
1100
  var _a;
1006
- let clone, classCSS;
1101
+ let clone;
1102
+ let classCSS = "";
1007
1103
  try {
1008
1104
  clone = deepClone(element, compress, options, element);
1009
1105
  } catch (e) {
@@ -1080,6 +1176,16 @@
1080
1176
  return { clone, classCSS };
1081
1177
  });
1082
1178
  }
1179
+ var init_prepare = __esm({
1180
+ "src/core/prepare.js"() {
1181
+ init_cssTools();
1182
+ init_helpers();
1183
+ init_clone();
1184
+ init_pseudo();
1185
+ init_svgDefs();
1186
+ init_cache();
1187
+ }
1188
+ });
1083
1189
 
1084
1190
  // src/modules/images.js
1085
1191
  function inlineImages(_0) {
@@ -1105,6 +1211,11 @@
1105
1211
  }
1106
1212
  });
1107
1213
  }
1214
+ var init_images = __esm({
1215
+ "src/modules/images.js"() {
1216
+ init_helpers();
1217
+ }
1218
+ });
1108
1219
 
1109
1220
  // src/modules/background.js
1110
1221
  function inlineBackgroundImages(_0, _1) {
@@ -1147,6 +1258,12 @@
1147
1258
  }
1148
1259
  });
1149
1260
  }
1261
+ var init_background = __esm({
1262
+ "src/modules/background.js"() {
1263
+ init_helpers();
1264
+ init_cache();
1265
+ }
1266
+ });
1150
1267
 
1151
1268
  // src/core/capture.js
1152
1269
  function captureDOM(_0) {
@@ -1253,6 +1370,17 @@
1253
1370
  return dataURL;
1254
1371
  });
1255
1372
  }
1373
+ var init_capture = __esm({
1374
+ "src/core/capture.js"() {
1375
+ init_prepare();
1376
+ init_images();
1377
+ init_background();
1378
+ init_helpers();
1379
+ init_cssTools();
1380
+ init_fonts();
1381
+ init_cache();
1382
+ }
1383
+ });
1256
1384
 
1257
1385
  // src/api/snapdom.js
1258
1386
  function toImg(_0, _1) {
@@ -1326,8 +1454,10 @@
1326
1454
  });
1327
1455
  }
1328
1456
  function toRasterImg(_0, _1) {
1329
- return __async(this, arguments, function* (url, { dpr = 1, scale = 1, backgroundColor = "#fff", quality }, format = "png") {
1330
- const canvas = yield createBackground(url, { dpr, scale }, backgroundColor);
1457
+ return __async(this, arguments, function* (url, { dpr = 1, scale = 1, backgroundColor, quality }, format = "png") {
1458
+ const defaultBg = ["jpg", "jpeg", "webp"].includes(format) ? "#fff" : void 0;
1459
+ const finalBg = backgroundColor != null ? backgroundColor : defaultBg;
1460
+ const canvas = yield createBackground(url, { dpr, scale }, finalBg);
1331
1461
  const img = new Image();
1332
1462
  img.src = canvas.toDataURL(`image/${format}`, quality);
1333
1463
  yield img.decode();
@@ -1374,56 +1504,63 @@
1374
1504
  return yield snapdom.capture(element, options);
1375
1505
  });
1376
1506
  }
1377
- snapdom.capture = (_0, ..._1) => __async(null, [_0, ..._1], function* (el, options = {}) {
1378
- const url = yield captureDOM(el, options);
1379
- const dpr = window.devicePixelRatio || 1;
1380
- const scale = options.scale || 1;
1381
- return {
1382
- url,
1383
- options,
1384
- toRaw: () => url,
1385
- toImg: () => toImg(url, { dpr, scale }),
1386
- toCanvas: () => toCanvas(url, { dpr, scale }),
1387
- toBlob: (options2) => toBlob(url, __spreadValues({ dpr, scale }, options2)),
1388
- toPng: (options2) => toRasterImg(url, __spreadValues({ dpr, scale }, options2), "png"),
1389
- toJpg: (options2) => toRasterImg(url, __spreadValues({ dpr, scale }, options2), "jpeg"),
1390
- toWebp: (options2) => toRasterImg(url, __spreadValues({ dpr, scale }, options2), "webp"),
1391
- download: ({ format = "png", filename = "capture", backgroundColor } = {}) => download(url, { dpr, scale, backgroundColor, format, filename })
1392
- };
1393
- });
1394
- snapdom.toRaw = (el, options) => __async(null, null, function* () {
1395
- return (yield snapdom.capture(el, options)).toRaw();
1396
- });
1397
- snapdom.toImg = (el, options) => __async(null, null, function* () {
1398
- return (yield snapdom.capture(el, options)).toImg();
1399
- });
1400
- snapdom.toCanvas = (el, options) => __async(null, null, function* () {
1401
- return (yield snapdom.capture(el, options)).toCanvas();
1402
- });
1403
- snapdom.toBlob = (el, options) => __async(null, null, function* () {
1404
- return (yield snapdom.capture(el, options)).toBlob(options);
1405
- });
1406
- snapdom.toPng = (el, options) => __async(null, null, function* () {
1407
- return (yield snapdom.capture(el, options)).toPng(options);
1408
- });
1409
- snapdom.toJpg = (el, options) => __async(null, null, function* () {
1410
- return (yield snapdom.capture(el, options)).toJpg(options);
1411
- });
1412
- snapdom.toWebp = (el, options) => __async(null, null, function* () {
1413
- return (yield snapdom.capture(el, options)).toWebp(options);
1414
- });
1415
- snapdom.download = (_0, ..._1) => __async(null, [_0, ..._1], function* (el, options = {}) {
1416
- const _a = options, {
1417
- format = "png",
1418
- filename = "capture",
1419
- backgroundColor
1420
- } = _a, rest = __objRest(_a, [
1421
- "format",
1422
- "filename",
1423
- "backgroundColor"
1424
- ]);
1425
- const capture = yield snapdom.capture(el, rest);
1426
- return yield capture.download({ format, filename, backgroundColor });
1507
+ var init_snapdom = __esm({
1508
+ "src/api/snapdom.js"() {
1509
+ init_capture();
1510
+ init_helpers();
1511
+ init_iconFonts();
1512
+ snapdom.capture = (_0, ..._1) => __async(null, [_0, ..._1], function* (el, options = {}) {
1513
+ const url = yield captureDOM(el, options);
1514
+ const dpr = window.devicePixelRatio || 1;
1515
+ const scale = options.scale || 1;
1516
+ return {
1517
+ url,
1518
+ options,
1519
+ toRaw: () => url,
1520
+ toImg: () => toImg(url, { dpr, scale }),
1521
+ toCanvas: () => toCanvas(url, { dpr, scale }),
1522
+ toBlob: (options2) => toBlob(url, __spreadValues({ dpr, scale }, options2)),
1523
+ toPng: (options2) => toRasterImg(url, __spreadValues({ dpr, scale }, options2), "png"),
1524
+ toJpg: (options2) => toRasterImg(url, __spreadValues({ dpr, scale }, options2), "jpeg"),
1525
+ toWebp: (options2) => toRasterImg(url, __spreadValues({ dpr, scale }, options2), "webp"),
1526
+ download: ({ format = "png", filename = "capture", backgroundColor } = {}) => download(url, { dpr, scale, backgroundColor, format, filename })
1527
+ };
1528
+ });
1529
+ snapdom.toRaw = (el, options) => __async(null, null, function* () {
1530
+ return (yield snapdom.capture(el, options)).toRaw();
1531
+ });
1532
+ snapdom.toImg = (el, options) => __async(null, null, function* () {
1533
+ return (yield snapdom.capture(el, options)).toImg();
1534
+ });
1535
+ snapdom.toCanvas = (el, options) => __async(null, null, function* () {
1536
+ return (yield snapdom.capture(el, options)).toCanvas();
1537
+ });
1538
+ snapdom.toBlob = (el, options) => __async(null, null, function* () {
1539
+ return (yield snapdom.capture(el, options)).toBlob(options);
1540
+ });
1541
+ snapdom.toPng = (el, options) => __async(null, null, function* () {
1542
+ return (yield snapdom.capture(el, options)).toPng(options);
1543
+ });
1544
+ snapdom.toJpg = (el, options) => __async(null, null, function* () {
1545
+ return (yield snapdom.capture(el, options)).toJpg(options);
1546
+ });
1547
+ snapdom.toWebp = (el, options) => __async(null, null, function* () {
1548
+ return (yield snapdom.capture(el, options)).toWebp(options);
1549
+ });
1550
+ snapdom.download = (_0, ..._1) => __async(null, [_0, ..._1], function* (el, options = {}) {
1551
+ const _a = options, {
1552
+ format = "png",
1553
+ filename = "capture",
1554
+ backgroundColor
1555
+ } = _a, rest = __objRest(_a, [
1556
+ "format",
1557
+ "filename",
1558
+ "backgroundColor"
1559
+ ]);
1560
+ const capture = yield snapdom.capture(el, rest);
1561
+ return yield capture.download({ format, filename, backgroundColor });
1562
+ });
1563
+ }
1427
1564
  });
1428
1565
 
1429
1566
  // src/api/preCache.js
@@ -1472,8 +1609,38 @@
1472
1609
  yield Promise.all(promises);
1473
1610
  });
1474
1611
  }
1612
+ var init_preCache = __esm({
1613
+ "src/api/preCache.js"() {
1614
+ init_helpers();
1615
+ init_fonts();
1616
+ init_cssTools();
1617
+ init_cache();
1618
+ }
1619
+ });
1475
1620
 
1476
1621
  // src/index.browser.js
1477
- window.snapdom = snapdom;
1478
- window.preCache = preCache;
1622
+ var require_index_browser = __commonJS({
1623
+ "src/index.browser.js"(exports, module) {
1624
+ init_snapdom();
1625
+ init_preCache();
1626
+ window.snapdom = snapdom;
1627
+ if (typeof window !== "undefined") {
1628
+ window.snapdom = snapdom;
1629
+ window.preCache = preCache;
1630
+ }
1631
+ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
1632
+ module.exports = { snapdom, preCache };
1633
+ }
1634
+ if (typeof define === "function" && define.amd) {
1635
+ define([], function() {
1636
+ return { snapdom, preCache };
1637
+ });
1638
+ }
1639
+ if (typeof globalThis !== "undefined") {
1640
+ globalThis.snapdom = snapdom;
1641
+ globalThis.preCache = preCache;
1642
+ }
1643
+ }
1644
+ });
1645
+ require_index_browser();
1479
1646
  })();