@slithy/prim-interface 0.2.8 → 0.2.9

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 (2) hide show
  1. package/dist/index.js +16 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -113,8 +113,15 @@ async function saveRasterFromVector(svgString, width, height, format = "png", qu
113
113
  saveRaster(canvas, format, quality, options);
114
114
  }
115
115
  async function copyRasterFromVector(svgString, width, height) {
116
- const canvas = await svgToCanvas(svgString, width, height);
117
- return copyRaster(canvas);
116
+ await navigator.clipboard.write([
117
+ new ClipboardItem({
118
+ "image/png": svgToCanvas(svgString, width, height).then(
119
+ (canvas) => new Promise(
120
+ (resolve, reject) => canvas.toBlob((b) => b ? resolve(b) : reject(new Error("toBlob failed")))
121
+ )
122
+ )
123
+ })
124
+ ]);
118
125
  }
119
126
  async function shareFromVector(svgString, width, height, options) {
120
127
  const canvas = await svgToCanvas(svgString, width, height);
@@ -130,8 +137,13 @@ async function copyVector(svgString) {
130
137
  await navigator.clipboard.writeText(svgString);
131
138
  }
132
139
  async function copyRaster(canvas) {
133
- const blob = await new Promise((resolve, reject) => canvas.toBlob((b) => b ? resolve(b) : reject(new Error("toBlob failed"))));
134
- await navigator.clipboard.write([new ClipboardItem({ "image/png": blob })]);
140
+ await navigator.clipboard.write([
141
+ new ClipboardItem({
142
+ "image/png": new Promise(
143
+ (resolve, reject) => canvas.toBlob((b) => b ? resolve(b) : reject(new Error("toBlob failed")))
144
+ )
145
+ })
146
+ ]);
135
147
  }
136
148
  async function share(canvas, options) {
137
149
  const blob = await new Promise((resolve, reject) => canvas.toBlob((b) => b ? resolve(b) : reject(new Error("toBlob failed"))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slithy/prim-interface",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Browser-facing API for primitive-based image reconstruction.",
5
5
  "type": "module",
6
6
  "exports": {