@swmansion/popcorn 0.4.0-next.2 → 0.4.0-next.3
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 +4 -4
- package/dist/events.d.ts +1 -1
- package/dist/index.mjs +5 -1
- package/dist/runtimes/core/beam.emu.mjs +139 -139
- package/dist/runtimes/core/beam.mjs +139 -139
- package/dist/runtimes/core/beam.wasm +0 -0
- package/dist/runtimes/crypto/beam.emu.mjs +518 -517
- package/dist/runtimes/crypto/beam.mjs +518 -517
- package/dist/runtimes/crypto/beam.wasm +0 -0
- package/dist/types.d.ts +1 -0
- package/dist/worker.mjs +21 -5
- package/package.json +1 -1
|
Binary file
|
package/dist/types.d.ts
CHANGED
package/dist/worker.mjs
CHANGED
|
@@ -466,7 +466,7 @@ function start(options) {
|
|
|
466
466
|
};
|
|
467
467
|
}
|
|
468
468
|
async function boot(opts, state, vm) {
|
|
469
|
-
const { otpAssetsRoot, emulatorArgs, extraArgs, env, ttySize, createModule, emit, } = opts;
|
|
469
|
+
const { otpAssetsRoot, emulatorArgs, extraArgs, env, ttySize, noshell, createModule, emit, } = opts;
|
|
470
470
|
const loadedFsData = await loadFsData(otpAssetsRoot);
|
|
471
471
|
if (!loadedFsData.ok) {
|
|
472
472
|
return { ok: false, error: loadedFsData.error };
|
|
@@ -485,22 +485,34 @@ async function boot(opts, state, vm) {
|
|
|
485
485
|
LINES: String(ttySize.rows),
|
|
486
486
|
ERL_INETRC: INETRC_PATH,
|
|
487
487
|
};
|
|
488
|
+
let emitError = function (payload) {
|
|
489
|
+
emitError = null;
|
|
490
|
+
state.isVmReady = false;
|
|
491
|
+
emit({ type: "otp:error", payload });
|
|
492
|
+
};
|
|
488
493
|
const moduleConfig = {
|
|
489
494
|
print: (text) => emit({ type: "otp:stdout", payload: UTF8.encode(text) }),
|
|
490
495
|
printErr: (text) => emit({ type: "otp:stderr", payload: UTF8.encode(text) }),
|
|
491
|
-
onExit: (code) =>
|
|
492
|
-
onAbort: (text) =>
|
|
496
|
+
onExit: (code) => emitError?.({ kind: "exit", data: code }),
|
|
497
|
+
onAbort: (text) => emitError?.({ kind: "abort", data: text }),
|
|
493
498
|
onBeamMessage: (text) => {
|
|
499
|
+
if (emitError === null) {
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
494
502
|
const event = deserializeBridgeMessage(text);
|
|
495
503
|
if (event === null)
|
|
496
504
|
return;
|
|
505
|
+
if (event.type === "otp:error") {
|
|
506
|
+
emitError(event.payload);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
497
509
|
if (handleVmReady(event))
|
|
498
510
|
return;
|
|
499
511
|
if (handleAppReady(event))
|
|
500
512
|
return;
|
|
501
513
|
emit(event);
|
|
502
514
|
},
|
|
503
|
-
onError: (text) =>
|
|
515
|
+
onError: (text) => emitError?.({ kind: "error", data: text }),
|
|
504
516
|
onStdinConsumed: (size) => emit({ type: "otp:stdin-consumed", payload: size }),
|
|
505
517
|
onTrackedValueDelete: (key) => emit({ type: "otp:tracked-value-delete", payload: key }),
|
|
506
518
|
onTtyChunk: (fd, chunk) => emit({
|
|
@@ -510,6 +522,7 @@ async function boot(opts, state, vm) {
|
|
|
510
522
|
arguments: buildArgs({
|
|
511
523
|
appNames: fsData.appNames,
|
|
512
524
|
entrypoint: fsData.entrypoint,
|
|
525
|
+
noshell,
|
|
513
526
|
emulator: emulatorArgs ?? [],
|
|
514
527
|
extra: extraArgs ?? [],
|
|
515
528
|
}),
|
|
@@ -577,8 +590,10 @@ function toPopcornError(error) {
|
|
|
577
590
|
const message = error instanceof Error ? error.message : String(error);
|
|
578
591
|
return err("worker:load", { message });
|
|
579
592
|
}
|
|
580
|
-
function buildArgs({ appNames, entrypoint, emulator, extra, }) {
|
|
593
|
+
function buildArgs({ appNames, entrypoint, noshell, emulator, extra, }) {
|
|
581
594
|
const args = [...emulator, "--", ...BASE_ARGS, "-boot", BOOT_NAME];
|
|
595
|
+
if (noshell)
|
|
596
|
+
args.push("-noshell");
|
|
582
597
|
for (const app of CORE_APPS) {
|
|
583
598
|
args.push("-pa", `/lib/${app}/ebin`);
|
|
584
599
|
}
|
|
@@ -775,6 +790,7 @@ self.onmessage = async (event) => {
|
|
|
775
790
|
extraArgs: data.payload.extraArgs,
|
|
776
791
|
env: data.payload.env,
|
|
777
792
|
ttySize: data.payload.ttySize,
|
|
793
|
+
noshell: data.payload.noshell,
|
|
778
794
|
createModule,
|
|
779
795
|
emit: toMain,
|
|
780
796
|
});
|