@synopackageland/cli 0.54.3 → 0.54.5

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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.54.5 (2026-11-15)
4
+
5
+ - The url launcher, a short path to `app` and the mobile `entry` open the fixed entry page as `launch.html`, a file name no earlier build used. Browsers cached the old build-specific `entry.html` as fresh for years (DSM sends package files without Cache-Control and with a 1970 Last-Modified), so after an upgrade the main menu could open the old build. `entry.html` keeps the same fixed content for old links. `inspect` checks both pages and reports a launcher that still points at `entry.html`.
6
+ - The generated entry page starts downloading the App's first screen while it signs in: the classic `app.js` as a preload and the first-screen modules listed in the build's `entry-preload.json` as `modulepreload`. App code still runs only after the identity is verified.
7
+ - Skill references name the entry SDK requirement without a release number.
8
+
9
+ ## 0.54.4 (2026-11-15)
10
+
11
+ - 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`.
12
+ - `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.
13
+ - `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`.
14
+ - 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.
15
+ - 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.
16
+
3
17
  ## 0.54.3 (2026-11-15)
4
18
 
5
19
  - `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,53 @@
1
+ import type { StandaloneManifest } from "./manifest.js";
2
+ /**
3
+ * The SDK entry page: `ui/app/launch.html`, served by DSM at
4
+ * `/webman/3rdparty/<package>/app/launch.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. Browsers treat such a file as fresh for years
8
+ * (heuristic freshness is a tenth of its age) and open it from the cache
9
+ * without asking DSM, even after an upgrade. The page is therefore fixed
10
+ * bytes, the same in every build and package: it reads the current build
11
+ * from `entry.json` with a no-store, cache-busted request and loads that
12
+ * build's `?v=` stamped module, stylesheet and icon.
13
+ *
14
+ * Before CLI 0.54.4, `entry.html` carried its build, so a browser that opened
15
+ * it keeps that build's page. Every launch therefore opens `launch.html`, a
16
+ * name no build ever served with other bytes; `entry.html` stays, as the same
17
+ * page, for older links. Changing the page's bytes needs a new file name.
18
+ */
19
+ export declare const ENTRY_PAGE_FILE = "launch.html";
20
+ /** The entry page's earlier name, kept with the same bytes for older links and registrations. */
21
+ export declare const LEGACY_ENTRY_PAGE_FILE = "entry.html";
22
+ export declare const ENTRY_POINTER_FILE = "entry.json";
23
+ export declare function entryPagePath(pkg: string): string;
24
+ /** The ui.short_paths target that names the entry page instead of a stable page. */
25
+ export declare const ENTRY_SHORT_PATH_TARGET = "app";
26
+ type LauncherManifest = Pick<StandaloneManifest, "compose" | "sdkWindow" | "console" | "identityGateway" | "ui">;
27
+ /**
28
+ * Main menu and Package Center open the entry page with a DSM url launcher:
29
+ * every native SDK window App that opens a full page (ui.launch: new-page).
30
+ * Not with a console (its Instance is the gateway's launcher) or an identity
31
+ * gateway (its DSM window resumes a cold OIDC sign-in from the launch).
32
+ */
33
+ export declare function entryLauncher(manifest: LauncherManifest): boolean;
34
+ /** Whether the build writes the entry page: the launcher's, or a mobile App entry's. */
35
+ export declare function hasEntryPage(manifest: LauncherManifest & Pick<StandaloneManifest, "mobile">): boolean;
36
+ /** The first short path (in path order) that opens the entry page; ctx.entryURL uses it. */
37
+ export declare function entryShortPath(manifest: Pick<StandaloneManifest, "ui">): string | undefined;
38
+ /** Fixed bytes: a cached copy from any build or package keeps working, since it reads entry.json.
39
+ * Never change them under the same file name (see ENTRY_PAGE_FILE). */
40
+ 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";
41
+ export interface EntryPointer {
42
+ v: 1;
43
+ build: string;
44
+ title: string;
45
+ icon: string;
46
+ css: string;
47
+ script: string;
48
+ }
49
+ /** The current build's assets, relative to the entry page. */
50
+ export declare function renderEntryPointer(build: string, title: string, css: string): string;
51
+ /** Undefined when entry.json names exactly this build's assets; otherwise why. */
52
+ export declare function entryPointerProblem(bytes: string, build: string): string | undefined;
53
+ export {};
@@ -0,0 +1,97 @@
1
+ import { resolvedSdkLaunch } from "../contract/app-launch.js";
2
+ /**
3
+ * The SDK entry page: `ui/app/launch.html`, served by DSM at
4
+ * `/webman/3rdparty/<package>/app/launch.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. Browsers treat such a file as fresh for years
8
+ * (heuristic freshness is a tenth of its age) and open it from the cache
9
+ * without asking DSM, even after an upgrade. The page is therefore fixed
10
+ * bytes, the same in every build and package: it reads the current build
11
+ * from `entry.json` with a no-store, cache-busted request and loads that
12
+ * build's `?v=` stamped module, stylesheet and icon.
13
+ *
14
+ * Before CLI 0.54.4, `entry.html` carried its build, so a browser that opened
15
+ * it keeps that build's page. Every launch therefore opens `launch.html`, a
16
+ * name no build ever served with other bytes; `entry.html` stays, as the same
17
+ * page, for older links. Changing the page's bytes needs a new file name.
18
+ */
19
+ export const ENTRY_PAGE_FILE = "launch.html";
20
+ /** The entry page's earlier name, kept with the same bytes for older links and registrations. */
21
+ export const LEGACY_ENTRY_PAGE_FILE = "entry.html";
22
+ export const ENTRY_POINTER_FILE = "entry.json";
23
+ export function entryPagePath(pkg) {
24
+ return `/webman/3rdparty/${pkg}/app/${ENTRY_PAGE_FILE}`;
25
+ }
26
+ /** The ui.short_paths target that names the entry page instead of a stable page. */
27
+ export const ENTRY_SHORT_PATH_TARGET = "app";
28
+ /**
29
+ * Main menu and Package Center open the entry page with a DSM url launcher:
30
+ * every native SDK window App that opens a full page (ui.launch: new-page).
31
+ * Not with a console (its Instance is the gateway's launcher) or an identity
32
+ * gateway (its DSM window resumes a cold OIDC sign-in from the launch).
33
+ */
34
+ export function entryLauncher(manifest) {
35
+ return !manifest.compose && manifest.sdkWindow !== false && !manifest.console && !manifest.identityGateway &&
36
+ resolvedSdkLaunch(manifest) === "new-page";
37
+ }
38
+ /** Whether the build writes the entry page: the launcher's, or a mobile App entry's. */
39
+ export function hasEntryPage(manifest) {
40
+ return manifest.mobile?.entry === "app" || entryLauncher(manifest);
41
+ }
42
+ /** The first short path (in path order) that opens the entry page; ctx.entryURL uses it. */
43
+ export function entryShortPath(manifest) {
44
+ const paths = manifest.ui?.shortPaths;
45
+ if (!paths)
46
+ return undefined;
47
+ return Object.entries(paths).filter(([, page]) => page === ENTRY_SHORT_PATH_TARGET).map(([path]) => path).sort()[0];
48
+ }
49
+ /** Fixed bytes: a cached copy from any build or package keeps working, since it reads entry.json.
50
+ * Never change them under the same file name (see ENTRY_PAGE_FILE). */
51
+ export const ENTRY_PAGE_STUB = `<!doctype html>
52
+ <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>
53
+ <body><div class="dsmapp-root"></div><noscript>This page needs JavaScript.</noscript><script>
54
+ (function () {
55
+ var asset = /^\\.\\/(?:[\\w~-][\\w.~-]*\\/)*[\\w~-][\\w.~-]*\\?v=[0-9a-f]{64}$/;
56
+ function fail() { document.body.textContent = "This page is not available. Reload to try again."; }
57
+ function add(parent, tag, attrs) { var node = document.createElement(tag); for (var key in attrs) node[key] = attrs[key]; parent.appendChild(node); return node; }
58
+ try {
59
+ fetch("${ENTRY_POINTER_FILE}?t=" + Date.now(), {cache: "no-store", credentials: "same-origin", redirect: "error"})
60
+ .then(function (r) { if (!r.ok) throw 0; return r.json(); })
61
+ .then(function (p) {
62
+ if (!p || p.v !== 1 || typeof p.title !== "string" || !asset.test(p.script) || !asset.test(p.css) || !asset.test(p.icon)) throw 0;
63
+ document.title = p.title;
64
+ add(document.head, "link", {rel: "icon", href: p.icon});
65
+ add(document.head, "link", {rel: "stylesheet", href: p.css});
66
+ add(document.body, "script", {type: "module", src: p.script, onerror: fail});
67
+ })
68
+ .catch(fail);
69
+ } catch (e) { fail(); }
70
+ })();
71
+ </script></body></html>
72
+ `;
73
+ /** The current build's assets, relative to the entry page. */
74
+ export function renderEntryPointer(build, title, css) {
75
+ const pointer = {
76
+ v: 1, build, title,
77
+ icon: `./icons/mobile-192.png?v=${build}`,
78
+ css: `${css}?v=${build}`,
79
+ script: `./entry.js?v=${build}`,
80
+ };
81
+ return `${JSON.stringify(pointer)}\n`;
82
+ }
83
+ /** Undefined when entry.json names exactly this build's assets; otherwise why. */
84
+ export function entryPointerProblem(bytes, build) {
85
+ let pointer;
86
+ try {
87
+ pointer = JSON.parse(bytes);
88
+ }
89
+ catch {
90
+ return "entry.json is not JSON";
91
+ }
92
+ if (!pointer || pointer.v !== 1 || pointer.build !== build || typeof pointer.title !== "string" ||
93
+ pointer.icon !== `./icons/mobile-192.png?v=${build}` || pointer.script !== `./entry.js?v=${build}` ||
94
+ typeof pointer.css !== "string" || !/^\.\/(?:[a-f0-9]{64}\/)?app\.css\?v=[a-f0-9]{64}$/.test(pointer.css) || !pointer.css.endsWith(`?v=${build}`))
95
+ return "entry.json does not name this build's entry assets";
96
+ return undefined;
97
+ }
@@ -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,40 @@ 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. */
47
- export declare function renderMobileAssets(manifest: StandaloneManifest, uiDigest: string, moduleVersion?: string): Promise<MobileAssets | undefined>;
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. */
65
+ /** The App's first-screen ES modules: an optional `entry-preload.json` at the
66
+ * root of the UI directory, written by the App's own build, lists up to 16
67
+ * paths relative to that directory (for example its main chunk). */
68
+ export declare const ENTRY_PRELOAD_FILE = "entry-preload.json";
69
+ export declare function entryPreload(appDir: string | undefined): string[];
70
+ export declare function renderMobileAssets(manifest: StandaloneManifest, uiDigest: string, moduleVersion?: string, appDir?: string): Promise<MobileAssets | undefined>;
71
+ /** Validate the entry page record before using any of its paths. */
72
+ export declare function entryRecordProblem(record: unknown): string | undefined;
73
+ /** The recorded files as built: the fixed page, this build's pointer and digests. */
74
+ export declare function inspectEntryFiles(root: string, record: EntryRecord): string | undefined;
48
75
  /** Validate the replay inventory before using any of its paths. */
