@synopackageland/cli 0.54.3 → 0.54.4

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.54.4 (2026-11-15)
4
+
5
+ - SDK-window Apps with `ui.launch: new-page` open the SDK entry page from DSM's main menu and Package Center: `ui/config` registers `SYNO.SDS.<pkg>.Instance` as a `type: "url"` launcher at `/webman/3rdparty/<pkg>/app/entry.html`, keeping `defaultAlias`, the sign-in style and Application Privileges, so the App no longer waits for DSM's desktop to boot. Console, compose and identity-gateway Apps keep their launchers. Every such App gets an entry page, not only `mobile.entry: app`.
6
+ - `entry.html` is the same bytes in every build: it reads `entry.json` (no-store) and loads that build's module, stylesheet and icon, so a bookmark never stays on an old build behind DSM's size-only ETag. `inspect` replays the page, the pointer and every digest (`ENTRY_PAGE_INVALID`) and checks the url launcher.
7
+ - `ui.short_paths` may point at `app` (a 302 to the entry page); the first such path becomes the SDK's `shortPath` for `ctx.entryURL`.
8
+ - When the manifest declares `daemon.backend` and `daemon.ingress` (not compose), the entry page reads `app.status` through that ingress instead of the App CGI.
9
+ - The build bundles the project's `@synopackageland/sdk/entry`, which must be 0.53.45 or later (`MOBILE_SDK_ENTRY_MISSING`, `ENTRY_SDK_OUTDATED`). `init` uses templates 0.44.1, whose projects list the SDK.
10
+
3
11
  ## 0.54.3 (2026-11-15)
4
12
 
5
13
  - `init` uses templates 0.44.0: Vue Apps start with a default data layer in `frontend/src/data/` (an in-memory `@tanstack/query-core` cache per window, keyed by user; cached answers show at once and are read again behind them) and a dev-only mock at `/?mock=1` with `latency=` and `trace=1` (`window.__calls`), so the frontend runs without a NAS. The `ui-vue` skill reference points at both.
@@ -4,7 +4,9 @@ export const ERROR_REGISTRY = {
4
4
  ...COMPOSE_ERRORS,
5
5
  INSTALLED_INFO_TOO_LARGE: { code: 'INSTALLED_INFO_TOO_LARGE', description: 'The installed INFO, with the base64 icon lines DSM adds at install, would exceed the 65536 bytes the SDK executor reads', suggestion: 'Recompress the icon PNG with fewer colours and less detail (posterize or quantize it); the 256 px icon typically needs to be under about 40 KB' },
6
6
  STANDALONE_MOBILE_INVALID: { code: 'STANDALONE_MOBILE_INVALID', description: 'The mobile declaration or its UI/gateway dependency is invalid', suggestion: 'Check mobile against the manifest schema and read the mobile skill' },
7
- MOBILE_SDK_ENTRY_MISSING: { code: 'MOBILE_SDK_ENTRY_MISSING', description: 'The installed frontend SDK has no entry export', suggestion: 'Install an SDK with /entry in the UI build directory or project root' },
7
+ MOBILE_SDK_ENTRY_MISSING: { code: 'MOBILE_SDK_ENTRY_MISSING', description: 'The App entry page (ui.launch: new-page or mobile.entry: app) needs the frontend SDK, which has no entry export here', suggestion: 'Install @synopackageland/sdk with /entry in the UI build directory or project root' },
8
+ ENTRY_SDK_OUTDATED: { code: 'ENTRY_SDK_OUTDATED', description: 'ui.launch: new-page opens the SDK entry page, and the installed frontend SDK predates 0.53.45 (ctx.entryURL)', suggestion: 'Update @synopackageland/sdk to 0.53.45 or later in the UI build directory or project root' },
9
+ ENTRY_PAGE_INVALID: { code: 'ENTRY_PAGE_INVALID', description: 'The packaged entry page, its entry.json or a recorded entry file differs from the build record', suggestion: 'Rebuild the SPK with synopkgland build and inspect it again' },
8
10
  UI_STABLE_PAGE_INVALID: { code: 'UI_STABLE_PAGE_INVALID', description: 'A packaged stable page differs from its build record', suggestion: 'Rebuild the SPK and inspect it again' },
9
11
  SHORT_PATHS_INVALID: { code: 'SHORT_PATHS_INVALID', description: 'Packaged short-path redirects, their INFO reload or their ownership check differ from the build record', suggestion: 'Rebuild the SPK with synopkgland build and inspect it again' },
10
12
  MOBILE_INVALID: { code: 'MOBILE_INVALID', description: 'Packaged mobile assets differ from their build declaration', suggestion: 'Rebuild the SPK and inspect it again' },
package/dist/init.js CHANGED
@@ -540,10 +540,19 @@ function useLocalSdk(targetDir, sdkDir) {
540
540
  }
541
541
  writeFileSync(goMod, `${text}\nreplace ${SDK_MODULE} => ${sdkDir}\n`);
542
542
  }
543
+ const local = `file:${join(sdkDir, "ts")}`;
544
+ // A plain UI's entry page bundles the SDK named in the project's own package.json.
545
+ const rootPackage = join(targetDir, "package.json");
546
+ if (existsSync(rootPackage)) {
547
+ const pkg = JSON.parse(readFileSync(rootPackage, "utf8"));
548
+ for (const field of ["dependencies", "devDependencies"])
549
+ if (pkg[field]?.[SDK_PACKAGE])
550
+ pkg[field][SDK_PACKAGE] = local;
551
+ writeFileSync(rootPackage, JSON.stringify(pkg, null, 2) + "\n");
552
+ }
543
553
  const frontend = join(targetDir, "frontend/package.json");
544
554
  if (!existsSync(frontend))
545
555
  return;
546
- const local = `file:${join(sdkDir, "ts")}`;
547
556
  const pkg = JSON.parse(readFileSync(frontend, "utf8"));
548
557
  pkg.dependencies[SDK_PACKAGE] = local;
549
558
  writeFileSync(frontend, JSON.stringify(pkg, null, 2) + "\n");
@@ -1,6 +1,7 @@
1
1
  import { renderExecutorApproval } from './executor-approval.js';
2
2
  import { CALL_RETRY_RUNTIME } from './call-retry.js';
3
3
  import { oidcResumeRuntime } from "./oidc-resume.js";
4
+ import { entryLauncher, entryPagePath, entryShortPath, hasEntryPage } from "./entry-page.js";
4
5
  import { gatewayIngressOnly } from './gateway-ingress-only.js';
5
6
  import { gatewayEntryPath } from './native-gateway.js';
6
7
  import { resolvedSdkLaunch, dsmLauncherType } from "../contract/app-launch.js";
@@ -187,6 +188,35 @@ export function renderUiConfig(manifest, icons = packageIcons(manifest.icon), lo
187
188
  },
