@expofp/offline 3.0.0-alpha.10 → 3.0.0-alpha.12
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
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @expofp/offline
|
|
2
|
+
|
|
3
|
+
CLI and programmatic API for creating offline ZIP archives of ExpoFP floor plans.
|
|
4
|
+
|
|
5
|
+
## CLI
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx expofp-offline <manifest-url> [options]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Arguments
|
|
12
|
+
|
|
13
|
+
| Argument | Description |
|
|
14
|
+
| -------------- | ----------------------------------- |
|
|
15
|
+
| `manifest-url` | URL to the floor plan manifest JSON |
|
|
16
|
+
|
|
17
|
+
### Options
|
|
18
|
+
|
|
19
|
+
| Option | Description | Default |
|
|
20
|
+
| ----------------- | ------------------- | ------------- |
|
|
21
|
+
| `-o`, `--output` | Output file path | `offline.zip` |
|
|
22
|
+
| `-h`, `--help` | Show help message | |
|
|
23
|
+
| `-v`, `--version` | Show version number | |
|
|
24
|
+
|
|
25
|
+
### Example
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx expofp-offline https://demo.expofp.com/manifest.json -o demo-offline.zip
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Programmatic API
|
|
32
|
+
|
|
33
|
+
### `buildOfflineZip(manifest, options): Promise<Blob>`
|
|
34
|
+
|
|
35
|
+
Generates a complete offline ZIP archive as a `Blob`. Works in both browser and Node.js.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { buildOfflineZip } from '@expofp/offline';
|
|
39
|
+
|
|
40
|
+
const blob = await buildOfflineZip(
|
|
41
|
+
{ $ref: 'https://demo.expofp.com/manifest.json' },
|
|
42
|
+
{ runtimeBaseUrl: 'https://cdn.expofp.com/runtime/' },
|
|
43
|
+
);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### `downloadOfflineZip(manifest, options): Promise<void>`
|
|
47
|
+
|
|
48
|
+
Builds the ZIP and triggers a browser download. Browser-only.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { downloadOfflineZip } from '@expofp/offline';
|
|
52
|
+
|
|
53
|
+
await downloadOfflineZip(manifest, {
|
|
54
|
+
runtimeBaseUrl: 'https://cdn.expofp.com/runtime/',
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### `saveOfflineZip(manifest, path, options): Promise<void>`
|
|
59
|
+
|
|
60
|
+
Builds the ZIP and writes it to disk. Node.js-only.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { saveOfflineZip } from '@expofp/offline';
|
|
64
|
+
|
|
65
|
+
await saveOfflineZip({ $ref: 'https://demo.expofp.com/manifest.json' }, './offline.zip', {
|
|
66
|
+
runtimeBaseUrl: 'https://cdn.expofp.com/runtime/',
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Options
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
interface OfflineOptions {
|
|
74
|
+
/** Base URL of the @expofp/floorplan runtime assets */
|
|
75
|
+
runtimeBaseUrl: string;
|
|
76
|
+
/** AbortSignal to cancel the operation */
|
|
77
|
+
signal?: AbortSignal;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from '@expofp/resolve';
|
|
2
|
-
import { deepClone,
|
|
2
|
+
import { deepClone, fetchWithRetry, makeLocalPath } from '@expofp/utils';
|
|
3
3
|
import debug from 'debug';
|
|
4
4
|
import { offlinizeAssetsInPlace } from './offlinize-assets-in-place.js';
|
|
5
5
|
const log = debug('efp:offline:generate-offline-data-legacy');
|
|
@@ -53,7 +53,7 @@ export async function* generateOfflineDataLegacy(manifest, options) {
|
|
|
53
53
|
* (the function itself is Node-only).
|
|
54
54
|
*/
|
|
55
55
|
async function execScriptInSandbox(url, signal) {
|
|
56
|
-
const response = await
|
|
56
|
+
const response = await fetchWithRetry(url, { signal });
|
|
57
57
|
if (!response.ok) {
|
|
58
58
|
throw new Error(`Failed to fetch script (HTTP ${response.status}): ${url}`);
|
|
59
59
|
}
|
|
@@ -22,7 +22,7 @@ export async function* generateOfflineData(inputManifest, options) {
|
|
|
22
22
|
// generate index.html
|
|
23
23
|
yield {
|
|
24
24
|
text: getIndexHtml(entry, manifest),
|
|
25
|
-
targetFilePath: '
|
|
25
|
+
targetFilePath: 'index.html',
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
/** Build a complete offline ZIP archive from a manifest. */
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { importJson } from '@expofp/utils';
|
|
2
2
|
import debug from 'debug';
|
|
3
3
|
const log = debug('efp:offline:generate-runtime-files-data');
|
|
4
4
|
export async function* generateRuntimeFilesData(runtimeBaseUrl) {
|
|
5
5
|
const bundleJsonUrl = new URL('bundle.json', runtimeBaseUrl).href;
|
|
6
|
-
const bundleJson = await
|
|
6
|
+
const bundleJson = await importJson(bundleJsonUrl);
|
|
7
7
|
log(`Generating runtime files from ${bundleJsonUrl}, ${bundleJson.files.length} files found`);
|
|
8
|
-
const basePath = '
|
|
8
|
+
const basePath = 'runtime/';
|
|
9
9
|
for (const file of bundleJson.files) {
|
|
10
10
|
yield {
|
|
11
11
|
url: new URL(file.file, runtimeBaseUrl),
|
|
12
12
|
targetFilePath: `${basePath}${file.file}`,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
return { entry:
|
|
15
|
+
return { entry: `./${basePath}${bundleJson.entry}` };
|
|
16
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fetchWithRetry, makeLocalPath } from '@expofp/utils';
|
|
2
2
|
import debug from 'debug';
|
|
3
3
|
import { offlinizeAssetUrl } from './offlinize-asset-url.js';
|
|
4
4
|
import { offlinizeCssAssetText } from './offlinize-css-asset-text.js';
|
|
@@ -66,7 +66,7 @@ export async function offlinizeAssetsInPlace(data, opts) {
|
|
|
66
66
|
// Mark as fetched to prevent duplicates
|
|
67
67
|
log(`Offlinizing $ref: ${refValue} -> ${targetFilePath}${fragment}`);
|
|
68
68
|
// Fetch and recursively process the referenced document
|
|
69
|
-
const response = await
|
|
69
|
+
const response = await fetchWithRetry(urlKey, { signal: opts.signal });
|
|
70
70
|
if (response.ok) {
|
|
71
71
|
const referencedData = await response.json();
|
|
72
72
|
processedRefs.set(urlKey, referencedData);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expofp/offline",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.12",
|
|
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.
|
|
34
|
-
"@expofp/floorplan": "3.0.0-alpha.
|
|
35
|
-
"@expofp/
|
|
36
|
-
"@expofp/
|
|
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"
|
|
37
37
|
}
|
|
38
38
|
}
|