This commit is contained in:
2026-01-19 14:39:55 -06:00
parent cbf99295da
commit 38a3697e28
2 changed files with 43 additions and 20 deletions

View File

@@ -56,8 +56,6 @@ globalThis.ends_with = function(str, suffix) {
var js = use_embed('js')
var fd = use_embed('fd')
os.print(fd)
// Get the shop path from HOME environment
var home = os.getenv('HOME') || os.getenv('USERPROFILE')
if (!home) {

View File

@@ -36572,36 +36572,61 @@ static JSValue js_cell_meme(JSContext *ctx, JSValueConst this_val,
if (JS_IsException(result))
return result;
/* Apply mixins */
for (int i = 1; i < argc; i++) {
JSValue mix = argv[i];
if (!JS_IsObject(mix) || JS_IsNull(mix) || JS_IsArray(ctx, mix))
continue;
if (argc < 2)
return result;
JSPropertyEnum *tab;
uint32_t len;
JSValue mixins = argv[1];
if (JS_GetOwnPropertyNames(ctx, &tab, &len, mix,
JS_GPN_STRING_MASK | JS_GPN_ENUM_ONLY) < 0) {
/* Helper function to apply a single mixin */
#define APPLY_MIXIN(mix) do { \
if (!JS_IsObject(mix) || JS_IsNull(mix) || JS_IsArray(ctx, mix)) \
break; \
JSPropertyEnum *tab; \
uint32_t len; \
if (JS_GetOwnPropertyNames(ctx, &tab, &len, mix, \
JS_GPN_STRING_MASK | JS_GPN_ENUM_ONLY) < 0) { \
JS_FreeValue(ctx, result); \
return JS_EXCEPTION; \
} \
for (uint32_t j = 0; j < len; j++) { \
JSValue val = JS_GetProperty(ctx, mix, tab[j].atom); \
if (JS_IsException(val)) { \
for (uint32_t k = j; k < len; k++) \
JS_FreeAtom(ctx, tab[k].atom); \
js_free(ctx, tab); \
JS_FreeValue(ctx, result); \
return JS_EXCEPTION; \
} \
JS_SetProperty(ctx, result, tab[j].atom, val); \
JS_FreeAtom(ctx, tab[j].atom); \
} \
js_free(ctx, tab); \
} while (0)
if (JS_IsArray(ctx, mixins)) {
/* Array of mixins */
int64_t len;
if (js_get_length64(ctx, &len, mixins)) {
JS_FreeValue(ctx, result);
return JS_EXCEPTION;
}
for (uint32_t j = 0; j < len; j++) {
JSValue val = JS_GetProperty(ctx, mix, tab[j].atom);
if (JS_IsException(val)) {
for (uint32_t k = j; k < len; k++)
JS_FreeAtom(ctx, tab[k].atom);
js_free(ctx, tab);
for (int64_t i = 0; i < len; i++) {
JSValue mix = JS_GetPropertyInt64(ctx, mixins, i);
if (JS_IsException(mix)) {
JS_FreeValue(ctx, result);
return JS_EXCEPTION;
}
JS_SetProperty(ctx, result, tab[j].atom, val);
JS_FreeAtom(ctx, tab[j].atom);
APPLY_MIXIN(mix);
JS_FreeValue(ctx, mix);
}
js_free(ctx, tab);
} else if (JS_IsObject(mixins) && !JS_IsNull(mixins)) {
/* Single mixin object */
APPLY_MIXIN(mixins);
}
#undef APPLY_MIXIN
return result;
}