@mentra/sdk 2.1.10 → 2.1.12
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/app/session/layouts.d.ts +6 -19
- package/dist/app/session/layouts.d.ts.map +1 -1
- package/dist/app/session/layouts.js +9 -2
- package/dist/types/models.d.ts +4 -3
- package/dist/types/models.d.ts.map +1 -1
- package/dist/types/models.js +37 -30
- package/dist/utils/bitmap-utils.d.ts +9 -7
- package/dist/utils/bitmap-utils.d.ts.map +1 -1
- package/dist/utils/bitmap-utils.js +37 -49
- package/package.json +1 -1
@@ -1,20 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* 🎨 Layout Manager Module
|
3
|
-
*
|
4
|
-
* Manages AR display layouts for Apps. This class provides an easy-to-use interface
|
5
|
-
* for showing different types of content in the user's AR view.
|
6
|
-
*
|
7
|
-
* @example
|
8
|
-
* ```typescript
|
9
|
-
* const layouts = new LayoutManager('org.example.myapp', sendMessage);
|
10
|
-
*
|
11
|
-
* // Show a simple message
|
12
|
-
* layouts.showTextWall('Hello AR World!');
|
13
|
-
*
|
14
|
-
* // Show a card with title
|
15
|
-
* layouts.showReferenceCard('Weather', 'Sunny and 75°F');
|
16
|
-
* ```
|
17
|
-
*/
|
18
1
|
import { DisplayRequest, ViewType } from "../../types";
|
19
2
|
export declare class LayoutManager {
|
20
3
|
private packageName;
|
@@ -125,9 +108,13 @@ export declare class LayoutManager {
|
|
125
108
|
* );
|
126
109
|
* ```
|
127
110
|
*/
|
128
|
-
showBitmapView(
|
111
|
+
showBitmapView(base64Bitmap: string, options?: {
|
129
112
|
view?: ViewType;
|
130
|
-
|
113
|
+
padding?: {
|
114
|
+
left: number;
|
115
|
+
top: number;
|
116
|
+
};
|
117
|
+
}): Promise<void>;
|
131
118
|
/**
|
132
119
|
* 📊 Shows a dashboard card with left and right text
|
133
120
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../../src/app/session/layouts.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../../src/app/session/layouts.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,cAAc,EAOd,QAAQ,EAKT,MAAM,aAAa,CAAC;AAErB,qBAAa,aAAa;IAQtB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,WAAW;IARrB;;;;;OAKG;gBAEO,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI;IAGxD;;;;;;;;OAQG;IACH,OAAO,CAAC,kBAAkB;IAoH1B;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CACV,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAuCpD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,kBAAkB,CAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAYpD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,iBAAiB,CACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAYpD;;;;;;;;;;;;;;;;OAgBG;IACG,cAAc,CAClB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,OAAO,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE;IAoBxE;;;;;;;;;;;;;;;;OAgBG;IACH,iBAAiB,CACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAgBpD;;;;;;;;;;;;;;;OAeG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAA;KAAE;IAOvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,mBAAmB,CACjB,eAAe,EAAE,MAAM,EAAE,EACzB,UAAU,GAAE,MAAa,EACzB,MAAM,GAAE,OAAe,EACvB,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,QAAQ,CAAA;KAAE,GAC5B;QAAE,IAAI,EAAE,MAAM,IAAI,CAAA;KAAE;CAiCxB"}
|
@@ -18,6 +18,7 @@ exports.LayoutManager = void 0;
|
|
18
18
|
* layouts.showReferenceCard('Weather', 'Sunny and 75°F');
|
19
19
|
* ```
|
20
20
|
*/
|
21
|
+
const bitmap_utils_1 = require("../../utils/bitmap-utils");
|
21
22
|
const types_1 = require("../../types");
|
22
23
|
class LayoutManager {
|
23
24
|
/**
|
@@ -254,10 +255,16 @@ class LayoutManager {
|
|
254
255
|
* );
|
255
256
|
* ```
|
256
257
|
*/
|
257
|
-
showBitmapView(
|
258
|
+
async showBitmapView(base64Bitmap, options) {
|
259
|
+
const padding = options?.padding ?? { left: 50, top: 35 };
|
260
|
+
const bitmapFrame = await bitmap_utils_1.BitmapUtils.padBase64Bitmap(base64Bitmap, padding);
|
261
|
+
const validation = bitmap_utils_1.BitmapUtils.validateBase64Bitmap(bitmapFrame);
|
262
|
+
if (!validation.isValid) {
|
263
|
+
throw new Error(`❌ Frame validation failed: ${validation.errors.join(", ")}`);
|
264
|
+
}
|
258
265
|
const layout = {
|
259
266
|
layoutType: types_1.LayoutType.BITMAP_VIEW,
|
260
|
-
data:
|
267
|
+
data: bitmapFrame,
|
261
268
|
};
|
262
269
|
this.sendMessage(this.createDisplayEvent(layout, options?.view));
|
263
270
|
}
|
package/dist/types/models.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { AppSettingType, AppType } from
|
1
|
+
import { AppSettingType, AppType } from "./enums";
|
2
2
|
export interface ToolParameterSchema {
|
3
|
-
type:
|
3
|
+
type: "string" | "number" | "boolean";
|
4
4
|
description: string;
|
5
5
|
enum?: string[];
|
6
6
|
required?: boolean;
|
@@ -24,6 +24,7 @@ export interface DeveloperProfile {
|
|
24
24
|
export declare enum PermissionType {
|
25
25
|
MICROPHONE = "MICROPHONE",
|
26
26
|
LOCATION = "LOCATION",
|
27
|
+
BACKGROUND_LOCATION = "BACKGROUND_LOCATION",
|
27
28
|
CALENDAR = "CALENDAR",
|
28
29
|
CAMERA = "CAMERA",
|
29
30
|
NOTIFICATIONS = "NOTIFICATIONS",
|
@@ -62,7 +63,7 @@ export interface AppI {
|
|
62
63
|
settings?: AppSettings;
|
63
64
|
tools?: ToolSchema[];
|
64
65
|
isPublic?: boolean;
|
65
|
-
appStoreStatus?:
|
66
|
+
appStoreStatus?: "DEVELOPMENT" | "SUBMITTED" | "REJECTED" | "PUBLISHED";
|
66
67
|
}
|
67
68
|
/**
|
68
69
|
* Base interface for all app settings
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/types/models.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAsB,OAAO,EAAE,MAAM,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/types/models.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAsB,OAAO,EAAE,MAAM,SAAS,CAAC;AAGtE,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,C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AY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,GACF,CAAC,cAAc,GAAG;IAChB,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,GACF,CAAC,cAAc,GAAG;IAChB,IAAI,EAAE,cAAc,CAAC,WAAW,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,GAAG,CAAC,EAAE,KAAK,CAAC;CACb,CAAC,CAAC;AAEP,MAAM,MAAM,WAAW,GAAG,UAAU,EAAE,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,SAAS,CAoGlE;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAC;CACrD"}
|
package/dist/types/models.js
CHANGED
@@ -10,6 +10,7 @@ var PermissionType;
|
|
10
10
|
(function (PermissionType) {
|
11
11
|
PermissionType["MICROPHONE"] = "MICROPHONE";
|
12
12
|
PermissionType["LOCATION"] = "LOCATION";
|
13
|
+
PermissionType["BACKGROUND_LOCATION"] = "BACKGROUND_LOCATION";
|
13
14
|
PermissionType["CALENDAR"] = "CALENDAR";
|
14
15
|
PermissionType["CAMERA"] = "CAMERA";
|
15
16
|
// Legacy notification permission (backward compatibility)
|
@@ -21,7 +22,7 @@ var PermissionType;
|
|
21
22
|
})(PermissionType || (exports.PermissionType = PermissionType = {}));
|
22
23
|
// Legacy permission mapping for backward compatibility
|
23
24
|
exports.LEGACY_PERMISSION_MAP = new Map([
|
24
|
-
[PermissionType.NOTIFICATIONS, [PermissionType.READ_NOTIFICATIONS]]
|
25
|
+
[PermissionType.NOTIFICATIONS, [PermissionType.READ_NOTIFICATIONS]],
|
25
26
|
]);
|
26
27
|
/**
|
27
28
|
* Validate a App configuration object
|
@@ -29,12 +30,12 @@ exports.LEGACY_PERMISSION_MAP = new Map([
|
|
29
30
|
* @returns True if the config is valid
|
30
31
|
*/
|
31
32
|
function validateAppConfig(config) {
|
32
|
-
if (!config || typeof config !==
|
33
|
+
if (!config || typeof config !== "object")
|
33
34
|
return false;
|
34
35
|
// Check required string properties
|
35
|
-
if (typeof config.name !==
|
36
|
-
typeof config.description !==
|
37
|
-
typeof config.version !==
|
36
|
+
if (typeof config.name !== "string" ||
|
37
|
+
typeof config.description !== "string" ||
|
38
|
+
typeof config.version !== "string") {
|
38
39
|
return false;
|
39
40
|
}
|
40
41
|
// Check settings array
|
@@ -43,50 +44,56 @@ function validateAppConfig(config) {
|
|
43
44
|
// Validate each setting
|
44
45
|
return config.settings.every((setting) => {
|
45
46
|
// Group settings just need a title
|
46
|
-
if (setting.type ===
|
47
|
-
return typeof setting.title ===
|
47
|
+
if (setting.type === "group") {
|
48
|
+
return typeof setting.title === "string";
|
48
49
|
}
|
49
50
|
// TITLE_VALUE settings just need label and value
|
50
|
-
if (setting.type ===
|
51
|
-
return typeof setting.label ===
|
51
|
+
if (setting.type === "titleValue") {
|
52
|
+
return typeof setting.label === "string" && "value" in setting;
|
52
53
|
}
|
53
54
|
// Regular settings need key and label
|
54
|
-
if (typeof setting.key !==
|
55
|
+
if (typeof setting.key !== "string" || typeof setting.label !== "string") {
|
55
56
|
return false;
|
56
57
|
}
|
57
58
|
// Type-specific validation
|
58
59
|
switch (setting.type) {
|
59
60
|
case enums_1.AppSettingType.TOGGLE:
|
60
|
-
return typeof setting.defaultValue ===
|
61
|
+
return typeof setting.defaultValue === "boolean";
|
61
62
|
case enums_1.AppSettingType.TEXT:
|
62
63
|
case enums_1.AppSettingType.TEXT_NO_SAVE_BUTTON:
|
63
|
-
return setting.defaultValue === undefined ||
|
64
|
+
return (setting.defaultValue === undefined ||
|
65
|
+
typeof setting.defaultValue === "string");
|
64
66
|
case enums_1.AppSettingType.SELECT:
|
65
67
|
case enums_1.AppSettingType.SELECT_WITH_SEARCH:
|
66
|
-
return Array.isArray(setting.options) &&
|
67
|
-
setting.options.every((opt) => typeof opt.label ===
|
68
|
+
return (Array.isArray(setting.options) &&
|
69
|
+
setting.options.every((opt) => typeof opt.label === "string" && "value" in opt));
|
68
70
|
case enums_1.AppSettingType.MULTISELECT:
|
69
|
-
return Array.isArray(setting.options) &&
|
70
|
-
setting.options.every((opt) => typeof opt.label ===
|
71
|
-
(setting.defaultValue === undefined ||
|
71
|
+
return (Array.isArray(setting.options) &&
|
72
|
+
setting.options.every((opt) => typeof opt.label === "string" && "value" in opt) &&
|
73
|
+
(setting.defaultValue === undefined ||
|
74
|
+
Array.isArray(setting.defaultValue)));
|
72
75
|
case enums_1.AppSettingType.SLIDER:
|
73
|
-
return typeof setting.defaultValue ===
|
74
|
-
typeof setting.min ===
|
75
|
-
typeof setting.max ===
|
76
|
-
setting.min <= setting.max;
|
76
|
+
return (typeof setting.defaultValue === "number" &&
|
77
|
+
typeof setting.min === "number" &&
|
78
|
+
typeof setting.max === "number" &&
|
79
|
+
setting.min <= setting.max);
|
77
80
|
case enums_1.AppSettingType.NUMERIC_INPUT:
|
78
|
-
return (setting.defaultValue === undefined ||
|
79
|
-
|
80
|
-
(setting.
|
81
|
-
(setting.
|
82
|
-
(setting.
|
81
|
+
return ((setting.defaultValue === undefined ||
|
82
|
+
typeof setting.defaultValue === "number") &&
|
83
|
+
(setting.min === undefined || typeof setting.min === "number") &&
|
84
|
+
(setting.max === undefined || typeof setting.max === "number") &&
|
85
|
+
(setting.step === undefined || typeof setting.step === "number") &&
|
86
|
+
(setting.placeholder === undefined ||
|
87
|
+
typeof setting.placeholder === "string"));
|
83
88
|
case enums_1.AppSettingType.TIME_PICKER:
|
84
|
-
return (setting.defaultValue === undefined ||
|
85
|
-
|
89
|
+
return ((setting.defaultValue === undefined ||
|
90
|
+
typeof setting.defaultValue === "number") &&
|
91
|
+
(setting.showSeconds === undefined ||
|
92
|
+
typeof setting.showSeconds === "boolean"));
|
86
93
|
case enums_1.AppSettingType.GROUP:
|
87
|
-
return typeof setting.title ===
|
94
|
+
return typeof setting.title === "string";
|
88
95
|
case enums_1.AppSettingType.TITLE_VALUE:
|
89
|
-
return typeof setting.label ===
|
96
|
+
return typeof setting.label === "string" && "value" in setting;
|
90
97
|
default:
|
91
98
|
return false;
|
92
99
|
}
|
@@ -57,6 +57,7 @@ export interface LoadFramesOptions {
|
|
57
57
|
* Utility class for working with bitmap images in MentraOS applications
|
58
58
|
*/
|
59
59
|
export declare class BitmapUtils {
|
60
|
+
static convert24BitTo1BitBMP(input24BitBmp: Buffer): Promise<Buffer>;
|
60
61
|
/**
|
61
62
|
* Load a BMP file as hex string from filesystem
|
62
63
|
*
|
@@ -70,12 +71,13 @@ export declare class BitmapUtils {
|
|
70
71
|
* session.layouts.showBitmapView(bmpBase64);
|
71
72
|
* ```
|
72
73
|
*/
|
73
|
-
static
|
74
|
-
static
|
75
|
-
static
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
static fileToBase64(filePath: string): Promise<string>;
|
75
|
+
static bufferToBase64(bmpData: Buffer): Promise<string>;
|
76
|
+
static padBase64Bitmap(bmpBase64: string, padding?: {
|
77
|
+
left: number;
|
78
|
+
top: number;
|
79
|
+
}): Promise<string>;
|
80
|
+
static padBmpForGlasses(bmpData: Buffer, leftPadding?: number, topPadding?: number): Promise<Buffer>;
|
79
81
|
/**
|
80
82
|
* Load multiple BMP frames as hex array for animations
|
81
83
|
*
|
@@ -113,7 +115,7 @@ export declare class BitmapUtils {
|
|
113
115
|
* }
|
114
116
|
* ```
|
115
117
|
*/
|
116
|
-
static
|
118
|
+
static validateBase64Bitmap(bmpFrame: string): BitmapValidation;
|
117
119
|
/**
|
118
120
|
* Convert bitmap data between different formats
|
119
121
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"bitmap-utils.d.ts","sourceRoot":"","sources":["../../src/utils/bitmap-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE;QACT,iDAAiD;QACjD,UAAU,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QAC/C,8BAA8B;QAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,8DAA8D;IAC9D,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,qBAAa,WAAW;
|
1
|
+
{"version":3,"file":"bitm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OAAO,EAAE,MAAM,EACf,WAAW,GAAE,MAAW,EACxB,UAAU,GAAE,MAAW,GACtB,OAAO,CAAC,MAAM,CAAC;IAkDlB;;;;;;;;;;;;;;;;;;;OAmBG;WACU,aAAa,CACxB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,EAAE,CAAC;IAgEpB;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB;IAgG/D;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,aAAa,CAClB,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,UAAU,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,EACvC,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GACpC,MAAM,GAAG,MAAM;IA+BlB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG;QACvC,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC;KACrB;CAsCF"}
|
@@ -60,43 +60,6 @@ const jimp_1 = require("jimp");
|
|
60
60
|
* Utility class for working with bitmap images in MentraOS applications
|
61
61
|
*/
|
62
62
|
class BitmapUtils {
|
63
|
-
/**
|
64
|
-
* Load a BMP file as hex string from filesystem
|
65
|
-
*
|
66
|
-
* @param filePath - Path to the BMP file
|
67
|
-
* @returns Promise resolving to hex-encoded bitmap data
|
68
|
-
* @throws Error if file cannot be read or is not a valid BMP
|
69
|
-
*
|
70
|
-
* @example
|
71
|
-
* ```typescript
|
72
|
-
* const bmpBase64 = await BitmapUtils.loadBmpFromFileAsBase64('./assets/icon.bmp');
|
73
|
-
* session.layouts.showBitmapView(bmpBase64);
|
74
|
-
* ```
|
75
|
-
*/
|
76
|
-
static async loadBmpFromFileAsBase64(filePath) {
|
77
|
-
try {
|
78
|
-
const bmpData = await fs.readFile(filePath);
|
79
|
-
return this.loadBmpFromDataAsBase64(bmpData);
|
80
|
-
}
|
81
|
-
catch (error) {
|
82
|
-
if (error instanceof Error) {
|
83
|
-
throw new Error(`Failed to load BMP file ${filePath}: ${error.message}`);
|
84
|
-
}
|
85
|
-
throw new Error(`Failed to load BMP file ${filePath}: Unknown error`);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
static async loadBmpFromFileAsHex(filePath) {
|
89
|
-
try {
|
90
|
-
const bmpData = await fs.readFile(filePath);
|
91
|
-
return this.loadBmpFromDataAsHex(bmpData);
|
92
|
-
}
|
93
|
-
catch (error) {
|
94
|
-
if (error instanceof Error) {
|
95
|
-
throw new Error(`Failed to load BMP file ${filePath}: ${error.message}`);
|
96
|
-
}
|
97
|
-
throw new Error(`Failed to load BMP file ${filePath}: Unknown error`);
|
98
|
-
}
|
99
|
-
}
|
100
63
|
static async convert24BitTo1BitBMP(input24BitBmp) {
|
101
64
|
// Read header information from 24-bit BMP
|
102
65
|
const width = input24BitBmp.readUInt32LE(18);
|
@@ -191,15 +154,40 @@ class BitmapUtils {
|
|
191
154
|
}
|
192
155
|
return output1BitBmp;
|
193
156
|
}
|
194
|
-
|
195
|
-
|
196
|
-
|
157
|
+
/**
|
158
|
+
* Load a BMP file as hex string from filesystem
|
159
|
+
*
|
160
|
+
* @param filePath - Path to the BMP file
|
161
|
+
* @returns Promise resolving to hex-encoded bitmap data
|
162
|
+
* @throws Error if file cannot be read or is not a valid BMP
|
163
|
+
*
|
164
|
+
* @example
|
165
|
+
* ```typescript
|
166
|
+
* const bmpBase64 = await BitmapUtils.loadBmpFromFileAsBase64('./assets/icon.bmp');
|
167
|
+
* session.layouts.showBitmapView(bmpBase64);
|
168
|
+
* ```
|
169
|
+
*/
|
170
|
+
static async fileToBase64(filePath) {
|
171
|
+
try {
|
172
|
+
const bmpData = await fs.readFile(filePath);
|
173
|
+
return this.bufferToBase64(bmpData);
|
174
|
+
}
|
175
|
+
catch (error) {
|
176
|
+
if (error instanceof Error) {
|
177
|
+
throw new Error(`Failed to load BMP file ${filePath}: ${error.message}`);
|
178
|
+
}
|
179
|
+
throw new Error(`Failed to load BMP file ${filePath}: Unknown error`);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
static async bufferToBase64(bmpData) {
|
183
|
+
return bmpData.toString("base64");
|
197
184
|
}
|
198
|
-
static async
|
199
|
-
const
|
200
|
-
|
185
|
+
static async padBase64Bitmap(bmpBase64, padding) {
|
186
|
+
const buffer = Buffer.from(bmpBase64, "base64");
|
187
|
+
const paddedBuffer = await this.padBmpForGlasses(buffer, padding?.left, padding?.top);
|
188
|
+
return paddedBuffer.toString("base64");
|
201
189
|
}
|
202
|
-
static async
|
190
|
+
static async padBmpForGlasses(bmpData, leftPadding = 50, topPadding = 35) {
|
203
191
|
try {
|
204
192
|
// Basic BMP validation - check for BMP signature
|
205
193
|
if (bmpData.length < 14 || bmpData[0] !== 0x42 || bmpData[1] !== 0x4d) {
|
@@ -265,9 +253,9 @@ class BitmapUtils {
|
|
265
253
|
const fileName = filePattern.replace("{i}", frameNumber.toString());
|
266
254
|
const filePath = path.join(basePath, fileName);
|
267
255
|
try {
|
268
|
-
const
|
256
|
+
const frameBase64 = await this.fileToBase64(filePath);
|
269
257
|
if (validateFrames) {
|
270
|
-
const validation = this.
|
258
|
+
const validation = this.validateBase64Bitmap(frameBase64);
|
271
259
|
if (!validation.isValid) {
|
272
260
|
const errorMsg = `Frame ${frameNumber} validation failed: ${validation.errors.join(", ")}`;
|
273
261
|
if (skipMissingFrames) {
|
@@ -280,7 +268,7 @@ class BitmapUtils {
|
|
280
268
|
}
|
281
269
|
console.log(`✅ Frame ${frameNumber} validated (${validation.blackPixels} black pixels)`);
|
282
270
|
}
|
283
|
-
frames.push(
|
271
|
+
frames.push(frameBase64);
|
284
272
|
}
|
285
273
|
catch (error) {
|
286
274
|
const errorMsg = `Failed to load frame ${frameNumber} (${fileName}): ${error instanceof Error ? error.message : "Unknown error"}`;
|
@@ -318,13 +306,13 @@ class BitmapUtils {
|
|
318
306
|
* }
|
319
307
|
* ```
|
320
308
|
*/
|
321
|
-
static
|
309
|
+
static validateBase64Bitmap(bmpFrame) {
|
322
310
|
const errors = [];
|
323
311
|
let byteCount = 0;
|
324
312
|
let blackPixels = 0;
|
325
313
|
const metadata = {};
|
326
314
|
try {
|
327
|
-
const hexString = Buffer.from(
|
315
|
+
const hexString = Buffer.from(bmpFrame, "base64").toString("hex");
|
328
316
|
// Basic hex validation
|
329
317
|
if (typeof hexString !== "string" || hexString.length === 0) {
|
330
318
|
errors.push("Hex string is empty or invalid");
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@mentra/sdk",
|
3
|
-
"version": "2.1.
|
3
|
+
"version": "2.1.12",
|
4
4
|
"description": "Build apps for MentraOS smartglasses. This SDK provides everything you need to create real-time smartglasses applications.",
|
5
5
|
"source": "src/index.ts",
|
6
6
|
"main": "dist/index.js",
|