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

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
@@ -8,6 +8,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,164 @@
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
+ img.style.display = "inline-block";
593
+ img.style.width = node.style.width || `${node.width}px`;
594
+ img.style.height = node.style.height || `${node.height}px`;
595
+ return img;
596
+ }
597
+ let clone;
523
598
  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;
599
+ clone = node.cloneNode(false);
600
+ if (!clone) {
601
+ throw new Error("Failed to clone node: cloneNode returned null");
529
602
  }
603
+ cache.preNodeMap.set(clone, node);
530
604
  } 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", "");
605
+ console.error("[Snapdom] Failed to clone node:", node, err);
606
+ throw err;
569
607
  }
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");
608
+ if (node instanceof HTMLInputElement) {
609
+ clone.value = node.value;
610
+ clone.setAttribute("value", node.value);
611
+ if (node.checked !== void 0) {
612
+ clone.checked = node.checked;
613
+ if (node.checked) clone.setAttribute("checked", "");
582
614
  }
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);
615
+ } else if (node instanceof HTMLTextAreaElement) {
616
+ const rect = node.getBoundingClientRect();
617
+ clone.textContent = node.value;
618
+ clone.style.width = `${rect.width}px`;
619
+ clone.style.height = `${rect.height}px`;
620
+ } else if (node instanceof HTMLSelectElement) {
621
+ clone.value = node.value;
622
+ Array.from(clone.options).forEach((opt) => {
623
+ if (opt.value === node.value) {
624
+ opt.setAttribute("selected", "");
625
+ } else {
626
+ opt.removeAttribute("selected");
627
+ }
628
+ });
601
629
  }
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);
630
+ inlineAllStyles(node, clone, compress);
631
+ try {
632
+ if (isSlotElement(node)) {
633
+ const assigned = ((_b = node.assignedNodes) == null ? void 0 : _b.call(node, { flatten: true })) || [];
634
+ const nodesToClone = assigned.length > 0 ? assigned : Array.from(node.childNodes);
635
+ const fragment = document.createDocumentFragment();
636
+ for (const child of nodesToClone) {
637
+ try {
638
+ const clonedChild = deepClone(child, compress, options, originalRoot || node);
639
+ if (clonedChild) fragment.appendChild(clonedChild);
640
+ } catch (err) {
641
+ console.warn("[Snapdom] Failed to clone slot content:", child, err);
642
+ }
643
+ }
644
+ return fragment;
645
+ } else {
646
+ const baseChildren = node.shadowRoot ? node.shadowRoot.childNodes : node.childNodes;
647
+ for (const child of baseChildren) {
648
+ try {
649
+ const clonedChild = deepClone(child, compress, options, originalRoot || node);
650
+ if (clonedChild) clone.appendChild(clonedChild);
651
+ } catch (err) {
652
+ console.warn("[Snapdom] Failed to clone child node:", child, err);
653
+ }
654
+ }
655
+ if (node.shadowRoot && node.childNodes.length > 0 && !node.shadowRoot.querySelector("slot")) {
656
+ const lightDomContent = document.createDocumentFragment();
657
+ for (const child of node.childNodes) {
658
+ try {
659
+ const clonedChild = deepClone(child, compress, options, originalRoot || node);
660
+ if (clonedChild) lightDomContent.appendChild(clonedChild);
661
+ } catch (err) {
662
+ console.warn("[Snapdom] Failed to clone light DOM child:", child, err);
663
+ }
664
+ }
665
+ clone.appendChild(lightDomContent);
666
+ }
607
667
  }
608
- clone.appendChild(lightDomContent);
668
+ } catch (err) {
669
+ console.error("[Snapdom] Error cloning children:", err);
670
+ throw err;
609
671
  }
672
+ return clone;
673
+ } catch (error) {
674
+ console.error("[Snapdom] Error in deepClone:", error);
675
+ throw error;
610
676
  }
611
- return clone;
612
677
  }
678
+ var init_clone = __esm({
679
+ "src/core/clone.js"() {
680
+ init_styles();
681
+ init_cache();
682
+ }
683
+ });
613
684
 
614
685
  // 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
686
  function extendIconFonts(fonts) {
630
687
  const list = Array.isArray(fonts) ? fonts : [fonts];
631
688
  for (const f of list) {
@@ -647,6 +704,25 @@
647
704
  if (/icon/i.test(text) || /glyph/i.test(text) || /symbols/i.test(text) || /feather/i.test(text) || /fontawesome/i.test(text)) return true;
648
705
  return false;
649
706
  }
707
+ var defaultIconFonts, userIconFonts;
708
+ var init_iconFonts = __esm({
709
+ "src/modules/iconFonts.js"() {
710
+ defaultIconFonts = [
711
+ // /uicons/i,
712
+ /font\s*awesome/i,
713
+ /material\s*icons/i,
714
+ /ionicons/i,
715
+ /glyphicons/i,
716
+ /feather/i,
717
+ /bootstrap\s*icons/i,
718
+ /remix\s*icons/i,
719
+ /heroicons/i,
720
+ /layui/i,
721
+ /lucide/i
722
+ ];
723
+ userIconFonts = [];
724
+ }
725
+ });
650
726
 
651
727
  // src/modules/fonts.js
652
728
  function iconToImage(unicodeChar, fontFamily, fontWeight, fontSize = 32, color = "#000") {
@@ -862,6 +938,13 @@
862
938
  return finalCSS;
863
939
  });
