@synopackageland/cli 0.52.10 → 0.52.13
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 +15 -0
- package/dist/build-spk/install-wizard.d.ts +5 -1
- package/dist/build-spk/install-wizard.js +31 -4
- package/dist/build-spk/wizard-messages.d.ts +22 -0
- package/dist/build-spk/wizard-messages.js +22 -0
- package/dist/error-registry.js +1 -0
- package/dist/standalone/host-adapter.d.ts +1 -1
- package/dist/standalone/host-adapter.js +57 -0
- package/dist/standalone/host-types.d.ts +1 -1
- package/dist/standalone/inspect-spk.d.ts +1 -0
- package/dist/standalone/inspect-spk.js +37 -10
- package/dist/standalone/install-memory.d.ts +9 -0
- package/dist/standalone/install-memory.js +52 -0
- package/dist/standalone/lifecycle.js +2 -1
- package/dist/standalone/manifest.d.ts +2 -0
- package/dist/standalone/manifest.js +3 -0
- package/dist/standalone/shared-folder.d.ts +1 -1
- package/dist/standalone/shared-folder.js +13 -6
- package/dist/standalone/spk.js +3 -2
- package/docs/app-entry.md +17 -0
- package/docs/install-memory.md +20 -0
- package/package.json +3 -2
- package/schema/dsm-package.schema.json +15 -0
- package/skills/SKILL.md +2 -0
- package/skills/reference/install.md +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.52.13
|
|
4
|
+
|
|
5
|
+
- Add `install.min_memory_mb` for dynamic physical RAM admission on install and upgrade, independent of NAS model
|
|
6
|
+
- Integrate localized low-memory pages with the existing install and upgrade wizards and repeat the check in package-account preinst
|
|
7
|
+
- Warn and allow installation when MemTotal cannot be read; keep runtime/start behavior unchanged
|
|
8
|
+
- Inspect packaged requirements, wizard files and preinst checks against the same declaration
|
|
9
|
+
|
|
10
|
+
## 0.52.11
|
|
11
|
+
|
|
12
|
+
- Bridge `window-activated` from the injected DSM AppWindow, including switching
|
|
13
|
+
back and showing a minimized window, without observing desktop document focus.
|
|
14
|
+
- Coalesce adjacent full-page visible/focus and window activation signals; cancel
|
|
15
|
+
queued callbacks on deactivation, hiding, subscription disposal or host disposal.
|
|
16
|
+
- Keep existing resize subscriptions and unsupported theme/language events.
|
|
17
|
+
|
|
3
18
|
## 0.52.10
|
|
4
19
|
|
|
5
20
|
- Supply the file-delegate declaration to desktop and mobile executor approval so WebAPI-only Apps can approve without file scope queries
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { type Locale } from "../standalone/i18n.js";
|
|
1
2
|
import { type Translate } from "./wizard-i18n.js";
|
|
2
3
|
/** One step of a DSM install wizard; `items` are rendered verbatim as JSON. */
|
|
3
4
|
export interface InstallWizardStep {
|
|
4
5
|
step_title: string;
|
|
5
6
|
items: Array<Record<string, unknown>>;
|
|
6
7
|
activeate?: string;
|
|
8
|
+
invalid_next_disabled_v2?: boolean;
|
|
7
9
|
}
|
|
8
10
|
/** The static JSON wizard per locale, and the dynamic script per locale. */
|
|
9
11
|
export interface InstallWizardFiles {
|
|
@@ -16,7 +18,9 @@ export interface InstallWizardFiles {
|
|
|
16
18
|
* versions and flows that do not run the dynamic script; both carry the same
|
|
17
19
|
* items, and only the dynamic one adds the reuse notice when data exists.
|
|
18
20
|
*/
|
|
19
|
-
export declare function renderInstallWizardFiles(packageName: string, render: (t: Translate) => InstallWizardStep[]): InstallWizardFiles;
|
|
21
|
+
export declare function renderInstallWizardFiles(packageName: string, render: (t: Translate) => InstallWizardStep[], minMemoryMb?: number): InstallWizardFiles;
|
|
22
|
+
/** Prepend to an existing dynamic wizard; retain its normal pages when memory is sufficient. */
|
|
23
|
+
export declare function renderMemoryWizardCheck(minMemoryMb: number | undefined, locale: Locale): string;
|
|
20
24
|
/** Lists the App's unauthenticated service callbacks for the administrator. */
|
|
21
25
|
export declare function integrationWizardSteps(t: Translate, methods?: readonly string[]): InstallWizardStep[];
|
|
22
26
|
/** The native-go install step: no parameters, only the app-space consent. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DSM_LANGS, LOCALES } from "../standalone/i18n.js";
|
|
2
2
|
import { renderWizardFiles, translator } from "./wizard-i18n.js";
|
|
3
|
+
import { memoryReason, renderMemoryProbe } from "../standalone/install-memory.js";
|
|
3
4
|
const BASE = "install_uifile";
|
|
4
5
|
function shellQuote(value) {
|
|
5
6
|
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
@@ -26,11 +27,11 @@ function withReuseNotice(steps, packageName, t) {
|
|
|
26
27
|
* is chosen after the wizard on some flows). The wizard JSON is written to
|
|
27
28
|
* `SYNOPKG_TEMP_LOGFILE`, DSM's documented channel, or stdout without it.
|
|
28
29
|
*/
|
|
29
|
-
function renderDynamicScript(packageName, withData, withoutData) {
|
|
30
|
+
function renderDynamicScript(packageName, withData, withoutData, memoryCheck = "") {
|
|
30
31
|
return `#!/bin/sh
|
|
31
32
|
# Generated by synopkgland. Read-only: it checks whether this package already
|
|
32
33
|
# has App Data on a volume, then prints the install wizard for this language.
|
|
33
|
-
pkg=${shellQuote(packageName)}
|
|
34
|
+
${memoryCheck}pkg=${shellQuote(packageName)}
|
|
34
35
|
existing=
|
|
35
36
|
for root in \${SYNOPKG_PKGDEST_VOL:-} /volume*; do
|
|
36
37
|
if [ -n "$root" ] && [ -d "$root/@appdata/$pkg" ]; then
|
|
@@ -58,7 +59,7 @@ fi
|
|
|
58
59
|
* versions and flows that do not run the dynamic script; both carry the same
|
|
59
60
|
* items, and only the dynamic one adds the reuse notice when data exists.
|
|
60
61
|
*/
|
|
61
|
-
export function renderInstallWizardFiles(packageName, render) {
|
|
62
|
+
export function renderInstallWizardFiles(packageName, render, minMemoryMb) {
|
|
62
63
|
const staticFiles = renderWizardFiles(BASE, render);
|
|
63
64
|
const dynamic = {};
|
|
64
65
|
for (const locale of LOCALES) {
|
|
@@ -66,10 +67,36 @@ export function renderInstallWizardFiles(packageName, render) {
|
|
|
66
67
|
const steps = render(t);
|
|
67
68
|
const withData = JSON.stringify(withReuseNotice(steps, packageName, t), null, 2);
|
|
68
69
|
const withoutData = JSON.stringify(steps, null, 2);
|
|
69
|
-
dynamic[localeName(locale, ".sh")] = renderDynamicScript(packageName, withData, withoutData);
|
|
70
|
+
dynamic[localeName(locale, ".sh")] = renderDynamicScript(packageName, withData, withoutData, renderMemoryWizardCheck(minMemoryMb, locale));
|
|
70
71
|
}
|
|
71
72
|
return { static: staticFiles, dynamic };
|
|
72
73
|
}
|
|
74
|
+
/** Prepend to an existing dynamic wizard; retain its normal pages when memory is sufficient. */
|
|
75
|
+
export function renderMemoryWizardCheck(minMemoryMb, locale) {
|
|
76
|
+
if (minMemoryMb === undefined)
|
|
77
|
+
return "";
|
|
78
|
+
const reason = memoryReason(minMemoryMb, locale, "__SYNOPKGLAND_MEMORY_GB__");
|
|
79
|
+
const page = [{
|
|
80
|
+
step_title: translator(locale)("memory.title"),
|
|
81
|
+
invalid_next_disabled_v2: true,
|
|
82
|
+
items: [{ type: "textfield", desc: reason, subitems: [{
|
|
83
|
+
key: "pkgwizard_memory_requirement", desc: "", defaultValue: "__SYNOPKGLAND_MEMORY_GB__",
|
|
84
|
+
readOnly: true, validator: { allowBlank: false, fn: `{return ${JSON.stringify(reason)}}` },
|
|
85
|
+
}] }],
|
|
86
|
+
}];
|
|
87
|
+
// Only a formatted numeric value enters JSON, never shell or meminfo text.
|
|
88
|
+
const json = JSON.stringify(page, null, 2);
|
|
89
|
+
return `${renderMemoryProbe(minMemoryMb)}if [ -n "$synopkgland_memory_low" ]; then
|
|
90
|
+
if [ -n "\${SYNOPKG_TEMP_LOGFILE:-}" ]; then
|
|
91
|
+
exec > "$SYNOPKG_TEMP_LOGFILE"
|
|
92
|
+
fi
|
|
93
|
+
sed "s/__SYNOPKGLAND_MEMORY_GB__/$synopkgland_memory_gb/g" <<'SYNOPKGLAND_MEMORY_WIZARD'
|
|
94
|
+
${json}
|
|
95
|
+
SYNOPKGLAND_MEMORY_WIZARD
|
|
96
|
+
exit 0
|
|
97
|
+
fi
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
73
100
|
/** Lists the App's unauthenticated service callbacks for the administrator. */
|
|
74
101
|
export function integrationWizardSteps(t, methods = []) {
|
|
75
102
|
return methods.length ? [{ step_title: t("integration.step"), items: [{ desc: t("integration.notice", { methods: methods.join(", ") }) }] }] : [];
|
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
export declare const WIZARD_MESSAGES: {
|
|
2
|
+
"memory.title": {
|
|
3
|
+
en: string;
|
|
4
|
+
"zh-TW": string;
|
|
5
|
+
"zh-CN": string;
|
|
6
|
+
ja: string;
|
|
7
|
+
ko: string;
|
|
8
|
+
de: string;
|
|
9
|
+
fr: string;
|
|
10
|
+
es: string;
|
|
11
|
+
it: string;
|
|
12
|
+
};
|
|
13
|
+
"memory.required": {
|
|
14
|
+
en: string;
|
|
15
|
+
"zh-TW": string;
|
|
16
|
+
"zh-CN": string;
|
|
17
|
+
ja: string;
|
|
18
|
+
ko: string;
|
|
19
|
+
de: string;
|
|
20
|
+
fr: string;
|
|
21
|
+
es: string;
|
|
22
|
+
it: string;
|
|
23
|
+
};
|
|
2
24
|
"ports.http": {
|
|
3
25
|
en: string;
|
|
4
26
|
"zh-TW": string;
|
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
export const WIZARD_MESSAGES = {
|
|
2
|
+
"memory.title": {
|
|
3
|
+
"en": "Memory requirement",
|
|
4
|
+
"zh-TW": "記憶體需求",
|
|
5
|
+
"zh-CN": "内存要求",
|
|
6
|
+
"ja": "必要なメモリ",
|
|
7
|
+
"ko": "메모리 요구 사항",
|
|
8
|
+
"de": "Arbeitsspeicheranforderung",
|
|
9
|
+
"fr": "Mémoire requise",
|
|
10
|
+
"es": "Memoria necesaria",
|
|
11
|
+
"it": "Memoria richiesta"
|
|
12
|
+
},
|
|
13
|
+
"memory.required": {
|
|
14
|
+
"en": "This App requires at least {required} GB of RAM; this NAS has {actual} GB",
|
|
15
|
+
"zh-TW": "此應用程式需要至少 {required} GB 記憶體,此 NAS 有 {actual} GB",
|
|
16
|
+
"zh-CN": "此应用程序需要至少 {required} GB 内存,此 NAS 有 {actual} GB",
|
|
17
|
+
"ja": "このアプリには {required} GB 以上の RAM が必要です。この NAS のメモリは {actual} GB です",
|
|
18
|
+
"ko": "이 앱에는 최소 {required} GB의 RAM이 필요합니다. 이 NAS의 메모리는 {actual} GB입니다",
|
|
19
|
+
"de": "Diese App benötigt mindestens {required} GB RAM; dieses NAS verfügt über {actual} GB",
|
|
20
|
+
"fr": "Cette application nécessite au moins {required} Go de RAM ; ce NAS dispose de {actual} Go",
|
|
21
|
+
"es": "Esta aplicación requiere al menos {required} GB de RAM; este NAS tiene {actual} GB",
|
|
22
|
+
"it": "Questa app richiede almeno {required} GB di RAM; questo NAS dispone di {actual} GB"
|
|
23
|
+
},
|
|
2
24
|
"ports.http": {
|
|
3
25
|
"en": "HTTP port",
|
|
4
26
|
"zh-TW": "HTTP 連接埠",
|
package/dist/error-registry.js
CHANGED
|
@@ -50,6 +50,7 @@ export const ERROR_REGISTRY = {
|
|
|
50
50
|
DSM_WINDOW_COLOR_SCHEME: { code: 'DSM_WINDOW_COLOR_SCHEME', description: 'A DSM-window Vue component combines OS theme detection with a dynamic color-scheme binding', suggestion: 'Leave color-scheme unset in DSM windows; follow OS preferences only on the App\'s own full page' },
|
|
51
51
|
STANDALONE_IDENTITY_WITHOUT_PORTAL: { code: 'STANDALONE_IDENTITY_WITHOUT_PORTAL', description: 'Standalone identity is enabled without an Application Portal declaration', suggestion: 'Use HTTPS-only standalone login outside DSM windows; declare portal only when an alias is needed' },
|
|
52
52
|
INSTALL_SETTINGS_INVALID: { "code": "INSTALL_SETTINGS_INVALID", "description": "The installation setting declaration is invalid.", "suggestion": "Declare 1–32 lowercase identifier keys in install.settings, each with type https-origin, a plain label and an explicit boolean required; omit defaults and values." },
|
|
53
|
+
INSTALL_MIN_MEMORY_INVALID: { code: "INSTALL_MIN_MEMORY_INVALID", description: "The physical memory requirement or its packaged check is invalid.", suggestion: "Set install.min_memory_mb to a positive integer in MiB, at most 2147483647, and rebuild with the generated package-account hooks and wizards." },
|
|
53
54
|
INSTALL_PORT_INVALID: { code: "INSTALL_PORT_INVALID", description: "The installation port declaration or selected value is invalid", suggestion: "Enable install.ports for a declared identity gateway and choose distinct available non-reserved ports between 1024 and 65535" },
|
|
54
55
|
SDK_PORT_SETTINGS_UNSUPPORTED: { code: "SDK_PORT_SETTINGS_UNSUPPORTED", description: "The selected SDK does not provide installer-selected ports", suggestion: "Pin SDK 0.38.2 or a matching supported release and rebuild with the matching CLI" },
|
|
55
56
|
SDK_INSTALL_SETTINGS_UNSUPPORTED: { "code": "SDK_INSTALL_SETTINGS_UNSUPPORTED", "description": "The selected SDK does not provide native installation settings.", "suggestion": "Pin SDK 0.24.0 or a matching supported release with installsettings/cmd/control, then rebuild with the matching CLI." },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { HostAdapter, HostTitleResult, HostRequestResult, HostURLResult, HostEvent, HostSubscriptionResult, HostFileNavigationResult, HostUnsupportedResult } from "./host-types.js";
|
|
2
|
-
export declare const HOST_ADAPTER_RUNTIME = "function inspectHostPlatform(ctx) {\n ctx = ctx || {};\n var web = typeof window !== \"undefined\";\n var host = false;\n try {\n host = !!(web && ctx.appWindow && typeof SYNO !== \"undefined\" &&\n SYNO.SDS && typeof SYNO.SDS.AppWindow === \"function\" &&\n ctx.appWindow instanceof SYNO.SDS.AppWindow);\n } catch (error) {\n // An unsupported host constructor must not break a standalone shell.\n }\n function read(key) {\n if (!host || typeof _S !== \"function\") return null;\n try { return _S(key); } catch (error) { return null; }\n }\n function text(value) {\n return typeof value === \"string\" && /\\S/.test(value) ? value : null;\n }\n function versionPart(value) {\n if (typeof value === \"number\") {\n if (!isFinite(value) || value < 0 || Math.floor(value) !== value) return null;\n value = String(value);\n }\n return typeof value === \"string\" && value.length > 0 && !/\\D/.test(value) ? value : null;\n }\n var standalone = read(\"standalone\");\n var language = text(read(\"lang\"));\n var major = versionPart(read(\"majorversion\"));\n var minor = versionPart(read(\"minorversion\"));\n var fullVersion = text(read(\"fullversion\"));\n return Object.freeze({\n web: web,\n host: host ? \"dsm\" : web ? \"standalone-web\" : \"unavailable\",\n dsmStandalone: typeof standalone === \"boolean\" ? standalone : null,\n dsmLanguage: language,\n appLocale: text(ctx.locale),\n systemVersion: major !== null && minor !== null ? major + \".\" + minor : null,\n fullVersion: fullVersion,\n theme: null\n });\n}\n\nfunction requestHostFileNavigation(launch, path, isDirectory) {\n if (typeof path !== \"string\" || path.length > 4096 || path.charAt(0) !== \"/\" ||\n /[\\x00-\\x1f\\x7f\\\\]/.test(path)) return { status: \"invalid-input\" };\n var volume = /^\\/volume(?:USB|SATA)?[0-9]+(?=\\/|$)/.exec(path);\n if (volume) path = path.slice(volume[0].length);\n var parts = path.split(\"/\");\n if (parts.length < 2 || parts.slice(1).some(function (part) {\n return !part || part === \".\" || part === \"..\";\n })) return { status: \"invalid-input\" };\n var result = launch(\"SYNO.SDS.App.FileStation3.Instance\", isDirectory ? { opendir: path } : { openfile: path });\n if (result.status !== \"requested\") return result;\n return { status: \"requested\", action: isDirectory ? \"locate-folder\" : \"highlight-file\" };\n}\n\n\nvar REVEAL_RECOVERY_TIMEOUT_MS = 5000;\nvar REVEAL_RECOVERY_POLL_MS = 100;\nvar REVEAL_RECOVERY_QUIET_MS = 300;\nvar hostFileRevealOwners = null, hostFileRevealSequence = 0;\ntry { if (typeof WeakMap === \"function\") hostFileRevealOwners = new WeakMap(); } catch (error) {}\nfunction createHostFileRevealRecovery(path, canAct) {\n var active = true, accepted = false, win = null, dom = null, tuple = null;\n var poll = null, deadline = null, removers = [], reached = false, pending = 0;\n var previous = null, quietSince = null, expires = 0, order = ++hostFileRevealSequence;\n var parent = path.slice(0, path.lastIndexOf(\"/\"));\n function cancel() {\n if (!active) return;\n active = false;\n try { if (poll !== null) clearTimeout(poll); } catch (error) {}\n try { if (deadline !== null) clearTimeout(deadline); } catch (error) {}\n poll = deadline = null;\n removers.splice(0).forEach(function (remove) { try { remove(); } catch (error) {} });\n try {\n if (win && hostFileRevealOwners.get(win).order === order) {\n // Preserve ordering for a late older callback, without retaining its closures.\n hostFileRevealOwners.set(win, { order: order, cancel: null });\n }\n } catch (error) {}\n win = dom = tuple = previous = null;\n }\n function requireMethods(target, names) {\n if (!target || names.some(function (name) { return typeof target[name] !== \"function\"; })) throw new Error(\"unsupported receiver\");\n }\n function guard(fn) {\n return function () {\n if (!active) return;\n try { fn.apply(null, arguments); } catch (error) { cancel(); }\n };\n }\n function listen(target, event, fn) {\n requireMethods(target, [\"on\", \"un\"]);\n var handler = guard(fn), remove = target.un;\n removers.push(function () { remove.call(target, event, handler, target); });\n target.on(event, handler, target);\n }\n function resetQuiet() { previous = null; quietSince = null; }\n function inspect() {\n requireMethods(win, [\"getPanelInstance\", \"getEl\", \"on\", \"un\"]);\n if (win.isDestroyed || win.destroyed || !canAct()) { cancel(); return null; }\n var element = win.getEl(), nextDom = element && element.dom;\n if (!nextDom) { if (dom) cancel(); return null; }\n requireMethods(nextDom, [\"addEventListener\", \"removeEventListener\"]);\n if (dom && nextDom !== dom) { cancel(); return null; }\n if (!dom) {\n dom = nextDom;\n [\"pointerdown\", \"mousedown\", \"touchstart\", \"keydown\", \"wheel\", \"click\", \"input\"].forEach(function (event) {\n var remove = dom.removeEventListener, handler = guard(cancel), target = dom;\n removers.push(function () { remove.call(target, event, handler, true); });\n dom.addEventListener(event, handler, true);\n });\n }\n var panel = win.getPanelInstance();\n if (!panel) { if (tuple) cancel(); return null; }\n requireMethods(panel, [\"getCurrentDir\", \"on\", \"un\"]);\n var view = panel.activeView, store = panel.activeDS;\n requireMethods(view, [\"getStore\", \"getSelectionModel\", \"scrollToItem\"]);\n requireMethods(store, [\"on\", \"un\", \"indexOfId\", \"getAt\", \"getCount\"]);\n var model = view.getSelectionModel();\n requireMethods(model, [\"on\", \"un\", \"getSelections\", \"selectRow\"]);\n if (view.getStore() !== store || panel.isDestroyed || store.isDestroyed || model.isDestroyed) { cancel(); return null; }\n if (tuple && (tuple.panel !== panel || tuple.view !== view || tuple.store !== store || tuple.model !== model)) { cancel(); return null; }\n if (!tuple) {\n tuple = { panel: panel, view: view, store: store, model: model };\n listen(panel, \"destroy\", cancel);\n listen(panel, \"onNodeClick\", function (node) {\n if (!node || !node.attributes || (reached && node.attributes.path !== parent)) cancel();\n });\n listen(store, \"beforeload\", function () {\n pending++; resetQuiet(); inspect();\n });\n listen(store, \"load\", function () {\n if (pending > 0) pending--;\n resetQuiet(); check();\n });\n [\"exception\", \"loadexception\", \"destroy\"].forEach(function (event) { listen(store, event, cancel); });\n listen(model, \"selectionchange\", function () { resetQuiet(); check(); });\n }\n var dir = panel.getCurrentDir(), params = store.baseParams;\n // New File Station panels expose their APIs before the first directory is set.\n // Keep the bound receiver guards and original deadline while startup finishes.\n if (!reached && dir === undefined && (!params || params.folder_path === undefined)) return null;\n if (!params || typeof params.folder_path !== \"string\") throw new Error(\"unsupported store path\");\n // Native reconfigure/selection events can precede the store's path assignment.\n if (dir === parent && params.folder_path === parent) reached = true;\n if (reached && (dir !== parent || params.folder_path !== parent)) { cancel(); return null; }\n var selections = model.getSelections();\n if (!Array.isArray(selections)) throw new Error(\"unsupported selection\");\n if (selections.some(function (record) { return !record || record.id !== path; })) { cancel(); return null; }\n var index = store.indexOfId(path), count = store.getCount();\n if (!Number.isInteger(index) || index < -1 || !Number.isInteger(count) || count < 0) throw new Error(\"unsupported store index\");\n var record = index >= 0 ? store.getAt(index) : null;\n if (index >= 0 && (!record || record.id !== path || index >= count)) throw new Error(\"inconsistent store\");\n return { dir: dir, folder: params.folder_path, count: count, index: index, record: record, selected: selections.length > 0 };\n }\n function check() {\n if (!active) return;\n if (Date.now() >= expires || !canAct()) { cancel(); return; }\n if (!win) return;\n var state = inspect();\n if (!active || !state) return;\n if (pending || state.dir !== parent || state.folder !== parent || state.index < 0) { resetQuiet(); return; }\n if (!previous || Object.keys(state).some(function (key) { return state[key] !== previous[key]; })) {\n previous = state; quietSince = Date.now();\n }\n if (Date.now() - quietSince < REVEAL_RECOVERY_QUIET_MS) return;\n var target = tuple, receiverWindow = win;\n cancel(); // Release every observer before the one permitted selection mutation.\n if (state.selected || !canAct()) return;\n target.model.selectRow(state.index);\n if (canAct() && !receiverWindow.isDestroyed && receiverWindow.getPanelInstance() === target.panel &&\n target.panel.activeView === target.view && target.panel.activeDS === target.store &&\n target.view.getSelectionModel() === target.model) target.view.scrollToItem(state.index);\n }\n function tick() {\n poll = null;\n try {\n check();\n if (active) poll = setTimeout(tick, REVEAL_RECOVERY_POLL_MS);\n } catch (error) { cancel(); }\n }\n function receive(instance) {\n if (!active || accepted) return;\n accepted = true;\n try {\n if (Date.now() >= expires || !canAct()) { cancel(); return; }\n win = instance && instance.window;\n requireMethods(win, [\"getPanelInstance\", \"getEl\", \"on\", \"un\"]);\n var owner = hostFileRevealOwners.get(win);\n if (owner && owner.order > order) { cancel(); return; }\n if (owner && owner.cancel) owner.cancel();\n hostFileRevealOwners.set(win, { order: order, cancel: cancel });\n [\"beforeclose\", \"close\", \"beforedestroy\", \"destroy\", \"hide\"].forEach(function (event) { listen(win, event, cancel); });\n check();\n } catch (error) { cancel(); }\n }\n try {\n if (!parent || !hostFileRevealOwners || typeof setTimeout !== \"function\" || typeof clearTimeout !== \"function\" || typeof Date.now !== \"function\") {\n cancel();\n } else {\n expires = Date.now() + REVEAL_RECOVERY_TIMEOUT_MS;\n deadline = setTimeout(cancel, REVEAL_RECOVERY_TIMEOUT_MS);\n poll = setTimeout(tick, REVEAL_RECOVERY_POLL_MS);\n }\n } catch (error) { cancel(); }\n return { receive: receive, cancel: cancel };\n}\n\nfunction createHostAdapter(ctx) {\n ctx = ctx || {};\n var disposed = false, subscriptions = [], revealRecovery = null;\n function launchApp(appId, config, receiverCallback) {\n if (disposed) return { status: \"unavailable\" };\n if (typeof appId !== \"string\" || !appId || /\\s/.test(appId)) return { status: \"invalid-input\" };\n try {\n if (inspectHostPlatform(ctx).host !== \"dsm\") return { status: \"unsupported\" };\n var sds = SYNO.SDS, map = sds.Config && sds.Config.FnMap, notifier = sds.StatusNotifier;\n if (typeof sds.AppLaunch !== \"function\" || !map ||\n !Object.prototype.hasOwnProperty.call(map, appId) || !map[appId] || !notifier ||\n typeof notifier.isAppEnabled !== \"function\" || !notifier.isAppEnabled(appId) ||\n typeof notifier.isAppLaunchable !== \"function\" || !notifier.isAppLaunchable(appId)) {\n return { status: \"unsupported\" };\n }\n if (receiverCallback) sds.AppLaunch(appId, config, undefined, receiverCallback);\n else sds.AppLaunch(appId, config);\n return { status: \"requested\" };\n } catch (error) { return { status: \"failed\" }; }\n }\n function navigateFileStation(path, isDirectory) {\n if (disposed) return { status: \"unavailable\" };\n if (revealRecovery) revealRecovery.cancel();\n revealRecovery = null;\n function launchFile(appId, config) {\n if (isDirectory) return launchApp(appId, config);\n var recovery = createHostFileRevealRecovery(config.openfile, function () { return !disposed && revealRecovery === recovery; });\n revealRecovery = recovery;\n var result = launchApp(appId, config, recovery.receive);\n if (result.status !== \"requested\") recovery.cancel();\n return result;\n }\n return requestHostFileNavigation(launchFile, path, isDirectory);\n }\n function unsupportedOperation() { return { status: disposed ? \"unavailable\" : \"unsupported\" }; }\n return Object.freeze({\n platform: function () {\n if (!disposed) return inspectHostPlatform(ctx);\n return Object.freeze({\n web: typeof window !== \"undefined\", host: \"unavailable\",\n dsmStandalone: null, dsmLanguage: null, appLocale: null,\n systemVersion: null, fullVersion: null, theme: null\n });\n },\n setTitle: function (title) {\n if (disposed) return { status: \"unavailable\" };\n if (typeof title !== \"string\") return { status: \"invalid-input\" };\n try {\n var platform = inspectHostPlatform(ctx);\n if (platform.host === \"dsm\") {\n if (typeof ctx.appWindow.setTitle !== \"function\") return { status: \"unsupported\" };\n ctx.appWindow.setTitle(title, undefined, true);\n return { status: \"ok\", target: \"dsm-window\" };\n }\n if (!platform.web) return { status: \"unavailable\" };\n if (typeof document === \"undefined\") return { status: \"unsupported\" };\n document.title = title;\n return { status: \"ok\", target: \"document\" };\n } catch (error) {\n return { status: \"failed\" };\n }\n },\n activateWindow: function () {\n if (disposed) return { status: \"unavailable\" };\n try {\n if (inspectHostPlatform(ctx).host !== \"dsm\") return { status: \"unsupported\" };\n var win = ctx.appWindow;\n var activate = typeof win.toFront === \"function\" ? win.toFront : win.activate;\n if (typeof activate !== \"function\") return { status: \"unsupported\" };\n // DSM minimizes by hiding; show preserves maximized geometry, unlike restore.\n if (win.hidden === true || win.minimized === true ||\n (typeof win.isVisible === \"function\" && win.isVisible() === false)) {\n if (typeof win.show !== \"function\") return { status: \"unsupported\" };\n win.show();\n }\n activate.call(win);\n return { status: \"requested\" };\n } catch (error) { return { status: \"failed\" }; }\n },\n requestClose: function () {\n if (disposed) return { status: \"unavailable\" };\n try {\n if (inspectHostPlatform(ctx).host !== \"dsm\") return { status: \"unsupported\" };\n var win = ctx.appWindow;\n // DSM returns a short-circuit value; only truthy means standalone main.\n if (typeof win.close !== \"function\" || typeof win.isStandaloneMainWindow !== \"function\" ||\n win.isStandaloneMainWindow()) return { status: \"unsupported\" };\n if (win.canClose === false) return { status: \"blocked\" };\n win.close();\n return { status: \"requested\" };\n } catch (error) { return { status: \"failed\" }; }\n },\n // DSM's own banner sign-out, for an App that hides the banner (ui.banner: hidden).\n signOut: function () {\n if (disposed) return { status: \"unavailable\" };\n try {\n if (inspectHostPlatform(ctx).host !== \"dsm\") return { status: \"unsupported\" };\n var sds = SYNO.SDS, logout = sds.Utils && sds.Utils.Logout;\n if (!logout || typeof logout.action !== \"function\") return { status: \"unsupported\" };\n if (sds.StatusNotifier) sds.StatusNotifier.fireEvent(\"logout\");\n window.onbeforeunload = sds.onBasicBeforeUnload;\n logout.action();\n return { status: \"requested\" };\n } catch (error) { return { status: \"failed\" }; }\n },\n openApp: function (appId) { return launchApp(appId, {}); },\n openURL: function (raw) {\n if (disposed || typeof window === \"undefined\") return { status: \"unavailable\" };\n if (typeof raw !== \"string\" || !raw || /[\\s\\x00-\\x1f\\x7f]/.test(raw)) return { status: \"invalid-input\" };\n if (typeof URL !== \"function\") return { status: \"unsupported\" };\n var url;\n try { url = new URL(raw); } catch (error) { return { status: \"invalid-input\" }; }\n if ((url.protocol !== \"http:\" && url.protocol !== \"https:\") || url.username || url.password) return { status: \"invalid-input\" };\n if (typeof window.open !== \"function\") return { status: \"unsupported\" };\n try {\n var opened = window.open(url.href, \"_blank\", \"noopener,noreferrer\");\n return { status: \"requested\", windowHandleAvailable: !!opened };\n } catch (error) { return { status: \"failed\" }; }\n },\n openFileManager: function (path) { return navigateFileStation(path, true); },\n revealFile: function (path) { return navigateFileStation(path, false); },\n openFile: unsupportedOperation,\n showFileDetails: unsupportedOperation,\n openAppSetting: unsupportedOperation,\n subscribe: function (event, listener) {\n if (disposed) return { status: \"unavailable\" };\n if (typeof listener !== \"function\") return { status: \"invalid-input\" };\n if (event !== \"window-resize\") return { status: \"unsupported\" };\n var win, callback = listener, active = true;\n function handler() { if (!disposed && callback) callback(); }\n function unsubscribe() {\n if (!active) return;\n active = false;\n callback = null;\n var target = win;\n win = null;\n var index = subscriptions.indexOf(unsubscribe);\n if (index !== -1) subscriptions.splice(index, 1);\n try { if (target) target.un(\"resize\", handler, target); } catch (error) {}\n }\n try {\n if (inspectHostPlatform(ctx).host !== \"dsm\") return { status: \"unsupported\" };\n win = ctx.appWindow;\n if (typeof win.on !== \"function\" || typeof win.un !== \"function\") return { status: \"unsupported\" };\n subscriptions.push(unsubscribe);\n win.on(\"resize\", handler, win);\n if (disposed) return { status: \"unavailable\" };\n return Object.freeze({ status: \"subscribed\", dispose: unsubscribe });\n } catch (error) {\n unsubscribe();\n return { status: \"failed\" };\n }\n },\n dispose: function () {\n if (disposed) return;\n disposed = true;\n if (revealRecovery) revealRecovery.cancel();\n revealRecovery = null;\n subscriptions.slice().forEach(function (unsubscribe) { unsubscribe(); });\n ctx = null;\n }\n });\n}";
|
|
2
|
+
export declare const HOST_ADAPTER_RUNTIME = "function inspectHostPlatform(ctx) {\n ctx = ctx || {};\n var web = typeof window !== \"undefined\";\n var host = false;\n try {\n host = !!(web && ctx.appWindow && typeof SYNO !== \"undefined\" &&\n SYNO.SDS && typeof SYNO.SDS.AppWindow === \"function\" &&\n ctx.appWindow instanceof SYNO.SDS.AppWindow);\n } catch (error) {\n // An unsupported host constructor must not break a standalone shell.\n }\n function read(key) {\n if (!host || typeof _S !== \"function\") return null;\n try { return _S(key); } catch (error) { return null; }\n }\n function text(value) {\n return typeof value === \"string\" && /\\S/.test(value) ? value : null;\n }\n function versionPart(value) {\n if (typeof value === \"number\") {\n if (!isFinite(value) || value < 0 || Math.floor(value) !== value) return null;\n value = String(value);\n }\n return typeof value === \"string\" && value.length > 0 && !/\\D/.test(value) ? value : null;\n }\n var standalone = read(\"standalone\");\n var language = text(read(\"lang\"));\n var major = versionPart(read(\"majorversion\"));\n var minor = versionPart(read(\"minorversion\"));\n var fullVersion = text(read(\"fullversion\"));\n return Object.freeze({\n web: web,\n host: host ? \"dsm\" : web ? \"standalone-web\" : \"unavailable\",\n dsmStandalone: typeof standalone === \"boolean\" ? standalone : null,\n dsmLanguage: language,\n appLocale: text(ctx.locale),\n systemVersion: major !== null && minor !== null ? major + \".\" + minor : null,\n fullVersion: fullVersion,\n theme: null\n });\n}\n\nfunction requestHostFileNavigation(launch, path, isDirectory) {\n if (typeof path !== \"string\" || path.length > 4096 || path.charAt(0) !== \"/\" ||\n /[\\x00-\\x1f\\x7f\\\\]/.test(path)) return { status: \"invalid-input\" };\n var volume = /^\\/volume(?:USB|SATA)?[0-9]+(?=\\/|$)/.exec(path);\n if (volume) path = path.slice(volume[0].length);\n var parts = path.split(\"/\");\n if (parts.length < 2 || parts.slice(1).some(function (part) {\n return !part || part === \".\" || part === \"..\";\n })) return { status: \"invalid-input\" };\n var result = launch(\"SYNO.SDS.App.FileStation3.Instance\", isDirectory ? { opendir: path } : { openfile: path });\n if (result.status !== \"requested\") return result;\n return { status: \"requested\", action: isDirectory ? \"locate-folder\" : \"highlight-file\" };\n}\n\n\nvar REVEAL_RECOVERY_TIMEOUT_MS = 5000;\nvar REVEAL_RECOVERY_POLL_MS = 100;\nvar REVEAL_RECOVERY_QUIET_MS = 300;\nvar hostFileRevealOwners = null, hostFileRevealSequence = 0;\ntry { if (typeof WeakMap === \"function\") hostFileRevealOwners = new WeakMap(); } catch (error) {}\nfunction createHostFileRevealRecovery(path, canAct) {\n var active = true, accepted = false, win = null, dom = null, tuple = null;\n var poll = null, deadline = null, removers = [], reached = false, pending = 0;\n var previous = null, quietSince = null, expires = 0, order = ++hostFileRevealSequence;\n var parent = path.slice(0, path.lastIndexOf(\"/\"));\n function cancel() {\n if (!active) return;\n active = false;\n try { if (poll !== null) clearTimeout(poll); } catch (error) {}\n try { if (deadline !== null) clearTimeout(deadline); } catch (error) {}\n poll = deadline = null;\n removers.splice(0).forEach(function (remove) { try { remove(); } catch (error) {} });\n try {\n if (win && hostFileRevealOwners.get(win).order === order) {\n // Preserve ordering for a late older callback, without retaining its closures.\n hostFileRevealOwners.set(win, { order: order, cancel: null });\n }\n } catch (error) {}\n win = dom = tuple = previous = null;\n }\n function requireMethods(target, names) {\n if (!target || names.some(function (name) { return typeof target[name] !== \"function\"; })) throw new Error(\"unsupported receiver\");\n }\n function guard(fn) {\n return function () {\n if (!active) return;\n try { fn.apply(null, arguments); } catch (error) { cancel(); }\n };\n }\n function listen(target, event, fn) {\n requireMethods(target, [\"on\", \"un\"]);\n var handler = guard(fn), remove = target.un;\n removers.push(function () { remove.call(target, event, handler, target); });\n target.on(event, handler, target);\n }\n function resetQuiet() { previous = null; quietSince = null; }\n function inspect() {\n requireMethods(win, [\"getPanelInstance\", \"getEl\", \"on\", \"un\"]);\n if (win.isDestroyed || win.destroyed || !canAct()) { cancel(); return null; }\n var element = win.getEl(), nextDom = element && element.dom;\n if (!nextDom) { if (dom) cancel(); return null; }\n requireMethods(nextDom, [\"addEventListener\", \"removeEventListener\"]);\n if (dom && nextDom !== dom) { cancel(); return null; }\n if (!dom) {\n dom = nextDom;\n [\"pointerdown\", \"mousedown\", \"touchstart\", \"keydown\", \"wheel\", \"click\", \"input\"].forEach(function (event) {\n var remove = dom.removeEventListener, handler = guard(cancel), target = dom;\n removers.push(function () { remove.call(target, event, handler, true); });\n dom.addEventListener(event, handler, true);\n });\n }\n var panel = win.getPanelInstance();\n if (!panel) { if (tuple) cancel(); return null; }\n requireMethods(panel, [\"getCurrentDir\", \"on\", \"un\"]);\n var view = panel.activeView, store = panel.activeDS;\n requireMethods(view, [\"getStore\", \"getSelectionModel\", \"scrollToItem\"]);\n requireMethods(store, [\"on\", \"un\", \"indexOfId\", \"getAt\", \"getCount\"]);\n var model = view.getSelectionModel();\n requireMethods(model, [\"on\", \"un\", \"getSelections\", \"selectRow\"]);\n if (view.getStore() !== store || panel.isDestroyed || store.isDestroyed || model.isDestroyed) { cancel(); return null; }\n if (tuple && (tuple.panel !== panel || tuple.view !== view || tuple.store !== store || tuple.model !== model)) { cancel(); return null; }\n if (!tuple) {\n tuple = { panel: panel, view: view, store: store, model: model };\n listen(panel, \"destroy\", cancel);\n listen(panel, \"onNodeClick\", function (node) {\n if (!node || !node.attributes || (reached && node.attributes.path !== parent)) cancel();\n });\n listen(store, \"beforeload\", function () {\n pending++; resetQuiet(); inspect();\n });\n listen(store, \"load\", function () {\n if (pending > 0) pending--;\n resetQuiet(); check();\n });\n [\"exception\", \"loadexception\", \"destroy\"].forEach(function (event) { listen(store, event, cancel); });\n listen(model, \"selectionchange\", function () { resetQuiet(); check(); });\n }\n var dir = panel.getCurrentDir(), params = store.baseParams;\n // New File Station panels expose their APIs before the first directory is set.\n // Keep the bound receiver guards and original deadline while startup finishes.\n if (!reached && dir === undefined && (!params || params.folder_path === undefined)) return null;\n if (!params || typeof params.folder_path !== \"string\") throw new Error(\"unsupported store path\");\n // Native reconfigure/selection events can precede the store's path assignment.\n if (dir === parent && params.folder_path === parent) reached = true;\n if (reached && (dir !== parent || params.folder_path !== parent)) { cancel(); return null; }\n var selections = model.getSelections();\n if (!Array.isArray(selections)) throw new Error(\"unsupported selection\");\n if (selections.some(function (record) { return !record || record.id !== path; })) { cancel(); return null; }\n var index = store.indexOfId(path), count = store.getCount();\n if (!Number.isInteger(index) || index < -1 || !Number.isInteger(count) || count < 0) throw new Error(\"unsupported store index\");\n var record = index >= 0 ? store.getAt(index) : null;\n if (index >= 0 && (!record || record.id !== path || index >= count)) throw new Error(\"inconsistent store\");\n return { dir: dir, folder: params.folder_path, count: count, index: index, record: record, selected: selections.length > 0 };\n }\n function check() {\n if (!active) return;\n if (Date.now() >= expires || !canAct()) { cancel(); return; }\n if (!win) return;\n var state = inspect();\n if (!active || !state) return;\n if (pending || state.dir !== parent || state.folder !== parent || state.index < 0) { resetQuiet(); return; }\n if (!previous || Object.keys(state).some(function (key) { return state[key] !== previous[key]; })) {\n previous = state; quietSince = Date.now();\n }\n if (Date.now() - quietSince < REVEAL_RECOVERY_QUIET_MS) return;\n var target = tuple, receiverWindow = win;\n cancel(); // Release every observer before the one permitted selection mutation.\n if (state.selected || !canAct()) return;\n target.model.selectRow(state.index);\n if (canAct() && !receiverWindow.isDestroyed && receiverWindow.getPanelInstance() === target.panel &&\n target.panel.activeView === target.view && target.panel.activeDS === target.store &&\n target.view.getSelectionModel() === target.model) target.view.scrollToItem(state.index);\n }\n function tick() {\n poll = null;\n try {\n check();\n if (active) poll = setTimeout(tick, REVEAL_RECOVERY_POLL_MS);\n } catch (error) { cancel(); }\n }\n function receive(instance) {\n if (!active || accepted) return;\n accepted = true;\n try {\n if (Date.now() >= expires || !canAct()) { cancel(); return; }\n win = instance && instance.window;\n requireMethods(win, [\"getPanelInstance\", \"getEl\", \"on\", \"un\"]);\n var owner = hostFileRevealOwners.get(win);\n if (owner && owner.order > order) { cancel(); return; }\n if (owner && owner.cancel) owner.cancel();\n hostFileRevealOwners.set(win, { order: order, cancel: cancel });\n [\"beforeclose\", \"close\", \"beforedestroy\", \"destroy\", \"hide\"].forEach(function (event) { listen(win, event, cancel); });\n check();\n } catch (error) { cancel(); }\n }\n try {\n if (!parent || !hostFileRevealOwners || typeof setTimeout !== \"function\" || typeof clearTimeout !== \"function\" || typeof Date.now !== \"function\") {\n cancel();\n } else {\n expires = Date.now() + REVEAL_RECOVERY_TIMEOUT_MS;\n deadline = setTimeout(cancel, REVEAL_RECOVERY_TIMEOUT_MS);\n poll = setTimeout(tick, REVEAL_RECOVERY_POLL_MS);\n }\n } catch (error) { cancel(); }\n return { receive: receive, cancel: cancel };\n}\n\nfunction createHostAdapter(ctx) {\n ctx = ctx || {};\n var disposed = false, subscriptions = [], revealRecovery = null;\n function launchApp(appId, config, receiverCallback) {\n if (disposed) return { status: \"unavailable\" };\n if (typeof appId !== \"string\" || !appId || /\\s/.test(appId)) return { status: \"invalid-input\" };\n try {\n if (inspectHostPlatform(ctx).host !== \"dsm\") return { status: \"unsupported\" };\n var sds = SYNO.SDS, map = sds.Config && sds.Config.FnMap, notifier = sds.StatusNotifier;\n if (typeof sds.AppLaunch !== \"function\" || !map ||\n !Object.prototype.hasOwnProperty.call(map, appId) || !map[appId] || !notifier ||\n typeof notifier.isAppEnabled !== \"function\" || !notifier.isAppEnabled(appId) ||\n typeof notifier.isAppLaunchable !== \"function\" || !notifier.isAppLaunchable(appId)) {\n return { status: \"unsupported\" };\n }\n if (receiverCallback) sds.AppLaunch(appId, config, undefined, receiverCallback);\n else sds.AppLaunch(appId, config);\n return { status: \"requested\" };\n } catch (error) { return { status: \"failed\" }; }\n }\n function navigateFileStation(path, isDirectory) {\n if (disposed) return { status: \"unavailable\" };\n if (revealRecovery) revealRecovery.cancel();\n revealRecovery = null;\n function launchFile(appId, config) {\n if (isDirectory) return launchApp(appId, config);\n var recovery = createHostFileRevealRecovery(config.openfile, function () { return !disposed && revealRecovery === recovery; });\n revealRecovery = recovery;\n var result = launchApp(appId, config, recovery.receive);\n if (result.status !== \"requested\") recovery.cancel();\n return result;\n }\n return requestHostFileNavigation(launchFile, path, isDirectory);\n }\n function unsupportedOperation() { return { status: disposed ? \"unavailable\" : \"unsupported\" }; }\n return Object.freeze({\n platform: function () {\n if (!disposed) return inspectHostPlatform(ctx);\n return Object.freeze({\n web: typeof window !== \"undefined\", host: \"unavailable\",\n dsmStandalone: null, dsmLanguage: null, appLocale: null,\n systemVersion: null, fullVersion: null, theme: null\n });\n },\n setTitle: function (title) {\n if (disposed) return { status: \"unavailable\" };\n if (typeof title !== \"string\") return { status: \"invalid-input\" };\n try {\n var platform = inspectHostPlatform(ctx);\n if (platform.host === \"dsm\") {\n if (typeof ctx.appWindow.setTitle !== \"function\") return { status: \"unsupported\" };\n ctx.appWindow.setTitle(title, undefined, true);\n return { status: \"ok\", target: \"dsm-window\" };\n }\n if (!platform.web) return { status: \"unavailable\" };\n if (typeof document === \"undefined\") return { status: \"unsupported\" };\n document.title = title;\n return { status: \"ok\", target: \"document\" };\n } catch (error) {\n return { status: \"failed\" };\n }\n },\n activateWindow: function () {\n if (disposed) return { status: \"unavailable\" };\n try {\n if (inspectHostPlatform(ctx).host !== \"dsm\") return { status: \"unsupported\" };\n var win = ctx.appWindow;\n var activate = typeof win.toFront === \"function\" ? win.toFront : win.activate;\n if (typeof activate !== \"function\") return { status: \"unsupported\" };\n // DSM minimizes by hiding; show preserves maximized geometry, unlike restore.\n if (win.hidden === true || win.minimized === true ||\n (typeof win.isVisible === \"function\" && win.isVisible() === false)) {\n if (typeof win.show !== \"function\") return { status: \"unsupported\" };\n win.show();\n }\n activate.call(win);\n return { status: \"requested\" };\n } catch (error) { return { status: \"failed\" }; }\n },\n requestClose: function () {\n if (disposed) return { status: \"unavailable\" };\n try {\n if (inspectHostPlatform(ctx).host !== \"dsm\") return { status: \"unsupported\" };\n var win = ctx.appWindow;\n // DSM returns a short-circuit value; only truthy means standalone main.\n if (typeof win.close !== \"function\" || typeof win.isStandaloneMainWindow !== \"function\" ||\n win.isStandaloneMainWindow()) return { status: \"unsupported\" };\n if (win.canClose === false) return { status: \"blocked\" };\n win.close();\n return { status: \"requested\" };\n } catch (error) { return { status: \"failed\" }; }\n },\n // DSM's own banner sign-out, for an App that hides the banner (ui.banner: hidden).\n signOut: function () {\n if (disposed) return { status: \"unavailable\" };\n try {\n if (inspectHostPlatform(ctx).host !== \"dsm\") return { status: \"unsupported\" };\n var sds = SYNO.SDS, logout = sds.Utils && sds.Utils.Logout;\n if (!logout || typeof logout.action !== \"function\") return { status: \"unsupported\" };\n if (sds.StatusNotifier) sds.StatusNotifier.fireEvent(\"logout\");\n window.onbeforeunload = sds.onBasicBeforeUnload;\n logout.action();\n return { status: \"requested\" };\n } catch (error) { return { status: \"failed\" }; }\n },\n openApp: function (appId) { return launchApp(appId, {}); },\n openURL: function (raw) {\n if (disposed || typeof window === \"undefined\") return { status: \"unavailable\" };\n if (typeof raw !== \"string\" || !raw || /[\\s\\x00-\\x1f\\x7f]/.test(raw)) return { status: \"invalid-input\" };\n if (typeof URL !== \"function\") return { status: \"unsupported\" };\n var url;\n try { url = new URL(raw); } catch (error) { return { status: \"invalid-input\" }; }\n if ((url.protocol !== \"http:\" && url.protocol !== \"https:\") || url.username || url.password) return { status: \"invalid-input\" };\n if (typeof window.open !== \"function\") return { status: \"unsupported\" };\n try {\n var opened = window.open(url.href, \"_blank\", \"noopener,noreferrer\");\n return { status: \"requested\", windowHandleAvailable: !!opened };\n } catch (error) { return { status: \"failed\" }; }\n },\n openFileManager: function (path) { return navigateFileStation(path, true); },\n revealFile: function (path) { return navigateFileStation(path, false); },\n openFile: unsupportedOperation,\n showFileDetails: unsupportedOperation,\n openAppSetting: unsupportedOperation,\n subscribe: function (event, listener) {\n if (disposed) return { status: \"unavailable\" };\n if (typeof listener !== \"function\") return { status: \"invalid-input\" };\n if (event === \"window-activated\") {\n var target = ctx.appWindow, bindings = [], timer = null, activeActivation = true;\n function cancelActivation() {\n if (timer !== null) clearTimeout(timer);\n timer = null;\n }\n function signalActivation() {\n if (disposed || !activeActivation) return;\n if (typeof document !== \"undefined\" && document.visibilityState === \"hidden\") { cancelActivation(); return; }\n if (timer !== null) return;\n // One return can produce visible, focus and AppWindow activate signals.\n timer = setTimeout(function () {\n timer = null;\n if (!disposed && activeActivation &&\n !(typeof document !== \"undefined\" && document.visibilityState === \"hidden\")) listener();\n }, 50);\n }\n function bindActivation(object, name, fn, ext) {\n bindings.push(function () {\n if (ext) object.un(name, fn, object);\n else object.removeEventListener(name, fn);\n });\n if (ext) object.on(name, fn, object);\n else object.addEventListener(name, fn);\n }\n function unsubscribeActivation() {\n if (!activeActivation) return;\n activeActivation = false;\n cancelActivation();\n bindings.splice(0).forEach(function (unbind) { try { unbind(); } catch (error) {} });\n target = null;\n listener = null;\n var index = subscriptions.indexOf(unsubscribeActivation);\n if (index !== -1) subscriptions.splice(index, 1);\n }\n try {\n var platform = inspectHostPlatform(ctx);\n if (!platform.web) return { status: \"unavailable\" };\n if (platform.host === \"dsm\") {\n if (typeof target.on !== \"function\" || typeof target.un !== \"function\") return { status: \"unsupported\" };\n // DSM show/toFront reactivates a minimized AppWindow. restore alone\n // changes maximized geometry and is not an activation signal.\n bindActivation(target, \"activate\", signalActivation, true);\n bindActivation(target, \"deactivate\", cancelActivation, true);\n bindActivation(target, \"hide\", cancelActivation, true);\n }\n if (platform.host !== \"dsm\" || platform.dsmStandalone === true) {\n if (typeof document === \"undefined\" || typeof window.addEventListener !== \"function\" ||\n typeof window.removeEventListener !== \"function\" || typeof document.addEventListener !== \"function\" ||\n typeof document.removeEventListener !== \"function\") { unsubscribeActivation(); return { status: \"unsupported\" }; }\n bindActivation(window, \"focus\", signalActivation, false);\n bindActivation(document, \"visibilitychange\", signalActivation, false);\n }\n subscriptions.push(unsubscribeActivation);\n return Object.freeze({ status: \"subscribed\", dispose: unsubscribeActivation });\n } catch (error) { unsubscribeActivation(); return { status: \"failed\" }; }\n }\n if (event !== \"window-resize\") return { status: \"unsupported\" };\n var win, callback = listener, active = true;\n function handler() { if (!disposed && callback) callback(); }\n function unsubscribe() {\n if (!active) return;\n active = false;\n callback = null;\n var target = win;\n win = null;\n var index = subscriptions.indexOf(unsubscribe);\n if (index !== -1) subscriptions.splice(index, 1);\n try { if (target) target.un(\"resize\", handler, target); } catch (error) {}\n }\n try {\n if (inspectHostPlatform(ctx).host !== \"dsm\") return { status: \"unsupported\" };\n win = ctx.appWindow;\n if (typeof win.on !== \"function\" || typeof win.un !== \"function\") return { status: \"unsupported\" };\n subscriptions.push(unsubscribe);\n win.on(\"resize\", handler, win);\n if (disposed) return { status: \"unavailable\" };\n return Object.freeze({ status: \"subscribed\", dispose: unsubscribe });\n } catch (error) {\n unsubscribe();\n return { status: \"failed\" };\n }\n },\n dispose: function () {\n if (disposed) return;\n disposed = true;\n if (revealRecovery) revealRecovery.cancel();\n revealRecovery = null;\n subscriptions.slice().forEach(function (unsubscribe) { unsubscribe(); });\n ctx = null;\n }\n });\n}";
|
|
3
3
|
/** A static, per-package factory for independent web shells; no Ext or transport. */
|
|
4
4
|
export declare function renderHostAdapterScript(packageId: string): string;
|
|
5
5
|
export declare function hostScriptName(build: number): string;
|
|
@@ -130,6 +130,63 @@ function createHostAdapter(ctx) {
|
|
|
130
130
|
subscribe: function (event, listener) {
|
|
131
131
|
if (disposed) return { status: "unavailable" };
|
|
132
132
|
if (typeof listener !== "function") return { status: "invalid-input" };
|
|
133
|
+
if (event === "window-activated") {
|
|
134
|
+
var target = ctx.appWindow, bindings = [], timer = null, activeActivation = true;
|
|
135
|
+
function cancelActivation() {
|
|
136
|
+
if (timer !== null) clearTimeout(timer);
|
|
137
|
+
timer = null;
|
|
138
|
+
}
|
|
139
|
+
function signalActivation() {
|
|
140
|
+
if (disposed || !activeActivation) return;
|
|
141
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") { cancelActivation(); return; }
|
|
142
|
+
if (timer !== null) return;
|
|
143
|
+
// One return can produce visible, focus and AppWindow activate signals.
|
|
144
|
+
timer = setTimeout(function () {
|
|
145
|
+
timer = null;
|
|
146
|
+
if (!disposed && activeActivation &&
|
|
147
|
+
!(typeof document !== "undefined" && document.visibilityState === "hidden")) listener();
|
|
148
|
+
}, 50);
|
|
149
|
+
}
|
|
150
|
+
function bindActivation(object, name, fn, ext) {
|
|
151
|
+
bindings.push(function () {
|
|
152
|
+
if (ext) object.un(name, fn, object);
|
|
153
|
+
else object.removeEventListener(name, fn);
|
|
154
|
+
});
|
|
155
|
+
if (ext) object.on(name, fn, object);
|
|
156
|
+
else object.addEventListener(name, fn);
|
|
157
|
+
}
|
|
158
|
+
function unsubscribeActivation() {
|
|
159
|
+
if (!activeActivation) return;
|
|
160
|
+
activeActivation = false;
|
|
161
|
+
cancelActivation();
|
|
162
|
+
bindings.splice(0).forEach(function (unbind) { try { unbind(); } catch (error) {} });
|
|
163
|
+
target = null;
|
|
164
|
+
listener = null;
|
|
165
|
+
var index = subscriptions.indexOf(unsubscribeActivation);
|
|
166
|
+
if (index !== -1) subscriptions.splice(index, 1);
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
var platform = inspectHostPlatform(ctx);
|
|
170
|
+
if (!platform.web) return { status: "unavailable" };
|
|
171
|
+
if (platform.host === "dsm") {
|
|
172
|
+
if (typeof target.on !== "function" || typeof target.un !== "function") return { status: "unsupported" };
|
|
173
|
+
// DSM show/toFront reactivates a minimized AppWindow. restore alone
|
|
174
|
+
// changes maximized geometry and is not an activation signal.
|
|
175
|
+
bindActivation(target, "activate", signalActivation, true);
|
|
176
|
+
bindActivation(target, "deactivate", cancelActivation, true);
|
|
177
|
+
bindActivation(target, "hide", cancelActivation, true);
|
|
178
|
+
}
|
|
179
|
+
if (platform.host !== "dsm" || platform.dsmStandalone === true) {
|
|
180
|
+
if (typeof document === "undefined" || typeof window.addEventListener !== "function" ||
|
|
181
|
+
typeof window.removeEventListener !== "function" || typeof document.addEventListener !== "function" ||
|
|
182
|
+
typeof document.removeEventListener !== "function") { unsubscribeActivation(); return { status: "unsupported" }; }
|
|
183
|
+
bindActivation(window, "focus", signalActivation, false);
|
|
184
|
+
bindActivation(document, "visibilitychange", signalActivation, false);
|
|
185
|
+
}
|
|
186
|
+
subscriptions.push(unsubscribeActivation);
|
|
187
|
+
return Object.freeze({ status: "subscribed", dispose: unsubscribeActivation });
|
|
188
|
+
} catch (error) { unsubscribeActivation(); return { status: "failed" }; }
|
|
189
|
+
}
|
|
133
190
|
if (event !== "window-resize") return { status: "unsupported" };
|
|
134
191
|
var win, callback = listener, active = true;
|
|
135
192
|
function handler() { if (!disposed && callback) callback(); }
|
|
@@ -16,7 +16,7 @@ export type HostURLResult = {
|
|
|
16
16
|
} | {
|
|
17
17
|
status: "unsupported" | "unavailable" | "invalid-input" | "failed";
|
|
18
18
|
};
|
|
19
|
-
export type HostEvent = "window-resize" | "host-theme-change" | "host-language-change";
|
|
19
|
+
export type HostEvent = "window-resize" | "window-activated" | "host-theme-change" | "host-language-change";
|
|
20
20
|
export type HostSubscriptionResult = {
|
|
21
21
|
status: "subscribed";
|
|
22
22
|
dispose(): void;
|
|
@@ -20,6 +20,7 @@ export interface SpkInspection {
|
|
|
20
20
|
tcpListeners?: TCPListeners;
|
|
21
21
|
dependencies?: PackageDependencies;
|
|
22
22
|
installSettings?: InstallSettings;
|
|
23
|
+
minMemoryMb?: number;
|
|
23
24
|
/** Hyper Backup application backup, as sdk-package.json records it. */
|
|
24
25
|
hyperBackup?: HyperBackup;
|
|
25
26
|
identityGateway?: GatewayAdmissionReport;
|
|
@@ -5,6 +5,7 @@ import { DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM, readNoFile
|
|
|
5
5
|
import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
6
6
|
import { renderGatewayIngressCheck } from './native-gateway.js';
|
|
7
7
|
import { portDefaults, portInstallSteps } from "./install-ports.js";
|
|
8
|
+
import { readMinMemoryMb, renderMemoryHook } from "./install-memory.js";
|
|
8
9
|
import { inspectPackageDependencies, dependencyInfo } from "./package-dependencies.js";
|
|
9
10
|
import { readInstallSettings, settingsInstallSteps, settingsConfig, renderSettingsHook } from './install-settings.js';
|
|
10
11
|
import { MODULE_UI_ENTRY, uiTreeDigest } from "./ui-assets.js";
|
|
@@ -186,6 +187,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
186
187
|
findings.push("DAEMON_RESTART_INVALID daemon restart requires a native daemon controller, without Compose supervision");
|
|
187
188
|
const { identityGateway, gateway } = await inspectGatewayAdmission(dir, paths, metadata.provider_only_oidc, findings);
|
|
188
189
|
await inspectExternalGateway(dir, paths, payload, metadata.gateway_external, findings);
|
|
190
|
+
const minMemoryMb = inspectMemoryRequirement(dir, metadata.minMemoryMb, findings);
|
|
189
191
|
const installSettings = await inspectInstallSettings(dir, payload, metadata, findings);
|
|
190
192
|
const hyperBackup = metadataText === undefined ? undefined : await inspectHyperBackup(dir, async () => {
|
|
191
193
|
const root = join(dir, "backup-inspection");
|
|
@@ -199,12 +201,14 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
199
201
|
const integrations = metadata.integrations ?? [];
|
|
200
202
|
await inspectCtlArtifacts(dir, paths, metadata.ctl, metadata.entry, findings);
|
|
201
203
|
if (metadata.compose !== undefined) {
|
|
202
|
-
const result = await inspectUnifiedCompose(dir, payload, { ...metadata, installSettings }, findings);
|
|
204
|
+
const result = await inspectUnifiedCompose(dir, payload, { ...metadata, installSettings, minMemoryMb }, findings);
|
|
203
205
|
if (dependencies) {
|
|
204
206
|
result.dependencies = dependencies;
|
|
205
207
|
}
|
|
206
208
|
if (installSettings)
|
|
207
209
|
result.installSettings = installSettings;
|
|
210
|
+
if (minMemoryMb !== undefined)
|
|
211
|
+
result.minMemoryMb = minMemoryMb;
|
|
208
212
|
if (hyperBackup)
|
|
209
213
|
result.hyperBackup = hyperBackup;
|
|
210
214
|
if (identityGateway)
|
|
@@ -346,7 +350,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
346
350
|
? await inspectLoginStyle(dir, info.package, Boolean(portal || executor?.policy.portal), findings)
|
|
347
351
|
: undefined;
|
|
348
352
|
if (standalone)
|
|
349
|
-
checkSharedFolder(dir, findings, info.package, sharedFolder, executor?.policy.scope === "install-selected", portal, hasExecutor, nativeGateway, info.os_min_ver, installSettings, integrations, metadata.installPorts);
|
|
353
|
+
checkSharedFolder(dir, findings, info.package, sharedFolder, executor?.policy.scope === "install-selected", portal, hasExecutor, nativeGateway, info.os_min_ver, installSettings, integrations, metadata.installPorts, minMemoryMb);
|
|
350
354
|
const icon = inspectPackageIcons(dir, findings);
|
|
351
355
|
const cgiEntry = payload.find((entry) => entry.path === CGI_PAYLOAD_PATH);
|
|
352
356
|
if (standalone && !cgiEntry) {
|
|
@@ -363,6 +367,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
363
367
|
...(identityGateway ? { identityGateway } : {}),
|
|
364
368
|
...(gateway ? { gateway } : {}),
|
|
365
369
|
...(installSettings ? { installSettings } : {}),
|
|
370
|
+
...(minMemoryMb !== undefined ? { minMemoryMb } : {}),
|
|
366
371
|
...(hyperBackup ? { hyperBackup } : {}),
|
|
367
372
|
...(launch ? { launch } : {}),
|
|
368
373
|
icon,
|
|
@@ -854,8 +859,8 @@ async function inspectUnifiedCompose(dir, payload, metadata, findings) {
|
|
|
854
859
|
throw new Error("gateway configuration differs from the declared package contract");
|
|
855
860
|
if (readOptional(join(dir, "conf/privilege")) !== renderNativePrivilege())
|
|
856
861
|
throw new Error("Compose hooks must run as the package account");
|
|
857
|
-
if (manifest.sharedFolder || metadata.installSettings || metadata.installPorts) {
|
|
858
|
-
for (const [name, text] of Object.entries(expectedWizardFiles(info.package, manifest.sharedFolder, false, undefined, metadata.installSettings, [], manifest.identityGateway?.listen.https, metadata.installPorts)))
|
|
862
|
+
if (manifest.sharedFolder || metadata.installSettings || metadata.installPorts || metadata.minMemoryMb !== undefined) {
|
|
863
|
+
for (const [name, text] of Object.entries(expectedWizardFiles(info.package, manifest.sharedFolder, false, undefined, metadata.installSettings, [], manifest.identityGateway?.listen.https, metadata.installPorts, metadata.minMemoryMb)))
|
|
859
864
|
if (readOptional(join(dir, "WIZARD_UIFILES", name)) !== text)
|
|
860
865
|
throw new Error(`unexpected WIZARD_UIFILES/${name}; native share selection must match the declaration`);
|
|
861
866
|
}
|
|
@@ -1510,7 +1515,7 @@ function checkBackground(dir, info, payload, findings, executor, daemon, bridge
|
|
|
1510
1515
|
* declaration (without one, any present file must be the default native
|
|
1511
1516
|
* install wizard), and no other install/upgrade wizard file may exist.
|
|
1512
1517
|
*/
|
|
1513
|
-
function checkSharedFolder(dir, findings, pkg, folder, selected = false, portal, executor = false, nativeGateway, osMinVer, installSettings, integrations = [], installPortDefinitions = {}) {
|
|
1518
|
+
function checkSharedFolder(dir, findings, pkg, folder, selected = false, portal, executor = false, nativeGateway, osMinVer, installSettings, integrations = [], installPortDefinitions = {}, minMemoryMb) {
|
|
1514
1519
|
const wizardDir = join(dir, "WIZARD_UIFILES");
|
|
1515
1520
|
const present = (existsSync(wizardDir) ? readdirSync(wizardDir) : [])
|
|
1516
1521
|
.filter((name) => /^(install|upgrade)_uifile(_|\.|$)/.test(name))
|
|
@@ -1537,7 +1542,7 @@ function checkSharedFolder(dir, findings, pkg, folder, selected = false, portal,
|
|
|
1537
1542
|
: {}),
|
|
1538
1543
|
...portalManifest(portal),
|
|
1539
1544
|
};
|
|
1540
|
-
const wizards = expectedWizardFiles(pkg, folder, selected, portal, installSettings, integrations, nativeGateway?.listen.https, installPortDefinitions);
|
|
1545
|
+
const wizards = expectedWizardFiles(pkg, folder, selected, portal, installSettings, integrations, nativeGateway?.listen.https, installPortDefinitions, minMemoryMb);
|
|
1541
1546
|
const source = selected
|
|
1542
1547
|
? "the install-selected policy"
|
|
1543
1548
|
: folder
|
|
@@ -1548,7 +1553,7 @@ function checkSharedFolder(dir, findings, pkg, folder, selected = false, portal,
|
|
|
1548
1553
|
? "the integrations declaration"
|
|
1549
1554
|
: "the native-go default install wizard";
|
|
1550
1555
|
// The default native wizard is optional; a declared shared folder or portal needs all of its files.
|
|
1551
|
-
for (const name of folder || selected || portal || installSettings || Object.keys(installPortDefinitions).length || integrations.length
|
|
1556
|
+
for (const name of folder || selected || portal || installSettings || Object.keys(installPortDefinitions).length || integrations.length || minMemoryMb !== undefined
|
|
1552
1557
|
? Object.keys(wizards)
|
|
1553
1558
|
: present.filter((n) => n in wizards)) {
|
|
1554
1559
|
if (readOptional(join(wizardDir, name)) !== wizards[name])
|
|
@@ -1570,6 +1575,28 @@ function checkSharedFolder(dir, findings, pkg, folder, selected = false, portal,
|
|
|
1570
1575
|
}
|
|
1571
1576
|
}
|
|
1572
1577
|
}
|
|
1578
|
+
/** Verify and peel only the exact memory prefix, within a canonical App wrapper if present. */
|
|
1579
|
+
function inspectMemoryRequirement(dir, value, findings) {
|
|
1580
|
+
const minMemoryMb = readMinMemoryMb(value, e => findings.push(`${e.code} ${e.message}`));
|
|
1581
|
+
const file = join(dir, "scripts/preinst");
|
|
1582
|
+
const text = readOptional(file);
|
|
1583
|
+
if (minMemoryMb === undefined) {
|
|
1584
|
+
if (text?.includes("[INSTALL_MEMORY_READ_WARNING]"))
|
|
1585
|
+
findings.push("INSTALL_MIN_MEMORY_INVALID memory check has no valid declaration");
|
|
1586
|
+
return undefined;
|
|
1587
|
+
}
|
|
1588
|
+
const prefix = renderMemoryHook(minMemoryMb);
|
|
1589
|
+
const sdk = text && sdkScriptOf("preinst", text)?.sdk;
|
|
1590
|
+
if (!text || !sdk?.startsWith("#!/bin/sh\n" + prefix) || text.split(prefix).length !== 2) {
|
|
1591
|
+
findings.push("INSTALL_MIN_MEMORY_INVALID scripts/preinst lacks the exact declared memory check");
|
|
1592
|
+
}
|
|
1593
|
+
else {
|
|
1594
|
+
writeFileSync(file, text.replace(prefix, ""));
|
|
1595
|
+
}
|
|
1596
|
+
if (readOptional(join(dir, "conf/privilege")) !== renderNativePrivilege())
|
|
1597
|
+
findings.push("INSTALL_MIN_MEMORY_INVALID memory check must run as the package account");
|
|
1598
|
+
return minMemoryMb;
|
|
1599
|
+
}
|
|
1573
1600
|
/** Validate SDK settings inventory and hook prefix before existing backend inspectors.
|
|
1574
1601
|
* All reads and temporary rewrites are in the extracted inspection directory. */
|
|
1575
1602
|
async function inspectInstallSettings(dir, payload, metadata, findings) {
|
|
@@ -1629,7 +1656,7 @@ async function inspectInstallSettings(dir, payload, metadata, findings) {
|
|
|
1629
1656
|
}
|
|
1630
1657
|
return settings;
|
|
1631
1658
|
}
|
|
1632
|
-
function expectedWizardFiles(pkg, folder, selected = false, portal, installSettings, integrations = [], settingsPort = 0, installPortDefinitions = {}) {
|
|
1659
|
+
function expectedWizardFiles(pkg, folder, selected = false, portal, installSettings, integrations = [], settingsPort = 0, installPortDefinitions = {}, minMemoryMb) {
|
|
1633
1660
|
const steps = selected
|
|
1634
1661
|
? (t) => [
|
|
1635
1662
|
...renderDelegateScopeSteps(t),
|
|
@@ -1638,11 +1665,11 @@ function expectedWizardFiles(pkg, folder, selected = false, portal, installSetti
|
|
|
1638
1665
|
: folder
|
|
1639
1666
|
? sharedFolderInstallSteps(pkg, folder)
|
|
1640
1667
|
: renderNativeInstallWizard;
|
|
1641
|
-
const install = renderInstallWizardFiles(pkg, t => [...steps(t), ...portInstallSteps({ package: pkg, ...(Object.keys(installPortDefinitions).length ? { installPorts: true } : {}) }, installPortDefinitions)(t), ...settingsInstallSteps(installSettings, settingsPort, Object.keys(installPortDefinitions).length ? pkg : undefined)(t), ...(portal ? [renderPortalWizardStep(t, portal.alias)] : []), ...integrationWizardSteps(t, integrations)]);
|
|
1668
|
+
const install = renderInstallWizardFiles(pkg, t => [...steps(t), ...portInstallSteps({ package: pkg, ...(Object.keys(installPortDefinitions).length ? { installPorts: true } : {}) }, installPortDefinitions)(t), ...settingsInstallSteps(installSettings, settingsPort, Object.keys(installPortDefinitions).length ? pkg : undefined)(t), ...(portal ? [renderPortalWizardStep(t, portal.alias)] : []), ...integrationWizardSteps(t, integrations)], minMemoryMb);
|
|
1642
1669
|
return {
|
|
1643
1670
|
...install.static,
|
|
1644
1671
|
...install.dynamic,
|
|
1645
|
-
...renderUpgradeWizardFiles(pkg, folder, integrations),
|
|
1672
|
+
...renderUpgradeWizardFiles(pkg, folder, integrations, minMemoryMb),
|
|
1646
1673
|
};
|
|
1647
1674
|
}
|
|
1648
1675
|
function portalManifest(portal) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StandaloneError } from "./manifest.js";
|
|
2
|
+
import { type Locale } from "./i18n.js";
|
|
3
|
+
/** MiB of physical MemTotal, not free/available memory or a model allowlist. */
|
|
4
|
+
export declare function readMinMemoryMb(value: unknown, fail: (error: StandaloneError) => void): number | undefined;
|
|
5
|
+
/** Shared by wizard and preinst. A missing, malformed or unreadable read allows installation. */
|
|
6
|
+
export declare function renderMemoryProbe(minMemoryMb: number): string;
|
|
7
|
+
export declare function memoryReason(minMemoryMb: number, locale: Locale, actual: string): string;
|
|
8
|
+
/** Runs in preinst for both install and upgrade, before other SDK or App work, as the package account. */
|
|
9
|
+
export declare function renderMemoryHook(minMemoryMb?: number): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DSM_LANGS, LOCALES } from "./i18n.js";
|
|
2
|
+
import { translator } from "../build-spk/wizard-i18n.js";
|
|
3
|
+
const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
4
|
+
/** MiB of physical MemTotal, not free/available memory or a model allowlist. */
|
|
5
|
+
export function readMinMemoryMb(value, fail) {
|
|
6
|
+
if (value === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > 2147483647) {
|
|
9
|
+
fail({ code: "INSTALL_MIN_MEMORY_INVALID", message: "install.min_memory_mb must be a positive integer in MiB, at most 2147483647" });
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
/** Shared by wizard and preinst. A missing, malformed or unreadable read allows installation. */
|
|
15
|
+
export function renderMemoryProbe(minMemoryMb) {
|
|
16
|
+
return `synopkgland_memory_kb=$(LC_ALL=C awk '
|
|
17
|
+
$1 == "MemTotal:" { count++; if (NF == 3 && $2 ~ /^[0-9]+$/ && $2 > 0 && $3 == "kB") total = $2 }
|
|
18
|
+
END { if (count == 1 && total > 0) printf "%.0f", total; else exit 1 }
|
|
19
|
+
' /proc/meminfo 2>/dev/null) || synopkgland_memory_kb=
|
|
20
|
+
synopkgland_memory_low=
|
|
21
|
+
if [ -n "$synopkgland_memory_kb" ]; then
|
|
22
|
+
synopkgland_memory_gb=$(LC_ALL=C awk -v kb="$synopkgland_memory_kb" 'BEGIN { printf "%.2f", kb / 1048576 }')
|
|
23
|
+
if LC_ALL=C awk -v kb="$synopkgland_memory_kb" 'BEGIN { exit !(kb < ${minMemoryMb * 1024}) }'; then
|
|
24
|
+
synopkgland_memory_low=1
|
|
25
|
+
fi
|
|
26
|
+
else
|
|
27
|
+
printf '%s\\n' '[INSTALL_MEMORY_READ_WARNING] Cannot read physical MemTotal; continuing installation' >&2
|
|
28
|
+
fi
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
export function memoryReason(minMemoryMb, locale, actual) {
|
|
32
|
+
return translator(locale)("memory.required", { required: String(Math.ceil(minMemoryMb / 1024)), actual });
|
|
33
|
+
}
|
|
34
|
+
/** Runs in preinst for both install and upgrade, before other SDK or App work, as the package account. */
|
|
35
|
+
export function renderMemoryHook(minMemoryMb) {
|
|
36
|
+
if (minMemoryMb === undefined)
|
|
37
|
+
return "";
|
|
38
|
+
const cases = LOCALES.map(locale => ` ${locale}|${DSM_LANGS[locale]}) synopkgland_memory_format=${quote(memoryReason(minMemoryMb, locale, "%s"))} ;;`).join("\n");
|
|
39
|
+
return `${renderMemoryProbe(minMemoryMb)}if [ -n "$synopkgland_memory_low" ]; then
|
|
40
|
+
case "\${SYNOPKG_DSM_LANGUAGE:-enu}" in
|
|
41
|
+
${cases}
|
|
42
|
+
*) synopkgland_memory_format=${quote(memoryReason(minMemoryMb, "en", "%s"))} ;;
|
|
43
|
+
esac
|
|
44
|
+
synopkgland_memory_message=$(printf "$synopkgland_memory_format" "$synopkgland_memory_gb")
|
|
45
|
+
printf '%s\\n' "$synopkgland_memory_message" >&2
|
|
46
|
+
if [ -n "\${SYNOPKG_TEMP_LOGFILE:-}" ]; then
|
|
47
|
+
printf '%s\\n' "$synopkgland_memory_message" > "$SYNOPKG_TEMP_LOGFILE" || :
|
|
48
|
+
fi
|
|
49
|
+
exit 1
|
|
50
|
+
fi
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { renderGatewayIngressCheck } from './native-gateway.js';
|
|
2
|
+
import { renderMemoryHook } from './install-memory.js';
|
|
2
3
|
import { renderSettingsHook } from './install-settings.js';
|
|
3
4
|
import { renderComposeRetainedData } from "../build-spk/compose-retained-data.js";
|
|
4
5
|
import { renderNativeGatewayDiagnostic, renderNativeGatewayPortWait, renderNativeGatewayPrepare } from './native-gateway.js';
|
|
@@ -24,7 +25,7 @@ export function renderStandaloneScript(name, manifest) {
|
|
|
24
25
|
}
|
|
25
26
|
function renderStandaloneScriptPrefix(name, manifest) {
|
|
26
27
|
const prepared = ['postinst', 'postupgrade'].includes(name) ? renderNativeGatewayPrepare(manifest) : '';
|
|
27
|
-
return renderGatewayIngressCheck(manifest, name) + renderNativeGatewayDiagnostic(manifest, name) + renderNativeGatewayPortWait(manifest, name) + renderSettingsHook(name, manifest) + prepared;
|
|
28
|
+
return (name === 'preinst' ? renderMemoryHook(manifest.minMemoryMb) : '') + renderGatewayIngressCheck(manifest, name) + renderNativeGatewayDiagnostic(manifest, name) + renderNativeGatewayPortWait(manifest, name) + renderSettingsHook(name, manifest) + prepared;
|
|
28
29
|
}
|
|
29
30
|
/** Settings inspection peels its hook only at the position build's renderer writes.
|
|
30
31
|
* The backend inspector then replays the entire remaining lifecycle script. */
|
|
@@ -116,6 +116,8 @@ export interface StandaloneManifest {
|
|
|
116
116
|
sharedFolder?: SharedFolder;
|
|
117
117
|
installSettings?: InstallSettings;
|
|
118
118
|
installPorts?: true;
|
|
119
|
+
/** `install.min_memory_mb`: minimum physical MemTotal in MiB at install and upgrade. */
|
|
120
|
+
minMemoryMb?: number;
|
|
119
121
|
/** `backup`: Hyper Backup application backup; on by default for native Apps, absent when opted out. */
|
|
120
122
|
hyperBackup?: HyperBackup;
|
|
121
123
|
/** Who may use the app at all; absent keeps the route policy alone. */
|
|
@@ -9,6 +9,7 @@ import { readRegistry, registryFile } from '../ctl/registry.js';
|
|
|
9
9
|
import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
10
10
|
import { nativeGatewaySdk } from "./native-gateway.js";
|
|
11
11
|
import { portDefaults } from "./install-ports.js";
|
|
12
|
+
import { readMinMemoryMb } from "./install-memory.js";
|
|
12
13
|
import { readPackageDependencies, packageDependencies, dependencyError } from "./package-dependencies.js";
|
|
13
14
|
import { readInstallSettings } from './install-settings.js';
|
|
14
15
|
import { auditGoRoutes } from './route-audit.js';
|
|
@@ -304,6 +305,7 @@ function readManifest(raw, c) {
|
|
|
304
305
|
? undefined
|
|
305
306
|
: readSharedFolder(raw.install, (e) => c.fail(e.code, e.message));
|
|
306
307
|
const installPorts = isRecord(raw.install) && raw.install.ports === true ? true : undefined;
|
|
308
|
+
const minMemoryMb = readMinMemoryMb(isRecord(raw.install) ? raw.install.min_memory_mb : undefined, e => c.fail(e.code, e.message));
|
|
307
309
|
if (isRecord(raw.install) && raw.install.ports !== undefined && raw.install.ports !== true)
|
|
308
310
|
c.fail("INSTALL_PORT_INVALID", "install.ports must be true when present");
|
|
309
311
|
const installSettings = readInstallSettings(isRecord(raw.install) ? raw.install.settings : undefined, e => c.fail(e.code, e.message));
|
|
@@ -682,6 +684,7 @@ function readManifest(raw, c) {
|
|
|
682
684
|
...(sharedFolder ? { sharedFolder } : {}),
|
|
683
685
|
...(installSettings ? { installSettings } : {}),
|
|
684
686
|
...(installPorts ? { installPorts } : {}),
|
|
687
|
+
...(minMemoryMb !== undefined ? { minMemoryMb } : {}),
|
|
685
688
|
...(hyperBackup ? { hyperBackup } : {}),
|
|
686
689
|
...(entry ? { entry } : {}),
|
|
687
690
|
...(integrations?.length ? { integrations } : {}),
|
|
@@ -39,7 +39,7 @@ export declare function renderSharedFolderUpgradeWizardFiles(pkg: string, folder
|
|
|
39
39
|
* The upgrade wizard: the shared folder choice, then the service callbacks an
|
|
40
40
|
* administrator re-approves on every upgrade. Empty without either.
|
|
41
41
|
*/
|
|
42
|
-
export declare function renderUpgradeWizardFiles(pkg: string, folder: SharedFolder | undefined, integrations?: readonly string[]): Record<string, string>;
|
|
42
|
+
export declare function renderUpgradeWizardFiles(pkg: string, folder: SharedFolder | undefined, integrations?: readonly string[], minMemoryMb?: number): Record<string, string>;
|
|
43
43
|
/** DSM substitutes wizard values and grants only the declared package account.
|
|
44
44
|
* On upgrade, omitted values reuse DSM's saved installer variables. */
|
|
45
45
|
export declare function sharedFolderResource(pkg: string, folder: SharedFolder): Record<string, unknown> | undefined;
|
|
@@ -2,7 +2,7 @@ import { DSM_LANGS, LOCALES } from "./i18n.js";
|
|
|
2
2
|
import { existingShareValidator } from "../build-spk/share-validation.js";
|
|
3
3
|
import { sharedFolderActivation, sharedFolderCombobox } from "../build-spk/share-combobox.js";
|
|
4
4
|
import { renderWizardFiles, translator } from "../build-spk/wizard-i18n.js";
|
|
5
|
-
import { integrationWizardSteps } from "../build-spk/install-wizard.js";
|
|
5
|
+
import { integrationWizardSteps, renderMemoryWizardCheck } from "../build-spk/install-wizard.js";
|
|
6
6
|
const FIELDS = new Set(["mode", "key", "name", "permission"]);
|
|
7
7
|
const KEY = /^[a-z][a-z0-9_]{0,31}$/;
|
|
8
8
|
const RESERVED_KEY = /^(pkgwizard_|synopkg|change_)/;
|
|
@@ -16,10 +16,10 @@ export function readSharedFolder(value, fail) {
|
|
|
16
16
|
fail({ code: "STANDALONE_SHARED_FOLDER_INVALID", message: `install.sharedFolder ${why}` });
|
|
17
17
|
return undefined;
|
|
18
18
|
};
|
|
19
|
-
if (!isRecord(value) || Object.keys(value).some((key) =>
|
|
20
|
-
return refuse(": only sharedFolder
|
|
19
|
+
if (!isRecord(value) || Object.keys(value).some((key) => !["sharedFolder", "settings", "ports", "min_memory_mb"].includes(key))) {
|
|
20
|
+
return refuse(": only sharedFolder, settings, ports and min_memory_mb are allowed.");
|
|
21
21
|
}
|
|
22
|
-
if (value.sharedFolder === undefined && (value.settings !== undefined || value.ports !== undefined))
|
|
22
|
+
if (value.sharedFolder === undefined && (value.settings !== undefined || value.ports !== undefined || value.min_memory_mb !== undefined))
|
|
23
23
|
return undefined;
|
|
24
24
|
const folder = value.sharedFolder;
|
|
25
25
|
if (!isRecord(folder) || Object.keys(folder).some((key) => !FIELDS.has(key))) {
|
|
@@ -151,8 +151,8 @@ export function renderSharedFolderUpgradeWizardFiles(pkg, folder) {
|
|
|
151
151
|
* The upgrade wizard: the shared folder choice, then the service callbacks an
|
|
152
152
|
* administrator re-approves on every upgrade. Empty without either.
|
|
153
153
|
*/
|
|
154
|
-
export function renderUpgradeWizardFiles(pkg, folder, integrations = []) {
|
|
155
|
-
if (!folder && !integrations.length)
|
|
154
|
+
export function renderUpgradeWizardFiles(pkg, folder, integrations = [], minMemoryMb) {
|
|
155
|
+
if (!folder && !integrations.length && minMemoryMb === undefined)
|
|
156
156
|
return {};
|
|
157
157
|
const files = renderWizardFiles("upgrade_uifile", t => [
|
|
158
158
|
...(folder ? [sharedFolderStep(t("upgrade.step"), upgradeItems(t, pkg, folder), folder)] : []),
|
|
@@ -172,6 +172,13 @@ export function renderUpgradeWizardFiles(pkg, folder, integrations = []) {
|
|
|
172
172
|
files[name] = sharedFolderUpgradeScript(pkg, folder.key, retained, fresh, invalid);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
+
if (minMemoryMb !== undefined) {
|
|
176
|
+
for (const locale of LOCALES) {
|
|
177
|
+
const name = locale === "en" ? "upgrade_uifile" : `upgrade_uifile_${DSM_LANGS[locale]}`;
|
|
178
|
+
const script = files[name + ".sh"] ?? `#!/bin/sh\n[ -z "\${SYNOPKG_TEMP_LOGFILE:-}" ] || exec > "$SYNOPKG_TEMP_LOGFILE"\ncat <<'SYNOPKGLAND_UPGRADE_WIZARD'\n${files[name]}\nSYNOPKGLAND_UPGRADE_WIZARD\n`;
|
|
179
|
+
files[name + ".sh"] = script.replace("#!/bin/sh\n", () => "#!/bin/sh\n" + renderMemoryWizardCheck(minMemoryMb, locale));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
175
182
|
return files;
|
|
176
183
|
}
|
|
177
184
|
/** DSM substitutes wizard values and grants only the declared package account.
|
package/dist/standalone/spk.js
CHANGED
|
@@ -303,6 +303,7 @@ export async function assembleStandaloneSpk(options) {
|
|
|
303
303
|
...(moduleVersion ? { ui_module: moduleVersion } : {}),
|
|
304
304
|
...(manifest.installSettings ? { installSettings: manifest.installSettings } : {}),
|
|
305
305
|
...(manifest.installPorts ? { installPorts: portDefaults(manifest) } : {}),
|
|
306
|
+
...(manifest.minMemoryMb !== undefined ? { minMemoryMb: manifest.minMemoryMb } : {}),
|
|
306
307
|
...(backup ? { hyperBackup: backupRecord(backup) } : {}),
|
|
307
308
|
...(manifest.integrations ? { integrations: manifest.integrations } : {}),
|
|
308
309
|
...(manifest.lifecycleTimeouts ? { lifecycleTimeouts: manifest.lifecycleTimeouts } : {}),
|
|
@@ -374,11 +375,11 @@ export async function assembleStandaloneSpk(options) {
|
|
|
374
375
|
: folder
|
|
375
376
|
? sharedFolderInstallSteps(manifest.package, folder)
|
|
376
377
|
: renderNativeInstallWizard;
|
|
377
|
-
const install = renderInstallWizardFiles(manifest.package, (t) => [...steps(t), ...portInstallSteps(manifest)(t), ...settingsInstallSteps(manifest.installSettings, manifest.identityGateway?.listen.https, manifest.installPorts ? manifest.package : undefined)(t), ...(portal ? [renderPortalWizardStep(t, portal.alias)] : []), ...integrationWizardSteps(t, manifest.integrations)]);
|
|
378
|
+
const install = renderInstallWizardFiles(manifest.package, (t) => [...steps(t), ...portInstallSteps(manifest)(t), ...settingsInstallSteps(manifest.installSettings, manifest.identityGateway?.listen.https, manifest.installPorts ? manifest.package : undefined)(t), ...(portal ? [renderPortalWizardStep(t, portal.alias)] : []), ...integrationWizardSteps(t, manifest.integrations)], manifest.minMemoryMb);
|
|
378
379
|
writeWizardUiFiles(staging, {
|
|
379
380
|
...install.static,
|
|
380
381
|
...install.dynamic,
|
|
381
|
-
...renderUpgradeWizardFiles(manifest.package, folder, manifest.integrations),
|
|
382
|
+
...renderUpgradeWizardFiles(manifest.package, folder, manifest.integrations, manifest.minMemoryMb),
|
|
382
383
|
...renderUninstallWizardFiles(manifest.package, "native", {
|
|
383
384
|
composeData: manifest.compose?.plan.app_data,
|
|
384
385
|
executor: Boolean(options.executor),
|
package/docs/app-entry.md
CHANGED
|
@@ -160,3 +160,20 @@ SO_PEERCRED authorization callback (nil denies all). Its owned 0711 directory
|
|
|
160
160
|
and 0666 socket admit connections from other packages while the callback and
|
|
161
161
|
per-request checks decide authority. The entry audit accepts direct calls and
|
|
162
162
|
rejects constructor aliases; custom listeners remain forbidden.
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
## Host activation
|
|
166
|
+
|
|
167
|
+
`ctx.host.subscribe('window-activated', listener)` observes the injected DSM
|
|
168
|
+
AppWindow's `activate` event, including switching back to the App and showing it
|
|
169
|
+
after minimization. The desktop document is shared with other Apps, so its
|
|
170
|
+
browser focus events do not indicate which App is active. A full-page shell
|
|
171
|
+
uses visible `visibilitychange` and `window` focus; DSM standalone pages also
|
|
172
|
+
observe their AppWindow. Signals within 50 ms are delivered once. There is no
|
|
173
|
+
initial callback, and listeners receive no native event data.
|
|
174
|
+
|
|
175
|
+
The return value is `{status: 'subscribed', dispose}` when supported. Dispose
|
|
176
|
+
on component unmount; host disposal removes all listeners and pending delivery.
|
|
177
|
+
Hide/deactivate cancels queued DSM notifications. Older generated hosts report
|
|
178
|
+
`unsupported`, so keep a manual check available. Activation only triggers a
|
|
179
|
+
fresh authenticated status read; it never proves another App completed setup.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Minimum physical memory
|
|
2
|
+
|
|
3
|
+
Declare a physical RAM requirement in `dsm-package.yaml`:
|
|
4
|
+
|
|
5
|
+
```yaml
|
|
6
|
+
install:
|
|
7
|
+
min_memory_mb: 1700
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
`min_memory_mb` is a positive integer threshold in **MiB** (1–2147483647), measured against `/proc/meminfo` **MemTotal** on the NAS at installation time. It measures physical memory visible to DSM, independently of free memory, swap, model names and the package server's architecture filters. RAM upgrades are detected automatically.
|
|
11
|
+
|
|
12
|
+
MemTotal excludes firmware and kernel reservations. Set the threshold to approximately **85% of the nominal capacity** when all machines of that capacity should work: use **1700 MiB for 2 GB NAS machines**, rather than 2048 MiB. Check the intended hardware's MemTotal before choosing a threshold. The requirement label rounds the threshold up to a whole GB (1700 MiB displays as 2 GB); the detected capacity uses two decimal places. Both use DSM's 1024-based convention, so displayed GB means 1024 MiB. The exact threshold, rather than the rounded label, controls admission.
|
|
13
|
+
|
|
14
|
+
The existing dynamic install and upgrade wizards read MemTotal on the NAS. Below the threshold they show a localized memory page in every supported wizard language, with a read-only field that always fails validation and `invalid_next_disabled_v2` to disable Next on DSM flows that honor it. Static fallback wizards retain their usual pages because they cannot know the NAS memory. CLI installation, wizard bypasses and DSM flows that do not honor wizard validation remain covered by preinst.
|
|
15
|
+
|
|
16
|
+
The generated **package-account preinst** checks the same threshold before other SDK work and the App's preinst hook, for **both installation and upgrade**. A low-memory result exits nonzero and writes the same localized reason to `SYNOPKG_TEMP_LOGFILE` for Package Center. Upgrade admission uses the incoming package's requirement even if an earlier version installed successfully. No root helper or runtime/start check is added.
|
|
17
|
+
|
|
18
|
+
An unreadable, missing or malformed MemTotal emits `INSTALL_MEMORY_READ_WARNING` to stderr and **allows installation**. This requirement stops clearly undersized machines; it does not reject an unfamiliar memory-reporting environment. Omitting the field preserves the existing installation behavior. `synopkgland inspect <spk> --json` reports `minMemoryMb` and verifies the generated memory check and wizard files against the packaged declaration.
|
|
19
|
+
|
|
20
|
+
See Synology's [wizard contract](https://help.synology.com/developer-guide/synology_package/wizard/WIZARD_UIFILES_v2.html) for dynamic wizard scripts and the `SYNOPKG_TEMP_LOGFILE` output channel.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synopackageland/cli",
|
|
3
|
-
"version": "0.52.
|
|
3
|
+
"version": "0.52.13",
|
|
4
4
|
"description": "Syno Package Land Developer Kit CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"skills",
|
|
23
23
|
"docs/shared-folders.md",
|
|
24
24
|
"docs/daemon-nofile.md",
|
|
25
|
-
"docs/compose-admin.md"
|
|
25
|
+
"docs/compose-admin.md",
|
|
26
|
+
"docs/install-memory.md"
|
|
26
27
|
],
|
|
27
28
|
"scripts": {
|
|
28
29
|
"check:docs": "node --test scripts/check-doc-versions.test.mjs && node scripts/check-doc-versions.mjs",
|
|
@@ -7,6 +7,21 @@
|
|
|
7
7
|
"required": ["schema"],
|
|
8
8
|
"properties": {
|
|
9
9
|
"schema": {"type": "integer", "const": 2},
|
|
10
|
+
"install": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"min_memory_mb": {
|
|
14
|
+
"type": "integer",
|
|
15
|
+
"minimum": 1,
|
|
16
|
+
"maximum": 2147483647,
|
|
17
|
+
"description": "Minimum physical /proc/meminfo MemTotal in MiB, checked dynamically on install and upgrade as the package account. Allow for firmware reservations: use about 85% of nominal RAM (1700 for a 2 GB NAS). Read failures warn and allow installation. No runtime check."
|
|
18
|
+
},
|
|
19
|
+
"sharedFolder": {"type": "object"},
|
|
20
|
+
"settings": {"type": "object"},
|
|
21
|
+
"ports": {"const": true}
|
|
22
|
+
},
|
|
23
|
+
"additionalProperties": false
|
|
24
|
+
},
|
|
10
25
|
"ui_secret_ignores": {
|
|
11
26
|
"description": "False-positive exceptions for public UI secret scanning. Exact paths relative to ui/; omit a module snapshot hash (app/help.json). Source maps cannot be ignored.",
|
|
12
27
|
"type": "array",
|
package/skills/SKILL.md
CHANGED
|
@@ -40,6 +40,8 @@ Query published releases with `npm view @synopackageland/cli version`,
|
|
|
40
40
|
`npm view @synopackageland/templates version` and `npm view @synopackageland/sdk version`;
|
|
41
41
|
keep the installed dependency tree and generated pins consistent.
|
|
42
42
|
|
|
43
|
+
For Apps with a physical RAM requirement, set `install.min_memory_mb` (MemTotal in MiB; use 1700 for 2 GB machines). The generated install/upgrade wizards and package-account preinst check it dynamically; read failures warn and allow installation, with no runtime check. See [minimum physical memory](../docs/install-memory.md).
|
|
44
|
+
|
|
43
45
|
For Apps with data folders or gateway listeners, read [reference/install.md](reference/install.md). Default to an App-named dedicated DSM data share and installer-selected ports. Existing-folder access, port number format/range and required HTTPS origins use localized wizard validation before Next; detected port conflicts are nonblocking inline warnings, and an unavailable DSM port inventory does not block installation; upgrades retain port selections.
|
|
44
46
|
|
|
45
47
|
For private native `<audio>` / `<video>` playback and seeking, read
|
|
@@ -6,6 +6,7 @@ Use matching CLI, SDK/App and templates releases, preserving the pins generated
|
|
|
6
6
|
|
|
7
7
|
```yaml
|
|
8
8
|
install:
|
|
9
|
+
min_memory_mb: 1700
|
|
9
10
|
ports: true
|
|
10
11
|
sharedFolder:
|
|
11
12
|
mode: dedicated
|
|
@@ -17,6 +18,8 @@ identity_gateway:
|
|
|
17
18
|
listen: {https: 28443}
|
|
18
19
|
```
|
|
19
20
|
|
|
21
|
+
Use `install.min_memory_mb` for a physical RAM requirement checked dynamically on the NAS during install and upgrade. The value is MemTotal in MiB, so allow for firmware reservations: 1700 MiB admits 2 GB machines. All wizard locales show a low-memory page; package-account preinst enforces the same threshold through Package Center. Unreadable MemTotal warns and allows installation; no runtime check is added. See [minimum physical memory](../../docs/install-memory.md).
|
|
22
|
+
|
|
20
23
|
For every App needing shared data, name the dedicated share after the package. The wizard defaults to that name, keeps it when the share list loads, and reuses the matching share if it exists. It also accepts a supported existing share. `mode: select` starts empty and requires an explicit choice; `mode: create` has no picker. Selecting a folder authorizes DSM's `data-share` worker to grant the declared RO/RW to the package account on install, upgrade/repair and starts. No pre-existing account or permission grant is required. Validation checks the name, existence and supported local mounted folder type, never package-account access. Local tiered/S2S shares are accepted; remote/C2, tiering buckets, WORM, unmounted, unavailable, moving, external and forced-read-only shares are refused. Runtime kernel checks still report the share, required access and recovery action when permission is revoked. No App root or ACL writer is generated.
|
|
21
24
|
|
|
22
25
|
The upgrade wizard prefills and submits the recorded folder without a separate change checkbox. Keep the dedicated name rather than clearing it. CLI automation uses `--param media=Media` on install and `--param CHANGE_media=true --param media=OtherMedia` to change it on upgrade/repair. Explicitly submit the saved folder when migrating older installations without saved DSM installer values.
|