49
76
  export declare function mobileRecordProblem(record: unknown): string | undefined;
50
77
  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_FILE, ENTRY_PAGE_STUB, ENTRY_POINTER_FILE, LEGACY_ENTRY_PAGE_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);
@@ -35,7 +37,7 @@ export function mobileRegistration(record) {
35
37
  return {
36
38
  schema: 1, package: record.package, version: record.version, build: record.build,
37
39
  name: record.name, icon: `./icons/mobile-192.png?v=${record.build}`,
38
- entry: mobile.entry === 'app' ? 'entry.html' : record.gatewayEntry,
40
+ entry: mobile.entry === 'app' ? ENTRY_PAGE_FILE : record.gatewayEntry,
39
41
  ...(record.portal ? { portal: record.portal } : {}),
40
42
  start: mobile.start ?? '/', capabilities: mobile.capabilities ?? [],
41
43
  ...(mobile.intake ? { intake: mobile.intake } : {}), status: mobile.status ?? false, minShell: mobile.min_shell ?? 1,
@@ -43,35 +45,110 @@ 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. */
65
- export async function renderMobileAssets(manifest, uiDigest, moduleVersion) {
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. */
121
+ /** The App's first-screen ES modules: an optional `entry-preload.json` at the
122
+ * root of the UI directory, written by the App's own build, lists up to 16
123
+ * paths relative to that directory (for example its main chunk). */
124
+ export const ENTRY_PRELOAD_FILE = 'entry-preload.json';
125
+ export function entryPreload(appDir) {
126
+ const file = appDir && join(appDir, ENTRY_PRELOAD_FILE);
127
+ if (!file || !existsSync(file))
128
+ return [];
129
+ let list;
130
+ try {
131
+ list = JSON.parse(readFileSync(file, 'utf8'));
132
+ }
133
+ catch {
134
+ list = undefined;
135
+ }
136
+ if (!Array.isArray(list) || list.length > 16 || !list.every(path => typeof path === 'string' &&
137
+ /^(?:[\w~-][\w.~-]*\/)*[\w~-][\w.~-]*\.m?js$/.test(path) && existsSync(join(appDir, path))))
138
+ throw new Error(`[ENTRY_PRELOAD_INVALID] ${ENTRY_PRELOAD_FILE} must be a JSON array of at most 16 .js or .mjs files in the UI directory, as relative paths without ".."`);
139
+ return list;
140
+ }
141
+ export async function renderMobileAssets(manifest, uiDigest, moduleVersion, appDir) {
66
142
  const mobile = manifest.mobile;
67
- if (!mobile)
143
+ const entry = hasEntryPage(manifest);
144
+ if (!mobile && !entry)
68
145
  return undefined;
69
- const icons = mobileIcons(mobile.icon ? mobileIconPath(manifest.root, mobile.icon) : manifest.icon);
70
- const name = { en: mobile.name ?? manifest.displayname };
146
+ const icons = mobileIcons(mobile?.icon ? mobileIconPath(manifest.root, mobile.icon) : manifest.icon);
147
+ const name = { en: mobile?.name ?? manifest.displayname };
71
148
  for (const [locale, text] of Object.entries(manifest.i18n?.info ?? {}))
72
149
  if (text?.mobile_name || text?.displayname)
73
150
  name[locale] = text.mobile_name ?? text.displayname;
74
- const record = {
151
+ const record = mobile && {
75
152
  declaration: mobile, package: manifest.package, version: manifest.spkVersion, build: '', name,
76
153
  ...(manifest.portal ? { portal: { defaultAlias: manifest.portal.alias } } : {}),
77
154
  ...(mobile.entry === 'gateway' ? { gatewayEntry: gatewayEntryPath(manifest) } : {}), files: {},
@@ -80,7 +157,7 @@ export async function renderMobileAssets(manifest, uiDigest, moduleVersion) {
80
157
  for (const [size, png] of icons)
81
158
  files.set(`icons/mobile-${size}.png`, png);
82
159
  let runtime = '';
83
- const approval = mobile.entry === 'app' && manifest.executor
160
+ const approval = entry && manifest.executor
84
161
  ? `var executorApproval = {};
85
162
  ${renderExecutorApproval('executorApproval', manifest)}
86
163
  ${CALL_RETRY_RUNTIME}
@@ -98,25 +175,37 @@ function attachExecutor(ctx, desktopWebApi) {
98
175
  }
99
176
  ` : '';
100
177
  const requestTimeout = requestTimeoutSeconds(manifest.backend) * 1000 + appSdkTimeouts(manifest.backend).browserMarginMs;
101
- if (mobile.entry === 'app') {
178
+ const daemonIngress = entry ? statusIngress(manifest) : undefined;
179
+ if (entry) {
102
180
  const result = await build({ entryPoints: [entryModule(manifest)], bundle: true, write: false, format: 'esm', platform: 'browser', target: 'es2022', minify: true, keepNames: true, legalComments: 'none' });
103
181
  runtime = result.outputFiles[0].text;
182
+ const outdated = entryLauncher(manifest) ? entryRuntimeProblem(runtime, entrySdkVersion(entryModule(manifest))) : undefined;
183
+ if (outdated)
184
+ throw new Error(outdated);
104
185
  }
105
186
  // 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 }));
187
+ const shortPath = entry ? entryShortPath(manifest) : undefined;
188
+ const hash = createHash('sha256').update(readFileSync(new URL(import.meta.url))).update(uiDigest).update(record ? json(mobileRegistration(record)) : '').update(runtime)
189
+ .update(json({ generator: CLI_VERSION, requestTimeout, messages: manifest.i18n?.catalogs, daemonIngress, shortPath, launcher: entryLauncher(manifest) }));
108
190
  if (approval)
109
191
  hash.update(approval);
110
192
  for (const [path, bytes] of files)
111
193
  hash.update(path).update(bytes);
112
194
  const version = hash.digest('hex');
113
- if (mobile.entry === 'app') {
195
+ if (entry) {
114
196
  const appBundle = `${moduleVersion ? `./${moduleVersion}/${MODULE_UI_ENTRY}` : './app.js'}?v=${version}`;
197
+ // Chunks keep the URL the App resolves against its own script: no query.
198
+ const preload = entryPreload(appDir).map(path => `./${moduleVersion ? `${moduleVersion}/` : ''}${path}`);
115
199
  const options = {
116
200
  packageId: manifest.package, build: version, displayName: name.en,
117
- appIcon: `./icons/mobile-192.png?v=${version}`, appBundle,
201
+ // Downloaded while identity is pending, run only by mount: a module as
202
+ // modulepreload, a classic app.js as preload (as=script).
203
+ appIcon: `./icons/mobile-192.png?v=${version}`, ...(moduleVersion ? { appBundle } : { appScript: appBundle }),
204
+ ...(preload.length ? { preload } : {}),
118
205
  ...(manifest.portal ? { portal: { defaultAlias: manifest.portal.alias } } : {}),
206
+ ...(shortPath ? { shortPath } : {}),
119
207
  requestTimeout,
208
+ ...(daemonIngress ? { daemonIngress } : {}),
120
209
  ...(manifest.i18n?.catalogs ? { messages: manifest.i18n.catalogs } : {}),
121
210
  };
122
211
  // Classic bundles rely on document.currentScript.dataset.package; keep
@@ -133,13 +222,44 @@ function attachExecutor(ctx, desktopWebApi) {
133
222
  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
223
  files.set('entry-context.js', Buffer.from(context.outputFiles[0].text));
135
224
  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`));
225
+ files.set(ENTRY_PAGE_FILE, Buffer.from(ENTRY_PAGE_STUB));
226
+ files.set(LEGACY_ENTRY_PAGE_FILE, Buffer.from(ENTRY_PAGE_STUB));
227
+ files.set(ENTRY_POINTER_FILE, Buffer.from(renderEntryPointer(version, name.en, css)));
228
+ }
229
+ if (record) {
230
+ record.build = version;
231
+ files.set('mobile.json', Buffer.from(JSON.stringify(mobileRegistration(record), null, 2) + '\n'));
232
+ }
233
+ const inventory = Object.fromEntries([...files].map(([path, bytes]) => [path, digest(bytes)]));
234
+ if (record)
235
+ record.files = inventory;
236
+ return { build: version, files, ...(record ? { record } : {}),
237
+ ...(entry ? { entry: { build: version, launcher: entryLauncher(manifest), files: Object.fromEntries(Object.entries(inventory).filter(([path]) => path !== 'mobile.json')) } } : {}) };
238
+ }
239
+ const ENTRY_FILES = [ENTRY_PAGE_FILE, LEGACY_ENTRY_PAGE_FILE, ENTRY_POINTER_FILE, 'entry.js', 'entry-context.js', 'icons/mobile-192.png', 'icons/mobile-512.png'];
240
+ /** Validate the entry page record before using any of its paths. */
241
+ export function entryRecordProblem(record) {
242
+ const r = record;
243
+ 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')
244
+ return 'invalid entry page record';
245
+ const paths = Object.keys(r.files);
246
+ if (paths.length !== ENTRY_FILES.length || !ENTRY_FILES.every(path => typeof r.files[path] === 'string' && /^[a-f0-9]{64}$/.test(r.files[path])))
247
+ return 'invalid entry page inventory';
248
+ return undefined;
249
+ }
250
+ /** The recorded files as built: the fixed page, this build's pointer and digests. */
251
+ export function inspectEntryFiles(root, record) {
252
+ const invalid = entryRecordProblem(record);
253
+ if (invalid)
254
+ return invalid;
255
+ for (const [path, hash] of Object.entries(record.files)) {
256
+ if (!existsSync(join(root, path)) || digest(readFileSync(join(root, path))) !== hash)
257
+ return `${path} differs from the generated build`;
137
258
  }
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 };
259
+ for (const page of [ENTRY_PAGE_FILE, LEGACY_ENTRY_PAGE_FILE])
260
+ if (readFileSync(join(root, page), 'utf8') !== ENTRY_PAGE_STUB)
261
+ return `${page} is not the fixed entry page`;
262
+ return entryPointerProblem(readFileSync(join(root, ENTRY_POINTER_FILE), 'utf8'), record.build);
143
263
  }
144
264
  /** Validate the replay inventory before using any of its paths. */
145
265
  export function mobileRecordProblem(record) {
@@ -158,10 +278,10 @@ export function mobileRecordProblem(record) {
158
278
  return 'invalid gateway entry';
159
279
  if (r.portal && !isPortalAlias(r.portal.defaultAlias))
160
280
  return 'invalid portal alias';
161
- 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'])))
281
+ if (!r.files['mobile.json'] || !r.files['icons/mobile-192.png'] || !r.files['icons/mobile-512.png'] || (r.declaration.entry === 'app' && (!r.files[ENTRY_PAGE_FILE] || !r.files[LEGACY_ENTRY_PAGE_FILE] || !r.files['entry.js'] || !r.files['entry-context.js'])))
162
282
  return 'missing registration or icon inventory';
163
283
  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))
284
+ if (!/^(entry\.(?:html|js|json)|launch\.html|entry-context\.js|mobile\.json|icons\/mobile-(?:192|512)\.png)$/.test(path) || typeof hash !== 'string' || !/^[a-f0-9]{64}$/.test(hash))
165
285
  return 'invalid asset inventory';
166
286
  return undefined;
167
287
  }
@@ -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
@@ -110,7 +110,7 @@ export async function assembleStandaloneSpk(options) {
110
110
  precompressUiTree(appDir);
111
111
  const moduleUi = hasSdkWindow(manifest) && existsSync(join(appDir, MODULE_UI_ENTRY));
112
112
  const uiDigest = uiTreeDigest(appDir, moduleUi);
113
- const mobile = await renderMobileAssets(manifest, uiDigest, moduleUi ? uiDigest : undefined);
113
+ const mobile = await renderMobileAssets(manifest, uiDigest, moduleUi ? uiDigest : undefined, appDir);
114
114
  const assetVersion = mobile?.build ?? uiDigest.slice(0, 12);
115
115
  const moduleVersion = moduleUi ? uiDigest : undefined;
116
116
  if (moduleVersion) {
@@ -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.5",
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
@@ -5,7 +5,7 @@ description: Initialize, extend, check, build, inspect, and deploy Synology appl
5
5
 
6
6
  # Independent Synology SPKs
7
7
 
8
- Files under ui/ (including mobile.json and entry.html) are public static files readable without sign-in; never put secrets there. Access control is the EntryGate/backend.
8
+ Files under ui/ (including mobile.json, launch.html and entry.html) are public static files readable without sign-in; never put secrets there. Access control is the EntryGate/backend.
9
9
 
10
10
  For native DSM strings and fixed desktop notifications, read
11
11
  [reference/dsm-texts.md](reference/dsm-texts.md) (`synopkgland skill show dsm-texts`).
@@ -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/launch.html`(SDK `bootEntryPage`,不載入 DSM 桌面);Portal alias 與
351
+ `/?launchApp=…` 連結由 DSM 轉到同一頁(DSM 會丟掉 query、把 launchParam 拆成單一字元,SDK 都會處理)。
352
+ entry 頁每次 build 都是相同的固定內容,從 `entry.json`(no-store)讀當前 build 的 `?v=` 資產,書籤不會停在舊版。較早 CLI 的 `entry.html` 內含 build,瀏覽器會把它當成多年有效的快取、升級後仍直接開舊版,所以入口改用從未有過舊內容的 `launch.html`;`entry.html` 保留相同的固定內容給舊連結。
353
+ build 需要在 UI build 目錄或專案根目錄安裝含 `/entry` 的 `@synopackageland/sdk`(缺少時 `MOBILE_SDK_ENTRY_MISSING`),
354
+ 且要用支援 `ctx.entryURL` 的 SDK(過舊時 `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/launch.html`(SDK `bootEntryPage`,不載入 DSM 桌面);Portal alias 與
268
+ `/?launchApp=…` 連結由 DSM 轉到同一頁(DSM 會丟掉 query、把 launchParam 拆成單一字元,SDK 都會處理)。
269
+ entry 頁每次 build 都是相同的固定內容,從 `entry.json`(no-store)讀當前 build 的 `?v=` 資產,書籤不會停在舊版。較早 CLI 的 `entry.html` 內含 build,瀏覽器會把它當成多年有效的快取、升級後仍直接開舊版,所以入口改用從未有過舊內容的 `launch.html`;`entry.html` 保留相同的固定內容給舊連結。
270
+ build 需要在 UI build 目錄或專案根目錄安裝含 `/entry` 的 `@synopackageland/sdk`(缺少時 `MOBILE_SDK_ENTRY_MISSING`),
271
+ 且要用支援 `ctx.entryURL` 的 SDK(過舊時 `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
@@ -1,6 +1,6 @@
1
1
  # Mobile Apps
2
2
 
3
- Files under ui/ (including mobile.json and entry.html) are public static files readable without sign-in; never put secrets there. Access control is the EntryGate/backend.
3
+ Files under ui/ (including mobile.json, launch.html and entry.html) are public static files readable without sign-in; never put secrets there. Access control is the EntryGate/backend.
4
4
 
5
5
  Declare `mobile` in `dsm-package.yaml`. Both `admin-only` and `app-privilege`
6
6
  Apps may register. DSM entry and backend permissions still apply to every request.
@@ -46,16 +46,35 @@ 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, `launch.html`, `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. `launch.html` is the same fixed bytes in
53
+ every build, and the registration's `entry`: browsers keep DSM's package files
54
+ for years without asking, and older CLIs put the build in `entry.html`,
55
+ so a browser that opened it keeps that page after an upgrade. `entry.html`
56
+ stays, with the same fixed bytes, for older links; one immutable content hash appears in `entry.json` (the build and
57
+ the assets the page loads), `bootEntryPage.build`, registration, and every
58
+ generated entry script, stylesheet and icon URL. A `ui.launch: new-page` App
59
+ gets the same entry page without a mobile declaration. Module UI assets retain their immutable
60
+ snapshot directory. For a module UI, the generated `bootEntryPage.appBundle` is
61
+ the exact URL loaded by `mount`, including its build query; SDK boot preloads it
62
+ while token/identity requests run, and App execution still waits for verified
63
+ identity. Classic bundles retain their script carrier and package dataset; the
64
+ generated `bootEntryPage.appScript` preloads the same `app.js?v=` URL as a
65
+ script (`<link rel="preload" as="script">`), so the script element reuses the
66
+ download and still runs only after identity. A UI build may also write
67
+ `entry-preload.json` at the root of the UI directory: a JSON array of at most 16
68
+ `.js`/`.mjs` paths relative to it (for example `["chunks/main-1a2b.js"]`) that
69
+ the first screen imports. The entry passes them as `bootEntryPage.preload` for a
70
+ `modulepreload` during the same wait, at the URL the App resolves against its
71
+ own script (no `?v=`). A missing file, a path outside the UI directory or more
72
+ than 16 entries fails the build (`ENTRY_PRELOAD_INVALID`). A language chunk
73
+ depends on the verified locale; the App hints it when it mounts.
74
+ The SDK comes from the project: `@synopackageland/sdk` in the UI build
75
+ directory or the project root (`MOBILE_SDK_ENTRY_MISSING` otherwise);
76
+ `SYNOPKGLAND_ENTRY_SDK_DIR` may name an SDK package directory to use when the
77
+ project has none, for local development and tests.
59
78
  SDK boot owns token acquisition, non-aborting hedges, portal
60
79
  probing, language fallback and the package-specific identity cache.
61
80
 
@@ -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/launch.html`(SDK `bootEntryPage`,不載入 DSM 桌面);Portal alias 與
55
+ `/?launchApp=…` 連結由 DSM 轉到同一頁(DSM 會丟掉 query、把 launchParam 拆成單一字元,SDK 都會處理)。
56
+ entry 頁每次 build 都是相同的固定內容,從 `entry.json`(no-store)讀當前 build 的 `?v=` 資產,書籤不會停在舊版。較早 CLI 的 `entry.html` 內含 build,瀏覽器會把它當成多年有效的快取、升級後仍直接開舊版,所以入口改用從未有過舊內容的 `launch.html`;`entry.html` 保留相同的固定內容給舊連結。
57
+ build 需要在 UI build 目錄或專案根目錄安裝含 `/entry` 的 `@synopackageland/sdk`(缺少時 `MOBILE_SDK_ENTRY_MISSING`),
58
+ 且要用支援 `ctx.entryURL` 的 SDK(過舊時 `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
@@ -1,6 +1,6 @@
1
1
  # Vue UI for DSM apps
2
2
 
3
- Files under ui/ (including mobile.json and entry.html) are public static files readable without sign-in; never put secrets there. Access control is the EntryGate/backend.
3
+ Files under ui/ (including mobile.json, launch.html and entry.html) are public static files readable without sign-in; never put secrets there. Access control is the EntryGate/backend.
4
4
 
5
5
  `build` minifies packaged JS/CSS and removes `.map` files and their JS/CSS comments.
6
6
  `check` scans the current UI output; `check path/to/package.spk` scans the final
@@ -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/launch.html`(SDK `bootEntryPage`,不載入 DSM 桌面);Portal alias 與
221
+ `/?launchApp=…` 連結由 DSM 轉到同一頁(DSM 會丟掉 query、把 launchParam 拆成單一字元,SDK 都會處理)。
222
+ entry 頁每次 build 都是相同的固定內容,從 `entry.json`(no-store)讀當前 build 的 `?v=` 資產,書籤不會停在舊版。較早 CLI 的 `entry.html` 內含 build,瀏覽器會把它當成多年有效的快取、升級後仍直接開舊版,所以入口改用從未有過舊內容的 `launch.html`;`entry.html` 保留相同的固定內容給舊連結。
223
+ build 需要在 UI build 目錄或專案根目錄安裝含 `/entry` 的 `@synopackageland/sdk`(缺少時 `MOBILE_SDK_ENTRY_MISSING`),
224
+ 且要用支援 `ctx.entryURL` 的 SDK(過舊時 `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/launch.html`(new-page 或 `mobile.entry: app` 的 App),`ctx.entryURL` 就用第一個這樣的短網址,App 自己加 `?link=`。
271
277
 
272
278
  ```yaml
273
279
  os_min_ver: "7.2-64570"