@glassly/miniapp 0.4.2 → 0.4.3-beta.1240
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/display/index.d.ts +2 -1
- package/dist/display/index.d.ts.map +1 -1
- package/dist/display/index.js +1 -1
- package/dist/display/index.js.map +1 -1
- package/dist/display/measurer/script-detection.d.ts +1 -1
- package/dist/display/measurer/script-detection.d.ts.map +1 -1
- package/dist/display/measurer/script-detection.js +46 -10
- package/dist/display/measurer/script-detection.js.map +1 -1
- package/dist/display/profiles/index.d.ts +3 -2
- package/dist/display/profiles/index.d.ts.map +1 -1
- package/dist/display/profiles/index.js +2 -3
- package/dist/display/profiles/index.js.map +1 -1
- package/dist/display/profiles/nimo.d.ts +10 -3
- package/dist/display/profiles/nimo.d.ts.map +1 -1
- package/dist/display/profiles/nimo.js +35 -3
- package/dist/display/profiles/nimo.js.map +1 -1
- package/dist/display/profiles/textProfile.d.ts +24 -0
- package/dist/display/profiles/textProfile.d.ts.map +1 -0
- package/dist/display/profiles/textProfile.js +48 -0
- package/dist/display/profiles/textProfile.js.map +1 -0
- package/dist/display/profiles/types.d.ts +5 -0
- package/dist/display/profiles/types.d.ts.map +1 -1
- package/dist/display/scene/degrade.d.ts +1 -1
- package/dist/display/scene/degrade.js +1 -1
- package/dist/display/scene/process.d.ts.map +1 -1
- package/dist/display/scene/process.js +2 -3
- package/dist/display/scene/process.js.map +1 -1
- package/dist/host/actionInvoke.d.ts +44 -0
- package/dist/host/actionInvoke.d.ts.map +1 -0
- package/dist/host/actionInvoke.js +87 -0
- package/dist/host/actionInvoke.js.map +1 -0
- package/dist/host/gestureClaims.d.ts +37 -0
- package/dist/host/gestureClaims.d.ts.map +1 -0
- package/dist/host/gestureClaims.js +45 -0
- package/dist/host/gestureClaims.js.map +1 -0
- package/dist/host/index.d.ts +8 -0
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +9 -0
- package/dist/host/index.js.map +1 -1
- package/dist/host/manifestActions.d.ts +69 -0
- package/dist/host/manifestActions.d.ts.map +1 -0
- package/dist/host/manifestActions.js +89 -0
- package/dist/host/manifestActions.js.map +1 -0
- package/dist/host/memory/MemoryStore.d.ts +178 -0
- package/dist/host/memory/MemoryStore.d.ts.map +1 -0
- package/dist/host/memory/MemoryStore.js +615 -0
- package/dist/host/memory/MemoryStore.js.map +1 -0
- package/dist/host/memory/search.d.ts +72 -0
- package/dist/host/memory/search.d.ts.map +1 -0
- package/dist/host/memory/search.js +188 -0
- package/dist/host/memory/search.js.map +1 -0
- package/dist/host/miniappPermissions.d.ts +16 -0
- package/dist/host/miniappPermissions.d.ts.map +1 -0
- package/dist/host/miniappPermissions.js +7 -0
- package/dist/host/miniappPermissions.js.map +1 -0
- package/dist/host/settingsBridge.d.ts +49 -0
- package/dist/host/settingsBridge.d.ts.map +1 -0
- package/dist/host/settingsBridge.js +110 -0
- package/dist/host/settingsBridge.js.map +1 -0
- package/dist/host/widgetPlacements.d.ts +44 -0
- package/dist/host/widgetPlacements.d.ts.map +1 -0
- package/dist/host/widgetPlacements.js +84 -0
- package/dist/host/widgetPlacements.js.map +1 -0
- package/dist/session.d.ts +6 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js.map +1 -1
- package/package.json +2 -2
- package/src/display/index.ts +4 -3
- package/src/display/measurer/script-detection.ts +47 -10
- package/src/display/profiles/index.ts +4 -4
- package/src/display/profiles/nimo.ts +38 -3
- package/src/display/profiles/textProfile.ts +62 -0
- package/src/display/profiles/types.ts +2 -0
- package/src/display/scene/degrade.ts +1 -1
- package/src/display/scene/process.ts +2 -3
- package/src/host/actionInvoke.ts +110 -0
- package/src/host/gestureClaims.ts +77 -0
- package/src/host/index.ts +10 -0
- package/src/host/manifestActions.ts +152 -0
- package/src/host/memory/MemoryStore.ts +704 -0
- package/src/host/memory/search.ts +214 -0
- package/src/host/miniappPermissions.ts +19 -0
- package/src/host/settingsBridge.ts +119 -0
- package/src/host/widgetPlacements.ts +135 -0
- package/src/session.ts +6 -0
- package/dist/display/profiles/z100.d.ts +0 -33
- package/dist/display/profiles/z100.d.ts.map +0 -1
- package/dist/display/profiles/z100.js +0 -182
- package/dist/display/profiles/z100.js.map +0 -1
- package/src/display/profiles/z100.ts +0 -198
package/src/host/index.ts
CHANGED
|
@@ -12,3 +12,13 @@ export {
|
|
|
12
12
|
type MiniappColorScheme,
|
|
13
13
|
type MiniappSafeArea,
|
|
14
14
|
} from "./webviewGlobals"
|
|
15
|
+
|
|
16
|
+
// Host rules with no device or network access, shared by the Glassly App and glassly sim.
|
|
17
|
+
export * from "./memory/MemoryStore"
|
|
18
|
+
export * from "./memory/search"
|
|
19
|
+
export * from "./widgetPlacements"
|
|
20
|
+
export * from "./gestureClaims"
|
|
21
|
+
export * from "./miniappPermissions"
|
|
22
|
+
export * from "./actionInvoke"
|
|
23
|
+
export * from "./manifestActions"
|
|
24
|
+
export * from "./settingsBridge"
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A manifest-declared action a miniapp exposes for other miniapps to invoke
|
|
3
|
+
* via `session.actions`. Populated from `miniapp.json`'s `actions` field.
|
|
4
|
+
* Shape maps 1:1 onto an MCP tool (id→name, description, parameters→inputSchema).
|
|
5
|
+
*/
|
|
6
|
+
export interface DeclaredAction {
|
|
7
|
+
id: string
|
|
8
|
+
description: string
|
|
9
|
+
/** JSON-Schema input descriptor (MCP-compatible subset). */
|
|
10
|
+
parameters?: Record<string, unknown>
|
|
11
|
+
/** JSON-Schema descriptor for the action's structured result. */
|
|
12
|
+
outputSchema?: Record<string, unknown>
|
|
13
|
+
/**
|
|
14
|
+
* Who may invoke the action: "public" (default — any installed miniapp) or
|
|
15
|
+
* "system" (system miniapps such as the AI assistant only).
|
|
16
|
+
*/
|
|
17
|
+
visibility?: "public" | "system"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type DeclaredWidgetSize = "XS" | "XSM" | "SM" | "MD" | "LG"
|
|
21
|
+
|
|
22
|
+
/** A dashboard widget a miniapp declares in `miniapp.json` and serves through `session.widgets`. */
|
|
23
|
+
export interface DeclaredWidget {
|
|
24
|
+
id: string
|
|
25
|
+
name: string
|
|
26
|
+
sizes: DeclaredWidgetSize[]
|
|
27
|
+
defaultSize: DeclaredWidgetSize
|
|
28
|
+
/** Lists the `EX` size: a tap on the selected widget can expand it to the full screen. */
|
|
29
|
+
expandable: boolean
|
|
30
|
+
/** A tap expands it rather than activating the card: expandable, and the wearer left expansion on. */
|
|
31
|
+
expandOnTap: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The subset of ClientApp that action-listing needs (structural, no cycle on applet types). */
|
|
35
|
+
export interface ActionListApp {
|
|
36
|
+
packageName: string
|
|
37
|
+
name: string
|
|
38
|
+
actions?: DeclaredAction[]
|
|
39
|
+
compatibility?: {isCompatible: boolean}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** One row of `session.actions.list` — a flat, MCP-tool-shaped descriptor. */
|
|
43
|
+
export interface ActionListRow {
|
|
44
|
+
packageName: string
|
|
45
|
+
appName: string
|
|
46
|
+
id: string
|
|
47
|
+
description: string
|
|
48
|
+
parameters?: Record<string, unknown>
|
|
49
|
+
outputSchema?: Record<string, unknown>
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Project the installed-app set into the caller's invokable-action rows:
|
|
54
|
+
* excludes the caller's own actions, incompatible apps, and placeholder
|
|
55
|
+
* packages; `visibility: "system"` actions only surface for system callers.
|
|
56
|
+
*/
|
|
57
|
+
export function visibleActionRows(
|
|
58
|
+
apps: ActionListApp[],
|
|
59
|
+
callerPackageName: string,
|
|
60
|
+
callerIsSystem: boolean,
|
|
61
|
+
): ActionListRow[] {
|
|
62
|
+
const rows: ActionListRow[] = []
|
|
63
|
+
for (const app of apps) {
|
|
64
|
+
if (!app.packageName || app.packageName === callerPackageName || app.packageName.includes("@empty")) continue
|
|
65
|
+
if (app.compatibility?.isCompatible === false) continue
|
|
66
|
+
for (const action of app.actions ?? []) {
|
|
67
|
+
if (action.visibility === "system" && !callerIsSystem) continue
|
|
68
|
+
rows.push({
|
|
69
|
+
packageName: app.packageName,
|
|
70
|
+
appName: app.name,
|
|
71
|
+
id: action.id,
|
|
72
|
+
description: action.description,
|
|
73
|
+
...(action.parameters ? {parameters: action.parameters} : {}),
|
|
74
|
+
...(action.outputSchema ? {outputSchema: action.outputSchema} : {}),
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return rows
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Normalize manifest actions defensively for installed and dev-sideloaded
|
|
83
|
+
* bundles. Input and output schemas are passed through as opaque JSON Schema.
|
|
84
|
+
*/
|
|
85
|
+
export function normalizeManifestActions(raw: unknown): DeclaredAction[] {
|
|
86
|
+
if (!Array.isArray(raw)) return []
|
|
87
|
+
const out: DeclaredAction[] = []
|
|
88
|
+
for (const a of raw as Array<{
|
|
89
|
+
id?: unknown
|
|
90
|
+
description?: unknown
|
|
91
|
+
parameters?: unknown
|
|
92
|
+
outputSchema?: unknown
|
|
93
|
+
visibility?: unknown
|
|
94
|
+
}>) {
|
|
95
|
+
if (a && typeof a.id === "string" && typeof a.description === "string") {
|
|
96
|
+
out.push({
|
|
97
|
+
id: a.id,
|
|
98
|
+
description: a.description,
|
|
99
|
+
...(a.parameters && typeof a.parameters === "object" && !Array.isArray(a.parameters)
|
|
100
|
+
? {parameters: a.parameters as Record<string, unknown>}
|
|
101
|
+
: {}),
|
|
102
|
+
...(a.outputSchema && typeof a.outputSchema === "object" && !Array.isArray(a.outputSchema)
|
|
103
|
+
? {outputSchema: a.outputSchema as Record<string, unknown>}
|
|
104
|
+
: {}),
|
|
105
|
+
// Unknown/absent values fall back to the default ("public") by omission.
|
|
106
|
+
...(a.visibility === "system" || a.visibility === "public" ? {visibility: a.visibility} : {}),
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return out
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const WIDGET_SIZES: readonly DeclaredWidgetSize[] = ["XS", "XSM", "SM", "MD", "LG"]
|
|
114
|
+
const isWidgetSize = (value: unknown): value is DeclaredWidgetSize =>
|
|
115
|
+
(WIDGET_SIZES as readonly unknown[]).includes(value)
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Normalize manifest widgets for installed and dev-sideloaded bundles: an
|
|
119
|
+
* entry without an id, a name or a usable card size is dropped, repeats of a
|
|
120
|
+
* size are folded, and a default size the widget does not offer becomes
|
|
121
|
+
* its first size. Listing `EX` makes a widget expandable; it is not a card
|
|
122
|
+
* size. Taps expand it until the wearer turns that off (AppRegistry applies
|
|
123
|
+
* the choice).
|
|
124
|
+
*/
|
|
125
|
+
export function normalizeManifestWidgets(raw: unknown): DeclaredWidget[] {
|
|
126
|
+
if (!Array.isArray(raw)) return []
|
|
127
|
+
const out: DeclaredWidget[] = []
|
|
128
|
+
const seen = new Set<string>()
|
|
129
|
+
for (const w of raw as Array<{
|
|
130
|
+
id?: unknown
|
|
131
|
+
name?: unknown
|
|
132
|
+
sizes?: unknown
|
|
133
|
+
defaultSize?: unknown
|
|
134
|
+
expandable?: unknown
|
|
135
|
+
}>) {
|
|
136
|
+
if (!w || typeof w.id !== "string" || !w.id || typeof w.name !== "string" || !w.name || seen.has(w.id)) continue
|
|
137
|
+
const sizes = Array.isArray(w.sizes) ? Array.from(new Set(w.sizes.filter(isWidgetSize))) : []
|
|
138
|
+
if (sizes.length === 0) continue
|
|
139
|
+
seen.add(w.id)
|
|
140
|
+
// `expandable: true` is how bundles from before `EX` said the same.
|
|
141
|
+
const expandable = (Array.isArray(w.sizes) && w.sizes.includes("EX")) || w.expandable === true
|
|
142
|
+
out.push({
|
|
143
|
+
id: w.id,
|
|
144
|
+
name: w.name,
|
|
145
|
+
sizes,
|
|
146
|
+
defaultSize: isWidgetSize(w.defaultSize) && sizes.includes(w.defaultSize) ? w.defaultSize : sizes[0],
|
|
147
|
+
expandable,
|
|
148
|
+
expandOnTap: expandable,
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
return out
|
|
152
|
+
}
|