arcane-os 0.51.2 → 0.52.1

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/src/toolchain.mjs CHANGED
@@ -299,6 +299,7 @@ async function refreshPreparedImportMap(prepared,{signal,onEvent,workspaceOperat
299
299
  signal
300
300
  });
301
301
  if(inspected.entry!==manifest.entry
302
+ ||JSON.stringify(inspected.documents)!==JSON.stringify(manifest.documents)
302
303
  ||JSON.stringify(inspected.include)!==JSON.stringify(manifest.include)
303
304
  ||JSON.stringify(inspected.exclude)!==JSON.stringify(manifest.exclude)){
304
305
  throw new ArcaneError(
@@ -329,24 +330,41 @@ async function refreshRootApplicationFiles(prepared,inspected,importMap,{signal,
329
330
  const manifest=prepared.validation.app.manifest;
330
331
  const installed=await readInstalledSdkLayout(workspaceRoot,prepared.validation.config);
331
332
  const entry=`/${manifest.entry.split('/').map(encodeURIComponent).join('/')}`;
332
- const navigationAliases={
333
- '/':entry
334
- };
333
+ const pwaEnabled = installed?.direct && manifest.pwa?.enabled;
334
+ let authoredRoot = false;
335
+ if (pwaEnabled) {
336
+ try {
337
+ authoredRoot = (await lstat(path.join(workspaceRoot, 'index.html'))).isFile();
338
+ } catch (error) {
339
+ if (error.code !== 'ENOENT') throw error;
340
+ }
341
+ }
342
+ // A host homepage need not belong to the selected application or its cache.
343
+ const navigationAliases = authoredRoot ? {} : {'/': entry};
344
+ function rootIndexPath(relative) {
345
+ return (process.platform === 'win32' ? relative.toLowerCase() : relative) === 'index.html';
346
+ }
347
+ const selectedRootIndex = authoredRoot && manifest.include.some(rootIndexPath)
348
+ && !manifest.exclude.some(rootIndexPath);
335
349
  // The source host serves the installed files in place. There is no runtime projection.
336
350
  const files=[...new Set([
337
- ...inspected.files.filter(file=>file!=='index.html'||manifest.include.includes('index.html')),
351
+ ...inspected.files.filter(
352
+ function selectedSourceFile(file) {
353
+ return file !== 'index.html' || selectedRootIndex;
354
+ }
355
+ ),
338
356
  importMap.artifactRelativePath
339
357
  ])];
340
358
  const sourceOrigin='http://arcane.invalid';
341
359
  const selectedPaths=new Set(files.map(function selectedStaticPath(file){
342
360
  return new URL(`/${file.split('/').map(encodeURIComponent).join('/')}`,sourceOrigin).pathname;
343
361
  }));
344
- const assets=installed?.direct&&manifest.pwa?.enabled
362
+ const assets=pwaEnabled
345
363
  ?(await collectSourcePwaAssets({workspaceRoot,appId,signal,onEvent})).filter(function selectedStaticVariant(value){
346
364
  const url=new URL(value,sourceOrigin);
347
365
  return url.origin===sourceOrigin&&selectedPaths.has(url.pathname);
348
366
  }):[];
349
- const pwa=installed?.direct&&manifest.pwa?.enabled?createPwaArtifacts({
367
+ const pwa=pwaEnabled?createPwaArtifacts({
350
368
  app:{id:appId,displayName:manifest.displayName,version:manifest.version,entry},
351
369
  sdkVersion:installed.version,
352
370
  pwa:manifest.pwa,