@mentra/miniapp 3.4.0-dev.1140 → 3.4.0-dev.1141
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/dist/react/MentraProvider.d.ts +13 -1
- package/dist/react/MentraProvider.d.ts.map +1 -1
- package/dist/react/MentraProvider.js +31 -1
- package/dist/react/MentraProvider.js.map +1 -1
- package/dist/ui/index.d.ts +7 -4
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js.map +1 -1
- package/package.json +2 -2
- package/src/react/MentraProvider.tsx +23 -2
- package/src/ui/index.ts +7 -4
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* miniapp. Currently:
|
|
6
6
|
* - Keeps `<html class="dark">` in sync with the host's color scheme so the
|
|
7
7
|
* shared theme CSS switches automatically.
|
|
8
|
+
* - Calls `mentra.ready()` once the app has mounted, which lifts the host's
|
|
9
|
+
* splash and fires the background's `session.ui.onOpen` handlers.
|
|
8
10
|
*
|
|
9
11
|
* Usage:
|
|
10
12
|
* createRoot(root).render(
|
|
@@ -28,6 +30,16 @@ export interface MentraProviderProps {
|
|
|
28
30
|
* (e.g. you integrate a theming library like next-themes).
|
|
29
31
|
*/
|
|
30
32
|
syncColorScheme?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Call `mentra.ready()` after the first mount. A parent's effects run after
|
|
35
|
+
* its children's, so every `mentra.on` subscription the app makes on mount
|
|
36
|
+
* is attached before the background is told the UI is open. Without
|
|
37
|
+
* `ready()` the host keeps its splash up and reports the miniapp as failed.
|
|
38
|
+
*
|
|
39
|
+
* Default: true. Set to false to call `mentra.ready()` yourself, e.g. to keep
|
|
40
|
+
* the splash up until the first screen has its data.
|
|
41
|
+
*/
|
|
42
|
+
autoReady?: boolean;
|
|
31
43
|
}
|
|
32
|
-
export declare function MentraProvider({ children, syncColorScheme }: MentraProviderProps): import("react").JSX.Element;
|
|
44
|
+
export declare function MentraProvider({ children, syncColorScheme, autoReady }: MentraProviderProps): import("react").JSX.Element;
|
|
33
45
|
//# sourceMappingURL=MentraProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentraProvider.d.ts","sourceRoot":"","sources":["../../src/react/MentraProvider.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MentraProvider.d.ts","sourceRoot":"","sources":["../../src/react/MentraProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAC,KAAK,SAAS,EAAY,MAAM,OAAO,CAAA;AAI/C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,SAAS,CAAA;IACnB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAOD,wBAAgB,cAAc,CAAC,EAAC,QAAQ,EAAE,eAAsB,EAAE,SAAgB,EAAC,EAAE,mBAAmB,+BAiBvG"}
|
|
@@ -1,7 +1,37 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview MentraProvider — optional root provider for miniapp apps.
|
|
4
|
+
*
|
|
5
|
+
* Opt-in conveniences that would otherwise require boilerplate in every
|
|
6
|
+
* miniapp. Currently:
|
|
7
|
+
* - Keeps `<html class="dark">` in sync with the host's color scheme so the
|
|
8
|
+
* shared theme CSS switches automatically.
|
|
9
|
+
* - Calls `mentra.ready()` once the app has mounted, which lifts the host's
|
|
10
|
+
* splash and fires the background's `session.ui.onOpen` handlers.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* createRoot(root).render(
|
|
14
|
+
* <MentraProvider>
|
|
15
|
+
* <App />
|
|
16
|
+
* </MentraProvider>
|
|
17
|
+
* )
|
|
18
|
+
*
|
|
19
|
+
* Each convenience is controllable via props so miniapps that manage these
|
|
20
|
+
* things themselves can opt out without forking the provider.
|
|
21
|
+
*/
|
|
22
|
+
import { useEffect } from "react";
|
|
2
23
|
import { useColorScheme } from "./useColorScheme";
|
|
3
|
-
|
|
24
|
+
function getBridge() {
|
|
25
|
+
if (typeof window === "undefined")
|
|
26
|
+
return null;
|
|
27
|
+
return window.mentra ?? null;
|
|
28
|
+
}
|
|
29
|
+
export function MentraProvider({ children, syncColorScheme = true, autoReady = true }) {
|
|
4
30
|
const scheme = useColorScheme();
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (autoReady)
|
|
33
|
+
getBridge()?.ready?.();
|
|
34
|
+
}, [autoReady]);
|
|
5
35
|
// Runs during render — before children paint, before effects fire.
|
|
6
36
|
if (syncColorScheme && typeof document !== "undefined") {
|
|
7
37
|
const el = document.documentElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentraProvider.js","sourceRoot":"","sources":["../../src/react/MentraProvider.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"MentraProvider.js","sourceRoot":"","sources":["../../src/react/MentraProvider.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAiB,SAAS,EAAC,MAAM,OAAO,CAAA;AAE/C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAyB/C,SAAS,SAAS;IAChB,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,IAAI,CAAA;IAC9C,OAAQ,MAAqD,CAAC,MAAM,IAAI,IAAI,CAAA;AAC9E,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,EAAE,SAAS,GAAG,IAAI,EAAsB;IACtG,MAAM,MAAM,GAAG,cAAc,EAAE,CAAA;IAE/B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS;YAAE,SAAS,EAAE,EAAE,KAAK,EAAE,EAAE,CAAA;IACvC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAEf,mEAAmE;IACnE,IAAI,eAAe,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;QACvD,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAA;QACnC,MAAM,YAAY,GAAG,MAAM,KAAK,MAAM,CAAA;QACtC,IAAI,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,YAAY,EAAE,CAAC;YACnD,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;QAC3C,CAAC;IACH,CAAC;IAED,OAAO,4BAAG,QAAQ,GAAI,CAAA;AACxB,CAAC"}
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -54,10 +54,13 @@ export interface MentraUiGlobal<TChannels extends object = Record<string, unknow
|
|
|
54
54
|
*/
|
|
55
55
|
onClose(cb: () => void): () => void;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
57
|
+
* Tells the host the WebView is mounted and ready to receive messages
|
|
58
|
+
* from background. `<MentraProvider>` calls it once the app has mounted;
|
|
59
|
+
* call it yourself only without the provider (or with `autoReady={false}`).
|
|
60
|
+
* The host's splash stays up until it lands, and a page that loads
|
|
61
|
+
* without calling it is reported as failed. Idempotent — subsequent
|
|
62
|
+
* calls no-op. Background's `session.ui.onOpen` handlers fire after this
|
|
63
|
+
* lands.
|
|
61
64
|
*/
|
|
62
65
|
ready(): void;
|
|
63
66
|
}
|
package/dist/ui/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAC3E,YAAY,EAAC,GAAG,EAAE,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c,EAAE,qBAAqB,EAAC,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAC,cAAc,EAAE,qBAAqB,EAAC,MAAM,eAAe,CAAA;AA8DnE,uEAAuE;AACvE,sEAAsE;AACtE,+DAA+D;AAC/D,OAAO,EACL,cAAc,GAEf,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAC,MAAM,EAAmB,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAC,eAAe,EAAuB,MAAM,0BAA0B,CAAA;AAC9E,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mentra/miniapp",
|
|
3
|
-
"version": "3.4.0-dev.
|
|
3
|
+
"version": "3.4.0-dev.1141",
|
|
4
4
|
"description": "SDK for building MentraOS local miniapps (browser/WebView)",
|
|
5
5
|
"author": "Mentra Labs",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@mentra/cloud-protocol": "3.4.0-dev.
|
|
60
|
+
"@mentra/cloud-protocol": "3.4.0-dev.1141",
|
|
61
61
|
"eventemitter3": "^5.0.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* miniapp. Currently:
|
|
6
6
|
* - Keeps `<html class="dark">` in sync with the host's color scheme so the
|
|
7
7
|
* shared theme CSS switches automatically.
|
|
8
|
+
* - Calls `mentra.ready()` once the app has mounted, which lifts the host's
|
|
9
|
+
* splash and fires the background's `session.ui.onOpen` handlers.
|
|
8
10
|
*
|
|
9
11
|
* Usage:
|
|
10
12
|
* createRoot(root).render(
|
|
@@ -17,7 +19,7 @@
|
|
|
17
19
|
* things themselves can opt out without forking the provider.
|
|
18
20
|
*/
|
|
19
21
|
|
|
20
|
-
import {type ReactNode} from "react"
|
|
22
|
+
import {type ReactNode, useEffect} from "react"
|
|
21
23
|
|
|
22
24
|
import {useColorScheme} from "./useColorScheme"
|
|
23
25
|
|
|
@@ -32,11 +34,30 @@ export interface MentraProviderProps {
|
|
|
32
34
|
* (e.g. you integrate a theming library like next-themes).
|
|
33
35
|
*/
|
|
34
36
|
syncColorScheme?: boolean
|
|
37
|
+
/**
|
|
38
|
+
* Call `mentra.ready()` after the first mount. A parent's effects run after
|
|
39
|
+
* its children's, so every `mentra.on` subscription the app makes on mount
|
|
40
|
+
* is attached before the background is told the UI is open. Without
|
|
41
|
+
* `ready()` the host keeps its splash up and reports the miniapp as failed.
|
|
42
|
+
*
|
|
43
|
+
* Default: true. Set to false to call `mentra.ready()` yourself, e.g. to keep
|
|
44
|
+
* the splash up until the first screen has its data.
|
|
45
|
+
*/
|
|
46
|
+
autoReady?: boolean
|
|
35
47
|
}
|
|
36
48
|
|
|
37
|
-
|
|
49
|
+
function getBridge(): {ready?: () => void} | null {
|
|
50
|
+
if (typeof window === "undefined") return null
|
|
51
|
+
return (window as unknown as {mentra?: {ready?: () => void}}).mentra ?? null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function MentraProvider({children, syncColorScheme = true, autoReady = true}: MentraProviderProps) {
|
|
38
55
|
const scheme = useColorScheme()
|
|
39
56
|
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (autoReady) getBridge()?.ready?.()
|
|
59
|
+
}, [autoReady])
|
|
60
|
+
|
|
40
61
|
// Runs during render — before children paint, before effects fire.
|
|
41
62
|
if (syncColorScheme && typeof document !== "undefined") {
|
|
42
63
|
const el = document.documentElement
|
package/src/ui/index.ts
CHANGED
|
@@ -71,10 +71,13 @@ export interface MentraUiGlobal<TChannels extends object = Record<string, unknow
|
|
|
71
71
|
onClose(cb: () => void): () => void
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
74
|
+
* Tells the host the WebView is mounted and ready to receive messages
|
|
75
|
+
* from background. `<MentraProvider>` calls it once the app has mounted;
|
|
76
|
+
* call it yourself only without the provider (or with `autoReady={false}`).
|
|
77
|
+
* The host's splash stays up until it lands, and a page that loads
|
|
78
|
+
* without calling it is reported as failed. Idempotent — subsequent
|
|
79
|
+
* calls no-op. Background's `session.ui.onOpen` handlers fire after this
|
|
80
|
+
* lands.
|
|
78
81
|
*/
|
|
79
82
|
ready(): void
|
|
80
83
|
}
|