@absolutejs/absolute 0.20.0-beta.36 → 0.20.0-beta.38

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.
@@ -2,6 +2,32 @@
2
2
  // src/dev/serverBootstrap.ts
3
3
  import { copyFileSync, existsSync, readdirSync, unlinkSync } from "fs";
4
4
  import { dirname, extname, join, resolve } from "path";
5
+
6
+ // src/dev/serverEntryCopies.ts
7
+ var ENTRY_COPY_OWNER_PATTERN = /^\.absolutejs-hmr-(\d+)-(?:bootstrap-)?\d+\.[^.]+$/;
8
+ var absoluteServerEntryCopyOwnerPid = (name) => {
9
+ const match = ENTRY_COPY_OWNER_PATTERN.exec(name);
10
+ if (!match)
11
+ return null;
12
+ const pid = Number(match[1]);
13
+ return Number.isSafeInteger(pid) && pid > 0 ? pid : null;
14
+ };
15
+ var isProcessAlive = (pid) => {
16
+ try {
17
+ process.kill(pid, 0);
18
+ return true;
19
+ } catch (error) {
20
+ return !(error instanceof Error && ("code" in error) && error.code === "ESRCH");
21
+ }
22
+ };
23
+ var isStaleAbsoluteServerEntryCopy = (name, currentPid = process.pid, ownerIsAlive = isProcessAlive) => {
24
+ const ownerPid = absoluteServerEntryCopyOwnerPid(name);
25
+ if (ownerPid === null)
26
+ return false;
27
+ return ownerPid === currentPid || !ownerIsAlive(ownerPid);
28
+ };
29
+
30
+ // src/dev/serverBootstrap.ts
5
31
  var originalEntry = process.env.ABSOLUTE_SERVER_ENTRY;
6
32
  if (!originalEntry) {
7
33
  throw new Error("ABSOLUTE_SERVER_ENTRY is required by the AbsoluteJS dev bootstrap");
@@ -24,6 +50,8 @@ if (!isHotReevaluation) {
24
50
  if (!name.startsWith(copyPrefix) || !name.endsWith(entryExtension)) {
25
51
  continue;
26
52
  }
53
+ if (!isStaleAbsoluteServerEntryCopy(name))
54
+ continue;
27
55
  removeEntryCopy(join(entryDir, name));
28
56
  }
29
57
  }
@@ -5427,12 +5427,26 @@ var shellPushModule = () => {
5427
5427
  throw new TypeError("AbsoluteJS mobile push shell module is missing.");
5428
5428
  };
5429
5429
  var escapeHtml = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
5430
- var indexHtml = (appName) => `<!doctype html>
5430
+ var contentSecurityPolicy = (productionOrigin) => {
5431
+ const backend = new URL(productionOrigin);
5432
+ const socketOrigin = `${backend.protocol === "https:" ? "wss:" : "ws:"}//${backend.host}`;
5433
+ return [
5434
+ "default-src 'self' data: blob: https:",
5435
+ "base-uri 'none'",
5436
+ "object-src 'none'",
5437
+ "script-src 'self'",
5438
+ "style-src 'self' 'unsafe-inline'",
5439
+ `connect-src 'self' ${backend.origin} ${socketOrigin}`,
5440
+ "form-action 'none'"
5441
+ ].join("; ");
5442
+ };
5443
+ var indexHtml = (appName, productionOrigin) => `<!doctype html>
5431
5444
  <html>
5432
5445
  <head>
5433
5446
  <meta charset="utf-8">
5434
5447
  <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
5435
5448
  <meta name="color-scheme" content="light dark">
5449
+ <meta http-equiv="Content-Security-Policy" content="${escapeHtml(contentSecurityPolicy(productionOrigin))}">
5436
5450
  <title>${escapeHtml(appName)}</title>
5437
5451
  </head>
5438
5452
  <body>
@@ -5663,7 +5677,7 @@ var materializeAbsoluteCapacitorWebBundle = async (options) => {
5663
5677
  await Promise.all([
5664
5678
  writeFile10(join9(staging, MANIFEST_FILE), `${JSON.stringify(manifest, null, "\t")}
5665
5679
  `),
5666
- writeFile10(join9(staging, INDEX_FILE), indexHtml(options.config.appName)),
5680
+ writeFile10(join9(staging, INDEX_FILE), indexHtml(options.config.appName, options.config.productionOrigin)),
5667
5681
  buildShellBootstrap(staging, options.auth !== undefined, options.auth !== undefined && options.sync === true, `absolutejs.${options.auth?.clientId ?? options.config.appId}.`, options.deviceCapabilities, options.projectRoot)
5668
5682
  ]);
5669
5683
  await installBundle(staging, destination);
@@ -7823,5 +7837,5 @@ export {
7823
7837
  ABSOLUTE_ANDROID_RELEASE_FORMAT
7824
7838
  };
7825
7839
 
7826
- //# debugId=4CA02552B071DAEC64756E2164756E21
7840
+ //# debugId=2B8EAAF79628B66764756E2164756E21
7827
7841
  //# sourceMappingURL=index.js.map