@livx.cc/appwrap 0.39.3 → 0.39.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/package.json +1 -1
- package/runtime/app/shell/devmenu.ts +15 -4
- package/src/cli.ts +10 -0
- package/src/config.ts +21 -0
package/package.json
CHANGED
|
@@ -5,9 +5,10 @@ import { SHELL_BUILD, reloadWebView, getReportedWebVersion } from './handlers';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Shake-to-open developer menu (enabled in prod too, gated by `SHELL_CONFIG.devMenu`).
|
|
8
|
-
* A shake raises a native action sheet
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* A shake raises a native action sheet with: "App Info" — non-sensitive diagnostics (ids, versions,
|
|
9
|
+
* loader, remote host) including the running webapp's version vs. the latest deployed, so you can tell
|
|
10
|
+
* at a glance whether the device got the update; "Reload"; and "Toggle Debug" — a generic hook that
|
|
11
|
+
* dispatches the `appwrap:toggleDebug` DOM event so the web app can flip its OWN debug UI.
|
|
11
12
|
* The web version status is reported via the always-on `app.reportWebVersion` handler
|
|
12
13
|
* (in handlers.ts) — independent of this menu — and read here when the menu is shown.
|
|
13
14
|
*/
|
|
@@ -120,10 +121,11 @@ async function showDevMenu(): Promise<void> {
|
|
|
120
121
|
title: SHELL_CONFIG.name,
|
|
121
122
|
message: 'Developer menu',
|
|
122
123
|
cancelButtonText: 'Cancel',
|
|
123
|
-
actions: ['App Info', 'Reload'],
|
|
124
|
+
actions: ['App Info', 'Reload', 'Toggle Debug'],
|
|
124
125
|
});
|
|
125
126
|
if (action === 'App Info') await showInfo();
|
|
126
127
|
else if (action === 'Reload') reloadWebView();
|
|
128
|
+
else if (action === 'Toggle Debug') toggleWebDebug();
|
|
127
129
|
} finally {
|
|
128
130
|
menuOpen = false;
|
|
129
131
|
}
|
|
@@ -152,6 +154,15 @@ async function showInfo(): Promise<void> {
|
|
|
152
154
|
Dialogs.alert({ title: 'App Info', message: lines.join('\n'), okButtonText: 'Close' });
|
|
153
155
|
}
|
|
154
156
|
|
|
157
|
+
/** Generic dev hook: dispatch a DOM event the running web app can listen for to flip its OWN debug UI
|
|
158
|
+
* (`window.addEventListener('appwrap:toggleDebug', …)`). No-op for apps that don't listen — the shell
|
|
159
|
+
* has no app-specific debug state of its own, so it just relays the intent. */
|
|
160
|
+
function toggleWebDebug(): void {
|
|
161
|
+
bridge
|
|
162
|
+
.evalJs("window.dispatchEvent(new CustomEvent('appwrap:toggleDebug'))")
|
|
163
|
+
.catch((e) => console.log('[appwrap] toggleDebug dispatch failed:', e));
|
|
164
|
+
}
|
|
165
|
+
|
|
155
166
|
/** Read the running page's embedded version directly from the WebView: `window.__APP_VERSION__`,
|
|
156
167
|
* then a `<meta name="app-version">` fallback. '' if neither is present (or eval fails). */
|
|
157
168
|
async function readPageVersion(): Promise<string> {
|
package/src/cli.ts
CHANGED
|
@@ -20,6 +20,7 @@ import type * as CapManifest from '../../../runtime/app/shell/capabilities.manif
|
|
|
20
20
|
// Config shape lives in its own import-safe module so a `appwrap.config.ts` file can import the
|
|
21
21
|
// type + `defineConfig` helper without pulling in (and running) the CLI dispatch.
|
|
22
22
|
import type { AppwrapConfig } from './config';
|
|
23
|
+
import { unknownConfigKeys } from './config';
|
|
23
24
|
import {
|
|
24
25
|
androidScreenOrientation,
|
|
25
26
|
applyBuildNumberFlag,
|
|
@@ -377,6 +378,15 @@ async function loadConfig(cwd: string, flags: Record<string, string>): Promise<A
|
|
|
377
378
|
}
|
|
378
379
|
const cfg = await readConfigFile(configPath);
|
|
379
380
|
|
|
381
|
+
// Warn (never fail) on keys this appwrap doesn't recognize. A config authored for a NEWER appwrap
|
|
382
|
+
// silently no-ops its unknown keys on an older install (e.g. `targetedDevices` before 0.39 → wrong
|
|
383
|
+
// device family, no error). Turn that silent no-op into a signal.
|
|
384
|
+
const stray = unknownConfigKeys(cfg as unknown as Record<string, unknown>);
|
|
385
|
+
if (stray.length) {
|
|
386
|
+
const ver = pkgVersion(resolve(import.meta.dir, '../package.json'));
|
|
387
|
+
for (const k of stray) console.warn(`⚠ appwrap: unrecognized config key '${k}' — ignored. If you expect it to apply, your installed @livx.cc/appwrap (${ver}) may predate it — upgrade.`);
|
|
388
|
+
}
|
|
389
|
+
|
|
380
390
|
// Manifest as source: the appwrap config wins, the PWA manifest fills the gaps, template default last.
|
|
381
391
|
// (DRY single-source — devs don't re-type identity already declared in the manifest.) See mergeManifest.
|
|
382
392
|
if (cfg.pwaDist) mergeManifest(cfg, loadManifest(cwd, cfg));
|
package/src/config.ts
CHANGED
|
@@ -200,3 +200,24 @@ export interface AppwrapConfig {
|
|
|
200
200
|
export function defineConfig(config: AppwrapConfig): AppwrapConfig {
|
|
201
201
|
return config;
|
|
202
202
|
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Top-level keys appwrap recognizes — KEEP IN SYNC with `AppwrapConfig` above (top-level only; nested
|
|
206
|
+
* keys like `push.ios` are not listed). Drives `unknownConfigKeys`, which warns (never fails) on stray
|
|
207
|
+
* keys at load time. The motivating bug: a config written for a NEWER appwrap silently no-ops its
|
|
208
|
+
* unknown keys on an OLDER installed version (e.g. `targetedDevices` before 0.39 → a universal build
|
|
209
|
+
* with no error, then an App Store rejection). A loud warning turns that silent no-op into a signal.
|
|
210
|
+
*/
|
|
211
|
+
export const KNOWN_CONFIG_KEYS: ReadonlySet<string> = new Set([
|
|
212
|
+
'appBoundDomains', 'backendOrigin', 'backgroundColor', 'backgroundTasks', 'buildNumber', 'debug',
|
|
213
|
+
'debugLog', 'devMenu', 'edgeToEdge', 'entry', 'icon', 'id', 'loader', 'modules', 'name',
|
|
214
|
+
'neutralizeServiceWorker', 'openNewWindowsInBrowser', 'orientation', 'overrides', 'permissions',
|
|
215
|
+
'plugins', 'push', 'pwaDist', 'queryPackages', 'queryUrlSchemes', 'serverUrl', 'statusBarStyle',
|
|
216
|
+
'storekitConfig', 'targetedDevices', 'teamId', 'themeColor', 'trackingDomains', 'urlScheme',
|
|
217
|
+
'usesNonExemptEncryption', 'vendorPaths', 'version',
|
|
218
|
+
]);
|
|
219
|
+
|
|
220
|
+
/** Config keys appwrap doesn't recognize (pure — the caller decides how to surface them). */
|
|
221
|
+
export function unknownConfigKeys(cfg: Record<string, unknown>): string[] {
|
|
222
|
+
return Object.keys(cfg).filter((k) => !KNOWN_CONFIG_KEYS.has(k));
|
|
223
|
+
}
|