@glassly/engine 0.4.0-beta.1059 → 0.4.0-beta.1076

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.
Files changed (54) hide show
  1. package/build/engine.d.ts +1 -0
  2. package/build/engine.d.ts.map +1 -1
  3. package/build/facades/permissions.d.ts.map +1 -1
  4. package/build/facades/permissions.js +0 -2
  5. package/build/facades/permissions.js.map +1 -1
  6. package/build/facades/phoneNotifications.d.ts +7 -0
  7. package/build/facades/phoneNotifications.d.ts.map +1 -1
  8. package/build/facades/phoneNotifications.js +6 -0
  9. package/build/facades/phoneNotifications.js.map +1 -1
  10. package/build/generated/releaseMetadata.js +3 -3
  11. package/build/generated/releaseMetadata.js.map +1 -1
  12. package/build/index.d.ts +1 -0
  13. package/build/index.d.ts.map +1 -1
  14. package/build/index.js.map +1 -1
  15. package/build/services/LocalLlmModelManager.d.ts.map +1 -1
  16. package/build/services/LocalLlmModelManager.js +4 -3
  17. package/build/services/LocalLlmModelManager.js.map +1 -1
  18. package/build/services/LocalLlmProvider.d.ts.map +1 -1
  19. package/build/services/LocalLlmProvider.js +5 -6
  20. package/build/services/LocalLlmProvider.js.map +1 -1
  21. package/build/services/LocalMiniappRuntime.d.ts +3 -0
  22. package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
  23. package/build/services/LocalMiniappRuntime.js +67 -1
  24. package/build/services/LocalMiniappRuntime.js.map +1 -1
  25. package/build/services/notifications/miniappNotifications.d.ts +31 -0
  26. package/build/services/notifications/miniappNotifications.d.ts.map +1 -0
  27. package/build/services/notifications/miniappNotifications.js +24 -0
  28. package/build/services/notifications/miniappNotifications.js.map +1 -0
  29. package/build/services/pages/pageEligibility.d.ts +1 -2
  30. package/build/services/pages/pageEligibility.d.ts.map +1 -1
  31. package/build/services/pages/pageEligibility.js +4 -2
  32. package/build/services/pages/pageEligibility.js.map +1 -1
  33. package/build/services/uiShim.d.ts.map +1 -1
  34. package/build/services/uiShim.js +14 -0
  35. package/build/services/uiShim.js.map +1 -1
  36. package/build/stores/settings.d.ts.map +1 -1
  37. package/build/stores/settings.js +7 -8
  38. package/build/stores/settings.js.map +1 -1
  39. package/build/types/capabilities/nimo.d.ts.map +1 -1
  40. package/build/types/capabilities/nimo.js +2 -0
  41. package/build/types/capabilities/nimo.js.map +1 -1
  42. package/package.json +15 -15
  43. package/src/facades/permissions.ts +0 -2
  44. package/src/facades/phoneNotifications.ts +10 -0
  45. package/src/generated/releaseMetadata.ts +3 -3
  46. package/src/index.ts +1 -0
  47. package/src/services/LocalLlmModelManager.ts +4 -3
  48. package/src/services/LocalLlmProvider.ts +6 -7
  49. package/src/services/LocalMiniappRuntime.ts +79 -1
  50. package/src/services/notifications/miniappNotifications.ts +53 -0
  51. package/src/services/pages/pageEligibility.ts +3 -2
  52. package/src/services/uiShim.ts +14 -0
  53. package/src/stores/settings.ts +7 -8
  54. package/src/types/capabilities/nimo.ts +3 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Notifications miniapps post (`session.phone.notifications.post`) on their