864
940
  }
941
+ var init_fonts = __esm({
942
+ "src/modules/fonts.js"() {
943
+ init_helpers();
944
+ init_cache();
945
+ init_iconFonts();
946
+ }
947
+ });
865
948
 
866
949
  // src/modules/pseudo.js
867
950
  function inlinePseudoElements(source, clone, compress, embedFonts = false, useProxy) {
@@ -968,6 +1051,15 @@
968
1051
  }
969
1052
  });
970
1053
  }
1054
+ var init_pseudo = __esm({
1055
+ "src/modules/pseudo.js"() {
1056
+ init_helpers();
1057
+ init_cssTools();
1058
+ init_fonts();
1059
+ init_iconFonts();
1060
+ init_cache();
1061
+ }
1062
+ });
971
1063
 
972
1064
  // src/modules/svgDefs.js
973
1065
  function inlineExternalDef(root) {
@@ -998,12 +1090,17 @@
998
1090
  }
999
1091
  });
1000
1092
  }
1093
+ var init_svgDefs = __esm({
1094
+ "src/modules/svgDefs.js"() {
1095
+ }
1096
+ });
1001
1097
 
1002
1098
  // src/core/prepare.js
1003
1099
  function prepareClone(_0) {
1004
1100
  return __async(this, arguments, function* (element, compress = false, embedFonts = false, options = {}) {
1005
1101
  var _a;
1006
- let clone, classCSS;
1102
+ let clone;
1103
+ let classCSS = "";
1007
1104
  try {
1008
1105
  clone = deepClone(element, compress, options, element);
1009
1106
  } catch (e) {
@@ -1080,6 +1177,16 @@
1080
1177
  return { clone, classCSS };
1081
1178
  });
1082
1179
  }
1180
+ var init_prepare = __esm({
1181
+ "src/core/prepare.js"() {
1182
+ init_cssTools();
1183
+ init_helpers();
1184
+ init_clone();
1185
+ init_pseudo();
1186
+ init_svgDefs();
1187
+ init_cache();
1188
+ }
1189
+ });
1083
1190
 
1084
1191
  // src/modules/images.js
1085
1192
  function inlineImages(_0) {
@@ -1105,6 +1212,11 @@
1105
1212
  }
1106
1213
  });
1107
1214
  }
1215
+ var init_images = __esm({
1216
+ "src/modules/images.js"() {
1217
+ init_helpers();
1218
+ }
1219
+ });
1108
1220
 
1109
1221
  // src/modules/background.js
1110
1222
  function inlineBackgroundImages(_0, _1) {
@@ -1147,6 +1259,12 @@
1147
1259
  }
1148
1260
  });
1149
1261
  }
1262
+ var init_background = __esm({
1263
+ "src/modules/background.js"() {
1264
+ init_helpers();
1265
+ init_cache();
1266
+ }
1267
+ });
1150
1268
 
1151
1269
  // src/core/capture.js
1152
1270
  function captureDOM(_0) {
@@ -1253,6 +1371,17 @@
1253
1371
  return dataURL;
1254
1372
  });
1255
1373
  }
1374
+ var init_capture = __esm({
1375
+ "src/core/capture.js"() {
1376
+ init_prepare();
1377
+ init_images();
1378
+ init_background();
1379
+ init_helpers();
1380
+ init_cssTools();
1381
+ init_fonts();
1382
+ init_cache();
1383
+ }
1384
+ });
1256
1385
 
1257
1386
  // src/api/snapdom.js
1258
1387
  function toImg(_0, _1) {
@@ -1326,8 +1455,10 @@
1326
1455
  });
1327
1456
  }
1328
1457
  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);
1458
+ return __async(this, arguments, function* (url, { dpr = 1, scale = 1, backgroundColor, quality }, format = "png") {
1459
+ const defaultBg = ["jpg", "jpeg", "webp"].includes(format) ? "#fff" : void 0;
1460
+ const finalBg = backgroundColor != null ? backgroundColor : defaultBg;
1461
+ const canvas = yield createBackground(url, { dpr, scale }, finalBg);
1331
1462
  const img = new Image();
1332
1463
  img.src = canvas.toDataURL(`image/${format}`, quality);
1333
1464
  yield img.decode();
@@ -1374,56 +1505,63 @@
1374
1505
  return yield snapdom.capture(element, options);
1375
1506
  });
