rust-editor 0.3.2 → 0.3.4
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/package.json +1 -1
- package/rust_editor.d.ts +3 -0
- package/rust_editor.js +69 -0
- package/rust_editor_bg.wasm +0 -0
package/package.json
CHANGED
package/rust_editor.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export function switch_color(image_source: Uint8Array, image_reference: Uint8Arr
|
|
|
5
5
|
export function blur(image_data: Uint8Array, radius: number): Uint8Array;
|
|
6
6
|
export function sharpen(image_data: Uint8Array, radius: number): Uint8Array;
|
|
7
7
|
export function fix_size_image(image_data: Uint8Array): Uint8Array;
|
|
8
|
+
export function extend_size_image(image_data: Uint8Array, size_type: string): Uint8Array;
|
|
8
9
|
export function grayscale_image(image_data: Uint8Array): Uint8Array;
|
|
9
10
|
export function adjust_saturation_image(image_data: Uint8Array, saturation: number): Uint8Array;
|
|
10
11
|
export function adjust_temperature_image(image_data: Uint8Array, temperature: number): Uint8Array;
|
|
@@ -23,6 +24,7 @@ export interface InitOutput {
|
|
|
23
24
|
readonly blur: (a: number, b: number, c: number) => [number, number];
|
|
24
25
|
readonly sharpen: (a: number, b: number, c: number) => [number, number];
|
|
25
26
|
readonly fix_size_image: (a: number, b: number) => [number, number];
|
|
27
|
+
readonly extend_size_image: (a: number, b: number, c: number, d: number) => [number, number];
|
|
26
28
|
readonly grayscale_image: (a: number, b: number) => [number, number];
|
|
27
29
|
readonly adjust_saturation_image: (a: number, b: number, c: number) => [number, number];
|
|
28
30
|
readonly adjust_temperature_image: (a: number, b: number, c: number) => [number, number];
|
|
@@ -34,6 +36,7 @@ export interface InitOutput {
|
|
|
34
36
|
readonly __wbindgen_export_0: WebAssembly.Table;
|
|
35
37
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
36
38
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
39
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
37
40
|
readonly __wbindgen_start: () => void;
|
|
38
41
|
}
|
|
39
42
|
|
package/rust_editor.js
CHANGED
|
@@ -105,6 +105,75 @@ export function fix_size_image(image_data) {
|
|
|
105
105
|
return v2;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
109
|
+
|
|
110
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
111
|
+
? function (arg, view) {
|
|
112
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
113
|
+
}
|
|
114
|
+
: function (arg, view) {
|
|
115
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
116
|
+
view.set(buf);
|
|
117
|
+
return {
|
|
118
|
+
read: arg.length,
|
|
119
|
+
written: buf.length
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
124
|
+
|
|
125
|
+
if (realloc === undefined) {
|
|
126
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
127
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
128
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
129
|
+
WASM_VECTOR_LEN = buf.length;
|
|
130
|
+
return ptr;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
let len = arg.length;
|
|
134
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
135
|
+
|
|
136
|
+
const mem = getUint8ArrayMemory0();
|
|
137
|
+
|
|
138
|
+
let offset = 0;
|
|
139
|
+
|
|
140
|
+
for (; offset < len; offset++) {
|
|
141
|
+
const code = arg.charCodeAt(offset);
|
|
142
|
+
if (code > 0x7F) break;
|
|
143
|
+
mem[ptr + offset] = code;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (offset !== len) {
|
|
147
|
+
if (offset !== 0) {
|
|
148
|
+
arg = arg.slice(offset);
|
|
149
|
+
}
|
|
150
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
151
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
152
|
+
const ret = encodeString(arg, view);
|
|
153
|
+
|
|
154
|
+
offset += ret.written;
|
|
155
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
WASM_VECTOR_LEN = offset;
|
|
159
|
+
return ptr;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @param {Uint8Array} image_data
|
|
163
|
+
* @param {string} size_type
|
|
164
|
+
* @returns {Uint8Array}
|
|
165
|
+
*/
|
|
166
|
+
export function extend_size_image(image_data, size_type) {
|
|
167
|
+
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_malloc);
|
|
168
|
+
const len0 = WASM_VECTOR_LEN;
|
|
169
|
+
const ptr1 = passStringToWasm0(size_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
170
|
+
const len1 = WASM_VECTOR_LEN;
|
|
171
|
+
const ret = wasm.extend_size_image(ptr0, len0, ptr1, len1);
|
|
172
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
173
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
174
|
+
return v3;
|
|
175
|
+
}
|
|
176
|
+
|
|
108
177
|
/**
|
|
109
178
|
* @param {Uint8Array} image_data
|
|
110
179
|
* @returns {Uint8Array}
|
package/rust_editor_bg.wasm
CHANGED
|
Binary file
|