3
+ * way into the host's phone-notification path. The runtime validates and
4
+ * emits here; the host subscribes through `engine.phoneNotifications` and
5
+ * feeds them to the same fan-out as the phone's own, with `system: false`
6
+ * and `source` set, so the dashboard, other readers and presentation treat
7
+ * them alike.
8
+ */
9
+ export interface MiniappNotificationPosted {
10
+ type: "posted";
11
+ notificationId: string;
12
+ source: string;
13
+ app: string;
14
+ title: string;
15
+ content: string;
16
+ timestamp: number;
17
+ }
18
+ export interface MiniappNotificationDismissed {
19
+ type: "dismissed";
20
+ notificationId: string;
21
+ source: string;
22
+ timestamp: number;
23
+ }
24
+ export type MiniappNotificationEvent = MiniappNotificationPosted | MiniappNotificationDismissed;
25
+ export declare const MINIAPP_NOTIFICATION_TITLE_MAX = 200;
26
+ export declare const MINIAPP_NOTIFICATION_CONTENT_MAX = 2000;
27
+ export declare const MINIAPP_NOTIFICATION_ID_MAX = 128;
28
+ export declare function miniappNotificationId(source: string, id: string): string;
29
+ export declare function emitMiniappNotification(event: MiniappNotificationEvent): void;
30
+ export declare function onMiniappNotification(listener: (event: MiniappNotificationEvent) => void): () => void;
31
+ //# sourceMappingURL=miniappNotifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"miniappNotifications.d.ts","sourceRoot":"","sources":["../../../src/services/notifications/miniappNotifications.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,QAAQ,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,WAAW,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,wBAAwB,GAAG,yBAAyB,GAAG,4BAA4B,CAAA;AAE/F,eAAO,MAAM,8BAA8B,MAAM,CAAA;AACjD,eAAO,MAAM,gCAAgC,OAAQ,CAAA;AACrD,eAAO,MAAM,2BAA2B,MAAM,CAAA;AAI9C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI,CAQ7E;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,GAAG,MAAM,IAAI,CAKrG"}
@@ -0,0 +1,24 @@
1
+ export const MINIAPP_NOTIFICATION_TITLE_MAX = 200;
2
+ export const MINIAPP_NOTIFICATION_CONTENT_MAX = 2_000;
3
+ export const MINIAPP_NOTIFICATION_ID_MAX = 128;
4
+ const listeners = new Set();
5
+ export function miniappNotificationId(source, id) {
6
+ return `${source}:${id}`;
7
+ }
8
+ export function emitMiniappNotification(event) {
9
+ for (const listener of listeners) {
10
+ try {
11
+ listener(event);
12
+ }
13
+ catch (err) {
14
+ console.warn(`miniappNotifications: listener threw: ${err?.message ?? err}`);
15
+ }
16
+ }
17
+ }
18
+ export function onMiniappNotification(listener) {
19
+ listeners.add(listener);
20
+ return () => {
21
+ listeners.delete(listener);
22
+ };
23
+ }
24
+ //# sourceMappingURL=miniappNotifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"miniappNotifications.js","sourceRoot":"","sources":["../../../src/services/notifications/miniappNotifications.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,CAAA;AACjD,MAAM,CAAC,MAAM,gCAAgC,GAAG,KAAK,CAAA;AACrD,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAA;AAE9C,MAAM,SAAS,GAAG,IAAI,GAAG,EAA6C,CAAA;AAEtE,MAAM,UAAU,qBAAqB,CAAC,MAAc,EAAE,EAAU;IAC9D,OAAO,GAAG,MAAM,IAAI,EAAE,EAAE,CAAA;AAC1B,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,KAA+B;IACrE,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,QAAQ,CAAC,KAAK,CAAC,CAAA;QACjB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,yCAA0C,GAAa,EAAE,OAAO,IAAI,GAAG,EAAE,CAAC,CAAA;QACzF,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,QAAmD;IACvF,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACvB,OAAO,GAAG,EAAE;QACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC5B,CAAC,CAAA;AACH,CAAC","sourcesContent":["/**\n * Notifications miniapps post (`session.phone.notifications.post`) on their\n * way into the host's phone-notification path. The runtime validates and\n * emits here; the host subscribes through `engine.phoneNotifications` and\n * feeds them to the same fan-out as the phone's own, with `system: false`\n * and `source` set, so the dashboard, other readers and presentation treat\n * them alike.\n */\nexport interface MiniappNotificationPosted {\n type: \"posted\"\n notificationId: string\n source: string\n app: string\n title: string\n content: string\n timestamp: number\n}\n\nexport interface MiniappNotificationDismissed {\n type: \"dismissed\"\n notificationId: string\n source: string\n timestamp: number\n}\n\nexport type MiniappNotificationEvent = MiniappNotificationPosted | MiniappNotificationDismissed\n\nexport const MINIAPP_NOTIFICATION_TITLE_MAX = 200\nexport const MINIAPP_NOTIFICATION_CONTENT_MAX = 2_000\nexport const MINIAPP_NOTIFICATION_ID_MAX = 128\n\nconst listeners = new Set<(event: MiniappNotificationEvent) => void>()\n\nexport function miniappNotificationId(source: string, id: string): string {\n return `${source}:${id}`\n}\n\nexport function emitMiniappNotification(event: MiniappNotificationEvent): void {\n for (const listener of listeners) {\n try {\n listener(event)\n } catch (err) {\n console.warn(`miniappNotifications: listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nexport function onMiniappNotification(listener: (event: MiniappNotificationEvent) => void): () => void {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n}\n"]}
@@ -2,8 +2,7 @@
2
2
  export declare function isCfwFirmwareVersion(firmwareVersion: string | null | undefined): boolean;
3
3
  /**
4
4
  * Only models that ship a Glassly custom firmware, and only while they run it.
5
- * Stock firmware on those models and every other model (NIMO, G1, ...) are
6
- * intentionally excluded.
5
+ * Stock firmware and every other model are intentionally excluded.
7
6
  */
