@vouchfor/embeds 0.0.0-experiment.8c5a3f8 → 0.0.0-experiment.8cafed9

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.
Files changed (72) hide show
  1. package/dist/es/browser-DfO9Pnu7.js +921 -0
  2. package/dist/es/browser-DfO9Pnu7.js.map +1 -0
  3. package/dist/es/embeds.js +1 -1599
  4. package/dist/es/embeds.js.map +1 -1
  5. package/dist/es/index-5G8orrrP.js +2609 -0
  6. package/dist/es/index-5G8orrrP.js.map +1 -0
  7. package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +20 -0
  8. package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +36 -0
  9. package/dist/es/src/components/DialogEmbed/index.d.ts +38 -0
  10. package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  11. package/dist/es/src/components/{Embed → PlayerEmbed}/controllers/fetcher.d.ts +5 -4
  12. package/dist/es/src/components/{Embed/controllers/tracking.d.ts → PlayerEmbed/controllers/tracking/index.d.ts} +14 -11
  13. package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  14. package/dist/es/src/components/{Embed → PlayerEmbed}/index.d.ts +28 -21
  15. package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  16. package/dist/es/src/index.d.ts +2 -1
  17. package/dist/iife/dialog-embed/browser-DCzTItVw.js +429 -0
  18. package/dist/iife/dialog-embed/browser-DCzTItVw.js.map +1 -0
  19. package/dist/iife/dialog-embed/embed.iife.js +1750 -0
  20. package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
  21. package/dist/iife/dialog-embed/embed.js +5 -0
  22. package/dist/iife/dialog-embed/embed.js.map +1 -0
  23. package/dist/iife/dialog-embed/index-CgdXxP5z.js +27698 -0
  24. package/dist/iife/dialog-embed/index-CgdXxP5z.js.map +1 -0
  25. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogOverlay.d.ts +20 -0
  26. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogPortal.d.ts +36 -0
  27. package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +38 -0
  28. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  29. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
  30. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  31. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  32. package/dist/iife/dialog-embed/src/components/PlayerEmbed/index.d.ts +74 -0
  33. package/dist/iife/dialog-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  34. package/dist/iife/dialog-embed/src/index.d.ts +2 -0
  35. package/dist/iife/dialog-embed/src/utils/env.d.ts +12 -0
  36. package/dist/iife/dialog-embed/src/utils/events.d.ts +2 -0
  37. package/dist/iife/embeds.iife.js +661 -456
  38. package/dist/iife/embeds.iife.js.map +1 -1
  39. package/dist/iife/player-embed/browser-BBSMddCs.js +429 -0
  40. package/dist/iife/player-embed/browser-BBSMddCs.js.map +1 -0
  41. package/dist/iife/player-embed/embed.iife.js +1612 -0
  42. package/dist/iife/player-embed/embed.iife.js.map +1 -0
  43. package/dist/iife/player-embed/embed.js +5 -0
  44. package/dist/iife/player-embed/embed.js.map +1 -0
  45. package/dist/iife/player-embed/index-BGZl_iqR.js +27255 -0
  46. package/dist/iife/player-embed/index-BGZl_iqR.js.map +1 -0
  47. package/dist/iife/player-embed/src/components/DialogEmbed/DialogOverlay.d.ts +20 -0
  48. package/dist/iife/player-embed/src/components/DialogEmbed/DialogPortal.d.ts +36 -0
  49. package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +38 -0
  50. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  51. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
  52. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  53. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  54. package/dist/iife/player-embed/src/components/PlayerEmbed/index.d.ts +74 -0
  55. package/dist/iife/player-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  56. package/dist/iife/player-embed/src/index.d.ts +2 -0
  57. package/dist/iife/player-embed/src/utils/env.d.ts +12 -0
  58. package/dist/iife/player-embed/src/utils/events.d.ts +2 -0
  59. package/package.json +43 -31
  60. package/src/components/DialogEmbed/Dialog.stories.ts +91 -0
  61. package/src/components/DialogEmbed/DialogOverlay.ts +131 -0
  62. package/src/components/DialogEmbed/DialogPortal.ts +126 -0
  63. package/src/components/DialogEmbed/index.ts +97 -0
  64. package/src/components/{Embed/Embed.stories.ts → PlayerEmbed/PlayerEmbed.stories.ts} +26 -14
  65. package/src/components/{Embed → PlayerEmbed}/controllers/event-forwarder.ts +6 -5
  66. package/src/components/{Embed → PlayerEmbed}/controllers/fetcher.ts +33 -14
  67. package/src/components/{Embed/controllers/tracking.ts → PlayerEmbed/controllers/tracking/index.ts} +47 -115
  68. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +95 -0
  69. package/src/components/{Embed → PlayerEmbed}/index.ts +71 -27
  70. package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +80 -0
  71. package/src/components/PlayerEmbed/tests/data.ts +183 -0
  72. package/src/index.ts +2 -1
