arcane-os 0.19.0 → 0.20.0
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/CHANGELOG.md +19 -0
- package/README.md +1 -1
- package/docs/architecture.md +18 -0
- package/docs/reference/cli.md +18 -17
- package/docs/reference/pwa.md +16 -2
- package/docs/reference/sdk-api.md +36 -33
- package/package.json +1 -1
- package/src/dev-server.mjs +10 -6
- package/src/packager/core.mjs +71 -26
- package/src/pwa.mjs +21 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.20.0
|
|
4
|
+
|
|
5
|
+
- Restore repository-shaped application packages: selected app files remain
|
|
6
|
+
under `apps/<id>/`, alongside shared `arcane/` and configured runtime routes.
|
|
7
|
+
Authored document bases, import maps, module-relative imports and application
|
|
8
|
+
resource paths retain their development layout without rewriting product
|
|
9
|
+
documents or application code to relocate them.
|
|
10
|
+
- Restore deployment-relative `ARCANE_APP_RELEASE.app.start` and a root
|
|
11
|
+
`index.html` launcher while preserving the app-relative `app.entry` identity.
|
|
12
|
+
Package consumers use `app.start` for navigation. SDK packaged previews honor
|
|
13
|
+
that field and retain support for earlier flat packages through `app.entry`.
|
|
14
|
+
- Keep generated PWA files at the deployment root, resolve manifest metadata
|
|
15
|
+
against the packaged app directory, and preserve app-relative offline
|
|
16
|
+
selections alongside shared runtime paths. Source import-map inspection keeps
|
|
17
|
+
app-relative document paths and separately reports emitted package paths.
|
|
18
|
+
- Align packaging references with the current public return values and explicit
|
|
19
|
+
source import-map generation. Add package-layout and nested-deployment test
|
|
20
|
+
source while retaining complete authored-content coverage.
|
|
21
|
+
|
|
3
22
|
## 0.19.0
|
|
4
23
|
|
|
5
24
|
- Read mail credentials from `.env.json` in the invocation directory through
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ version-locked SDK runtime, while an integrated Arcane checkout uses its live
|
|
|
19
19
|
`arcane/` runtime. Both profiles preserve the same app URLs, theme, packaging,
|
|
20
20
|
event, cancellation, and browser run contracts.
|
|
21
21
|
|
|
22
|
-
This checkout defines the `0.
|
|
22
|
+
This checkout defines the `0.20.0` SDK contract. Applications pin one exact npm
|
|
23
23
|
version and lockfile; registry state is deliberately not baked into application
|
|
24
24
|
artifacts.
|
|
25
25
|
|
package/docs/architecture.md
CHANGED
|
@@ -199,9 +199,27 @@ URLs and release schema:
|
|
|
199
199
|
apps/<id>/arcane-app.json
|
|
200
200
|
apps/<id>/arcane-package.json
|
|
201
201
|
apps/<id>/index.html
|
|
202
|
+
dist/<id>/index.html
|
|
203
|
+
dist/<id>/apps/<id>/index.html
|
|
202
204
|
dist/<id>/ARCANE_APP_RELEASE.json
|
|
203
205
|
```
|
|
204
206
|
|
|
207
|
+
Packaging places each selected app file beneath `apps/<id>/` in the release
|
|
208
|
+
and preserves every shared route destination. When no selected shared payload
|
|
209
|
+
supplies a root `index.html`, the SDK generates one that opens the selected app
|
|
210
|
+
entry. Authored document bases, app URLs, relative module imports, and shared
|
|
211
|
+
runtime paths therefore resolve through the same layout in
|
|
212
|
+
source development and packaged delivery. Packaging consumes the saved source
|
|
213
|
+
and managed import maps; use `arcane import-map` to refresh those maps, or the
|
|
214
|
+
ordinary `arcane dev` startup that performs that refresh.
|
|
215
|
+
|
|
216
|
+
The release manifest keeps `app.entry` relative to the app directory and records
|
|
217
|
+
the package launch URL in `app.start`, such as
|
|
218
|
+
`./apps/hello-world/index.html`. Its complete `files` inventory includes the
|
|
219
|
+
root `index.html` and the prefixed app files. Packaged browser serving opens
|
|
220
|
+
`app.start`; a previously generated flat release without `app.start` retains
|
|
221
|
+
its `app.entry` launch path.
|
|
222
|
+
|
|
205
223
|
The authored schema-2 descriptor is canonical for new apps and projects an
|
|
206
224
|
exact schema-1 `arcane-package.json` for current consumers. Existing Arcane
|
|
207
225
|
apps synthesize that descriptor from their schema-1 package plus the current
|
package/docs/reference/cli.md
CHANGED
|
@@ -195,8 +195,8 @@ Wrong or duplicate explicit app identity fails. The renderer then requires one
|
|
|
195
195
|
path-correct base for every selected document. Included HTML files with neither
|
|
196
196
|
the identity marker nor an active base are component fragments: they remain
|
|
197
197
|
package files and are not rewritten with a document-level import map.
|
|
198
|
-
Packaging and development use the same discovery owner
|
|
199
|
-
|
|
198
|
+
Packaging and development use the same discovery owner. Packaging consumes
|
|
199
|
+
the saved managed import maps in directly navigable source pages.
|
|
200
200
|
|
|
201
201
|
```text
|
|
202
202
|
arcane import-map [--workspace <directory>] [--app <id>]
|
|
@@ -254,19 +254,12 @@ together. A post-commit observer failure preserves delivery with
|
|
|
254
254
|
`eventDelivery.status === 'degraded'` and `ARCANE_EVENT_DELIVERY_FAILED`; it
|
|
255
255
|
does not roll back complete application content.
|
|
256
256
|
|
|
257
|
-
An external package also publishes `/ARCANE_RUNTIME_PROJECTION.json`. The JSON
|
|
258
|
-
is `{schemaVersion:1,kind:'arcane-app-runtime-projection',sdkVersion,
|
|
259
|
-
pathPrefix:'arcane/',files:[{path}]}` and lists the complete packaged runtime.
|
|
260
|
-
The development server exposes the same public route from its workspace
|
|
261
|
-
projection. The private `/ARCANE_APP_RELEASE.json` record is not served to
|
|
262
|
-
application code. Malformed projection data fails
|
|
263
|
-
`ARCANE_RUNTIME_PROJECTION_INVALID`.
|
|
264
|
-
|
|
265
257
|
`new` and `init` generate the map during scaffolding. `dev` refreshes all
|
|
266
|
-
selected documents once before binding
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
258
|
+
selected documents once before binding. `package` consumes the saved source
|
|
259
|
+
and maps; use `import-map` to refresh them explicitly before selecting output
|
|
260
|
+
that needs updated maps. Packaging does not run tests or checks automatically.
|
|
261
|
+
Browser `build` and paired native packaging reuse the package flow.
|
|
262
|
+
Explicit `test` and `check` operations read the existing map without regenerating it;
|
|
270
263
|
`verify`, `bundle`, and browser `run` do not regenerate it. There is no
|
|
271
264
|
watcher, polling, scheduled refresh, download, or self-update behavior.
|
|
272
265
|
|
|
@@ -504,9 +497,12 @@ npm exec -- arcane check --app hello-world
|
|
|
504
497
|
### Overview
|
|
505
498
|
|
|
506
499
|
Creates one complete browser release beneath `dist/<id>/`, preserving the prior
|
|
507
|
-
output until the replacement is complete. It
|
|
508
|
-
|
|
509
|
-
|
|
500
|
+
output until the replacement is complete. It consumes saved source and managed
|
|
501
|
+
import maps, places app files beneath `apps/<id>/`, and retains the configured
|
|
502
|
+
shared route destinations. When selected shared content supplies no root
|
|
503
|
+
`index.html`, the SDK generates one that opens the selected app entry.
|
|
504
|
+
Source document bases and resource URLs therefore retain their development
|
|
505
|
+
layout. Packaging does not run tests or checks automatically.
|
|
510
506
|
|
|
511
507
|
```text
|
|
512
508
|
arcane package [--app <id>] [--dry-run]
|
|
@@ -515,6 +511,9 @@ arcane package [--app <id>] [--dry-run]
|
|
|
515
511
|
### Result
|
|
516
512
|
|
|
517
513
|
The result includes the release root, manifest, and complete selected inventory.
|
|
514
|
+
`ARCANE_APP_RELEASE.json` keeps the authored app-relative `app.entry` and records
|
|
515
|
+
the package launch URL in `app.start`, such as `./apps/hello-world/index.html`.
|
|
516
|
+
The file inventory includes that app tree and the root `index.html`.
|
|
518
517
|
`--dry-run` plans the package without refreshing source, running tests, or
|
|
519
518
|
replacing output.
|
|
520
519
|
|
|
@@ -672,6 +671,8 @@ npm exec -- arcane build \
|
|
|
672
671
|
|
|
673
672
|
For `--target browser`, starts the existing current `dist/<app>` release; it
|
|
674
673
|
does not package, rebuild, test, check, or verify that release automatically.
|
|
674
|
+
It opens the release manifest's `app.start` URL. Older flat releases without
|
|
675
|
+
that field continue to open their `app.entry` path.
|
|
675
676
|
The preview always uses HTTPS with the workspace certificate pair. Supply
|
|
676
677
|
`--cert <file> --key <file>` together to use another pair; see
|
|
677
678
|
[development HTTPS setup](#development-https-setup).
|
package/docs/reference/pwa.md
CHANGED
|
@@ -39,13 +39,20 @@ display preference, routes and descriptions. Use real app icons; the SDK does
|
|
|
39
39
|
not invent branding or claim that a browser has installed the app.
|
|
40
40
|
|
|
41
41
|
Manifest URL fields are relative to the application directory. Source delivery
|
|
42
|
-
and packaged delivery
|
|
43
|
-
|
|
42
|
+
and packaged delivery retain the app tree at `apps/<id>/`. For packaged output,
|
|
43
|
+
the default `start_url` is `./apps/<id>/<entry>`, resolved from the generated
|
|
44
|
+
root manifest. The default `id` and `scope` remain `./`, preserving the existing
|
|
45
|
+
deployment-root installation identity. Authored relative URL fields, including
|
|
46
|
+
explicit `id` and `scope` values, resolve against `./apps/<id>/`; an icon such
|
|
47
|
+
as `img/library.png` therefore remains beneath the app directory. Absolute URL
|
|
48
|
+
fields retain their authored destination.
|
|
44
49
|
|
|
45
50
|
`offline.include` and `offline.exclude` select literal paths or directory
|
|
46
51
|
prefixes from the selected emitted inventory. An omitted or empty include list
|
|
47
52
|
selects that inventory; exclusions subtract from it. App files use app-relative
|
|
48
53
|
paths and shared runtime files use paths such as `arcane/sdk/pwa.mjs`.
|
|
54
|
+
For example, selecting `modules` matches packaged
|
|
55
|
+
`apps/<id>/modules/...`; emitted offline URLs keep the `apps/<id>/` prefix.
|
|
49
56
|
The application entry and generated PWA shell records are retained. Select the
|
|
50
57
|
resources needed by every offline page, including its shared modules and styles.
|
|
51
58
|
The worker script itself is never an application cache entry.
|
|
@@ -67,6 +74,13 @@ Browser packaging emits these files at the selected deployment root:
|
|
|
67
74
|
| `arcane-sw.js` | Stable worker URL with the selected offline manifest embedded in its source. |
|
|
68
75
|
| `arcane-pwa.mjs` | Independent registration and installation-component bootstrap importing the SDK client. |
|
|
69
76
|
|
|
77
|
+
The selected app files remain under `apps/<id>/`, with shared runtime routes
|
|
78
|
+
alongside them. The SDK supplies a root `index.html` launcher when selected
|
|
79
|
+
shared content has no root page. The generated PWA files stay at the deployment
|
|
80
|
+
root so their worker can serve the selected app and shared resources. The
|
|
81
|
+
worker is registered for the deployment root independently of any app-authored
|
|
82
|
+
manifest scope.
|
|
83
|
+
|
|
70
84
|
Each packaged output gets one deployment revision shared by its offline
|
|
71
85
|
manifest and worker. It distinguishes separately generated outputs even when
|
|
72
86
|
their app and SDK versions match. It is not a content measurement.
|
|
@@ -719,6 +719,12 @@ matching `meta[name="arcane-app-id"]`; unmarked pages with an active `base`
|
|
|
719
719
|
remain selected for patch compatibility. Included HTML with neither signal is
|
|
720
720
|
retained as a package fragment rather than rewritten as a document.
|
|
721
721
|
|
|
722
|
+
`entry` and each app browser document's `path` stay relative to the app
|
|
723
|
+
directory. Each browser document also reports `packagePath`, the emitted path
|
|
724
|
+
such as `apps/hello-world/index.html`. The complete `files` inventory uses
|
|
725
|
+
package-relative paths and includes the root `index.html`. Shared
|
|
726
|
+
files retain their configured route destinations.
|
|
727
|
+
|
|
722
728
|
### Availability and normalization
|
|
723
729
|
|
|
724
730
|
**Node.** Normalized SDK validation with complete canonical archive and release content. Deep protocol: [SDK packager and deterministic bundle contract](protocols.md).
|
|
@@ -772,27 +778,22 @@ when explicitly requested or when required for this selected release output.
|
|
|
772
778
|
async packageApp(options)
|
|
773
779
|
```
|
|
774
780
|
|
|
775
|
-
Import it from `arcane-os` or `arcane-os/packager`. Packaging
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
`ARCANE_RUNTIME_PROJECTION.json` inventory:
|
|
782
|
-
|
|
783
|
-
```javascript
|
|
784
|
-
{
|
|
785
|
-
schemaVersion: 1,
|
|
786
|
-
kind: 'arcane-app-runtime-projection',
|
|
787
|
-
sdkVersion: '0.5.18',
|
|
788
|
-
pathPrefix: 'arcane/',
|
|
789
|
-
files: [{path}]
|
|
790
|
-
}
|
|
791
|
-
```
|
|
781
|
+
Import it from `arcane-os` or `arcane-os/packager`. Packaging consumes the saved
|
|
782
|
+
source and managed import maps. Refresh maps through `arcane import-map` or
|
|
783
|
+
ordinary `arcane dev` startup before selecting output that needs updated maps.
|
|
784
|
+
The package preserves the complete selected content, applying the documented
|
|
785
|
+
asset-version and enabled browser-PWA transformations to resource references.
|
|
786
|
+
Malformed configuration or descriptors fail while preserving the prior output.
|
|
792
787
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
`
|
|
788
|
+
Selected app files are emitted beneath `apps/<id>/`; shared files retain their
|
|
789
|
+
configured route destinations. When selected shared content supplies no root
|
|
790
|
+
`index.html`, the SDK generates one that opens the selected app page. The result
|
|
791
|
+
contains `outputRoot`, `manifest`, and the complete `files` inventory.
|
|
792
|
+
`manifest.app.entry` stays app-relative, while `manifest.app.start`
|
|
793
|
+
is the package launch URL, such as `./apps/hello-world/index.html`. Release
|
|
794
|
+
schema `1`, kind `arcane-app-release`, and packager identity
|
|
795
|
+
`arcane-app-packager-v1` remain unchanged. A dry run returns the planned output
|
|
796
|
+
and file inventory without writing source or output.
|
|
796
797
|
|
|
797
798
|
### Availability and normalization
|
|
798
799
|
|
|
@@ -808,7 +809,7 @@ const packaged = await packageApp({
|
|
|
808
809
|
appId: 'hello-world'
|
|
809
810
|
});
|
|
810
811
|
|
|
811
|
-
console.log(packaged.
|
|
812
|
+
console.log(packaged.manifest.app.start, packaged.files);
|
|
812
813
|
```
|
|
813
814
|
|
|
814
815
|
## PACKAGER_VERSION
|
|
@@ -4038,17 +4039,19 @@ console.log(result.importMap.documentPaths, result.importMap.documentCount);
|
|
|
4038
4039
|
### Overview
|
|
4039
4040
|
|
|
4040
4041
|
Runs the high-level package operation for one selected application. It reads
|
|
4041
|
-
the installed SDK/runtime selection
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4042
|
+
the installed SDK/runtime selection and packages the saved source and managed
|
|
4043
|
+
import maps through `packageApp()`. Map generation remains the explicit
|
|
4044
|
+
`arcane import-map` operation and the ordinary `arcane dev` startup refresh.
|
|
4045
|
+
Selected app files retain their `apps/<id>/` paths alongside the shared routes
|
|
4046
|
+
and root launcher described by `packageApp()`.
|
|
4047
|
+
|
|
4048
|
+
Packaging does not automatically run tests or checks. Verification occurs only
|
|
4049
|
+
when explicitly requested or when required for the selected release output.
|
|
4050
|
+
A failure leaves the prior distribution untouched. Success returns the selected
|
|
4051
|
+
workspace and app identity plus `release`, containing the low-level package
|
|
4052
|
+
result, manifest, and complete file inventory. `ARCANE_APP_RELEASE.json` records
|
|
4053
|
+
that inventory and the distinct app-relative `app.entry` and package-relative
|
|
4054
|
+
`app.start`; it remains package metadata rather than an application route.
|
|
4052
4055
|
|
|
4053
4056
|
### Signature and result
|
|
4054
4057
|
|
|
@@ -4072,7 +4075,7 @@ const result = await packageApplication({
|
|
|
4072
4075
|
appId: 'hello-world'
|
|
4073
4076
|
});
|
|
4074
4077
|
|
|
4075
|
-
console.log(result.release.
|
|
4078
|
+
console.log(result.release.manifest.app.start, result.release.files);
|
|
4076
4079
|
```
|
|
4077
4080
|
|
|
4078
4081
|
## planApplication()
|
package/package.json
CHANGED
package/src/dev-server.mjs
CHANGED
|
@@ -516,15 +516,19 @@ async function packagedRoutes(releaseRoot){
|
|
|
516
516
|
const canonical=await canonicalRealDirectory(requested,'Packaged release root');
|
|
517
517
|
let pwa = false;
|
|
518
518
|
let startPath = '/index.html';
|
|
519
|
+
try {
|
|
520
|
+
const release = JSON.parse(
|
|
521
|
+
await readFile(path.join(canonical, 'ARCANE_APP_RELEASE.json'), 'utf8')
|
|
522
|
+
);
|
|
523
|
+
const start = release.app.start ?? release.app.entry;
|
|
524
|
+
const startUrl = new URL(start, 'http://arcane.invalid/');
|
|
525
|
+
startPath = `${startUrl.pathname}${startUrl.search}${startUrl.hash}`;
|
|
526
|
+
} catch (error) {
|
|
527
|
+
if (error.code !== 'ENOENT') throw error;
|
|
528
|
+
}
|
|
519
529
|
try {
|
|
520
530
|
const manifest = JSON.parse(await readFile(path.join(canonical, 'arcane-offline.json'), 'utf8'));
|
|
521
531
|
pwa = manifest.schemaVersion === 1;
|
|
522
|
-
if (pwa) {
|
|
523
|
-
const release = JSON.parse(
|
|
524
|
-
await readFile(path.join(canonical, 'ARCANE_APP_RELEASE.json'), 'utf8')
|
|
525
|
-
);
|
|
526
|
-
startPath = `/${release.app.entry}`;
|
|
527
|
-
}
|
|
528
532
|
} catch (error) {
|
|
529
533
|
if (error.code !== 'ENOENT') throw error;
|
|
530
534
|
}
|
package/src/packager/core.mjs
CHANGED
|
@@ -424,6 +424,15 @@ function destinationJoin(root,relative){
|
|
|
424
424
|
return root==='.'?relative:`${root}/${relative}`;
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
+
function appPackagePath(context, relative) {
|
|
428
|
+
return `apps/${context.appId}/${relative}`;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function packageResourceUrl(relative) {
|
|
432
|
+
const segments = relative.split('/');
|
|
433
|
+
return `./${segments.map(encodeURIComponent).join('/')}`;
|
|
434
|
+
}
|
|
435
|
+
|
|
427
436
|
async function collectSelectedPath({
|
|
428
437
|
sourceRoot,
|
|
429
438
|
selected,
|
|
@@ -483,7 +492,7 @@ async function collectPackageRecords(context,{signal}={}){
|
|
|
483
492
|
await collectSelectedPath({
|
|
484
493
|
sourceRoot:context.appRoot,
|
|
485
494
|
selected,
|
|
486
|
-
destination:selected,
|
|
495
|
+
destination:appPackagePath(context, selected),
|
|
487
496
|
excludes:context.config.exclude,
|
|
488
497
|
reject:isAppSourceForbidden,
|
|
489
498
|
records,
|
|
@@ -512,23 +521,25 @@ async function collectPackageRecords(context,{signal}={}){
|
|
|
512
521
|
}
|
|
513
522
|
}
|
|
514
523
|
records.sort((left,right)=>compareText(left.destination,right.destination));
|
|
515
|
-
if(!records.some(record=>pathKey(record.destination)===pathKey(context.config.entry))){
|
|
524
|
+
if(!records.some(record=>pathKey(record.destination)===pathKey(appPackagePath(context, context.config.entry)))){
|
|
516
525
|
fail(`Package entry is missing from the selected files: ${context.config.entry}.`);
|
|
517
526
|
}
|
|
518
527
|
return records;
|
|
519
528
|
}
|
|
520
529
|
|
|
521
|
-
async function browserDocuments(records,entry){
|
|
530
|
+
async function browserDocuments(records,entry,appPrefix){
|
|
522
531
|
let entryDocument=null;
|
|
523
532
|
const documents=[];
|
|
524
533
|
for(const record of records){
|
|
525
534
|
const extension=path.posix.extname(record.destination).toLocaleLowerCase('en-US');
|
|
526
535
|
if(extension!=='.html'&&extension!=='.htm')continue;
|
|
536
|
+
const documentPath=record.destination.startsWith(appPrefix)
|
|
537
|
+
?record.destination.slice(appPrefix.length):record.destination;
|
|
527
538
|
const inspected=inspectImportMapHtml(await readFile(record.source,'utf8'),{
|
|
528
|
-
documentPath
|
|
539
|
+
documentPath
|
|
529
540
|
});
|
|
530
|
-
const document={path:record.destination,...copyJson(inspected)};
|
|
531
|
-
if(record.destination
|
|
541
|
+
const document={path:documentPath,packagePath:record.destination,...copyJson(inspected)};
|
|
542
|
+
if(record.destination===`${appPrefix}${entry}`){
|
|
532
543
|
entryDocument=document;
|
|
533
544
|
}else if(inspected.bases.length>0){
|
|
534
545
|
documents.push(document);
|
|
@@ -567,8 +578,8 @@ async function inspectContext(context,{signal}={}){
|
|
|
567
578
|
}),
|
|
568
579
|
...(context.config.adapter===undefined?{}:{adapter:context.config.adapter}),
|
|
569
580
|
descriptor:await optionalDescriptor(context),
|
|
570
|
-
browserDocuments:await browserDocuments(records,context.config.entry),
|
|
571
|
-
files:records.map(record=>record.destination),
|
|
581
|
+
browserDocuments:await browserDocuments(records,context.config.entry,appPackagePath(context,'')),
|
|
582
|
+
files:[...new Set(['index.html',...records.map(record=>record.destination)])].sort(compareText),
|
|
572
583
|
output:path.relative(context.workspaceRoot,context.outputRoot).split(path.sep).join('/')
|
|
573
584
|
};
|
|
574
585
|
}
|
|
@@ -611,6 +622,28 @@ async function copyRecords(records,stagingRoot,{signal,onEvent}={}){
|
|
|
611
622
|
}
|
|
612
623
|
}
|
|
613
624
|
|
|
625
|
+
async function writePackageLauncher(context, stagingRoot) {
|
|
626
|
+
function escapeHtml(value) {
|
|
627
|
+
return value.replaceAll('&', '&').replaceAll('"', '"')
|
|
628
|
+
.replaceAll('<', '<').replaceAll('>', '>');
|
|
629
|
+
}
|
|
630
|
+
const start = escapeHtml(packageResourceUrl(appPackagePath(context, context.config.entry)));
|
|
631
|
+
const title = escapeHtml(context.config.displayName);
|
|
632
|
+
const content = `<!doctype html>
|
|
633
|
+
<html lang="en">
|
|
634
|
+
<head>
|
|
635
|
+
<meta charset="utf-8">
|
|
636
|
+
<meta http-equiv="refresh" content="0; url=${start}">
|
|
637
|
+
<title>${title}</title>
|
|
638
|
+
</head>
|
|
639
|
+
<body>
|
|
640
|
+
<a href="${start}">Open ${title}</a>
|
|
641
|
+
</body>
|
|
642
|
+
</html>
|
|
643
|
+
`;
|
|
644
|
+
await writeFile(path.join(stagingRoot, 'index.html'), content, 'utf8');
|
|
645
|
+
}
|
|
646
|
+
|
|
614
647
|
async function listOutputFiles(root,{signal}={}){
|
|
615
648
|
const files=[];
|
|
616
649
|
async function visit(directory,relativeRoot=''){
|
|
@@ -652,6 +685,7 @@ function releaseManifest(context,files,pwaArtifacts){
|
|
|
652
685
|
displayName:context.config.displayName,
|
|
653
686
|
version:context.config.version,
|
|
654
687
|
entry:context.config.entry,
|
|
688
|
+
start:packageResourceUrl(appPackagePath(context, context.config.entry)),
|
|
655
689
|
strategy:context.config.strategy,
|
|
656
690
|
shared:[...context.config.shared],
|
|
657
691
|
...(pwaArtifacts?{pwa:{
|
|
@@ -695,6 +729,8 @@ async function replaceDirectory(stagingRoot,outputRoot){
|
|
|
695
729
|
async function packageWithContext(context,options={}){
|
|
696
730
|
const {signal,onEvent,browserPwa=true}=options;
|
|
697
731
|
const pwaEnabled=browserPwa&&context.config.pwa?.enabled===true;
|
|
732
|
+
const appPath=`apps/${context.appId}`;
|
|
733
|
+
const entryPath=appPackagePath(context,context.config.entry);
|
|
698
734
|
const inspected=await inspectContext(context,{signal});
|
|
699
735
|
if(options.dryRun){
|
|
700
736
|
return {
|
|
@@ -724,7 +760,14 @@ async function packageWithContext(context,options={}){
|
|
|
724
760
|
let promoted=false;
|
|
725
761
|
try{
|
|
726
762
|
const records=await collectPackageRecords(context,{signal});
|
|
727
|
-
|
|
763
|
+
async function copyBase() {
|
|
764
|
+
await copyRecords(records,stagingRoot,{signal,onEvent});
|
|
765
|
+
if (!records.some(function selectedRootIndex(record) {
|
|
766
|
+
return record.destination === 'index.html';
|
|
767
|
+
})) {
|
|
768
|
+
await writePackageLauncher(context, stagingRoot);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
728
771
|
const adapter=await loadAdapter(context);
|
|
729
772
|
if(adapter){
|
|
730
773
|
await adapter.buildArcanePackage({
|
|
@@ -745,21 +788,22 @@ async function packageWithContext(context,options={}){
|
|
|
745
788
|
const assetVersion=await readWorkspaceAssetVersion(context.workspaceRoot);
|
|
746
789
|
const version=pwaEnabled?null:assetVersion;
|
|
747
790
|
const inventory=new Set(files);
|
|
748
|
-
const offlineInventory=pwaEnabled?new Set(selectPwaFiles(files,context.config.pwa)):null;
|
|
791
|
+
const offlineInventory=pwaEnabled?new Set(selectPwaFiles(files,context.config.pwa,appPath)):null;
|
|
749
792
|
const offlineReferences=new Set();
|
|
750
|
-
const entryUrl=new URL(
|
|
793
|
+
const entryUrl=new URL(packageResourceUrl(entryPath),'http://arcane.invalid/');
|
|
751
794
|
const pwaDocumentSources=new Map();
|
|
752
795
|
if(pwaEnabled){
|
|
753
|
-
const documentPaths=new Set([
|
|
796
|
+
const documentPaths=new Set([entryPath]);
|
|
754
797
|
for(const selected of context.config.include){
|
|
755
|
-
|
|
798
|
+
const selectedPath=appPackagePath(context,selected);
|
|
799
|
+
if(/\.html?$/iu.test(selected)&&inventory.has(selectedPath))documentPaths.add(selectedPath);
|
|
756
800
|
}
|
|
757
801
|
for(const document of inspected.browserDocuments){
|
|
758
802
|
const appDocument=context.config.include.some(function includesAppDocument(selected){
|
|
759
803
|
return sameOrDescendant(document.path,selected);
|
|
760
804
|
});
|
|
761
|
-
if(appDocument&&document.managedMaps.length>0&&inventory.has(document.
|
|
762
|
-
documentPaths.add(document.
|
|
805
|
+
if(appDocument&&document.managedMaps.length>0&&inventory.has(document.packagePath)){
|
|
806
|
+
documentPaths.add(document.packagePath);
|
|
763
807
|
}
|
|
764
808
|
}
|
|
765
809
|
await Promise.all(
|
|
@@ -777,13 +821,13 @@ async function packageWithContext(context,options={}){
|
|
|
777
821
|
)
|
|
778
822
|
);
|
|
779
823
|
}
|
|
780
|
-
const entryDocument=pwaEnabled?pwaDocumentSources.get(
|
|
824
|
+
const entryDocument=pwaEnabled?pwaDocumentSources.get(entryPath).inspected
|
|
781
825
|
:inspected.browserDocuments.find(function matchingEntryDocument(document){
|
|
782
826
|
return document.path===context.config.entry;
|
|
783
827
|
});
|
|
784
828
|
const documentUrl=entryDocument?.bases[0]?.href
|
|
785
829
|
?new URL(entryDocument.bases[0].href,entryUrl):entryUrl;
|
|
786
|
-
const pending=[{file:
|
|
830
|
+
const pending=[{file:entryPath,documentUrl}];
|
|
787
831
|
for(const file of files){
|
|
788
832
|
if(/^arcane\/(?:modules|entities|components|css|sdk|dependencies)\//u.test(file)
|
|
789
833
|
&&/\.(?:m?js|html?|css)$/iu.test(file))pending.push({file,documentUrl});
|
|
@@ -792,15 +836,15 @@ async function packageWithContext(context,options={}){
|
|
|
792
836
|
}
|
|
793
837
|
}
|
|
794
838
|
for(const document of inspected.browserDocuments){
|
|
795
|
-
if(document.managedMaps.length>0&&!pwaDocumentSources.has(document.
|
|
796
|
-
const url=new URL(document.
|
|
797
|
-
pending.push({file:document.
|
|
839
|
+
if(document.managedMaps.length>0&&!pwaDocumentSources.has(document.packagePath)){
|
|
840
|
+
const url=new URL(packageResourceUrl(document.packagePath),entryUrl.origin);
|
|
841
|
+
pending.push({file:document.packagePath,documentUrl:document.bases[0]?.href
|
|
798
842
|
?new URL(document.bases[0].href,url):url});
|
|
799
843
|
}
|
|
800
844
|
}
|
|
801
845
|
for(const [file,document] of pwaDocumentSources){
|
|
802
|
-
if(file===
|
|
803
|
-
const url=new URL(file,entryUrl.origin);
|
|
846
|
+
if(file===entryPath)continue;
|
|
847
|
+
const url=new URL(packageResourceUrl(file),entryUrl.origin);
|
|
804
848
|
pending.push({file,documentUrl:document.inspected.bases[0]?.href
|
|
805
849
|
?new URL(document.inspected.bases[0].href,url):url});
|
|
806
850
|
}
|
|
@@ -832,7 +876,7 @@ async function packageWithContext(context,options={}){
|
|
|
832
876
|
if(!pwaEnabled&&!traversable)continue;
|
|
833
877
|
if(kind==='import'&&!/^(?:\.{1,2}\/|\/)/u.test(url))continue;
|
|
834
878
|
try{
|
|
835
|
-
const ownerUrl=new URL(relative,entryUrl.origin);
|
|
879
|
+
const ownerUrl=new URL(packageResourceUrl(relative),entryUrl.origin);
|
|
836
880
|
const base=baseHref?new URL(baseHref,ownerUrl)
|
|
837
881
|
:baseKind==='document'||path.posix.basename(relative)==='arcane.importmap.json'
|
|
838
882
|
?current.documentUrl:ownerUrl;
|
|
@@ -854,7 +898,7 @@ async function packageWithContext(context,options={}){
|
|
|
854
898
|
if(files.some(file=>pathKey(file)===pathKey(RELEASE_MANIFEST_NAME))){
|
|
855
899
|
fail(`Package content must not author ${RELEASE_MANIFEST_NAME}.`);
|
|
856
900
|
}
|
|
857
|
-
if(!files.some(file=>pathKey(file)===pathKey(
|
|
901
|
+
if(!files.some(file=>pathKey(file)===pathKey(entryPath))){
|
|
858
902
|
fail(`Package output is missing its entry file: ${context.config.entry}.`);
|
|
859
903
|
}
|
|
860
904
|
const pwaArtifacts=pwaEnabled?createPwaArtifacts({
|
|
@@ -862,8 +906,9 @@ async function packageWithContext(context,options={}){
|
|
|
862
906
|
id:context.appId,
|
|
863
907
|
displayName:context.config.displayName,
|
|
864
908
|
version:context.config.version,
|
|
865
|
-
entry:
|
|
909
|
+
entry:packageResourceUrl(entryPath)
|
|
866
910
|
},
|
|
911
|
+
appPath,
|
|
867
912
|
sdkVersion:assetVersion,
|
|
868
913
|
pwa:context.config.pwa,
|
|
869
914
|
files,
|
|
@@ -878,7 +923,7 @@ async function packageWithContext(context,options={}){
|
|
|
878
923
|
files.push(artifact.path);
|
|
879
924
|
}
|
|
880
925
|
for(const [documentPath,document] of pwaDocumentSources){
|
|
881
|
-
const documentUrl=new URL(documentPath,entryUrl.origin);
|
|
926
|
+
const documentUrl=new URL(packageResourceUrl(documentPath),entryUrl.origin);
|
|
882
927
|
const outputBase=document.inspected.bases[0]?.href
|
|
883
928
|
?new URL(document.inspected.bases[0].href,documentUrl):documentUrl;
|
|
884
929
|
const outputDirectory=new URL('./',outputBase).pathname;
|
package/src/pwa.mjs
CHANGED
|
@@ -72,17 +72,20 @@ function selectedPath(file, selection) {
|
|
|
72
72
|
return file === selection || file.startsWith(prefix);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export function selectPwaFiles(files, pwa) {
|
|
75
|
+
export function selectPwaFiles(files, pwa, appPath = '') {
|
|
76
76
|
const config = normalizePwaConfig(pwa);
|
|
77
77
|
const include = config?.offline.include ?? [];
|
|
78
78
|
const exclude = config?.offline.exclude ?? [];
|
|
79
|
+
const appPrefix = appPath ? `${appPath}/` : '';
|
|
79
80
|
return files.filter(
|
|
80
81
|
function selectedOfflineFile(file) {
|
|
82
|
+
const relative = appPrefix && file.startsWith(appPrefix)
|
|
83
|
+
? file.slice(appPrefix.length) : file;
|
|
81
84
|
function includedPath(selection) {
|
|
82
|
-
return selectedPath(
|
|
85
|
+
return selectedPath(relative, selection);
|
|
83
86
|
}
|
|
84
87
|
function excludedPath(selection) {
|
|
85
|
-
return selectedPath(
|
|
88
|
+
return selectedPath(relative, selection);
|
|
86
89
|
}
|
|
87
90
|
return (include.length === 0 || include.some(includedPath))
|
|
88
91
|
&& !exclude.some(excludedPath);
|
|
@@ -199,6 +202,7 @@ export function createPwaArtifacts(
|
|
|
199
202
|
mode = 'release',
|
|
200
203
|
runtimeBase = './arcane/sdk/',
|
|
201
204
|
appBase,
|
|
205
|
+
appPath = '',
|
|
202
206
|
navigationAliases,
|
|
203
207
|
revision
|
|
204
208
|
} = {}
|
|
@@ -209,20 +213,19 @@ export function createPwaArtifacts(
|
|
|
209
213
|
throw new TypeError('PWA mode must be release or development.');
|
|
210
214
|
}
|
|
211
215
|
const entryUrl = new URL(app.entry, 'https://arcane.invalid/');
|
|
212
|
-
const applicationBase = appBase ?? (
|
|
213
|
-
? new URL('./', entryUrl).pathname : './');
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
);
|
|
216
|
+
const applicationBase = appBase ?? (appPath ? `./${appPath}/`
|
|
217
|
+
: mode === 'development' ? new URL('./', entryUrl).pathname : './');
|
|
218
|
+
// Relocating app files must not change an existing installed app's default identity.
|
|
219
|
+
const installationBase = appBase ?? (mode === 'development' ? applicationBase : './');
|
|
220
|
+
const manifest = {
|
|
221
|
+
id: installationBase,
|
|
222
|
+
name: app.displayName,
|
|
223
|
+
short_name: app.displayName,
|
|
224
|
+
start_url: manifestUrl(app.entry, appPath ? basePath : applicationBase),
|
|
225
|
+
scope: installationBase,
|
|
226
|
+
display: 'standalone',
|
|
227
|
+
...applicationManifest(config.manifest, applicationBase)
|
|
228
|
+
};
|
|
226
229
|
const generatedAssets = [
|
|
227
230
|
PWA_MANIFEST_NAME,
|
|
228
231
|
PWA_OFFLINE_MANIFEST_NAME,
|
|
@@ -232,7 +235,7 @@ export function createPwaArtifacts(
|
|
|
232
235
|
return resourceUrl(basePath, file);
|
|
233
236
|
}
|
|
234
237
|
);
|
|
235
|
-
const selectedFiles = selectPwaFiles(files, config);
|
|
238
|
+
const selectedFiles = selectPwaFiles(files, config, appPath);
|
|
236
239
|
const selectedAssets = [
|
|
237
240
|
...selectedFiles.map(
|
|
238
241
|
function packagedResource(file) {
|