jseption 0.0.5 → 0.0.6
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 +25 -4
- package/dist/atoms.d.ts +1 -0
- package/dist/atoms.js +2 -1
- package/dist/atoms.js.map +1 -1
- package/dist/builtins/base64.d.ts +14 -0
- package/dist/builtins/base64.js +219 -0
- package/dist/builtins/base64.js.map +1 -0
- package/dist/builtins/bigint.js +3 -3
- package/dist/builtins/bigint.js.map +1 -1
- package/dist/builtins/date.d.ts +1 -0
- package/dist/builtins/date.js +26 -12
- package/dist/builtins/date.js.map +1 -1
- package/dist/builtins/error.js +9 -0
- package/dist/builtins/error.js.map +1 -1
- package/dist/builtins/float16.d.ts +3 -0
- package/dist/builtins/float16.js +69 -0
- package/dist/builtins/float16.js.map +1 -0
- package/dist/builtins/function.js +2 -2
- package/dist/builtins/index.js +9 -6
- package/dist/builtins/index.js.map +1 -1
- package/dist/builtins/iterator.d.ts +2 -0
- package/dist/builtins/iterator.js +624 -0
- package/dist/builtins/iterator.js.map +1 -0
- package/dist/builtins/json.d.ts +13 -1
- package/dist/builtins/json.js +283 -211
- package/dist/builtins/json.js.map +1 -1
- package/dist/builtins/mapset.js +365 -6
- package/dist/builtins/mapset.js.map +1 -1
- package/dist/builtins/math.js +203 -3
- package/dist/builtins/math.js.map +1 -1
- package/dist/builtins/native.js +6 -6
- package/dist/builtins/object.js +9 -2
- package/dist/builtins/object.js.map +1 -1
- package/dist/builtins/promise.js +31 -11
- package/dist/builtins/promise.js.map +1 -1
- package/dist/builtins/proxy.js +2 -2
- package/dist/builtins/reflect.js +6 -2
- package/dist/builtins/reflect.js.map +1 -1
- package/dist/builtins/regexp.js +74 -3
- package/dist/builtins/regexp.js.map +1 -1
- package/dist/builtins/string.js +1 -1
- package/dist/builtins/symbol.js +1 -1
- package/dist/builtins/symbol.js.map +1 -1
- package/dist/builtins/typedarray.d.ts +1 -0
- package/dist/builtins/typedarray.js +302 -32
- package/dist/builtins/typedarray.js.map +1 -1
- package/dist/builtins/weakref.js +7 -7
- package/dist/embed.js +3 -3
- package/dist/interpreter.js +15 -14
- package/dist/interpreter.js.map +1 -1
- package/dist/jit.d.ts +1 -0
- package/dist/jit.js +51 -13
- package/dist/jit.js.map +1 -1
- package/dist/jit_hook.d.ts +1 -0
- package/dist/jit_hook.js.map +1 -1
- package/dist/jit_runtime.d.ts +1 -1
- package/dist/jit_runtime.js +6 -6
- package/dist/jit_runtime.js.map +1 -1
- package/dist/jit_stack.d.ts +1 -0
- package/dist/jit_stack.js +2 -1
- package/dist/jit_stack.js.map +1 -1
- package/dist/jseption.d.ts +2 -0
- package/dist/jseption.js +1 -0
- package/dist/jseption.js.map +1 -1
- package/dist/membrane.js +1 -1
- package/dist/module.js +5 -3
- package/dist/module.js.map +1 -1
- package/dist/parser.js +26 -9
- package/dist/parser.js.map +1 -1
- package/dist/print.d.ts +12 -0
- package/dist/print.js +494 -0
- package/dist/print.js.map +1 -0
- package/dist/qjs.js +13 -10
- package/dist/qjs.js.map +1 -1
- package/dist/quickjs.d.ts +8 -0
- package/dist/quickjs.js +132 -53
- package/dist/quickjs.js.map +1 -1
- package/dist/std.d.ts +4 -2
- package/dist/std.js +42 -8
- package/dist/std.js.map +1 -1
- package/dist/values.d.ts +31 -27
- package/dist/values.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
package/dist/builtins/weakref.js
CHANGED
|
@@ -11,14 +11,14 @@ function js_weakref_constructor(ctx, new_target, argv) {
|
|
|
11
11
|
const arg = argv[0];
|
|
12
12
|
if (!js_weakref_is_target(arg))
|
|
13
13
|
return JS_ThrowTypeError(ctx, 'invalid target');
|
|
14
|
-
const obj = js_create_from_ctor(ctx, new_target,
|
|
14
|
+
const obj = js_create_from_ctor(ctx, new_target, 55 /* JSClassID.WEAK_REF */);
|
|
15
15
|
if (JS_IsException(obj))
|
|
16
16
|
return JS_EXCEPTION;
|
|
17
17
|
JS_SetOpaque(obj, new JSWeakRefData(arg));
|
|
18
18
|
return obj;
|
|
19
19
|
}
|
|
20
20
|
function js_weakref_deref(ctx, this_val, argv) {
|
|
21
|
-
const wrd = JS_GetOpaque2(ctx, this_val,
|
|
21
|
+
const wrd = JS_GetOpaque2(ctx, this_val, 55 /* JSClassID.WEAK_REF */);
|
|
22
22
|
if (!wrd)
|
|
23
23
|
return JS_EXCEPTION;
|
|
24
24
|
const target = wrd.target.deref();
|
|
@@ -67,14 +67,14 @@ function js_finrec_constructor(ctx, new_target, argv) {
|
|
|
67
67
|
const cb = argv[0];
|
|
68
68
|
if (!JS_IsFunction(ctx, cb))
|
|
69
69
|
return JS_ThrowTypeError(ctx, 'argument must be a function');
|
|
70
|
-
const obj = js_create_from_ctor(ctx, new_target,
|
|
70
|
+
const obj = js_create_from_ctor(ctx, new_target, 56 /* JSClassID.FINALIZATION_REGISTRY */);
|
|
71
71
|
if (JS_IsException(obj))
|
|
72
72
|
return JS_EXCEPTION;
|
|
73
73
|
JS_SetOpaque(obj, new JSFinalizationRegistryData(ctx, cb));
|
|
74
74
|
return obj;
|
|
75
75
|
}
|
|
76
76
|
function js_finrec_register(ctx, this_val, argv) {
|
|
77
|
-
const frd = JS_GetOpaque2(ctx, this_val,
|
|
77
|
+
const frd = JS_GetOpaque2(ctx, this_val, 56 /* JSClassID.FINALIZATION_REGISTRY */);
|
|
78
78
|
if (!frd)
|
|
79
79
|
return JS_EXCEPTION;
|
|
80
80
|
const target = argv[0];
|
|
@@ -92,7 +92,7 @@ function js_finrec_register(ctx, this_val, argv) {
|
|
|
92
92
|
return undefined;
|
|
93
93
|
}
|
|
94
94
|
function js_finrec_unregister(ctx, this_val, argv) {
|
|
95
|
-
const frd = JS_GetOpaque2(ctx, this_val,
|
|
95
|
+
const frd = JS_GetOpaque2(ctx, this_val, 56 /* JSClassID.FINALIZATION_REGISTRY */);
|
|
96
96
|
if (!frd)
|
|
97
97
|
return JS_EXCEPTION;
|
|
98
98
|
const token = argv[0];
|
|
@@ -118,12 +118,12 @@ const js_finrec_proto_funcs = [
|
|
|
118
118
|
export function JS_AddIntrinsicWeakRef(ctx) {
|
|
119
119
|
/* WeakRef */
|
|
120
120
|
const weakref_proto = JS_NewObject(ctx);
|
|
121
|
-
ctx.class_proto[
|
|
121
|
+
ctx.class_proto[55 /* JSClassID.WEAK_REF */] = weakref_proto;
|
|
122
122
|
JS_SetPropertyFunctionList(ctx, weakref_proto, js_weakref_proto_funcs);
|
|
123
123
|
JS_NewGlobalCConstructor(ctx, 'WeakRef', js_weakref_constructor, 1, weakref_proto);
|
|
124
124
|
/* FinalizationRegistry */
|
|
125
125
|
const finrec_proto = JS_NewObject(ctx);
|
|
126
|
-
ctx.class_proto[
|
|
126
|
+
ctx.class_proto[56 /* JSClassID.FINALIZATION_REGISTRY */] = finrec_proto;
|
|
127
127
|
JS_SetPropertyFunctionList(ctx, finrec_proto, js_finrec_proto_funcs);
|
|
128
128
|
JS_NewGlobalCConstructor(ctx, 'FinalizationRegistry', js_finrec_constructor, 1, finrec_proto);
|
|
129
129
|
}
|
package/dist/embed.js
CHANGED
|
@@ -237,7 +237,7 @@ function fromGuestRec(ctx, v, seen, hook) {
|
|
|
237
237
|
return cached;
|
|
238
238
|
const o = v;
|
|
239
239
|
switch (JS_GetClassID(v)) {
|
|
240
|
-
case
|
|
240
|
+
case 46 /* JSClassID.PROMISE */:
|
|
241
241
|
return guestPromiseToHost(ctx, v);
|
|
242
242
|
case 10 /* JSClassID.DATE */:
|
|
243
243
|
return new Date(JS_GetAnyOpaque(v));
|
|
@@ -245,14 +245,14 @@ function fromGuestRec(ctx, v, seen, hook) {
|
|
|
245
245
|
return guestErrorToHost(ctx, v);
|
|
246
246
|
case 18 /* JSClassID.REGEXP */:
|
|
247
247
|
return new RegExp(o.source, o.flags);
|
|
248
|
-
case
|
|
248
|
+
case 35 /* JSClassID.MAP */: {
|
|
249
249
|
const m = new Map();
|
|
250
250
|
seen.set(v, m);
|
|
251
251
|
for (const [k, val] of Map.prototype.entries.call(o))
|
|
252
252
|
m.set(fromGuestRec(ctx, k, seen, hook), fromGuestRec(ctx, val, seen, hook));
|
|
253
253
|
return m;
|
|
254
254
|
}
|
|
255
|
-
case
|
|
255
|
+
case 36 /* JSClassID.SET */: {
|
|
256
256
|
const s = new Set();
|
|
257
257
|
seen.set(v, s);
|
|
258
258
|
for (const val of Set.prototype.values.call(o))
|
package/dist/interpreter.js
CHANGED
|
@@ -18,7 +18,7 @@ export const GEN_MAGIC_THROW = 2;
|
|
|
18
18
|
--------------------------------------------------------------------- */
|
|
19
19
|
export function js_class_has_bytecode(class_id) {
|
|
20
20
|
return class_id === 13 /* JSClassID.BYTECODE_FUNCTION */ || class_id === 16 /* JSClassID.GENERATOR_FUNCTION */ ||
|
|
21
|
-
class_id ===
|
|
21
|
+
class_id === 49 /* JSClassID.ASYNC_FUNCTION */ || class_id === 53 /* JSClassID.ASYNC_GENERATOR_FUNCTION */;
|
|
22
22
|
}
|
|
23
23
|
export function get_var_ref(ctx, sf, var_idx, is_arg) {
|
|
24
24
|
for (const vr of sf.var_refs) {
|
|
@@ -54,8 +54,8 @@ export function close_lexical_var(ctx, sf, var_idx) {
|
|
|
54
54
|
function func_kind_to_class_id(kind) {
|
|
55
55
|
switch (kind) {
|
|
56
56
|
case 1 /* JSFunctionKind.GENERATOR */: return 16 /* JSClassID.GENERATOR_FUNCTION */;
|
|
57
|
-
case 2 /* JSFunctionKind.ASYNC */: return
|
|
58
|
-
case 3 /* JSFunctionKind.ASYNC_GENERATOR */: return
|
|
57
|
+
case 2 /* JSFunctionKind.ASYNC */: return 49 /* JSClassID.ASYNC_FUNCTION */;
|
|
58
|
+
case 3 /* JSFunctionKind.ASYNC_GENERATOR */: return 53 /* JSClassID.ASYNC_GENERATOR_FUNCTION */;
|
|
59
59
|
default: return 13 /* JSClassID.BYTECODE_FUNCTION */;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -139,7 +139,7 @@ export function js_closure(ctx, b, cur_var_refs, sf) {
|
|
|
139
139
|
js_function_set_properties(ctx, func_obj, name_atom, b.defined_arg_count);
|
|
140
140
|
if (b.func_kind & 1 /* JSFunctionKind.GENERATOR */) {
|
|
141
141
|
/* generators have a prototype field which is used as prototype for the generator object */
|
|
142
|
-
const proto_class_id = (b.func_kind === 3 /* JSFunctionKind.ASYNC_GENERATOR */) ?
|
|
142
|
+
const proto_class_id = (b.func_kind === 3 /* JSFunctionKind.ASYNC_GENERATOR */) ? 54 /* JSClassID.ASYNC_GENERATOR */ : 44 /* JSClassID.GENERATOR */;
|
|
143
143
|
const gproto = JS_NewObjectProto(ctx, ctx.class_proto[proto_class_id]);
|
|
144
144
|
if (JS_IsException(gproto))
|
|
145
145
|
return JS_EXCEPTION;
|
|
@@ -3207,7 +3207,7 @@ function free_generator_stack(ctx, s) {
|
|
|
3207
3207
|
s.state = 4 /* JSGeneratorState.COMPLETED */;
|
|
3208
3208
|
}
|
|
3209
3209
|
export function js_generator_next(ctx, this_val, argv, pdone, magic) {
|
|
3210
|
-
const s = JS_GetOpaque(this_val,
|
|
3210
|
+
const s = JS_GetOpaque(this_val, 44 /* JSClassID.GENERATOR */);
|
|
3211
3211
|
pdone.done = 1;
|
|
3212
3212
|
if (!s)
|
|
3213
3213
|
return JS_ThrowTypeError(ctx, 'not a generator');
|
|
@@ -3287,7 +3287,7 @@ export function js_generator_function_call(ctx, func_obj, this_obj, argv, flags)
|
|
|
3287
3287
|
free_generator_stack(ctx, s);
|
|
3288
3288
|
return JS_EXCEPTION;
|
|
3289
3289
|
}
|
|
3290
|
-
const obj = js_create_from_ctor(ctx, func_obj,
|
|
3290
|
+
const obj = js_create_from_ctor(ctx, func_obj, 44 /* JSClassID.GENERATOR */);
|
|
3291
3291
|
if (JS_IsException(obj)) {
|
|
3292
3292
|
free_generator_stack(ctx, s);
|
|
3293
3293
|
return JS_EXCEPTION;
|
|
@@ -3315,7 +3315,7 @@ function js_async_function_resolve_create(ctx, s) {
|
|
|
3315
3315
|
js_async_function_resolve_call(ctx, s, is_reject, args.length > 0 ? args[0] : undefined);
|
|
3316
3316
|
return undefined;
|
|
3317
3317
|
};
|
|
3318
|
-
const f = js_new_host_function(ctx, impl, false, '', 1, ctx.function_proto, (
|
|
3318
|
+
const f = js_new_host_function(ctx, impl, false, '', 1, ctx.function_proto, (50 /* JSClassID.ASYNC_FUNCTION_RESOLVE */ + i));
|
|
3319
3319
|
js_meta.get(f).u = s;
|
|
3320
3320
|
funcs[i] = f;
|
|
3321
3321
|
}
|
|
@@ -3558,7 +3558,7 @@ function js_async_generator_resume_next(ctx, s) {
|
|
|
3558
3558
|
}
|
|
3559
3559
|
function js_async_generator_resolve_function(ctx, this_obj, argv, magic, func_data) {
|
|
3560
3560
|
const is_reject = (magic & 1) !== 0;
|
|
3561
|
-
const s = JS_GetOpaque(func_data[0],
|
|
3561
|
+
const s = JS_GetOpaque(func_data[0], 54 /* JSClassID.ASYNC_GENERATOR */);
|
|
3562
3562
|
const arg = argv[0];
|
|
3563
3563
|
if (!s)
|
|
3564
3564
|
return undefined;
|
|
@@ -3570,8 +3570,9 @@ function js_async_generator_resolve_function(ctx, this_obj, argv, magic, func_da
|
|
|
3570
3570
|
else
|
|
3571
3571
|
js_async_generator_resolve(ctx, s, arg, true);
|
|
3572
3572
|
}
|
|
3573
|
-
else {
|
|
3574
|
-
/* restart function execution after await()
|
|
3573
|
+
else if (s.state === 3 /* JSAsyncGeneratorState.EXECUTING */) {
|
|
3574
|
+
/* restart function execution after await() (only while it is executing:
|
|
3575
|
+
QuickJS e7b9f21) */
|
|
3575
3576
|
const fs = s.func_state;
|
|
3576
3577
|
fs.throw_flag = is_reject;
|
|
3577
3578
|
if (is_reject) {
|
|
@@ -3587,7 +3588,7 @@ function js_async_generator_resolve_function(ctx, this_obj, argv, magic, func_da
|
|
|
3587
3588
|
}
|
|
3588
3589
|
/* magic = GEN_MAGIC_x */
|
|
3589
3590
|
export function js_async_generator_next(ctx, this_val, argv, magic) {
|
|
3590
|
-
const s = JS_GetOpaque(this_val,
|
|
3591
|
+
const s = JS_GetOpaque(this_val, 54 /* JSClassID.ASYNC_GENERATOR */);
|
|
3591
3592
|
const resolving_funcs = [undefined, undefined];
|
|
3592
3593
|
const promise = JS_NewPromiseCapability(ctx, resolving_funcs);
|
|
3593
3594
|
if (JS_IsException(promise))
|
|
@@ -3612,7 +3613,7 @@ export function js_async_generator_function_call(ctx, func_obj, this_obj, argv,
|
|
|
3612
3613
|
const func_ret = async_func_resume(ctx, s.func_state);
|
|
3613
3614
|
if (JS_IsException(func_ret))
|
|
3614
3615
|
return JS_EXCEPTION;
|
|
3615
|
-
const obj = js_create_from_ctor(ctx, func_obj,
|
|
3616
|
+
const obj = js_create_from_ctor(ctx, func_obj, 54 /* JSClassID.ASYNC_GENERATOR */);
|
|
3616
3617
|
if (JS_IsException(obj))
|
|
3617
3618
|
return JS_EXCEPTION;
|
|
3618
3619
|
s.generator = obj;
|
|
@@ -3640,7 +3641,7 @@ export function JS_CreateAsyncFromSyncIterator(ctx, sync_iter) {
|
|
|
3640
3641
|
const next_method = JS_GetProperty(ctx, sync_iter, JS_ATOM_next);
|
|
3641
3642
|
if (JS_IsException(next_method))
|
|
3642
3643
|
return JS_EXCEPTION;
|
|
3643
|
-
const async_iter = JS_NewObjectClass(ctx,
|
|
3644
|
+
const async_iter = JS_NewObjectClass(ctx, 52 /* JSClassID.ASYNC_FROM_SYNC_ITERATOR */);
|
|
3644
3645
|
if (JS_IsException(async_iter))
|
|
3645
3646
|
return async_iter;
|
|
3646
3647
|
JS_SetOpaque(async_iter, new JSAsyncFromSyncIteratorData(sync_iter, next_method));
|
|
@@ -3671,7 +3672,7 @@ function js_async_from_sync_iterator_next(ctx, this_val, argv, magic) {
|
|
|
3671
3672
|
JS_Call(ctx, resolving_funcs[1], undefined, [err]);
|
|
3672
3673
|
return promise;
|
|
3673
3674
|
};
|
|
3674
|
-
const s = JS_GetOpaque(this_val,
|
|
3675
|
+
const s = JS_GetOpaque(this_val, 52 /* JSClassID.ASYNC_FROM_SYNC_ITERATOR */);
|
|
3675
3676
|
if (!s) {
|
|
3676
3677
|
JS_ThrowTypeError(ctx, 'not an Async-from-Sync Iterator');
|
|
3677
3678
|
return reject();
|