slopcode 0.2.149 → 0.2.150
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/android-runtime/arm64/bin/slopcode +0 -0
- package/android-runtime/arm64/bin/slopcode-android-host +0 -0
- package/android-runtime/x64/bin/slopcode +0 -0
- package/android-runtime/x64/bin/slopcode-android-host +0 -0
- package/bin/slopcode +48 -23
- package/bundle/index.js +163 -5
- package/bundle/worker.js +83 -65
- package/package.json +12 -12
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bin/slopcode
CHANGED
|
@@ -19,29 +19,40 @@ function startupLog(phase, extra = {}) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function run(target, options = {}) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
startupLog("launcher.exec", { target: path.basename(target) })
|
|
23
|
+
const result = childProcess.spawnSync(target, options.args || process.argv.slice(2), {
|
|
24
|
+
stdio: "inherit",
|
|
25
|
+
env: options.env ? { ...process.env, ...options.env } : process.env,
|
|
26
|
+
})
|
|
27
|
+
if (result.error) {
|
|
28
|
+
console.error(result.error.message)
|
|
29
|
+
process.exit(1)
|
|
30
|
+
}
|
|
31
|
+
if (result.signal === "SIGABRT" && options.fallback) {
|
|
32
|
+
console.error("slopcode crashed (SIGABRT), falling back to JS bundle...")
|
|
33
|
+
const bun = childProcess.spawnSync("bun", ["--version"], { encoding: "utf8", timeout: 3000 })
|
|
34
|
+
if (bun.status === 0 && bun.stdout.trim()) {
|
|
35
|
+
const fbEnv = { ...process.env, SLOPCODE_IN_PROCESS: "1", ...(options.fallbackEnv || {}) }
|
|
36
|
+
const fb = childProcess.spawnSync("bun", ["run", options.fallback, ...(options.args || process.argv.slice(2))], {
|
|
37
|
+
stdio: "inherit",
|
|
38
|
+
env: fbEnv,
|
|
39
|
+
})
|
|
40
|
+
if (fb.error) {
|
|
41
|
+
console.error(fb.error.message)
|
|
42
|
+
process.exit(1)
|
|
43
|
+
}
|
|
44
|
+
if (fb.signal) {
|
|
45
|
+
try { process.kill(process.pid, fb.signal) } catch {}
|
|
46
|
+
}
|
|
47
|
+
process.exit(typeof fb.status === "number" ? fb.status : 1)
|
|
41
48
|
}
|
|
42
|
-
const code = typeof result.status === "number" ? result.status : 1
|
|
43
|
-
process.exit(code)
|
|
44
49
|
}
|
|
50
|
+
if (result.signal) {
|
|
51
|
+
try {
|
|
52
|
+
process.kill(process.pid, result.signal)
|
|
53
|
+
} catch {}
|
|
54
|
+
}
|
|
55
|
+
process.exit(typeof result.status === "number" ? result.status : 1)
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
const envPath = process.env.SLOPCODE_BIN_PATH
|
|
@@ -321,9 +332,19 @@ const useCache = libc() !== "bionic"
|
|
|
321
332
|
|
|
322
333
|
const packageNames = names("slopcode-bin")
|
|
323
334
|
const resolvedNames = Array.from(new Set([...packageNames, ...names("slopcode")]))
|
|
335
|
+
|
|
336
|
+
function findFallback(binaryPath) {
|
|
337
|
+
const pkgDir = path.dirname(path.dirname(binaryPath))
|
|
338
|
+
const fallback = path.join(pkgDir, "fallback", "index.js")
|
|
339
|
+
if (!fs.existsSync(fallback)) return
|
|
340
|
+
const modules = path.join(pkgDir, "fallback", "modules")
|
|
341
|
+
return { path: fallback, env: { NODE_PATH: [modules, process.env.NODE_PATH].filter(Boolean).join(path.delimiter) } }
|
|
342
|
+
}
|
|
343
|
+
|
|
324
344
|
const hit = useCache ? cacheReady(resolvedNames) : undefined
|
|
325
345
|
if (hit) {
|
|
326
|
-
|
|
346
|
+
const resolvedPkg = resolveBinary() || findBinary(scriptDir)
|
|
347
|
+
run(hit, { fallback: resolvedPkg ? findFallback(resolvedPkg.path)?.path : undefined, fallbackEnv: resolvedPkg ? findFallback(resolvedPkg.path)?.env : undefined })
|
|
327
348
|
}
|
|
328
349
|
clearCache()
|
|
329
350
|
|
|
@@ -428,4 +449,8 @@ if (libc() === "bionic" && androidInteractive(args)) {
|
|
|
428
449
|
}
|
|
429
450
|
}
|
|
430
451
|
|
|
431
|
-
|
|
452
|
+
const fallback = findFallback(resolved.path)
|
|
453
|
+
run(resolved.path, {
|
|
454
|
+
fallback: fallback?.path,
|
|
455
|
+
fallbackEnv: fallback?.env,
|
|
456
|
+
})
|