8
7
  export declare function isCustomDashboardEligible(info: {
9
8
  model?: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"pageEligibility.d.ts","sourceRoot":"","sources":["../../../src/services/pages/pageEligibility.ts"],"names":[],"mappings":"AAaA,0GAA0G;AAC1G,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAKxF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAC,GAAG,OAAO,CAWjH;AAED,wBAAgB,aAAa,IAAI,OAAO,CAOvC"}
1
+ {"version":3,"file":"pageEligibility.d.ts","sourceRoot":"","sources":["../../../src/services/pages/pageEligibility.ts"],"names":[],"mappings":"AAaA,0GAA0G;AAC1G,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAKxF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAC,GAAG,OAAO,CAajH;AAED,wBAAgB,aAAa,IAAI,OAAO,CAOvC"}
@@ -17,12 +17,14 @@ export function isCfwFirmwareVersion(firmwareVersion) {
17
17
  }
18
18
  /**
19
19
  * Only models that ship a Glassly custom firmware, and only while they run it.
20
- * Stock firmware on those models and every other model (NIMO, G1, ...) are
21
- * intentionally excluded.
20
+ * Stock firmware and every other model are intentionally excluded.
22
21
  */
23
22
  export function isCustomDashboardEligible(info) {
24
23
  if (!info.model)
25
24
  return false;
25
+ // The NIMO drivers draw no scenes through its CFW yet; the dashboard would land on the text page.
26
+ if (info.model === DeviceTypes.NIMO)
27
+ return false;
26
28
  if (info.model === DeviceTypes.MEMOMIND_ONE) {
27
29
  const match = /^GLASSLYCFW\/([0-9]+)$/.exec(info.firmwareVersion ?? "");
28
30
  const revision = match ? Number(match[1]) : 0;
@@ -1 +1 @@
1
- {"version":3,"file":"pageEligibility.js","sourceRoot":"","sources":["../../../src/services/pages/pageEligibility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EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,KAAK,KAAK;QAAE,OAAO,KAAK,CAAA;IACzG,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;IACxC,OAAO,CACL,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC;QACpC,yBAAyB,CAAC,EAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,CAAC,eAAe,EAAC,CAAC,CAC9F,CAAA;AACH,CAAC","sourcesContent":["/**\n * Whether the dashboard view may show right now: connected Glassly CFW\n * glasses with the dashboard enabled. The page host reads it before showing\n * a page and hides the showing page when it turns false; the miniapp runtime\n * folds it into the designated app's `display.views` capability. Read at\n * decision time, never cached.\n */\nimport {useGlassesStore} from \"../../stores/glasses\"\nimport {SETTINGS, useSettingsStore} from \"../../stores/settings\"\nimport {DeviceTypes} from \"../../types/enums\"\nimport {getModelCapabilities} from \"../../types/hardware\"\nimport {isGlassesConnected} from \"../GlassesReadiness\"\n\n/** The SGC appends this marker after the firmware advertises Glassly CFW capabilities (G2, RayNeo iO). */\nexport function isCfwFirmwareVersion(firmwareVersion: string | null | undefined): boolean {\n return (\n firmwareVersion?.toLowerCase().includes(\"glassly cfw\") === true ||\n /^GLASSLYCFW\\/[0-9]+$/.test(firmwareVersion ?? \"\")\n )\n}\n\n/**\n * Only models that ship a Glassly custom firmware, and only while they run it.\n * Stock firmware on those models and every other model (NIMO, G1, ...) are\n * intentionally excluded.\n */\nexport function isCustomDashboardEligible(info: {model?: string | null; firmwareVersion?: string | null}): boolean {\n if (!info.model) return false\n if (info.model === DeviceTypes.MEMOMIND_ONE) {\n const match = /^GLASSLYCFW\\/([0-9]+)$/.exec(info.firmwareVersion ?? \"\")\n const revision = match ? Number(match[1]) : 0\n return Number.isSafeInteger(revision) && revision >= 10\n }\n return (\n getModelCapabilities(info.model as DeviceTypes).hasCustomFirmware === true &&\n isCfwFirmwareVersion(info.firmwareVersion)\n )\n}\n\nexport function pagesEligible(): boolean {\n if (useSettingsStore.getState().getSetting(SETTINGS.custom_dashboard_enabled.key) === false) return false\n const state = useGlassesStore.getState()\n return (\n isGlassesConnected(state.connection) &&\n isCustomDashboardEligible({model: state.deviceModel, firmwareVersion: state.firmwareVersion})\n )\n}\n"]}
1
+ {"version":3,"file":"pageEligibility.js","sourceRoot":"","sources":["../../../src/services/pages/pageEligibility.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAA;AAChE,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAC,kBAAkB,EAAC,MAAM,qBAAqB,CAAA;AAEtD,0GAA0G;AAC1G,MAAM,UAAU,oBAAoB,CAAC,eAA0C;IAC7E,OAAO,CACL,eAAe,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,IAAI;QAC/D,sBAAsB,CAAC,IAAI,CAAC,eAAe,IAAI,EAAE,CAAC,CACnD,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAA8D;IACtG,IAAI,CAAC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAA;IAC7B,kGAAkG;IAClG,IAAI,IAAI,CAAC,KAAK,KAAK,WAAW,CAAC,IAAI;QAAE,OAAO,KAAK,CAAA;IACjD,IAAI,IAAI,CAAC,KAAK,KAAK,WAAW,CAAC,YAAY,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAG,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,EAAE,CAAC,CAAA;QACvE,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC7C,OAAO,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,QAAQ,IAAI,EAAE,CAAA;IACzD,CAAC;IACD,OAAO,CACL,oBAAoB,CAAC,IAAI,CAAC,KAAoB,CAAC,CAAC,iBAAiB,KAAK,IAAI;QAC1E,oBAAoB,CAAC,IAAI,CAAC,eAAe,CAAC,CAC3C,CAAA;AACH,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,wBAAwB,CAAC,GAAG,CAAC,KAAK,KAAK;QAAE,OAAO,KAAK,CAAA;IACzG,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;IACxC,OAAO,CACL,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC;QACpC,yBAAyB,CAAC,EAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,CAAC,eAAe,EAAC,CAAC,CAC9F,CAAA;AACH,CAAC","sourcesContent":["/**\n * Whether the dashboard view may show right now: connected Glassly CFW\n * glasses with the dashboard enabled. The page host reads it before showing\n * a page and hides the showing page when it turns false; the miniapp runtime\n * folds it into the designated app's `display.views` capability. Read at\n * decision time, never cached.\n */\nimport {useGlassesStore} from \"../../stores/glasses\"\nimport {SETTINGS, useSettingsStore} from \"../../stores/settings\"\nimport {DeviceTypes} from \"../../types/enums\"\nimport {getModelCapabilities} from \"../../types/hardware\"\nimport {isGlassesConnected} from \"../GlassesReadiness\"\n\n/** The SGC appends this marker after the firmware advertises Glassly CFW capabilities (G2, RayNeo iO). */\nexport function isCfwFirmwareVersion(firmwareVersion: string | null | undefined): boolean {\n return (\n firmwareVersion?.toLowerCase().includes(\"glassly cfw\") === true ||\n /^GLASSLYCFW\\/[0-9]+$/.test(firmwareVersion ?? \"\")\n )\n}\n\n/**\n * Only models that ship a Glassly custom firmware, and only while they run it.\n * Stock firmware and every other model are intentionally excluded.\n */\nexport function isCustomDashboardEligible(info: {model?: string | null; firmwareVersion?: string | null}): boolean {\n if (!info.model) return false\n // The NIMO drivers draw no scenes through its CFW yet; the dashboard would land on the text page.\n if (info.model === DeviceTypes.NIMO) return false\n if (info.model === DeviceTypes.MEMOMIND_ONE) {\n const match = /^GLASSLYCFW\\/([0-9]+)$/.exec(info.firmwareVersion ?? \"\")\n const revision = match ? Number(match[1]) : 0\n return Number.isSafeInteger(revision) && revision >= 10\n }\n return (\n getModelCapabilities(info.model as DeviceTypes).hasCustomFirmware === true &&\n isCfwFirmwareVersion(info.firmwareVersion)\n )\n}\n\nexport function pagesEligible(): boolean {\n if (useSettingsStore.getState().getSetting(SETTINGS.custom_dashboard_enabled.key) === false) return false\n const state = useGlassesStore.getState()\n return (\n isGlassesConnected(state.connection) &&\n isCustomDashboardEligible({model: state.deviceModel, firmwareVersion: state.firmwareVersion})\n )\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"uiShim.d.ts","sourceRoot":"","sources":["../../src/services/uiShim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,yFAAyF;IACzF,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAgV1D"}
1
+ {"version":3,"file":"uiShim.d.ts","sourceRoot":"","sources":["../../src/services/uiShim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,yFAAyF;IACzF,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CA8V1D"}
@@ -297,6 +297,13 @@ export function buildUiShim(options) {
297
297
  postEnvelope({ type: 'set_background', color: color });
298
298
  }
299
299
 
300
+ var backHandler = null;
301
+
302
+ function setBackActionFn(handler) {
303
+ backHandler = typeof handler === 'function' ? handler : null;
304
+ postEnvelope({ type: 'set_back_action', shown: backHandler !== null });
305
+ }
306
+
300
307
  function fireChannel(channel, payload) {
301
308
  var list = channelHandlers[channel];
302
309
  if (!list || list.length === 0) {
@@ -341,6 +348,12 @@ export function buildUiShim(options) {
341
348
  }
342
349
  return;
343
350
  }
351
+ if (type === 'back') {
352
+ if (backHandler) {
353
+ try { backHandler(); } catch (e) {}
354
+ }
355
+ return;
356
+ }
344
357
  if (type === 'cancel' && typeof envelope.requestId === 'string') {
345
358
  // Background-side cancel (reserved; currently unused). If we had a
346
359
  // future bidirectional RPC this would abort an in-flight UI handler.
@@ -359,6 +372,7 @@ export function buildUiShim(options) {
359
372
  onClose: onClose,
360
373
  ready: readyFn,
361
374
  setBackgroundColor: setBackgroundColorFn,
375
+ setBackAction: setBackActionFn,
362
376
  /** @internal — packageName for diagnostic logs only. */
363
377
  _packageName: packageName,
364
378
  };
@@ -1 +1 @@
1
- {"version":3,"file":"uiShim.js","sourceRoot":"","sources":["../../src/services/uiShim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAQH,MAAM,UAAU,WAAW,CAAC,OAAsB;IAChD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3D,+DAA+D;IAC/D,mEAAmE;IACnE,yDAAyD;IACzD,OAAO;;;;sBAIa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsUpC,CAAC,IAAI,EAAE,CAAA;AACR,CAAC","sourcesContent":["/**\n * window.glassly — WebView-side bridge to the per-miniapp background JSContext.\n *\n * Injected into every UI WebView via `injectedJavaScriptBeforeContentLoaded`\n * (iOS) or `injectedJavaScriptObject` + a bundler-emitted inline `<script>`\n * (Android, where the `BeforeContentLoaded` prop is documented unreliable\n * per react-native-webview issues #1099 / #1609).\n *\n * The shim:\n * - Buffers `glassly.send(channel, payload)` calls until `glassly.ready()`\n * fires + the host acks the channel is open. WebView-side BUFFERS (the\n * WebView is the short-lived side and shouldn't drop user input).\n * - Installs `window.__host.recv(envelope)` for the host to push\n * background → WebView messages via `webview.injectJavaScript(...)`.\n * - Sends `__heartbeat__` every 5s; host considers the WebView gone\n * after 15s of silence.\n * - Maintains monotonic seq numbers; the host's per-WebView dedup window\n * drops replays during reconnect.\n *\n * This file exports a `buildUiShim()` function returning the JS\n * source as a string. The host's UIRouter wraps it inside the\n * existing WebView setup so a single bundler-time string emission covers\n * both platforms.\n *\n * IMPORTANT: the shim runs in the WebView's bare ECMAScript scope before\n * the miniapp's bundle. It must not import anything; the source is one\n * IIFE. The only injected dependencies are\n * `window.ReactNativeWebView.postMessage` (provided by react-native-webview)\n * and (on Android) `window.ReactNativeWebView.injectedObjectJson()`\n * (provided when the host sets `injectedJavaScriptObject`).\n */\n\nexport interface UiShimOptions {\n packageName: string\n /** @deprecated No longer used — heartbeat removed since WebViews are foreground-only. */\n heartbeatIntervalMs?: number\n}\n\nexport function buildUiShim(options: UiShimOptions): string {\n const packageNameJson = JSON.stringify(options.packageName)\n // The IIFE assembles a typed `glassly` global plus an internal\n // `__host` for host inbound calls. Quoted strings are JSON-safe so\n // direct injection inside another JS literal also works.\n return `\n(function () {\n if (typeof window === 'undefined') return;\n if (window.glassly && window.__host) return;\n var packageName = ${packageNameJson};\n // Resolve window.ReactNativeWebView.postMessage LAZILY, not once at shim-eval.\n // On Android the shim is injected as a WebViewCompat document-start script\n // (so it beats the page bundle and the ready handshake can't be raced — see\n // the react-native-webview patch). But the order in which that document-start\n // script runs vs. the WebMessageListener that installs\n // window.ReactNativeWebView is not contractually fixed on Android the way it\n // is on iOS (postMessageScript is registered before atStartScript there). If\n // we captured rnPost once and the bridge object wasn't installed yet, every\n // postMessage — including {type:'ready'} — would be silently dropped and the\n // splash would hang forever. Resolving per-call means we always pick up the\n // bridge once it exists, which it reliably does by the time the bundle mounts\n // and calls glassly.ready().\n function getRnPost() {\n try {\n return window.ReactNativeWebView && typeof window.ReactNativeWebView.postMessage === 'function'\n ? window.ReactNativeWebView.postMessage.bind(window.ReactNativeWebView)\n : null;\n } catch (e) { return null; }\n }\n\n // Outbound seq number — purely a log-correlation aid (the host's\n // router doesn't dedup anymore since reconnect can't happen: one\n // WebView, foreground-only, destroyed on close → fresh shim on\n // next open).\n var outboundSeq = 1;\n var ready = false;\n var channelHandlers = Object.create(null);\n var openHandlers = [];\n var closeHandlers = [];\n // Queued glassly.send calls before glassly.ready() acks. FIFO drained\n // on ack. Buffered so user input (button taps, etc.) isn't dropped\n // when the WebView mounts faster than the host expects.\n var outboundQueue = [];\n // Inbound payloads that arrived before any glassly.on subscriber was\n // registered for the channel. The background side fires\n // session.ui.onOpen handlers as soon as the WebView posts {type:'ready'},\n // and on a fast bridge the resulting ui.send round-trips back before\n // React useEffects have had a chance to attach listeners. Without\n // buffering, the very first snapshot (the one a controller pushes from\n // its ui.onOpen handler to hydrate the fresh UI) is silently dropped.\n //\n // Drain policy: the queue for a channel is flushed into the FIRST\n // glassly.on(channel, ...) subscriber, then discarded. Subsequent\n // sends with no listener fall back to the old drop-on-floor behaviour\n // — we don't want a re-subscribe to replay stale state.\n //\n // Cap: 32 entries per channel, oldest dropped on overflow. Bounds the\n // memory cost when a controller pushes to a channel that no UI page\n // ever subscribes to.\n var pendingByChannel = Object.create(null);\n var PENDING_CAP_PER_CHANNEL = 32;\n\n function postEnvelope(envelope) {\n var rnPost = getRnPost();\n if (!rnPost) return;\n try { rnPost(JSON.stringify(envelope)); } catch (_) {}\n }\n\n function send(channel, payload) {\n var seq = outboundSeq++;\n var envelope = { type: 'msg', seq: seq, channel: String(channel), payload: payload };\n if (!ready) {\n outboundQueue.push(envelope);\n return;\n }\n postEnvelope(envelope);\n }\n\n function flushQueue() {\n while (outboundQueue.length > 0) {\n postEnvelope(outboundQueue.shift());\n }\n }\n\n // NOTE: console.* tap lives in miniappGlobals.ts (injected alongside\n // this shim for every UI WebView, two-layer or single-bundle). That\n // shim posts {payload:{type:\"dev_log\", ...}} envelopes which\n // LocalMiniappRuntime forwards to the dev sidecar tagged source:\"ui\".\n // We don't re-wrap here to avoid double-delivery.\n\n function on(channel, cb) {\n if (typeof cb !== 'function') return function () {};\n var list = channelHandlers[channel];\n var firstSubscriber = !list || list.length === 0;\n if (!list) { list = []; channelHandlers[channel] = list; }\n list.push(cb);\n // Drain any payloads buffered before this channel had a listener.\n // Only fired on the first subscriber for the channel — a later\n // re-subscribe (after an unsubscribe) does NOT replay history.\n if (firstSubscriber) {\n var pending = pendingByChannel[channel];\n if (pending) {\n delete pendingByChannel[channel];\n for (var i = 0; i < pending.length; i++) {\n try { cb(pending[i]); } catch (e) {}\n }\n }\n }\n return function () {\n var idx = list.indexOf(cb);\n if (idx >= 0) list.splice(idx, 1);\n };\n }\n\n // ── RPC ─────────────────────────────────────────────────────────────\n // Outbound RPC: every glassly.request() generates a request id, sends a\n // 'msg' envelope tagged with requestId, and stashes a one-shot resolver\n // keyed on the id. The background-side reply is a recv('msg') with the\n // same channel + requestId; we route it directly to the resolver.\n //\n // Cancellation: caller's AbortSignal triggers a 'cancel' envelope to\n // background and rejects the local promise with a DOM-standard\n // AbortError. The background side's UI_CANCEL handler aborts the\n // handler's ctx.signal and drops the reply.\n var rpcCounter = 0;\n var rpcInflight = Object.create(null);\n\n function makeRequestId() {\n rpcCounter += 1;\n return 'r' + rpcCounter + '-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8);\n }\n\n function RpcError(message, code, stage, transport) {\n var e = new Error(message);\n e.name = 'RpcError';\n if (code) {\n try { e.cause = {code: code}; } catch (_) { /* old runtimes */ }\n e.code = code;\n }\n // Diagnostic fields ride as own props so a miniapp can show exactly which\n // pipeline stage and transport failed, not just a message string.\n if (stage) e.stage = stage;\n if (transport) e.transport = transport;\n return e;\n }\n\n function RpcTimeoutError(message) {\n var e = new Error(message || 'RPC timed out');\n e.name = 'RpcTimeoutError';\n return e;\n }\n\n function makeAbortError() {\n var e;\n try { e = new DOMException('aborted', 'AbortError'); } catch (_) {\n e = new Error('aborted');\n e.name = 'AbortError';\n }\n return e;\n }\n\n function request(channel, payload, options) {\n var opts = options || {};\n var signal = opts.signal;\n var timeoutMs = typeof opts.timeout === 'number' ? opts.timeout : null;\n var id = makeRequestId();\n\n return new Promise(function (resolve, reject) {\n var done = false;\n var timeoutHandle = null;\n var abortListener = null;\n\n function cleanup() {\n if (done) return;\n done = true;\n delete rpcInflight[id];\n if (timeoutHandle != null) { clearTimeout(timeoutHandle); timeoutHandle = null; }\n if (signal && abortListener) {\n try { signal.removeEventListener('abort', abortListener); } catch (_) {}\n }\n }\n\n function settle(envelope) {\n if (done) return;\n cleanup();\n if (envelope && envelope.ok === true) {\n resolve(envelope.result);\n } else if (envelope && envelope.ok === false) {\n reject(RpcError(envelope.error && envelope.error.message || 'RPC failed', envelope.error && envelope.error.code, envelope.error && envelope.error.stage, envelope.error && envelope.error.transport));\n } else {\n reject(RpcError('malformed RPC reply'));\n }\n }\n\n rpcInflight[id] = settle;\n\n if (signal) {\n if (signal.aborted) {\n cleanup();\n reject(makeAbortError());\n return;\n }\n abortListener = function () {\n if (done) return;\n cleanup();\n postEnvelope({type: 'cancel', requestId: id});\n reject(makeAbortError());\n };\n try { signal.addEventListener('abort', abortListener); } catch (_) {}\n }\n\n if (timeoutMs != null) {\n timeoutHandle = setTimeout(function () {\n if (done) return;\n cleanup();\n postEnvelope({type: 'cancel', requestId: id});\n reject(RpcTimeoutError());\n }, timeoutMs);\n }\n\n var envelope = {type: 'msg', seq: outboundSeq++, channel: String(channel), payload: payload, requestId: id};\n if (!ready) {\n outboundQueue.push(envelope);\n return;\n }\n postEnvelope(envelope);\n });\n }\n\n function onOpen(cb) {\n if (typeof cb !== 'function') return function () {};\n openHandlers.push(cb);\n if (ready) {\n try { cb(); } catch (e) {}\n }\n return function () {\n var idx = openHandlers.indexOf(cb);\n if (idx >= 0) openHandlers.splice(idx, 1);\n };\n }\n\n function onClose(cb) {\n if (typeof cb !== 'function') return function () {};\n closeHandlers.push(cb);\n return function () {\n var idx = closeHandlers.indexOf(cb);\n if (idx >= 0) closeHandlers.splice(idx, 1);\n };\n }\n\n function readyFn() {\n if (ready) return;\n ready = true;\n postEnvelope({ type: 'ready' });\n flushQueue();\n for (var i = 0; i < openHandlers.length; i++) {\n try { openHandlers[i](); } catch (e) {}\n }\n }\n\n function setBackgroundColorFn(color) {\n // Tells the host what to paint the native WebView layer (the surface\n // exposed during keyboard push-up / resize animations, which page CSS\n // cannot reach). Host validates and falls back to its theme background.\n if (typeof color !== 'string' || !color) return;\n postEnvelope({ type: 'set_background', color: color });\n }\n\n function fireChannel(channel, payload) {\n var list = channelHandlers[channel];\n if (!list || list.length === 0) {\n // No subscriber yet — stash for the first glassly.on(channel, ...).\n // Bounded FIFO: drop the oldest when capped so a stuck channel\n // can't grow unbounded.\n var q = pendingByChannel[channel];\n if (!q) { q = []; pendingByChannel[channel] = q; }\n q.push(payload);\n if (q.length > PENDING_CAP_PER_CHANNEL) q.shift();\n return;\n }\n for (var i = 0; i < list.length; i++) {\n try { list[i](payload); } catch (e) {}\n }\n }\n\n function recv(envelope) {\n if (!envelope || typeof envelope !== 'object') return;\n var type = envelope.type;\n if (type === 'msg' && typeof envelope.channel === 'string') {\n // RPC frames carry a requestId; broadcast frames don't. Treat them\n // as disjoint — never fall through from RPC to broadcast. An orphan\n // RPC reply (caller already aborted/timed out) is silently dropped.\n if (typeof envelope.requestId === 'string') {\n var settle = rpcInflight[envelope.requestId];\n if (settle) settle(envelope.payload);\n return;\n }\n fireChannel(envelope.channel, envelope.payload);\n return;\n }\n if (type === 'open') {\n for (var j = 0; j < openHandlers.length; j++) {\n try { openHandlers[j](); } catch (e) {}\n }\n return;\n }\n if (type === 'close') {\n for (var k = 0; k < closeHandlers.length; k++) {\n try { closeHandlers[k](); } catch (e) {}\n }\n return;\n }\n if (type === 'cancel' && typeof envelope.requestId === 'string') {\n // Background-side cancel (reserved; currently unused). If we had a\n // future bidirectional RPC this would abort an in-flight UI handler.\n return;\n }\n if (type === 'ack') {\n return;\n }\n }\n\n window.glassly = {\n send: send,\n on: on,\n request: request,\n onOpen: onOpen,\n onClose: onClose,\n ready: readyFn,\n setBackgroundColor: setBackgroundColorFn,\n /** @internal — packageName for diagnostic logs only. */\n _packageName: packageName,\n };\n window.__host = { recv: recv };\n})();\n`.trim()\n}\n"]}
1
+ {"version":3,"file":"uiShim.js","sourceRoot":"","sources":["../../src/services/uiShim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAQH,MAAM,UAAU,WAAW,CAAC,OAAsB;IAChD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3D,+DAA+D;IAC/D,mEAAmE;IACnE,yDAAyD;IACzD,OAAO;;;;sBAIa,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoVpC,CAAC,IAAI,EAAE,CAAA;AACR,CAAC","sourcesContent":["/**\n * window.glassly — WebView-side bridge to the per-miniapp background JSContext.\n *\n * Injected into every UI WebView via `injectedJavaScriptBeforeContentLoaded`\n * (iOS) or `injectedJavaScriptObject` + a bundler-emitted inline `<script>`\n * (Android, where the `BeforeContentLoaded` prop is documented unreliable\n * per react-native-webview issues #1099 / #1609).\n *\n * The shim:\n * - Buffers `glassly.send(channel, payload)` calls until `glassly.ready()`\n * fires + the host acks the channel is open. WebView-side BUFFERS (the\n * WebView is the short-lived side and shouldn't drop user input).\n * - Installs `window.__host.recv(envelope)` for the host to push\n * background → WebView messages via `webview.injectJavaScript(...)`.\n * - Sends `__heartbeat__` every 5s; host considers the WebView gone\n * after 15s of silence.\n * - Maintains monotonic seq numbers; the host's per-WebView dedup window\n * drops replays during reconnect.\n *\n * This file exports a `buildUiShim()` function returning the JS\n * source as a string. The host's UIRouter wraps it inside the\n * existing WebView setup so a single bundler-time string emission covers\n * both platforms.\n *\n * IMPORTANT: the shim runs in the WebView's bare ECMAScript scope before\n * the miniapp's bundle. It must not import anything; the source is one\n * IIFE. The only injected dependencies are\n * `window.ReactNativeWebView.postMessage` (provided by react-native-webview)\n * and (on Android) `window.ReactNativeWebView.injectedObjectJson()`\n * (provided when the host sets `injectedJavaScriptObject`).\n */\n\nexport interface UiShimOptions {\n packageName: string\n /** @deprecated No longer used — heartbeat removed since WebViews are foreground-only. */\n heartbeatIntervalMs?: number\n}\n\nexport function buildUiShim(options: UiShimOptions): string {\n const packageNameJson = JSON.stringify(options.packageName)\n // The IIFE assembles a typed `glassly` global plus an internal\n // `__host` for host inbound calls. Quoted strings are JSON-safe so\n // direct injection inside another JS literal also works.\n return `\n(function () {\n if (typeof window === 'undefined') return;\n if (window.glassly && window.__host) return;\n var packageName = ${packageNameJson};\n // Resolve window.ReactNativeWebView.postMessage LAZILY, not once at shim-eval.\n // On Android the shim is injected as a WebViewCompat document-start script\n // (so it beats the page bundle and the ready handshake can't be raced — see\n // the react-native-webview patch). But the order in which that document-start\n // script runs vs. the WebMessageListener that installs\n // window.ReactNativeWebView is not contractually fixed on Android the way it\n // is on iOS (postMessageScript is registered before atStartScript there). If\n // we captured rnPost once and the bridge object wasn't installed yet, every\n // postMessage — including {type:'ready'} — would be silently dropped and the\n // splash would hang forever. Resolving per-call means we always pick up the\n // bridge once it exists, which it reliably does by the time the bundle mounts\n // and calls glassly.ready().\n function getRnPost() {\n try {\n return window.ReactNativeWebView && typeof window.ReactNativeWebView.postMessage === 'function'\n ? window.ReactNativeWebView.postMessage.bind(window.ReactNativeWebView)\n : null;\n } catch (e) { return null; }\n }\n\n // Outbound seq number — purely a log-correlation aid (the host's\n // router doesn't dedup anymore since reconnect can't happen: one\n // WebView, foreground-only, destroyed on close → fresh shim on\n // next open).\n var outboundSeq = 1;\n var ready = false;\n var channelHandlers = Object.create(null);\n var openHandlers = [];\n var closeHandlers = [];\n // Queued glassly.send calls before glassly.ready() acks. FIFO drained\n // on ack. Buffered so user input (button taps, etc.) isn't dropped\n // when the WebView mounts faster than the host expects.\n var outboundQueue = [];\n // Inbound payloads that arrived before any glassly.on subscriber was\n // registered for the channel. The background side fires\n // session.ui.onOpen handlers as soon as the WebView posts {type:'ready'},\n // and on a fast bridge the resulting ui.send round-trips back before\n // React useEffects have had a chance to attach listeners. Without\n // buffering, the very first snapshot (the one a controller pushes from\n // its ui.onOpen handler to hydrate the fresh UI) is silently dropped.\n //\n // Drain policy: the queue for a channel is flushed into the FIRST\n // glassly.on(channel, ...) subscriber, then discarded. Subsequent\n // sends with no listener fall back to the old drop-on-floor behaviour\n // — we don't want a re-subscribe to replay stale state.\n //\n // Cap: 32 entries per channel, oldest dropped on overflow. Bounds the\n // memory cost when a controller pushes to a channel that no UI page\n // ever subscribes to.\n var pendingByChannel = Object.create(null);\n var PENDING_CAP_PER_CHANNEL = 32;\n\n function postEnvelope(envelope) {\n var rnPost = getRnPost();\n if (!rnPost) return;\n try { rnPost(JSON.stringify(envelope)); } catch (_) {}\n }\n\n function send(channel, payload) {\n var seq = outboundSeq++;\n var envelope = { type: 'msg', seq: seq, channel: String(channel), payload: payload };\n if (!ready) {\n outboundQueue.push(envelope);\n return;\n }\n postEnvelope(envelope);\n }\n\n function flushQueue() {\n while (outboundQueue.length > 0) {\n postEnvelope(outboundQueue.shift());\n }\n }\n\n // NOTE: console.* tap lives in miniappGlobals.ts (injected alongside\n // this shim for every UI WebView, two-layer or single-bundle). That\n // shim posts {payload:{type:\"dev_log\", ...}} envelopes which\n // LocalMiniappRuntime forwards to the dev sidecar tagged source:\"ui\".\n // We don't re-wrap here to avoid double-delivery.\n\n function on(channel, cb) {\n if (typeof cb !== 'function') return function () {};\n var list = channelHandlers[channel];\n var firstSubscriber = !list || list.length === 0;\n if (!list) { list = []; channelHandlers[channel] = list; }\n list.push(cb);\n // Drain any payloads buffered before this channel had a listener.\n // Only fired on the first subscriber for the channel — a later\n // re-subscribe (after an unsubscribe) does NOT replay history.\n if (firstSubscriber) {\n var pending = pendingByChannel[channel];\n if (pending) {\n delete pendingByChannel[channel];\n for (var i = 0; i < pending.length; i++) {\n try { cb(pending[i]); } catch (e) {}\n }\n }\n }\n return function () {\n var idx = list.indexOf(cb);\n if (idx >= 0) list.splice(idx, 1);\n };\n }\n\n // ── RPC ─────────────────────────────────────────────────────────────\n // Outbound RPC: every glassly.request() generates a request id, sends a\n // 'msg' envelope tagged with requestId, and stashes a one-shot resolver\n // keyed on the id. The background-side reply is a recv('msg') with the\n // same channel + requestId; we route it directly to the resolver.\n //\n // Cancellation: caller's AbortSignal triggers a 'cancel' envelope to\n // background and rejects the local promise with a DOM-standard\n // AbortError. The background side's UI_CANCEL handler aborts the\n // handler's ctx.signal and drops the reply.\n var rpcCounter = 0;\n var rpcInflight = Object.create(null);\n\n function makeRequestId() {\n rpcCounter += 1;\n return 'r' + rpcCounter + '-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8);\n }\n\n function RpcError(message, code, stage, transport) {\n var e = new Error(message);\n e.name = 'RpcError';\n if (code) {\n try { e.cause = {code: code}; } catch (_) { /* old runtimes */ }\n e.code = code;\n }\n // Diagnostic fields ride as own props so a miniapp can show exactly which\n // pipeline stage and transport failed, not just a message string.\n if (stage) e.stage = stage;\n if (transport) e.transport = transport;\n return e;\n }\n\n function RpcTimeoutError(message) {\n var e = new Error(message || 'RPC timed out');\n e.name = 'RpcTimeoutError';\n return e;\n }\n\n function makeAbortError() {\n var e;\n try { e = new DOMException('aborted', 'AbortError'); } catch (_) {\n e = new Error('aborted');\n e.name = 'AbortError';\n }\n return e;\n }\n\n function request(channel, payload, options) {\n var opts = options || {};\n var signal = opts.signal;\n var timeoutMs = typeof opts.timeout === 'number' ? opts.timeout : null;\n var id = makeRequestId();\n\n return new Promise(function (resolve, reject) {\n var done = false;\n var timeoutHandle = null;\n var abortListener = null;\n\n function cleanup() {\n if (done) return;\n done = true;\n delete rpcInflight[id];\n if (timeoutHandle != null) { clearTimeout(timeoutHandle); timeoutHandle = null; }\n if (signal && abortListener) {\n try { signal.removeEventListener('abort', abortListener); } catch (_) {}\n }\n }\n\n function settle(envelope) {\n if (done) return;\n cleanup();\n if (envelope && envelope.ok === true) {\n resolve(envelope.result);\n } else if (envelope && envelope.ok === false) {\n reject(RpcError(envelope.error && envelope.error.message || 'RPC failed', envelope.error && envelope.error.code, envelope.error && envelope.error.stage, envelope.error && envelope.error.transport));\n } else {\n reject(RpcError('malformed RPC reply'));\n }\n }\n\n rpcInflight[id] = settle;\n\n if (signal) {\n if (signal.aborted) {\n cleanup();\n reject(makeAbortError());\n return;\n }\n abortListener = function () {\n if (done) return;\n cleanup();\n postEnvelope({type: 'cancel', requestId: id});\n reject(makeAbortError());\n };\n try { signal.addEventListener('abort', abortListener); } catch (_) {}\n }\n\n if (timeoutMs != null) {\n timeoutHandle = setTimeout(function () {\n if (done) return;\n cleanup();\n postEnvelope({type: 'cancel', requestId: id});\n reject(RpcTimeoutError());\n }, timeoutMs);\n }\n\n var envelope = {type: 'msg', seq: outboundSeq++, channel: String(channel), payload: payload, requestId: id};\n if (!ready) {\n outboundQueue.push(envelope);\n return;\n }\n postEnvelope(envelope);\n });\n }\n\n function onOpen(cb) {\n if (typeof cb !== 'function') return function () {};\n openHandlers.push(cb);\n if (ready) {\n try { cb(); } catch (e) {}\n }\n return function () {\n var idx = openHandlers.indexOf(cb);\n if (idx >= 0) openHandlers.splice(idx, 1);\n };\n }\n\n function onClose(cb) {\n if (typeof cb !== 'function') return function () {};\n closeHandlers.push(cb);\n return function () {\n var idx = closeHandlers.indexOf(cb);\n if (idx >= 0) closeHandlers.splice(idx, 1);\n };\n }\n\n function readyFn() {\n if (ready) return;\n ready = true;\n postEnvelope({ type: 'ready' });\n flushQueue();\n for (var i = 0; i < openHandlers.length; i++) {\n try { openHandlers[i](); } catch (e) {}\n }\n }\n\n function setBackgroundColorFn(color) {\n // Tells the host what to paint the native WebView layer (the surface\n // exposed during keyboard push-up / resize animations, which page CSS\n // cannot reach). Host validates and falls back to its theme background.\n if (typeof color !== 'string' || !color) return;\n postEnvelope({ type: 'set_background', color: color });\n }\n\n var backHandler = null;\n\n function setBackActionFn(handler) {\n backHandler = typeof handler === 'function' ? handler : null;\n postEnvelope({ type: 'set_back_action', shown: backHandler !== null });\n }\n\n function fireChannel(channel, payload) {\n var list = channelHandlers[channel];\n if (!list || list.length === 0) {\n // No subscriber yet — stash for the first glassly.on(channel, ...).\n // Bounded FIFO: drop the oldest when capped so a stuck channel\n // can't grow unbounded.\n var q = pendingByChannel[channel];\n if (!q) { q = []; pendingByChannel[channel] = q; }\n q.push(payload);\n if (q.length > PENDING_CAP_PER_CHANNEL) q.shift();\n return;\n }\n for (var i = 0; i < list.length; i++) {\n try { list[i](payload); } catch (e) {}\n }\n }\n\n function recv(envelope) {\n if (!envelope || typeof envelope !== 'object') return;\n var type = envelope.type;\n if (type === 'msg' && typeof envelope.channel === 'string') {\n // RPC frames carry a requestId; broadcast frames don't. Treat them\n // as disjoint — never fall through from RPC to broadcast. An orphan\n // RPC reply (caller already aborted/timed out) is silently dropped.\n if (typeof envelope.requestId === 'string') {\n var settle = rpcInflight[envelope.requestId];\n if (settle) settle(envelope.payload);\n return;\n }\n fireChannel(envelope.channel, envelope.payload);\n return;\n }\n if (type === 'open') {\n for (var j = 0; j < openHandlers.length; j++) {\n try { openHandlers[j](); } catch (e) {}\n }\n return;\n }\n if (type === 'close') {\n for (var k = 0; k < closeHandlers.length; k++) {\n try { closeHandlers[k](); } catch (e) {}\n }\n return;\n }\n if (type === 'back') {\n if (backHandler) {\n try { backHandler(); } catch (e) {}\n }\n return;\n }\n if (type === 'cancel' && typeof envelope.requestId === 'string') {\n // Background-side cancel (reserved; currently unused). If we had a\n // future bidirectional RPC this would abort an in-flight UI handler.\n return;\n }\n if (type === 'ack') {\n return;\n }\n }\n\n window.glassly = {\n send: send,\n on: on,\n request: request,\n onOpen: onOpen,\n onClose: onClose,\n ready: readyFn,\n setBackgroundColor: setBackgroundColorFn,\n setBackAction: setBackActionFn,\n /** @internal — packageName for diagnostic logs only. */\n _packageName: packageName,\n };\n window.__host = { recv: recv };\n})();\n`.trim()\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/stores/settings.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAwB,MAAM,aAAa,CAAA;AAS9D,OAAO,EAAC,wBAAwB,EAAE,gCAAgC,EAAC,MAAM,wBAAwB,CAAA;AAEjG,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,GA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AG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,OAAO,KAAK,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACzF,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC3E,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAA;IAEhC,eAAe,EAAE,MAAM,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAE/C,oBAAoB,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/C,uBAAuB,EAAE,MAAM,IAAI,CAAA;CACpC;AAuBD,eAAO,MAAM,gBAAgB;;;;;;;;EAsX5B,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,CAAC,GAAG,GAAG,EAAE,KAAK,MAAM,KAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAI3F,CAAA"}
@@ -89,13 +89,6 @@ export const SETTINGS = {
89
89
  saveOnServer: true,
90
90
  persist: true,
91
91
  },
92
- memomind_accessory_picker: {
93
- key: "memomind_accessory_picker",
94
- defaultValue: () => true,
95
- writable: true,
96
- saveOnServer: false,
97
- persist: true,
98
- },
99
92
  debug_console: {
100
93
  key: "debug_console",
101
94
  defaultValue: () => false,
@@ -906,6 +899,13 @@ export const SETTINGS = {
906
899
  saveOnServer: false,
907
900
  persist: true,
908
901
  },
902
+ debug_mirror_rail: {
903
+ key: "debug_mirror_rail",
904
+ defaultValue: () => false,
905
+ writable: true,
906
+ saveOnServer: false,
907
+ persist: true,
908
+ },
909
909
  home_offline_card: {
910
910
  key: "home_offline_card",
911
911
  defaultValue: () => true,
@@ -1227,7 +1227,6 @@ export const BLUETOOTH_SETTING_KEYS = [
1227
1227
  SETTINGS.cfw_scene_renderer.key,
1228
1228
  SETTINGS.cfw_fast_ble.key,
1229
1229
  SETTINGS.perf_logs.key,
1230
- SETTINGS.memomind_accessory_picker.key,
1231
1230
  SETTINGS.ring_via_glasses.key,
1232
1231
  SETTINGS.display_max_fps.key,
1233
1232
  SETTINGS.twelve_hour_time.key,