float-pigment-css 0.1.1-alpha.1
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 +67 -0
- package/float_pigment_css.d.ts +75 -0
- package/float_pigment_css.js +547 -0
- package/float_pigment_css_bg.wasm +0 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# float-pigment-css
|
|
2
|
+
|
|
3
|
+
The CSS parser for the float-pigment project.
|
|
4
|
+
|
|
5
|
+
This is a crate of the [float-pigment](https://github.com/wechat-miniprogram/float-pigment) project. See its documentation for details.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Compile to WebAssembly
|
|
9
|
+
|
|
10
|
+
In most cases this module is a dependency for high-level modules.
|
|
11
|
+
|
|
12
|
+
But more, this module can be compiled to WebAssembly itself, and can be called from JavaScript.
|
|
13
|
+
|
|
14
|
+
With [wasm-pack](https://github.com/rustwasm/wasm-pack) installed globally:
|
|
15
|
+
|
|
16
|
+
```shell
|
|
17
|
+
wasm-pack build float-pigment-css --target nodejs --features nodejs-package
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Generate C++ Headers
|
|
22
|
+
|
|
23
|
+
This module contains C++ bindings, and it generates a C++ header file for visiting from C++. However, the C++ header should be updated manually.
|
|
24
|
+
|
|
25
|
+
To update the C++ header, make sure installed:
|
|
26
|
+
|
|
27
|
+
* [cargo-expand](https://github.com/dtolnay/cargo-expand)
|
|
28
|
+
|
|
29
|
+
The C++ header update command:
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
cargo run --bin float_pigment_css_cpp_binding_gen_tool --features build-cpp-header
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Compatibility Checks
|
|
37
|
+
|
|
38
|
+
Some `serde` structs and enums needs compatibility checks.
|
|
39
|
+
|
|
40
|
+
This is because the `serialize_bincode` and `deserialize_bincode` forbid some changes to keep compatibilities across versions.
|
|
41
|
+
It means that structs and enums can only *add new fields* but not *modify fields*.
|
|
42
|
+
This is done by compare the current version of struct/enum definitions and the corresponding previous one.
|
|
43
|
+
The previous struct/enum definitions are stored in the `compile_cache` dir.
|
|
44
|
+
|
|
45
|
+
For new struct/enum that needs across-version compatibilities, `CompatibilityStructCheck` and `CompatibilityEnumCheck` macros must be derived.
|
|
46
|
+
When struct/enum name conflicts, `compatibility_struct_check` can be used to specify a name prefix. For example:
|
|
47
|
+
|
|
48
|
+
```rust
|
|
49
|
+
#[derive(Serialize, Deserialize, CompatibilityEnumCheck)]
|
|
50
|
+
enum Name {
|
|
51
|
+
None
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#[derive(Serialize, Deserialize, CompatibilityStructCheck)]
|
|
55
|
+
struct Hello {
|
|
56
|
+
name: String
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#[compatibility_struct_check(mod_name)]
|
|
60
|
+
#[derive(Serialize, Deserialize)]
|
|
61
|
+
struct Hello {
|
|
62
|
+
name: String
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
To update the `compile_cache`, run `cargo run --bin float_pigment_css_update_version --features compile_cache`.
|
|
67
|
+
(This will be automatically done by the publish script.)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function wasm_main(): void;
|
|
4
|
+
/**
|
|
5
|
+
* Serialize CSS to the binary format.
|
|
6
|
+
*/
|
|
7
|
+
export function compileStyleSheetToBincode(filename: string, style_text: string): Uint8Array;
|
|
8
|
+
/**
|
|
9
|
+
* Deserialize bincode from the binary format.
|
|
10
|
+
*/
|
|
11
|
+
export function styleSheetFromBincode(bincode: Uint8Array): StyleSheetGroup;
|
|
12
|
+
/**
|
|
13
|
+
* A group of ordered style sheets.
|
|
14
|
+
*/
|
|
15
|
+
export class StyleSheetGroup {
|
|
16
|
+
private constructor();
|
|
17
|
+
free(): void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Import information of style sheet resources.
|
|
21
|
+
*/
|
|
22
|
+
export class StyleSheetImportIndex {
|
|
23
|
+
private constructor();
|
|
24
|
+
free(): void;
|
|
25
|
+
/**
|
|
26
|
+
* The JavaScript version of `query_and_mark_dependencies`.
|
|
27
|
+
*/
|
|
28
|
+
queryAndMarkDependencies(path: string): any;
|
|
29
|
+
/**
|
|
30
|
+
* Serialize it to the binary format.
|
|
31
|
+
*/
|
|
32
|
+
serializeBincode(): Uint8Array;
|
|
33
|
+
/**
|
|
34
|
+
* Deserialize from the binary format.
|
|
35
|
+
*/
|
|
36
|
+
static deserializeBincode(s: Uint8Array): StyleSheetImportIndex;
|
|
37
|
+
/**
|
|
38
|
+
* Deserialize from the binary format and merge into `self`.
|
|
39
|
+
*/
|
|
40
|
+
mergeBincode(s: Uint8Array): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Resource manager to store style sheet files.
|
|
44
|
+
*/
|
|
45
|
+
export class StyleSheetResource {
|
|
46
|
+
free(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Create a new resource manager.
|
|
49
|
+
*/
|
|
50
|
+
constructor();
|
|
51
|
+
/**
|
|
52
|
+
* Generate a `StyleSheetImportIndex`.
|
|
53
|
+
*/
|
|
54
|
+
generateImportIndexes(): StyleSheetImportIndex;
|
|
55
|
+
/**
|
|
56
|
+
* Add a prefix to all tag names.
|
|
57
|
+
*/
|
|
58
|
+
addTagNamePrefix(path: string, prefix: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Get `@import` source paths (for JavaScript).
|
|
61
|
+
*/
|
|
62
|
+
directDependencies(path: string): any[];
|
|
63
|
+
/**
|
|
64
|
+
* Serialize the specified style sheet to the binary format.
|
|
65
|
+
*/
|
|
66
|
+
serializeBincode(path: string): Uint8Array | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Add a style sheet file (for JavaScript).
|
|
69
|
+
*/
|
|
70
|
+
addSource(path: string, source: string): any;
|
|
71
|
+
/**
|
|
72
|
+
* Add a style sheet file in the binary format (for JavaScript).
|
|
73
|
+
*/
|
|
74
|
+
addBincode(path: string, bincode: Uint8Array): any;
|
|
75
|
+
}
|
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
|
|
2
|
+
let imports = {};
|
|
3
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
|
+
let wasm;
|
|
5
|
+
const { TextDecoder, TextEncoder } = require(`util`);
|
|
6
|
+
|
|
7
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
8
|
+
|
|
9
|
+
cachedTextDecoder.decode();
|
|
10
|
+
|
|
11
|
+
let cachedUint8ArrayMemory0 = null;
|
|
12
|
+
|
|
13
|
+
function getUint8ArrayMemory0() {
|
|
14
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
15
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
16
|
+
}
|
|
17
|
+
return cachedUint8ArrayMemory0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getStringFromWasm0(ptr, len) {
|
|
21
|
+
ptr = ptr >>> 0;
|
|
22
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function addToExternrefTable0(obj) {
|
|
26
|
+
const idx = wasm.__externref_table_alloc();
|
|
27
|
+
wasm.__wbindgen_export_3.set(idx, obj);
|
|
28
|
+
return idx;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function handleError(f, args) {
|
|
32
|
+
try {
|
|
33
|
+
return f.apply(this, args);
|
|
34
|
+
} catch (e) {
|
|
35
|
+
const idx = addToExternrefTable0(e);
|
|
36
|
+
wasm.__wbindgen_exn_store(idx);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let WASM_VECTOR_LEN = 0;
|
|
41
|
+
|
|
42
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
43
|
+
|
|
44
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
45
|
+
? function (arg, view) {
|
|
46
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
47
|
+
}
|
|
48
|
+
: function (arg, view) {
|
|
49
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
50
|
+
view.set(buf);
|
|
51
|
+
return {
|
|
52
|
+
read: arg.length,
|
|
53
|
+
written: buf.length
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
58
|
+
|
|
59
|
+
if (realloc === undefined) {
|
|
60
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
61
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
62
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
63
|
+
WASM_VECTOR_LEN = buf.length;
|
|
64
|
+
return ptr;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let len = arg.length;
|
|
68
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
69
|
+
|
|
70
|
+
const mem = getUint8ArrayMemory0();
|
|
71
|
+
|
|
72
|
+
let offset = 0;
|
|
73
|
+
|
|
74
|
+
for (; offset < len; offset++) {
|
|
75
|
+
const code = arg.charCodeAt(offset);
|
|
76
|
+
if (code > 0x7F) break;
|
|
77
|
+
mem[ptr + offset] = code;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (offset !== len) {
|
|
81
|
+
if (offset !== 0) {
|
|
82
|
+
arg = arg.slice(offset);
|
|
83
|
+
}
|
|
84
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
85
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
86
|
+
const ret = encodeString(arg, view);
|
|
87
|
+
|
|
88
|
+
offset += ret.written;
|
|
89
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
WASM_VECTOR_LEN = offset;
|
|
93
|
+
return ptr;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let cachedDataViewMemory0 = null;
|
|
97
|
+
|
|
98
|
+
function getDataViewMemory0() {
|
|
99
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
100
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
101
|
+
}
|
|
102
|
+
return cachedDataViewMemory0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function debugString(val) {
|
|
106
|
+
// primitive types
|
|
107
|
+
const type = typeof val;
|
|
108
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
109
|
+
return `${val}`;
|
|
110
|
+
}
|
|
111
|
+
if (type == 'string') {
|
|
112
|
+
return `"${val}"`;
|
|
113
|
+
}
|
|
114
|
+
if (type == 'symbol') {
|
|
115
|
+
const description = val.description;
|
|
116
|
+
if (description == null) {
|
|
117
|
+
return 'Symbol';
|
|
118
|
+
} else {
|
|
119
|
+
return `Symbol(${description})`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (type == 'function') {
|
|
123
|
+
const name = val.name;
|
|
124
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
125
|
+
return `Function(${name})`;
|
|
126
|
+
} else {
|
|
127
|
+
return 'Function';
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// objects
|
|
131
|
+
if (Array.isArray(val)) {
|
|
132
|
+
const length = val.length;
|
|
133
|
+
let debug = '[';
|
|
134
|
+
if (length > 0) {
|
|
135
|
+
debug += debugString(val[0]);
|
|
136
|
+
}
|
|
137
|
+
for(let i = 1; i < length; i++) {
|
|
138
|
+
debug += ', ' + debugString(val[i]);
|
|
139
|
+
}
|
|
140
|
+
debug += ']';
|
|
141
|
+
return debug;
|
|
142
|
+
}
|
|
143
|
+
// Test for built-in
|
|
144
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
145
|
+
let className;
|
|
146
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
147
|
+
className = builtInMatches[1];
|
|
148
|
+
} else {
|
|
149
|
+
// Failed to match the standard '[object ClassName]'
|
|
150
|
+
return toString.call(val);
|
|
151
|
+
}
|
|
152
|
+
if (className == 'Object') {
|
|
153
|
+
// we're a user defined class or Object
|
|
154
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
155
|
+
// easier than looping through ownProperties of `val`.
|
|
156
|
+
try {
|
|
157
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
158
|
+
} catch (_) {
|
|
159
|
+
return 'Object';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// errors
|
|
163
|
+
if (val instanceof Error) {
|
|
164
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
165
|
+
}
|
|
166
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
167
|
+
return className;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
171
|
+
ptr = ptr >>> 0;
|
|
172
|
+
const mem = getDataViewMemory0();
|
|
173
|
+
const result = [];
|
|
174
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
175
|
+
result.push(wasm.__wbindgen_export_3.get(mem.getUint32(i, true)));
|
|
176
|
+
}
|
|
177
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
182
|
+
ptr = ptr >>> 0;
|
|
183
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
187
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
188
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
189
|
+
WASM_VECTOR_LEN = arg.length;
|
|
190
|
+
return ptr;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
module.exports.wasm_main = function() {
|
|
194
|
+
wasm.wasm_main();
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Serialize CSS to the binary format.
|
|
199
|
+
* @param {string} filename
|
|
200
|
+
* @param {string} style_text
|
|
201
|
+
* @returns {Uint8Array}
|
|
202
|
+
*/
|
|
203
|
+
module.exports.compileStyleSheetToBincode = function(filename, style_text) {
|
|
204
|
+
const ptr0 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
205
|
+
const len0 = WASM_VECTOR_LEN;
|
|
206
|
+
const ptr1 = passStringToWasm0(style_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
207
|
+
const len1 = WASM_VECTOR_LEN;
|
|
208
|
+
const ret = wasm.compileStyleSheetToBincode(ptr0, len0, ptr1, len1);
|
|
209
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
210
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
211
|
+
return v3;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Deserialize bincode from the binary format.
|
|
216
|
+
* @param {Uint8Array} bincode
|
|
217
|
+
* @returns {StyleSheetGroup}
|
|
218
|
+
*/
|
|
219
|
+
module.exports.styleSheetFromBincode = function(bincode) {
|
|
220
|
+
const ptr0 = passArray8ToWasm0(bincode, wasm.__wbindgen_malloc);
|
|
221
|
+
const len0 = WASM_VECTOR_LEN;
|
|
222
|
+
const ret = wasm.styleSheetFromBincode(ptr0, len0);
|
|
223
|
+
return StyleSheetGroup.__wrap(ret);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const StyleSheetGroupFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
227
|
+
? { register: () => {}, unregister: () => {} }
|
|
228
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_stylesheetgroup_free(ptr >>> 0, 1));
|
|
229
|
+
/**
|
|
230
|
+
* A group of ordered style sheets.
|
|
231
|
+
*/
|
|
232
|
+
class StyleSheetGroup {
|
|
233
|
+
|
|
234
|
+
static __wrap(ptr) {
|
|
235
|
+
ptr = ptr >>> 0;
|
|
236
|
+
const obj = Object.create(StyleSheetGroup.prototype);
|
|
237
|
+
obj.__wbg_ptr = ptr;
|
|
238
|
+
StyleSheetGroupFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
239
|
+
return obj;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
__destroy_into_raw() {
|
|
243
|
+
const ptr = this.__wbg_ptr;
|
|
244
|
+
this.__wbg_ptr = 0;
|
|
245
|
+
StyleSheetGroupFinalization.unregister(this);
|
|
246
|
+
return ptr;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
free() {
|
|
250
|
+
const ptr = this.__destroy_into_raw();
|
|
251
|
+
wasm.__wbg_stylesheetgroup_free(ptr, 0);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
module.exports.StyleSheetGroup = StyleSheetGroup;
|
|
255
|
+
|
|
256
|
+
const StyleSheetImportIndexFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
257
|
+
? { register: () => {}, unregister: () => {} }
|
|
258
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_stylesheetimportindex_free(ptr >>> 0, 1));
|
|
259
|
+
/**
|
|
260
|
+
* Import information of style sheet resources.
|
|
261
|
+
*/
|
|
262
|
+
class StyleSheetImportIndex {
|
|
263
|
+
|
|
264
|
+
static __wrap(ptr) {
|
|
265
|
+
ptr = ptr >>> 0;
|
|
266
|
+
const obj = Object.create(StyleSheetImportIndex.prototype);
|
|
267
|
+
obj.__wbg_ptr = ptr;
|
|
268
|
+
StyleSheetImportIndexFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
269
|
+
return obj;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
__destroy_into_raw() {
|
|
273
|
+
const ptr = this.__wbg_ptr;
|
|
274
|
+
this.__wbg_ptr = 0;
|
|
275
|
+
StyleSheetImportIndexFinalization.unregister(this);
|
|
276
|
+
return ptr;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
free() {
|
|
280
|
+
const ptr = this.__destroy_into_raw();
|
|
281
|
+
wasm.__wbg_stylesheetimportindex_free(ptr, 0);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* The JavaScript version of `query_and_mark_dependencies`.
|
|
285
|
+
* @param {string} path
|
|
286
|
+
* @returns {any}
|
|
287
|
+
*/
|
|
288
|
+
queryAndMarkDependencies(path) {
|
|
289
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
290
|
+
const len0 = WASM_VECTOR_LEN;
|
|
291
|
+
const ret = wasm.stylesheetimportindex_queryAndMarkDependencies(this.__wbg_ptr, ptr0, len0);
|
|
292
|
+
return ret;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Serialize it to the binary format.
|
|
296
|
+
* @returns {Uint8Array}
|
|
297
|
+
*/
|
|
298
|
+
serializeBincode() {
|
|
299
|
+
const ret = wasm.stylesheetimportindex_serializeBincode(this.__wbg_ptr);
|
|
300
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
301
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
302
|
+
return v1;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Deserialize from the binary format.
|
|
306
|
+
* @param {Uint8Array} s
|
|
307
|
+
* @returns {StyleSheetImportIndex}
|
|
308
|
+
*/
|
|
309
|
+
static deserializeBincode(s) {
|
|
310
|
+
const ptr0 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
|
|
311
|
+
const len0 = WASM_VECTOR_LEN;
|
|
312
|
+
const ret = wasm.stylesheetimportindex_deserializeBincode(ptr0, len0);
|
|
313
|
+
return StyleSheetImportIndex.__wrap(ret);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Deserialize from the binary format and merge into `self`.
|
|
317
|
+
* @param {Uint8Array} s
|
|
318
|
+
*/
|
|
319
|
+
mergeBincode(s) {
|
|
320
|
+
const ptr0 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
|
|
321
|
+
const len0 = WASM_VECTOR_LEN;
|
|
322
|
+
wasm.stylesheetimportindex_mergeBincode(this.__wbg_ptr, ptr0, len0);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
module.exports.StyleSheetImportIndex = StyleSheetImportIndex;
|
|
326
|
+
|
|
327
|
+
const StyleSheetResourceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
328
|
+
? { register: () => {}, unregister: () => {} }
|
|
329
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_stylesheetresource_free(ptr >>> 0, 1));
|
|
330
|
+
/**
|
|
331
|
+
* Resource manager to store style sheet files.
|
|
332
|
+
*/
|
|
333
|
+
class StyleSheetResource {
|
|
334
|
+
|
|
335
|
+
__destroy_into_raw() {
|
|
336
|
+
const ptr = this.__wbg_ptr;
|
|
337
|
+
this.__wbg_ptr = 0;
|
|
338
|
+
StyleSheetResourceFinalization.unregister(this);
|
|
339
|
+
return ptr;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
free() {
|
|
343
|
+
const ptr = this.__destroy_into_raw();
|
|
344
|
+
wasm.__wbg_stylesheetresource_free(ptr, 0);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Create a new resource manager.
|
|
348
|
+
*/
|
|
349
|
+
constructor() {
|
|
350
|
+
const ret = wasm.stylesheetresource_new();
|
|
351
|
+
this.__wbg_ptr = ret >>> 0;
|
|
352
|
+
StyleSheetResourceFinalization.register(this, this.__wbg_ptr, this);
|
|
353
|
+
return this;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Generate a `StyleSheetImportIndex`.
|
|
357
|
+
* @returns {StyleSheetImportIndex}
|
|
358
|
+
*/
|
|
359
|
+
generateImportIndexes() {
|
|
360
|
+
const ret = wasm.stylesheetresource_generateImportIndexes(this.__wbg_ptr);
|
|
361
|
+
return StyleSheetImportIndex.__wrap(ret);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Add a prefix to all tag names.
|
|
365
|
+
* @param {string} path
|
|
366
|
+
* @param {string} prefix
|
|
367
|
+
*/
|
|
368
|
+
addTagNamePrefix(path, prefix) {
|
|
369
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
370
|
+
const len0 = WASM_VECTOR_LEN;
|
|
371
|
+
const ptr1 = passStringToWasm0(prefix, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
372
|
+
const len1 = WASM_VECTOR_LEN;
|
|
373
|
+
wasm.stylesheetresource_addTagNamePrefix(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Get `@import` source paths (for JavaScript).
|
|
377
|
+
* @param {string} path
|
|
378
|
+
* @returns {any[]}
|
|
379
|
+
*/
|
|
380
|
+
directDependencies(path) {
|
|
381
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
382
|
+
const len0 = WASM_VECTOR_LEN;
|
|
383
|
+
const ret = wasm.stylesheetresource_directDependencies(this.__wbg_ptr, ptr0, len0);
|
|
384
|
+
var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
385
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
386
|
+
return v2;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Serialize the specified style sheet to the binary format.
|
|
390
|
+
* @param {string} path
|
|
391
|
+
* @returns {Uint8Array | undefined}
|
|
392
|
+
*/
|
|
393
|
+
serializeBincode(path) {
|
|
394
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
395
|
+
const len0 = WASM_VECTOR_LEN;
|
|
396
|
+
const ret = wasm.stylesheetresource_serializeBincode(this.__wbg_ptr, ptr0, len0);
|
|
397
|
+
let v2;
|
|
398
|
+
if (ret[0] !== 0) {
|
|
399
|
+
v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
400
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
401
|
+
}
|
|
402
|
+
return v2;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Add a style sheet file (for JavaScript).
|
|
406
|
+
* @param {string} path
|
|
407
|
+
* @param {string} source
|
|
408
|
+
* @returns {any}
|
|
409
|
+
*/
|
|
410
|
+
addSource(path, source) {
|
|
411
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
412
|
+
const len0 = WASM_VECTOR_LEN;
|
|
413
|
+
const ptr1 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
414
|
+
const len1 = WASM_VECTOR_LEN;
|
|
415
|
+
const ret = wasm.stylesheetresource_addSource(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
416
|
+
return ret;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Add a style sheet file in the binary format (for JavaScript).
|
|
420
|
+
* @param {string} path
|
|
421
|
+
* @param {Uint8Array} bincode
|
|
422
|
+
* @returns {any}
|
|
423
|
+
*/
|
|
424
|
+
addBincode(path, bincode) {
|
|
425
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
426
|
+
const len0 = WASM_VECTOR_LEN;
|
|
427
|
+
const ptr1 = passArray8ToWasm0(bincode, wasm.__wbindgen_malloc);
|
|
428
|
+
const len1 = WASM_VECTOR_LEN;
|
|
429
|
+
const ret = wasm.stylesheetresource_addBincode(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
430
|
+
return ret;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
module.exports.StyleSheetResource = StyleSheetResource;
|
|
434
|
+
|
|
435
|
+
module.exports.__wbg_debug_156ca727dbc3150f = function(arg0) {
|
|
436
|
+
console.debug(arg0);
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
module.exports.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
440
|
+
let deferred0_0;
|
|
441
|
+
let deferred0_1;
|
|
442
|
+
try {
|
|
443
|
+
deferred0_0 = arg0;
|
|
444
|
+
deferred0_1 = arg1;
|
|
445
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
446
|
+
} finally {
|
|
447
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
module.exports.__wbg_error_fab41a42d22bf2bc = function(arg0) {
|
|
452
|
+
console.error(arg0);
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
module.exports.__wbg_info_c3044c86ae29faab = function(arg0) {
|
|
456
|
+
console.info(arg0);
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
module.exports.__wbg_log_464d1b2190ca1e04 = function(arg0) {
|
|
460
|
+
console.log(arg0);
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
module.exports.__wbg_new_254fa9eac11932ae = function() {
|
|
464
|
+
const ret = new Array();
|
|
465
|
+
return ret;
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
module.exports.__wbg_new_688846f374351c92 = function() {
|
|
469
|
+
const ret = new Object();
|
|
470
|
+
return ret;
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
module.exports.__wbg_new_8a6f238a6ece86ea = function() {
|
|
474
|
+
const ret = new Error();
|
|
475
|
+
return ret;
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
module.exports.__wbg_newwithlength_759c7b9d6a7a314f = function(arg0) {
|
|
479
|
+
const ret = new Array(arg0 >>> 0);
|
|
480
|
+
return ret;
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
module.exports.__wbg_push_6edad0df4b546b2c = function(arg0, arg1) {
|
|
484
|
+
const ret = arg0.push(arg1);
|
|
485
|
+
return ret;
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
module.exports.__wbg_set_4e647025551483bd = function() { return handleError(function (arg0, arg1, arg2) {
|
|
489
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
490
|
+
return ret;
|
|
491
|
+
}, arguments) };
|
|
492
|
+
|
|
493
|
+
module.exports.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
494
|
+
const ret = arg1.stack;
|
|
495
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
496
|
+
const len1 = WASM_VECTOR_LEN;
|
|
497
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
498
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
module.exports.__wbg_warn_123db6aa8948382e = function(arg0) {
|
|
502
|
+
console.warn(arg0);
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
module.exports.__wbindgen_debug_string = function(arg0, arg1) {
|
|
506
|
+
const ret = debugString(arg1);
|
|
507
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
508
|
+
const len1 = WASM_VECTOR_LEN;
|
|
509
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
510
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
module.exports.__wbindgen_init_externref_table = function() {
|
|
514
|
+
const table = wasm.__wbindgen_export_3;
|
|
515
|
+
const offset = table.grow(4);
|
|
516
|
+
table.set(0, undefined);
|
|
517
|
+
table.set(offset + 0, undefined);
|
|
518
|
+
table.set(offset + 1, null);
|
|
519
|
+
table.set(offset + 2, true);
|
|
520
|
+
table.set(offset + 3, false);
|
|
521
|
+
;
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
module.exports.__wbindgen_number_new = function(arg0) {
|
|
525
|
+
const ret = arg0;
|
|
526
|
+
return ret;
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
530
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
531
|
+
return ret;
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
|
535
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
const path = require('path').join(__dirname, 'float_pigment_css_bg.wasm');
|
|
539
|
+
const bytes = require('fs').readFileSync(path);
|
|
540
|
+
|
|
541
|
+
const wasmModule = new WebAssembly.Module(bytes);
|
|
542
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
543
|
+
wasm = wasmInstance.exports;
|
|
544
|
+
module.exports.__wasm = wasm;
|
|
545
|
+
|
|
546
|
+
wasm.__wbindgen_start();
|
|
547
|
+
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "float-pigment-css",
|
|
3
|
+
"collaborators": [
|
|
4
|
+
"LastLeaf <bqfu@163.com>",
|
|
5
|
+
"TtTRz <romc1224@gmail.com>"
|
|
6
|
+
],
|
|
7
|
+
"description": "The CSS parser for the float-pigment project.",
|
|
8
|
+
"version": "0.1.1-alpha.1",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/wechat-miniprogram/float-pigment"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"float_pigment_css_bg.wasm",
|
|
16
|
+
"float_pigment_css.js",
|
|
17
|
+
"float_pigment_css.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"main": "float_pigment_css.js",
|
|
20
|
+
"homepage": "https://github.com/wechat-miniprogram/float-pigment",
|
|
21
|
+
"types": "float_pigment_css.d.ts",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"CSS",
|
|
24
|
+
"flexbox",
|
|
25
|
+
"layout"
|
|
26
|
+
]
|
|
27
|
+
}
|