@glassly/miniapp-cli 0.1.15-dev.0 → 0.1.15
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 +1 -1
- package/package.json +1 -1
- package/src/api.ts +2 -1
- package/src/sim/client/app.css +5 -0
- package/src/sim/client/main.ts +7 -2
- package/src/sim/device.test.ts +57 -28
- package/src/sim/device.ts +172 -82
- package/src/sim/host.test.ts +369 -10
- package/src/sim/host.ts +664 -88
- package/src/sim/models.json +599 -0
- package/src/sim/regenerate-models.ts +34 -0
- package/src/sim/registry.ts +394 -0
- package/src/sim/scenarios.test.ts +74 -0
- package/src/sim/script.test.ts +31 -0
- package/src/sim/script.ts +48 -0
- package/src/sim/server.ts +49 -1
- package/src/sim/shots.test.ts +59 -0
- package/src/sim/shots.ts +161 -0
- package/src/sim/sim.ts +114 -12
- package/src/sim/storage.ts +8 -7
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ that works without the computer.
|
|
|
73
73
|
glassly sim # build, run, open the simulator window
|
|
74
74
|
glassly sim --no-open # same, without a browser
|
|
75
75
|
glassly sim --detach # start in the background, return once it answers
|
|
76
|
-
glassly sim --device nimo # simulate one glasses model (g1, g2,
|
|
76
|
+
glassly sim --device nimo # simulate one glasses model (g1, g2, rayneo-io, nimo-cfw, ...)
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
Runs a miniapp with no phone and no glasses:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glassly/miniapp-cli",
|
|
3
|
-
"version": "0.1.15
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "Build tooling for Glassly miniapps: dev server, packer, manifest validation, and JSON Schema. The `glassly` command that drives it ships in @glassly/cli.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
package/src/api.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { buildProduction } from './build.js';
|
|
2
2
|
export { dev, type DevAttestationInput, type DevOptions } from './dev.js';
|
|
3
|
-
export { sim, simDetached, listSimRecords, type DetachedSim, type SimOptions, type SimRecord } from './sim/sim.js';
|
|
3
|
+
export { sim, simDetached, simReset, simStateDir, listSimRecords, type DetachedSim, type SimOptions, type SimRecord } from './sim/sim.js';
|
|
4
|
+
export { simShots, CANNOT_STAND_IN_FOR_URL, type Shot, type ShotsOptions } from './sim/shots.js';
|
|
4
5
|
export {
|
|
5
6
|
findSim,
|
|
6
7
|
simGet,
|
package/src/sim/client/app.css
CHANGED
package/src/sim/client/main.ts
CHANGED
|
@@ -20,7 +20,7 @@ interface Status {
|
|
|
20
20
|
permissions: string[]
|
|
21
21
|
ui: {open: boolean; clients: number}
|
|
22
22
|
display: {view: string | null; frames: number; elements: number}
|
|
23
|
-
device: {model: string; canvas: {width: number; height: number} | null}
|
|
23
|
+
device: {model: string; label: string; canvas: {width: number; height: number} | null; gestures: string[]}
|
|
24
24
|
speaker: string
|
|
25
25
|
sensors: {glassesBattery: {level: number}; location: {lat: number; lng: number}; glassesConnected: boolean}
|
|
26
26
|
colorScheme: string
|
|
@@ -112,7 +112,12 @@ function showStatus(status: Status): void {
|
|
|
112
112
|
const label = status.background === "running" && !status.connected ? "starting" : status.background
|
|
113
113
|
state.dataset.state = status.background
|
|
114
114
|
state.textContent = status.paused && status.background === "running" ? "paused" : label
|
|
115
|
-
$("device-model").textContent = status.device.
|
|
115
|
+
$("device-model").textContent = status.device.label
|
|
116
|
+
document.querySelectorAll<HTMLButtonElement>("[data-touch]").forEach((button) => {
|
|
117
|
+
const sent = status.device.gestures.includes(button.dataset.touch ?? "")
|
|
118
|
+
button.disabled = !sent
|
|
119
|
+
button.title = sent ? "" : `${status.device.label} does not send this gesture`
|
|
120
|
+
})
|
|
116
121
|
const battery = $<HTMLInputElement>("battery")
|
|
117
122
|
if (document.activeElement !== battery) battery.value = String(status.sensors.glassesBattery.level)
|
|
118
123
|
$("battery-value").textContent = `${battery.value}%`
|
package/src/sim/device.test.ts
CHANGED
|
@@ -1,38 +1,67 @@
|
|
|
1
1
|
/// <reference types="bun-types" />
|
|
2
2
|
|
|
3
3
|
import {expect, test} from "bun:test"
|
|
4
|
-
import {textProfileFor} from "@glassly/miniapp/display"
|
|
5
4
|
import {existsSync} from "fs"
|
|
6
|
-
import {fileURLToPath} from "url"
|
|
7
5
|
|
|
8
|
-
import {
|
|
6
|
+
import {SIM_DEVICES} from "./device.js"
|
|
7
|
+
import MODELS from "./models.json" with {type: "json"}
|
|
8
|
+
import {ENGINE_MODEL_FILES, engineModelPath, loadEngineModels} from "./regenerate-models.js"
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
// computed path keeps the engine's sources out of this package's typecheck.
|
|
12
|
-
const engineProfile = fileURLToPath(
|
|
13
|
-
new URL("../../../../mobile/modules/engine/src/types/capabilities/simulated-glasses.ts", import.meta.url),
|
|
14
|
-
)
|
|
10
|
+
const inMonorepo = Object.values(ENGINE_MODEL_FILES).every(([file]) => existsSync(engineModelPath(file)))
|
|
15
11
|
|
|
16
|
-
test.skipIf(!
|
|
17
|
-
|
|
18
|
-
const device = simDevice()
|
|
19
|
-
expect(device.capabilities).toEqual(JSON.parse(JSON.stringify(simulatedGlasses)))
|
|
20
|
-
for (const [key, value] of Object.entries(device.scene)) expect(simulatedGlasses.display[key]).toEqual(value)
|
|
12
|
+
test.skipIf(!inMonorepo)("models.json matches the Glassly App's capability files (bun src/sim/regenerate-models.ts)", async () => {
|
|
13
|
+
expect(MODELS).toEqual((await loadEngineModels()) as typeof MODELS)
|
|
21
14
|
})
|
|
22
15
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
16
|
+
// Written by hand from the engine's capability files and, for custom firmware,
|
|
17
|
+
// the canvas and flags the native drivers publish.
|
|
18
|
+
const ALL = ["rect", "circle", "arc", "pie", "line", "triangle", "quad", "bezier", "svg"]
|
|
19
|
+
const EXPECTED = {
|
|
20
|
+
simulated: {model: "Simulated Glasses", canvas: [576, 288], position: true, text: 120, images: 120, shapes: ALL, animation: true, depth: true, profile: "even-realities-g1", mic: 1, speaker: true, camera: false},
|
|
21
|
+
g1: {model: "Even Realities G1", canvas: [640, 200], position: false, text: 6, images: 0, shapes: [], animation: false, depth: false, profile: "even-realities-g1", mic: 1, speaker: false, camera: false},
|
|
22
|
+
"g1-cfw": {model: "Even Realities G1", canvas: [640, 200], position: true, text: 120, images: 120, shapes: ALL, animation: true, depth: true, profile: "even-realities-g1", mic: 1, speaker: false, camera: false},
|
|
23
|
+
g2: {model: "Even Realities G2", canvas: [576, 288], position: true, text: 6, images: 4, shapes: ["rect"], animation: false, depth: false, profile: "even-realities-g2", mic: 1, speaker: false, camera: false},
|
|
24
|
+
"g2-cfw": {model: "Even Realities G2", canvas: [576, 288], position: true, text: 120, images: 120, shapes: ALL, animation: true, depth: true, profile: "even-realities-g2", mic: 1, speaker: false, camera: false},
|
|
25
|
+
"rayneo-io": {model: "RayNeo iO", canvas: [540, 180], position: true, text: 6, images: 4, shapes: [], animation: false, depth: false, profile: "rayneo-io", mic: 1, speaker: false, camera: false},
|
|
26
|
+
"rayneo-io-cfw": {model: "RayNeo iO", canvas: [540, 180], position: true, text: 120, images: 120, shapes: ALL, animation: true, depth: true, profile: "rayneo-io-cfw", mic: 1, speaker: false, camera: false},
|
|
27
|
+
nimo: {model: "NIMO", canvas: [500, 220], position: true, text: 32, images: 4, shapes: ["rect", "circle", "line"], animation: false, depth: false, profile: "nimo", mic: 2, speaker: false, camera: false},
|
|
28
|
+
"nimo-cfw": {model: "NIMO", canvas: [540, 280], position: true, text: 120, images: 120, shapes: ALL, animation: true, depth: true, profile: "nimo-cfw", mic: 2, speaker: false, camera: false},
|
|
29
|
+
"memomind-one": {model: "MemoMind One", canvas: [600, 350], position: true, text: 120, images: 120, shapes: ALL, animation: true, depth: true, profile: "memomind-one", mic: 1, speaker: false, camera: false},
|
|
30
|
+
"mentra-display": {model: "Mentra Display", canvas: [500, 220], position: true, text: 6, images: 4, shapes: ["rect"], animation: false, depth: false, profile: "mentra-nex", mic: 1, speaker: false, camera: false},
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
test("every device has an expected row", () => {
|
|
34
|
+
expect(Object.keys(SIM_DEVICES).sort()).toEqual([...Object.keys(EXPECTED), "mentra-live"].sort())
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test.each(Object.entries(EXPECTED))("--device %s reports what the Glassly App reports", (id, expected) => {
|
|
38
|
+
const {capabilities, scene} = SIM_DEVICES[id]
|
|
39
|
+
const display = capabilities.display as Record<string, unknown>
|
|
40
|
+
const microphone = capabilities.microphone as {count: number} | null
|
|
41
|
+
expect({
|
|
42
|
+
model: capabilities.modelName,
|
|
43
|
+
canvas: [scene?.width, scene?.height],
|
|
44
|
+
position: scene?.canPosition,
|
|
45
|
+
text: scene?.maxTextElements,
|
|
46
|
+
images: scene?.maxImageElements,
|
|
47
|
+
shapes: scene?.shapes as string[] | undefined,
|
|
48
|
+
animation: scene?.animation,
|
|
49
|
+
depth: scene?.depth,
|
|
50
|
+
profile: display.textProfile,
|
|
51
|
+
mic: capabilities.hasMicrophone ? microphone?.count : 0,
|
|
52
|
+
speaker: capabilities.hasSpeaker,
|
|
53
|
+
camera: capabilities.hasCamera,
|
|
54
|
+
}).toEqual(expected)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test("custom firmware turns off the firmware's own navigation and G2 gates its microphone on volume", () => {
|
|
58
|
+
expect(SIM_DEVICES.g2.capabilities.hasNativeNavigation).toBe(true)
|
|
59
|
+
expect(SIM_DEVICES["g2-cfw"].capabilities.hasNativeNavigation).toBe(false)
|
|
60
|
+
expect(SIM_DEVICES["g2-cfw"].capabilities.microphone).toEqual({count: 1, hasVAD: false, volumeGate: true})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test("Mentra Live has a camera and speaker but no display", () => {
|
|
64
|
+
const {capabilities, scene} = SIM_DEVICES["mentra-live"]
|
|
65
|
+
expect([capabilities.hasDisplay, capabilities.display, scene]).toEqual([false, null, null])
|
|
66
|
+
expect([capabilities.hasCamera, capabilities.hasSpeaker]).toEqual([true, true])
|
|
38
67
|
})
|
package/src/sim/device.ts
CHANGED
|
@@ -1,108 +1,198 @@
|
|
|
1
1
|
import {
|
|
2
|
-
G1_PROFILE,
|
|
3
|
-
G2_PROFILE,
|
|
4
2
|
MEMOMIND_ONE_PROFILE,
|
|
5
|
-
NEX_PROFILE,
|
|
6
3
|
NIMO_CFW_PROFILE,
|
|
7
|
-
NIMO_PROFILE,
|
|
8
4
|
RAYNEO_IO_CFW_PROFILE,
|
|
9
|
-
|
|
10
|
-
Z100_PROFILE,
|
|
5
|
+
textProfileFor,
|
|
11
6
|
type DisplayProfile,
|
|
12
7
|
type SceneDisplayCapabilities,
|
|
13
8
|
} from "@glassly/miniapp/display"
|
|
14
9
|
|
|
10
|
+
import MODELS from "./models.json" with {type: "json"}
|
|
11
|
+
|
|
12
|
+
type ModelName = keyof typeof MODELS
|
|
13
|
+
type Display = Record<string, unknown> & {count?: number; resolution?: {width: number; height: number}}
|
|
14
|
+
|
|
15
15
|
export interface SimDevice {
|
|
16
16
|
id: string
|
|
17
|
+
label: string
|
|
17
18
|
capabilities: Record<string, unknown> & {modelName: string}
|
|
18
|
-
|
|
19
|
+
/** Null for glasses without a display. */
|
|
20
|
+
scene: SceneDisplayCapabilities | null
|
|
19
21
|
profile: DisplayProfile
|
|
22
|
+
/** Touch and head gestures the model's driver sends, by wire name. */
|
|
23
|
+
gestures: readonly string[]
|
|
24
|
+
sendsButtonPress: boolean
|
|
25
|
+
/** Stock RayNeo iO: the driver joins a frame's text into its one subtitle page. */
|
|
26
|
+
joinsText: boolean
|
|
27
|
+
/** Glassly custom firmware gives the dashboard miniapp its own view. */
|
|
28
|
+
dashboardView: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface CustomFirmware {
|
|
32
|
+
canvas: {width: number; height: number}
|
|
33
|
+
stereo?: boolean
|
|
34
|
+
volumeGate?: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface DeviceSpec {
|
|
38
|
+
id: string
|
|
39
|
+
model: ModelName
|
|
40
|
+
label: string
|
|
41
|
+
gestures: readonly string[]
|
|
42
|
+
sendsButtonPress?: boolean
|
|
43
|
+
joinsText?: boolean
|
|
44
|
+
cfw?: CustomFirmware
|
|
20
45
|
}
|
|
21
46
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
height: 288,
|
|
25
|
-
canPosition: true,
|
|
26
|
-
maxTextElements: 120,
|
|
27
|
-
maxImageElements: 120,
|
|
28
|
-
shapes: ["rect", "circle", "arc", "pie", "line", "triangle", "quad", "bezier", "svg"],
|
|
29
|
-
animation: true,
|
|
30
|
-
rotation: true,
|
|
31
|
-
depth: true,
|
|
32
|
-
intensityLevels: 16,
|
|
33
|
-
partialUpdate: true,
|
|
34
|
-
} satisfies SceneDisplayCapabilities
|
|
47
|
+
const ALL_SHAPES = ["rect", "circle", "arc", "pie", "line", "triangle", "quad", "bezier", "svg"]
|
|
48
|
+
const CFW_VECTOR_MAX_ELEMENTS = 120
|
|
35
49
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
50
|
+
const CFW_SCENE_PROFILES: Partial<Record<ModelName, DisplayProfile>> = {
|
|
51
|
+
"RayNeo iO": RAYNEO_IO_CFW_PROFILE,
|
|
52
|
+
"MemoMind One": MEMOMIND_ONE_PROFILE,
|
|
53
|
+
NIMO: NIMO_CFW_PROFILE,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const HEAD = ["head_up", "head_down"]
|
|
57
|
+
const EVEN_TOUCH = ["single_tap", "double_tap", "swipe_up", "swipe_down", "tap_start", "tap_end", "tap_then_hold", "touch_down"]
|
|
58
|
+
const RAYNEO_TOUCH = ["single_tap", "double_tap", "swipe_up", "swipe_down", "tap_start", "tap_end", "tap_then_hold"]
|
|
59
|
+
const NIMO_TOUCH = ["single_tap", "double_tap", "long_press", "tap_start", "tap_end"]
|
|
60
|
+
|
|
61
|
+
// Gestures are the names each native driver forwards, not the events the
|
|
62
|
+
// capability file lists. Custom firmware values are what the drivers publish
|
|
63
|
+
// at runtime on current Glassly CFW.
|
|
64
|
+
const SPECS: DeviceSpec[] = [
|
|
65
|
+
{
|
|
66
|
+
id: "simulated",
|
|
67
|
+
model: "Simulated Glasses",
|
|
68
|
+
label: "Simulated Glasses (the Glassly App's phone mode)",
|
|
69
|
+
gestures: ["single_tap", "double_tap", "long_press", "tap_then_hold", "tap_start", "tap_end", "swipe_up", "swipe_down", "swipe_left", "swipe_right"],
|
|
70
|
+
sendsButtonPress: true,
|
|
71
|
+
},
|
|
72
|
+
{id: "g1", model: "Even Realities G1", label: "Even Realities G1, stock firmware", gestures: HEAD},
|
|
73
|
+
{
|
|
74
|
+
id: "g1-cfw",
|
|
75
|
+
model: "Even Realities G1",
|
|
76
|
+
label: "Even Realities G1, Glassly custom firmware",
|
|
77
|
+
gestures: ["single_tap", "double_tap", "triple_tap", "long_press", ...HEAD],
|
|
78
|
+
cfw: {canvas: {width: 640, height: 200}},
|
|
79
|
+
},
|
|
80
|
+
{id: "g2", model: "Even Realities G2", label: "Even Realities G2, stock firmware", gestures: [...EVEN_TOUCH, ...HEAD]},
|
|
81
|
+
{
|
|
82
|
+
id: "g2-cfw",
|
|
83
|
+
model: "Even Realities G2",
|
|
84
|
+
label: "Even Realities G2, Glassly custom firmware",
|
|
85
|
+
gestures: [...EVEN_TOUCH, ...HEAD],
|
|
86
|
+
cfw: {canvas: {width: 576, height: 288}, volumeGate: true},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: "rayneo-io",
|
|
90
|
+
model: "RayNeo iO",
|
|
91
|
+
label: "RayNeo iO, stock firmware",
|
|
92
|
+
gestures: [...RAYNEO_TOUCH, ...HEAD],
|
|
93
|
+
joinsText: true,
|
|
71
94
|
},
|
|
95
|
+
{
|
|
96
|
+
id: "rayneo-io-cfw",
|
|
97
|
+
model: "RayNeo iO",
|
|
98
|
+
label: "RayNeo iO, Glassly custom firmware",
|
|
99
|
+
gestures: [...RAYNEO_TOUCH, ...HEAD],
|
|
100
|
+
cfw: {canvas: {width: 540, height: 180}},
|
|
101
|
+
},
|
|
102
|
+
{id: "nimo", model: "NIMO", label: "NIMO, stock layout page", gestures: [...NIMO_TOUCH, ...HEAD]},
|
|
103
|
+
{
|
|
104
|
+
id: "nimo-cfw",
|
|
105
|
+
model: "NIMO",
|
|
106
|
+
label: "NIMO, Glassly custom firmware",
|
|
107
|
+
gestures: [...NIMO_TOUCH, ...HEAD],
|
|
108
|
+
cfw: {canvas: {width: 540, height: 280}},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: "memomind-one",
|
|
112
|
+
model: "MemoMind One",
|
|
113
|
+
label: "MemoMind One, Glassly custom firmware",
|
|
114
|
+
gestures: ["single_tap", "double_tap", "long_press", "tap_end", ...HEAD],
|
|
115
|
+
sendsButtonPress: true,
|
|
116
|
+
cfw: {canvas: {width: 600, height: 350}, stereo: true},
|
|
117
|
+
},
|
|
118
|
+
{id: "mentra-display", model: "Mentra Display", label: "Mentra Display", gestures: ["head_up"]},
|
|
119
|
+
{
|
|
120
|
+
id: "mentra-live",
|
|
121
|
+
model: "Mentra Live",
|
|
122
|
+
label: "Mentra Live (camera, no display)",
|
|
123
|
+
gestures: ["single_tap", "double_tap", "triple_tap", "long_press", ...HEAD],
|
|
124
|
+
sendsButtonPress: true,
|
|
125
|
+
},
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
function copy<T>(value: T): T {
|
|
129
|
+
return JSON.parse(JSON.stringify(value)) as T
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Mirrors the Glassly App's effective capabilities: the custom firmware
|
|
133
|
+
// overlay, then the published text profile.
|
|
134
|
+
function capabilitiesOf(spec: DeviceSpec): SimDevice["capabilities"] {
|
|
135
|
+
const base = copy(MODELS[spec.model]) as SimDevice["capabilities"] & {display: Display | null}
|
|
136
|
+
const cfw = spec.cfw
|
|
137
|
+
if (cfw && base.display) {
|
|
138
|
+
if (base.hasNativeNavigation === true) base.hasNativeNavigation = false
|
|
139
|
+
if (cfw.volumeGate) base.microphone = {...(base.microphone as object), volumeGate: true}
|
|
140
|
+
base.display = {
|
|
141
|
+
...base.display,
|
|
142
|
+
width: cfw.canvas.width,
|
|
143
|
+
height: cfw.canvas.height,
|
|
144
|
+
canPosition: true,
|
|
145
|
+
maxTextElements: Math.max(Number(base.display.maxTextElements ?? 0), CFW_VECTOR_MAX_ELEMENTS),
|
|
146
|
+
maxImageElements: Math.max(Number(base.display.maxImageElements ?? 0), CFW_VECTOR_MAX_ELEMENTS),
|
|
147
|
+
shapes: ALL_SHAPES,
|
|
148
|
+
animation: true,
|
|
149
|
+
rotation: true,
|
|
150
|
+
depth: (base.display.count ?? 1) >= 2 || cfw.stereo === true,
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (base.display) {
|
|
154
|
+
const profile = (cfw && CFW_SCENE_PROFILES[spec.model]) || textProfileFor({modelName: spec.model})
|
|
155
|
+
base.display = {...base.display, textProfile: profile.id}
|
|
156
|
+
}
|
|
157
|
+
return base
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// SceneRenderer.currentCapabilities in the Glassly App, with the same defaults.
|
|
161
|
+
function sceneOf(display: Display | null, profile: DisplayProfile): SceneDisplayCapabilities | null {
|
|
162
|
+
if (!display) return null
|
|
163
|
+
return {
|
|
164
|
+
width: Number(display.width ?? display.resolution?.width ?? profile.displayWidthPx),
|
|
165
|
+
height: Number(display.height ?? display.resolution?.height ?? profile.displayHeightPx ?? 288),
|
|
166
|
+
canPosition: display.canPosition === true,
|
|
167
|
+
maxTextElements: Number(display.maxTextElements ?? 6),
|
|
168
|
+
maxImageElements: Number(display.maxImageElements ?? 0),
|
|
169
|
+
maxImagePx: display.maxImagePx as SceneDisplayCapabilities["maxImagePx"],
|
|
170
|
+
shapes: (display.shapes ?? []) as SceneDisplayCapabilities["shapes"],
|
|
171
|
+
animation: display.animation === true,
|
|
172
|
+
rotation: display.rotation === true,
|
|
173
|
+
depth: display.depth === true,
|
|
174
|
+
intensityLevels: Number(display.intensityLevels ?? 2),
|
|
175
|
+
partialUpdate: display.partialUpdate === true,
|
|
176
|
+
}
|
|
72
177
|
}
|
|
73
178
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
function modelDevice(id: string, modelName: string, profile: DisplayProfile, width: number, height: number): SimDevice {
|
|
78
|
-
const scene = {...SIMULATED_DISPLAY, width, height}
|
|
79
|
-
const display = SIMULATED.capabilities.display as Record<string, unknown>
|
|
179
|
+
function deviceOf(spec: DeviceSpec): SimDevice {
|
|
180
|
+
const capabilities = capabilitiesOf(spec)
|
|
181
|
+
const profile = textProfileFor(capabilities)
|
|
80
182
|
return {
|
|
81
|
-
id,
|
|
82
|
-
|
|
183
|
+
id: spec.id,
|
|
184
|
+
label: spec.label,
|
|
185
|
+
capabilities,
|
|
186
|
+
scene: sceneOf(capabilities.display as Display | null, profile),
|
|
83
187
|
profile,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
188
|
+
gestures: spec.gestures,
|
|
189
|
+
sendsButtonPress: spec.sendsButtonPress === true,
|
|
190
|
+
joinsText: spec.joinsText === true,
|
|
191
|
+
dashboardView: spec.cfw !== undefined,
|
|
89
192
|
}
|
|
90
193
|
}
|
|
91
194
|
|
|
92
|
-
export const SIM_DEVICES: Record<string, SimDevice> = Object.fromEntries(
|
|
93
|
-
[
|
|
94
|
-
SIMULATED,
|
|
95
|
-
modelDevice("g1", "Even Realities G1", G1_PROFILE, 576, 288),
|
|
96
|
-
modelDevice("g2", "Even Realities G2", G2_PROFILE, 576, 288),
|
|
97
|
-
modelDevice("z100", "Vuzix Z100", Z100_PROFILE, 390, 288),
|
|
98
|
-
modelDevice("mentra-display", "Mentra Display", NEX_PROFILE, 500, 220),
|
|
99
|
-
modelDevice("nimo", "NIMO", NIMO_PROFILE, 500, 220),
|
|
100
|
-
modelDevice("nimo-cfw", "NIMO", NIMO_CFW_PROFILE, 540, 280),
|
|
101
|
-
modelDevice("rayneo-io", "RayNeo iO", RAYNEO_IO_PROFILE, 540, 180),
|
|
102
|
-
modelDevice("rayneo-io-cfw", "RayNeo iO", RAYNEO_IO_CFW_PROFILE, 540, 180),
|
|
103
|
-
modelDevice("memomind-one", "MemoMind One", MEMOMIND_ONE_PROFILE, 600, 350),
|
|
104
|
-
].map((device) => [device.id, device]),
|
|
105
|
-
)
|
|
195
|
+
export const SIM_DEVICES: Record<string, SimDevice> = Object.fromEntries(SPECS.map((spec) => [spec.id, deviceOf(spec)]))
|
|
106
196
|
|
|
107
197
|
export function simDevice(id = "simulated"): SimDevice {
|
|
108
198
|
const device = SIM_DEVICES[id]
|