sloppycode 0.2.149 → 0.2.151
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 +49 -23
- package/bundle/index.js +167 -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,41 @@ 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
|
+
cwd: path.dirname(options.fallback),
|
|
40
|
+
})
|
|
41
|
+
if (fb.error) {
|
|
42
|
+
console.error(fb.error.message)
|
|
43
|
+
process.exit(1)
|
|
44
|
+
}
|
|
45
|
+
if (fb.signal) {
|
|
46
|
+
try { process.kill(process.pid, fb.signal) } catch {}
|
|
47
|
+
}
|
|
48
|
+
process.exit(typeof fb.status === "number" ? fb.status : 1)
|
|
41
49
|
}
|
|
42
|
-
const code = typeof result.status === "number" ? result.status : 1
|
|
43
|
-
process.exit(code)
|
|
44
50
|
}
|
|
51
|
+
if (result.signal) {
|
|
52
|
+
try {
|
|
53
|
+
process.kill(process.pid, result.signal)
|
|
54
|
+
} catch {}
|
|
55
|
+
}
|
|
56
|
+
process.exit(typeof result.status === "number" ? result.status : 1)
|
|
45
57
|
}
|
|
46
58
|
|
|
47
59
|
const envPath = process.env.SLOPCODE_BIN_PATH
|
|
@@ -321,9 +333,19 @@ const useCache = libc() !== "bionic"
|
|
|
321
333
|
|
|
322
334
|
const packageNames = names("slopcode-bin")
|
|
323
335
|
const resolvedNames = Array.from(new Set([...packageNames, ...names("slopcode")]))
|
|
336
|
+
|
|
337
|
+
function findFallback(binaryPath) {
|
|
338
|
+
const pkgDir = path.dirname(path.dirname(binaryPath))
|
|
339
|
+
const fallback = path.join(pkgDir, "fallback", "index.js")
|
|
340
|
+
if (!fs.existsSync(fallback)) return
|
|
341
|
+
const modules = path.join(pkgDir, "fallback", "modules")
|
|
342
|
+
return { path: fallback, env: { NODE_PATH: [modules, process.env.NODE_PATH].filter(Boolean).join(path.delimiter) } }
|
|
343
|
+
}
|
|
344
|
+
|
|
324
345
|
const hit = useCache ? cacheReady(resolvedNames) : undefined
|
|
325
346
|
if (hit) {
|
|
326
|
-
|
|
347
|
+
const resolvedPkg = resolveBinary() || findBinary(scriptDir)
|
|
348
|
+
run(hit, { fallback: resolvedPkg ? findFallback(resolvedPkg.path)?.path : undefined, fallbackEnv: resolvedPkg ? findFallback(resolvedPkg.path)?.env : undefined })
|
|
327
349
|
}
|
|
328
350
|
clearCache()
|
|
329
351
|
|
|
@@ -428,4 +450,8 @@ if (libc() === "bionic" && androidInteractive(args)) {
|
|
|
428
450
|
}
|
|
429
451
|
}
|
|
430
452
|
|
|
431
|
-
|
|
453
|
+
const fallback = findFallback(resolved.path)
|
|
454
|
+
run(resolved.path, {
|
|
455
|
+
fallback: fallback?.path,
|
|
456
|
+
fallbackEnv: fallback?.env,
|
|
457
|
+
})
|