@rwth-pads/cpnsim 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/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2018 István Koren <istvank@gmx.de>
2
+
3
+ Permission is hereby granted, free of charge, to any
4
+ person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the
6
+ Software without restriction, including without
7
+ limitation the rights to use, copy, modify, merge,
8
+ publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software
10
+ is furnished to do so, subject to the following
11
+ conditions:
12
+
13
+ The above copyright notice and this permission notice
14
+ shall be included in all copies or substantial portions
15
+ of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21
+ SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25
+ DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # CPNsim - Colored Petri Net Simulator
2
+
3
+ > ⚠️🚧 **Note:** This library is a work in progress. We are prioritizing tasks as we go. Feel free to leave an issue with your feature request or bug report — your feedback is greatly appreciated! 🚀
4
+
5
+ CPNsim is a Rust library and command-line tool for simulating Colored Petri Nets (CPNs). It parses CPN models defined in a specific JSON format (`.ocpn`) and executes the simulation step by step, handling token consumption, guard evaluation, and token production based on arc inscriptions and variable bindings.
6
+
7
+ ## Features
8
+
9
+ * Parses `.ocpn` JSON format for CPN models.
10
+ * Supports basic CPN elements: Places, Transitions, Arcs.
11
+ * Handles Color Sets (basic types like INT, STRING, etc.).
12
+ * Supports Variables and binding during transition firing.
13
+ * Evaluates transition guards using the Rhai scripting language.
14
+ * Evaluates arc inscriptions (also using Rhai) for token production.
15
+ * Provides a library interface for integration into other Rust projects.
16
+ * Includes a debug executable for running simulations from the command line.
17
+ * Compiles to WebAssembly (WASM) for use in web environments.
18
+
19
+ ## Building the Project
20
+
21
+ You can build the project using standard Cargo commands:
22
+
23
+ ```bash
24
+ # Build for development (debug mode)
25
+ cargo run
26
+
27
+ # Build for release (WebAssembly)
28
+ wasm-pack build --target web --features wasm
package/cpnsim.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export class WasmSimulator {
4
+ free(): void;
5
+ constructor(ocpn_json_string: string);
6
+ setEventListener(listener: Function): void;
7
+ run_step(): any;
8
+ }
9
+
10
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
11
+
12
+ export interface InitOutput {
13
+ readonly memory: WebAssembly.Memory;
14
+ readonly wasmsimulator_new: (a: number, b: number) => [number, number, number];
15
+ readonly wasmsimulator_setEventListener: (a: number, b: any) => void;
16
+ readonly wasmsimulator_run_step: (a: number) => [number, number, number];
17
+ readonly __wbg_wasmsimulator_free: (a: number, b: number) => void;
18
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
19
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
20
+ readonly __wbindgen_exn_store: (a: number) => void;
21
+ readonly __externref_table_alloc: () => number;
22
+ readonly __wbindgen_export_4: WebAssembly.Table;
23
+ readonly __externref_table_dealloc: (a: number) => void;
24
+ readonly __wbindgen_start: () => void;
25
+ }
26
+
27
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
28
+ /**
29
+ * Instantiates the given `module`, which can either be bytes or
30
+ * a precompiled `WebAssembly.Module`.
31
+ *
32
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
33
+ *
34
+ * @returns {InitOutput}
35
+ */
36
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
37
+
38
+ /**
39
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
40
+ * for everything else, calls `WebAssembly.instantiate` directly.
41
+ *
42
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
43
+ *
44
+ * @returns {Promise<InitOutput>}
45
+ */
46
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/cpnsim.js ADDED
@@ -0,0 +1,526 @@
1
+ let wasm;
2
+
3
+ let WASM_VECTOR_LEN = 0;
4
+
5
+ let cachedUint8ArrayMemory0 = null;
6
+
7
+ function getUint8ArrayMemory0() {
8
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
9
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
10
+ }
11
+ return cachedUint8ArrayMemory0;
12
+ }
13
+
14
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
15
+
16
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
17
+ ? function (arg, view) {
18
+ return cachedTextEncoder.encodeInto(arg, view);
19
+ }
20
+ : function (arg, view) {
21
+ const buf = cachedTextEncoder.encode(arg);
22
+ view.set(buf);
23
+ return {
24
+ read: arg.length,
25
+ written: buf.length
26
+ };
27
+ });
28
+
29
+ function passStringToWasm0(arg, malloc, realloc) {
30
+
31
+ if (realloc === undefined) {
32
+ const buf = cachedTextEncoder.encode(arg);
33
+ const ptr = malloc(buf.length, 1) >>> 0;
34
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
35
+ WASM_VECTOR_LEN = buf.length;
36
+ return ptr;
37
+ }
38
+
39
+ let len = arg.length;
40
+ let ptr = malloc(len, 1) >>> 0;
41
+
42
+ const mem = getUint8ArrayMemory0();
43
+
44
+ let offset = 0;
45
+
46
+ for (; offset < len; offset++) {
47
+ const code = arg.charCodeAt(offset);
48
+ if (code > 0x7F) break;
49
+ mem[ptr + offset] = code;
50
+ }
51
+
52
+ if (offset !== len) {
53
+ if (offset !== 0) {
54
+ arg = arg.slice(offset);
55
+ }
56
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
57
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
58
+ const ret = encodeString(arg, view);
59
+
60
+ offset += ret.written;
61
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
62
+ }
63
+
64
+ WASM_VECTOR_LEN = offset;
65
+ return ptr;
66
+ }
67
+
68
+ let cachedDataViewMemory0 = null;
69
+
70
+ function getDataViewMemory0() {
71
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
72
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
73
+ }
74
+ return cachedDataViewMemory0;
75
+ }
76
+
77
+ function addToExternrefTable0(obj) {
78
+ const idx = wasm.__externref_table_alloc();
79
+ wasm.__wbindgen_export_4.set(idx, obj);
80
+ return idx;
81
+ }
82
+
83
+ function handleError(f, args) {
84
+ try {
85
+ return f.apply(this, args);
86
+ } catch (e) {
87
+ const idx = addToExternrefTable0(e);
88
+ wasm.__wbindgen_exn_store(idx);
89
+ }
90
+ }
91
+
92
+ function getArrayU8FromWasm0(ptr, len) {
93
+ ptr = ptr >>> 0;
94
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
95
+ }
96
+
97
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
98
+
99
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
100
+
101
+ function getStringFromWasm0(ptr, len) {
102
+ ptr = ptr >>> 0;
103
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
104
+ }
105
+
106
+ function isLikeNone(x) {
107
+ return x === undefined || x === null;
108
+ }
109
+
110
+ function debugString(val) {
111
+ // primitive types
112
+ const type = typeof val;
113
+ if (type == 'number' || type == 'boolean' || val == null) {
114
+ return `${val}`;
115
+ }
116
+ if (type == 'string') {
117
+ return `"${val}"`;
118
+ }
119
+ if (type == 'symbol') {
120
+ const description = val.description;
121
+ if (description == null) {
122
+ return 'Symbol';
123
+ } else {
124
+ return `Symbol(${description})`;
125
+ }
126
+ }
127
+ if (type == 'function') {
128
+ const name = val.name;
129
+ if (typeof name == 'string' && name.length > 0) {
130
+ return `Function(${name})`;
131
+ } else {
132
+ return 'Function';
133
+ }
134
+ }
135
+ // objects
136
+ if (Array.isArray(val)) {
137
+ const length = val.length;
138
+ let debug = '[';
139
+ if (length > 0) {
140
+ debug += debugString(val[0]);
141
+ }
142
+ for(let i = 1; i < length; i++) {
143
+ debug += ', ' + debugString(val[i]);
144
+ }
145
+ debug += ']';
146
+ return debug;
147
+ }
148
+ // Test for built-in
149
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
150
+ let className;
151
+ if (builtInMatches && builtInMatches.length > 1) {
152
+ className = builtInMatches[1];
153
+ } else {
154
+ // Failed to match the standard '[object ClassName]'
155
+ return toString.call(val);
156
+ }
157
+ if (className == 'Object') {
158
+ // we're a user defined class or Object
159
+ // JSON.stringify avoids problems with cycles, and is generally much
160
+ // easier than looping through ownProperties of `val`.
161
+ try {
162
+ return 'Object(' + JSON.stringify(val) + ')';
163
+ } catch (_) {
164
+ return 'Object';
165
+ }
166
+ }
167
+ // errors
168
+ if (val instanceof Error) {
169
+ return `${val.name}: ${val.message}\n${val.stack}`;
170
+ }
171
+ // TODO we could test for more things here, like `Set`s and `Map`s.
172
+ return className;
173
+ }
174
+
175
+ function takeFromExternrefTable0(idx) {
176
+ const value = wasm.__wbindgen_export_4.get(idx);
177
+ wasm.__externref_table_dealloc(idx);
178
+ return value;
179
+ }
180
+
181
+ const WasmSimulatorFinalization = (typeof FinalizationRegistry === 'undefined')
182
+ ? { register: () => {}, unregister: () => {} }
183
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmsimulator_free(ptr >>> 0, 1));
184
+
185
+ export class WasmSimulator {
186
+
187
+ __destroy_into_raw() {
188
+ const ptr = this.__wbg_ptr;
189
+ this.__wbg_ptr = 0;
190
+ WasmSimulatorFinalization.unregister(this);
191
+ return ptr;
192
+ }
193
+
194
+ free() {
195
+ const ptr = this.__destroy_into_raw();
196
+ wasm.__wbg_wasmsimulator_free(ptr, 0);
197
+ }
198
+ /**
199
+ * @param {string} ocpn_json_string
200
+ */
201
+ constructor(ocpn_json_string) {
202
+ const ptr0 = passStringToWasm0(ocpn_json_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
203
+ const len0 = WASM_VECTOR_LEN;
204
+ const ret = wasm.wasmsimulator_new(ptr0, len0);
205
+ if (ret[2]) {
206
+ throw takeFromExternrefTable0(ret[1]);
207
+ }
208
+ this.__wbg_ptr = ret[0] >>> 0;
209
+ WasmSimulatorFinalization.register(this, this.__wbg_ptr, this);
210
+ return this;
211
+ }
212
+ /**
213
+ * @param {Function} listener
214
+ */
215
+ setEventListener(listener) {
216
+ wasm.wasmsimulator_setEventListener(this.__wbg_ptr, listener);
217
+ }
218
+ /**
219
+ * @returns {any}
220
+ */
221
+ run_step() {
222
+ const ret = wasm.wasmsimulator_run_step(this.__wbg_ptr);
223
+ if (ret[2]) {
224
+ throw takeFromExternrefTable0(ret[1]);
225
+ }
226
+ return takeFromExternrefTable0(ret[0]);
227
+ }
228
+ }
229
+
230
+ async function __wbg_load(module, imports) {
231
+ if (typeof Response === 'function' && module instanceof Response) {
232
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
233
+ try {
234
+ return await WebAssembly.instantiateStreaming(module, imports);
235
+
236
+ } catch (e) {
237
+ if (module.headers.get('Content-Type') != 'application/wasm') {
238
+ 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);
239
+
240
+ } else {
241
+ throw e;
242
+ }
243
+ }
244
+ }
245
+
246
+ const bytes = await module.arrayBuffer();
247
+ return await WebAssembly.instantiate(bytes, imports);
248
+
249
+ } else {
250
+ const instance = await WebAssembly.instantiate(module, imports);
251
+
252
+ if (instance instanceof WebAssembly.Instance) {
253
+ return { instance, module };
254
+
255
+ } else {
256
+ return instance;
257
+ }
258
+ }
259
+ }
260
+
261
+ function __wbg_get_imports() {
262
+ const imports = {};
263
+ imports.wbg = {};
264
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
265
+ const ret = String(arg1);
266
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
267
+ const len1 = WASM_VECTOR_LEN;
268
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
269
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
270
+ };
271
+ imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
272
+ const ret = arg0.buffer;
273
+ return ret;
274
+ };
275
+ imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
276
+ const ret = arg0.call(arg1);
277
+ return ret;
278
+ }, arguments) };
279
+ imports.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) {
280
+ const ret = arg0.call(arg1, arg2);
281
+ return ret;
282
+ }, arguments) };
283
+ imports.wbg.__wbg_crypto_ed58b8e10a292839 = function(arg0) {
284
+ const ret = arg0.crypto;
285
+ return ret;
286
+ };
287
+ imports.wbg.__wbg_fromCodePoint_f37c25c172f2e8b5 = function() { return handleError(function (arg0) {
288
+ const ret = String.fromCodePoint(arg0 >>> 0);
289
+ return ret;
290
+ }, arguments) };
291
+ imports.wbg.__wbg_from_2a5d3e218e67aa85 = function(arg0) {
292
+ const ret = Array.from(arg0);
293
+ return ret;
294
+ };
295
+ imports.wbg.__wbg_getRandomValues_21a0191e74d0e1d3 = function() { return handleError(function (arg0, arg1) {
296
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
297
+ }, arguments) };
298
+ imports.wbg.__wbg_getRandomValues_bcb4912f16000dc4 = function() { return handleError(function (arg0, arg1) {
299
+ arg0.getRandomValues(arg1);
300
+ }, arguments) };
301
+ imports.wbg.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
302
+ const ret = Reflect.get(arg0, arg1);
303
+ return ret;
304
+ }, arguments) };
305
+ imports.wbg.__wbg_log_5e46e5057e0d43bd = function(arg0, arg1) {
306
+ console.log(getStringFromWasm0(arg0, arg1));
307
+ };
308
+ imports.wbg.__wbg_msCrypto_0a36e2ec3a343d26 = function(arg0) {
309
+ const ret = arg0.msCrypto;
310
+ return ret;
311
+ };
312
+ imports.wbg.__wbg_new_405e22f390576ce2 = function() {
313
+ const ret = new Object();
314
+ return ret;
315
+ };
316
+ imports.wbg.__wbg_new_5e0be73521bc8c17 = function() {
317
+ const ret = new Map();
318
+ return ret;
319
+ };
320
+ imports.wbg.__wbg_new_78feb108b6472713 = function() {
321
+ const ret = new Array();
322
+ return ret;
323
+ };
324
+ imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
325
+ const ret = new Uint8Array(arg0);
326
+ return ret;
327
+ };
328
+ imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
329
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
330
+ return ret;
331
+ };
332
+ imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
333
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
334
+ return ret;
335
+ };
336
+ imports.wbg.__wbg_newwithlength_a381634e90c276d4 = function(arg0) {
337
+ const ret = new Uint8Array(arg0 >>> 0);
338
+ return ret;
339
+ };
340
+ imports.wbg.__wbg_node_02999533c4ea02e3 = function(arg0) {
341
+ const ret = arg0.node;
342
+ return ret;
343
+ };
344
+ imports.wbg.__wbg_now_d18023d54d4e5500 = function(arg0) {
345
+ const ret = arg0.now();
346
+ return ret;
347
+ };
348
+ imports.wbg.__wbg_process_5c1d670bc53614b8 = function(arg0) {
349
+ const ret = arg0.process;
350
+ return ret;
351
+ };
352
+ imports.wbg.__wbg_randomFillSync_ab2cfe79ebbf2740 = function() { return handleError(function (arg0, arg1) {
353
+ arg0.randomFillSync(arg1);
354
+ }, arguments) };
355
+ imports.wbg.__wbg_require_79b1e9274cde3c87 = function() { return handleError(function () {
356
+ const ret = module.require;
357
+ return ret;
358
+ }, arguments) };
359
+ imports.wbg.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
360
+ arg0[arg1 >>> 0] = arg2;
361
+ };
362
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
363
+ arg0[arg1] = arg2;
364
+ };
365
+ imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
366
+ arg0.set(arg1, arg2 >>> 0);
367
+ };
368
+ imports.wbg.__wbg_set_8fc6bf8a5b1071d1 = function(arg0, arg1, arg2) {
369
+ const ret = arg0.set(arg1, arg2);
370
+ return ret;
371
+ };
372
+ imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
373
+ const ret = typeof global === 'undefined' ? null : global;
374
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
375
+ };
376
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
377
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
378
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
379
+ };
380
+ imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
381
+ const ret = typeof self === 'undefined' ? null : self;
382
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
383
+ };
384
+ imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
385
+ const ret = typeof window === 'undefined' ? null : window;
386
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
387
+ };
388
+ imports.wbg.__wbg_subarray_aa9065fa9dc5df96 = function(arg0, arg1, arg2) {
389
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
390
+ return ret;
391
+ };
392
+ imports.wbg.__wbg_versions_c71aa1626a93e0a1 = function(arg0) {
393
+ const ret = arg0.versions;
394
+ return ret;
395
+ };
396
+ imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
397
+ const ret = arg0;
398
+ return ret;
399
+ };
400
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
401
+ const ret = debugString(arg1);
402
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
403
+ const len1 = WASM_VECTOR_LEN;
404
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
405
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
406
+ };
407
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
408
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
409
+ return ret;
410
+ };
411
+ imports.wbg.__wbindgen_init_externref_table = function() {
412
+ const table = wasm.__wbindgen_export_4;
413
+ const offset = table.grow(4);
414
+ table.set(0, undefined);
415
+ table.set(offset + 0, undefined);
416
+ table.set(offset + 1, null);
417
+ table.set(offset + 2, true);
418
+ table.set(offset + 3, false);
419
+ ;
420
+ };
421
+ imports.wbg.__wbindgen_is_function = function(arg0) {
422
+ const ret = typeof(arg0) === 'function';
423
+ return ret;
424
+ };
425
+ imports.wbg.__wbindgen_is_object = function(arg0) {
426
+ const val = arg0;
427
+ const ret = typeof(val) === 'object' && val !== null;
428
+ return ret;
429
+ };
430
+ imports.wbg.__wbindgen_is_string = function(arg0) {
431
+ const ret = typeof(arg0) === 'string';
432
+ return ret;
433
+ };
434
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
435
+ const ret = arg0 === undefined;
436
+ return ret;
437
+ };
438
+ imports.wbg.__wbindgen_memory = function() {
439
+ const ret = wasm.memory;
440
+ return ret;
441
+ };
442
+ imports.wbg.__wbindgen_number_new = function(arg0) {
443
+ const ret = arg0;
444
+ return ret;
445
+ };
446
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
447
+ const ret = getStringFromWasm0(arg0, arg1);
448
+ return ret;
449
+ };
450
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
451
+ throw new Error(getStringFromWasm0(arg0, arg1));
452
+ };
453
+
454
+ return imports;
455
+ }
456
+
457
+ function __wbg_init_memory(imports, memory) {
458
+
459
+ }
460
+
461
+ function __wbg_finalize_init(instance, module) {
462
+ wasm = instance.exports;
463
+ __wbg_init.__wbindgen_wasm_module = module;
464
+ cachedDataViewMemory0 = null;
465
+ cachedUint8ArrayMemory0 = null;
466
+
467
+
468
+ wasm.__wbindgen_start();
469
+ return wasm;
470
+ }
471
+
472
+ function initSync(module) {
473
+ if (wasm !== undefined) return wasm;
474
+
475
+
476
+ if (typeof module !== 'undefined') {
477
+ if (Object.getPrototypeOf(module) === Object.prototype) {
478
+ ({module} = module)
479
+ } else {
480
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
481
+ }
482
+ }
483
+
484
+ const imports = __wbg_get_imports();
485
+
486
+ __wbg_init_memory(imports);
487
+
488
+ if (!(module instanceof WebAssembly.Module)) {
489
+ module = new WebAssembly.Module(module);
490
+ }
491
+
492
+ const instance = new WebAssembly.Instance(module, imports);
493
+
494
+ return __wbg_finalize_init(instance, module);
495
+ }
496
+
497
+ async function __wbg_init(module_or_path) {
498
+ if (wasm !== undefined) return wasm;
499
+
500
+
501
+ if (typeof module_or_path !== 'undefined') {
502
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
503
+ ({module_or_path} = module_or_path)
504
+ } else {
505
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
506
+ }
507
+ }
508
+
509
+ if (typeof module_or_path === 'undefined') {
510
+ module_or_path = new URL('cpnsim_bg.wasm', import.meta.url);
511
+ }
512
+ const imports = __wbg_get_imports();
513
+
514
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
515
+ module_or_path = fetch(module_or_path);
516
+ }
517
+
518
+ __wbg_init_memory(imports);
519
+
520
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
521
+
522
+ return __wbg_finalize_init(instance, module);
523
+ }
524
+
525
+ export { initSync };
526
+ export default __wbg_init;
package/cpnsim_bg.wasm ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@rwth-pads/cpnsim",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "István Koren"
6
+ ],
7
+ "description": "CPNsim is a Rust library and command-line tool for simulating Colored Petri Nets (CPNs)",
8
+ "version": "0.1.0",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/rwth-pads/cpnsim.git"
13
+ },
14
+ "files": [
15
+ "cpnsim_bg.wasm",
16
+ "cpnsim.js",
17
+ "cpnsim.d.ts"
18
+ ],
19
+ "main": "cpnsim.js",
20
+ "types": "cpnsim.d.ts",
21
+ "sideEffects": [
22
+ "./snippets/*"
23
+ ]
24
+ }