@expofp/offline 3.0.0-alpha.12 → 3.0.0-alpha.14

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.
@@ -9,20 +9,35 @@ const log = debug('efp:offline:generate-offline-data');
9
9
  export async function* generateOfflineData(inputManifest, options) {
10
10
  const manifest = deepClone(await resolve(inputManifest));
11
11
  log(`Generating offline files for expo: ${manifest.expo}`);
12
+ const pathPrefix = manifest.expo;
13
+ // this is a requirement of mobile SDK, paths in the ZIP must be prefixed with the expo name
14
+ // TODO: make sure SDK works with unprefixed paths, and remove the prefixing logic from this function
15
+ const prefixPath = (path) => `${pathPrefix}/${path}`;
12
16
  if (manifest.legacyDataUrlBase) {
13
- yield* generateOfflineDataLegacy(manifest, options);
17
+ for await (const d of generateOfflineDataLegacy(manifest, options)) {
18
+ yield { ...d, targetFilePath: prefixPath(d.targetFilePath) };
19
+ }
14
20
  }
15
21
  // transform entire manifest + assets
16
22
  const data = await offlinizeAssetsInPlace(manifest, options);
17
23
  for (const d of data) {
18
- yield d;
24
+ yield { ...d, targetFilePath: prefixPath(d.targetFilePath) };
19
25
  }
20
- // add runtime files
21
- const { entry } = yield* generateRuntimeFilesData(options.runtimeBaseUrl);
26
+ // add runtime files — manually iterate to prefix paths while capturing return value
27
+ const runtimeGen = generateRuntimeFilesData(options.runtimeBaseUrl);
28
+ let runtimeResult = await runtimeGen.next();
29
+ while (!runtimeResult.done) {
30
+ yield {
31
+ ...runtimeResult.value,
32
+ targetFilePath: prefixPath(runtimeResult.value.targetFilePath),
33
+ };
34
+ runtimeResult = await runtimeGen.next();
35
+ }
36
+ const { entry } = runtimeResult.value;
22
37
  // generate index.html
23
38
  yield {
24
39
  text: getIndexHtml(entry, manifest),
25
- targetFilePath: 'index.html',
40
+ targetFilePath: prefixPath('index.html'),
26
41
  };
27
42
  }
28
43
  /** Build a complete offline ZIP archive from a manifest. */
@@ -31,13 +46,17 @@ export async function buildOfflineZip(manifest, options) {
31
46
  const files = dataToFiles(data, { signal: options.signal });
32
47
  return await buildZipArchive(files);
33
48
  }
49
+ /** Known path — file lives in `packages/floorplan/public/` and is copied to dist by Vite. */
50
+ const COMPAT_HELPER = 'compat-helper.js';
34
51
  function getIndexHtml(entry, manifest) {
52
+ // entry is "./runtime/index.js", derive the runtime base path
53
+ const runtimeBase = entry.slice(0, entry.lastIndexOf('/') + 1);
35
54
  return `\
36
55
  <!DOCTYPE html>
56
+ <script src="${runtimeBase}${COMPAT_HELPER}"></script>
37
57
  <script type="module">
38
58
  import { load } from ${JSON.stringify(entry)};
39
59
  await load(${JSON.stringify(manifest)});
40
- console.info('loaded');
41
60
  </script>
42
61
  `;
43
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expofp/offline",
3
- "version": "3.0.0-alpha.12",
3
+ "version": "3.0.0-alpha.14",
4
4
  "type": "module",
5
5
  "description": "CLI tool for creating offline copies of ExpoFP floor plans",
6
6
  "license": "MIT",
@@ -30,9 +30,9 @@
30
30
  "dependencies": {
31
31
  "debug": "^4.4.3",
32
32
  "tslib": "^2.3.0",
33
- "@expofp/data": "3.0.0-alpha.12",
34
- "@expofp/floorplan": "3.0.0-alpha.12",
35
- "@expofp/utils": "3.0.0-alpha.12",
36
- "@expofp/resolve": "3.0.0-alpha.12"
33
+ "@expofp/data": "3.0.0-alpha.14",
34
+ "@expofp/floorplan": "3.0.0-alpha.14",
35
+ "@expofp/utils": "3.0.0-alpha.14",
36
+ "@expofp/resolve": "3.0.0-alpha.14"
37
37
  }
38
38
  }