gospelo-iconcraft-react 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 +257 -0
- package/dist/icon_craft_wasm-JDPURZOP.js +266 -0
- package/dist/index.d.ts +942 -0
- package/dist/index.js +1954 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# @gospelo-dev/iconcraft-react
|
|
2
|
+
|
|
3
|
+
React components for creating emboss-style decorative icon shapes from SVG. Features 3D-looking shapes with highlights, shadows, and smooth animations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @gospelo-dev/iconcraft-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { IconCraft } from '@gospelo-dev/iconcraft-react';
|
|
15
|
+
|
|
16
|
+
function App() {
|
|
17
|
+
return (
|
|
18
|
+
<IconCraft
|
|
19
|
+
svgContent="<svg>...</svg>"
|
|
20
|
+
mode="wax"
|
|
21
|
+
baseColor="#6366f1"
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Components
|
|
28
|
+
|
|
29
|
+
### `<IconCraftShape>` (Recommended)
|
|
30
|
+
|
|
31
|
+
Modern component with full feature support.
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { IconCraftShape } from '@gospelo-dev/iconcraft-react';
|
|
35
|
+
|
|
36
|
+
<IconCraftShape
|
|
37
|
+
svg="<svg>...</svg>"
|
|
38
|
+
mode="jelly"
|
|
39
|
+
color="#10b981"
|
|
40
|
+
size={120}
|
|
41
|
+
animation="bounce"
|
|
42
|
+
shadow
|
|
43
|
+
/>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### Props
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Default | Description |
|
|
49
|
+
|------|------|---------|-------------|
|
|
50
|
+
| `svg` | `string` | required | SVG content string |
|
|
51
|
+
| `mode` | `'jelly' \| 'droplet' \| 'wax'` | `'jelly'` | Shape mode |
|
|
52
|
+
| `color` | `string` | `'#6366f1'` | Base color (hex) |
|
|
53
|
+
| `iconStyle` | `'original' \| 'white' \| 'dark' \| 'emboss'` | `'emboss'` | Icon rendering style |
|
|
54
|
+
| `size` | `number \| string` | - | Width and height |
|
|
55
|
+
| `width` | `number \| string` | - | Width |
|
|
56
|
+
| `height` | `number \| string` | - | Height |
|
|
57
|
+
| `shadow` | `boolean` | `true` | Show drop shadow |
|
|
58
|
+
| `highlight` | `boolean` | `true` | Show highlight effect |
|
|
59
|
+
| `animation` | `AnimationType \| AnimationOptions` | - | Animation preset or config |
|
|
60
|
+
| `animateOnHover` | `boolean` | `false` | Trigger animation on hover |
|
|
61
|
+
| `offset` | `number` | `20` | Contour offset |
|
|
62
|
+
| `resolution` | `number` | `256` | Rasterization resolution |
|
|
63
|
+
| `simplify` | `number` | `2.0` | Polygon simplification |
|
|
64
|
+
| `className` | `string` | - | CSS class |
|
|
65
|
+
| `style` | `CSSProperties` | - | Inline styles |
|
|
66
|
+
| `onLoad` | `(result) => void` | - | Called when generation completes |
|
|
67
|
+
| `onError` | `(error) => void` | - | Called on error |
|
|
68
|
+
| `onClick` | `() => void` | - | Click handler |
|
|
69
|
+
|
|
70
|
+
### `<IconCraft>` (Legacy)
|
|
71
|
+
|
|
72
|
+
Original component for backwards compatibility.
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import { IconCraft } from '@gospelo-dev/iconcraft-react';
|
|
76
|
+
|
|
77
|
+
<IconCraft
|
|
78
|
+
svgContent="<svg>...</svg>"
|
|
79
|
+
mode="wax"
|
|
80
|
+
baseColor="#6366f1"
|
|
81
|
+
/>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Shape Modes
|
|
85
|
+
|
|
86
|
+
| Mode | Description |
|
|
87
|
+
|------|-------------|
|
|
88
|
+
| `jelly` | Smooth, organic blob shape following icon contours |
|
|
89
|
+
| `droplet` | Perfect circle/sphere with glass-like highlights |
|
|
90
|
+
| `wax` | Irregular wax seal shape with pressed icon indent |
|
|
91
|
+
|
|
92
|
+
## Animations
|
|
93
|
+
|
|
94
|
+
### Built-in Animations (17 types)
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
// Basic usage
|
|
98
|
+
<IconCraftShape svg={svg} animation="bounce" />
|
|
99
|
+
|
|
100
|
+
// With options
|
|
101
|
+
<IconCraftShape
|
|
102
|
+
svg={svg}
|
|
103
|
+
animation={{
|
|
104
|
+
type: 'pulse',
|
|
105
|
+
duration: 2,
|
|
106
|
+
iterationCount: 'infinite',
|
|
107
|
+
}}
|
|
108
|
+
/>
|
|
109
|
+
|
|
110
|
+
// Animate on hover
|
|
111
|
+
<IconCraftShape svg={svg} animation="jello" animateOnHover />
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### Available Animations
|
|
115
|
+
|
|
116
|
+
| Animation | Description |
|
|
117
|
+
|-----------|-------------|
|
|
118
|
+
| `none` | No animation |
|
|
119
|
+
| `shake` | Horizontal shake |
|
|
120
|
+
| `bounce` | Vertical bounce |
|
|
121
|
+
| `pulse` | Scale pulse |
|
|
122
|
+
| `swing` | Pendulum swing |
|
|
123
|
+
| `wobble` | Wobbly movement |
|
|
124
|
+
| `jello` | Jelly-like squish |
|
|
125
|
+
| `heartbeat` | Double pulse |
|
|
126
|
+
| `float` | Gentle floating |
|
|
127
|
+
| `spin` | 360° rotation |
|
|
128
|
+
| `rubberBand` | Rubber band stretch |
|
|
129
|
+
| `squish` | Squish deformation |
|
|
130
|
+
| `tada` | Attention-grabbing |
|
|
131
|
+
| `flip` | 3D flip |
|
|
132
|
+
| `drop` | Drop with bounce |
|
|
133
|
+
| `pop` | Pop-in effect |
|
|
134
|
+
| `wiggle` | Left-right wiggle |
|
|
135
|
+
| `breathe` | Breathing effect |
|
|
136
|
+
|
|
137
|
+
### Animation Options
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
interface AnimationOptions {
|
|
141
|
+
type: AnimationType;
|
|
142
|
+
target?: 'shape' | 'icon' | 'both'; // What to animate
|
|
143
|
+
duration?: number; // Seconds
|
|
144
|
+
delay?: number; // Seconds
|
|
145
|
+
iterationCount?: number | 'infinite';
|
|
146
|
+
timingFunction?: 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear';
|
|
147
|
+
playState?: 'running' | 'paused';
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Custom Animations
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
import { registerAnimation, IconCraftShape } from '@gospelo-dev/iconcraft-react';
|
|
155
|
+
|
|
156
|
+
// Register custom animation
|
|
157
|
+
registerAnimation('myAnimation', {
|
|
158
|
+
keyframes: `
|
|
159
|
+
@keyframes iconcraft-myAnimation {
|
|
160
|
+
0%, 100% { transform: scale(1); }
|
|
161
|
+
50% { transform: scale(1.5) rotate(10deg); }
|
|
162
|
+
}
|
|
163
|
+
`,
|
|
164
|
+
defaults: {
|
|
165
|
+
duration: 1,
|
|
166
|
+
iterationCount: 'infinite',
|
|
167
|
+
},
|
|
168
|
+
transformOrigin: 'center',
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Use it
|
|
172
|
+
<IconCraftShape svg={svg} animation="myAnimation" />
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Hooks
|
|
176
|
+
|
|
177
|
+
### `useIconCraft`
|
|
178
|
+
|
|
179
|
+
Low-level hook for direct WASM access.
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { useIconCraft } from '@gospelo-dev/iconcraft-react';
|
|
183
|
+
|
|
184
|
+
function MyComponent() {
|
|
185
|
+
const { result, loading, error, generate } = useIconCraft({
|
|
186
|
+
svg: svgContent,
|
|
187
|
+
mode: 'wax',
|
|
188
|
+
color: '#6366f1',
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
if (loading) return <div>Loading...</div>;
|
|
192
|
+
if (error) return <div>Error: {error}</div>;
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<div dangerouslySetInnerHTML={{ __html: result?.emboss_svg || '' }} />
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Context (State Management)
|
|
201
|
+
|
|
202
|
+
For complex applications with multiple icons:
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
import {
|
|
206
|
+
IconCraftProvider,
|
|
207
|
+
useIconCraftStore,
|
|
208
|
+
IconCraftView,
|
|
209
|
+
} from '@gospelo-dev/iconcraft-react';
|
|
210
|
+
|
|
211
|
+
function App() {
|
|
212
|
+
return (
|
|
213
|
+
<IconCraftProvider>
|
|
214
|
+
<IconGallery />
|
|
215
|
+
</IconCraftProvider>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function IconGallery() {
|
|
220
|
+
const { icons, createIcon } = useIconCraftStore();
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<div>
|
|
224
|
+
{icons.map(icon => (
|
|
225
|
+
<IconCraftView key={icon.id} instance={icon} />
|
|
226
|
+
))}
|
|
227
|
+
</div>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## TypeScript
|
|
233
|
+
|
|
234
|
+
Full TypeScript support with exported types:
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import type {
|
|
238
|
+
ShapeMode,
|
|
239
|
+
IconStyle,
|
|
240
|
+
AnimationType,
|
|
241
|
+
AnimationOptions,
|
|
242
|
+
IconCraftResult,
|
|
243
|
+
IconCraftShapeProps,
|
|
244
|
+
} from '@gospelo-dev/iconcraft-react';
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Browser Support
|
|
248
|
+
|
|
249
|
+
Requires WebAssembly support. Works in all modern browsers.
|
|
250
|
+
|
|
251
|
+
## Related
|
|
252
|
+
|
|
253
|
+
- [gospelo-iconcraft-wasm](https://www.npmjs.com/package/gospelo-iconcraft-wasm) - WASM core module
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
MIT
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// ../wasm/icon_craft_wasm.js
|
|
2
|
+
var ShapeMode = Object.freeze({
|
|
3
|
+
Jelly: 0,
|
|
4
|
+
"0": "Jelly",
|
|
5
|
+
Droplet: 1,
|
|
6
|
+
"1": "Droplet",
|
|
7
|
+
Wax: 2,
|
|
8
|
+
"2": "Wax"
|
|
9
|
+
});
|
|
10
|
+
function generate_clippath(svg_content, mode, offset, resolution, simplify_epsilon) {
|
|
11
|
+
const ptr0 = passStringToWasm0(svg_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
12
|
+
const len0 = WASM_VECTOR_LEN;
|
|
13
|
+
const ret = wasm.generate_clippath(ptr0, len0, mode, offset, resolution, simplify_epsilon);
|
|
14
|
+
return ret;
|
|
15
|
+
}
|
|
16
|
+
function generate_clippath_with_color(svg_content, mode, offset, resolution, simplify_epsilon, include_icon, base_color) {
|
|
17
|
+
const ptr0 = passStringToWasm0(svg_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
18
|
+
const len0 = WASM_VECTOR_LEN;
|
|
19
|
+
const ptr1 = passStringToWasm0(base_color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
20
|
+
const len1 = WASM_VECTOR_LEN;
|
|
21
|
+
const ret = wasm.generate_clippath_with_color(ptr0, len0, mode, offset, resolution, simplify_epsilon, include_icon, ptr1, len1);
|
|
22
|
+
return ret;
|
|
23
|
+
}
|
|
24
|
+
function generate_clippath_with_icon(svg_content, mode, offset, resolution, simplify_epsilon, include_icon) {
|
|
25
|
+
const ptr0 = passStringToWasm0(svg_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
26
|
+
const len0 = WASM_VECTOR_LEN;
|
|
27
|
+
const ret = wasm.generate_clippath_with_icon(ptr0, len0, mode, offset, resolution, simplify_epsilon, include_icon);
|
|
28
|
+
return ret;
|
|
29
|
+
}
|
|
30
|
+
function init() {
|
|
31
|
+
wasm.init();
|
|
32
|
+
}
|
|
33
|
+
function __wbg_get_imports() {
|
|
34
|
+
const import0 = {
|
|
35
|
+
__proto__: null,
|
|
36
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
37
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
38
|
+
return ret;
|
|
39
|
+
},
|
|
40
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
41
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
42
|
+
},
|
|
43
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
44
|
+
let deferred0_0;
|
|
45
|
+
let deferred0_1;
|
|
46
|
+
try {
|
|
47
|
+
deferred0_0 = arg0;
|
|
48
|
+
deferred0_1 = arg1;
|
|
49
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
50
|
+
} finally {
|
|
51
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
55
|
+
const ret = new Object();
|
|
56
|
+
return ret;
|
|
57
|
+
},
|
|
58
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
59
|
+
const ret = new Array();
|
|
60
|
+
return ret;
|
|
61
|
+
},
|
|
62
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
63
|
+
const ret = new Error();
|
|
64
|
+
return ret;
|
|
65
|
+
},
|
|
66
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
67
|
+
arg0[arg1] = arg2;
|
|
68
|
+
},
|
|
69
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
70
|
+
arg0[arg1 >>> 0] = arg2;
|
|
71
|
+
},
|
|
72
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
73
|
+
const ret = arg1.stack;
|
|
74
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
75
|
+
const len1 = WASM_VECTOR_LEN;
|
|
76
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
77
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
78
|
+
},
|
|
79
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
80
|
+
const ret = arg0;
|
|
81
|
+
return ret;
|
|
82
|
+
},
|
|
83
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
84
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
85
|
+
return ret;
|
|
86
|
+
},
|
|
87
|
+
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
88
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
89
|
+
return ret;
|
|
90
|
+
},
|
|
91
|
+
__wbindgen_init_externref_table: function() {
|
|
92
|
+
const table = wasm.__wbindgen_externrefs;
|
|
93
|
+
const offset = table.grow(4);
|
|
94
|
+
table.set(0, void 0);
|
|
95
|
+
table.set(offset + 0, void 0);
|
|
96
|
+
table.set(offset + 1, null);
|
|
97
|
+
table.set(offset + 2, true);
|
|
98
|
+
table.set(offset + 3, false);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return {
|
|
102
|
+
__proto__: null,
|
|
103
|
+
"./icon_craft_wasm_bg.js": import0
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
var cachedDataViewMemory0 = null;
|
|
107
|
+
function getDataViewMemory0() {
|
|
108
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
109
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
110
|
+
}
|
|
111
|
+
return cachedDataViewMemory0;
|
|
112
|
+
}
|
|
113
|
+
function getStringFromWasm0(ptr, len) {
|
|
114
|
+
ptr = ptr >>> 0;
|
|
115
|
+
return decodeText(ptr, len);
|
|
116
|
+
}
|
|
117
|
+
var cachedUint8ArrayMemory0 = null;
|
|
118
|
+
function getUint8ArrayMemory0() {
|
|
119
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
120
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
121
|
+
}
|
|
122
|
+
return cachedUint8ArrayMemory0;
|
|
123
|
+
}
|
|
124
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
125
|
+
if (realloc === void 0) {
|
|
126
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
127
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
128
|
+
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
129
|
+
WASM_VECTOR_LEN = buf.length;
|
|
130
|
+
return ptr2;
|
|
131
|
+
}
|
|
132
|
+
let len = arg.length;
|
|
133
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
134
|
+
const mem = getUint8ArrayMemory0();
|
|
135
|
+
let offset = 0;
|
|
136
|
+
for (; offset < len; offset++) {
|
|
137
|
+
const code = arg.charCodeAt(offset);
|
|
138
|
+
if (code > 127) break;
|
|
139
|
+
mem[ptr + offset] = code;
|
|
140
|
+
}
|
|
141
|
+
if (offset !== len) {
|
|
142
|
+
if (offset !== 0) {
|
|
143
|
+
arg = arg.slice(offset);
|
|
144
|
+
}
|
|
145
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
146
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
147
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
148
|
+
offset += ret.written;
|
|
149
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
150
|
+
}
|
|
151
|
+
WASM_VECTOR_LEN = offset;
|
|
152
|
+
return ptr;
|
|
153
|
+
}
|
|
154
|
+
var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
155
|
+
cachedTextDecoder.decode();
|
|
156
|
+
var MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
157
|
+
var numBytesDecoded = 0;
|
|
158
|
+
function decodeText(ptr, len) {
|
|
159
|
+
numBytesDecoded += len;
|
|
160
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
161
|
+
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
162
|
+
cachedTextDecoder.decode();
|
|
163
|
+
numBytesDecoded = len;
|
|
164
|
+
}
|
|
165
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
166
|
+
}
|
|
167
|
+
var cachedTextEncoder = new TextEncoder();
|
|
168
|
+
if (!("encodeInto" in cachedTextEncoder)) {
|
|
169
|
+
cachedTextEncoder.encodeInto = function(arg, view) {
|
|
170
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
171
|
+
view.set(buf);
|
|
172
|
+
return {
|
|
173
|
+
read: arg.length,
|
|
174
|
+
written: buf.length
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
var WASM_VECTOR_LEN = 0;
|
|
179
|
+
var wasmModule;
|
|
180
|
+
var wasm;
|
|
181
|
+
function __wbg_finalize_init(instance, module) {
|
|
182
|
+
wasm = instance.exports;
|
|
183
|
+
wasmModule = module;
|
|
184
|
+
cachedDataViewMemory0 = null;
|
|
185
|
+
cachedUint8ArrayMemory0 = null;
|
|
186
|
+
wasm.__wbindgen_start();
|
|
187
|
+
return wasm;
|
|
188
|
+
}
|
|
189
|
+
async function __wbg_load(module, imports) {
|
|
190
|
+
if (typeof Response === "function" && module instanceof Response) {
|
|
191
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
192
|
+
try {
|
|
193
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
194
|
+
} catch (e) {
|
|
195
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
196
|
+
if (validResponse && module.headers.get("Content-Type") !== "application/wasm") {
|
|
197
|
+
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);
|
|
198
|
+
} else {
|
|
199
|
+
throw e;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const bytes = await module.arrayBuffer();
|
|
204
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
205
|
+
} else {
|
|
206
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
207
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
208
|
+
return { instance, module };
|
|
209
|
+
} else {
|
|
210
|
+
return instance;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function expectedResponseType(type) {
|
|
214
|
+
switch (type) {
|
|
215
|
+
case "basic":
|
|
216
|
+
case "cors":
|
|
217
|
+
case "default":
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function initSync(module) {
|
|
224
|
+
if (wasm !== void 0) return wasm;
|
|
225
|
+
if (module !== void 0) {
|
|
226
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
227
|
+
({ module } = module);
|
|
228
|
+
} else {
|
|
229
|
+
console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const imports = __wbg_get_imports();
|
|
233
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
234
|
+
module = new WebAssembly.Module(module);
|
|
235
|
+
}
|
|
236
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
237
|
+
return __wbg_finalize_init(instance, module);
|
|
238
|
+
}
|
|
239
|
+
async function __wbg_init(module_or_path) {
|
|
240
|
+
if (wasm !== void 0) return wasm;
|
|
241
|
+
if (module_or_path !== void 0) {
|
|
242
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
243
|
+
({ module_or_path } = module_or_path);
|
|
244
|
+
} else {
|
|
245
|
+
console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (module_or_path === void 0) {
|
|
249
|
+
module_or_path = new URL("icon_craft_wasm_bg.wasm", import.meta.url);
|
|
250
|
+
}
|
|
251
|
+
const imports = __wbg_get_imports();
|
|
252
|
+
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
|
|
253
|
+
module_or_path = fetch(module_or_path);
|
|
254
|
+
}
|
|
255
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
256
|
+
return __wbg_finalize_init(instance, module);
|
|
257
|
+
}
|
|
258
|
+
export {
|
|
259
|
+
ShapeMode,
|
|
260
|
+
__wbg_init as default,
|
|
261
|
+
generate_clippath,
|
|
262
|
+
generate_clippath_with_color,
|
|
263
|
+
generate_clippath_with_icon,
|
|
264
|
+
init,
|
|
265
|
+
initSync
|
|
266
|
+
};
|