@slithy/prim-interface 0.2.7 → 0.2.8
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/README.md +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -80,7 +80,7 @@ Higher-level (rasterize SVG at save time for crisp output):
|
|
|
80
80
|
|
|
81
81
|
- **`saveRasterFromVector(svgString, width, height, format?, quality?, options?)`** — downloads PNG or JPEG rasterized from the SVG
|
|
82
82
|
- **`copyRasterFromVector(svgString, width, height)`** — copies a PNG rasterized from the SVG to the clipboard
|
|
83
|
-
- **`shareFromVector(svgString, width, height)`** — shares a PNG rasterized from the SVG via the Web Share API
|
|
83
|
+
- **`shareFromVector(svgString, width, height, options?)`** — shares a PNG rasterized from the SVG via the Web Share API
|
|
84
84
|
|
|
85
85
|
Lower-level (operate directly on a canvas or SVG string):
|
|
86
86
|
|
|
@@ -88,7 +88,7 @@ Lower-level (operate directly on a canvas or SVG string):
|
|
|
88
88
|
- **`saveVector(svgString, options?)`** — downloads SVG
|
|
89
89
|
- **`copyRaster(canvas)`** — copies PNG to clipboard
|
|
90
90
|
- **`copyVector(svgString)`** — copies SVG markup to clipboard
|
|
91
|
-
- **`share(canvas)`** — shares via Web Share API if available
|
|
91
|
+
- **`share(canvas, options?)`** — shares via Web Share API if available
|
|
92
92
|
|
|
93
93
|
**`SaveOptions`** controls download filenames, formatted as `${filename}--${suffix}.${ext}`:
|
|
94
94
|
|
package/dist/index.d.ts
CHANGED
|
@@ -50,10 +50,10 @@ interface SaveOptions {
|
|
|
50
50
|
declare function saveRaster(canvas: HTMLCanvasElement, format?: 'png' | 'jpeg', quality?: number, options?: SaveOptions): void;
|
|
51
51
|
declare function saveRasterFromVector(svgString: string, width: number, height: number, format?: 'png' | 'jpeg', quality?: number, options?: SaveOptions): Promise<void>;
|
|
52
52
|
declare function copyRasterFromVector(svgString: string, width: number, height: number): Promise<void>;
|
|
53
|
-
declare function shareFromVector(svgString: string, width: number, height: number): Promise<void>;
|
|
53
|
+
declare function shareFromVector(svgString: string, width: number, height: number, options?: SaveOptions): Promise<void>;
|
|
54
54
|
declare function saveVector(svgString: string, options?: SaveOptions): void;
|
|
55
55
|
declare function copyVector(svgString: string): Promise<void>;
|
|
56
56
|
declare function copyRaster(canvas: HTMLCanvasElement): Promise<void>;
|
|
57
|
-
declare function share(canvas: HTMLCanvasElement): Promise<void>;
|
|
57
|
+
declare function share(canvas: HTMLCanvasElement, options?: SaveOptions): Promise<void>;
|
|
58
58
|
|
|
59
59
|
export { type Config, type JobHandle, type RunCallbacks, type SaveOptions, type StepResult, copyRaster, copyRasterFromVector, copyVector, run, saveRaster, saveRasterFromVector, saveVector, share, shareFromVector };
|
package/dist/index.js
CHANGED
|
@@ -116,9 +116,9 @@ async function copyRasterFromVector(svgString, width, height) {
|
|
|
116
116
|
const canvas = await svgToCanvas(svgString, width, height);
|
|
117
117
|
return copyRaster(canvas);
|
|
118
118
|
}
|
|
119
|
-
async function shareFromVector(svgString, width, height) {
|
|
119
|
+
async function shareFromVector(svgString, width, height, options) {
|
|
120
120
|
const canvas = await svgToCanvas(svgString, width, height);
|
|
121
|
-
return share(canvas);
|
|
121
|
+
return share(canvas, options);
|
|
122
122
|
}
|
|
123
123
|
function saveVector(svgString, options) {
|
|
124
124
|
const blob = new Blob([svgString], { type: "image/svg+xml" });
|
|
@@ -133,9 +133,9 @@ async function copyRaster(canvas) {
|
|
|
133
133
|
const blob = await new Promise((resolve, reject) => canvas.toBlob((b) => b ? resolve(b) : reject(new Error("toBlob failed"))));
|
|
134
134
|
await navigator.clipboard.write([new ClipboardItem({ "image/png": blob })]);
|
|
135
135
|
}
|
|
136
|
-
async function share(canvas) {
|
|
136
|
+
async function share(canvas, options) {
|
|
137
137
|
const blob = await new Promise((resolve, reject) => canvas.toBlob((b) => b ? resolve(b) : reject(new Error("toBlob failed"))));
|
|
138
|
-
const file = new File([blob], "
|
|
138
|
+
const file = new File([blob], buildFilename("png", options), { type: "image/png" });
|
|
139
139
|
if (navigator.canShare({ files: [file] })) {
|
|
140
140
|
await navigator.share({ files: [file] });
|
|
141
141
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slithy/prim-interface",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Browser-facing API for primitive-based image reconstruction.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"tsup": "^8",
|
|
23
23
|
"typescript": "^5",
|
|
24
24
|
"vitest": "^4",
|
|
25
|
-
"@slithy/
|
|
26
|
-
"@slithy/
|
|
25
|
+
"@slithy/tsconfig": "0.0.0",
|
|
26
|
+
"@slithy/eslint-config": "0.0.0"
|
|
27
27
|
},
|
|
28
28
|
"author": {
|
|
29
29
|
"name": "Matthew Campagna",
|