@swmansion/popcorn 0.4.0-next.8 → 0.4.0-next.9
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/dist/index.mjs +10 -2
- package/dist/plugins/vite.mjs +1 -0
- package/dist/popcorn.d.ts +1 -0
- package/dist/worker.mjs +5 -8
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -716,7 +716,12 @@ class Popcorn {
|
|
|
716
716
|
return;
|
|
717
717
|
case "otp:run_js":
|
|
718
718
|
this.vmReady = true;
|
|
719
|
-
this.runJs(data.payload)
|
|
719
|
+
this.runJs(data.payload).catch((error) => {
|
|
720
|
+
check(error instanceof Error);
|
|
721
|
+
const payload = { ok: false, error: error.toString() };
|
|
722
|
+
this.sendRunJsReply(data.payload, payload);
|
|
723
|
+
throw error;
|
|
724
|
+
});
|
|
720
725
|
return;
|
|
721
726
|
case "otp:await-ready":
|
|
722
727
|
this.handleReadyRequest(data.payload.replyTo);
|
|
@@ -1212,9 +1217,12 @@ class Popcorn {
|
|
|
1212
1217
|
payload = { ok: true, value: value ?? null };
|
|
1213
1218
|
}
|
|
1214
1219
|
catch (error) {
|
|
1215
|
-
check(error instanceof Error);
|
|
1220
|
+
check(error instanceof Error, `JS.run/3 must throw an Error instance. Received: ${String(error)}`);
|
|
1216
1221
|
payload = { ok: false, error: error.toString() };
|
|
1217
1222
|
}
|
|
1223
|
+
this.sendRunJsReply(request, payload);
|
|
1224
|
+
}
|
|
1225
|
+
sendRunJsReply(request, payload) {
|
|
1218
1226
|
const target = { pid: request.replyTo };
|
|
1219
1227
|
const tracked = [];
|
|
1220
1228
|
const command = serializeSendPayload(target, payload, this.handleMapper(tracked));
|
package/dist/plugins/vite.mjs
CHANGED
|
@@ -112,6 +112,7 @@ function popcorn(options) {
|
|
|
112
112
|
}
|
|
113
113
|
const content = await readFile(`${filePath}${encoding.suffix}`);
|
|
114
114
|
setContentType(res, filePath);
|
|
115
|
+
res.setHeader("Cache-Control", "no-cache");
|
|
115
116
|
res.setHeader("Vary", "Accept-Encoding");
|
|
116
117
|
if (encoding.name !== null) {
|
|
117
118
|
res.setHeader("Content-Encoding", encoding.name);
|
package/dist/popcorn.d.ts
CHANGED
package/dist/worker.mjs
CHANGED
|
@@ -649,17 +649,14 @@ async function loadFsData(assetsRoot) {
|
|
|
649
649
|
error: err("beam:missing-boot-script", { url: bootUrl }),
|
|
650
650
|
};
|
|
651
651
|
}
|
|
652
|
-
const loadedTarballs = await Promise.all(
|
|
653
|
-
const entry = manifest.apps[name];
|
|
652
|
+
const loadedTarballs = await Promise.all(Object.entries(manifest.bundles).map(async ([name, entry]) => {
|
|
654
653
|
const tarUrl = resolveAssetsPath(assetsRoot, entry.tar);
|
|
655
654
|
const tar = await fetchBinary(tarUrl);
|
|
656
|
-
if (tar
|
|
657
|
-
return {
|
|
658
|
-
ok: false,
|
|
659
|
-
error: err("beam:missing-tarball", { name, all: appNames }),
|
|
660
|
-
};
|
|
655
|
+
if (tar !== null) {
|
|
656
|
+
return { ok: true, data: tar };
|
|
661
657
|
}
|
|
662
|
-
|
|
658
|
+
const all = Object.keys(manifest.bundles);
|
|
659
|
+
return { ok: false, error: err("beam:missing-tarball", { name, all }) };
|
|
663
660
|
}));
|
|
664
661
|
const tarballs = [];
|
|
665
662
|
for (const tarball of loadedTarballs) {
|