toon-ld 0.1.1 → 0.2.2
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 +339 -0
- package/package.json +12 -34
- package/toon_wasm.d.ts +126 -0
- package/toon_wasm.js +729 -0
- package/toon_wasm_bg.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# toon-ld
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/toon-ld)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
**Token-Oriented Object Notation for Linked Data** — A compact RDF serialization format that achieves 40-60% token reduction compared to JSON-LD, making it ideal for LLM applications and bandwidth-constrained environments.
|
|
7
|
+
|
|
8
|
+
TOON-LD extends TOON in the same way that JSON-LD extends JSON: **every valid TOON-LD document is also a valid TOON document**. Base TOON parsers can process TOON-LD without modification, while TOON-LD processors interpret `@-prefixed` keys according to JSON-LD semantics.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **40-60% Token Reduction**: Fewer tokens means lower LLM costs and more data in context windows
|
|
13
|
+
- **Full JSON-LD Compatibility**: Round-trip conversion without data loss
|
|
14
|
+
- **Tabular Arrays**: Serialize arrays of objects as CSV-like rows with shared headers
|
|
15
|
+
- **All JSON-LD 1.1 Keywords**: Complete support for `@context`, `@graph`, `@id`, `@type`, value nodes, etc.
|
|
16
|
+
- **WebAssembly Performance**: Compiled from Rust for high-performance parsing and serialization
|
|
17
|
+
- **TypeScript Support**: Fully typed API with excellent IDE support
|
|
18
|
+
- **Browser & Node.js**: Works in both environments
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install toon-ld
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or with yarn:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
yarn add toon-ld
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import { encode, decode, parse, stringify } from 'toon-ld';
|
|
36
|
+
|
|
37
|
+
// 1. String Conversion
|
|
38
|
+
// Convert JSON-LD to TOON-LD
|
|
39
|
+
const jsonLd = JSON.stringify({
|
|
40
|
+
"@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
|
|
41
|
+
"foaf:name": "Alice",
|
|
42
|
+
"foaf:age": 30
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const toon = encode(jsonLd);
|
|
46
|
+
console.log(toon);
|
|
47
|
+
// Output:
|
|
48
|
+
// @context:
|
|
49
|
+
// foaf: http://xmlns.com/foaf/0.1/
|
|
50
|
+
// foaf:name: Alice
|
|
51
|
+
// foaf:age: 30
|
|
52
|
+
|
|
53
|
+
// Convert back to JSON-LD
|
|
54
|
+
const backToJson = decode(toon);
|
|
55
|
+
const parsed = JSON.parse(backToJson);
|
|
56
|
+
console.log(parsed);
|
|
57
|
+
|
|
58
|
+
// 2. Object Helper Functions
|
|
59
|
+
// Parse directly to JS Object
|
|
60
|
+
const data = parse(toon);
|
|
61
|
+
console.log(data['foaf:name']); // "Alice"
|
|
62
|
+
|
|
63
|
+
// Serialize JS Object directly to TOON-LD
|
|
64
|
+
const toonStr = stringify({
|
|
65
|
+
"@context": {"schema": "http://schema.org/"},
|
|
66
|
+
"schema:name": "Bob"
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Tabular Arrays - The Key Feature
|
|
71
|
+
|
|
72
|
+
TOON-LD's most powerful feature is efficient serialization of arrays of objects:
|
|
73
|
+
|
|
74
|
+
**JSON-LD (repetitive keys):**
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
|
|
78
|
+
"@graph": [
|
|
79
|
+
{"@id": "ex:1", "@type": "foaf:Person", "foaf:name": "Alice", "foaf:age": 30},
|
|
80
|
+
{"@id": "ex:2", "@type": "foaf:Person", "foaf:name": "Bob", "foaf:age": 25},
|
|
81
|
+
{"@id": "ex:3", "@type": "foaf:Person", "foaf:name": "Carol", "foaf:age": 28}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**TOON-LD (shared headers):**
|
|
87
|
+
```
|
|
88
|
+
@context:
|
|
89
|
+
foaf: http://xmlns.com/foaf/0.1/
|
|
90
|
+
@graph[3]{@id,@type,foaf:age,foaf:name}:
|
|
91
|
+
ex:1, foaf:Person, 30, Alice
|
|
92
|
+
ex:2, foaf:Person, 25, Bob
|
|
93
|
+
ex:3, foaf:Person, 28, Carol
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Notice how object keys appear once in the header instead of repeating for each object.
|
|
97
|
+
|
|
98
|
+
## API Reference
|
|
99
|
+
|
|
100
|
+
### `encode(json: string): string`
|
|
101
|
+
|
|
102
|
+
Convert (encode) a JSON-LD string to TOON-LD format.
|
|
103
|
+
|
|
104
|
+
**Parameters:**
|
|
105
|
+
- `json` - A JSON or JSON-LD formatted string
|
|
106
|
+
|
|
107
|
+
**Returns:**
|
|
108
|
+
- TOON-LD formatted string
|
|
109
|
+
|
|
110
|
+
**Throws:**
|
|
111
|
+
- Error with message if the input is invalid JSON
|
|
112
|
+
|
|
113
|
+
### `decode(toon: string): string`
|
|
114
|
+
|
|
115
|
+
Convert (decode) a TOON-LD string to JSON-LD format.
|
|
116
|
+
|
|
117
|
+
**Parameters:**
|
|
118
|
+
- `toon` - A TOON-LD formatted string
|
|
119
|
+
|
|
120
|
+
**Returns:**
|
|
121
|
+
- JSON-LD formatted string (pretty-printed)
|
|
122
|
+
|
|
123
|
+
**Throws:**
|
|
124
|
+
- Error with message if the input is invalid TOON-LD
|
|
125
|
+
|
|
126
|
+
### `parse(toon: string): any`
|
|
127
|
+
|
|
128
|
+
Parse a TOON-LD string directly into a JavaScript Object.
|
|
129
|
+
|
|
130
|
+
**Parameters:**
|
|
131
|
+
- `toon` - A TOON-LD formatted string
|
|
132
|
+
|
|
133
|
+
**Returns:**
|
|
134
|
+
- JavaScript Object representing the data
|
|
135
|
+
|
|
136
|
+
### `stringify(data: any): string`
|
|
137
|
+
|
|
138
|
+
Stringify a JavaScript Object directly into a TOON-LD string.
|
|
139
|
+
|
|
140
|
+
**Parameters:**
|
|
141
|
+
- `data` - A JavaScript Object
|
|
142
|
+
|
|
143
|
+
**Returns:**
|
|
144
|
+
- TOON-LD formatted string
|
|
145
|
+
|
|
146
|
+
### `validateJson(json: string): boolean`
|
|
147
|
+
|
|
148
|
+
Validate a JSON-LD string.
|
|
149
|
+
|
|
150
|
+
**Parameters:**
|
|
151
|
+
- `json` - A JSON or JSON-LD formatted string
|
|
152
|
+
|
|
153
|
+
**Returns:**
|
|
154
|
+
- `true` if the string is valid JSON, `false` otherwise
|
|
155
|
+
|
|
156
|
+
### `validateToonld(toon: string): boolean`
|
|
157
|
+
|
|
158
|
+
Validate a TOON-LD string.
|
|
159
|
+
|
|
160
|
+
**Parameters:**
|
|
161
|
+
- `toon` - A TOON-LD formatted string
|
|
162
|
+
|
|
163
|
+
**Returns:**
|
|
164
|
+
- `true` if the string is valid TOON-LD, `false` otherwise
|
|
165
|
+
|
|
166
|
+
### `init(): void`
|
|
167
|
+
|
|
168
|
+
Initialize panic hook for better error messages in the browser console. This is optional but recommended for development.
|
|
169
|
+
|
|
170
|
+
**Example:**
|
|
171
|
+
```javascript
|
|
172
|
+
import { init } from 'toon-ld';
|
|
173
|
+
|
|
174
|
+
init(); // Call once at app startup
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## TypeScript Support
|
|
178
|
+
|
|
179
|
+
This package includes TypeScript type definitions out of the box:
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
import {
|
|
183
|
+
encode,
|
|
184
|
+
decode,
|
|
185
|
+
validateJson,
|
|
186
|
+
validateToonld
|
|
187
|
+
} from 'toon-ld';
|
|
188
|
+
|
|
189
|
+
const jsonLd: string = '{"name": "Alice"}';
|
|
190
|
+
const toon: string = encode(jsonLd);
|
|
191
|
+
const isValid: boolean = validateToonld(toon);
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Usage Examples
|
|
195
|
+
|
|
196
|
+
### With Express.js
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
import express from 'express';
|
|
200
|
+
import { encode, decode } from 'toon-ld';
|
|
201
|
+
|
|
202
|
+
const app = express();
|
|
203
|
+
app.use(express.text({ type: 'text/toon' }));
|
|
204
|
+
|
|
205
|
+
app.post('/convert/to-toon', (req, res) => {
|
|
206
|
+
try {
|
|
207
|
+
const toon = encode(req.body);
|
|
208
|
+
res.type('text/toon').send(toon);
|
|
209
|
+
} catch (error) {
|
|
210
|
+
res.status(400).json({ error: error.message });
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
app.post('/convert/to-jsonld', (req, res) => {
|
|
215
|
+
try {
|
|
216
|
+
const jsonLd = decode(req.body);
|
|
217
|
+
res.json(JSON.parse(jsonLd));
|
|
218
|
+
} catch (error) {
|
|
219
|
+
res.status(400).json({ error: error.message });
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### In the Browser
|
|
225
|
+
|
|
226
|
+
```html
|
|
227
|
+
<!DOCTYPE html>
|
|
228
|
+
<html>
|
|
229
|
+
<head>
|
|
230
|
+
<title>TOON-LD Converter</title>
|
|
231
|
+
</head>
|
|
232
|
+
<body>
|
|
233
|
+
<script type="module">
|
|
234
|
+
import { encode, init } from 'https://unpkg.com/toon-ld';
|
|
235
|
+
|
|
236
|
+
init(); // Better error messages
|
|
237
|
+
|
|
238
|
+
const jsonLd = JSON.stringify({
|
|
239
|
+
"@context": {"schema": "http://schema.org/"},
|
|
240
|
+
"schema:name": "Example"
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const toon = encode(jsonLd);
|
|
244
|
+
console.log(toon);
|
|
245
|
+
</script>
|
|
246
|
+
</body>
|
|
247
|
+
</html>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Value Nodes with Language Tags
|
|
251
|
+
|
|
252
|
+
```javascript
|
|
253
|
+
const jsonLd = JSON.stringify({
|
|
254
|
+
"@context": {
|
|
255
|
+
"dc": "http://purl.org/dc/terms/"
|
|
256
|
+
},
|
|
257
|
+
"dc:title": [
|
|
258
|
+
{"@value": "Bonjour", "@language": "fr"},
|
|
259
|
+
{"@value": "Hello", "@language": "en"}
|
|
260
|
+
]
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const toon = encode(jsonLd);
|
|
264
|
+
console.log(toon);
|
|
265
|
+
// Output:
|
|
266
|
+
// @context:
|
|
267
|
+
// dc: http://purl.org/dc/terms/
|
|
268
|
+
// dc:title[2]{@value,@language}:
|
|
269
|
+
// Bonjour,fr
|
|
270
|
+
// Hello,en
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Error Handling
|
|
274
|
+
|
|
275
|
+
```javascript
|
|
276
|
+
import { decode } from 'toon-ld';
|
|
277
|
+
|
|
278
|
+
try {
|
|
279
|
+
const result = decode("invalid: [unclosed");
|
|
280
|
+
} catch (error) {
|
|
281
|
+
console.error("Conversion failed:", error.message);
|
|
282
|
+
// Error message includes line numbers and helpful context
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Performance & Benchmarks
|
|
287
|
+
|
|
288
|
+
Real-world token savings across different dataset sizes:
|
|
289
|
+
|
|
290
|
+
| Records | JSON-LD Size | TOON-LD Size | Size Saved | Tokens Saved |
|
|
291
|
+
|---------|--------------|--------------|------------|--------------|
|
|
292
|
+
| 10 | 2,249 B | 1,425 B | **36.6%** | **51.6%** |
|
|
293
|
+
| 100 | 20,208 B | 11,375 B | **43.7%** | **57.8%** |
|
|
294
|
+
| 1,000 | 202,497 B | 113,565 B | **43.9%** | **58.5%** |
|
|
295
|
+
| 10,000 | 2,052,356 B | 1,162,425 B | **43.4%** | **58.6%** |
|
|
296
|
+
|
|
297
|
+
Token savings scale well and are especially valuable for LLM context windows.
|
|
298
|
+
|
|
299
|
+
## Cross-Platform Support
|
|
300
|
+
|
|
301
|
+
TOON-LD is also available for:
|
|
302
|
+
- **Rust**: `cargo add toon-ld` - [crates.io](https://crates.io/crates/toon-ld)
|
|
303
|
+
- **Python**: `pip install toon-ld` - [PyPI](https://pypi.org/project/toon-ld/)
|
|
304
|
+
- **CLI**: `cargo install toon-cli` - Command-line conversion tool
|
|
305
|
+
|
|
306
|
+
## Documentation
|
|
307
|
+
|
|
308
|
+
- **[Full Specification](https://github.com/argahsuknesib/toon-ld)** - Complete TOON-LD specification
|
|
309
|
+
- **[GitHub Repository](https://github.com/argahsuknesib/toon-ld)** - Source code and examples
|
|
310
|
+
- **[API Documentation](https://github.com/argahsuknesib/toon-ld#readme)** - Detailed guides
|
|
311
|
+
|
|
312
|
+
## Browser Compatibility
|
|
313
|
+
|
|
314
|
+
This package uses WebAssembly and requires:
|
|
315
|
+
- Chrome/Edge 57+
|
|
316
|
+
- Firefox 52+
|
|
317
|
+
- Safari 11+
|
|
318
|
+
- Node.js 12+
|
|
319
|
+
|
|
320
|
+
## Contributing
|
|
321
|
+
|
|
322
|
+
Contributions are welcome! Please see the [Contributing Guide](https://github.com/argahsuknesib/toon-ld/blob/main/CONTRIBUTING.md) for details.
|
|
323
|
+
|
|
324
|
+
## License
|
|
325
|
+
|
|
326
|
+
MIT License - See [LICENSE](https://github.com/argahsuknesib/toon-ld/blob/main/LICENSE) for details.
|
|
327
|
+
|
|
328
|
+
## Citation
|
|
329
|
+
|
|
330
|
+
If you use TOON-LD in your research, please cite:
|
|
331
|
+
|
|
332
|
+
```bibtex
|
|
333
|
+
@software{toon-ld,
|
|
334
|
+
title = {TOON-LD: Token-Oriented Object Notation for Linked Data},
|
|
335
|
+
author = {Bisen, Kushagra Singh},
|
|
336
|
+
year = {2025},
|
|
337
|
+
url = {https://github.com/argahsuknesib/toon-ld}
|
|
338
|
+
}
|
|
339
|
+
```
|
package/package.json
CHANGED
|
@@ -1,42 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toon-ld",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"types": "toon_wasm.d.ts",
|
|
7
|
-
"module": "toon_wasm.js",
|
|
8
|
-
"sideEffects": false,
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "https://github.com/toon-ld/toon-ld"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"toon",
|
|
15
|
-
"json-ld",
|
|
16
|
-
"rdf",
|
|
17
|
-
"linked-data",
|
|
18
|
-
"serialization",
|
|
19
|
-
"wasm",
|
|
20
|
-
"webassembly",
|
|
21
|
-
"rust"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Kush Bisen"
|
|
22
6
|
],
|
|
23
|
-
"
|
|
7
|
+
"description": "WASM bindings for TOON-LD serializer/parser",
|
|
8
|
+
"version": "0.2.2",
|
|
24
9
|
"license": "MIT",
|
|
25
|
-
"bugs": {
|
|
26
|
-
"url": "https://github.com/toon-ld/toon-ld/issues"
|
|
27
|
-
},
|
|
28
|
-
"homepage": "https://github.com/toon-ld/toon-ld#readme",
|
|
29
10
|
"files": [
|
|
30
11
|
"toon_wasm_bg.wasm",
|
|
31
|
-
"toon_wasm_bg.wasm.d.ts",
|
|
32
12
|
"toon_wasm.js",
|
|
33
|
-
"toon_wasm.d.ts"
|
|
34
|
-
"snippets/**/*"
|
|
13
|
+
"toon_wasm.d.ts"
|
|
35
14
|
],
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
15
|
+
"main": "toon_wasm.js",
|
|
16
|
+
"types": "toon_wasm.d.ts",
|
|
17
|
+
"sideEffects": [
|
|
18
|
+
"./snippets/*"
|
|
19
|
+
]
|
|
20
|
+
}
|
package/toon_wasm.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export function convert_jsonld_to_toonld(json: string): string;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Convert TOON-LD string to JSON-LD format
|
|
8
|
+
*
|
|
9
|
+
* # Arguments
|
|
10
|
+
* * `toon` - A TOON-LD formatted string
|
|
11
|
+
*
|
|
12
|
+
* # Returns
|
|
13
|
+
* * JSON-LD formatted string (pretty-printed) on success
|
|
14
|
+
* * Error message on failure
|
|
15
|
+
*/
|
|
16
|
+
export function convert_toonld_to_jsonld(toon: string): string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Decode TOON-LD string to JSON-LD format
|
|
20
|
+
*
|
|
21
|
+
* Alias for `convert_toonld_to_jsonld`
|
|
22
|
+
*/
|
|
23
|
+
export function decode(toon: string): string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Encode JSON-LD string to TOON-LD format
|
|
27
|
+
*
|
|
28
|
+
* Alias for `convert_jsonld_to_toonld`
|
|
29
|
+
*/
|
|
30
|
+
export function encode(json: string): string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Initialize panic hook for better error messages in browser console
|
|
34
|
+
*/
|
|
35
|
+
export function init(): void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Parse TOON-LD string to a JavaScript Object
|
|
39
|
+
*
|
|
40
|
+
* # Arguments
|
|
41
|
+
* * `toon` - A TOON-LD formatted string
|
|
42
|
+
*
|
|
43
|
+
* # Returns
|
|
44
|
+
* * JavaScript Object representing the parsed data
|
|
45
|
+
*/
|
|
46
|
+
export function parse(toon: string): any;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Stringify a JavaScript Object to TOON-LD format
|
|
50
|
+
*
|
|
51
|
+
* # Arguments
|
|
52
|
+
* * `data` - A JavaScript Object
|
|
53
|
+
*
|
|
54
|
+
* # Returns
|
|
55
|
+
* * TOON-LD formatted string
|
|
56
|
+
*/
|
|
57
|
+
export function stringify(data: any): string;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Validate a JSON-LD string
|
|
61
|
+
*
|
|
62
|
+
* # Arguments
|
|
63
|
+
* * `json` - A JSON or JSON-LD formatted string
|
|
64
|
+
*
|
|
65
|
+
* # Returns
|
|
66
|
+
* * `true` if the string is valid JSON
|
|
67
|
+
* * `false` otherwise
|
|
68
|
+
*/
|
|
69
|
+
export function validateJson(json: string): boolean;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Validate a TOON-LD string
|
|
73
|
+
*
|
|
74
|
+
* # Arguments
|
|
75
|
+
* * `toon` - A TOON-LD formatted string
|
|
76
|
+
*
|
|
77
|
+
* # Returns
|
|
78
|
+
* * `true` if the string is valid TOON-LD
|
|
79
|
+
* * `false` otherwise
|
|
80
|
+
*/
|
|
81
|
+
export function validateToonld(toon: string): boolean;
|
|
82
|
+
|
|
83
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
84
|
+
|
|
85
|
+
export interface InitOutput {
|
|
86
|
+
readonly memory: WebAssembly.Memory;
|
|
87
|
+
readonly init: () => void;
|
|
88
|
+
readonly convert_jsonld_to_toonld: (a: number, b: number) => [number, number, number, number];
|
|
89
|
+
readonly convert_toonld_to_jsonld: (a: number, b: number) => [number, number, number, number];
|
|
90
|
+
readonly validateToonld: (a: number, b: number) => number;
|
|
91
|
+
readonly validateJson: (a: number, b: number) => number;
|
|
92
|
+
readonly parse: (a: number, b: number) => [number, number, number];
|
|
93
|
+
readonly stringify: (a: any) => [number, number, number, number];
|
|
94
|
+
readonly encode: (a: number, b: number) => [number, number, number, number];
|
|
95
|
+
readonly decode: (a: number, b: number) => [number, number, number, number];
|
|
96
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
97
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
98
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
99
|
+
readonly __externref_table_alloc: () => number;
|
|
100
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
101
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
102
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
103
|
+
readonly __wbindgen_start: () => void;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
110
|
+
* a precompiled `WebAssembly.Module`.
|
|
111
|
+
*
|
|
112
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
113
|
+
*
|
|
114
|
+
* @returns {InitOutput}
|
|
115
|
+
*/
|
|
116
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
120
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
121
|
+
*
|
|
122
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
123
|
+
*
|
|
124
|
+
* @returns {Promise<InitOutput>}
|
|
125
|
+
*/
|
|
126
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/toon_wasm.js
ADDED
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
function addToExternrefTable0(obj) {
|
|
4
|
+
const idx = wasm.__externref_table_alloc();
|
|
5
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
6
|
+
return idx;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function debugString(val) {
|
|
10
|
+
// primitive types
|
|
11
|
+
const type = typeof val;
|
|
12
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
13
|
+
return `${val}`;
|
|
14
|
+
}
|
|
15
|
+
if (type == 'string') {
|
|
16
|
+
return `"${val}"`;
|
|
17
|
+
}
|
|
18
|
+
if (type == 'symbol') {
|
|
19
|
+
const description = val.description;
|
|
20
|
+
if (description == null) {
|
|
21
|
+
return 'Symbol';
|
|
22
|
+
} else {
|
|
23
|
+
return `Symbol(${description})`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (type == 'function') {
|
|
27
|
+
const name = val.name;
|
|
28
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
29
|
+
return `Function(${name})`;
|
|
30
|
+
} else {
|
|
31
|
+
return 'Function';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// objects
|
|
35
|
+
if (Array.isArray(val)) {
|
|
36
|
+
const length = val.length;
|
|
37
|
+
let debug = '[';
|
|
38
|
+
if (length > 0) {
|
|
39
|
+
debug += debugString(val[0]);
|
|
40
|
+
}
|
|
41
|
+
for(let i = 1; i < length; i++) {
|
|
42
|
+
debug += ', ' + debugString(val[i]);
|
|
43
|
+
}
|
|
44
|
+
debug += ']';
|
|
45
|
+
return debug;
|
|
46
|
+
}
|
|
47
|
+
// Test for built-in
|
|
48
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
49
|
+
let className;
|
|
50
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
51
|
+
className = builtInMatches[1];
|
|
52
|
+
} else {
|
|
53
|
+
// Failed to match the standard '[object ClassName]'
|
|
54
|
+
return toString.call(val);
|
|
55
|
+
}
|
|
56
|
+
if (className == 'Object') {
|
|
57
|
+
// we're a user defined class or Object
|
|
58
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
59
|
+
// easier than looping through ownProperties of `val`.
|
|
60
|
+
try {
|
|
61
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
62
|
+
} catch (_) {
|
|
63
|
+
return 'Object';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// errors
|
|
67
|
+
if (val instanceof Error) {
|
|
68
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
69
|
+
}
|
|
70
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
71
|
+
return className;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
75
|
+
ptr = ptr >>> 0;
|
|
76
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let cachedDataViewMemory0 = null;
|
|
80
|
+
function getDataViewMemory0() {
|
|
81
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
82
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
83
|
+
}
|
|
84
|
+
return cachedDataViewMemory0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getStringFromWasm0(ptr, len) {
|
|
88
|
+
ptr = ptr >>> 0;
|
|
89
|
+
return decodeText(ptr, len);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let cachedUint8ArrayMemory0 = null;
|
|
93
|
+
function getUint8ArrayMemory0() {
|
|
94
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
95
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
96
|
+
}
|
|
97
|
+
return cachedUint8ArrayMemory0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function handleError(f, args) {
|
|
101
|
+
try {
|
|
102
|
+
return f.apply(this, args);
|
|
103
|
+
} catch (e) {
|
|
104
|
+
const idx = addToExternrefTable0(e);
|
|
105
|
+
wasm.__wbindgen_exn_store(idx);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isLikeNone(x) {
|
|
110
|
+
return x === undefined || x === null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
114
|
+
if (realloc === undefined) {
|
|
115
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
116
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
117
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
118
|
+
WASM_VECTOR_LEN = buf.length;
|
|
119
|
+
return ptr;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
let len = arg.length;
|
|
123
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
124
|
+
|
|
125
|
+
const mem = getUint8ArrayMemory0();
|
|
126
|
+
|
|
127
|
+
let offset = 0;
|
|
128
|
+
|
|
129
|
+
for (; offset < len; offset++) {
|
|
130
|
+
const code = arg.charCodeAt(offset);
|
|
131
|
+
if (code > 0x7F) break;
|
|
132
|
+
mem[ptr + offset] = code;
|
|
133
|
+
}
|
|
134
|
+
if (offset !== len) {
|
|
135
|
+
if (offset !== 0) {
|
|
136
|
+
arg = arg.slice(offset);
|
|
137
|
+
}
|
|
138
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
139
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
140
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
141
|
+
|
|
142
|
+
offset += ret.written;
|
|
143
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
WASM_VECTOR_LEN = offset;
|
|
147
|
+
return ptr;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function takeFromExternrefTable0(idx) {
|
|
151
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
152
|
+
wasm.__externref_table_dealloc(idx);
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
157
|
+
cachedTextDecoder.decode();
|
|
158
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
159
|
+
let numBytesDecoded = 0;
|
|
160
|
+
function decodeText(ptr, len) {
|
|
161
|
+
numBytesDecoded += len;
|
|
162
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
163
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
164
|
+
cachedTextDecoder.decode();
|
|
165
|
+
numBytesDecoded = len;
|
|
166
|
+
}
|
|
167
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const cachedTextEncoder = new TextEncoder();
|
|
171
|
+
|
|
172
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
173
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
174
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
175
|
+
view.set(buf);
|
|
176
|
+
return {
|
|
177
|
+
read: arg.length,
|
|
178
|
+
written: buf.length
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
let WASM_VECTOR_LEN = 0;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @param {string} json
|
|
187
|
+
* @returns {string}
|
|
188
|
+
*/
|
|
189
|
+
export function convert_jsonld_to_toonld(json) {
|
|
190
|
+
let deferred3_0;
|
|
191
|
+
let deferred3_1;
|
|
192
|
+
try {
|
|
193
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
194
|
+
const len0 = WASM_VECTOR_LEN;
|
|
195
|
+
const ret = wasm.convert_jsonld_to_toonld(ptr0, len0);
|
|
196
|
+
var ptr2 = ret[0];
|
|
197
|
+
var len2 = ret[1];
|
|
198
|
+
if (ret[3]) {
|
|
199
|
+
ptr2 = 0; len2 = 0;
|
|
200
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
201
|
+
}
|
|
202
|
+
deferred3_0 = ptr2;
|
|
203
|
+
deferred3_1 = len2;
|
|
204
|
+
return getStringFromWasm0(ptr2, len2);
|
|
205
|
+
} finally {
|
|
206
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Convert TOON-LD string to JSON-LD format
|
|
212
|
+
*
|
|
213
|
+
* # Arguments
|
|
214
|
+
* * `toon` - A TOON-LD formatted string
|
|
215
|
+
*
|
|
216
|
+
* # Returns
|
|
217
|
+
* * JSON-LD formatted string (pretty-printed) on success
|
|
218
|
+
* * Error message on failure
|
|
219
|
+
* @param {string} toon
|
|
220
|
+
* @returns {string}
|
|
221
|
+
*/
|
|
222
|
+
export function convert_toonld_to_jsonld(toon) {
|
|
223
|
+
let deferred3_0;
|
|
224
|
+
let deferred3_1;
|
|
225
|
+
try {
|
|
226
|
+
const ptr0 = passStringToWasm0(toon, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
227
|
+
const len0 = WASM_VECTOR_LEN;
|
|
228
|
+
const ret = wasm.convert_toonld_to_jsonld(ptr0, len0);
|
|
229
|
+
var ptr2 = ret[0];
|
|
230
|
+
var len2 = ret[1];
|
|
231
|
+
if (ret[3]) {
|
|
232
|
+
ptr2 = 0; len2 = 0;
|
|
233
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
234
|
+
}
|
|
235
|
+
deferred3_0 = ptr2;
|
|
236
|
+
deferred3_1 = len2;
|
|
237
|
+
return getStringFromWasm0(ptr2, len2);
|
|
238
|
+
} finally {
|
|
239
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Decode TOON-LD string to JSON-LD format
|
|
245
|
+
*
|
|
246
|
+
* Alias for `convert_toonld_to_jsonld`
|
|
247
|
+
* @param {string} toon
|
|
248
|
+
* @returns {string}
|
|
249
|
+
*/
|
|
250
|
+
export function decode(toon) {
|
|
251
|
+
let deferred3_0;
|
|
252
|
+
let deferred3_1;
|
|
253
|
+
try {
|
|
254
|
+
const ptr0 = passStringToWasm0(toon, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
255
|
+
const len0 = WASM_VECTOR_LEN;
|
|
256
|
+
const ret = wasm.decode(ptr0, len0);
|
|
257
|
+
var ptr2 = ret[0];
|
|
258
|
+
var len2 = ret[1];
|
|
259
|
+
if (ret[3]) {
|
|
260
|
+
ptr2 = 0; len2 = 0;
|
|
261
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
262
|
+
}
|
|
263
|
+
deferred3_0 = ptr2;
|
|
264
|
+
deferred3_1 = len2;
|
|
265
|
+
return getStringFromWasm0(ptr2, len2);
|
|
266
|
+
} finally {
|
|
267
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Encode JSON-LD string to TOON-LD format
|
|
273
|
+
*
|
|
274
|
+
* Alias for `convert_jsonld_to_toonld`
|
|
275
|
+
* @param {string} json
|
|
276
|
+
* @returns {string}
|
|
277
|
+
*/
|
|
278
|
+
export function encode(json) {
|
|
279
|
+
let deferred3_0;
|
|
280
|
+
let deferred3_1;
|
|
281
|
+
try {
|
|
282
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
283
|
+
const len0 = WASM_VECTOR_LEN;
|
|
284
|
+
const ret = wasm.encode(ptr0, len0);
|
|
285
|
+
var ptr2 = ret[0];
|
|
286
|
+
var len2 = ret[1];
|
|
287
|
+
if (ret[3]) {
|
|
288
|
+
ptr2 = 0; len2 = 0;
|
|
289
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
290
|
+
}
|
|
291
|
+
deferred3_0 = ptr2;
|
|
292
|
+
deferred3_1 = len2;
|
|
293
|
+
return getStringFromWasm0(ptr2, len2);
|
|
294
|
+
} finally {
|
|
295
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Initialize panic hook for better error messages in browser console
|
|
301
|
+
*/
|
|
302
|
+
export function init() {
|
|
303
|
+
wasm.init();
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Parse TOON-LD string to a JavaScript Object
|
|
308
|
+
*
|
|
309
|
+
* # Arguments
|
|
310
|
+
* * `toon` - A TOON-LD formatted string
|
|
311
|
+
*
|
|
312
|
+
* # Returns
|
|
313
|
+
* * JavaScript Object representing the parsed data
|
|
314
|
+
* @param {string} toon
|
|
315
|
+
* @returns {any}
|
|
316
|
+
*/
|
|
317
|
+
export function parse(toon) {
|
|
318
|
+
const ptr0 = passStringToWasm0(toon, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
319
|
+
const len0 = WASM_VECTOR_LEN;
|
|
320
|
+
const ret = wasm.parse(ptr0, len0);
|
|
321
|
+
if (ret[2]) {
|
|
322
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
323
|
+
}
|
|
324
|
+
return takeFromExternrefTable0(ret[0]);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Stringify a JavaScript Object to TOON-LD format
|
|
329
|
+
*
|
|
330
|
+
* # Arguments
|
|
331
|
+
* * `data` - A JavaScript Object
|
|
332
|
+
*
|
|
333
|
+
* # Returns
|
|
334
|
+
* * TOON-LD formatted string
|
|
335
|
+
* @param {any} data
|
|
336
|
+
* @returns {string}
|
|
337
|
+
*/
|
|
338
|
+
export function stringify(data) {
|
|
339
|
+
let deferred2_0;
|
|
340
|
+
let deferred2_1;
|
|
341
|
+
try {
|
|
342
|
+
const ret = wasm.stringify(data);
|
|
343
|
+
var ptr1 = ret[0];
|
|
344
|
+
var len1 = ret[1];
|
|
345
|
+
if (ret[3]) {
|
|
346
|
+
ptr1 = 0; len1 = 0;
|
|
347
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
348
|
+
}
|
|
349
|
+
deferred2_0 = ptr1;
|
|
350
|
+
deferred2_1 = len1;
|
|
351
|
+
return getStringFromWasm0(ptr1, len1);
|
|
352
|
+
} finally {
|
|
353
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Validate a JSON-LD string
|
|
359
|
+
*
|
|
360
|
+
* # Arguments
|
|
361
|
+
* * `json` - A JSON or JSON-LD formatted string
|
|
362
|
+
*
|
|
363
|
+
* # Returns
|
|
364
|
+
* * `true` if the string is valid JSON
|
|
365
|
+
* * `false` otherwise
|
|
366
|
+
* @param {string} json
|
|
367
|
+
* @returns {boolean}
|
|
368
|
+
*/
|
|
369
|
+
export function validateJson(json) {
|
|
370
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
371
|
+
const len0 = WASM_VECTOR_LEN;
|
|
372
|
+
const ret = wasm.validateJson(ptr0, len0);
|
|
373
|
+
return ret !== 0;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Validate a TOON-LD string
|
|
378
|
+
*
|
|
379
|
+
* # Arguments
|
|
380
|
+
* * `toon` - A TOON-LD formatted string
|
|
381
|
+
*
|
|
382
|
+
* # Returns
|
|
383
|
+
* * `true` if the string is valid TOON-LD
|
|
384
|
+
* * `false` otherwise
|
|
385
|
+
* @param {string} toon
|
|
386
|
+
* @returns {boolean}
|
|
387
|
+
*/
|
|
388
|
+
export function validateToonld(toon) {
|
|
389
|
+
const ptr0 = passStringToWasm0(toon, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
390
|
+
const len0 = WASM_VECTOR_LEN;
|
|
391
|
+
const ret = wasm.validateToonld(ptr0, len0);
|
|
392
|
+
return ret !== 0;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
396
|
+
|
|
397
|
+
async function __wbg_load(module, imports) {
|
|
398
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
399
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
400
|
+
try {
|
|
401
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
402
|
+
} catch (e) {
|
|
403
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
404
|
+
|
|
405
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
406
|
+
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);
|
|
407
|
+
|
|
408
|
+
} else {
|
|
409
|
+
throw e;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const bytes = await module.arrayBuffer();
|
|
415
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
416
|
+
} else {
|
|
417
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
418
|
+
|
|
419
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
420
|
+
return { instance, module };
|
|
421
|
+
} else {
|
|
422
|
+
return instance;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function __wbg_get_imports() {
|
|
428
|
+
const imports = {};
|
|
429
|
+
imports.wbg = {};
|
|
430
|
+
imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
|
|
431
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
432
|
+
return ret;
|
|
433
|
+
};
|
|
434
|
+
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
|
|
435
|
+
const ret = String(arg1);
|
|
436
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
437
|
+
const len1 = WASM_VECTOR_LEN;
|
|
438
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
439
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
440
|
+
};
|
|
441
|
+
imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
|
|
442
|
+
const v = arg1;
|
|
443
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
444
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
445
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
446
|
+
};
|
|
447
|
+
imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
|
|
448
|
+
const v = arg0;
|
|
449
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
450
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
451
|
+
};
|
|
452
|
+
imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
|
|
453
|
+
const ret = debugString(arg1);
|
|
454
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
455
|
+
const len1 = WASM_VECTOR_LEN;
|
|
456
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
457
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
458
|
+
};
|
|
459
|
+
imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
|
|
460
|
+
const ret = arg0 in arg1;
|
|
461
|
+
return ret;
|
|
462
|
+
};
|
|
463
|
+
imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
|
|
464
|
+
const ret = typeof(arg0) === 'bigint';
|
|
465
|
+
return ret;
|
|
466
|
+
};
|
|
467
|
+
imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
|
|
468
|
+
const ret = typeof(arg0) === 'function';
|
|
469
|
+
return ret;
|
|
470
|
+
};
|
|
471
|
+
imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
|
|
472
|
+
const val = arg0;
|
|
473
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
474
|
+
return ret;
|
|
475
|
+
};
|
|
476
|
+
imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
|
|
477
|
+
const ret = typeof(arg0) === 'string';
|
|
478
|
+
return ret;
|
|
479
|
+
};
|
|
480
|
+
imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
|
|
481
|
+
const ret = arg0 === arg1;
|
|
482
|
+
return ret;
|
|
483
|
+
};
|
|
484
|
+
imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
|
|
485
|
+
const ret = arg0 == arg1;
|
|
486
|
+
return ret;
|
|
487
|
+
};
|
|
488
|
+
imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
|
|
489
|
+
const obj = arg1;
|
|
490
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
491
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
492
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
493
|
+
};
|
|
494
|
+
imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
|
|
495
|
+
const obj = arg1;
|
|
496
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
497
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
498
|
+
var len1 = WASM_VECTOR_LEN;
|
|
499
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
500
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
501
|
+
};
|
|
502
|
+
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
503
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
504
|
+
};
|
|
505
|
+
imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
|
|
506
|
+
const ret = arg0.call(arg1);
|
|
507
|
+
return ret;
|
|
508
|
+
}, arguments) };
|
|
509
|
+
imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
|
|
510
|
+
const ret = arg0.done;
|
|
511
|
+
return ret;
|
|
512
|
+
};
|
|
513
|
+
imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
|
|
514
|
+
const ret = Object.entries(arg0);
|
|
515
|
+
return ret;
|
|
516
|
+
};
|
|
517
|
+
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
518
|
+
let deferred0_0;
|
|
519
|
+
let deferred0_1;
|
|
520
|
+
try {
|
|
521
|
+
deferred0_0 = arg0;
|
|
522
|
+
deferred0_1 = arg1;
|
|
523
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
524
|
+
} finally {
|
|
525
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
|
|
529
|
+
const ret = arg0[arg1 >>> 0];
|
|
530
|
+
return ret;
|
|
531
|
+
};
|
|
532
|
+
imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
|
|
533
|
+
const ret = Reflect.get(arg0, arg1);
|
|
534
|
+
return ret;
|
|
535
|
+
}, arguments) };
|
|
536
|
+
imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
|
|
537
|
+
let result;
|
|
538
|
+
try {
|
|
539
|
+
result = arg0 instanceof ArrayBuffer;
|
|
540
|
+
} catch (_) {
|
|
541
|
+
result = false;
|
|
542
|
+
}
|
|
543
|
+
const ret = result;
|
|
544
|
+
return ret;
|
|
545
|
+
};
|
|
546
|
+
imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
|
|
547
|
+
let result;
|
|
548
|
+
try {
|
|
549
|
+
result = arg0 instanceof Map;
|
|
550
|
+
} catch (_) {
|
|
551
|
+
result = false;
|
|
552
|
+
}
|
|
553
|
+
const ret = result;
|
|
554
|
+
return ret;
|
|
555
|
+
};
|
|
556
|
+
imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
|
|
557
|
+
let result;
|
|
558
|
+
try {
|
|
559
|
+
result = arg0 instanceof Uint8Array;
|
|
560
|
+
} catch (_) {
|
|
561
|
+
result = false;
|
|
562
|
+
}
|
|
563
|
+
const ret = result;
|
|
564
|
+
return ret;
|
|
565
|
+
};
|
|
566
|
+
imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
|
|
567
|
+
const ret = Array.isArray(arg0);
|
|
568
|
+
return ret;
|
|
569
|
+
};
|
|
570
|
+
imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
|
|
571
|
+
const ret = Number.isSafeInteger(arg0);
|
|
572
|
+
return ret;
|
|
573
|
+
};
|
|
574
|
+
imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
|
|
575
|
+
const ret = Symbol.iterator;
|
|
576
|
+
return ret;
|
|
577
|
+
};
|
|
578
|
+
imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
|
|
579
|
+
const ret = arg0.length;
|
|
580
|
+
return ret;
|
|
581
|
+
};
|
|
582
|
+
imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
|
|
583
|
+
const ret = arg0.length;
|
|
584
|
+
return ret;
|
|
585
|
+
};
|
|
586
|
+
imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
|
|
587
|
+
const ret = new Object();
|
|
588
|
+
return ret;
|
|
589
|
+
};
|
|
590
|
+
imports.wbg.__wbg_new_25f239778d6112b9 = function() {
|
|
591
|
+
const ret = new Array();
|
|
592
|
+
return ret;
|
|
593
|
+
};
|
|
594
|
+
imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
|
|
595
|
+
const ret = new Uint8Array(arg0);
|
|
596
|
+
return ret;
|
|
597
|
+
};
|
|
598
|
+
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
599
|
+
const ret = new Error();
|
|
600
|
+
return ret;
|
|
601
|
+
};
|
|
602
|
+
imports.wbg.__wbg_new_b546ae120718850e = function() {
|
|
603
|
+
const ret = new Map();
|
|
604
|
+
return ret;
|
|
605
|
+
};
|
|
606
|
+
imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
|
|
607
|
+
const ret = arg0.next;
|
|
608
|
+
return ret;
|
|
609
|
+
};
|
|
610
|
+
imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
|
|
611
|
+
const ret = arg0.next();
|
|
612
|
+
return ret;
|
|
613
|
+
}, arguments) };
|
|
614
|
+
imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
|
|
615
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
616
|
+
};
|
|
617
|
+
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
|
|
618
|
+
arg0[arg1] = arg2;
|
|
619
|
+
};
|
|
620
|
+
imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
|
|
621
|
+
arg0[arg1 >>> 0] = arg2;
|
|
622
|
+
};
|
|
623
|
+
imports.wbg.__wbg_set_efaaf145b9377369 = function(arg0, arg1, arg2) {
|
|
624
|
+
const ret = arg0.set(arg1, arg2);
|
|
625
|
+
return ret;
|
|
626
|
+
};
|
|
627
|
+
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
628
|
+
const ret = arg1.stack;
|
|
629
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
630
|
+
const len1 = WASM_VECTOR_LEN;
|
|
631
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
632
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
633
|
+
};
|
|
634
|
+
imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
|
|
635
|
+
const ret = arg0.value;
|
|
636
|
+
return ret;
|
|
637
|
+
};
|
|
638
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
639
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
640
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
641
|
+
return ret;
|
|
642
|
+
};
|
|
643
|
+
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
644
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
645
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
646
|
+
return ret;
|
|
647
|
+
};
|
|
648
|
+
imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
|
|
649
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
650
|
+
const ret = arg0;
|
|
651
|
+
return ret;
|
|
652
|
+
};
|
|
653
|
+
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
654
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
655
|
+
const ret = arg0;
|
|
656
|
+
return ret;
|
|
657
|
+
};
|
|
658
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
659
|
+
const table = wasm.__wbindgen_externrefs;
|
|
660
|
+
const offset = table.grow(4);
|
|
661
|
+
table.set(0, undefined);
|
|
662
|
+
table.set(offset + 0, undefined);
|
|
663
|
+
table.set(offset + 1, null);
|
|
664
|
+
table.set(offset + 2, true);
|
|
665
|
+
table.set(offset + 3, false);
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
return imports;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
function __wbg_finalize_init(instance, module) {
|
|
672
|
+
wasm = instance.exports;
|
|
673
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
674
|
+
cachedDataViewMemory0 = null;
|
|
675
|
+
cachedUint8ArrayMemory0 = null;
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
wasm.__wbindgen_start();
|
|
679
|
+
return wasm;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
function initSync(module) {
|
|
683
|
+
if (wasm !== undefined) return wasm;
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
if (typeof module !== 'undefined') {
|
|
687
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
688
|
+
({module} = module)
|
|
689
|
+
} else {
|
|
690
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
const imports = __wbg_get_imports();
|
|
695
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
696
|
+
module = new WebAssembly.Module(module);
|
|
697
|
+
}
|
|
698
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
699
|
+
return __wbg_finalize_init(instance, module);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
async function __wbg_init(module_or_path) {
|
|
703
|
+
if (wasm !== undefined) return wasm;
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
if (typeof module_or_path !== 'undefined') {
|
|
707
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
708
|
+
({module_or_path} = module_or_path)
|
|
709
|
+
} else {
|
|
710
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
if (typeof module_or_path === 'undefined') {
|
|
715
|
+
module_or_path = new URL('toon_wasm_bg.wasm', import.meta.url);
|
|
716
|
+
}
|
|
717
|
+
const imports = __wbg_get_imports();
|
|
718
|
+
|
|
719
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
720
|
+
module_or_path = fetch(module_or_path);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
724
|
+
|
|
725
|
+
return __wbg_finalize_init(instance, module);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
export { initSync };
|
|
729
|
+
export default __wbg_init;
|
|
Binary file
|