@mapgis/leaflet-easyprint 16.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.js ADDED
@@ -0,0 +1,479 @@
1
+ var domtoimage = require('dom-to-image');
2
+ var fileSaver = require('file-saver');
3
+
4
+ function EasyPrint(L) {
5
+ L.Control.EasyPrint = L.Control.extend({
6
+ options: {
7
+ title: 'Print map',
8
+ position: 'topleft',
9
+ sizeModes: ['Current'],
10
+ filename: 'map',
11
+ exportOnly: false,
12
+ hidden: false,
13
+ tileWait: 500,
14
+ hideControlContainer: true,
15
+ hideClasses: [],
16
+ customWindowTitle: window.document.title,
17
+ spinnerBgCOlor: '#0DC5C1',
18
+ customSpinnerClass: 'epLoader',
19
+ defaultSizeTitles: {
20
+ Current: 'Current Size',
21
+ A4Landscape: 'A4 Landscape',
22
+ A4Portrait: 'A4 Portrait'
23
+ }
24
+ },
25
+
26
+ onAdd: function () {
27
+ this.mapContainer = this._map.getContainer();
28
+ this.options.sizeModes = this.options.sizeModes.map(function (sizeMode) {
29
+ if (sizeMode === 'Current') {
30
+ return {
31
+ name: this.options.defaultSizeTitles.Current,
32
+ className: 'CurrentSize'
33
+ }
34
+ }
35
+ if (sizeMode === 'A4Landscape') {
36
+ return {
37
+ height: this._a4PageSize.height,
38
+ width: this._a4PageSize.width,
39
+ name: this.options.defaultSizeTitles.A4Landscape,
40
+ className: 'A4Landscape page'
41
+ }
42
+ }
43
+ if (sizeMode === 'A4Portrait') {
44
+ return {
45
+ height: this._a4PageSize.width,
46
+ width: this._a4PageSize.height,
47
+ name: this.options.defaultSizeTitles.A4Portrait,
48
+ className: 'A4Portrait page'
49
+ }
50
+ };
51
+ return sizeMode;
52
+ }, this);
53
+
54
+ var container = L.DomUtil.create('div', 'leaflet-control-easyPrint leaflet-bar leaflet-control');
55
+ if (!this.options.hidden) {
56
+ this._addCss();
57
+
58
+ L.DomEvent.addListener(container, 'mouseover', this._togglePageSizeButtons, this);
59
+ L.DomEvent.addListener(container, 'mouseout', this._togglePageSizeButtons, this);
60
+
61
+ var btnClass = 'leaflet-control-easyPrint-button'
62
+ if (this.options.exportOnly) btnClass = btnClass + '-export'
63
+
64
+ this.link = L.DomUtil.create('a', btnClass, container);
65
+ this.link.id = "leafletEasyPrint";
66
+ this.link.title = this.options.title;
67
+ this.holder = L.DomUtil.create('ul', 'easyPrintHolder', container);
68
+
69
+ this.options.sizeModes.forEach(function (sizeMode) {
70
+ var btn = L.DomUtil.create('li', 'easyPrintSizeMode', this.holder);
71
+ btn.title = sizeMode.name;
72
+ var link = L.DomUtil.create('a', sizeMode.className, btn);
73
+ L.DomEvent.addListener(btn, 'click', this.printMap, this);
74
+ }, this);
75
+
76
+ L.DomEvent.disableClickPropagation(container);
77
+ }
78
+ return container;
79
+ },
80
+
81
+ printMap: async function (event, filename) {
82
+ if (filename) {
83
+ this.options.filename = filename
84
+ }
85
+
86
+ if (this.options.format) {
87
+ if(this.options.format.toLowerCase() == 'jpeg'){
88
+ this.formatFun = 'toJpeg';
89
+ } else if(this.options.format.toLowerCase() == 'svg'){
90
+ this.formatFun = 'toSvg';
91
+ } else {
92
+ this.formatFun = 'toPng';
93
+ }
94
+ this.format = this.options.format;
95
+ } else{
96
+ this.formatFun = 'toPng';
97
+ this.format = 'png';
98
+ }
99
+
100
+ this.options.width = this.options.width? this.options.width:this.mapContainer.clientWidth;
101
+ this.options.height = this.options.height? this.options.height:this.mapContainer.clientHeight;
102
+
103
+ if (!this.options.exportOnly) {
104
+ this._page = window.open("", "_blank", 'toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,left=10, top=10, width=200, height=250, visible=none');
105
+ this._page.document.write(this._createSpinner(this.options.customWindowTitle, this.options.customSpinnerClass, this.options.spinnerBgCOlor));
106
+ }
107
+ this.originalState = {
108
+ mapWidth: this.mapContainer.style.width,
109
+ widthWasAuto: false,
110
+ widthWasPercentage: false,
111
+ mapHeight: this.mapContainer.style.height,
112
+ zoom: this._map.getZoom(),
113
+ center: this._map.getCenter()
114
+ };
115
+ if (this.originalState.mapWidth === 'auto') {
116
+ this.originalState.mapWidth = this._map.getSize().x + 'px'
117
+ this.originalState.widthWasAuto = true
118
+ } else if (this.originalState.mapWidth.includes('%')) {
119
+ this.originalState.percentageWidth = this.originalState.mapWidth
120
+ this.originalState.widthWasPercentage = true
121
+ this.originalState.mapWidth = this._map.getSize().x + 'px'
122
+ }
123
+ this._map.fire("easyPrint-start", { event: event });
124
+ if (!this.options.hidden) {
125
+ this._togglePageSizeButtons({type: null});
126
+ }
127
+ if (this.options.hideControlContainer) {
128
+ this._toggleControls();
129
+ }
130
+ if (this.options.hideClasses) {
131
+ this._toggleClasses(this.options.hideClasses);
132
+ }
133
+ var sizeMode = typeof event !== 'string' ? event.target.className : event;
134
+ if (sizeMode === 'CurrentSize') {
135
+ const dataUrlResult = await this._printOpertion(sizeMode);
136
+ return dataUrlResult
137
+ }
138
+ this.outerContainer = this._createOuterContainer(this.mapContainer)
139
+ if (this.originalState.widthWasAuto) {
140
+ this.outerContainer.style.width = this.originalState.mapWidth
141
+ }
142
+ this._createImagePlaceholder(sizeMode)
143
+ },
144
+
145
+ _createImagePlaceholder: function (sizeMode) {
146
+ var plugin = this;
147
+ domtoimage.toPng(this.mapContainer, {
148
+ width: parseInt(this.originalState.mapWidth.replace('px')),
149
+ height: parseInt(this.originalState.mapHeight.replace('px'))
150
+ })
151
+ .then(function (dataUrl) {
152
+ plugin.blankDiv = document.createElement("div");
153
+ var blankDiv = plugin.blankDiv;
154
+ plugin.outerContainer.parentElement.insertBefore(blankDiv, plugin.outerContainer);
155
+ blankDiv.className = 'epHolder';
156
+ blankDiv.style.backgroundImage = 'url("' + dataUrl + '")';
157
+ blankDiv.style.position = 'absolute';
158
+ blankDiv.style.zIndex = 1011;
159
+ blankDiv.style.display = 'initial';
160
+ blankDiv.style.width = plugin.originalState.mapWidth;
161
+ blankDiv.style.height = plugin.originalState.mapHeight;
162
+ plugin._resizeAndPrintMap(sizeMode);
163
+ })
164
+ .catch(function (error) {
165
+ console.error('oops, something went wrong!', error);
166
+ });
167
+ },
168
+
169
+ _resizeAndPrintMap: function (sizeMode) {
170
+ this.outerContainer.style.opacity = 0;
171
+ var pageSize = this.options.sizeModes.filter(function (item) {
172
+ return item.className.indexOf(sizeMode) > -1;
173
+ });
174
+ pageSize = pageSize[0]
175
+ this.mapContainer.style.width = pageSize.width + 'px';
176
+ this.mapContainer.style.height = pageSize.height + 'px';
177
+ if (this.mapContainer.style.width > this.mapContainer.style.height) {
178
+ this.orientation = 'portrait';
179
+ } else {
180
+ this.orientation = 'landscape';
181
+ }
182
+ this._map.setView(this.originalState.center);
183
+ this._map.setZoom(this.originalState.zoom);
184
+ this._map.invalidateSize();
185
+ if (this.options.tileLayer) {
186
+ this._pausePrint(sizeMode)
187
+ } else {
188
+ this._printOpertion(sizeMode)
189
+ }
190
+ },
191
+
192
+ _pausePrint: function (sizeMode) {
193
+ var plugin = this
194
+ var loadingTest = setInterval(function () {
195
+ if(!plugin.options.tileLayer.isLoading()) {
196
+ clearInterval(loadingTest);
197
+ plugin._printOpertion(sizeMode)
198
+ }
199
+ }, plugin.options.tileWait);
200
+ },
201
+
202
+ _printOpertion: function (sizemode) {
203
+ var plugin = this;
204
+
205
+ var widthForExport = this.options.width
206
+ // var widthForExport = this.mapContainer.style.width
207
+ var heightForExport = this.options.height
208
+ if (this.originalState.widthWasAuto && sizemode === 'CurrentSize' || this.originalState.widthWasPercentage && sizemode === 'CurrentSize') {
209
+ widthForExport = this.originalState.mapWidth
210
+ }
211
+
212
+ return new Promise((resolve)=>{
213
+ domtoimage[this.formatFun](plugin.mapContainer, {
214
+ // domtoimage.toPng(plugin.mapContainer, {
215
+ width: parseInt(widthForExport),
216
+ height: parseInt(heightForExport)
217
+ })
218
+ .then(function (dataUrl) {
219
+ var blob = plugin._dataURItoBlob(dataUrl);
220
+ if (plugin.options.exportOnly) {
221
+ fileSaver.saveAs(blob, plugin.options.filename + '.' + plugin.format);
222
+ } else {
223
+ plugin._sendToBrowserPrint(dataUrl, plugin.orientation);
224
+ }
225
+ plugin._toggleControls(true);
226
+ plugin._toggleClasses(plugin.options.hideClasses, true);
227
+
228
+ if (plugin.outerContainer) {
229
+ if (plugin.originalState.widthWasAuto) {
230
+ plugin.mapContainer.style.width = 'auto'
231
+ } else if (plugin.originalState.widthWasPercentage) {
232
+ plugin.mapContainer.style.width = plugin.originalState.percentageWidth
233
+ }
234
+ else {
235
+ plugin.mapContainer.style.width = plugin.originalState.mapWidth;
236
+ }
237
+ plugin.mapContainer.style.height = plugin.originalState.mapHeight;
238
+ plugin._removeOuterContainer(plugin.mapContainer, plugin.outerContainer, plugin.blankDiv)
239
+ plugin._map.invalidateSize();
240
+ plugin._map.setView(plugin.originalState.center);
241
+ plugin._map.setZoom(plugin.originalState.zoom);
242
+ }
243
+ plugin._map.fire("easyPrint-finished");
244
+ resolve({dataUrl: dataUrl});
245
+ })
246
+ .catch(function (error) {
247
+ console.error('Print operation failed', error);
248
+ });
249
+ })
250
+ },
251
+
252
+ _sendToBrowserPrint: function (img, orientation) {
253
+ this._page.resizeTo(600, 800);
254
+ var pageContent = this._createNewWindow(img, orientation, this)
255
+ this._page.document.body.innerHTML = ''
256
+ this._page.document.write(pageContent);
257
+ this._page.document.close();
258
+ },
259
+
260
+ _createSpinner: function (title, spinnerClass, spinnerColor) {
261
+ return `<html><head><title>`+ title + `</title></head><body><style>
262
+ body{
263
+ background: ` + spinnerColor + `;
264
+ }
265
+ .epLoader,
266
+ .epLoader:before,
267
+ .epLoader:after {
268
+ border-radius: 50%;
269
+ }
270
+ .epLoader {
271
+ color: #ffffff;
272
+ font-size: 11px;
273
+ text-indent: -99999em;
274
+ margin: 55px auto;
275
+ position: relative;
276
+ width: 10em;
277
+ height: 10em;
278
+ box-shadow: inset 0 0 0 1em;
279
+ -webkit-transform: translateZ(0);
280
+ -ms-transform: translateZ(0);
281
+ transform: translateZ(0);
282
+ }
283
+ .epLoader:before,
284
+ .epLoader:after {
285
+ position: absolute;
286
+ content: '';
287
+ }
288
+ .epLoader:before {
289
+ width: 5.2em;
290
+ height: 10.2em;
291
+ background: #0dc5c1;
292
+ border-radius: 10.2em 0 0 10.2em;
293
+ top: -0.1em;
294
+ left: -0.1em;
295
+ -webkit-transform-origin: 5.2em 5.1em;
296
+ transform-origin: 5.2em 5.1em;
297
+ -webkit-animation: load2 2s infinite ease 1.5s;
298
+ animation: load2 2s infinite ease 1.5s;
299
+ }
300
+ .epLoader:after {
301
+ width: 5.2em;
302
+ height: 10.2em;
303
+ background: #0dc5c1;
304
+ border-radius: 0 10.2em 10.2em 0;
305
+ top: -0.1em;
306
+ left: 5.1em;
307
+ -webkit-transform-origin: 0px 5.1em;
308
+ transform-origin: 0px 5.1em;
309
+ -webkit-animation: load2 2s infinite ease;
310
+ animation: load2 2s infinite ease;
311
+ }
312
+ @-webkit-keyframes load2 {
313
+ 0% {
314
+ -webkit-transform: rotate(0deg);
315
+ transform: rotate(0deg);
316
+ }
317
+ 100% {
318
+ -webkit-transform: rotate(360deg);
319
+ transform: rotate(360deg);
320
+ }
321
+ }
322
+ @keyframes load2 {
323
+ 0% {
324
+ -webkit-transform: rotate(0deg);
325
+ transform: rotate(0deg);
326
+ }
327
+ 100% {
328
+ -webkit-transform: rotate(360deg);
329
+ transform: rotate(360deg);
330
+ }
331
+ }
332
+ </style>
333
+ <div class="`+spinnerClass+`">Loading...</div></body></html>`;
334
+ },
335
+
336
+ _createNewWindow: function (img, orientation, plugin) {
337
+ return `<html><head>
338
+ <style>@media print {
339
+ img { max-width: 98%!important; max-height: 98%!important; }
340
+ @page { size: ` + orientation + `;}}
341
+ </style>
342
+ <script>function step1(){
343
+ setTimeout('step2()', 10);}
344
+ function step2(){window.print();window.close()}
345
+ </script></head><body onload='step1()'>
346
+ <img src="` + img + `" style="display:block; margin:auto;"></body></html>`;
347
+ },
348
+
349
+ _createOuterContainer: function (mapDiv) {
350
+ var outerContainer = document.createElement('div');
351
+ mapDiv.parentNode.insertBefore(outerContainer, mapDiv);
352
+ mapDiv.parentNode.removeChild(mapDiv);
353
+ outerContainer.appendChild(mapDiv);
354
+ outerContainer.style.width = mapDiv.style.width;
355
+ outerContainer.style.height = mapDiv.style.height;
356
+ outerContainer.style.display = 'inline-block'
357
+ outerContainer.style.overflow = 'hidden';
358
+ return outerContainer;
359
+ },
360
+
361
+ _removeOuterContainer: function (mapDiv, outerContainer, blankDiv) {
362
+ if (outerContainer.parentNode) {
363
+ outerContainer.parentNode.insertBefore(mapDiv, outerContainer);
364
+ outerContainer.parentNode.removeChild(blankDiv);
365
+ outerContainer.parentNode.removeChild(outerContainer);
366
+ }
367
+ },
368
+
369
+ _addCss: function () {
370
+ var css = document.createElement("style");
371
+ css.type = "text/css";
372
+ css.innerHTML = `.leaflet-control-easyPrint-button {
373
+ background-image: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjE2cHgiIGhlaWdodD0iMTZweCIgdmlld0JveD0iMCAwIDUxMiA1MTIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDU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gUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjE2cHgiIGhlaWdodD0iMTZweCIgdmlld0JveD0iMCAwIDQzMy41IDQzMy41IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA0MzMuNSA0MzMuNTsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8Zz4KCTxnIGlkPSJmaWxlLWRvd25sb2FkIj4KCQk8cGF0aCBkPSJNMzk1LjI1LDE1M2gtMTAyVjBoLTE1M3YxNTNoLTEwMmwxNzguNSwxNzguNUwzOTUuMjUsMTUzeiBNMzguMjUsMzgyLjV2NTFoMzU3di01MUgzOC4yNXoiIGZpbGw9IiMwMDAwMDAiLz4KCTwvZz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K);
379
+ background-size: 16px 16px;
380
+ cursor: pointer;
381
+ }
382
+ .easyPrintHolder a {
383
+ background-size: 16px 16px;
384
+ cursor: pointer;
385
+ }
386
+ .easyPrintHolder .CurrentSize{
387
+ background-image: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCFET0NUWVBF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4Ij4KPGc+Cgk8Zz4KCQk8cGF0aCBkPSJNNTUuMjUsNDQ0LjgzM2gzMzQuMzMzYzkuMzUsMCwxNy03LjY1LDE3LTE3VjEzOS4xMTdjMC00LjgxNy0xLjk4My05LjM1LTUuMzgzLTEyLjQ2N0wyNjkuNzMzLDQuNTMzICAgIEMyNjYuNjE3LDEuNywyNjIuMzY3LDAsMjU4LjExNywwSDU1LjI1Yy05LjM1LDAtMTcsNy42NS0xNywxN3Y0MTAuODMzQzM4LjI1LDQzNy4xODMsNDUuOSw0NDQuODMzLDU1LjI1LDQ0NC44MzN6ICAgICBNMzcyLjU4MywxNDYuNDgzdjAuODVIMjU2LjQxN3YtMTA4LjhMMzcyLjU4MywxNDYuNDgzeiBNNzIuMjUsMzRoMTUwLjE2N3YxMzAuMzMzYzAsOS4zNSw3LjY1LDE3LDE3LDE3aDEzMy4xNjd2MjI5LjVINzIuMjVWMzR6ICAgICIgZmlsbD0iIzAwMDAwMCIvPgoJPC9nPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+Cjwvc3ZnPgo=);
391
+ }
392
+ .easyPrintHolder .A4Landscape {
393
+ transform: rotate(-90deg);
394
+ }
395
+
396
+ .leaflet-control-easyPrint-button{
397
+ display: inline-block;
398
+ }
399
+ .easyPrintHolder{
400
+ margin-top:-31px;
401
+ margin-bottom: -5px;
402
+ margin-left: 30px;
403
+ padding-left: 0px;
404
+ display: none;
405
+ }
406
+
407
+ .easyPrintSizeMode {
408
+ display: inline-block;
409
+ }
410
+ .easyPrintHolder .easyPrintSizeMode a {
411
+ border-radius: 0px;
412
+ }
413
+
414
+ .easyPrintHolder .easyPrintSizeMode:last-child a{
415
+ border-top-right-radius: 2px;
416
+ border-bottom-right-radius: 2px;
417
+ margin-left: -1px;
418
+ }
419
+
420
+ .easyPrintPortrait:hover, .easyPrintLandscape:hover{
421
+ background-color: #757570;
422
+ cursor: pointer;
423
+ }`;
424
+ document.body.appendChild(css);
425
+ },
426
+
427
+ _dataURItoBlob: function (dataURI) {
428
+ var byteString = atob(dataURI.split(',')[1]);
429
+ var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
430
+ var ab = new ArrayBuffer(byteString.length);
431
+ var dw = new DataView(ab);
432
+ for(var i = 0; i < byteString.length; i++) {
433
+ dw.setUint8(i, byteString.charCodeAt(i));
434
+ }
435
+ return new Blob([ab], {type: mimeString});
436
+ },
437
+
438
+ _togglePageSizeButtons: function (e) {
439
+ var holderStyle = this.holder.style
440
+ var linkStyle = this.link.style
441
+ if (e.type === 'mouseover') {
442
+ holderStyle.display = 'block';
443
+ linkStyle.borderTopRightRadius = '0'
444
+ linkStyle.borderBottomRightRadius = '0'
445
+ } else {
446
+ holderStyle.display = 'none';
447
+ linkStyle.borderTopRightRadius = '2px'
448
+ linkStyle.borderBottomRightRadius = '2px'
449
+ }
450
+ },
451
+
452
+ _toggleControls: function (show) {
453
+ var controlContainer = document.getElementsByClassName("leaflet-control-container")[0];
454
+ if (show) return controlContainer.style.display = 'block';
455
+ controlContainer.style.display = 'none';
456
+ },
457
+ _toggleClasses: function (classes, show) {
458
+ classes.forEach(function (className) {
459
+ var div = document.getElementsByClassName(className)[0];
460
+ if (show) return div.style.display = 'block';
461
+ div.style.display = 'none';
462
+ });
463
+ },
464
+
465
+ _a4PageSize: {
466
+ height: 715,
467
+ width: 1045
468
+ }
469
+
470
+ });
471
+
472
+ L.EasyPrint = function(options) {
473
+ return new L.Control.EasyPrint(options);
474
+ };
475
+ console.log("1--"+L.EasyPrint)
476
+
477
+ }
478
+
479
+ export default EasyPrint
package/src/main.js ADDED
@@ -0,0 +1 @@
1
+ import {} from './index.js';