1376
1507
  }
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 });
1508
+ var init_snapdom = __esm({
1509
+ "src/api/snapdom.js"() {
1510
+ init_capture();
1511
+ init_helpers();
1512
+ init_iconFonts();
1513
+ snapdom.capture = (_0, ..._1) => __async(null, [_0, ..._1], function* (el, options = {}) {
1514
+ const url = yield captureDOM(el, options);
1515
+ const dpr = window.devicePixelRatio || 1;
1516
+ const scale = options.scale || 1;
1517
+ return {
1518
+ url,
1519
+ options,
1520
+ toRaw: () => url,
1521
+ toImg: () => toImg(url, { dpr, scale }),
1522
+ toCanvas: () => toCanvas(url, { dpr, scale }),
1523
+ toBlob: (options2) => toBlob(url, __spreadValues({ dpr, scale }, options2)),
1524
+ toPng: (options2) => toRasterImg(url, __spreadValues({ dpr, scale }, options2), "png"),
1525
+ toJpg: (options2) => toRasterImg(url, __spreadValues({ dpr, scale }, options2), "jpeg"),
1526
+ toWebp: (options2) => toRasterImg(url, __spreadValues({ dpr, scale }, options2), "webp"),
1527
+ download: ({ format = "png", filename = "capture", backgroundColor } = {}) => download(url, { dpr, scale, backgroundColor, format, filename })
1528
+ };
1529
+ });
1530
+ snapdom.toRaw = (el, options) => __async(null, null, function* () {
1531
+ return (yield snapdom.capture(el, options)).toRaw();
1532
+ });
1533
+ snapdom.toImg = (el, options) => __async(null, null, function* () {
1534
+ return (yield snapdom.capture(el, options)).toImg();
1535
+ });
1536
+ snapdom.toCanvas = (el, options) => __async(null, null, function* () {
1537
+ return (yield snapdom.capture(el, options)).toCanvas();
1538
+ });
1539
+ snapdom.toBlob = (el, options) => __async(null, null, function* () {
1540
+ return (yield snapdom.capture(el, options)).toBlob(options);
1541
+ });
1542
+ snapdom.toPng = (el, options) => __async(null, null, function* () {
1543
+ return (yield snapdom.capture(el, options)).toPng(options);
1544
+ });
1545
+ snapdom.toJpg = (el, options) => __async(null, null, function* () {
1546
+ return (yield snapdom.capture(el, options)).toJpg(options);
1547
+ });
1548
+ snapdom.toWebp = (el, options) => __async(null, null, function* () {
1549
+ return (yield snapdom.capture(el, options)).toWebp(options);
1550
+ });
1551
+ snapdom.download = (_0, ..._1) => __async(null, [_0, ..._1], function* (el, options = {}) {
1552
+ const _a = options, {
1553
+ format = "png",
1554
+ filename = "capture",
1555
+ backgroundColor
1556
+ } = _a, rest = __objRest(_a, [
1557
+ "format",
1558
+ "filename",
1559
+ "backgroundColor"
1560
+ ]);
1561
+ const capture = yield snapdom.capture(el, rest);
1562
+ return yield capture.download({ format, filename, backgroundColor });
1563
+ });
1564
+ }
1427
1565
  });
1428
1566
 
1429
1567
  // src/api/preCache.js
@@ -1472,8 +1610,38 @@
1472
1610
  yield Promise.all(promises);
1473
1611
  });
1474
1612
  }
1613
+ var init_preCache = __esm({
1614
+ "src/api/preCache.js"() {
1615
+ init_helpers();
1616
+ init_fonts();
1617
+ init_cssTools();
1618
+ init_cache();
1619
+ }
1620
+ });
1475
1621
 
1476
1622
  // src/index.browser.js
1477
- window.snapdom = snapdom;
1478
- window.preCache = preCache;
1623
+ var require_index_browser = __commonJS({
1624
+ "src/index.browser.js"(exports, module) {
1625
+ init_snapdom();
1626
+ init_preCache();
1627
+ window.snapdom = snapdom;
1628
+ if (typeof window !== "undefined") {
1629
+ window.snapdom = snapdom;
1630
+ window.preCache = preCache;
1631
+ }
1632
+ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
1633
+ module.exports = { snapdom, preCache };
1634
+ }
1635
+ if (typeof define === "function" && define.amd) {
1636
+ define([], function() {
1637
+ return { snapdom, preCache };
1638
+ });
1639
+ }
1640
+ if (typeof globalThis !== "undefined") {
1641
+ globalThis.snapdom = snapdom;
1642
+ globalThis.preCache = preCache;
1643
+ }
1644
+ }
1645
+ });
1646
+ require_index_browser();
1479
1647
  })();