188
189
  }, null, 2)}\n`;
189
190
  }
191
+ if (entryLauncher(manifest)) {
192
+ // Main menu and Package Center open the SDK entry page in a new tab; DSM
193
+ // redirects an alias or a launch link to it (DSM 7.3: same tab, without
194
+ // the query, launchParam per character). The window script keeps its
195
+ // MainWindow class.
196
+ return `${JSON.stringify({
197
+ ".url": {
198
+ [`${ns}.Instance`]: {
199
+ type: "url",
200
+ ...(manifest.portal ? { defaultAlias: manifest.portal.alias } : {}),
201
+ ...titleFields,
202
+ icon,
203
+ url: entryPagePath(manifest.package),
204
+ ...launcherAccess(manifest),
205
+ ...(loginStyle ? { loginIcon: icon, loginStyle } : {}),
206
+ },
207
+ },
208
+ [windowScriptName(manifest)]: {
209
+ [`${ns}.MainWindow`]: {
210
+ type: "lib",
211
+ title: titleFields.title,
212
+ texts: titleFields.texts,
213
+ ...(manifest.i18n?.nativeTexts ? { preloadTexts: titleFields.preloadTexts } : {}),
214
+ icon,
215
+ depend: [],
216
+ },
217
+ },
218
+ }, null, 2)}\n`;
219
+ }
190
220
  return `${JSON.stringify({
191
221
  [windowScriptName(manifest)]: {
192
222
  [`${ns}.Instance`]: {
@@ -380,7 +410,7 @@ ${root ? root.definitions : ""}${manifest.portal ? renderPortalDefinition(ns, po
380
410
  // registered. Reuse it only when this build loaded it; an older loader records
381
411
  // no build, so its app is replaced as well.
382
412
  ${ns}.loadApp = function (done) {
383
- ${manifest.mobile?.entry === 'app' ? ` var deliver = done;
413
+ ${hasEntryPage(manifest) ? ` var deliver = done;
384
414
  done = function (app, error) {
385
415
  if (!app || error) { deliver(app, error); return; }
386
416
  import(new URL("webman/3rdparty/${pkg}/app/entry-context.js?v=${assetVersion}", document.baseURI).href).then(function (entry) {
@@ -391,7 +421,8 @@ ${manifest.mobile?.entry === 'app' ? ` var deliver = done;
391
421
  options.session = ${ns}.session;
392
422
  options.token = SYNO.SDS.Session && SYNO.SDS.Session.SynoToken;
393
423
  options.portalAccess = ctx.portal;
394
- delete options.portal;
424
+ ${entryShortPath(manifest) ? ` options.shortPath = ${JSON.stringify(entryShortPath(manifest))};
425
+ ` : ""} delete options.portal;
395
426
  delete options.uiUpdate;
396
427
  var shared = entry.createAppContext(options);
397
428
  try {
@@ -0,0 +1,44 @@
1
+ import type { StandaloneManifest } from "./manifest.js";
2
+ /**
3
+ * The SDK entry page: `ui/app/entry.html`, served by DSM at
4
+ * `/webman/3rdparty/<package>/app/entry.html` without DSM's desktop.
5
+ *
6
+ * DSM serves package files with no Cache-Control, Last-Modified 1970 and an
7
+ * ETag of the size alone, so a browser may keep a bookmarked page for years
8
+ * and a revalidation keeps any older copy of the same size. The page is
9
+ * therefore fixed bytes, the same in every build and package: it reads the
10
+ * current build from `entry.json` with a no-store, cache-busted request and
11
+ * loads that build's `?v=` stamped module, stylesheet and icon.
12
+ */
13
+ export declare const ENTRY_PAGE_FILE = "entry.html";
14
+ export declare const ENTRY_POINTER_FILE = "entry.json";
15
+ export declare function entryPagePath(pkg: string): string;
16
+ /** The ui.short_paths target that names the entry page instead of a stable page. */
17
+ export declare const ENTRY_SHORT_PATH_TARGET = "app";
18
+ type LauncherManifest = Pick<StandaloneManifest, "compose" | "sdkWindow" | "console" | "identityGateway" | "ui">;
19
+ /**
20
+ * Main menu and Package Center open the entry page with a DSM url launcher:
21
+ * every native SDK window App that opens a full page (ui.launch: new-page).
22
+ * Not with a console (its Instance is the gateway's launcher) or an identity
23
+ * gateway (its DSM window resumes a cold OIDC sign-in from the launch).
24
+ */
25
+ export declare function entryLauncher(manifest: LauncherManifest): boolean;
26
+ /** Whether the build writes the entry page: the launcher's, or a mobile App entry's. */
27
+ export declare function hasEntryPage(manifest: LauncherManifest & Pick<StandaloneManifest, "mobile">): boolean;
28
+ /** The first short path (in path order) that opens the entry page; ctx.entryURL uses it. */
29
+ export declare function entryShortPath(manifest: Pick<StandaloneManifest, "ui">): string | undefined;
30
+ /** Fixed bytes: a cached copy from any build or package keeps working, since it reads entry.json. */
31
+ export declare const ENTRY_PAGE_STUB = "<!doctype html>\n<html><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, viewport-fit=cover\"><meta name=\"referrer\" content=\"same-origin\"><title></title><style>html,body,.dsmapp-root{margin:0;height:100%;min-height:100%}</style></head>\n<body><div class=\"dsmapp-root\"></div><noscript>This page needs JavaScript.</noscript><script>\n(function () {\n var asset = /^\\.\\/(?:[\\w~-][\\w.~-]*\\/)*[\\w~-][\\w.~-]*\\?v=[0-9a-f]{64}$/;\n function fail() { document.body.textContent = \"This page is not available. Reload to try again.\"; }\n function add(parent, tag, attrs) { var node = document.createElement(tag); for (var key in attrs) node[key] = attrs[key]; parent.appendChild(node); return node; }\n try {\n fetch(\"entry.json?t=\" + Date.now(), {cache: \"no-store\", credentials: \"same-origin\", redirect: \"error\"})\n .then(function (r) { if (!r.ok) throw 0; return r.json(); })\n .then(function (p) {\n if (!p || p.v !== 1 || typeof p.title !== \"string\" || !asset.test(p.script) || !asset.test(p.css) || !asset.test(p.icon)) throw 0;\n document.title = p.title;\n add(document.head, \"link\", {rel: \"icon\", href: p.icon});\n add(document.head, \"link\", {rel: \"stylesheet\", href: p.css});\n add(document.body, \"script\", {type: \"module\", src: p.script, onerror: fail});\n })\n .catch(fail);\n } catch (e) { fail(); }\n})();\n</script></body></html>\n";
32
+ export interface EntryPointer {
33
+ v: 1;
34
+ build: string;
35
+ title: string;
36
+ icon: string;
37
+ css: string;
38
+ script: string;
39
+ }
40
+ /** The current build's assets, relative to the entry page. */
41
+ export declare function renderEntryPointer(build: string, title: string, css: string): string;
42
+ /** Undefined when entry.json names exactly this build's assets; otherwise why. */
43
+ export declare function entryPointerProblem(bytes: string, build: string): string | undefined;
44
+ export {};
@@ -0,0 +1,88 @@
1
+ import { resolvedSdkLaunch } from "../contract/app-launch.js";
2
+ /**
3
+ * The SDK entry page: `ui/app/entry.html`, served by DSM at
4
+ * `/webman/3rdparty/<package>/app/entry.html` without DSM's desktop.
5
+ *
6
+ * DSM serves package files with no Cache-Control, Last-Modified 1970 and an
7
+ * ETag of the size alone, so a browser may keep a bookmarked page for years
8
+ * and a revalidation keeps any older copy of the same size. The page is
9
+ * therefore fixed bytes, the same in every build and package: it reads the
10
+ * current build from `entry.json` with a no-store, cache-busted request and
11
+ * loads that build's `?v=` stamped module, stylesheet and icon.
12
+ */
13
+ export const ENTRY_PAGE_FILE = "entry.html";
14
+ export const ENTRY_POINTER_FILE = "entry.json";
15
+ export function entryPagePath(pkg) {
16
+ return `/webman/3rdparty/${pkg}/app/${ENTRY_PAGE_FILE}`;
17
+ }
18
+ /** The ui.short_paths target that names the entry page instead of a stable page. */
19
+ export const ENTRY_SHORT_PATH_TARGET = "app";
20
+ /**
21
+ * Main menu and Package Center open the entry page with a DSM url launcher:
22
+ * every native SDK window App that opens a full page (ui.launch: new-page).
23
+ * Not with a console (its Instance is the gateway's launcher) or an identity
24
+ * gateway (its DSM window resumes a cold OIDC sign-in from the launch).
25
+ */
26
+ export function entryLauncher(manifest) {
27
+ return !manifest.compose && manifest.sdkWindow !== false && !manifest.console && !manifest.identityGateway &&
28
+ resolvedSdkLaunch(manifest) === "new-page";
29
+ }
30
+ /** Whether the build writes the entry page: the launcher's, or a mobile App entry's. */
31
+ export function hasEntryPage(manifest) {
32
+ return manifest.mobile?.entry === "app" || entryLauncher(manifest);
33
+ }
34
+ /** The first short path (in path order) that opens the entry page; ctx.entryURL uses it. */
35
+ export function entryShortPath(manifest) {
36
+ const paths = manifest.ui?.shortPaths;
37
+ if (!paths)
38
+ return undefined;
39
+ return Object.entries(paths).filter(([, page]) => page === ENTRY_SHORT_PATH_TARGET).map(([path]) => path).sort()[0];
40
+ }
41
+ /** Fixed bytes: a cached copy from any build or package keeps working, since it reads entry.json. */
42
+ export const ENTRY_PAGE_STUB = `<!doctype html>
43
+ <html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"><meta name="referrer" content="same-origin"><title></title><style>html,body,.dsmapp-root{margin:0;height:100%;min-height:100%}</style></head>
44
+ <body><div class="dsmapp-root"></div><noscript>This page needs JavaScript.</noscript><script>
45
+ (function () {
46
+ var asset = /^\\.\\/(?:[\\w~-][\\w.~-]*\\/)*[\\w~-][\\w.~-]*\\?v=[0-9a-f]{64}$/;
47
+ function fail() { document.body.textContent = "This page is not available. Reload to try again."; }
48
+ function add(parent, tag, attrs) { var node = document.createElement(tag); for (var key in attrs) node[key] = attrs[key]; parent.appendChild(node); return node; }
49
+ try {
50
+ fetch("${ENTRY_POINTER_FILE}?t=" + Date.now(), {cache: "no-store", credentials: "same-origin", redirect: "error"})
51
+ .then(function (r) { if (!r.ok) throw 0; return r.json(); })
52
+ .then(function (p) {
53
+ if (!p || p.v !== 1 || typeof p.title !== "string" || !asset.test(p.script) || !asset.test(p.css) || !asset.test(p.icon)) throw 0;
54
+ document.title = p.title;
55
+ add(document.head, "link", {rel: "icon", href: p.icon});
56
+ add(document.head, "link", {rel: "stylesheet", href: p.css});
57
+ add(document.body, "script", {type: "module", src: p.script, onerror: fail});
58
+ })
59
+ .catch(fail);
60
+ } catch (e) { fail(); }
61
+ })();
62
+ </script></body></html>
63
+ `;
64
+ /** The current build's assets, relative to the entry page. */
65
+ export function renderEntryPointer(build, title, css) {
66
+ const pointer = {
67
+ v: 1, build, title,
68
+ icon: `./icons/mobile-192.png?v=${build}`,
69
+ css: `${css}?v=${build}`,
70
+ script: `./entry.js?v=${build}`,
71
+ };
72
+ return `${JSON.stringify(pointer)}\n`;
73
+ }
74
+ /** Undefined when entry.json names exactly this build's assets; otherwise why. */
75
+ export function entryPointerProblem(bytes, build) {
76
+ let pointer;
77
+ try {
78
+ pointer = JSON.parse(bytes);
79
+ }
80
+ catch {
81
+ return "entry.json is not JSON";
82
+ }
83
+ if (!pointer || pointer.v !== 1 || pointer.build !== build || typeof pointer.title !== "string" ||
84
+ pointer.icon !== `./icons/mobile-192.png?v=${build}` || pointer.script !== `./entry.js?v=${build}` ||
85
+ typeof pointer.css !== "string" || !/^\.\/(?:[a-f0-9]{64}\/)?app\.css\?v=[a-f0-9]{64}$/.test(pointer.css) || !pointer.css.endsWith(`?v=${build}`))
86
+ return "entry.json does not name this build's entry assets";
87
+ return undefined;
88
+ }
@@ -1,7 +1,8 @@
1
1
  import { folderPickerWizardFiles } from '../build-spk/folder-picker.js';
2
2
  import { parseDsmStrings } from "./dsm-texts.js";
3
3
  import { readTCPListeners } from "./tcp-listeners.js";
4
- import { inspectMobileFiles, mobileRecordProblem } from './mobile.js';
4
+ import { entryRecordProblem, inspectEntryFiles, inspectMobileFiles, mobileRecordProblem } from './mobile.js';
5
+ import { ENTRY_SHORT_PATH_TARGET, entryPagePath } from './entry-page.js';
5
6
  import { inspectStablePages } from './stable-pages.js';
6
7
  import { LIFECYCLE_SCRIPTS } from '../spk/dsm-spec.js';
7
8
  import { SHORT_PATHS_CONFIG, renderShortPathsCheck, renderShortPathsConfig, shortPathIngressProblem, shortPathsMinDsmProblem, shortPathsProblem, withoutShortPathsCheck } from './short-paths.js';
@@ -186,7 +187,7 @@ export async function inspectSpk(spkPath, expectedKind, options = {}) {
186
187
  if (metadata.daemon_nofile !== undefined && (!paths.has("daemon/control") || metadata.compose !== undefined))
187
188
  findings.push("daemon.nofile requires a native daemon controller");
188
189
  const daemonRestart = recoverDaemonRestart(metadata.daemon_restart, metadata.daemon_restart === undefined && daemonNoFile !== undefined ? undefined : metadata.daemon_sdk, findings);
189
- await inspectModuleUi(dir, paths, metadata.ui_module, findings, metadata.mobile);
190
+ await inspectModuleUi(dir, paths, metadata.ui_module, findings, metadata.mobile, metadata.entry_page);
190
191
  await inspectStablePageFiles(dir, paths, metadata.stable_pages, metadata.ui_module, findings);
191
192
  if (metadata.daemon_restart !== undefined && (metadata.compose !== undefined || !paths.has("daemon/control")))
192
193
  findings.push("DAEMON_RESTART_INVALID daemon restart requires a native daemon controller, without Compose supervision");
@@ -250,13 +251,14 @@ export async function inspectSpk(spkPath, expectedKind, options = {}) {
250
251
  const daemonNode = recoverDaemonNode(metadata.daemon_node, findings);
251
252
  const info = readInfo(join(dir, "INFO"), findings, kind, Boolean(combined), daemonNode, dependencies);
252
253
  await inspectMobile(dir, paths, metadata.mobile, info, findings);
254
+ await inspectEntryPage(dir, paths, metadata.entry_page, findings);
253
255
  if (combined &&
254
256
  (!info.os_min_ver || !isDsmAtLeast(info.os_min_ver, CONTAINER_MIN_DSM)))
255
257
  findings.push("compose identity_gateway requires DSM >= 7.2.1");
256
258
  await checkArch(dir, info, kind, paths.has(CGI_PAYLOAD_PATH), findings);
257
259
  const nativeGateway = await recoverNativeGateway(dir, metadata.native_gateway, info, findings);
258
260
  const daemonIngress = await recoverDaemonIngress(dir, metadata.daemon_ingress, info, paths, findings);
259
- const shortPaths = await recoverShortPaths(dir, metadata.short_paths, metadata.stable_pages, info, nativeGateway, findings);
261
+ const shortPaths = await recoverShortPaths(dir, metadata.short_paths, metadata.stable_pages, info, nativeGateway, findings, metadata.entry_page !== undefined);
260
262
  const background = compiledKind && paths.has(BACKGROUND_WORKER_PAYLOAD);
261
263
  // Before any fixed-lifecycle comparison: those see the SDK steps alone.
262
264
  if (shortPaths)
@@ -354,7 +356,7 @@ export async function inspectSpk(spkPath, expectedKind, options = {}) {
354
356
  }
355
357
  if (metadata.entry)
356
358
  await checkEntryLauncher(dir, info.package, metadata.entry, findings);
357
- const launch = await checkLaunchConfiguration(dir, info, standalone, metadata.launch, portal?.alias ?? executor?.policy.portal?.alias, findings, metadata.console === true, metadata.window === false);
359
+ const launch = await checkLaunchConfiguration(dir, info, standalone, metadata.launch, portal?.alias ?? executor?.policy.portal?.alias, findings, metadata.console === true, metadata.window === false, metadata.entry_page?.launcher === true);
358
360
  const loginStyle = standalone
359
361
  ? await inspectLoginStyle(dir, info.package, Boolean(portal || executor?.policy.portal), findings)
360
362
  : undefined;
@@ -444,7 +446,7 @@ async function inspectNativeTexts(dir, paths, findings) {
444
446
  }
445
447
  return result;
446
448
  }
447
- async function inspectModuleUi(dir, paths, version, findings, mobile) {
449
+ async function inspectModuleUi(dir, paths, version, findings, mobile, entryPage) {
448
450
  if (version === undefined) {
449
451
  if ([...paths].some(path => /^ui\/app\/[a-f0-9]{64}\/app\.module\.js$/.test(path)))
450
452
  findings.push("UI_MODULE_INVALID module UI requires its build record");
@@ -457,7 +459,7 @@ async function inspectModuleUi(dir, paths, version, findings, mobile) {
457
459
  for (const entry of [MODULE_UI_ENTRY, "app.css"])
458
460
  if (!paths.has(prefix + entry))
459
461
  throw new Error(`missing ${entry}`);
460
- if ([...paths].some(path => path.startsWith("ui/app/") && path !== `ui/app/${version}` && !path.startsWith(prefix) && !(mobile && !mobileRecordProblem(mobile) && Object.hasOwn(mobile.files, path.slice("ui/app/".length)))))
462
+ if ([...paths].some(path => path.startsWith("ui/app/") && path !== `ui/app/${version}` && !path.startsWith(prefix) && !(mobile && !mobileRecordProblem(mobile) && Object.hasOwn(mobile.files, path.slice("ui/app/".length))) && !(entryPage && !entryRecordProblem(entryPage) && Object.hasOwn(entryPage.files, path.slice("ui/app/".length)))))
461
463
  throw new Error("module UI assets must all belong to the recorded tree");
462
464
  const root = join(dir, "module-ui-inspection");
463
465
  mkdirSync(root);
@@ -491,7 +493,7 @@ async function inspectStablePageFiles(dir, paths, record, version, findings) {
491
493
  const LAUNCHER_TYPE_MISMATCH = "LAUNCHER_TYPE_MISMATCH";
492
494
  const LAUNCHER_PORTAL_MISMATCH = "LAUNCHER_PORTAL_MISMATCH";
493
495
  /** Compare the actual launcher and Portal fields to the packaged declaration. */
494
- async function checkLaunchConfiguration(dir, info, native, declared, alias, findings, console = false, windowless = false) {
496
+ async function checkLaunchConfiguration(dir, info, native, declared, alias, findings, console = false, windowless = false, entryLauncher = false) {
495
497
  const target = join(dir, "launch-inspection");
496
498
  mkdirSync(target);
497
499
  await extractSpkArchive({
@@ -550,14 +552,18 @@ async function checkLaunchConfiguration(dir, info, native, declared, alias, find
550
552
  checkGatewayOnlyLauncher(target, info, native, findings);
551
553
  return launch;
552
554
  }
553
- const type = dsmLauncherType(launch, native);
555
+ // A native full page opens the SDK entry page with a url launcher.
556
+ const entry = native && entryLauncher && launch === "new-page";
557
+ const type = entry ? "url" : dsmLauncherType(launch, native);
554
558
  if (!launcher ||
555
559
  launcher.type !== type ||
556
560
  info.dsmuidir !== "ui" ||
557
561
  info.dsmappname !== appId ||
558
- (native
559
- ? launcher.appWindow !== `SYNO.SDS.${info.package}.MainWindow`
560
- : launcher.url !== url || info.adminurl !== url)) {
562
+ (entry
563
+ ? launcher.url !== entryPagePath(info.package) || launcher.appWindow !== undefined
564
+ : native
565
+ ? launcher.appWindow !== `SYNO.SDS.${info.package}.MainWindow`
566
+ : launcher.url !== url || info.adminurl !== url)) {
561
567
  findings.push(`${LAUNCHER_TYPE_MISMATCH} ${launch} requires a ${type} launcher at ${appId} and matching INFO entry; rebuild with synopkgland build`);
562
568
  }
563
569
  if (launcher &&
@@ -1423,11 +1429,12 @@ async function recoverDaemonIngress(dir, value, info, paths, findings) {
1423
1429
  }
1424
1430
  const SHORT_PATHS_INVALID = "SHORT_PATHS_INVALID";
1425
1431
  /** Replay the recorded short paths: the redirect-only locations and their DSM floor. */
1426
- async function recoverShortPaths(dir, value, stablePages, info, gateway, findings) {
1432
+ async function recoverShortPaths(dir, value, stablePages, info, gateway, findings, entryPage = false) {
1427
1433
  if (value === undefined)
1428
1434
  return undefined;
1429
1435
  try {
1430
1436
  const problem = shortPathsProblem(value, stablePages && typeof stablePages === "object" && !Array.isArray(stablePages) ? stablePages : undefined)
1437
+ ?? (!entryPage && value && typeof value === "object" && Object.values(value).includes(ENTRY_SHORT_PATH_TARGET) ? "a short path opens the entry page, which this package does not record" : undefined)
1431
1438
  ?? shortPathsMinDsmProblem(info.os_min_ver)
1432
1439
  ?? shortPathIngressProblem(value, gateway?.ingress?.path);
1433
1440
  if (problem)
@@ -1971,6 +1978,29 @@ function matchesGatewayConfig(actual, manifest) {
1971
1978
  delete expected[key];
1972
1979
  return actual === JSON.stringify(expected) + '\n';
1973
1980
  }
1981
+ /** Replay the entry page record: the fixed page, its pointer and every digest. */
1982
+ async function inspectEntryPage(dir, paths, record, findings) {
1983
+ const ENTRY_PAGE_INVALID = 'ENTRY_PAGE_INVALID';
1984
+ if (record === undefined) {
1985
+ if (paths.has('ui/app/entry.json'))
1986
+ findings.push(`${ENTRY_PAGE_INVALID} entry.json has no build record`);
1987
+ return;
1988
+ }
1989
+ try {
1990
+ const invalid = entryRecordProblem(record);
1991
+ if (invalid)
1992
+ throw new Error(invalid);
1993
+ const target = join(dir, 'entry-page-inspection');
1994
+ mkdirSync(target);
1995
+ await extractSpkArchive({ file: join(dir, 'package.tgz'), cwd: target, filter: path => path.replace(/^\.\//, '').startsWith('ui/app/') });
1996
+ const problem = inspectEntryFiles(join(target, 'ui/app'), record);
1997
+ if (problem)
1998
+ throw new Error(problem);
1999
+ }
2000
+ catch (error) {
2001
+ findings.push(`${ENTRY_PAGE_INVALID} ${error.message}`);
2002
+ }
2003
+ }
1974
2004
  async function inspectMobile(dir, paths, record, info, findings) {
1975
2005
  const MOBILE_INVALID = 'MOBILE_INVALID';
1976
2006
  const hasRegistration = paths.has('ui/app/mobile.json');
@@ -2,6 +2,7 @@ import { loadNativeTexts } from "./dsm-texts.js";
2
2
  import { readUiSecretIgnores } from "./public-ui.js";
3
3
  import { stablePagesProblem } from "./stable-pages.js";
4
4
  import { shortPathIngressProblem, shortPathsMinDsmProblem, shortPathsProblem } from "./short-paths.js";
5
+ import { ENTRY_SHORT_PATH_TARGET, hasEntryPage } from "./entry-page.js";
5
6
  import { readTCPListeners, tcpSDKProblem } from "./tcp-listeners.js";
6
7
  import { validateNativeManifest } from './native-http.js';
7
8
  import { readMobile, mobileIconPath } from './mobile.js';
@@ -626,6 +627,9 @@ function readManifest(raw, c) {
626
627
  if (entryProblem)
627
628
  c.fail("STANDALONE_PORTAL_ENTRY_INVALID", entryProblem);
628
629
  const dsmConsole = raw.console === undefined ? undefined : readConsole(raw, ui?.launch, c);
630
+ if (ui && "shortPaths" in ui && ui.shortPaths && Object.values(ui.shortPaths).includes(ENTRY_SHORT_PATH_TARGET) &&
631
+ !hasEntryPage({ compose: raw.compose === undefined ? undefined : {}, sdkWindow: noWindow ? false : undefined, console: dsmConsole, identityGateway, ui: ui, mobile }))
632
+ c.fail("STANDALONE_UI_SHORT_PATHS_INVALID", "ui.short_paths app opens the App's entry page, which needs a native SDK UI with ui.launch: new-page (no console or identity_gateway) or mobile.entry: app.");
629
633
  const loginStyle = raw.login_style === undefined
630
634
  ? undefined
631
635
  : readLoginStyle(raw.login_style, raw.portal !== undefined, c);
@@ -38,13 +38,35 @@ export interface MobileRecord {
38
38
  }
39
39
  /** Replayed by inspect from the packaged declaration, rather than copied JSON. */
40
40
  export declare function mobileRegistration(record: MobileRecord): Record<string, unknown>;
41
+ /** The entry page's build record: its files, and whether the url launcher opens it. */
42
+ export interface EntryRecord {
43
+ build: string;
44
+ launcher: boolean;
45
+ files: Record<string, string>;
46
+ }
41
47
  export interface MobileAssets {
42
48
  build: string;
43
49
  files: Map<string, Buffer>;
44
- record: MobileRecord;
50
+ record?: MobileRecord;
51
+ entry?: EntryRecord;
45
52
  }
46
- /** Pure packaging glue; login, cache, portal and host behavior stay in the bundled SDK. */
53
+ /**
54
+ * The entry reads app.status from the App's own backend daemon when the
55
+ * manifest serves that backend at daemon.ingress: a CGI process would first
56
+ * reserve its whole fallback budget from the daemon. Only the manifest
57
+ * decides; another daemon or a Compose App keeps the CGI.
58
+ */
59
+ export declare function statusIngress(manifest: Pick<StandaloneManifest, 'package' | 'compose' | 'daemon'>): string | undefined;
60
+ /** The SDK release whose entry keeps its address and carries a launch across DSM's sign-in. */
61
+ export declare const ENTRY_SDK_MIN = "0.53.45";
62
+ /** Pure packaging glue; login, cache, portal and host behavior stay in the bundled SDK.
63
+ * Writes the entry page for the url launcher and for a mobile App entry, and
64
+ * mobile.json for a mobile declaration. */
47
65
  export declare function renderMobileAssets(manifest: StandaloneManifest, uiDigest: string, moduleVersion?: string): Promise<MobileAssets | undefined>;
66
+ /** Validate the entry page record before using any of its paths. */
67
+ export declare function entryRecordProblem(record: unknown): string | undefined;
68
+ /** The recorded files as built: the fixed page, this build's pointer and digests. */
69
+ export declare function inspectEntryFiles(root: string, record: EntryRecord): string | undefined;
48
70
  /** Validate the replay inventory before using any of its paths. */
49
71
  export declare function mobileRecordProblem(record: unknown): string | undefined;
50
72
  export declare function inspectMobileFiles(root: string, record: MobileRecord): string | undefined;
@@ -2,7 +2,7 @@ import { Ajv } from 'ajv';
2
2
  import { createHash } from 'node:crypto';
3
3
  import { existsSync, readFileSync } from 'node:fs';
4
4
  import { createRequire } from 'node:module';
5
- import { isAbsolute, join, relative, resolve } from 'node:path';
5
+ import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
6
6
  import { build } from 'esbuild';
7
7
  import { mobileIcons } from '../build-spk/dsm-icons.js';
8
8
  import { appSdkTimeouts } from '../runtime/sdk-timeouts.js';
@@ -14,6 +14,8 @@ import { isPortalAlias } from '../portal/alias.js';
14
14
  import { renderExecutorApproval } from './executor-approval.js';
15
15
  import { CALL_RETRY_RUNTIME } from './call-retry.js';
16
16
  import { MOBILE_APPROVAL_WEBAPI } from './mobile-approval-webapi.js';
17
+ import { daemonIngressPath, readDaemonIngress } from './daemon-ingress.js';
18
+ import { ENTRY_PAGE_STUB, ENTRY_POINTER_FILE, entryLauncher, entryPointerProblem, entryShortPath, hasEntryPage, renderEntryPointer } from './entry-page.js';
17
19
  const schema = JSON.parse(readFileSync(new URL('../../schema/mobile.v1.schema.json', import.meta.url), 'utf8'));
18
20
  const ajv = new Ajv({ allErrors: true });
19
21
  const validate = ajv.compile(schema);
@@ -43,35 +45,90 @@ export function mobileRegistration(record) {
43
45
  }
44
46
  const digest = (bytes) => createHash('sha256').update(bytes).digest('hex');
45
47
  const json = (value) => JSON.stringify(value).replaceAll('<', '\\u003c');
46
- const html = (value) => value.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('"', '&quot;');
48
+ /** The SDK package's /entry module in dir, if it has one. */
49
+ function sdkEntryIn(dir) {
50
+ try {
51
+ const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
52
+ const entry = pkg.exports?.['./entry'];
53
+ const path = typeof entry === 'string' ? entry : entry?.import;
54
+ if (typeof path === 'string' && path.startsWith('./') && existsSync(join(dir, path)))
55
+ return join(dir, path);
56
+ }
57
+ catch { /* Not an SDK package */ }
58
+ return undefined;
59
+ }
60
+ /** The version of the SDK package that holds an entry module, if it says. */
61
+ function entrySdkVersion(module) {
62
+ for (let dir = dirname(module); dir !== dirname(dir); dir = dirname(dir)) {
63
+ try {
64
+ const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
65
+ if (pkg?.name === '@synopackageland/sdk')
66
+ return typeof pkg.version === 'string' ? pkg.version : undefined;
67
+ }
68
+ catch { /* Keep looking upward */ }
69
+ }
70
+ return undefined;
71
+ }
72
+ /** The App's own @synopackageland/sdk/entry; SYNOPKGLAND_ENTRY_SDK_DIR names an
73
+ * SDK package for projects without one (local development and tests). */
47
74
  function entryModule(manifest) {
48
75
  const roots = [manifest.ui.build?.cwd, manifest.root].filter((x) => !!x);
49
76
  for (const root of roots) {
50
77
  for (const modules of createRequire(join(root, 'package.json')).resolve.paths('@synopackageland/sdk') ?? []) {
51
- try {
52
- const dir = join(modules, '@synopackageland/sdk');
53
- const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
54
- const entry = pkg.exports?.['./entry'];
55
- const path = typeof entry === 'string' ? entry : entry?.import;
56
- if (typeof path === 'string' && path.startsWith('./') && existsSync(join(dir, path)))
57
- return join(dir, path);
58
- }
59
- catch { /* Try the next installed package */ }
78
+ const found = sdkEntryIn(join(modules, '@synopackageland/sdk'));
79
+ if (found)
80
+ return found;
60
81
  }
61
82
  }
62
- throw new Error('[MOBILE_SDK_ENTRY_MISSING] install @synopackageland/sdk with the /entry export in the UI build directory or project root');
83
+ const fallback = process.env.SYNOPKGLAND_ENTRY_SDK_DIR ? sdkEntryIn(process.env.SYNOPKGLAND_ENTRY_SDK_DIR) : undefined;
84
+ if (fallback)
85
+ return fallback;
86
+ throw new Error('[MOBILE_SDK_ENTRY_MISSING] the App entry page (ui.launch: new-page or mobile.entry: app) bundles @synopackageland/sdk/entry: install @synopackageland/sdk in the UI build directory or project root');
87
+ }
88
+ /**
89
+ * The entry reads app.status from the App's own backend daemon when the
90
+ * manifest serves that backend at daemon.ingress: a CGI process would first
91
+ * reserve its whole fallback budget from the daemon. Only the manifest
92
+ * decides; another daemon or a Compose App keeps the CGI.
93
+ */
94
+ export function statusIngress(manifest) {
95
+ const ingress = manifest.daemon?.ingress;
96
+ if (manifest.compose || !manifest.daemon?.backend || !ingress)
97
+ return undefined;
98
+ const path = daemonIngressPath(manifest.package);
99
+ if (!readDaemonIngress(ingress, manifest.package, () => { }) || ingress.path !== path)
100
+ throw new Error('Invalid daemon ingress: use /synopkgland/<package>/ with the exact package ID');
101
+ return path;
102
+ }
103
+ /** The SDK release whose entry keeps its address and carries a launch across DSM's sign-in. */
104
+ export const ENTRY_SDK_MIN = '0.53.45';
105
+ const older = (version, floor) => {
106
+ const a = version.split('.').map(Number), b = floor.split('.').map(Number);
107
+ for (let i = 0; i < 3; i++)
108
+ if ((a[i] ?? 0) !== (b[i] ?? 0))
109
+ return (a[i] ?? 0) < (b[i] ?? 0);
110
+ return false;
111
+ };
112
+ /** The url launcher needs SDK 0.53.45 or later: by its package version, and by its rewriteToAlias option. */
113
+ function entryRuntimeProblem(runtime, version) {
114
+ const versionOld = typeof version === 'string' && /^\d+\.\d+\.\d+/.test(version) && older(version, ENTRY_SDK_MIN);
115
+ return !versionOld && runtime.includes('rewriteToAlias') ? undefined
116
+ : `[ENTRY_SDK_OUTDATED] ui.launch: new-page opens the SDK entry page; update @synopackageland/sdk to ${ENTRY_SDK_MIN} or later${version ? ` (installed ${version})` : ''}`;
63
117
  }
64
- /** Pure packaging glue; login, cache, portal and host behavior stay in the bundled SDK. */
118
+ /** Pure packaging glue; login, cache, portal and host behavior stay in the bundled SDK.
119
+ * Writes the entry page for the url launcher and for a mobile App entry, and
120
+ * mobile.json for a mobile declaration. */
65
121
  export async function renderMobileAssets(manifest, uiDigest, moduleVersion) {
66
122
  const mobile = manifest.mobile;
67
- if (!mobile)
123
+ const entry = hasEntryPage(manifest);
124
+ if (!mobile && !entry)
68
125
  return undefined;
69
- const icons = mobileIcons(mobile.icon ? mobileIconPath(manifest.root, mobile.icon) : manifest.icon);
70
- const name = { en: mobile.name ?? manifest.displayname };
126
+ const icons = mobileIcons(mobile?.icon ? mobileIconPath(manifest.root, mobile.icon) : manifest.icon);
127
+ const name = { en: mobile?.name ?? manifest.displayname };
71
128
  for (const [locale, text] of Object.entries(manifest.i18n?.info ?? {}))
72
129
  if (text?.mobile_name || text?.displayname)
73
130
  name[locale] = text.mobile_name ?? text.displayname;
74
- const record = {
131
+ const record = mobile && {
75
132
  declaration: mobile, package: manifest.package, version: manifest.spkVersion, build: '', name,
76
133
  ...(manifest.portal ? { portal: { defaultAlias: manifest.portal.alias } } : {}),
77
134
  ...(mobile.entry === 'gateway' ? { gatewayEntry: gatewayEntryPath(manifest) } : {}), files: {},
@@ -80,7 +137,7 @@ export async function renderMobileAssets(manifest, uiDigest, moduleVersion) {
80
137
  for (const [size, png] of icons)
81
138
  files.set(`icons/mobile-${size}.png`, png);
82
139
  let runtime = '';
83
- const approval = mobile.entry === 'app' && manifest.executor
140
+ const approval = entry && manifest.executor
84
141
  ? `var executorApproval = {};
85
142
  ${renderExecutorApproval('executorApproval', manifest)}
86
143
  ${CALL_RETRY_RUNTIME}
@@ -98,25 +155,33 @@ function attachExecutor(ctx, desktopWebApi) {
98
155
  }
99
156
  ` : '';
100
157
  const requestTimeout = requestTimeoutSeconds(manifest.backend) * 1000 + appSdkTimeouts(manifest.backend).browserMarginMs;
101
- if (mobile.entry === 'app') {
158
+ const daemonIngress = entry ? statusIngress(manifest) : undefined;
159
+ if (entry) {
102
160
  const result = await build({ entryPoints: [entryModule(manifest)], bundle: true, write: false, format: 'esm', platform: 'browser', target: 'es2022', minify: true, keepNames: true, legalComments: 'none' });
103
161
  runtime = result.outputFiles[0].text;
162
+ const outdated = entryLauncher(manifest) ? entryRuntimeProblem(runtime, entrySdkVersion(entryModule(manifest))) : undefined;
163
+ if (outdated)
164
+ throw new Error(outdated);
104
165
  }
105
166
  // Hash both runtime and declaration, as well as the original UI and all icons.
106
- const hash = createHash('sha256').update(readFileSync(new URL(import.meta.url))).update(uiDigest).update(json(mobileRegistration(record))).update(runtime)
107
- .update(json({ generator: CLI_VERSION, requestTimeout, messages: manifest.i18n?.catalogs }));
167
+ const shortPath = entry ? entryShortPath(manifest) : undefined;
168
+ const hash = createHash('sha256').update(readFileSync(new URL(import.meta.url))).update(uiDigest).update(record ? json(mobileRegistration(record)) : '').update(runtime)
169
+ .update(json({ generator: CLI_VERSION, requestTimeout, messages: manifest.i18n?.catalogs, daemonIngress, shortPath, launcher: entryLauncher(manifest) }));
108
170
  if (approval)
109
171
  hash.update(approval);
110
172
  for (const [path, bytes] of files)
111
173
  hash.update(path).update(bytes);
112
174
  const version = hash.digest('hex');
113
- if (mobile.entry === 'app') {
175
+ if (entry) {
114
176
  const appBundle = `${moduleVersion ? `./${moduleVersion}/${MODULE_UI_ENTRY}` : './app.js'}?v=${version}`;
115
177
  const options = {
116
178
  packageId: manifest.package, build: version, displayName: name.en,
117
- appIcon: `./icons/mobile-192.png?v=${version}`, appBundle,
179
+ // modulepreload suits a module only: a classic app.js would load twice.
180
+ appIcon: `./icons/mobile-192.png?v=${version}`, ...(moduleVersion ? { appBundle } : {}),
118
181
  ...(manifest.portal ? { portal: { defaultAlias: manifest.portal.alias } } : {}),
182
+ ...(shortPath ? { shortPath } : {}),
119
183
  requestTimeout,
184
+ ...(daemonIngress ? { daemonIngress } : {}),
120
185
  ...(manifest.i18n?.catalogs ? { messages: manifest.i18n.catalogs } : {}),
121
186
  };
122
187
  // Classic bundles rely on document.currentScript.dataset.package; keep
@@ -133,13 +198,42 @@ function attachExecutor(ctx, desktopWebApi) {
133
198
  const context = await build({ stdin: { contents: contextSource, resolveDir: manifest.root, sourcefile: 'synopkgland-context.generated.js' }, bundle: true, write: false, format: 'esm', platform: 'browser', target: 'es2022', minify: true, keepNames: true, legalComments: 'none' });
134
199
  files.set('entry-context.js', Buffer.from(context.outputFiles[0].text));
135
200
  const css = moduleVersion ? `./${moduleVersion}/app.css` : './app.css';
136
- files.set('entry.html', Buffer.from(`<!doctype html>\n<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"><meta name="synopkgland-build" content="${version}"><title>${html(name.en)}</title><link rel="icon" href="./icons/mobile-192.png?v=${version}"><link rel="stylesheet" href="${css}?v=${version}"><style>html,body,.dsmapp-root{margin:0;height:100%;min-height:100%}</style></head><body><div class="dsmapp-root"></div><script type="module" src="./entry.js?v=${version}"></script></body></html>\n`));
201
+ files.set('entry.html', Buffer.from(ENTRY_PAGE_STUB));
202
+ files.set(ENTRY_POINTER_FILE, Buffer.from(renderEntryPointer(version, name.en, css)));
203
+ }
204
+ if (record) {
205
+ record.build = version;
206
+ files.set('mobile.json', Buffer.from(JSON.stringify(mobileRegistration(record), null, 2) + '\n'));
207
+ }
208
+ const inventory = Object.fromEntries([...files].map(([path, bytes]) => [path, digest(bytes)]));
209
+ if (record)
210
+ record.files = inventory;
211
+ return { build: version, files, ...(record ? { record } : {}),
212
+ ...(entry ? { entry: { build: version, launcher: entryLauncher(manifest), files: Object.fromEntries(Object.entries(inventory).filter(([path]) => path !== 'mobile.json')) } } : {}) };
213
+ }
214
+ const ENTRY_FILES = ['entry.html', ENTRY_POINTER_FILE, 'entry.js', 'entry-context.js', 'icons/mobile-192.png', 'icons/mobile-512.png'];
215
+ /** Validate the entry page record before using any of its paths. */
216
+ export function entryRecordProblem(record) {
217
+ const r = record;
218
+ if (!r || typeof r !== 'object' || typeof r.build !== 'string' || !/^[a-f0-9]{64}$/.test(r.build) || typeof r.launcher !== 'boolean' || !r.files || typeof r.files !== 'object')
219
+ return 'invalid entry page record';
220
+ const paths = Object.keys(r.files);
221
+ if (paths.length !== ENTRY_FILES.length || !ENTRY_FILES.every(path => typeof r.files[path] === 'string' && /^[a-f0-9]{64}$/.test(r.files[path])))
222
+ return 'invalid entry page inventory';
223
+ return undefined;
224
+ }
225
+ /** The recorded files as built: the fixed page, this build's pointer and digests. */
226
+ export function inspectEntryFiles(root, record) {
227
+ const invalid = entryRecordProblem(record);
228
+ if (invalid)
229
+ return invalid;
230
+ for (const [path, hash] of Object.entries(record.files)) {
231
+ if (!existsSync(join(root, path)) || digest(readFileSync(join(root, path))) !== hash)
232
+ return `${path} differs from the generated build`;
137
233
  }
138
- record.build = version;
139
- const registered = mobileRegistration(record);
140
- files.set('mobile.json', Buffer.from(JSON.stringify(registered, null, 2) + '\n'));
141
- record.files = Object.fromEntries([...files].map(([path, bytes]) => [path, digest(bytes)]));
142
- return { build: version, files, record };
234
+ if (readFileSync(join(root, 'entry.html'), 'utf8') !== ENTRY_PAGE_STUB)
235
+ return 'entry.html is not the fixed entry page';
236
+ return entryPointerProblem(readFileSync(join(root, ENTRY_POINTER_FILE), 'utf8'), record.build);
143
237
  }
144
238
  /** Validate the replay inventory before using any of its paths. */
145
239
  export function mobileRecordProblem(record) {
@@ -161,7 +255,7 @@ export function mobileRecordProblem(record) {
161
255
  if (!r.files['mobile.json'] || !r.files['icons/mobile-192.png'] || !r.files['icons/mobile-512.png'] || (r.declaration.entry === 'app' && (!r.files['entry.html'] || !r.files['entry.js'] || !r.files['entry-context.js'])))
162
256
  return 'missing registration or icon inventory';
163
257
  for (const [path, hash] of Object.entries(r.files))
164
- if (!/^(entry\.(?:html|js)|entry-context\.js|mobile\.json|icons\/mobile-(?:192|512)\.png)$/.test(path) || typeof hash !== 'string' || !/^[a-f0-9]{64}$/.test(hash))
258
+ if (!/^(entry\.(?:html|js|json)|entry-context\.js|mobile\.json|icons\/mobile-(?:192|512)\.png)$/.test(path) || typeof hash !== 'string' || !/^[a-f0-9]{64}$/.test(hash))
165
259
  return 'invalid asset inventory';
166
260
  return undefined;
167
261
  }
@@ -19,7 +19,7 @@ export declare function shortPathsProblem(value: unknown, stablePages: StablePag
19
19
  export declare function shortPathsMinDsmProblem(osMinVer: string | undefined): string | undefined;
20
20
  /** A custom ingress of the same package must not share the path: the exact location would shadow it. */
21
21
  export declare function shortPathIngressProblem(paths: ShortPaths, ingressPath: string | undefined): string | undefined;
22
- /** The URL each short path redirects to: the stable page itself (DSM answers its folder with 403). */
22
+ /** The URL each short path redirects to: the stable page itself (DSM answers its folder with 403), or for app the fixed entry page. */
23
23
  export declare function shortPathTarget(pkg: string, page: string): string;
24
24
  /**
25
25
  * One exact location per path and per path with a trailing slash. A relative
@@ -1,6 +1,7 @@
1
1
  import { isDsmAtLeast, PORTAL_MIN_DSM } from "../build-spk/dsm-version.js";
2
2
  import { RESERVED_GATEWAY_PREFIXES } from "./gateway-ingress.js";
3
3
  import { STABLE_PAGE_FILE } from "./stable-pages.js";
4
+ import { ENTRY_SHORT_PATH_TARGET, entryPagePath } from "./entry-page.js";
4
5
  export const SHORT_PATHS_CONFIG = "etc/short-paths-nginx.conf";
5
6
  export const SHORT_PATH_LIMIT = 4;
6
7
  const PATH = /^\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
@@ -10,7 +11,7 @@ const CHECK_HOOKS = ["preinst", "preupgrade", "postinst", "postupgrade"];
10
11
  /** Undefined when valid; otherwise why. `stablePages` are the package's declared pages. */
11
12
  export function shortPathsProblem(value, stablePages) {
12
13
  if (!value || typeof value !== "object" || Array.isArray(value))
13
- return "must map a path to a ui.stable_pages name, for example {/connect: m}";
14
+ return "must map a path to a ui.stable_pages name or app (the App's entry page), for example {/connect: m}";
14
15
  const entries = Object.entries(value);
15
16
  if (!entries.length || entries.length > SHORT_PATH_LIMIT)
16
17
  return `must list 1 to ${SHORT_PATH_LIMIT} paths`;
@@ -19,8 +20,10 @@ export function shortPathsProblem(value, stablePages) {
19
20
  return `path ${JSON.stringify(path)} must be one lowercase segment such as /connect: a leading /, letters, digits and inner -, no trailing / (at most 64 characters); / is unsupported`;
20
21
  if (RESERVED_GATEWAY_PREFIXES.includes(path.slice(1)))
21
22
  return `path ${path} is reserved by DSM or the SDK (${RESERVED_GATEWAY_PREFIXES.join(", ")}); choose another path`;
23
+ if (page === ENTRY_SHORT_PATH_TARGET)
24
+ continue;
22
25
  if (typeof page !== "string" || !stablePages || !Object.hasOwn(stablePages, page))
23
- return `${path} must name a page declared in ui.stable_pages`;
26
+ return `${path} must name a page declared in ui.stable_pages, or app for the App's entry page`;
24
27
  }
25
28
  return undefined;
26
29
  }
@@ -43,9 +46,9 @@ function checked(pkg, paths) {
43
46
  throw new Error("Invalid ui.short_paths declaration");
44
47
  return Object.entries(paths).sort(([a], [b]) => a.localeCompare(b));
45
48
  }
46
- /** The URL each short path redirects to: the stable page itself (DSM answers its folder with 403). */
49
+ /** The URL each short path redirects to: the stable page itself (DSM answers its folder with 403), or for app the fixed entry page. */
47
50
  export function shortPathTarget(pkg, page) {
48
- return `/webman/3rdparty/${pkg}/${page}/${STABLE_PAGE_FILE}`;
51
+ return page === ENTRY_SHORT_PATH_TARGET ? entryPagePath(pkg) : `/webman/3rdparty/${pkg}/${page}/${STABLE_PAGE_FILE}`;
49
52
  }
50
53
  /**
51
54
  * One exact location per path and per path with a trailing slash. A relative
@@ -318,7 +318,8 @@ export async function assembleStandaloneSpk(options) {
318
318
  // Record resolved exact files: older CLIs reject `[hash]` when inspecting.
319
319
  ...(uiIgnores.length ? { ui_secret_ignores: storedUiSecretIgnores(uiIgnores) } : {}),
320
320
  ...(manifest.tcpListeners ? { tcp_listeners: manifest.tcpListeners } : {}),
321
- ...(mobile ? { mobile: mobile.record } : {}),
321
+ ...(mobile?.record ? { mobile: mobile.record } : {}),
322
+ ...(mobile?.entry ? { entry_page: mobile.entry } : {}),
322
323
  dependencies: packageDependencies(manifest),
323
324
  ...(moduleVersion ? { ui_module: moduleVersion } : {}),
324
325
  ...(manifest.ui?.stablePages ? { stable_pages: manifest.ui.stablePages } : {}),
package/docs/daemon.md CHANGED
@@ -303,6 +303,13 @@ daemon:
303
303
  - With `ingress`, the backend serves it with `api.ServeIngress`, which the
304
304
  route audit treats like `cgi.Serve`: called directly in `main` with a handler
305
305
  built for it.
306
+ - With `ingress`, the generated entry page (`entry.html`) passes
307
+ `daemonIngress: /synopkgland/<package>/` to the SDK's `bootEntryPage`, so
308
+ its `app.status` reads (at boot and the background entry check) go to the
309
+ backend daemon instead of a CGI process; other calls keep the CGI. The
310
+ value comes from the manifest, never from the page. Apps without
311
+ `backend: true` and `ingress`, and Compose Apps, keep the CGI. An SDK older
312
+ than the entry-ingress release ignores the option.
306
313
 
307
314
  ## Upgrades that introduce the daemon
308
315
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.54.3",
3
+ "version": "0.54.4",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@napi-rs/keyring": "^2.1.1",
45
- "@synopackageland/templates": "~0.44.0",
45
+ "@synopackageland/templates": "~0.44.1",
46
46
  "ajv": "^8.17.1",
47
47
  "commander": "^13.1.0",
48
48
  "esbuild": "^0.28.2",
package/skills/SKILL.md CHANGED
@@ -346,15 +346,20 @@ SDK 原生 App 的內建預設為 `dsm-window`。使用 `@synopackageland/ui`
346
346
  Scaffold 明確寫入此選擇,plain/binary 使用 `new-page`,Vue UI SDK 使用
347
347
  預設的 `dsm-window`(省略 `ui.launch`)。原生 manifest 省略 `ui.launch` 時解析為 `dsm-window`,CLI 不猜測前端依賴。
348
348
 
349
- `new-page` 產生 DSM `type: "standalone"` launcher,主選單及套件中心皆在 DSM
350
- 本身的 origin 開啟全頁。`ctx.fullPage`、`ctx.appIcon`、`ctx.uiUpdate`、SynoToken/session、
351
- `ctx.launchParams`/`onLaunch`、`entry` 權限沿用共用 wrapper;全頁的標題、
352
- favicon 與手機 viewport 由 wrapper 設定。不需要 `pureEnv` 或 `allowAltPort`。
349
+ `new-page` 讓主選單與套件中心以 DSM `type: "url"` launcher 在新分頁開 App 的 entry 頁
350
+ `/webman/3rdparty/<package>/app/entry.html`(SDK `bootEntryPage`,不載入 DSM 桌面);Portal alias 與
351
+ `/?launchApp=…` 連結由 DSM 轉到同一頁(DSM 會丟掉 query、把 launchParam 拆成單一字元,SDK 都會處理)。
352
+ entry 頁每次 build 都是相同的固定內容,從 `entry.json`(no-store)讀當前 build 的 `?v=` 資產,書籤不會停在舊版。
353
+ build 需要在 UI build 目錄或專案根目錄安裝含 `/entry` 的 `@synopackageland/sdk`(缺少時 `MOBILE_SDK_ENTRY_MISSING`),
354
+ 且版本要支援 `ctx.entryURL`(0.53.45 以上;過舊時 `ENTRY_SDK_OUTDATED`)。`ctx.fullPage`、`ctx.appIcon`、`ctx.uiUpdate`、
355
+ SynoToken/session、`ctx.launchParams`/`onLaunch`、`entry` 權限照舊;分享與書籤用 `ctx.entryURL`(`ui.short_paths`
356
+ 有指向 `app` 的路徑時是短網址,否則是 entry 頁網址),App 內的位置放在 `?link=`。宣告 `identity_gateway` 的 App
357
+ 仍用 `type: "standalone"`(DSM 視窗要接續 OIDC 冷登入)。不需要 `pureEnv` 或 `allowAltPort`。
353
358
 
354
359
  `ui.banner: hidden` 只替這個 App 的全頁拿掉 DSM 橫幅(預設 `shown` 保留);適合 App 外框已有名稱與帳號區時,帳號與登出改由 SDK `AppShell` 負責。細節見 reference/ui-vue.md。
355
360
 
356
361
  要給人一個跨版本不變的頁面網址(QR code、書籤、手機主畫面捷徑、PWA `start_url`)時,宣告 `ui.stable_pages: {<name>: <ui.dir 內的檔案>}`,例如 `{m: m/index.html}` → `/webman/3rdparty/<package>/m/index.html`。不要把 `app/<digest>/…` 網址交給使用者:module UI 的 digest 資料夾每次 build 都會換。build 生成固定內容的轉址頁與 `target.json`,DSM 7.1+ 免登入可開,不需 ingress 或 CGI。細節見 reference/ui-vue.md 的 Stable page URLs。
357
- 要更短的網址(例如 `https://<nas>:5001/connect`)時,再加 `ui.short_paths: {/connect: m}`:值是 `stable_pages` 的頁名,DSM nginx 以 302 轉到 `/webman/3rdparty/<package>/m/index.html`,只在套件執行時有效,需要 `os_min_ver` 7.2-64570+。路徑是單一小寫片段;DSM 已用的名稱(`/mobile`、`/webman`、`/sharing` 等)不能用,安裝時還會檢查 NAS 上是否已被 DSM 或其他套件佔用。
362
+ 要更短的網址(例如 `https://<nas>:5001/connect`)時,再加 `ui.short_paths: {/connect: m}`:值是 `stable_pages` 的頁名,或 `app`(轉到 App 的 entry 頁,`ctx.entryURL` 就用這個短網址;需要 new-page 或 `mobile.entry: app`),DSM nginx 以 302 轉到 `/webman/3rdparty/<package>/m/index.html`,只在套件執行時有效,需要 `os_min_ver` 7.2-64570+。路徑是單一小寫片段;DSM 已用的名稱(`/mobile`、`/webman`、`/sharing` 等)不能用,安裝時還會檢查 NAS 上是否已被 DSM 或其他套件佔用。
358
363
 
359
364
  Application Portal 是獨立 opt-in:不想要別名就省略 `portal`,不生成
360
365
  `defaultAlias`、Portal 面板/capability 或 Web Station alias;沒有 Portal
@@ -263,10 +263,15 @@ SDK 原生內建預設為 `dsm-window`;使用 `@synopackageland/ui` 維持視
263
263
  Scaffold 明確寫入此選擇,plain/binary 使用 `new-page`,Vue UI SDK 使用
264
264
  預設的 `dsm-window`(省略 `ui.launch`)。原生 manifest 省略 `ui.launch` 時解析為 `dsm-window`,CLI 不猜測前端依賴。
265
265
 
266
- `new-page` 產生 DSM `type: "standalone"` launcher,主選單及套件中心皆在 DSM
267
- 本身的 origin 開啟全頁。`ctx.fullPage`、`ctx.appIcon`、`ctx.uiUpdate`、SynoToken/session、
268
- `ctx.launchParams`/`onLaunch`、`entry` 權限沿用共用 wrapper;全頁的標題、
269
- favicon 與手機 viewport 由 wrapper 設定。不需要 `pureEnv` 或 `allowAltPort`。
266
+ `new-page` 讓主選單與套件中心以 DSM `type: "url"` launcher 在新分頁開 App 的 entry 頁
267
+ `/webman/3rdparty/<package>/app/entry.html`(SDK `bootEntryPage`,不載入 DSM 桌面);Portal alias 與
268
+ `/?launchApp=…` 連結由 DSM 轉到同一頁(DSM 會丟掉 query、把 launchParam 拆成單一字元,SDK 都會處理)。
269
+ entry 頁每次 build 都是相同的固定內容,從 `entry.json`(no-store)讀當前 build 的 `?v=` 資產,書籤不會停在舊版。
270
+ build 需要在 UI build 目錄或專案根目錄安裝含 `/entry` 的 `@synopackageland/sdk`(缺少時 `MOBILE_SDK_ENTRY_MISSING`),
271
+ 且版本要支援 `ctx.entryURL`(0.53.45 以上;過舊時 `ENTRY_SDK_OUTDATED`)。`ctx.fullPage`、`ctx.appIcon`、`ctx.uiUpdate`、
272
+ SynoToken/session、`ctx.launchParams`/`onLaunch`、`entry` 權限照舊;分享與書籤用 `ctx.entryURL`(`ui.short_paths`
273
+ 有指向 `app` 的路徑時是短網址,否則是 entry 頁網址),App 內的位置放在 `?link=`。宣告 `identity_gateway` 的 App
274
+ 仍用 `type: "standalone"`(DSM 視窗要接續 OIDC 冷登入)。不需要 `pureEnv` 或 `allowAltPort`。
270
275
 
271
276
  Application Portal 是獨立 opt-in:不想要別名就省略 `portal`,不生成
272
277
  `defaultAlias`、Portal 面板/capability 或 Web Station alias;沒有 Portal
@@ -46,16 +46,23 @@ Capabilities are `download`, `open-external`, and `camera`. Intake accepts `url`
46
46
  check. `status` is accepted for the later launcher-status protocol; v1 does not
47
47
  invoke it. `min_shell` is a positive integer, default 1.
48
48
 
49
- Build writes `ui/app/mobile.json`, mobile icons and, for SDK Apps, `entry.html`
49
+ Build writes `ui/app/mobile.json`, mobile icons and, for SDK Apps, `entry.html`, `entry.json`
50
50
  and bundled `entry.js` into the SPK only. The generated DSM window loads
51
51
  `entry-context.js` and passes its existing session, host and privileged adapters
52
- to the same SDK context builder. One immutable content hash appears in
53
- the entry build meta tag, `bootEntryPage.build`, registration, and every generated
54
- entry script, stylesheet and icon URL. Module UI assets retain their immutable
55
- snapshot directory. The generated `bootEntryPage.appBundle` is the exact URL
56
- loaded by `mount`, including its build query. SDK boot preloads same-origin App
57
- assets while token/identity requests run; App execution still waits for verified
58
- identity. Classic bundles retain their script carrier and package dataset.
52
+ to the same SDK context builder. `entry.html` is the same fixed bytes in
53
+ every build; one immutable content hash appears in `entry.json` (the build and
54
+ the assets the page loads), `bootEntryPage.build`, registration, and every
55
+ generated entry script, stylesheet and icon URL. A `ui.launch: new-page` App
56
+ gets the same entry page without a mobile declaration. Module UI assets retain their immutable
57
+ snapshot directory. For a module UI, the generated `bootEntryPage.appBundle` is
58
+ the exact URL loaded by `mount`, including its build query; SDK boot preloads it
59
+ while token/identity requests run, and App execution still waits for verified
60
+ identity. Classic bundles retain their script carrier and package dataset and
61
+ are not preloaded (a classic script would load twice).
62
+ The SDK comes from the project: `@synopackageland/sdk` in the UI build
63
+ directory or the project root (`MOBILE_SDK_ENTRY_MISSING` otherwise);
64
+ `SYNOPKGLAND_ENTRY_SDK_DIR` may name an SDK package directory to use when the
65
+ project has none, for local development and tests.
59
66
  SDK boot owns token acquisition, non-aborting hedges, portal
60
67
  probing, language fallback and the package-specific identity cache.
61
68
 
@@ -50,10 +50,15 @@ SDK 原生內建預設為 `dsm-window`;使用 `@synopackageland/ui` 維持視
50
50
  Scaffold 明確寫入此選擇,plain/binary 使用 `new-page`,Vue UI SDK 使用
51
51
  預設的 `dsm-window`(省略 `ui.launch`)。原生 manifest 省略 `ui.launch` 時解析為 `dsm-window`,CLI 不猜測前端依賴。
52
52
 
53
- `new-page` 產生 DSM `type: "standalone"` launcher,主選單及套件中心皆在 DSM
54
- 本身的 origin 開啟全頁。`ctx.fullPage`、`ctx.appIcon`、`ctx.uiUpdate`、SynoToken/session、
55
- `ctx.launchParams`/`onLaunch`、`entry` 權限沿用共用 wrapper;全頁的標題、
56
- favicon 與手機 viewport 由 wrapper 設定。不需要 `pureEnv` 或 `allowAltPort`。
53
+ `new-page` 讓主選單與套件中心以 DSM `type: "url"` launcher 在新分頁開 App 的 entry 頁
54
+ `/webman/3rdparty/<package>/app/entry.html`(SDK `bootEntryPage`,不載入 DSM 桌面);Portal alias 與
55
+ `/?launchApp=…` 連結由 DSM 轉到同一頁(DSM 會丟掉 query、把 launchParam 拆成單一字元,SDK 都會處理)。
56
+ entry 頁每次 build 都是相同的固定內容,從 `entry.json`(no-store)讀當前 build 的 `?v=` 資產,書籤不會停在舊版。
57
+ build 需要在 UI build 目錄或專案根目錄安裝含 `/entry` 的 `@synopackageland/sdk`(缺少時 `MOBILE_SDK_ENTRY_MISSING`),
58
+ 且版本要支援 `ctx.entryURL`(0.53.45 以上;過舊時 `ENTRY_SDK_OUTDATED`)。`ctx.fullPage`、`ctx.appIcon`、`ctx.uiUpdate`、
59
+ SynoToken/session、`ctx.launchParams`/`onLaunch`、`entry` 權限照舊;分享與書籤用 `ctx.entryURL`(`ui.short_paths`
60
+ 有指向 `app` 的路徑時是短網址,否則是 entry 頁網址),App 內的位置放在 `?link=`。宣告 `identity_gateway` 的 App
61
+ 仍用 `type: "standalone"`(DSM 視窗要接續 OIDC 冷登入)。不需要 `pureEnv` 或 `allowAltPort`。
57
62
 
58
63
  Application Portal 是獨立 opt-in:不想要別名就省略 `portal`,不生成
59
64
  `defaultAlias`、Portal 面板/capability 或 Web Station alias;沒有 Portal
@@ -216,10 +216,15 @@ SDK 原生內建預設為 `dsm-window`;使用 `@synopackageland/ui` 維持視
216
216
  Scaffold 明確寫入此選擇,plain/binary 使用 `new-page`,Vue UI SDK 使用
217
217
  預設的 `dsm-window`(省略 `ui.launch`)。原生 manifest 省略 `ui.launch` 時解析為 `dsm-window`,CLI 不猜測前端依賴。
218
218
 
219
- `new-page` 產生 DSM `type: "standalone"` launcher,主選單及套件中心皆在 DSM
220
- 本身的 origin 開啟全頁。`ctx.fullPage`、`ctx.appIcon`、`ctx.uiUpdate`、SynoToken/session、
221
- `ctx.launchParams`/`onLaunch`、`entry` 權限沿用共用 wrapper;全頁的標題、
222
- favicon 與手機 viewport 由 wrapper 設定。不需要 `pureEnv` 或 `allowAltPort`。
219
+ `new-page` 讓主選單與套件中心以 DSM `type: "url"` launcher 在新分頁開 App 的 entry 頁
220
+ `/webman/3rdparty/<package>/app/entry.html`(SDK `bootEntryPage`,不載入 DSM 桌面);Portal alias 與
221
+ `/?launchApp=…` 連結由 DSM 轉到同一頁(DSM 會丟掉 query、把 launchParam 拆成單一字元,SDK 都會處理)。
222
+ entry 頁每次 build 都是相同的固定內容,從 `entry.json`(no-store)讀當前 build 的 `?v=` 資產,書籤不會停在舊版。
223
+ build 需要在 UI build 目錄或專案根目錄安裝含 `/entry` 的 `@synopackageland/sdk`(缺少時 `MOBILE_SDK_ENTRY_MISSING`),
224
+ 且版本要支援 `ctx.entryURL`(0.53.45 以上;過舊時 `ENTRY_SDK_OUTDATED`)。`ctx.fullPage`、`ctx.appIcon`、`ctx.uiUpdate`、
225
+ SynoToken/session、`ctx.launchParams`/`onLaunch`、`entry` 權限照舊;分享與書籤用 `ctx.entryURL`(`ui.short_paths`
226
+ 有指向 `app` 的路徑時是短網址,否則是 entry 頁網址),App 內的位置放在 `?link=`。宣告 `identity_gateway` 的 App
227
+ 仍用 `type: "standalone"`(DSM 視窗要接續 OIDC 冷登入)。不需要 `pureEnv` 或 `allowAltPort`。
223
228
 
224
229
  `ui.banner: shown | hidden` 決定 App 全頁(standalone)上方要不要有 DSM 橫幅
225
230
  (App 名稱與帳號選單)。預設 `shown`,維持 DSM 原本的樣子;`hidden` 只替這個 App
@@ -268,6 +273,7 @@ ui:
268
273
  ### Short paths
269
274
 
270
275
  穩定網址仍然很長。要讓使用者直接輸入 `https://<nas>:5001/connect`,加 `ui.short_paths`:路徑對應到 `stable_pages` 的頁名。
276
+ 值也可以是 `app`:轉到 App 的 entry 頁 `/webman/3rdparty/<package>/app/entry.html`(new-page 或 `mobile.entry: app` 的 App),`ctx.entryURL` 就用第一個這樣的短網址,App 自己加 `?link=`。
271
277
 
272
278
  ```yaml
273
279
  os_min_ver: "7.2-64570"