gospelo-iconcraft-wasm 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -0
- package/icon_craft_wasm.d.ts +67 -0
- package/icon_craft_wasm.js +327 -0
- package/icon_craft_wasm_bg.wasm +0 -0
- package/package.json +17 -0
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# gospelo-iconcraft-wasm
|
|
2
|
+
|
|
3
|
+
A WebAssembly module that generates emboss-style decorative shapes from SVG icons. Creates smooth, 3D-looking clip-paths with highlights and shadows.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install gospelo-iconcraft-wasm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import init, { generate_clippath, generate_clippath_with_icon, ShapeMode } from 'gospelo-iconcraft-wasm';
|
|
15
|
+
|
|
16
|
+
// Initialize WASM module
|
|
17
|
+
await init();
|
|
18
|
+
|
|
19
|
+
// Basic usage - generate clip-path only
|
|
20
|
+
const result = generate_clippath(
|
|
21
|
+
svgContent, // SVG string
|
|
22
|
+
ShapeMode.Jelly, // Shape mode: Jelly, Droplet, or Wax
|
|
23
|
+
20, // Offset (padding around icon)
|
|
24
|
+
256, // Resolution
|
|
25
|
+
1.0 // Simplify epsilon (polygon simplification)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// With icon embedding - generates complete emboss SVG
|
|
29
|
+
const resultWithIcon = generate_clippath_with_icon(
|
|
30
|
+
svgContent,
|
|
31
|
+
ShapeMode.Wax,
|
|
32
|
+
20,
|
|
33
|
+
256,
|
|
34
|
+
1.0,
|
|
35
|
+
true // include_icon: generates emboss_svg with gradients
|
|
36
|
+
);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
### Shape Modes
|
|
42
|
+
|
|
43
|
+
| Mode | Description |
|
|
44
|
+
|------|-------------|
|
|
45
|
+
| `ShapeMode.Jelly` | Smooth, organic blob shape following icon contours |
|
|
46
|
+
| `ShapeMode.Droplet` | Perfect circle/sphere with glass-like highlights |
|
|
47
|
+
| `ShapeMode.Wax` | Irregular wax seal shape with pressed icon indent |
|
|
48
|
+
|
|
49
|
+
### Functions
|
|
50
|
+
|
|
51
|
+
#### `generate_clippath(svg_content, mode, offset, resolution, simplify_epsilon)`
|
|
52
|
+
|
|
53
|
+
Generates a clip-path polygon from SVG content.
|
|
54
|
+
|
|
55
|
+
**Returns:**
|
|
56
|
+
```typescript
|
|
57
|
+
{
|
|
58
|
+
success: boolean;
|
|
59
|
+
clip_path: string; // CSS polygon() string
|
|
60
|
+
inner_clip_path?: string; // Inner shape for Wax mode
|
|
61
|
+
highlight_clip_paths?: string[];
|
|
62
|
+
points_count: number;
|
|
63
|
+
mode: string;
|
|
64
|
+
icon_layout: {
|
|
65
|
+
top_percent: number;
|
|
66
|
+
left_percent: number;
|
|
67
|
+
width_percent: number;
|
|
68
|
+
height_percent: number;
|
|
69
|
+
};
|
|
70
|
+
svg_paths: {
|
|
71
|
+
clip: string; // SVG path d attribute
|
|
72
|
+
inner?: string;
|
|
73
|
+
shadow?: string;
|
|
74
|
+
highlight?: string;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### `generate_clippath_with_icon(svg_content, mode, offset, resolution, simplify_epsilon, include_icon)`
|
|
80
|
+
|
|
81
|
+
Same as above, but when `include_icon` is true, also returns:
|
|
82
|
+
- `emboss_svg`: Complete SVG with gradients, filters, and icon paths
|
|
83
|
+
- `icon_paths`: Parsed icon path data for custom rendering
|
|
84
|
+
|
|
85
|
+
#### `generate_clippath_with_color(svg_content, mode, offset, resolution, simplify_epsilon, include_icon, base_color)`
|
|
86
|
+
|
|
87
|
+
Same as `generate_clippath_with_icon`, but uses custom base color (hex string like `"#6366f1"`) to generate the color palette for gradients.
|
|
88
|
+
|
|
89
|
+
## Example Output
|
|
90
|
+
|
|
91
|
+
The generated `emboss_svg` includes:
|
|
92
|
+
- Multi-layer gradients for 3D depth effect
|
|
93
|
+
- Highlights and shadows
|
|
94
|
+
- Drop shadow filter
|
|
95
|
+
- Embedded icon with emboss styling
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
99
|
+
<defs>
|
|
100
|
+
<!-- Gradients and filters -->
|
|
101
|
+
</defs>
|
|
102
|
+
<!-- Main shape with gradient layers -->
|
|
103
|
+
<!-- Inner indent (Wax mode) -->
|
|
104
|
+
<!-- Highlights (Jelly/Droplet mode) -->
|
|
105
|
+
<!-- Embedded icon -->
|
|
106
|
+
</svg>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Browser Support
|
|
110
|
+
|
|
111
|
+
Requires WebAssembly support. Works in all modern browsers.
|
|
112
|
+
|
|
113
|
+
## Repository
|
|
114
|
+
|
|
115
|
+
- [GitHub](https://github.com/gospelo-dev/iconcraft/tree/main/packages/wasm) - Package distribution
|
|
116
|
+
- [Issues](https://github.com/gospelo-dev/iconcraft/issues) - Bug reports & feature requests
|
|
117
|
+
|
|
118
|
+
## Related
|
|
119
|
+
|
|
120
|
+
- [@gospelo-dev/iconcraft-react](https://www.npmjs.com/package/@gospelo-dev/iconcraft-react) - React components using this WASM module
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shape mode for clip-path generation
|
|
6
|
+
*/
|
|
7
|
+
export enum ShapeMode {
|
|
8
|
+
Jelly = 0,
|
|
9
|
+
Droplet = 1,
|
|
10
|
+
Wax = 2,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Generate clip-path from SVG content
|
|
15
|
+
*/
|
|
16
|
+
export function generate_clippath(svg_content: string, mode: ShapeMode, offset: number, resolution: number, simplify_epsilon: number): any;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Generate clip-path with icon and custom base color for gradients
|
|
20
|
+
* base_color: hex color string (e.g., "#6366f1") - used to generate color palette
|
|
21
|
+
*/
|
|
22
|
+
export function generate_clippath_with_color(svg_content: string, mode: ShapeMode, offset: number, resolution: number, simplify_epsilon: number, include_icon: boolean, base_color: string): any;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Generate clip-path from SVG content with icon embedding option
|
|
26
|
+
* When include_icon is true, generates complete emboss SVG with icon paths
|
|
27
|
+
*/
|
|
28
|
+
export function generate_clippath_with_icon(svg_content: string, mode: ShapeMode, offset: number, resolution: number, simplify_epsilon: number, include_icon: boolean): any;
|
|
29
|
+
|
|
30
|
+
export function init(): void;
|
|
31
|
+
|
|
32
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
33
|
+
|
|
34
|
+
export interface InitOutput {
|
|
35
|
+
readonly memory: WebAssembly.Memory;
|
|
36
|
+
readonly generate_clippath: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
|
|
37
|
+
readonly generate_clippath_with_color: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => any;
|
|
38
|
+
readonly generate_clippath_with_icon: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
39
|
+
readonly init: () => void;
|
|
40
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
41
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
42
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
43
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
44
|
+
readonly __wbindgen_start: () => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
51
|
+
* a precompiled `WebAssembly.Module`.
|
|
52
|
+
*
|
|
53
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
54
|
+
*
|
|
55
|
+
* @returns {InitOutput}
|
|
56
|
+
*/
|
|
57
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
61
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
62
|
+
*
|
|
63
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
64
|
+
*
|
|
65
|
+
* @returns {Promise<InitOutput>}
|
|
66
|
+
*/
|
|
67
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/* @ts-self-types="./icon_craft_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shape mode for clip-path generation
|
|
5
|
+
* @enum {0 | 1 | 2}
|
|
6
|
+
*/
|
|
7
|
+
export const ShapeMode = Object.freeze({
|
|
8
|
+
Jelly: 0, "0": "Jelly",
|
|
9
|
+
Droplet: 1, "1": "Droplet",
|
|
10
|
+
Wax: 2, "2": "Wax",
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Generate clip-path from SVG content
|
|
15
|
+
* @param {string} svg_content
|
|
16
|
+
* @param {ShapeMode} mode
|
|
17
|
+
* @param {number} offset
|
|
18
|
+
* @param {number} resolution
|
|
19
|
+
* @param {number} simplify_epsilon
|
|
20
|
+
* @returns {any}
|
|
21
|
+
*/
|
|
22
|
+
export function generate_clippath(svg_content, mode, offset, resolution, simplify_epsilon) {
|
|
23
|
+
const ptr0 = passStringToWasm0(svg_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
24
|
+
const len0 = WASM_VECTOR_LEN;
|
|
25
|
+
const ret = wasm.generate_clippath(ptr0, len0, mode, offset, resolution, simplify_epsilon);
|
|
26
|
+
return ret;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Generate clip-path with icon and custom base color for gradients
|
|
31
|
+
* base_color: hex color string (e.g., "#6366f1") - used to generate color palette
|
|
32
|
+
* @param {string} svg_content
|
|
33
|
+
* @param {ShapeMode} mode
|
|
34
|
+
* @param {number} offset
|
|
35
|
+
* @param {number} resolution
|
|
36
|
+
* @param {number} simplify_epsilon
|
|
37
|
+
* @param {boolean} include_icon
|
|
38
|
+
* @param {string} base_color
|
|
39
|
+
* @returns {any}
|
|
40
|
+
*/
|
|
41
|
+
export function generate_clippath_with_color(svg_content, mode, offset, resolution, simplify_epsilon, include_icon, base_color) {
|
|
42
|
+
const ptr0 = passStringToWasm0(svg_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
43
|
+
const len0 = WASM_VECTOR_LEN;
|
|
44
|
+
const ptr1 = passStringToWasm0(base_color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
45
|
+
const len1 = WASM_VECTOR_LEN;
|
|
46
|
+
const ret = wasm.generate_clippath_with_color(ptr0, len0, mode, offset, resolution, simplify_epsilon, include_icon, ptr1, len1);
|
|
47
|
+
return ret;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Generate clip-path from SVG content with icon embedding option
|
|
52
|
+
* When include_icon is true, generates complete emboss SVG with icon paths
|
|
53
|
+
* @param {string} svg_content
|
|
54
|
+
* @param {ShapeMode} mode
|
|
55
|
+
* @param {number} offset
|
|
56
|
+
* @param {number} resolution
|
|
57
|
+
* @param {number} simplify_epsilon
|
|
58
|
+
* @param {boolean} include_icon
|
|
59
|
+
* @returns {any}
|
|
60
|
+
*/
|
|
61
|
+
export function generate_clippath_with_icon(svg_content, mode, offset, resolution, simplify_epsilon, include_icon) {
|
|
62
|
+
const ptr0 = passStringToWasm0(svg_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
63
|
+
const len0 = WASM_VECTOR_LEN;
|
|
64
|
+
const ret = wasm.generate_clippath_with_icon(ptr0, len0, mode, offset, resolution, simplify_epsilon, include_icon);
|
|
65
|
+
return ret;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function init() {
|
|
69
|
+
wasm.init();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function __wbg_get_imports() {
|
|
73
|
+
const import0 = {
|
|
74
|
+
__proto__: null,
|
|
75
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
76
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
77
|
+
return ret;
|
|
78
|
+
},
|
|
79
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
80
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
81
|
+
},
|
|
82
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
83
|
+
let deferred0_0;
|
|
84
|
+
let deferred0_1;
|
|
85
|
+
try {
|
|
86
|
+
deferred0_0 = arg0;
|
|
87
|
+
deferred0_1 = arg1;
|
|
88
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
89
|
+
} finally {
|
|
90
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
94
|
+
const ret = new Object();
|
|
95
|
+
return ret;
|
|
96
|
+
},
|
|
97
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
98
|
+
const ret = new Array();
|
|
99
|
+
return ret;
|
|
100
|
+
},
|
|
101
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
102
|
+
const ret = new Error();
|
|
103
|
+
return ret;
|
|
104
|
+
},
|
|
105
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
106
|
+
arg0[arg1] = arg2;
|
|
107
|
+
},
|
|
108
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
109
|
+
arg0[arg1 >>> 0] = arg2;
|
|
110
|
+
},
|
|
111
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
112
|
+
const ret = arg1.stack;
|
|
113
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
114
|
+
const len1 = WASM_VECTOR_LEN;
|
|
115
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
116
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
117
|
+
},
|
|
118
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
119
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
120
|
+
const ret = arg0;
|
|
121
|
+
return ret;
|
|
122
|
+
},
|
|
123
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
124
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
125
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
126
|
+
return ret;
|
|
127
|
+
},
|
|
128
|
+
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
129
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
130
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
131
|
+
return ret;
|
|
132
|
+
},
|
|
133
|
+
__wbindgen_init_externref_table: function() {
|
|
134
|
+
const table = wasm.__wbindgen_externrefs;
|
|
135
|
+
const offset = table.grow(4);
|
|
136
|
+
table.set(0, undefined);
|
|
137
|
+
table.set(offset + 0, undefined);
|
|
138
|
+
table.set(offset + 1, null);
|
|
139
|
+
table.set(offset + 2, true);
|
|
140
|
+
table.set(offset + 3, false);
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
return {
|
|
144
|
+
__proto__: null,
|
|
145
|
+
"./icon_craft_wasm_bg.js": import0,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let cachedDataViewMemory0 = null;
|
|
150
|
+
function getDataViewMemory0() {
|
|
151
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
152
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
153
|
+
}
|
|
154
|
+
return cachedDataViewMemory0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function getStringFromWasm0(ptr, len) {
|
|
158
|
+
ptr = ptr >>> 0;
|
|
159
|
+
return decodeText(ptr, len);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let cachedUint8ArrayMemory0 = null;
|
|
163
|
+
function getUint8ArrayMemory0() {
|
|
164
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
165
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
166
|
+
}
|
|
167
|
+
return cachedUint8ArrayMemory0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
171
|
+
if (realloc === undefined) {
|
|
172
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
173
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
174
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
175
|
+
WASM_VECTOR_LEN = buf.length;
|
|
176
|
+
return ptr;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let len = arg.length;
|
|
180
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
181
|
+
|
|
182
|
+
const mem = getUint8ArrayMemory0();
|
|
183
|
+
|
|
184
|
+
let offset = 0;
|
|
185
|
+
|
|
186
|
+
for (; offset < len; offset++) {
|
|
187
|
+
const code = arg.charCodeAt(offset);
|
|
188
|
+
if (code > 0x7F) break;
|
|
189
|
+
mem[ptr + offset] = code;
|
|
190
|
+
}
|
|
191
|
+
if (offset !== len) {
|
|
192
|
+
if (offset !== 0) {
|
|
193
|
+
arg = arg.slice(offset);
|
|
194
|
+
}
|
|
195
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
196
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
197
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
198
|
+
|
|
199
|
+
offset += ret.written;
|
|
200
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
WASM_VECTOR_LEN = offset;
|
|
204
|
+
return ptr;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
208
|
+
cachedTextDecoder.decode();
|
|
209
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
210
|
+
let numBytesDecoded = 0;
|
|
211
|
+
function decodeText(ptr, len) {
|
|
212
|
+
numBytesDecoded += len;
|
|
213
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
214
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
215
|
+
cachedTextDecoder.decode();
|
|
216
|
+
numBytesDecoded = len;
|
|
217
|
+
}
|
|
218
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const cachedTextEncoder = new TextEncoder();
|
|
222
|
+
|
|
223
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
224
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
225
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
226
|
+
view.set(buf);
|
|
227
|
+
return {
|
|
228
|
+
read: arg.length,
|
|
229
|
+
written: buf.length
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
let WASM_VECTOR_LEN = 0;
|
|
235
|
+
|
|
236
|
+
let wasmModule, wasm;
|
|
237
|
+
function __wbg_finalize_init(instance, module) {
|
|
238
|
+
wasm = instance.exports;
|
|
239
|
+
wasmModule = module;
|
|
240
|
+
cachedDataViewMemory0 = null;
|
|
241
|
+
cachedUint8ArrayMemory0 = null;
|
|
242
|
+
wasm.__wbindgen_start();
|
|
243
|
+
return wasm;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async function __wbg_load(module, imports) {
|
|
247
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
248
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
249
|
+
try {
|
|
250
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
251
|
+
} catch (e) {
|
|
252
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
253
|
+
|
|
254
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
255
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
256
|
+
|
|
257
|
+
} else { throw e; }
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const bytes = await module.arrayBuffer();
|
|
262
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
263
|
+
} else {
|
|
264
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
265
|
+
|
|
266
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
267
|
+
return { instance, module };
|
|
268
|
+
} else {
|
|
269
|
+
return instance;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function expectedResponseType(type) {
|
|
274
|
+
switch (type) {
|
|
275
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
276
|
+
}
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function initSync(module) {
|
|
282
|
+
if (wasm !== undefined) return wasm;
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
if (module !== undefined) {
|
|
286
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
287
|
+
({module} = module)
|
|
288
|
+
} else {
|
|
289
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const imports = __wbg_get_imports();
|
|
294
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
295
|
+
module = new WebAssembly.Module(module);
|
|
296
|
+
}
|
|
297
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
298
|
+
return __wbg_finalize_init(instance, module);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
async function __wbg_init(module_or_path) {
|
|
302
|
+
if (wasm !== undefined) return wasm;
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
if (module_or_path !== undefined) {
|
|
306
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
307
|
+
({module_or_path} = module_or_path)
|
|
308
|
+
} else {
|
|
309
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (module_or_path === undefined) {
|
|
314
|
+
module_or_path = new URL('icon_craft_wasm_bg.wasm', import.meta.url);
|
|
315
|
+
}
|
|
316
|
+
const imports = __wbg_get_imports();
|
|
317
|
+
|
|
318
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
319
|
+
module_or_path = fetch(module_or_path);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
323
|
+
|
|
324
|
+
return __wbg_finalize_init(instance, module);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gospelo-iconcraft-wasm",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "WASM-based clip-path generator for IconCraft",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "gorosun <goro-hayakawa@no-studio.net>",
|
|
7
|
+
"keywords": ["wasm", "svg", "clip-path", "icon", "shape"],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "icon_craft_wasm.js",
|
|
10
|
+
"types": "icon_craft_wasm.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"icon_craft_wasm_bg.wasm",
|
|
13
|
+
"icon_craft_wasm.js",
|
|
14
|
+
"icon_craft_wasm.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"sideEffects": ["./snippets/*"]
|
|
17
|
+
}
|