@@ -0,0 +1,921 @@
1
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './index-5G8orrrP.js';
2
+
3
+ function _mergeNamespaces(n, m) {
4
+ for (var i = 0; i < m.length; i++) {
5
+ const e = m[i];
6
+ if (typeof e !== 'string' && !Array.isArray(e)) { for (const k in e) {
7
+ if (k !== 'default' && !(k in n)) {
8
+ const d = Object.getOwnPropertyDescriptor(e, k);
9
+ if (d) {
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: () => e[k]
13
+ });
14
+ }
15
+ }
16
+ } }
17
+ }
18
+ return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: 'Module' }));
19
+ }
20
+
21
+ function assertPath(path) {
22
+ if (typeof path !== 'string') {
23
+ throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
24
+ }
25
+ }
26
+
27
+ // Resolves . and .. elements in a path with directory names
28
+ function normalizeStringPosix(path, allowAboveRoot) {
29
+ var res = '';
30
+ var lastSegmentLength = 0;
31
+ var lastSlash = -1;
32
+ var dots = 0;
33
+ var code;
34
+ for (var i = 0; i <= path.length; ++i) {
35
+ if (i < path.length)
36
+ code = path.charCodeAt(i);
37
+ else if (code === 47 /*/*/)
38
+ break;
39
+ else
40
+ code = 47 /*/*/;
41
+ if (code === 47 /*/*/) {
42
+ if (lastSlash === i - 1 || dots === 1) ; else if (lastSlash !== i - 1 && dots === 2) {
43
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
44
+ if (res.length > 2) {
45
+ var lastSlashIndex = res.lastIndexOf('/');
46
+ if (lastSlashIndex !== res.length - 1) {
47
+ if (lastSlashIndex === -1) {
48
+ res = '';
49
+ lastSegmentLength = 0;
50
+ } else {
51
+ res = res.slice(0, lastSlashIndex);
52
+ lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
53
+ }
54
+ lastSlash = i;
55
+ dots = 0;
56
+ continue;
57
+ }
58
+ } else if (res.length === 2 || res.length === 1) {
59
+ res = '';
60
+ lastSegmentLength = 0;
61
+ lastSlash = i;
62
+ dots = 0;
63
+ continue;
64
+ }
65
+ }
66
+ if (allowAboveRoot) {
67
+ if (res.length > 0)
68
+ res += '/..';
69
+ else
70
+ res = '..';
71
+ lastSegmentLength = 2;
72
+ }
73
+ } else {
74
+ if (res.length > 0)
75
+ res += '/' + path.slice(lastSlash + 1, i);
76
+ else
77
+ res = path.slice(lastSlash + 1, i);
78
+ lastSegmentLength = i - lastSlash - 1;
79
+ }
80
+ lastSlash = i;
81
+ dots = 0;
82
+ } else if (code === 46 /*.*/ && dots !== -1) {
83
+ ++dots;
84
+ } else {
85
+ dots = -1;
86
+ }
87
+ }
88
+ return res;
89
+ }
90
+
91
+ function _format(sep, pathObject) {
92
+ var dir = pathObject.dir || pathObject.root;
93
+ var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
94
+ if (!dir) {
95
+ return base;
96
+ }
97
+ if (dir === pathObject.root) {
98
+ return dir + base;
99
+ }
100
+ return dir + sep + base;
101
+ }
102
+
103
+ var posix = {
104
+ // path.resolve([from ...], to)
105
+ resolve: function resolve() {
106
+ var resolvedPath = '';
107
+ var resolvedAbsolute = false;
108
+ var cwd;
109
+
110
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
111
+ var path;
112
+ if (i >= 0)
113
+ path = arguments[i];
114
+ else {
115
+ if (cwd === undefined)
116
+ cwd = process.cwd();
117
+ path = cwd;
118
+ }
119
+
120
+ assertPath(path);
121
+
122
+ // Skip empty entries
123
+ if (path.length === 0) {
124
+ continue;
125
+ }
126
+
127
+ resolvedPath = path + '/' + resolvedPath;
128
+ resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
129
+ }
130
+
131
+ // At this point the path should be resolved to a full absolute path, but
132
+ // handle relative paths to be safe (might happen when process.cwd() fails)
133
+
134
+ // Normalize the path
135
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
136
+
137
+ if (resolvedAbsolute) {
138
+ if (resolvedPath.length > 0)
139
+ return '/' + resolvedPath;
140
+ else
141
+ return '/';
142
+ } else if (resolvedPath.length > 0) {
143
+ return resolvedPath;
144
+ } else {
145
+ return '.';
146
+ }
147
+ },
148
+
149
+ normalize: function normalize(path) {
150
+ assertPath(path);
151
+
152
+ if (path.length === 0) return '.';
153
+
154
+ var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
155
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
156
+
157
+ // Normalize the path
158
+ path = normalizeStringPosix(path, !isAbsolute);
159
+
160
+ if (path.length === 0 && !isAbsolute) path = '.';
161
+ if (path.length > 0 && trailingSeparator) path += '/';
162
+
163
+ if (isAbsolute) return '/' + path;
164
+ return path;
165
+ },
166
+
167
+ isAbsolute: function isAbsolute(path) {
168
+ assertPath(path);
169
+ return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
170
+ },
171
+
172
+ join: function join() {
173
+ if (arguments.length === 0)
174
+ return '.';
175
+ var joined;
176
+ for (var i = 0; i < arguments.length; ++i) {
177
+ var arg = arguments[i];
178
+ assertPath(arg);
179
+ if (arg.length > 0) {
180
+ if (joined === undefined)
181
+ joined = arg;
182
+ else
183
+ joined += '/' + arg;
184
+ }
185
+ }
186
+ if (joined === undefined)
187
+ return '.';
188
+ return posix.normalize(joined);
189
+ },
190
+
191
+ relative: function relative(from, to) {
192
+ assertPath(from);
193
+ assertPath(to);
194
+
195
+ if (from === to) return '';
196
+
197
+ from = posix.resolve(from);
198
+ to = posix.resolve(to);
199
+
200
+ if (from === to) return '';
201
+
202
+ // Trim any leading backslashes
203
+ var fromStart = 1;
204
+ for (; fromStart < from.length; ++fromStart) {
205
+ if (from.charCodeAt(fromStart) !== 47 /*/*/)
206
+ break;
207
+ }
208
+ var fromEnd = from.length;
209
+ var fromLen = fromEnd - fromStart;
210
+
211
+ // Trim any leading backslashes
212
+ var toStart = 1;
213
+ for (; toStart < to.length; ++toStart) {
214
+ if (to.charCodeAt(toStart) !== 47 /*/*/)
215
+ break;
216
+ }
217
+ var toEnd = to.length;
218
+ var toLen = toEnd - toStart;
219
+
220
+ // Compare paths to find the longest common path from root
221
+ var length = fromLen < toLen ? fromLen : toLen;
222
+ var lastCommonSep = -1;
223
+ var i = 0;
224
+ for (; i <= length; ++i) {
225
+ if (i === length) {
226
+ if (toLen > length) {
227
+ if (to.charCodeAt(toStart + i) === 47 /*/*/) {
228
+ // We get here if `from` is the exact base path for `to`.
229
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
230
+ return to.slice(toStart + i + 1);
231
+ } else if (i === 0) {
232
+ // We get here if `from` is the root
233
+ // For example: from='/'; to='/foo'
234
+ return to.slice(toStart + i);
235
+ }
236
+ } else if (fromLen > length) {
237
+ if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
238
+ // We get here if `to` is the exact base path for `from`.
239
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
240
+ lastCommonSep = i;
241
+ } else if (i === 0) {
242
+ // We get here if `to` is the root.
243
+ // For example: from='/foo'; to='/'
244
+ lastCommonSep = 0;
245
+ }
246
+ }
247
+ break;
248
+ }
249
+ var fromCode = from.charCodeAt(fromStart + i);
250
+ var toCode = to.charCodeAt(toStart + i);
251
+ if (fromCode !== toCode)
252
+ break;
253
+ else if (fromCode === 47 /*/*/)
254
+ lastCommonSep = i;
255
+ }
256
+
257
+ var out = '';
258
+ // Generate the relative path based on the path difference between `to`
259
+ // and `from`
260
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
261
+ if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
262
+ if (out.length === 0)
263
+ out += '..';
264
+ else
265
+ out += '/..';
266
+ }
267
+ }
268
+
269
+ // Lastly, append the rest of the destination (`to`) path that comes after
270
+ // the common path parts
271
+ if (out.length > 0)
272
+ return out + to.slice(toStart + lastCommonSep);
273
+ else {
274
+ toStart += lastCommonSep;
275
+ if (to.charCodeAt(toStart) === 47 /*/*/)
276
+ ++toStart;
277
+ return to.slice(toStart);
278
+ }
279
+ },
280
+
281
+ _makeLong: function _makeLong(path) {
282
+ return path;
283
+ },
284
+
285
+ dirname: function dirname(path) {
286
+ assertPath(path);
287
+ if (path.length === 0) return '.';
288
+ var code = path.charCodeAt(0);
289
+ var hasRoot = code === 47 /*/*/;
290
+ var end = -1;
291
+ var matchedSlash = true;
292
+ for (var i = path.length - 1; i >= 1; --i) {
293
+ code = path.charCodeAt(i);
294
+ if (code === 47 /*/*/) {
295
+ if (!matchedSlash) {
296
+ end = i;
297
+ break;
298
+ }
299
+ } else {
300
+ // We saw the first non-path separator
301
+ matchedSlash = false;
302
+ }
303
+ }
304
+
305
+ if (end === -1) return hasRoot ? '/' : '.';
306
+ if (hasRoot && end === 1) return '//';
307
+ return path.slice(0, end);
308
+ },
309
+
310
+ basename: function basename(path, ext) {
311
+ if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
312
+ assertPath(path);
313
+
314
+ var start = 0;
315
+ var end = -1;
316
+ var matchedSlash = true;
317
+ var i;
318
+
319
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
320
+ if (ext.length === path.length && ext === path) return '';
321
+ var extIdx = ext.length - 1;
322
+ var firstNonSlashEnd = -1;
323
+ for (i = path.length - 1; i >= 0; --i) {
324
+ var code = path.charCodeAt(i);
325
+ if (code === 47 /*/*/) {
326
+ // If we reached a path separator that was not part of a set of path
327
+ // separators at the end of the string, stop now
328
+ if (!matchedSlash) {
329
+ start = i + 1;
330
+ break;
331
+ }
332
+ } else {
333
+ if (firstNonSlashEnd === -1) {
334
+ // We saw the first non-path separator, remember this index in case
335
+ // we need it if the extension ends up not matching
336
+ matchedSlash = false;
337
+ firstNonSlashEnd = i + 1;
338
+ }
339
+ if (extIdx >= 0) {
340
+ // Try to match the explicit extension
341
+ if (code === ext.charCodeAt(extIdx)) {
342
+ if (--extIdx === -1) {
343
+ // We matched the extension, so mark this as the end of our path
344
+ // component
345
+ end = i;
346
+ }
347
+ } else {
348
+ // Extension does not match, so our result is the entire path
349
+ // component
350
+ extIdx = -1;
351
+ end = firstNonSlashEnd;
352
+ }
353
+ }
354
+ }
355
+ }
356
+
357
+ if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
358
+ return path.slice(start, end);
359
+ } else {
360
+ for (i = path.length - 1; i >= 0; --i) {
361
+ if (path.charCodeAt(i) === 47 /*/*/) {
362
+ // If we reached a path separator that was not part of a set of path
363
+ // separators at the end of the string, stop now
364
+ if (!matchedSlash) {
365
+ start = i + 1;
366
+ break;
367
+ }
368
+ } else if (end === -1) {
369
+ // We saw the first non-path separator, mark this as the end of our
370
+ // path component
371
+ matchedSlash = false;
372
+ end = i + 1;
373
+ }
374
+ }
375
+
376
+ if (end === -1) return '';
377
+ return path.slice(start, end);
378
+ }
379
+ },
380
+
381
+ extname: function extname(path) {
382
+ assertPath(path);
383
+ var startDot = -1;
384
+ var startPart = 0;
385
+ var end = -1;
386
+ var matchedSlash = true;
387
+ // Track the state of characters (if any) we see before our first dot and
388
+ // after any path separator we find
389
+ var preDotState = 0;
390
+ for (var i = path.length - 1; i >= 0; --i) {
391
+ var code = path.charCodeAt(i);
392
+ if (code === 47 /*/*/) {
393
+ // If we reached a path separator that was not part of a set of path
394
+ // separators at the end of the string, stop now
395
+ if (!matchedSlash) {
396
+ startPart = i + 1;
397
+ break;
398
+ }
399
+ continue;
400
+ }
401
+ if (end === -1) {
402
+ // We saw the first non-path separator, mark this as the end of our
403
+ // extension
404
+ matchedSlash = false;
405
+ end = i + 1;
406
+ }
407
+ if (code === 46 /*.*/) {
408
+ // If this is our first dot, mark it as the start of our extension
409
+ if (startDot === -1)
410
+ startDot = i;
411
+ else if (preDotState !== 1)
412
+ preDotState = 1;
413
+ } else if (startDot !== -1) {
414
+ // We saw a non-dot and non-path separator before our dot, so we should
415
+ // have a good chance at having a non-empty extension
416
+ preDotState = -1;
417
+ }
418
+ }
419
+
420
+ if (startDot === -1 || end === -1 ||
421
+ // We saw a non-dot character immediately before the dot
422
+ preDotState === 0 ||
423
+ // The (right-most) trimmed path component is exactly '..'
424
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
425
+ return '';
426
+ }
427
+ return path.slice(startDot, end);
428
+ },
429
+
430
+ format: function format(pathObject) {
431
+ if (pathObject === null || typeof pathObject !== 'object') {
432
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
433
+ }
434
+ return _format('/', pathObject);
435
+ },
436
+
437
+ parse: function parse(path) {
438
+ assertPath(path);
439
+
440
+ var ret = { root: '', dir: '', base: '', ext: '', name: '' };
441
+ if (path.length === 0) return ret;
442
+ var code = path.charCodeAt(0);
443
+ var isAbsolute = code === 47 /*/*/;
444
+ var start;
445
+ if (isAbsolute) {
446
+ ret.root = '/';
447
+ start = 1;
448
+ } else {
449
+ start = 0;
450
+ }
451
+ var startDot = -1;
452
+ var startPart = 0;
453
+ var end = -1;
454
+ var matchedSlash = true;
455
+ var i = path.length - 1;
456
+
457
+ // Track the state of characters (if any) we see before our first dot and
458
+ // after any path separator we find
459
+ var preDotState = 0;
460
+
461
+ // Get non-dir info
462
+ for (; i >= start; --i) {
463
+ code = path.charCodeAt(i);
464
+ if (code === 47 /*/*/) {
465
+ // If we reached a path separator that was not part of a set of path
466
+ // separators at the end of the string, stop now
467
+ if (!matchedSlash) {
468
+ startPart = i + 1;
469
+ break;
470
+ }
471
+ continue;
472
+ }
473
+ if (end === -1) {
474
+ // We saw the first non-path separator, mark this as the end of our
475
+ // extension
476
+ matchedSlash = false;
477
+ end = i + 1;
478
+ }
479
+ if (code === 46 /*.*/) {
480
+ // If this is our first dot, mark it as the start of our extension
481
+ if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
482
+ } else if (startDot !== -1) {
483
+ // We saw a non-dot and non-path separator before our dot, so we should
484
+ // have a good chance at having a non-empty extension
485
+ preDotState = -1;
486
+ }
487
+ }
488
+
489
+ if (startDot === -1 || end === -1 ||
490
+ // We saw a non-dot character immediately before the dot
491
+ preDotState === 0 ||
492
+ // The (right-most) trimmed path component is exactly '..'
493
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
494
+ if (end !== -1) {
495
+ if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
496
+ }
497
+ } else {
498
+ if (startPart === 0 && isAbsolute) {
499
+ ret.name = path.slice(1, startDot);
500
+ ret.base = path.slice(1, end);
501
+ } else {
502
+ ret.name = path.slice(startPart, startDot);
503
+ ret.base = path.slice(startPart, end);
504
+ }
505
+ ret.ext = path.slice(startDot, end);
506
+ }
507
+
508
+ if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
509
+
510
+ return ret;
511
+ },
512
+
513
+ sep: '/',
514
+ delimiter: ':',
515
+ win32: null,
516
+ posix: null
517
+ };
518
+
519
+ posix.posix = posix;
520
+
521
+ var pathBrowserify = posix;
522
+
523
+ const {basename, extname} = pathBrowserify;
524
+
525
+ //
526
+ // Mime type <-> File extension mappings
527
+ //
528
+
529
+ class Format{
530
+ constructor(){
531
+ let isWeb = (() => typeof commonjsGlobal=='undefined')(),
532
+ png = "image/png",
533
+ jpg = "image/jpeg",
534
+ jpeg = "image/jpeg",
535
+ webp = "image/webp",
536
+ pdf = "application/pdf",
537
+ svg = "image/svg+xml";
538
+
539
+ Object.assign(this, {
540
+ toMime: this.toMime.bind(this),
541
+ fromMime: this.fromMime.bind(this),
542
+ expected: isWeb ? `"png", "jpg", or "webp"`
543
+ : `"png", "jpg", "pdf", or "svg"`,
544
+ formats: isWeb ? {png, jpg, jpeg, webp}
545
+ : {png, jpg, jpeg, pdf, svg},
546
+ mimes: isWeb ? {[png]: "png", [jpg]: "jpg", [webp]: "webp"}
547
+ : {[png]: "png", [jpg]: "jpg", [pdf]: "pdf", [svg]: "svg"},
548
+ });
549
+ }
550
+
551
+ toMime(ext){
552
+ return this.formats[(ext||'').replace(/^\./, '').toLowerCase()]
553
+ }
554
+
555
+ fromMime(mime){
556
+ return this.mimes[mime]
557
+ }
558
+ }
559
+
560
+ //
561
+ // Validation of the options dict shared by the Canvas saveAs, toBuffer, and toDataURL methods
562
+ //
563
+
564
+ function options$1(pages, {filename='', extension='', format, page, quality, matte, density, outline, archive}={}){
565
+ var {fromMime, toMime, expected} = new Format(),
566
+ archive = archive || 'canvas',
567
+ ext = format || extension.replace(/@\d+x$/i,'') || extname(filename),
568
+ format = fromMime(toMime(ext) || ext),
569
+ mime = toMime(format),
570
+ pp = pages.length;
571
+
572
+ if(!ext) throw new Error(`Cannot determine image format (use a filename extension or 'format' argument)`)
573
+ if (!format) throw new Error(`Unsupported file format "${ext}" (expected ${expected})`)
574
+ if (!pp) throw new RangeError(`Canvas has no associated contexts (try calling getContext or newPage first)`)
575
+
576
+ let padding, isSequence, pattern = filename.replace(/{(\d*)}/g, (_, width) => {
577
+ isSequence = true;
578
+ width = parseInt(width, 10);
579
+ padding = isFinite(width) ? width : isFinite(padding) ? padding : -1;
580
+ return "{}"
581
+ });
582
+
583
+ // allow negative indexing if a specific page is specified
584
+ let idx = page > 0 ? page - 1
585
+ : page < 0 ? pp + page
586
+ : undefined;
587
+
588
+ if (isFinite(idx) && idx < 0 || idx >= pp) throw new RangeError(
589
+ pp == 1 ? `Canvas only has a ‘page 1’ (${idx} is out of bounds)`
590
+ : `Canvas has pages 1–${pp} (${idx} is out of bounds)`
591
+ )
592
+
593
+ pages = isFinite(idx) ? [pages[idx]]
594
+ : isSequence || format=='pdf' ? pages
595
+ : pages.slice(-1); // default to the 'current' context
596
+
597
+ if (quality===undefined){
598
+ quality = 0.92;
599
+ }else {
600
+ if (typeof quality!='number' || !isFinite(quality) || quality<0 || quality>1){
601
+ throw new TypeError("The quality option must be an number in the 0.0–1.0 range")
602
+ }
603
+ }
604
+
605
+ if (density===undefined){
606
+ let m = (extension || basename(filename, ext)).match(/@(\d+)x$/i);
607
+ density = m ? parseInt(m[1], 10) : 1;
608
+ }else if (typeof density!='number' || !Number.isInteger(density) || density<1){
609
+ throw new TypeError("The density option must be a non-negative integer")
610
+ }
611
+
612
+ if (outline===undefined){
613
+ outline = true;
614
+ }else if (format == 'svg'){
615
+ outline = !!outline;
616
+ }
617
+
618
+ return {filename, pattern, format, mime, pages, padding, quality, matte, density, outline, archive}
619
+ }
620
+
621
+ //
622
+ // Zip (pace Phil Katz & q.v. https://github.com/jimmywarting/StreamSaver.js)
623
+ //
624
+
625
+ class Crc32 {
626
+ static for(data){
627
+ return new Crc32().append(data).get()
628
+ }
629
+
630
+ constructor(){ this.crc = -1; }
631
+
632
+ get(){ return ~this.crc }
633
+
634
+ append(data){
635
+ var crc = this.crc | 0,
636
+ table = this.table;
637
+ for (var offset = 0, len = data.length | 0; offset < len; offset++) {
638
+ crc = (crc >>> 8) ^ table[(crc ^ data[offset]) & 0xFF];
639
+ }
640
+ this.crc = crc;
641
+ return this
642
+ }
643
+
644
+ }
645
+
646
+ Crc32.prototype.table = (() => {
647
+ var i, j, t, table = [];
648
+ for (i = 0; i < 256; i++) {
649
+ t = i;
650
+ for (j = 0; j < 8; j++) {
651
+ t = (t & 1)
652
+ ? (t >>> 1) ^ 0xEDB88320
653
+ : t >>> 1;
654
+ }
655
+ table[i] = t;
656
+ }
657
+ return table
658
+ })();
659
+
660
+ function calloc(size){
661
+ let array = new Uint8Array(size),
662
+ view = new DataView(array.buffer),
663
+ buf = {
664
+ array, view, size,
665
+ set8(at, to){ view.setUint8(at, to); return buf },
666
+ set16(at, to){ view.setUint16(at, to, true); return buf },
667
+ set32(at, to){ view.setUint32(at, to, true); return buf },
668
+ bytes(at, to){ array.set(to, at); return buf },
669
+ };
670
+ return buf
671
+ }
672
+
673
+ class Zip{
674
+ static encoder = new TextEncoder()
675
+
676
+ constructor(directory){
677
+ let now = new Date();
678
+ Object.assign(this, {
679
+ directory,
680
+ offset: 0,
681
+ files: [],
682
+ time: (((now.getHours() << 6) | now.getMinutes()) << 5) | now.getSeconds() / 2,
683
+ date: ((((now.getFullYear() - 1980) << 4) | (now.getMonth() + 1)) << 5) | now.getDate(),
684
+ });
685
+ this.add(directory);
686
+ }
687
+
688
+ async add(filename, blob){
689
+ let folder = !blob,
690
+ name = Zip.encoder.encode(`${this.directory}/${folder ? '' : filename}`),
691
+ data = new Uint8Array(folder ? 0 : await blob.arrayBuffer()),
692
+ preamble = 30 + name.length,
693
+ descriptor = preamble + data.length,
694
+ postamble = 16,
695
+ {offset} = this;
696
+
697
+ let header = calloc(26)
698
+ .set32(0, 0x08080014) // zip version
699
+ .set16(6, this.time) // time
700
+ .set16(8, this.date) // date
701
+ .set32(10, Crc32.for(data)) // checksum
702
+ .set32(14, data.length) // compressed size (w/ zero compression)
703
+ .set32(18, data.length) // un-compressed size
704
+ .set16(22, name.length); // filename length (utf8 bytes)
705
+ offset += preamble;
706
+
707
+ let payload = calloc(preamble + data.length + postamble)
708
+ .set32(0, 0x04034b50) // local header signature
709
+ .bytes(4, header.array) // ...header fields...
710
+ .bytes(30, name) // filename
711
+ .bytes(preamble, data); // blob bytes
712
+ offset += data.length;
713
+
714
+ payload
715
+ .set32(descriptor, 0x08074b50) // signature
716
+ .bytes(descriptor + 4, header.array.slice(10,22)); // length & filemame
717
+ offset += postamble;
718
+
719
+ this.files.push({offset, folder, name, header, payload});
720
+ this.offset = offset;
721
+ }
722
+
723
+ toBuffer(){
724
+ // central directory record
725
+ let length = this.files.reduce((len, {name}) => 46 + name.length + len, 0),
726
+ cdr = calloc(length + 22),
727
+ index = 0;
728
+
729
+ for (var {offset, name, header, folder} of this.files){
730
+ cdr.set32(index, 0x02014b50) // archive file signature
731
+ .set16(index + 4, 0x0014) // version
732
+ .bytes(index + 6, header.array) // ...header fields...
733
+ .set8(index + 38, folder ? 0x10 : 0) // is_dir flag
734
+ .set32(index + 42, offset) // file offset
735
+ .bytes(index + 46, name); // filename
736
+ index += 46 + name.length;
737
+ }
738
+ cdr.set32(index, 0x06054b50) // signature
739
+ .set16(index + 8, this.files.length) // № files per-segment
740
+ .set16(index + 10, this.files.length) // № files this segment
741
+ .set32(index + 12, length) // central directory length
742
+ .set32(index + 16, this.offset); // file-offset of directory
743
+
744
+ // concatenated zipfile data
745
+ let output = new Uint8Array(this.offset + cdr.size),
746
+ cursor = 0;
747
+
748
+ for (var {payload} of this.files){
749
+ output.set(payload.array, cursor);
750
+ cursor += payload.size;
751
+ }
752
+ output.set(cdr.array, cursor);
753
+
754
+ return output
755
+ }
756
+
757
+ get blob(){
758
+ return new Blob([this.toBuffer()], {type:"application/zip"})
759
+ }
760
+ }
761
+
762
+
763
+ //
764
+ // Browser helpers for converting canvas elements to blobs/buffers/files/zips
765
+ //
766
+
767
+ const asBlob = (canvas, mime, quality, matte) => {
768
+ if (matte){
769
+ let {width, height} = canvas,
770
+ comp = Object.assign(document.createElement('canvas'), {width, height}),
771
+ ctx = comp.getContext("2d");
772
+ ctx.fillStyle = matte;
773
+ ctx.fillRect(0, 0, width, height);
774
+ ctx.drawImage(canvas, 0, 0);
775
+ canvas = comp;
776
+ }
777
+
778
+ return new Promise((res, rej) => canvas.toBlob(res, mime, quality))
779
+ };
780
+
781
+ const asBuffer$1 = (...args) => asBlob(...args).then(b => b.arrayBuffer());
782
+
783
+ const asDownload$1 = async (canvas, mime, quality, matte, filename) => {
784
+ _download(filename, await asBlob(canvas, mime, quality, matte));
785
+ };
786
+
787
+ const asZipDownload$1 = async (pages, mime, quality, matte, archive, pattern, padding) => {
788
+ let filenames = i => pattern.replace('{}', String(i+1).padStart(padding, '0')),
789
+ folder = basename(archive, '.zip') || 'archive',
790
+ zip = new Zip(folder);
791
+
792
+ await Promise.all(pages.map(async (page, i) => {
793
+ let filename = filenames(i); // serialize filename(s) before awaiting
794
+ await zip.add(filename, await asBlob(page, mime, quality, matte));
795
+ }));
796
+
797
+ _download(`${folder}.zip`, zip.blob);
798
+ };
799
+
800
+ const _download = (filename, blob) => {
801
+ const href = window.URL.createObjectURL(blob),
802
+ link = document.createElement('a');
803
+ link.style.display = 'none';
804
+ link.href = href;
805
+ link.setAttribute('download', filename);
806
+ if (typeof link.download === 'undefined') {
807
+ link.setAttribute('target', '_blank');
808
+ }
809
+ document.body.appendChild(link);
810
+ link.click();
811
+ document.body.removeChild(link);
812
+ setTimeout(() => window.URL.revokeObjectURL(href), 100);
813
+ };
814
+
815
+ const atScale$1 = (pages, density, matte) => pages.map(page => {
816
+ if (density == 1 && !matte) return page.canvas
817
+
818
+ let scaled = document.createElement('canvas'),
819
+ ctx = scaled.getContext("2d"),
820
+ src = page.canvas ? page.canvas : page;
821
+ scaled.width = src.width * density;
822
+ scaled.height = src.height * density;
823
+ if (matte){
824
+ ctx.fillStyle = matte;
825
+ ctx.fillRect(0, 0, scaled.width, scaled.height);
826
+ }
827
+ ctx.scale(density, density);
828
+ ctx.drawImage(src, 0, 0);
829
+ return scaled
830
+ });
831
+
832
+ var io = {asBuffer: asBuffer$1, asDownload: asDownload$1, asZipDownload: asZipDownload$1, atScale: atScale$1, options: options$1};
833
+
834
+ const {asBuffer, asDownload, asZipDownload, atScale, options} = io;
835
+
836
+ //
837
+ // Browser equivalents of the skia-canvas convenience initializers and polyfills for
838
+ // the Canvas object’s newPage & export methods
839
+ //
840
+
841
+ const _toURL_ = Symbol.for("toDataURL");
842
+
843
+ const loadImage = src => {
844
+ let img = Object.assign(new Image(), {crossOrigin:'Anonymous', src});
845
+ return img.decode().then(() => img)
846
+ };
847
+
848
+ class Canvas{
849
+ constructor(width, height){
850
+ let elt = document.createElement('canvas'),
851
+ pages = [];
852
+
853
+ Object.defineProperty(elt, "async", {value:true, writable:false, enumerable:true});
854
+
855
+ for (var [prop, get] of Object.entries({
856
+ png: () => asBuffer(elt, 'image/png'),
857
+ jpg: () => asBuffer(elt, 'image/jpeg'),
858
+ pages: () => pages.concat(elt).map(c => c.getContext("2d")),
859
+ })) Object.defineProperty(elt, prop, {get});
860
+
861
+ return Object.assign(elt, {
862
+ width, height,
863
+
864
+ newPage(...size){
865
+ var {width, height} = elt,
866
+ page = Object.assign(document.createElement('canvas'), {width, height});
867
+ page.getContext("2d").drawImage(elt, 0, 0);
868
+ pages.push(page);
869
+
870
+ var [width, height] = size.length ? size : [width, height];
871
+ return Object.assign(elt, {width, height}).getContext("2d")
872
+ },
873
+
874
+ saveAs(filename, args){
875
+ args = typeof args=='number' ? {quality:args} : args;
876
+ let opts = options(this.pages, {filename, ...args}),
877
+ {pattern, padding, mime, quality, matte, density, archive} = opts,
878
+ pages = atScale(opts.pages, density);
879
+ return padding==undefined ? asDownload(pages[0], mime, quality, matte, filename)
880
+ : asZipDownload(pages, mime, quality, matte, archive, pattern, padding)
881
+ },
882
+
883
+ toBuffer(extension="png", args={}){
884
+ args = typeof args=='number' ? {quality:args} : args;
885
+ let opts = options(this.pages, {extension, ...args}),
886
+ {mime, quality, matte, pages, density} = opts,
887
+ canvas = atScale(pages, density, matte)[0];
888
+ return asBuffer(canvas, mime, quality, matte)
889
+ },
890
+
891
+ [_toURL_]: elt.toDataURL.bind(elt),
892
+ toDataURL(extension="png", args={}){
893
+ args = typeof args=='number' ? {quality:args} : args;
894
+ let opts = options(this.pages, {extension, ...args}),
895
+ {mime, quality, matte, pages, density} = opts,
896
+ canvas = atScale(pages, density, matte)[0],
897
+ url = canvas[canvas===elt ? _toURL_ : 'toDataURL'](mime, quality);
898
+ return Promise.resolve(url)
899
+ }
900
+ })
901
+ }
902
+ }
903
+
904
+ const {CanvasRenderingContext2D, CanvasGradient, CanvasPattern,
905
+ Image, ImageData, Path2D, DOMMatrix, DOMRect, DOMPoint} = window;
906
+
907
+ var browser = {
908
+ Canvas, loadImage,
909
+ CanvasRenderingContext2D, CanvasGradient, CanvasPattern,
910
+ Image, ImageData, Path2D, DOMMatrix, DOMRect, DOMPoint
911
+ };
912
+
913
+ const browser$1 = /*@__PURE__*/getDefaultExportFromCjs(browser);
914
+
915
+ const browser$2 = /*#__PURE__*/_mergeNamespaces({
916
+ __proto__: null,
917
+ default: browser$1
918
+ }, [browser]);
919
+
920
+ export { browser$2 as b };
921
+ //# sourceMappingURL=browser-DfO9Pnu7.js.map