@monkey-mini-app/panel 0.1.0 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/dist/{chunk-X3QW77RD.js → chunk-JAWSEXOV.js} +36 -5
- package/dist/index.cjs +1916 -595
- package/dist/index.d.cts +127 -3
- package/dist/index.d.ts +127 -3
- package/dist/index.js +1451 -169
- package/dist/themes.cjs +41 -4
- package/dist/themes.d.cts +22 -1
- package/dist/themes.d.ts +22 -1
- package/dist/themes.js +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TokenSet } from './themes.cjs';
|
|
2
|
-
export { CustomPaletteMap, ModeId, PALETTES, PaletteId, applyThemeTo, clampMode, clampPalette, cssVars, parseThemeCss, runnerThemeCss, themeLabelFromCss, tokensOf } from './themes.cjs';
|
|
2
|
+
export { CustomPaletteMap, GLOBAL_PALETTE_ID, LOCAL_PALETTE_ID, ModeId, PALETTES, PaletteId, applyThemeTo, clampMode, clampPalette, cssVars, effectivePalette, parseThemeCss, resolveMode, runnerThemeCss, selectedPalette, themeCssVars, themeLabelFromCss, tokensOf } from './themes.cjs';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
|
|
5
5
|
declare const LOCALE_IDS: readonly ["zh-CN", "en"];
|
|
@@ -15,6 +15,15 @@ type AppItem = {
|
|
|
15
15
|
theme: string;
|
|
16
16
|
palette: string;
|
|
17
17
|
} | null;
|
|
18
|
+
/** Parsed from the app's `theme.css` when present. */
|
|
19
|
+
localPalette?: {
|
|
20
|
+
label: string;
|
|
21
|
+
swatch: string;
|
|
22
|
+
tokens: {
|
|
23
|
+
light: TokenSet;
|
|
24
|
+
dark: TokenSet;
|
|
25
|
+
};
|
|
26
|
+
} | null;
|
|
18
27
|
};
|
|
19
28
|
type TabKind = "all" | "app";
|
|
20
29
|
type TabItem = {
|
|
@@ -27,6 +36,25 @@ type BrowseKind = "history" | "storage";
|
|
|
27
36
|
type ThemeScope = "global" | "app";
|
|
28
37
|
type DockId = "fill" | "side";
|
|
29
38
|
type CardStyle = "stamp" | "etch" | "hero" | "list";
|
|
39
|
+
type AboutPackage = {
|
|
40
|
+
name: string;
|
|
41
|
+
version: string;
|
|
42
|
+
};
|
|
43
|
+
type AboutInfo = {
|
|
44
|
+
adapter: string;
|
|
45
|
+
env: string;
|
|
46
|
+
packages: AboutPackage[];
|
|
47
|
+
};
|
|
48
|
+
type UpdateCheck = {
|
|
49
|
+
name: string;
|
|
50
|
+
current: string;
|
|
51
|
+
latest: string | null;
|
|
52
|
+
updateAvailable: boolean;
|
|
53
|
+
error?: string;
|
|
54
|
+
};
|
|
55
|
+
type UpdateCheckState = UpdateCheck & {
|
|
56
|
+
status: "idle" | "loading" | "done";
|
|
57
|
+
};
|
|
30
58
|
type CommitFile = {
|
|
31
59
|
path: string;
|
|
32
60
|
add?: number;
|
|
@@ -43,6 +71,22 @@ type StorageTable = {
|
|
|
43
71
|
name: string;
|
|
44
72
|
size?: number;
|
|
45
73
|
updatedAt?: string;
|
|
74
|
+
/** Top-level key count when the host knows. */
|
|
75
|
+
keys?: number;
|
|
76
|
+
};
|
|
77
|
+
/** Soft notice when a table crossed a size band — banner + copy-paste AI prompt. */
|
|
78
|
+
type StorageNotice = {
|
|
79
|
+
appId: string;
|
|
80
|
+
table: string;
|
|
81
|
+
bytes: number;
|
|
82
|
+
keys: number;
|
|
83
|
+
heavy: Array<{
|
|
84
|
+
key: string;
|
|
85
|
+
bytes: number;
|
|
86
|
+
kind: "list" | "map" | "value";
|
|
87
|
+
entries?: number;
|
|
88
|
+
}>;
|
|
89
|
+
prompt: string;
|
|
46
90
|
};
|
|
47
91
|
type PanelCapabilities = {
|
|
48
92
|
history: boolean;
|
|
@@ -69,11 +113,14 @@ type PanelActions = {
|
|
|
69
113
|
toggleSettings: (open: boolean) => void;
|
|
70
114
|
getCfg: () => Record<string, string>;
|
|
71
115
|
saveHostConfig: (form: Record<string, string>) => void;
|
|
116
|
+
checkUpdates: () => void;
|
|
72
117
|
toggleBrowse: (kind: string) => void;
|
|
73
118
|
loadCommitDetail: (id: string) => void;
|
|
74
119
|
loadTable: (name: string) => void;
|
|
75
120
|
browseBack: () => void;
|
|
76
121
|
browseFile: (path: string) => void;
|
|
122
|
+
dismissStorageNotice: () => void;
|
|
123
|
+
applyStorageNotice: (notice: StorageNotice) => void;
|
|
77
124
|
reloadActive: () => void;
|
|
78
125
|
askDelete: () => void;
|
|
79
126
|
hideModal: () => void;
|
|
@@ -106,6 +153,8 @@ type PanelState = {
|
|
|
106
153
|
cfgMsg: string;
|
|
107
154
|
cfgVersion: number;
|
|
108
155
|
cfg: Record<string, string>;
|
|
156
|
+
about: AboutInfo | null;
|
|
157
|
+
updateCheck: UpdateCheckState | null;
|
|
109
158
|
emptyText: string | undefined;
|
|
110
159
|
capabilities: PanelCapabilities;
|
|
111
160
|
locale: LocaleId;
|
|
@@ -120,6 +169,8 @@ type PanelState = {
|
|
|
120
169
|
browseTable: string | null;
|
|
121
170
|
browseTableValue: unknown;
|
|
122
171
|
browseOpenFile: string | null;
|
|
172
|
+
/** Latest storage-size notice for the active app; banner is dismissible. */
|
|
173
|
+
storageNotice: StorageNotice | null;
|
|
123
174
|
};
|
|
124
175
|
|
|
125
176
|
type I18nParams = Record<string, string | number>;
|
|
@@ -172,12 +223,20 @@ interface PanelHost {
|
|
|
172
223
|
load(): Promise<Record<string, string>>;
|
|
173
224
|
save(cfg: Record<string, string>): Promise<void>;
|
|
174
225
|
};
|
|
226
|
+
/** Settings → About: adapter / env / package versions + update check. */
|
|
227
|
+
about?: {
|
|
228
|
+
load(): Promise<AboutInfo>;
|
|
229
|
+
checkUpdates(): Promise<UpdateCheck>;
|
|
230
|
+
};
|
|
175
231
|
history?: {
|
|
176
232
|
list(appId: string): Promise<Commit[]>;
|
|
177
233
|
detail(appId: string, id: string): Promise<Commit>;
|
|
178
234
|
};
|
|
179
235
|
storage?: {
|
|
180
|
-
listTables(appId: string): Promise<
|
|
236
|
+
listTables(appId: string): Promise<{
|
|
237
|
+
tables: StorageTable[];
|
|
238
|
+
notices: StorageNotice[];
|
|
239
|
+
}>;
|
|
181
240
|
readTable(appId: string, name: string): Promise<unknown>;
|
|
182
241
|
};
|
|
183
242
|
onOpenRequest?(cb: (appId?: string) => void): () => void;
|
|
@@ -237,6 +296,24 @@ type FrameEnv = {
|
|
|
237
296
|
theme: string;
|
|
238
297
|
palette: string;
|
|
239
298
|
dock: string;
|
|
299
|
+
vars?: Record<string, string>;
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* A `mini_app_view_eval` query the host asked a rendered view to run. It arrives on the
|
|
303
|
+
* shell's existing event stream, and only the shell can cross into the iframe with it.
|
|
304
|
+
*/
|
|
305
|
+
type ViewEvalQuery = {
|
|
306
|
+
requestId: string;
|
|
307
|
+
appId: string;
|
|
308
|
+
code?: string;
|
|
309
|
+
maxBytes?: number;
|
|
310
|
+
};
|
|
311
|
+
type ViewEvalAnswer = {
|
|
312
|
+
requestId: string;
|
|
313
|
+
/** Set instead of `ok` when the shell holds no frame for the app. */
|
|
314
|
+
view?: "not-open";
|
|
315
|
+
ok?: boolean;
|
|
316
|
+
error?: Record<string, unknown>;
|
|
240
317
|
};
|
|
241
318
|
type FrameRecord = {
|
|
242
319
|
wrap: HTMLElement;
|
|
@@ -250,6 +327,11 @@ type FrameController = {
|
|
|
250
327
|
reload(appId: string): void;
|
|
251
328
|
postEnv(appId: string): void;
|
|
252
329
|
postEnvAll(): void;
|
|
330
|
+
/**
|
|
331
|
+
* Relay a view query into an app iframe. False means this shell holds no frame for the
|
|
332
|
+
* app — the caller must answer `not-open` rather than let the host wait out its timeout.
|
|
333
|
+
*/
|
|
334
|
+
postViewEval(query: ViewEvalQuery): boolean;
|
|
253
335
|
/** Set/rebind the container the app iframes mount into (e.g. the panel's #mma-frames). */
|
|
254
336
|
setContainer(el: HTMLElement): void;
|
|
255
337
|
readonly map: Map<string, FrameRecord>;
|
|
@@ -371,11 +453,53 @@ declare class HostUnreachableError extends Error {
|
|
|
371
453
|
constructor(url: string, cause?: unknown);
|
|
372
454
|
}
|
|
373
455
|
declare function isHostUnreachable(e: unknown): e is HostUnreachableError;
|
|
456
|
+
/**
|
|
457
|
+
* The frame URL carries exactly what the runner reads back out of `location.search`
|
|
458
|
+
* (`http/app-runner-html.ts`: theme / palette / dock). CSS variables do **not** travel here —
|
|
459
|
+
* they go over the `mma-set-env` postMessage.
|
|
460
|
+
*
|
|
461
|
+
* Callers hand us the whole app env, which also holds a `vars` map. Letting that reach
|
|
462
|
+
* `URLSearchParams` stringifies it to `[object Object]` and puts the junk in every iframe src,
|
|
463
|
+
* and TypeScript cannot catch it: excess-property checks apply to fresh literals, and this
|
|
464
|
+
* arrives as a variable. Picking the keys here keeps the invariant in one place, so a future
|
|
465
|
+
* caller cannot reintroduce it.
|
|
466
|
+
*/
|
|
374
467
|
declare function appFrameUrl(origin: string, appId: string, query: {
|
|
375
468
|
theme: string;
|
|
376
469
|
palette: string;
|
|
377
470
|
dock: string;
|
|
378
471
|
}): string;
|
|
472
|
+
/** What the host pushes on `GET /api/events`. */
|
|
473
|
+
type HostEventHandlers = {
|
|
474
|
+
onOpen?: (appId: string, title?: string) => void;
|
|
475
|
+
/** Sources were recompiled: an already-open iframe must refetch, not keep old code. */
|
|
476
|
+
onReload?: (appId: string) => void;
|
|
477
|
+
/**
|
|
478
|
+
* The host wants an answer from a rendered view. Only the shell can deliver it: the iframe
|
|
479
|
+
* is cross-origin, so `postMessage` is the one door from this page into that one.
|
|
480
|
+
*/
|
|
481
|
+
onEval?: (query: ViewEvalQuery) => void;
|
|
482
|
+
/** A storage table crossed a size band — soft banner, writes were not blocked. */
|
|
483
|
+
onStorageNotice?: (notice: StorageNotice) => void;
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* Relay one host view query into the iframe that renders `appId`, or answer on the app's
|
|
487
|
+
* behalf when no shell here is showing it.
|
|
488
|
+
*
|
|
489
|
+
* Answering `not-open` immediately is what makes the distinction real: without it the host
|
|
490
|
+
* can only see "nobody replied" and has to guess between a closed app and a wedged one.
|
|
491
|
+
* Reused by every adapter (panel shell, dsh client) so hosts get identical freshness
|
|
492
|
+
* semantics instead of subtly different ones.
|
|
493
|
+
*/
|
|
494
|
+
declare function relayViewEval(origin: string, frames: FrameController, query: ViewEvalQuery): void;
|
|
495
|
+
/**
|
|
496
|
+
* Subscribe to the host event stream. Returns an unsubscribe function.
|
|
497
|
+
*
|
|
498
|
+
* Lives here rather than in each adapter so every host gets the same freshness
|
|
499
|
+
* semantics for free. A missing/blocked stream is not fatal — it only costs live
|
|
500
|
+
* refresh, so failures degrade to the old behaviour and stay silent.
|
|
501
|
+
*/
|
|
502
|
+
declare function subscribeHostEvents(origin: string, handlers: HostEventHandlers): () => void;
|
|
379
503
|
declare function parseAppsResponse(raw: unknown): AppItem[];
|
|
380
504
|
declare function hostConfigToForm(raw: unknown, cardStyle: string): Record<string, string>;
|
|
381
505
|
declare function formToHostConfigBody(form: Record<string, string>): Record<string, unknown>;
|
|
@@ -398,4 +522,4 @@ declare function injectPanelCss(): void;
|
|
|
398
522
|
|
|
399
523
|
declare const packageName = "@monkey-mini-app/panel";
|
|
400
524
|
|
|
401
|
-
export { type AppItem, AppList, Browse, type BrowseKind, type CardStyle, type Commit, type CommitFile, type CreateMiniAppPanelOptions, type DockId, type FrameController, type FrameControllerOptions, type FrameEnv, type FrameRecord, type HostShellInstance, type HostShellOptions, HostUnreachableError, type I18nParams, LOCALE_IDS, ListRegion, Loading, type LocaleId, MiniAppPanel, Modal, PANEL_CSS_TAG, type Palette, type PanelActions, type PanelCapabilities, PanelError, type PanelHost, type PanelI18n, type PanelInstance, PanelProvider, type PanelState, type RestOptions, Settings, type StorageTable, type TabItem, type TabKind, Tabs, ThemePop, type ThemeScope, TokenSet, Toolbar, activeAppFrom, appBlurb, appFrameUrl, capabilitiesOf, clampPaletteId, createFrameController, createHostShell, createMiniAppPanel, createPanelActions, createPanelI18n, createRestPanelHost, defaultHideThemePop, formToHostConfigBody, getPanelState, hostConfigToForm, hue, injectPanelCss, isHostUnreachable, monoOf, packageName, parseAppsResponse, parseCommitDetail, parseCommitList, parsePalettes, parseStorageTables, readJson, resetPanelState, resolvePanelLocale, setPanelState, subscribePanel, usePanelActions, usePanelI18n, usePanelState };
|
|
525
|
+
export { type AboutInfo, type AboutPackage, type AppItem, AppList, Browse, type BrowseKind, type CardStyle, type Commit, type CommitFile, type CreateMiniAppPanelOptions, type DockId, type FrameController, type FrameControllerOptions, type FrameEnv, type FrameRecord, type HostEventHandlers, type HostShellInstance, type HostShellOptions, HostUnreachableError, type I18nParams, LOCALE_IDS, ListRegion, Loading, type LocaleId, MiniAppPanel, Modal, PANEL_CSS_TAG, type Palette, type PanelActions, type PanelCapabilities, PanelError, type PanelHost, type PanelI18n, type PanelInstance, PanelProvider, type PanelState, type RestOptions, Settings, type StorageNotice, type StorageTable, type TabItem, type TabKind, Tabs, ThemePop, type ThemeScope, TokenSet, Toolbar, type UpdateCheck, type UpdateCheckState, type ViewEvalAnswer, type ViewEvalQuery, activeAppFrom, appBlurb, appFrameUrl, capabilitiesOf, clampPaletteId, createFrameController, createHostShell, createMiniAppPanel, createPanelActions, createPanelI18n, createRestPanelHost, defaultHideThemePop, formToHostConfigBody, getPanelState, hostConfigToForm, hue, injectPanelCss, isHostUnreachable, monoOf, packageName, parseAppsResponse, parseCommitDetail, parseCommitList, parsePalettes, parseStorageTables, readJson, relayViewEval, resetPanelState, resolvePanelLocale, setPanelState, subscribeHostEvents, subscribePanel, usePanelActions, usePanelI18n, usePanelState };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TokenSet } from './themes.js';
|
|
2
|
-
export { CustomPaletteMap, ModeId, PALETTES, PaletteId, applyThemeTo, clampMode, clampPalette, cssVars, parseThemeCss, runnerThemeCss, themeLabelFromCss, tokensOf } from './themes.js';
|
|
2
|
+
export { CustomPaletteMap, GLOBAL_PALETTE_ID, LOCAL_PALETTE_ID, ModeId, PALETTES, PaletteId, applyThemeTo, clampMode, clampPalette, cssVars, effectivePalette, parseThemeCss, resolveMode, runnerThemeCss, selectedPalette, themeCssVars, themeLabelFromCss, tokensOf } from './themes.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
|
|
5
5
|
declare const LOCALE_IDS: readonly ["zh-CN", "en"];
|
|
@@ -15,6 +15,15 @@ type AppItem = {
|
|
|
15
15
|
theme: string;
|
|
16
16
|
palette: string;
|
|
17
17
|
} | null;
|
|
18
|
+
/** Parsed from the app's `theme.css` when present. */
|
|
19
|
+
localPalette?: {
|
|
20
|
+
label: string;
|
|
21
|
+
swatch: string;
|
|
22
|
+
tokens: {
|
|
23
|
+
light: TokenSet;
|
|
24
|
+
dark: TokenSet;
|
|
25
|
+
};
|
|
26
|
+
} | null;
|
|
18
27
|
};
|
|
19
28
|
type TabKind = "all" | "app";
|
|
20
29
|
type TabItem = {
|
|
@@ -27,6 +36,25 @@ type BrowseKind = "history" | "storage";
|
|
|
27
36
|
type ThemeScope = "global" | "app";
|
|
28
37
|
type DockId = "fill" | "side";
|
|
29
38
|
type CardStyle = "stamp" | "etch" | "hero" | "list";
|
|
39
|
+
type AboutPackage = {
|
|
40
|
+
name: string;
|
|
41
|
+
version: string;
|
|
42
|
+
};
|
|
43
|
+
type AboutInfo = {
|
|
44
|
+
adapter: string;
|
|
45
|
+
env: string;
|
|
46
|
+
packages: AboutPackage[];
|
|
47
|
+
};
|
|
48
|
+
type UpdateCheck = {
|
|
49
|
+
name: string;
|
|
50
|
+
current: string;
|
|
51
|
+
latest: string | null;
|
|
52
|
+
updateAvailable: boolean;
|
|
53
|
+
error?: string;
|
|
54
|
+
};
|
|
55
|
+
type UpdateCheckState = UpdateCheck & {
|
|
56
|
+
status: "idle" | "loading" | "done";
|
|
57
|
+
};
|
|
30
58
|
type CommitFile = {
|
|
31
59
|
path: string;
|
|
32
60
|
add?: number;
|
|
@@ -43,6 +71,22 @@ type StorageTable = {
|
|
|
43
71
|
name: string;
|
|
44
72
|
size?: number;
|
|
45
73
|
updatedAt?: string;
|
|
74
|
+
/** Top-level key count when the host knows. */
|
|
75
|
+
keys?: number;
|
|
76
|
+
};
|
|
77
|
+
/** Soft notice when a table crossed a size band — banner + copy-paste AI prompt. */
|
|
78
|
+
type StorageNotice = {
|
|
79
|
+
appId: string;
|
|
80
|
+
table: string;
|
|
81
|
+
bytes: number;
|
|
82
|
+
keys: number;
|
|
83
|
+
heavy: Array<{
|
|
84
|
+
key: string;
|
|
85
|
+
bytes: number;
|
|
86
|
+
kind: "list" | "map" | "value";
|
|
87
|
+
entries?: number;
|
|
88
|
+
}>;
|
|
89
|
+
prompt: string;
|
|
46
90
|
};
|
|
47
91
|
type PanelCapabilities = {
|
|
48
92
|
history: boolean;
|
|
@@ -69,11 +113,14 @@ type PanelActions = {
|
|
|
69
113
|
toggleSettings: (open: boolean) => void;
|
|
70
114
|
getCfg: () => Record<string, string>;
|
|
71
115
|
saveHostConfig: (form: Record<string, string>) => void;
|
|
116
|
+
checkUpdates: () => void;
|
|
72
117
|
toggleBrowse: (kind: string) => void;
|
|
73
118
|
loadCommitDetail: (id: string) => void;
|
|
74
119
|
loadTable: (name: string) => void;
|
|
75
120
|
browseBack: () => void;
|
|
76
121
|
browseFile: (path: string) => void;
|
|
122
|
+
dismissStorageNotice: () => void;
|
|
123
|
+
applyStorageNotice: (notice: StorageNotice) => void;
|
|
77
124
|
reloadActive: () => void;
|
|
78
125
|
askDelete: () => void;
|
|
79
126
|
hideModal: () => void;
|
|
@@ -106,6 +153,8 @@ type PanelState = {
|
|
|
106
153
|
cfgMsg: string;
|
|
107
154
|
cfgVersion: number;
|
|
108
155
|
cfg: Record<string, string>;
|
|
156
|
+
about: AboutInfo | null;
|
|
157
|
+
updateCheck: UpdateCheckState | null;
|
|
109
158
|
emptyText: string | undefined;
|
|
110
159
|
capabilities: PanelCapabilities;
|
|
111
160
|
locale: LocaleId;
|
|
@@ -120,6 +169,8 @@ type PanelState = {
|
|
|
120
169
|
browseTable: string | null;
|
|
121
170
|
browseTableValue: unknown;
|
|
122
171
|
browseOpenFile: string | null;
|
|
172
|
+
/** Latest storage-size notice for the active app; banner is dismissible. */
|
|
173
|
+
storageNotice: StorageNotice | null;
|
|
123
174
|
};
|
|
124
175
|
|
|
125
176
|
type I18nParams = Record<string, string | number>;
|
|
@@ -172,12 +223,20 @@ interface PanelHost {
|
|
|
172
223
|
load(): Promise<Record<string, string>>;
|
|
173
224
|
save(cfg: Record<string, string>): Promise<void>;
|
|
174
225
|
};
|
|
226
|
+
/** Settings → About: adapter / env / package versions + update check. */
|
|
227
|
+
about?: {
|
|
228
|
+
load(): Promise<AboutInfo>;
|
|
229
|
+
checkUpdates(): Promise<UpdateCheck>;
|
|
230
|
+
};
|
|
175
231
|
history?: {
|
|
176
232
|
list(appId: string): Promise<Commit[]>;
|
|
177
233
|
detail(appId: string, id: string): Promise<Commit>;
|
|
178
234
|
};
|
|
179
235
|
storage?: {
|
|
180
|
-
listTables(appId: string): Promise<
|
|
236
|
+
listTables(appId: string): Promise<{
|
|
237
|
+
tables: StorageTable[];
|
|
238
|
+
notices: StorageNotice[];
|
|
239
|
+
}>;
|
|
181
240
|
readTable(appId: string, name: string): Promise<unknown>;
|
|
182
241
|
};
|
|
183
242
|
onOpenRequest?(cb: (appId?: string) => void): () => void;
|
|
@@ -237,6 +296,24 @@ type FrameEnv = {
|
|
|
237
296
|
theme: string;
|
|
238
297
|
palette: string;
|
|
239
298
|
dock: string;
|
|
299
|
+
vars?: Record<string, string>;
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* A `mini_app_view_eval` query the host asked a rendered view to run. It arrives on the
|
|
303
|
+
* shell's existing event stream, and only the shell can cross into the iframe with it.
|
|
304
|
+
*/
|
|
305
|
+
type ViewEvalQuery = {
|
|
306
|
+
requestId: string;
|
|
307
|
+
appId: string;
|
|
308
|
+
code?: string;
|
|
309
|
+
maxBytes?: number;
|
|
310
|
+
};
|
|
311
|
+
type ViewEvalAnswer = {
|
|
312
|
+
requestId: string;
|
|
313
|
+
/** Set instead of `ok` when the shell holds no frame for the app. */
|
|
314
|
+
view?: "not-open";
|
|
315
|
+
ok?: boolean;
|
|
316
|
+
error?: Record<string, unknown>;
|
|
240
317
|
};
|
|
241
318
|
type FrameRecord = {
|
|
242
319
|
wrap: HTMLElement;
|
|
@@ -250,6 +327,11 @@ type FrameController = {
|
|
|
250
327
|
reload(appId: string): void;
|
|
251
328
|
postEnv(appId: string): void;
|
|
252
329
|
postEnvAll(): void;
|
|
330
|
+
/**
|
|
331
|
+
* Relay a view query into an app iframe. False means this shell holds no frame for the
|
|
332
|
+
* app — the caller must answer `not-open` rather than let the host wait out its timeout.
|
|
333
|
+
*/
|
|
334
|
+
postViewEval(query: ViewEvalQuery): boolean;
|
|
253
335
|
/** Set/rebind the container the app iframes mount into (e.g. the panel's #mma-frames). */
|
|
254
336
|
setContainer(el: HTMLElement): void;
|
|
255
337
|
readonly map: Map<string, FrameRecord>;
|
|
@@ -371,11 +453,53 @@ declare class HostUnreachableError extends Error {
|
|
|
371
453
|
constructor(url: string, cause?: unknown);
|
|
372
454
|
}
|
|
373
455
|
declare function isHostUnreachable(e: unknown): e is HostUnreachableError;
|
|
456
|
+
/**
|
|
457
|
+
* The frame URL carries exactly what the runner reads back out of `location.search`
|
|
458
|
+
* (`http/app-runner-html.ts`: theme / palette / dock). CSS variables do **not** travel here —
|
|
459
|
+
* they go over the `mma-set-env` postMessage.
|
|
460
|
+
*
|
|
461
|
+
* Callers hand us the whole app env, which also holds a `vars` map. Letting that reach
|
|
462
|
+
* `URLSearchParams` stringifies it to `[object Object]` and puts the junk in every iframe src,
|
|
463
|
+
* and TypeScript cannot catch it: excess-property checks apply to fresh literals, and this
|
|
464
|
+
* arrives as a variable. Picking the keys here keeps the invariant in one place, so a future
|
|
465
|
+
* caller cannot reintroduce it.
|
|
466
|
+
*/
|
|
374
467
|
declare function appFrameUrl(origin: string, appId: string, query: {
|
|
375
468
|
theme: string;
|
|
376
469
|
palette: string;
|
|
377
470
|
dock: string;
|
|
378
471
|
}): string;
|
|
472
|
+
/** What the host pushes on `GET /api/events`. */
|
|
473
|
+
type HostEventHandlers = {
|
|
474
|
+
onOpen?: (appId: string, title?: string) => void;
|
|
475
|
+
/** Sources were recompiled: an already-open iframe must refetch, not keep old code. */
|
|
476
|
+
onReload?: (appId: string) => void;
|
|
477
|
+
/**
|
|
478
|
+
* The host wants an answer from a rendered view. Only the shell can deliver it: the iframe
|
|
479
|
+
* is cross-origin, so `postMessage` is the one door from this page into that one.
|
|
480
|
+
*/
|
|
481
|
+
onEval?: (query: ViewEvalQuery) => void;
|
|
482
|
+
/** A storage table crossed a size band — soft banner, writes were not blocked. */
|
|
483
|
+
onStorageNotice?: (notice: StorageNotice) => void;
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* Relay one host view query into the iframe that renders `appId`, or answer on the app's
|
|
487
|
+
* behalf when no shell here is showing it.
|
|
488
|
+
*
|
|
489
|
+
* Answering `not-open` immediately is what makes the distinction real: without it the host
|
|
490
|
+
* can only see "nobody replied" and has to guess between a closed app and a wedged one.
|
|
491
|
+
* Reused by every adapter (panel shell, dsh client) so hosts get identical freshness
|
|
492
|
+
* semantics instead of subtly different ones.
|
|
493
|
+
*/
|
|
494
|
+
declare function relayViewEval(origin: string, frames: FrameController, query: ViewEvalQuery): void;
|
|
495
|
+
/**
|
|
496
|
+
* Subscribe to the host event stream. Returns an unsubscribe function.
|
|
497
|
+
*
|
|
498
|
+
* Lives here rather than in each adapter so every host gets the same freshness
|
|
499
|
+
* semantics for free. A missing/blocked stream is not fatal — it only costs live
|
|
500
|
+
* refresh, so failures degrade to the old behaviour and stay silent.
|
|
501
|
+
*/
|
|
502
|
+
declare function subscribeHostEvents(origin: string, handlers: HostEventHandlers): () => void;
|
|
379
503
|
declare function parseAppsResponse(raw: unknown): AppItem[];
|
|
380
504
|
declare function hostConfigToForm(raw: unknown, cardStyle: string): Record<string, string>;
|
|
381
505
|
declare function formToHostConfigBody(form: Record<string, string>): Record<string, unknown>;
|
|
@@ -398,4 +522,4 @@ declare function injectPanelCss(): void;
|
|
|
398
522
|
|
|
399
523
|
declare const packageName = "@monkey-mini-app/panel";
|
|
400
524
|
|
|
401
|
-
export { type AppItem, AppList, Browse, type BrowseKind, type CardStyle, type Commit, type CommitFile, type CreateMiniAppPanelOptions, type DockId, type FrameController, type FrameControllerOptions, type FrameEnv, type FrameRecord, type HostShellInstance, type HostShellOptions, HostUnreachableError, type I18nParams, LOCALE_IDS, ListRegion, Loading, type LocaleId, MiniAppPanel, Modal, PANEL_CSS_TAG, type Palette, type PanelActions, type PanelCapabilities, PanelError, type PanelHost, type PanelI18n, type PanelInstance, PanelProvider, type PanelState, type RestOptions, Settings, type StorageTable, type TabItem, type TabKind, Tabs, ThemePop, type ThemeScope, TokenSet, Toolbar, activeAppFrom, appBlurb, appFrameUrl, capabilitiesOf, clampPaletteId, createFrameController, createHostShell, createMiniAppPanel, createPanelActions, createPanelI18n, createRestPanelHost, defaultHideThemePop, formToHostConfigBody, getPanelState, hostConfigToForm, hue, injectPanelCss, isHostUnreachable, monoOf, packageName, parseAppsResponse, parseCommitDetail, parseCommitList, parsePalettes, parseStorageTables, readJson, resetPanelState, resolvePanelLocale, setPanelState, subscribePanel, usePanelActions, usePanelI18n, usePanelState };
|
|
525
|
+
export { type AboutInfo, type AboutPackage, type AppItem, AppList, Browse, type BrowseKind, type CardStyle, type Commit, type CommitFile, type CreateMiniAppPanelOptions, type DockId, type FrameController, type FrameControllerOptions, type FrameEnv, type FrameRecord, type HostEventHandlers, type HostShellInstance, type HostShellOptions, HostUnreachableError, type I18nParams, LOCALE_IDS, ListRegion, Loading, type LocaleId, MiniAppPanel, Modal, PANEL_CSS_TAG, type Palette, type PanelActions, type PanelCapabilities, PanelError, type PanelHost, type PanelI18n, type PanelInstance, PanelProvider, type PanelState, type RestOptions, Settings, type StorageNotice, type StorageTable, type TabItem, type TabKind, Tabs, ThemePop, type ThemeScope, TokenSet, Toolbar, type UpdateCheck, type UpdateCheckState, type ViewEvalAnswer, type ViewEvalQuery, activeAppFrom, appBlurb, appFrameUrl, capabilitiesOf, clampPaletteId, createFrameController, createHostShell, createMiniAppPanel, createPanelActions, createPanelI18n, createRestPanelHost, defaultHideThemePop, formToHostConfigBody, getPanelState, hostConfigToForm, hue, injectPanelCss, isHostUnreachable, monoOf, packageName, parseAppsResponse, parseCommitDetail, parseCommitList, parsePalettes, parseStorageTables, readJson, relayViewEval, resetPanelState, resolvePanelLocale, setPanelState, subscribeHostEvents, subscribePanel, usePanelActions, usePanelI18n, usePanelState };
|