@mikrojs/quickjs 0.12.0 → 0.14.0-pr-229.g0d8db1b
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/deps/quickjs/quickjs.c +42 -0
- package/deps/quickjs/quickjs.h +20 -0
- package/package.json +1 -1
package/deps/quickjs/quickjs.c
CHANGED
|
@@ -29724,6 +29724,48 @@ static void js_free_module_def(JSContext *ctx, JSModuleDef *m)
|
|
|
29724
29724
|
js_free(ctx, m);
|
|
29725
29725
|
}
|
|
29726
29726
|
|
|
29727
|
+
/* mikrojs patch: public wrapper to free a single module (remove it from
|
|
29728
|
+
* the context's loaded-modules cache and release all its resources).
|
|
29729
|
+
* Callers must ensure the module is not mid-linking or mid-evaluating and
|
|
29730
|
+
* that no other modules hold live import bindings to its exports (or accept
|
|
29731
|
+
* that such bindings remain valid via refcounted JSVarRefs). */
|
|
29732
|
+
void JS_FreeModule(JSContext *ctx, JSModuleDef *m)
|
|
29733
|
+
{
|
|
29734
|
+
js_free_module_def(ctx, m);
|
|
29735
|
+
}
|
|
29736
|
+
|
|
29737
|
+
static JSModuleDef *js_find_loaded_module(JSContext *ctx, JSAtom name);
|
|
29738
|
+
|
|
29739
|
+
/* mikrojs patch: lookup a module in the context cache by name atom.
|
|
29740
|
+
* Returns NULL if no module with that name is loaded. */
|
|
29741
|
+
JSModuleDef *JS_FindLoadedModule(JSContext *ctx, JSAtom name)
|
|
29742
|
+
{
|
|
29743
|
+
return js_find_loaded_module(ctx, name);
|
|
29744
|
+
}
|
|
29745
|
+
|
|
29746
|
+
/* mikrojs patch: return the module's current status as an integer.
|
|
29747
|
+
* 0=UNLINKED, 1=LINKING, 2=LINKED, 3=EVALUATING, 4=EVALUATING_ASYNC, 5=EVALUATED. */
|
|
29748
|
+
int JS_GetModuleStatus(JSContext *ctx, JSModuleDef *m)
|
|
29749
|
+
{
|
|
29750
|
+
(void)ctx;
|
|
29751
|
+
return (int)m->status;
|
|
29752
|
+
}
|
|
29753
|
+
|
|
29754
|
+
/* mikrojs patch: find the loaded module whose namespace object is `ns`.
|
|
29755
|
+
* Reverse of JS_GetModuleNamespace. Returns NULL if `ns` is not the
|
|
29756
|
+
* namespace of any loaded module (or its namespace has not been built). */
|
|
29757
|
+
JSModuleDef *JS_FindModuleByNamespace(JSContext *ctx, JSValueConst ns)
|
|
29758
|
+
{
|
|
29759
|
+
struct list_head *el;
|
|
29760
|
+
list_for_each(el, &ctx->loaded_modules) {
|
|
29761
|
+
JSModuleDef *m = list_entry(el, JSModuleDef, link);
|
|
29762
|
+
if (!JS_IsUndefined(m->module_ns) &&
|
|
29763
|
+
JS_VALUE_GET_PTR(m->module_ns) == JS_VALUE_GET_PTR(ns))
|
|
29764
|
+
return m;
|
|
29765
|
+
}
|
|
29766
|
+
return NULL;
|
|
29767
|
+
}
|
|
29768
|
+
|
|
29727
29769
|
#ifndef QJS_DISABLE_PARSER
|
|
29728
29770
|
|
|
29729
29771
|
static int add_req_module_entry(JSContext *ctx, JSModuleDef *m,
|
package/deps/quickjs/quickjs.h
CHANGED
|
@@ -1190,6 +1190,26 @@ JS_EXTERN JSValue JS_GetImportMeta(JSContext *ctx, JSModuleDef *m);
|
|
|
1190
1190
|
JS_EXTERN JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m);
|
|
1191
1191
|
JS_EXTERN JSValue JS_GetModuleNamespace(JSContext *ctx, JSModuleDef *m);
|
|
1192
1192
|
|
|
1193
|
+
/* mikrojs patch: evict a module from the context, releasing all its
|
|
1194
|
+
* resources. Caller is responsible for ensuring the module is in a safe
|
|
1195
|
+
* state (not linking, not evaluating). */
|
|
1196
|
+
JS_EXTERN void JS_FreeModule(JSContext *ctx, JSModuleDef *m);
|
|
1197
|
+
|
|
1198
|
+
/* mikrojs patch: lookup a module in the context cache by name atom.
|
|
1199
|
+
* Returns NULL if no module with that name is loaded. */
|
|
1200
|
+
JS_EXTERN JSModuleDef *JS_FindLoadedModule(JSContext *ctx, JSAtom name);
|
|
1201
|
+
|
|
1202
|
+
/* mikrojs patch: return the module's current status.
|
|
1203
|
+
* 0=UNLINKED, 1=LINKING, 2=LINKED, 3=EVALUATING, 4=EVALUATING_ASYNC, 5=EVALUATED.
|
|
1204
|
+
* Constants deliberately omitted here because the internal QuickJS enum
|
|
1205
|
+
* reuses the same symbol names; callers define their own mirrored names. */
|
|
1206
|
+
JS_EXTERN int JS_GetModuleStatus(JSContext *ctx, JSModuleDef *m);
|
|
1207
|
+
|
|
1208
|
+
/* mikrojs patch: find the loaded module whose namespace object is `ns`
|
|
1209
|
+
* (reverse of JS_GetModuleNamespace). Returns NULL if `ns` is not a loaded
|
|
1210
|
+
* module's namespace. */
|
|
1211
|
+
JS_EXTERN JSModuleDef *JS_FindModuleByNamespace(JSContext *ctx, JSValueConst ns);
|
|
1212
|
+
|
|
1193
1213
|
/* associate a JSValue to a C module */
|
|
1194
1214
|
JS_EXTERN int JS_SetModulePrivateValue(JSContext *ctx, JSModuleDef *m, JSValue val);
|
|
1195
1215
|
JS_EXTERN JSValue JS_GetModulePrivateValue(JSContext *ctx, JSModuleDef *m);
|