react-smart-copy 1.17.2 → 1.19.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.
Files changed (154) hide show
  1. package/README.md +86 -5
  2. package/dist/capture.cjs +30 -153
  3. package/dist/capture.cjs.map +1 -1
  4. package/dist/capture.d.cts +2 -25
  5. package/dist/capture.d.ts +2 -25
  6. package/dist/capture.js +5 -128
  7. package/dist/capture.js.map +1 -1
  8. package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs +102 -0
  9. package/dist/chunks/clipboard-adapter-Cfz-rzw3.cjs.map +1 -0
  10. package/dist/chunks/clipboard-adapter-CtH4VELE.d.cts +43 -0
  11. package/dist/chunks/clipboard-adapter-DEXkXxwV.js +97 -0
  12. package/dist/chunks/clipboard-adapter-DEXkXxwV.js.map +1 -0
  13. package/dist/chunks/clipboard-adapter-Ds0irroN.d.ts +43 -0
  14. package/dist/chunks/contrast-C6CVklEI.cjs +842 -0
  15. package/dist/chunks/contrast-C6CVklEI.cjs.map +1 -0
  16. package/dist/chunks/contrast-DpK2JIVu.js +789 -0
  17. package/dist/chunks/contrast-DpK2JIVu.js.map +1 -0
  18. package/dist/chunks/copy-interceptor-C6NABy1l.d.ts +141 -0
  19. package/dist/chunks/copy-interceptor-CZWzGOkL.d.cts +141 -0
  20. package/dist/chunks/core-Cp2HSpaz.js +1035 -0
  21. package/dist/chunks/core-Cp2HSpaz.js.map +1 -0
  22. package/dist/chunks/core-DYf_Lhbe.cjs +1142 -0
  23. package/dist/chunks/core-DYf_Lhbe.cjs.map +1 -0
  24. package/dist/chunks/deadline-C29AlS_Q.js +46 -0
  25. package/dist/chunks/deadline-C29AlS_Q.js.map +1 -0
  26. package/dist/chunks/deadline-DkiB8ZHE.cjs +51 -0
  27. package/dist/chunks/deadline-DkiB8ZHE.cjs.map +1 -0
  28. package/dist/chunks/errors-9h8sdFFX.js +120 -0
  29. package/dist/chunks/errors-9h8sdFFX.js.map +1 -0
  30. package/dist/chunks/errors-BwOF6T_M.cjs +167 -0
  31. package/dist/chunks/errors-BwOF6T_M.cjs.map +1 -0
  32. package/dist/chunks/index-mr7sSAgP.d.ts +426 -0
  33. package/dist/chunks/index-vz0iW5V2.d.cts +426 -0
  34. package/dist/chunks/inert-html-D75NyVvT.js +34 -0
  35. package/dist/chunks/inert-html-D75NyVvT.js.map +1 -0
  36. package/dist/chunks/inert-html-DyxjWDok.cjs +39 -0
  37. package/dist/chunks/inert-html-DyxjWDok.cjs.map +1 -0
  38. package/dist/chunks/mime--LB7kdqG.cjs +153 -0
  39. package/dist/chunks/mime--LB7kdqG.cjs.map +1 -0
  40. package/dist/chunks/mime-aa-HA2dm.js +100 -0
  41. package/dist/chunks/mime-aa-HA2dm.js.map +1 -0
  42. package/dist/chunks/paste-adapter--SPL4PRE.d.cts +35 -0
  43. package/dist/chunks/paste-adapter-uahXnTYk.d.ts +35 -0
  44. package/dist/chunks/paste-reader-Bo01IMC_.cjs +289 -0
  45. package/dist/chunks/paste-reader-Bo01IMC_.cjs.map +1 -0
  46. package/dist/chunks/paste-reader-D9i7yMXF.js +224 -0
  47. package/dist/chunks/paste-reader-D9i7yMXF.js.map +1 -0
  48. package/dist/chunks/paste-reader-DcXnRWQr.d.cts +96 -0
  49. package/dist/chunks/paste-reader-DcXnRWQr.d.ts +96 -0
  50. package/dist/chunks/payload-CUymxwim.cjs +100 -0
  51. package/dist/chunks/payload-CUymxwim.cjs.map +1 -0
  52. package/dist/chunks/payload-CcwKJ_bU.d.cts +162 -0
  53. package/dist/chunks/payload-Cl_8hCI5.d.ts +162 -0
  54. package/dist/chunks/payload-DGw-JOo7.js +71 -0
  55. package/dist/chunks/payload-DGw-JOo7.js.map +1 -0
  56. package/dist/chunks/payload-DI5AorDz.js +103 -0
  57. package/dist/chunks/payload-DI5AorDz.js.map +1 -0
  58. package/dist/chunks/payload-J6GjHuh3.cjs +132 -0
  59. package/dist/chunks/payload-J6GjHuh3.cjs.map +1 -0
  60. package/dist/chunks/share-Bop47Znn.js +208 -0
  61. package/dist/chunks/share-Bop47Znn.js.map +1 -0
  62. package/dist/chunks/share-C0esXvRK.d.cts +115 -0
  63. package/dist/chunks/share-ayDz974N.cjs +231 -0
  64. package/dist/chunks/share-ayDz974N.cjs.map +1 -0
  65. package/dist/chunks/share-e7FenIr2.d.ts +115 -0
  66. package/dist/chunks/text-field-Ba8W3v4R.cjs +77 -0
  67. package/dist/chunks/text-field-Ba8W3v4R.cjs.map +1 -0
  68. package/dist/chunks/text-field-C0SGmvvR.d.cts +18 -0
  69. package/dist/chunks/text-field-C0SGmvvR.d.ts +18 -0
  70. package/dist/chunks/text-field-DUvrMMaK.js +66 -0
  71. package/dist/chunks/text-field-DUvrMMaK.js.map +1 -0
  72. package/dist/chunks/url-B9jdFGQy.cjs +86 -0
  73. package/dist/chunks/url-B9jdFGQy.cjs.map +1 -0
  74. package/dist/chunks/url-BcMYVCXQ.js +135 -0
  75. package/dist/chunks/url-BcMYVCXQ.js.map +1 -0
  76. package/dist/chunks/url-D4PGsRm8.cjs +164 -0
  77. package/dist/chunks/url-D4PGsRm8.cjs.map +1 -0
  78. package/dist/chunks/url-DWdElCT3.d.cts +43 -0
  79. package/dist/chunks/url-DWdElCT3.d.ts +43 -0
  80. package/dist/chunks/url-vJaFPbNL.js +57 -0
  81. package/dist/chunks/url-vJaFPbNL.js.map +1 -0
  82. package/dist/code.cjs +22 -113
  83. package/dist/code.cjs.map +1 -1
  84. package/dist/code.d.cts +4 -28
  85. package/dist/code.d.ts +4 -28
  86. package/dist/code.js +5 -96
  87. package/dist/code.js.map +1 -1
  88. package/dist/color.cjs +21 -893
  89. package/dist/color.cjs.map +1 -1
  90. package/dist/color.d.cts +4 -28
  91. package/dist/color.d.ts +4 -28
  92. package/dist/color.js +4 -876
  93. package/dist/color.js.map +1 -1
  94. package/dist/core.cjs +52 -1659
  95. package/dist/core.d.cts +8 -878
  96. package/dist/core.d.ts +8 -878
  97. package/dist/core.js +7 -1614
  98. package/dist/image.cjs +23 -94
  99. package/dist/image.cjs.map +1 -1
  100. package/dist/image.d.cts +1 -0
  101. package/dist/image.d.ts +1 -0
  102. package/dist/image.js +3 -74
  103. package/dist/image.js.map +1 -1
  104. package/dist/index.cjs +74 -2072
  105. package/dist/index.cjs.map +1 -1
  106. package/dist/index.d.cts +8 -978
  107. package/dist/index.d.ts +8 -978
  108. package/dist/index.js +7 -2005
  109. package/dist/index.js.map +1 -1
  110. package/dist/link.cjs +26 -339
  111. package/dist/link.cjs.map +1 -1
  112. package/dist/link.d.cts +5 -83
  113. package/dist/link.d.ts +5 -83
  114. package/dist/link.js +7 -320
  115. package/dist/link.js.map +1 -1
  116. package/dist/markdown.cjs +19 -159
  117. package/dist/markdown.cjs.map +1 -1
  118. package/dist/markdown.d.cts +3 -16
  119. package/dist/markdown.d.ts +3 -16
  120. package/dist/markdown.js +6 -146
  121. package/dist/markdown.js.map +1 -1
  122. package/dist/rich.cjs +1123 -940
  123. package/dist/rich.cjs.map +1 -1
  124. package/dist/rich.d.cts +101 -91
  125. package/dist/rich.d.ts +101 -91
  126. package/dist/rich.js +1099 -919
  127. package/dist/rich.js.map +1 -1
  128. package/dist/share.cjs +5 -640
  129. package/dist/share.d.cts +3 -248
  130. package/dist/share.d.ts +3 -248
  131. package/dist/share.js +1 -637
  132. package/dist/structured.cjs +13 -95
  133. package/dist/structured.cjs.map +1 -1
  134. package/dist/structured.d.cts +2 -11
  135. package/dist/structured.d.ts +2 -11
  136. package/dist/structured.js +4 -86
  137. package/dist/structured.js.map +1 -1
  138. package/dist/table.cjs +13 -40
  139. package/dist/table.cjs.map +1 -1
  140. package/dist/table.d.cts +2 -12
  141. package/dist/table.d.ts +2 -12
  142. package/dist/table.js +4 -31
  143. package/dist/table.js.map +1 -1
  144. package/dist/testing.cjs +10 -43
  145. package/dist/testing.cjs.map +1 -1
  146. package/dist/testing.d.cts +6 -181
  147. package/dist/testing.d.ts +6 -181
  148. package/dist/testing.js +3 -36
  149. package/dist/testing.js.map +1 -1
  150. package/package.json +37 -5
  151. package/dist/core.cjs.map +0 -1
  152. package/dist/core.js.map +0 -1
  153. package/dist/share.cjs.map +0 -1
  154. package/dist/share.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mime--LB7kdqG.cjs","names":[],"sources":["../../src/core/mime.ts"],"sourcesContent":["/**\n * MIME helpers shared by paste and capture. Everything that comes from the\n * clipboard is untrusted input, so types are normalised and validated before\n * they are compared, and image types are confirmed from the bytes themselves.\n */\n\n/** RFC 6838 token shape, lower-cased. Parameters (`;charset=…`) are stripped first. */\nconst MIME_SHAPE = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}\\/[a-z0-9][a-z0-9!#$&^_.+-]{0,126}$/;\n\n/** SVG is XML that can carry scripts; it is never matched by a wildcard. */\nexport const SVG_MIME_TYPE = 'image/svg+xml';\n\n/** Lower-cased `type/subtype` without parameters, or `null` if it is not a valid MIME type. */\nexport function normalizeMimeType(value: string): string | null {\n const separator = value.indexOf(';');\n const base = (separator === -1 ? value : value.slice(0, separator)).trim().toLowerCase();\n return MIME_SHAPE.test(base) ? base : null;\n}\n\n/** Prefix of the async Clipboard API's web custom formats (`web application/vnd.acme+json`). */\nexport const WEB_CUSTOM_FORMAT_PREFIX = 'web ';\n\n/** Whether a clipboard type is a web custom format (`web type/subtype`). */\nexport function isWebCustomFormat(type: string): boolean {\n return type.slice(0, 4).toLowerCase() === WEB_CUSTOM_FORMAT_PREFIX;\n}\n\n/**\n * Like {@link normalizeMimeType}, but also accepts web custom formats\n * (`web type/subtype`), returned as `web ` + the normalised MIME type.\n */\nexport function normalizeClipboardType(value: string): string | null {\n if (!isWebCustomFormat(value)) return normalizeMimeType(value);\n const inner = normalizeMimeType(value.slice(4));\n return inner === null ? null : WEB_CUSTOM_FORMAT_PREFIX + inner;\n}\n\n/**\n * Types a wildcard never matches, so accepting them must be explicit:\n * `image/svg+xml` (scriptable XML), web custom formats and structured `+json` types\n * (application-specific data that only the app that defined them should read).\n */\nfunction requiresExactMatch(mimeType: string): boolean {\n return mimeType === SVG_MIME_TYPE || isWebCustomFormat(mimeType) || mimeType.endsWith('+json');\n}\n\n/**\n * Does `mimeType` (already normalised) match `pattern` (`type/subtype`, `type/*` or `*\\/*`)?\n * Wildcards never match `image/svg+xml`, web custom formats or `+json` types: those must be listed exactly.\n */\nexport function matchesMimePattern(mimeType: string, pattern: string): boolean {\n if (pattern === mimeType) return true;\n if (requiresExactMatch(mimeType)) return false;\n if (pattern === '*/*') return true;\n return pattern.endsWith('/*') && mimeType.startsWith(pattern.slice(0, -1));\n}\n\n/** Types whose clipboard data is text and is therefore surfaced as a `string`. */\nexport function isTextualMimeType(mimeType: string): boolean {\n const type = isWebCustomFormat(mimeType) ? mimeType.slice(4) : mimeType;\n return (\n type.startsWith('text/') ||\n type === SVG_MIME_TYPE ||\n type === 'application/json' ||\n type === 'application/xml' ||\n type.endsWith('+json')\n );\n}\n\n/** Raster image formats recognised from their leading bytes. */\nexport type RasterImageMimeType = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp' | 'image/bmp' | 'image/avif';\n\nconst SNIFF_BYTES = 16;\n\nfunction startsWith(bytes: Uint8Array, signature: readonly number[], offset = 0): boolean {\n return signature.every((byte, index) => bytes[offset + index] === byte);\n}\n\nconst ascii = (text: string): number[] => Array.from(text, (char) => char.charCodeAt(0));\n\nconst PNG = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];\nconst JPEG = [0xff, 0xd8, 0xff];\nconst GIF = ascii('GIF8');\nconst RIFF = ascii('RIFF');\nconst WEBP = ascii('WEBP');\nconst BMP = ascii('BM');\nconst FTYP_AVIF = ascii('ftypavif');\nconst FTYP_AVIS = ascii('ftypavis');\n\n/** Identifies a raster image from its magic bytes, ignoring whatever type the Blob claims. */\nexport function sniffImageBytes(bytes: Uint8Array): RasterImageMimeType | null {\n if (startsWith(bytes, PNG)) return 'image/png';\n if (startsWith(bytes, JPEG)) return 'image/jpeg';\n if (startsWith(bytes, GIF)) return 'image/gif';\n if (startsWith(bytes, RIFF) && startsWith(bytes, WEBP, 8)) return 'image/webp';\n if (startsWith(bytes, FTYP_AVIF, 4) || startsWith(bytes, FTYP_AVIS, 4)) return 'image/avif';\n if (startsWith(bytes, BMP)) return 'image/bmp';\n return null;\n}\n\n/** Reads only the first bytes of a Blob, so sniffing a 20 MB screenshot stays cheap. */\nexport async function sniffImageType(blob: Blob): Promise<RasterImageMimeType | null> {\n const head = await blob.slice(0, SNIFF_BYTES).arrayBuffer();\n return sniffImageBytes(new Uint8Array(head));\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,aAAa;;AAGnB,MAAa,gBAAgB;;AAG7B,SAAgB,kBAAkB,OAA8B;CAC9D,MAAM,YAAY,MAAM,QAAQ,GAAG;CACnC,MAAM,QAAQ,cAAc,KAAK,QAAQ,MAAM,MAAM,GAAG,SAAS,EAAA,CAAG,KAAK,CAAC,CAAC,YAAY;CACvF,OAAO,WAAW,KAAK,IAAI,IAAI,OAAO;AACxC;;AAGA,MAAa,2BAA2B;;AAGxC,SAAgB,kBAAkB,MAAuB;CACvD,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,YAAY,MAAM;AAC5C;;;;;AAMA,SAAgB,uBAAuB,OAA8B;CACnE,IAAI,CAAC,kBAAkB,KAAK,GAAG,OAAO,kBAAkB,KAAK;CAC7D,MAAM,QAAQ,kBAAkB,MAAM,MAAM,CAAC,CAAC;CAC9C,OAAO,UAAU,OAAO,OAAO,2BAA2B;AAC5D;;;;;;AAOA,SAAS,mBAAmB,UAA2B;CACrD,OAAO,aAAA,mBAA8B,kBAAkB,QAAQ,KAAK,SAAS,SAAS,OAAO;AAC/F;;;;;AAMA,SAAgB,mBAAmB,UAAkB,SAA0B;CAC7E,IAAI,YAAY,UAAU,OAAO;CACjC,IAAI,mBAAmB,QAAQ,GAAG,OAAO;CACzC,IAAI,YAAY,OAAO,OAAO;CAC9B,OAAO,QAAQ,SAAS,I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gBAAgB,IAAI,WAAW,IAAI,CAAC;AAC7C"}
@@ -0,0 +1,100 @@
1
+
2
+ //#region src/core/mime.ts
3
+ /**
4
+ * MIME helpers shared by paste and capture. Everything that comes from the
5
+ * clipboard is untrusted input, so types are normalised and validated before
6
+ * they are compared, and image types are confirmed from the bytes themselves.
7
+ */
8
+ /** RFC 6838 token shape, lower-cased. Parameters (`;charset=…`) are stripped first. */
9
+ const MIME_SHAPE = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}\/[a-z0-9][a-z0-9!#$&^_.+-]{0,126}$/;
10
+ /** SVG is XML that can carry scripts; it is never matched by a wildcard. */
11
+ const SVG_MIME_TYPE = "image/svg+xml";
12
+ /** Lower-cased `type/subtype` without parameters, or `null` if it is not a valid MIME type. */
13
+ function normalizeMimeType(value) {
14
+ const separator = value.indexOf(";");
15
+ const base = (separator === -1 ? value : value.slice(0, separator)).trim().toLowerCase();
16
+ return MIME_SHAPE.test(base) ? base : null;
17
+ }
18
+ /** Prefix of the async Clipboard API's web custom formats (`web application/vnd.acme+json`). */
19
+ const WEB_CUSTOM_FORMAT_PREFIX = "web ";
20
+ /** Whether a clipboard type is a web custom format (`web type/subtype`). */
21
+ function isWebCustomFormat(type) {
22
+ return type.slice(0, 4).toLowerCase() === WEB_CUSTOM_FORMAT_PREFIX;
23
+ }
24
+ /**
25
+ * Like {@link normalizeMimeType}, but also accepts web custom formats
26
+ * (`web type/subtype`), returned as `web ` + the normalised MIME type.
27
+ */
28
+ function normalizeClipboardType(value) {
29
+ if (!isWebCustomFormat(value)) return normalizeMimeType(value);
30
+ const inner = normalizeMimeType(value.slice(4));
31
+ return inner === null ? null : WEB_CUSTOM_FORMAT_PREFIX + inner;
32
+ }
33
+ /**
34
+ * Types a wildcard never matches, so accepting them must be explicit:
35
+ * `image/svg+xml` (scriptable XML), web custom formats and structured `+json` types
36
+ * (application-specific data that only the app that defined them should read).
37
+ */
38
+ function requiresExactMatch(mimeType) {
39
+ return mimeType === "image/svg+xml" || isWebCustomFormat(mimeType) || mimeType.endsWith("+json");
40
+ }
41
+ /**
42
+ * Does `mimeType` (already normalised) match `pattern` (`type/subtype`, `type/*` or `*\/*`)?
43
+ * Wildcards never match `image/svg+xml`, web custom formats or `+json` types: those must be listed exactly.
44
+ */
45
+ function matchesMimePattern(mimeType, pattern) {
46
+ if (pattern === mimeType) return true;
47
+ if (requiresExactMatch(mimeType)) return false;
48
+ if (pattern === "*/*") return true;
49
+ return pattern.endsWith("/*") && mimeType.startsWith(pattern.slice(0, -1));
50
+ }
51
+ /** Types whose clipboard data is text and is therefore surfaced as a `string`. */
52
+ function isTextualMimeType(mimeType) {
53
+ const type = isWebCustomFormat(mimeType) ? mimeType.slice(4) : mimeType;
54
+ return type.startsWith("text/") || type === "image/svg+xml" || type === "application/json" || type === "application/xml" || type.endsWith("+json");
55
+ }
56
+ const SNIFF_BYTES = 16;
57
+ function startsWith(bytes, signature, offset = 0) {
58
+ return signature.every((byte, index) => bytes[offset + index] === byte);
59
+ }
60
+ const ascii = (text) => Array.from(text, (char) => char.charCodeAt(0));
61
+ const PNG = [
62
+ 137,
63
+ 80,
64
+ 78,
65
+ 71,
66
+ 13,
67
+ 10,
68
+ 26,
69
+ 10
70
+ ];
71
+ const JPEG = [
72
+ 255,
73
+ 216,
74
+ 255
75
+ ];
76
+ const GIF = ascii("GIF8");
77
+ const RIFF = ascii("RIFF");
78
+ const WEBP = ascii("WEBP");
79
+ const BMP = ascii("BM");
80
+ const FTYP_AVIF = ascii("ftypavif");
81
+ const FTYP_AVIS = ascii("ftypavis");
82
+ /** Identifies a raster image from its magic bytes, ignoring whatever type the Blob claims. */
83
+ function sniffImageBytes(bytes) {
84
+ if (startsWith(bytes, PNG)) return "image/png";
85
+ if (startsWith(bytes, JPEG)) return "image/jpeg";
86
+ if (startsWith(bytes, GIF)) return "image/gif";
87
+ if (startsWith(bytes, RIFF) && startsWith(bytes, WEBP, 8)) return "image/webp";
88
+ if (startsWith(bytes, FTYP_AVIF, 4) || startsWith(bytes, FTYP_AVIS, 4)) return "image/avif";
89
+ if (startsWith(bytes, BMP)) return "image/bmp";
90
+ return null;
91
+ }
92
+ /** Reads only the first bytes of a Blob, so sniffing a 20 MB screenshot stays cheap. */
93
+ async function sniffImageType(blob) {
94
+ const head = await blob.slice(0, SNIFF_BYTES).arrayBuffer();
95
+ return sniffImageBytes(new Uint8Array(head));
96
+ }
97
+ //#endregion
98
+ export { matchesMimePattern as a, sniffImageBytes as c, isWebCustomFormat as i, sniffImageType as l, WEB_CUSTOM_FORMAT_PREFIX as n, normalizeClipboardType as o, isTextualMimeType as r, normalizeMimeType as s, SVG_MIME_TYPE as t };
99
+
100
+ //# sourceMappingURL=mime-aa-HA2dm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mime-aa-HA2dm.js","names":[],"sources":["../../src/core/mime.ts"],"sourcesContent":["/**\n * MIME helpers shared by paste and capture. Everything that comes from the\n * clipboard is untrusted input, so types are normalised and validated before\n * they are compared, and image types are confirmed from the bytes themselves.\n */\n\n/** RFC 6838 token shape, lower-cased. Parameters (`;charset=…`) are stripped first. */\nconst MIME_SHAPE = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}\\/[a-z0-9][a-z0-9!#$&^_.+-]{0,126}$/;\n\n/** SVG is XML that can carry scripts; it is never matched by a wildcard. */\nexport const SVG_MIME_TYPE = 'image/svg+xml';\n\n/** Lower-cased `type/subtype` without parameters, or `null` if it is not a valid MIME type. */\nexport function normalizeMimeType(value: string): string | null {\n const separator = value.indexOf(';');\n const base = (separator === -1 ? value : value.slice(0, separator)).trim().toLowerCase();\n return MIME_SHAPE.test(base) ? base : null;\n}\n\n/** Prefix of the async Clipboard API's web custom formats (`web application/vnd.acme+json`). */\nexport const WEB_CUSTOM_FORMAT_PREFIX = 'web ';\n\n/** Whether a clipboard type is a web custom format (`web type/subtype`). */\nexport function isWebCustomFormat(type: string): boolean {\n return type.slice(0, 4).toLowerCase() === WEB_CUSTOM_FORMAT_PREFIX;\n}\n\n/**\n * Like {@link normalizeMimeType}, but also accepts web custom formats\n * (`web type/subtype`), returned as `web ` + the normalised MIME type.\n */\nexport function normalizeClipboardType(value: string): string | null {\n if (!isWebCustomFormat(value)) return normalizeMimeType(value);\n const inner = normalizeMimeType(value.slice(4));\n return inner === null ? null : WEB_CUSTOM_FORMAT_PREFIX + inner;\n}\n\n/**\n * Types a wildcard never matches, so accepting them must be explicit:\n * `image/svg+xml` (scriptable XML), web custom formats and structured `+json` types\n * (application-specific data that only the app that defined them should read).\n */\nfunction requiresExactMatch(mimeType: string): boolean {\n return mimeType === SVG_MIME_TYPE || isWebCustomFormat(mimeType) || mimeType.endsWith('+json');\n}\n\n/**\n * Does `mimeType` (already normalised) match `pattern` (`type/subtype`, `type/*` or `*\\/*`)?\n * Wildcards never match `image/svg+xml`, web custom formats or `+json` types: those must be listed exactly.\n */\nexport function matchesMimePattern(mimeType: string, pattern: string): boolean {\n if (pattern === mimeType) return true;\n if (requiresExactMatch(mimeType)) return false;\n if (pattern === '*/*') return true;\n return pattern.endsWith('/*') && mimeType.startsWith(pattern.slice(0, -1));\n}\n\n/** Types whose clipboard data is text and is therefore surfaced as a `string`. */\nexport function isTextualMimeType(mimeType: string): boolean {\n const type = isWebCustomFormat(mimeType) ? mimeType.slice(4) : mimeType;\n return (\n type.startsWith('text/') ||\n type === SVG_MIME_TYPE ||\n type === 'application/json' ||\n type === 'application/xml' ||\n type.endsWith('+json')\n );\n}\n\n/** Raster image formats recognised from their leading bytes. */\nexport type RasterImageMimeType = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp' | 'image/bmp' | 'image/avif';\n\nconst SNIFF_BYTES = 16;\n\nfunction startsWith(bytes: Uint8Array, signature: readonly number[], offset = 0): boolean {\n return signature.every((byte, index) => bytes[offset + index] === byte);\n}\n\nconst ascii = (text: string): number[] => Array.from(text, (char) => char.charCodeAt(0));\n\nconst PNG = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];\nconst JPEG = [0xff, 0xd8, 0xff];\nconst GIF = ascii('GIF8');\nconst RIFF = ascii('RIFF');\nconst WEBP = ascii('WEBP');\nconst BMP = ascii('BM');\nconst FTYP_AVIF = ascii('ftypavif');\nconst FTYP_AVIS = ascii('ftypavis');\n\n/** Identifies a raster image from its magic bytes, ignoring whatever type the Blob claims. */\nexport function sniffImageBytes(bytes: Uint8Array): RasterImageMimeType | null {\n if (startsWith(bytes, PNG)) return 'image/png';\n if (startsWith(bytes, JPEG)) return 'image/jpeg';\n if (startsWith(bytes, GIF)) return 'image/gif';\n if (startsWith(bytes, RIFF) && startsWith(bytes, WEBP, 8)) return 'image/webp';\n if (startsWith(bytes, FTYP_AVIF, 4) || startsWith(bytes, FTYP_AVIS, 4)) return 'image/avif';\n if (startsWith(bytes, BMP)) return 'image/bmp';\n return null;\n}\n\n/** Reads only the first bytes of a Blob, so sniffing a 20 MB screenshot stays cheap. */\nexport async function sniffImageType(blob: Blob): Promise<RasterImageMimeType | null> {\n const head = await blob.slice(0, SNIFF_BYTES).arrayBuffer();\n return sniffImageBytes(new Uint8Array(head));\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,aAAa;;AAGnB,MAAa,gBAAgB;;AAG7B,SAAgB,kBAAkB,OAA8B;CAC9D,MAAM,YAAY,MAAM,QAAQ,GAAG;CACnC,MAAM,QAAQ,cAAc,KAAK,QAAQ,MAAM,MAAM,GAAG,SAAS,EAAA,CAAG,KAAK,CAAC,CAAC,YAAY;CACvF,OAAO,WAAW,KAAK,IAAI,IAAI,OAAO;AACxC;;AAGA,MAAa,2BAA2B;;AAGxC,SAAgB,kBAAkB,MAAuB;CACvD,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,YAAY,MAAM;AAC5C;;;;;AAMA,SAAgB,uBAAuB,OAA8B;CACnE,IAAI,CAAC,kBAAkB,KAAK,GAAG,OAAO,kBAAkB,KAAK;CAC7D,MAAM,QAAQ,kBAAkB,MAAM,MAAM,CAAC,CAA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G,OAAO;CACnC,IAAI,WAAW,OAAO,IAAI,KAAK,WAAW,OAAO,MAAM,CAAC,GAAG,OAAO;CAClE,IAAI,WAAW,OAAO,WAAW,CAAC,KAAK,WAAW,OAAO,WAAW,CAAC,GAAG,OAAO;CAC/E,IAAI,WAAW,OAAO,GAAG,GAAG,OAAO;CACnC,OAAO;AACT;;AAGA,eAAsB,eAAe,MAAiD;CACpF,MAAM,OAAO,MAAM,KAAK,MAAM,GAAG,WAAW,CAAC,CAAC,YAAY;CAC1D,OAAO,gBAAgB,IAAI,WAAW,IAAI,CAAC;AAC7C"}
@@ -0,0 +1,35 @@
1
+
2
+ import { k as OperationContext } from "./payload-CcwKJ_bU.cjs";
3
+ import { f as PasteReadResult, h as ResolvedPasteReadOptions, t as ClipboardItemLike } from "./paste-reader-DcXnRWQr.cjs";
4
+ //#region src/core/paste-adapter.d.ts
5
+ /** Minimal structural view of `navigator.clipboard` for reading. */
6
+ interface PasteClipboardLike {
7
+ read?(): Promise<readonly ClipboardItemLike[]>;
8
+ readText?(): Promise<string>;
9
+ }
10
+ interface PasteEnvironment {
11
+ readonly isSecureContext?: boolean;
12
+ readonly navigator?: {
13
+ readonly clipboard?: PasteClipboardLike | undefined;
14
+ } | undefined;
15
+ }
16
+ /**
17
+ * Reads the system clipboard. Implement it for Electron, a native bridge or tests.
18
+ *
19
+ * Contract: call the platform API synchronously (before any `await`) so the
20
+ * browser still sees the user gesture, and reject with a `CopyFailure`.
21
+ * `context.signal` aborts when the read is superseded, reset, or its host
22
+ * unmounts; honour it to stop decoding early.
23
+ */
24
+ interface PasteAdapter {
25
+ read(options: ResolvedPasteReadOptions, context?: OperationContext): Promise<PasteReadResult>;
26
+ }
27
+ interface BrowserPasteAdapterOptions {
28
+ /** Defaults to `window`, read lazily at paste time (SSR-safe). */
29
+ readonly getEnvironment?: () => PasteEnvironment | undefined;
30
+ }
31
+ /** The default paste adapter: async Clipboard API with feature detection and honest errors. */
32
+ declare function createBrowserPasteAdapter(options?: BrowserPasteAdapterOptions): PasteAdapter;
33
+ //#endregion
34
+ export { createBrowserPasteAdapter as a, PasteEnvironment as i, PasteAdapter as n, PasteClipboardLike as r, BrowserPasteAdapterOptions as t };
35
+ //# sourceMappingURL=paste-adapter--SPL4PRE.d.cts.map
@@ -0,0 +1,35 @@
1
+
2
+ import { k as OperationContext } from "./payload-Cl_8hCI5.js";
3
+ import { f as PasteReadResult, h as ResolvedPasteReadOptions, t as ClipboardItemLike } from "./paste-reader-DcXnRWQr.js";
4
+ //#region src/core/paste-adapter.d.ts
5
+ /** Minimal structural view of `navigator.clipboard` for reading. */
6
+ interface PasteClipboardLike {
7
+ read?(): Promise<readonly ClipboardItemLike[]>;
8
+ readText?(): Promise<string>;
9
+ }
10
+ interface PasteEnvironment {
11
+ readonly isSecureContext?: boolean;
12
+ readonly navigator?: {
13
+ readonly clipboard?: PasteClipboardLike | undefined;
14
+ } | undefined;
15
+ }
16
+ /**
17
+ * Reads the system clipboard. Implement it for Electron, a native bridge or tests.
18
+ *
19
+ * Contract: call the platform API synchronously (before any `await`) so the
20
+ * browser still sees the user gesture, and reject with a `CopyFailure`.
21
+ * `context.signal` aborts when the read is superseded, reset, or its host
22
+ * unmounts; honour it to stop decoding early.
23
+ */
24
+ interface PasteAdapter {
25
+ read(options: ResolvedPasteReadOptions, context?: OperationContext): Promise<PasteReadResult>;
26
+ }
27
+ interface BrowserPasteAdapterOptions {
28
+ /** Defaults to `window`, read lazily at paste time (SSR-safe). */
29
+ readonly getEnvironment?: () => PasteEnvironment | undefined;
30
+ }
31
+ /** The default paste adapter: async Clipboard API with feature detection and honest errors. */
32
+ declare function createBrowserPasteAdapter(options?: BrowserPasteAdapterOptions): PasteAdapter;
33
+ //#endregion
34
+ export { createBrowserPasteAdapter as a, PasteEnvironment as i, PasteAdapter as n, PasteClipboardLike as r, BrowserPasteAdapterOptions as t };
35
+ //# sourceMappingURL=paste-adapter-uahXnTYk.d.ts.map
@@ -0,0 +1,289 @@
1
+
2
+ const require_errors = require("./errors-BwOF6T_M.cjs");
3
+ const require_mime = require("./mime--LB7kdqG.cjs");
4
+ //#region src/core/paste-reader.ts
5
+ /** Adds the derived fields to an adapter's result. Any `imageFiles` it carried is recomputed. */
6
+ function completePasteResult(result) {
7
+ const images = new Set(result.images);
8
+ return {
9
+ ...result,
10
+ imageFiles: result.files.filter((file) => images.has(file))
11
+ };
12
+ }
13
+ const DEFAULT_PASTE_ACCEPT = /* @__PURE__ */ Object.freeze(["text"]);
14
+ const DEFAULT_PASTE_MAX_BYTES = 33554432;
15
+ const DEFAULT_PASTE_MAX_ITEMS = 32;
16
+ const SHORTHANDS = /* @__PURE__ */ new Map([
17
+ ["text", "text/plain"],
18
+ ["html", "text/html"],
19
+ ["image", "image/*"],
20
+ ["any", "*/*"]
21
+ ]);
22
+ const TYPE_TOKEN = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}$/;
23
+ function resolvePattern(entry) {
24
+ if (typeof entry !== "string") return null;
25
+ const shorthand = SHORTHANDS.get(entry);
26
+ if (shorthand !== void 0) return shorthand;
27
+ if (entry === "*/*") return entry;
28
+ if (entry.endsWith("/*")) {
29
+ const type = entry.slice(0, -2).toLowerCase();
30
+ return TYPE_TOKEN.test(type) ? `${type}/*` : null;
31
+ }
32
+ return require_mime.normalizeClipboardType(entry);
33
+ }
34
+ function resolveLimit(value, fallback, name) {
35
+ if (value === void 0) return fallback;
36
+ if (value === Infinity || Number.isInteger(value) && value > 0) return value;
37
+ throw require_errors.copyFailure("invalid-payload", `\`${name}\` must be a positive integer or Infinity (received ${String(value)}).`);
38
+ }
39
+ /** Validates and normalises paste options. Throws a classified `invalid-payload` failure. */
40
+ function resolvePasteReadOptions(options = {}) {
41
+ const accept = [];
42
+ for (const entry of options.accept ?? DEFAULT_PASTE_ACCEPT) {
43
+ const pattern = resolvePattern(entry);
44
+ if (pattern === null) throw require_errors.copyFailure("invalid-payload", `Invalid \`accept\` entry: ${JSON.stringify(entry)}.`);
45
+ if (!accept.includes(pattern)) accept.push(pattern);
46
+ }
47
+ if (accept.length === 0) throw require_errors.copyFailure("invalid-payload", "`accept` must list at least one type.");
48
+ return {
49
+ accept,
50
+ maxBytes: resolveLimit(options.maxBytes, DEFAULT_PASTE_MAX_BYTES, "maxBytes"),
51
+ maxItems: resolveLimit(options.maxItems, 32, "maxItems")
52
+ };
53
+ }
54
+ /** Whether a normalised MIME type is allowed by the resolved `accept` list. */
55
+ function isAccepted(mimeType, options) {
56
+ return options.accept.some((pattern) => require_mime.matchesMimePattern(mimeType, pattern));
57
+ }
58
+ function createBudget(options) {
59
+ let bytes = 0;
60
+ let items = 0;
61
+ return { charge: (size) => {
62
+ items += 1;
63
+ bytes += size;
64
+ if (items > options.maxItems) throw require_errors.copyFailure("too-large", `The paste has more than ${String(options.maxItems)} accepted items.`);
65
+ if (bytes > options.maxBytes) throw require_errors.copyFailure("too-large", `The paste exceeds the ${String(options.maxBytes)}-byte limit.`);
66
+ } };
67
+ }
68
+ /**
69
+ * UTF-8 byte length of a string, without allocating an encoded copy.
70
+ * Lone surrogates count 3 bytes, as `TextEncoder` / `Blob` encode them as U+FFFD.
71
+ */
72
+ function utf8ByteLength(text) {
73
+ let bytes = 0;
74
+ for (let i = 0; i < text.length; i += 1) {
75
+ const unit = text.charCodeAt(i);
76
+ if (unit < 128) bytes += 1;
77
+ else if (unit < 2048) bytes += 2;
78
+ else if (unit >= 55296 && unit <= 56319 && i + 1 < text.length && (text.charCodeAt(i + 1) & 64512) === 56320) {
79
+ bytes += 4;
80
+ i += 1;
81
+ } else bytes += 3;
82
+ }
83
+ return bytes;
84
+ }
85
+ /** Strings are measured as UTF-8, the same unit `Blob.size` reports for clipboard items. */
86
+ const sizeOf = (data) => typeof data === "string" ? utf8ByteLength(data) : data.size;
87
+ /** Throws `too-large` when the entries break `maxItems` / `maxBytes`. */
88
+ function enforcePasteLimits(entries, options) {
89
+ const budget = createBudget(options);
90
+ for (const entry of entries) budget.charge(sizeOf(entry.data));
91
+ }
92
+ /**
93
+ * Whether a drag in progress could drop anything `accept`s. Uses only what
94
+ * browsers expose before the drop (item kinds and types, never the data).
95
+ * A file whose type is not known yet (some browsers hide it while dragging)
96
+ * counts as a maybe: the drop itself is checked against `accept`.
97
+ */
98
+ function canAcceptDrag(data, options) {
99
+ const items = data.items ?? Array.from(data.types, (type) => type === "Files" ? {
100
+ kind: "file",
101
+ type: ""
102
+ } : {
103
+ kind: "string",
104
+ type
105
+ });
106
+ return Array.from(items).some(({ kind, type: raw }) => {
107
+ const file = kind === "file";
108
+ const type = require_mime.normalizeClipboardType(raw);
109
+ if (type === null) return file;
110
+ return (file || require_mime.isTextualMimeType(type)) && isAccepted(type, options);
111
+ });
112
+ }
113
+ /**
114
+ * Synchronously copies the accepted parts of a paste event's `DataTransfer`.
115
+ * It must run during the event: browsers empty the object afterwards.
116
+ */
117
+ function snapshotDataTransfer(data, options) {
118
+ const entries = [];
119
+ const seen = /* @__PURE__ */ new Set();
120
+ for (const raw of Array.from(data.types)) {
121
+ const type = require_mime.normalizeClipboardType(raw);
122
+ if (type === null || seen.has(type) || !require_mime.isTextualMimeType(type) || !isAccepted(type, options)) continue;
123
+ seen.add(type);
124
+ const text = data.getData(raw);
125
+ if (text.length > 0) entries.push({
126
+ type,
127
+ data: text,
128
+ file: false
129
+ });
130
+ }
131
+ for (const file of Array.from(data.files ?? [])) {
132
+ const type = require_mime.normalizeMimeType(file.type) ?? "application/octet-stream";
133
+ if (isAccepted(type, options)) entries.push({
134
+ type,
135
+ data: file,
136
+ file: true
137
+ });
138
+ }
139
+ return entries;
140
+ }
141
+ /**
142
+ * Reads the accepted types from `navigator.clipboard.read()` items, enforcing
143
+ * the limits *before* decoding any text so an oversized paste is never buffered twice.
144
+ */
145
+ async function collectClipboardItems(items, options, signal) {
146
+ const budget = createBudget(options);
147
+ const entries = [];
148
+ const seen = /* @__PURE__ */ new Set();
149
+ for (const item of items) for (const raw of item.types) {
150
+ const type = require_mime.normalizeClipboardType(raw);
151
+ if (type === null || seen.has(type) || !isAccepted(type, options)) continue;
152
+ seen.add(type);
153
+ let blob;
154
+ try {
155
+ blob = await item.getType(raw);
156
+ } catch {
157
+ continue;
158
+ }
159
+ if (signal?.aborted) throw require_errors.copyFailure("aborted", "The paste was cancelled.");
160
+ if (blob.size === 0) continue;
161
+ budget.charge(blob.size);
162
+ entries.push({
163
+ type,
164
+ data: require_mime.isTextualMimeType(type) ? await blob.text() : blob,
165
+ file: false
166
+ });
167
+ }
168
+ return entries;
169
+ }
170
+ function retype(entry, data, type) {
171
+ if (entry.file) {
172
+ const file = data;
173
+ return new File([file], file.name, {
174
+ type,
175
+ lastModified: file.lastModified
176
+ });
177
+ }
178
+ return data.slice(0, data.size, type);
179
+ }
180
+ /**
181
+ * Verifies image bytes, then builds the result. Blobs that claim to be images
182
+ * but aren't (or whose real format is not accepted) are dropped. Throws
183
+ * `no-content` when nothing survives.
184
+ */
185
+ async function finalizePaste(entries, source, options) {
186
+ const items = [];
187
+ const images = [];
188
+ const files = [];
189
+ let text = null;
190
+ let html = null;
191
+ for (const entry of entries) {
192
+ let { type, data } = entry;
193
+ if (typeof data === "string") {
194
+ if (type === "text/plain") text = data;
195
+ else if (type === "text/html") html = data;
196
+ } else if (type.startsWith("image/")) {
197
+ const actual = await require_mime.sniffImageType(data);
198
+ if (actual === null || !isAccepted(actual, options)) continue;
199
+ if (actual !== type) {
200
+ data = retype(entry, data, actual);
201
+ type = actual;
202
+ }
203
+ images.push(data);
204
+ }
205
+ if (entry.file) files.push(data);
206
+ items.push({
207
+ type,
208
+ data
209
+ });
210
+ }
211
+ if (items.length === 0) throw require_errors.copyFailure("no-content", "The content holds nothing that matches `accept`.");
212
+ return {
213
+ source,
214
+ items,
215
+ text,
216
+ html,
217
+ images,
218
+ files
219
+ };
220
+ }
221
+ //#endregion
222
+ Object.defineProperty(exports, "DEFAULT_PASTE_ACCEPT", {
223
+ enumerable: true,
224
+ get: function() {
225
+ return DEFAULT_PASTE_ACCEPT;
226
+ }
227
+ });
228
+ Object.defineProperty(exports, "DEFAULT_PASTE_MAX_BYTES", {
229
+ enumerable: true,
230
+ get: function() {
231
+ return DEFAULT_PASTE_MAX_BYTES;
232
+ }
233
+ });
234
+ Object.defineProperty(exports, "DEFAULT_PASTE_MAX_ITEMS", {
235
+ enumerable: true,
236
+ get: function() {
237
+ return DEFAULT_PASTE_MAX_ITEMS;
238
+ }
239
+ });
240
+ Object.defineProperty(exports, "canAcceptDrag", {
241
+ enumerable: true,
242
+ get: function() {
243
+ return canAcceptDrag;
244
+ }
245
+ });
246
+ Object.defineProperty(exports, "collectClipboardItems", {
247
+ enumerable: true,
248
+ get: function() {
249
+ return collectClipboardItems;
250
+ }
251
+ });
252
+ Object.defineProperty(exports, "completePasteResult", {
253
+ enumerable: true,
254
+ get: function() {
255
+ return completePasteResult;
256
+ }
257
+ });
258
+ Object.defineProperty(exports, "enforcePasteLimits", {
259
+ enumerable: true,
260
+ get: function() {
261
+ return enforcePasteLimits;
262
+ }
263
+ });
264
+ Object.defineProperty(exports, "finalizePaste", {
265
+ enumerable: true,
266
+ get: function() {
267
+ return finalizePaste;
268
+ }
269
+ });
270
+ Object.defineProperty(exports, "resolvePasteReadOptions", {
271
+ enumerable: true,
272
+ get: function() {
273
+ return resolvePasteReadOptions;
274
+ }
275
+ });
276
+ Object.defineProperty(exports, "snapshotDataTransfer", {
277
+ enumerable: true,
278
+ get: function() {
279
+ return snapshotDataTransfer;
280
+ }
281
+ });
282
+ Object.defineProperty(exports, "utf8ByteLength", {
283
+ enumerable: true,
284
+ get: function() {
285
+ return utf8ByteLength;
286
+ }
287
+ });
288
+
289
+ //# sourceMappingURL=paste-reader-Bo01IMC_.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste-reader-Bo01IMC_.cjs","names":["normalizeClipboardType","copyFailure","matchesMimePattern","isTextualMimeType","normalizeMimeType","sniffImageType"],"sources":["../../src/core/paste-reader.ts"],"sourcesContent":["import { copyFailure } from './errors';\nimport { isTextualMimeType, matchesMimePattern, normalizeClipboardType, normalizeMimeType, sniffImageType } from './mime';\n\n/* ------------------------------------------------------------------ Types */\n\n/** Friendly names for the common cases. */\nexport type PasteAcceptShorthand = 'text' | 'html' | 'image' | 'any';\n\n/**\n * What a paste may contain, in any order: a shorthand, an exact MIME type\n * (`'image/png'`), a web custom format (`'web application/vnd.acme+json'`) or a\n * wildcard (`'image/*'`, `'*\\/*'`). `image/svg+xml` (scriptable XML), web custom\n * formats and `+json` types are only accepted when listed exactly.\n */\nexport type PasteAccept = PasteAcceptShorthand | `${string}/${string}`;\n\nexport interface PasteLimits {\n /**\n * Total size cap across all accepted items, in UTF-8 bytes. Strings are measured as\n * they would be encoded, matching `Blob.size`, so every paste path counts the same way.\n * Default 32 MiB.\n */\n readonly maxBytes?: number;\n /** Max number of accepted items (types + files). Default 32. */\n readonly maxItems?: number;\n}\n\nexport interface PasteReadOptions extends PasteLimits {\n /** Default `['text']` (plain text only): the safest choice. */\n readonly accept?: readonly PasteAccept[];\n}\n\n/** Validated, normalised options that adapters receive. */\nexport interface ResolvedPasteReadOptions {\n /** Normalised patterns: `type/subtype`, `type/*` or `*\\/*`. */\n readonly accept: readonly string[];\n readonly maxBytes: number;\n readonly maxItems: number;\n}\n\n/** Where the content came from: a Clipboard API read, a `paste` event, or a drag-and-drop `drop` event. */\nexport type PasteSource = 'clipboard' | 'event' | 'drop';\n\n/** One accepted clipboard entry. Textual types are decoded to `string`, everything else stays a `Blob`. */\nexport interface PasteItem {\n readonly type: string;\n readonly data: string | Blob;\n}\n\n/**\n * Everything the paste produced. Treat all of it as untrusted user input:\n * in particular never inject `html` into the DOM without sanitising it.\n */\nexport interface PasteResult {\n readonly source: PasteSource;\n /** Every accepted entry, in clipboard order. */\n readonly items: readonly PasteItem[];\n /** `text/plain`, when accepted and present. */\n readonly text: string | null;\n /** `text/html`, when accepted and present. UNTRUSTED markup: sanitise before rendering. */\n readonly html: string | null;\n /** Raster images, verified from their bytes (PNG, JPEG, GIF, WebP, AVIF, BMP), typed accordingly. */\n readonly images: readonly Blob[];\n /** Files from a paste event (e.g. copied in the OS file manager). Includes image files. */\n readonly files: readonly File[];\n /**\n * The entries of `files` that are also in `images`: verified image files, keeping their\n * names, ready for `FormData`. Derived by the paste machine, so it is always consistent.\n */\n readonly imageFiles: readonly File[];\n}\n\n/** What a {@link PasteAdapter} resolves with. `imageFiles` is derived from it by the machine. */\nexport type PasteReadResult = Omit<PasteResult, 'imageFiles'>;\n\n/** Adds the derived fields to an adapter's result. Any `imageFiles` it carried is recomputed. */\nexport function completePasteResult(result: PasteReadResult): PasteResult {\n const images = new Set<Blob>(result.images);\n return { ...result, imageFiles: result.files.filter((file) => images.has(file)) };\n}\n\n/* -------------------------------------------------------- Option handling */\n\nexport const DEFAULT_PASTE_ACCEPT: readonly PasteAccept[] = /* @__PURE__ */ Object.freeze(['text'] as const);\nexport const DEFAULT_PASTE_MAX_BYTES = 32 * 1024 * 1024;\nexport const DEFAULT_PASTE_MAX_ITEMS = 32;\n\nconst SHORTHANDS: ReadonlyMap<string, string> = /* @__PURE__ */ new Map([\n ['text', 'text/plain'],\n ['html', 'text/html'],\n ['image', 'image/*'],\n ['any', '*/*'],\n]);\n\nconst TYPE_TOKEN = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}$/;\n\nfunction resolvePattern(entry: unknown): string | null {\n if (typeof entry !== 'string') return null;\n const shorthand = SHORTHANDS.get(entry);\n if (shorthand !== undefined) return shorthand;\n if (entry === '*/*') return entry;\n if (entry.endsWith('/*')) {\n const type = entry.slice(0, -2).toLowerCase();\n return TYPE_TOKEN.test(type) ? `${type}/*` : null;\n }\n return normalizeClipboardType(entry);\n}\n\nfunction resolveLimit(value: number | undefined, fallback: number, name: string): number {\n if (value === undefined) return fallback;\n if (value === Infinity || (Number.isInteger(value) && value > 0)) return value;\n throw copyFailure('invalid-payload', `\\`${name}\\` must be a positive integer or Infinity (received ${String(value)}).`);\n}\n\n/** Validates and normalises paste options. Throws a classified `invalid-payload` failure. */\nexport function resolvePasteReadOptions(options: PasteReadOptions = {}): ResolvedPasteReadOptions {\n const accept: string[] = [];\n for (const entry of options.accept ?? DEFAULT_PASTE_ACCEPT) {\n const pattern = resolvePattern(entry);\n if (pattern === null) throw copyFailure('invalid-payload', `Invalid \\`accept\\` entry: ${JSON.stringify(entry)}.`);\n if (!accept.includes(pattern)) accept.push(pattern);\n }\n if (accept.length === 0) throw copyFailure('invalid-payload', '`accept` must list at least one type.');\n return {\n accept,\n maxBytes: resolveLimit(options.maxBytes, DEFAULT_PASTE_MAX_BYTES, 'maxBytes'),\n maxItems: resolveLimit(options.maxItems, DEFAULT_PASTE_MAX_ITEMS, 'maxItems'),\n };\n}\n\n/** Whether a normalised MIME type is allowed by the resolved `accept` list. */\nexport function isAccepted(mimeType: string, options: ResolvedPasteReadOptions): boolean {\n return options.accept.some((pattern) => matchesMimePattern(mimeType, pattern));\n}\n\n/* -------------------------------------------------------------- Entries */\n\n/** An accepted, not-yet-verified entry. */\nexport interface PasteEntry {\n readonly type: string;\n readonly data: string | Blob;\n /** Came from `DataTransfer.files`, i.e. `data` is a `File`. */\n readonly file: boolean;\n}\n\ninterface Budget {\n readonly charge: (size: number) => void;\n}\n\nfunction createBudget(options: ResolvedPasteReadOptions): Budget {\n let bytes = 0;\n let items = 0;\n return {\n charge: (size) => {\n items += 1;\n bytes += size;\n if (items > options.maxItems) {\n throw copyFailure('too-large', `The paste has more than ${String(options.maxItems)} accepted items.`);\n }\n if (bytes > options.maxBytes) {\n throw copyFailure('too-large', `The paste exceeds the ${String(options.maxBytes)}-byte limit.`);\n }\n },\n };\n}\n\n/**\n * UTF-8 byte length of a string, without allocating an encoded copy.\n * Lone surrogates count 3 bytes, as `TextEncoder` / `Blob` encode them as U+FFFD.\n */\nexport function utf8ByteLength(text: string): number {\n let bytes = 0;\n for (let i = 0; i < text.length; i += 1) {\n const unit = text.charCodeAt(i);\n if (unit < 0x80) bytes += 1;\n else if (unit < 0x800) bytes += 2;\n else if (unit >= 0xd800 && unit <= 0xdbff && i + 1 < text.length && (text.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {\n bytes += 4;\n i += 1;\n } else bytes += 3;\n }\n return bytes;\n}\n\n/** Strings are measured as UTF-8, the same unit `Blob.size` reports for clipboard items. */\nconst sizeOf = (data: string | Blob): number => (typeof data === 'string' ? utf8ByteLength(data) : data.size);\n\n/** Throws `too-large` when the entries break `maxItems` / `maxBytes`. */\nexport function enforcePasteLimits(entries: readonly PasteEntry[], options: ResolvedPasteReadOptions): void {\n const budget = createBudget(options);\n for (const entry of entries) budget.charge(sizeOf(entry.data));\n}\n\n/** Structural view of a `DataTransferItem`: only what is readable while dragging. */\nexport interface DataTransferItemLike {\n /** `'string'` or `'file'`. */\n readonly kind: string;\n readonly type: string;\n}\n\n/** Structural view of `DataTransfer` (paste and drop events). */\nexport interface DataTransferLike {\n readonly types: ArrayLike<string>;\n getData(format: string): string;\n readonly files?: ArrayLike<File> | null;\n readonly items?: ArrayLike<DataTransferItemLike> | null;\n}\n\n/**\n * Whether a drag in progress could drop anything `accept`s. Uses only what\n * browsers expose before the drop (item kinds and types, never the data).\n * A file whose type is not known yet (some browsers hide it while dragging)\n * counts as a maybe: the drop itself is checked against `accept`.\n */\nexport function canAcceptDrag(data: DataTransferLike, options: ResolvedPasteReadOptions): boolean {\n // Without an item list, a file is only known as the type \"Files\": treat it as an untyped file.\n const items = data.items ?? Array.from(data.types, (type) => (type === 'Files' ? { kind: 'file', type: '' } : { kind: 'string', type }));\n return Array.from(items).some(({ kind, type: raw }) => {\n const file = kind === 'file';\n const type = normalizeClipboardType(raw);\n if (type === null) return file;\n return (file || isTextualMimeType(type)) && isAccepted(type, options);\n });\n}\n\n/**\n * Synchronously copies the accepted parts of a paste event's `DataTransfer`.\n * It must run during the event: browsers empty the object afterwards.\n */\nexport function snapshotDataTransfer(data: DataTransferLike, options: ResolvedPasteReadOptions): PasteEntry[] {\n const entries: PasteEntry[] = [];\n const seen = new Set<string>();\n\n for (const raw of Array.from(data.types)) {\n const type = normalizeClipboardType(raw);\n // Binary types are delivered through `files`; `getData` only returns strings.\n if (type === null || seen.has(type) || !isTextualMimeType(type) || !isAccepted(type, options)) continue;\n seen.add(type);\n const text = data.getData(raw);\n if (text.length > 0) entries.push({ type, data: text, file: false });\n }\n\n for (const file of Array.from(data.files ?? [])) {\n const type = normalizeMimeType(file.type) ?? 'application/octet-stream';\n if (isAccepted(type, options)) entries.push({ type, data: file, file: true });\n }\n\n return entries;\n}\n\n/** Structural view of a `ClipboardItem` as returned by `navigator.clipboard.read()`. */\nexport interface ClipboardItemLike {\n readonly types: readonly string[];\n getType(type: string): Promise<Blob>;\n}\n\n/**\n * Reads the accepted types from `navigator.clipboard.read()` items, enforcing\n * the limits *before* decoding any text so an oversized paste is never buffered twice.\n */\nexport async function collectClipboardItems(\n items: readonly ClipboardItemLike[],\n options: ResolvedPasteReadOptions,\n signal?: AbortSignal,\n): Promise<PasteEntry[]> {\n const budget = createBudget(options);\n const entries: PasteEntry[] = [];\n const seen = new Set<string>();\n\n for (const item of items) {\n for (const raw of item.types) {\n const type = normalizeClipboardType(raw);\n if (type === null || seen.has(type) || !isAccepted(type, options)) continue;\n seen.add(type);\n\n let blob: Blob;\n try {\n blob = await item.getType(raw);\n } catch {\n // Chromium lists some types it then refuses to hand over; skip them, don't fail the paste.\n continue;\n }\n // Cancelled (reset, superseded, unmounted) while waiting: don't decode the rest.\n if (signal?.aborted) throw copyFailure('aborted', 'The paste was cancelled.');\n if (blob.size === 0) continue;\n budget.charge(blob.size);\n entries.push({ type, data: isTextualMimeType(type) ? await blob.text() : blob, file: false });\n }\n }\n return entries;\n}\n\n/* ------------------------------------------------------------ Finalising */\n\nfunction retype(entry: PasteEntry, data: Blob, type: string): Blob {\n if (entry.file) {\n const file = data as File;\n return new File([file], file.name, { type, lastModified: file.lastModified });\n }\n return data.slice(0, data.size, type);\n}\n\n/**\n * Verifies image bytes, then builds the result. Blobs that claim to be images\n * but aren't (or whose real format is not accepted) are dropped. Throws\n * `no-content` when nothing survives.\n */\nexport async function finalizePaste(\n entries: readonly PasteEntry[],\n source: PasteSource,\n options: ResolvedPasteReadOptions,\n): Promise<PasteReadResult> {\n const items: PasteItem[] = [];\n const images: Blob[] = [];\n const files: File[] = [];\n let text: string | null = null;\n let html: string | null = null;\n\n for (const entry of entries) {\n let { type, data } = entry;\n\n if (typeof data === 'string') {\n // Types are de-duplicated upstream, so each of these is seen at most once.\n if (type === 'text/plain') text = data;\n else if (type === 'text/html') html = data;\n } else if (type.startsWith('image/')) {\n const actual = await sniffImageType(data);\n if (actual === null || !isAccepted(actual, options)) continue;\n if (actual !== type) {\n data = retype(entry, data, actual);\n type = actual;\n }\n images.push(data);\n }\n\n if (entry.file) files.push(data as File);\n items.push({ type, data });\n }\n\n if (items.length === 0) {\n throw copyFailure('no-content', 'The content holds nothing that matches `accept`.');\n }\n return { source, items, text, html, images, files };\n}\n"],"mappings":";;;;;AA4EA,SAAgB,oBAAoB,QAAsC;CACxE,MAAM,SAAS,IAAI,IAAU,OAAO,MAAM;CAC1C,OAAO;EAAE,GAAG;EAAQ,YAAY,OAAO,MAAM,QAAQ,SAAS,OAAO,IAAI,IAAI,CAAC;CAAE;AAClF;AAIA,MAAa,uBAA+D,uBAAO,OAAO,CAAC,MAAM,CAAU;AAC3G,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;AAEvC,MAAM,6BAA0D,IAAI,IAAI;CACtE,CAAC,QAAQ,YAAY;CACrB,CAAC,QAAQ,WAAW;CACpB,CAAC,SAAS,SAAS;CACnB,CAAC,OAAO,KAAK;AACf,CAAC;AAED,MAAM,aAAa;AAEnB,SAAS,eAAe,OAA+B;CACrD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,MAAM,YAAY,WAAW,IAAI,KAAK;CACtC,IAAI,cAAc,KAAA,GAAW,OAAO;CACpC,IAAI,UAAU,OAAO,OAAO;CAC5B,IAAI,MAAM,SAAS,IAAI,GAAG;EACxB,MAAM,OAAO,MA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