@mentra/sdk 2.1.3 → 2.1.4
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 +18 -21
- package/dist/app/session/layouts.d.ts.map +1 -1
- package/dist/app/session/layouts.js +44 -55
- package/dist/app/session/modules/audio.d.ts +2 -2
- package/dist/app/session/modules/audio.d.ts.map +1 -1
- package/dist/app/session/modules/audio.js +21 -17
- package/dist/app/session/modules/camera.d.ts +4 -4
- package/dist/app/session/modules/camera.d.ts.map +1 -1
- package/dist/app/session/modules/camera.js +28 -22
- package/dist/app/session/modules/location.d.ts +3 -3
- package/dist/app/session/modules/location.d.ts.map +1 -1
- package/dist/app/session/modules/location.js +8 -5
- package/dist/types/user-session.d.ts +8 -8
- package/dist/types/user-session.d.ts.map +1 -1
- package/dist/utils/animation-utils.d.ts +4 -4
- package/dist/utils/animation-utils.d.ts.map +1 -1
- package/dist/utils/animation-utils.js +25 -24
- package/dist/utils/bitmap-utils.d.ts +4 -2
- package/dist/utils/bitmap-utils.d.ts.map +1 -1
- package/dist/utils/bitmap-utils.js +172 -45
- package/package.json +2 -1
@@ -1,12 +1,12 @@
|
|
1
|
-
import { AppSession } from
|
2
|
-
import { LocationUpdate } from
|
1
|
+
import { AppSession } from "..";
|
2
|
+
import { LocationUpdate } from "../../../types";
|
3
3
|
export declare class LocationManager {
|
4
4
|
private session;
|
5
5
|
private send;
|
6
6
|
private lastLocationCleanupHandler;
|
7
7
|
constructor(session: AppSession, send: (message: any) => void);
|
8
8
|
subscribeToStream(options: {
|
9
|
-
accuracy:
|
9
|
+
accuracy: "standard" | "high" | "realtime" | "tenMeters" | "hundredMeters" | "kilometer" | "threeKilometers" | "reduced";
|
10
10
|
}, handler: (data: LocationUpdate) => void): () => void;
|
11
11
|
unsubscribeFromStream(): void;
|
12
12
|
getLatestLocation(options: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../../../src/app/session/modules/location.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,
|
1
|
+
{"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../../../src/app/session/modules/location.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAGL,cAAc,EAEf,MAAM,gBAAgB,CAAC;AAExB,qBAAa,eAAe;IAIxB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,IAAI;IAJd,OAAO,CAAC,0BAA0B,CAAwB;gBAGhD,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI;IAI/B,iBAAiB,CACtB,OAAO,EAAE;QACP,QAAQ,EACJ,UAAU,GACV,MAAM,GACN,UAAU,GACV,WAAW,GACX,eAAe,GACf,WAAW,GACX,iBAAiB,GACjB,SAAS,CAAC;KACf,EACD,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,GACtC,MAAM,IAAI;IAWN,qBAAqB,IAAI,IAAI;IAUvB,iBAAiB,CAAC,OAAO,EAAE;QACtC,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,cAAc,CAAC;CA+B5B"}
|
@@ -10,7 +10,10 @@ class LocationManager {
|
|
10
10
|
}
|
11
11
|
// subscribes to the continuous location stream with a specified accuracy tier
|
12
12
|
subscribeToStream(options, handler) {
|
13
|
-
const subscription = {
|
13
|
+
const subscription = {
|
14
|
+
stream: "location_stream",
|
15
|
+
rate: options.accuracy,
|
16
|
+
};
|
14
17
|
this.session.subscribe(subscription);
|
15
18
|
this.lastLocationCleanupHandler = this.session.events.onLocation(handler);
|
16
19
|
return this.lastLocationCleanupHandler;
|
@@ -22,7 +25,7 @@ class LocationManager {
|
|
22
25
|
this.lastLocationCleanupHandler = () => { };
|
23
26
|
}
|
24
27
|
else {
|
25
|
-
this.session.unsubscribe(
|
28
|
+
this.session.unsubscribe("location_stream");
|
26
29
|
}
|
27
30
|
}
|
28
31
|
// performs a one-time, intelligent poll for a location fix
|
@@ -30,7 +33,7 @@ class LocationManager {
|
|
30
33
|
return new Promise((resolve, reject) => {
|
31
34
|
const requestId = `poll_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
32
35
|
// listens for a location update with a matching correlationId
|
33
|
-
const unsubscribe = this.session.events.on(
|
36
|
+
const unsubscribe = this.session.events.on("location_update", (data) => {
|
34
37
|
if (data.correlationId === requestId) {
|
35
38
|
unsubscribe(); // clean up the listener
|
36
39
|
resolve(data);
|
@@ -42,12 +45,12 @@ class LocationManager {
|
|
42
45
|
correlationId: requestId,
|
43
46
|
packageName: this.session.getPackageName(),
|
44
47
|
sessionId: this.session.getSessionId(),
|
45
|
-
accuracy: options.accuracy
|
48
|
+
accuracy: options.accuracy,
|
46
49
|
});
|
47
50
|
// sets a timeout to prevent the promise from hanging indefinitely
|
48
51
|
setTimeout(() => {
|
49
52
|
unsubscribe();
|
50
|
-
reject(
|
53
|
+
reject("Location poll request timed out");
|
51
54
|
}, 15000); // 15 second timeout
|
52
55
|
});
|
53
56
|
}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import { WebSocket } from
|
2
|
-
import { AppI, TranscriptI } from
|
3
|
-
import { DisplayRequest } from
|
4
|
-
import { Transform } from
|
5
|
-
import { ConversationTranscriber, PushAudioInputStream } from
|
6
|
-
import { ExtendedStreamType } from
|
7
|
-
import pino from
|
1
|
+
import { WebSocket } from "ws";
|
2
|
+
import { AppI, TranscriptI } from "./models";
|
3
|
+
import { DisplayRequest } from "./layouts";
|
4
|
+
import { Transform } from "stream";
|
5
|
+
import { ConversationTranscriber, PushAudioInputStream } from "microsoft-cognitiveservices-speech-sdk";
|
6
|
+
import { ExtendedStreamType } from "./streams";
|
7
|
+
import pino from "pino";
|
8
8
|
/**
|
9
9
|
* Session for an application
|
10
10
|
*/
|
@@ -53,7 +53,7 @@ export interface UserSession {
|
|
53
53
|
installedApps: AppI[];
|
54
54
|
activeAppSessions: string[];
|
55
55
|
loadingApps: Set<string>;
|
56
|
-
appSubscriptions: Map<string, ExtendedStreamType[]> |
|
56
|
+
appSubscriptions: Map<string, ExtendedStreamType[]> | object;
|
57
57
|
appConnections: Map<string, WebSocket>;
|
58
58
|
websocket: WebSocket;
|
59
59
|
transcript: TranscriptI;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user-session.d.ts","sourceRoot":"","sources":["../../src/types/user-session.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAe,WAAW,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAU,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAc,MAAM,WAAW,CAAC;AAE3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;GAEG;AAkBH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;CAAG;AAErD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,kBAAkB,
|
1
|
+
{"version":3,"file":"user-session.d.ts","sourceRoot":"","sources":["../../src/types/user-session.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,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AAI,CAAC,MAAM,CAAC;IAGpB,aAAa,EAAE,IAAI,EAAE,CAAC;IACtB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,GAAG,MAAM,CAAC;IAC7D,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAEvC,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,WAAW,CAAC;IAGxB,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAG9B,aAAa,EAAE,eAAe,EAAE,CAAC;IAGjC,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAG5B,YAAY,EAAE,kBAAkB,EAAE,CAAC;CACpC;AAED;;GAEG"}
|
@@ -20,8 +20,8 @@
|
|
20
20
|
* animation.stop();
|
21
21
|
* ```
|
22
22
|
*/
|
23
|
-
import { AppSession } from
|
24
|
-
import { LoadFramesOptions } from
|
23
|
+
import { AppSession } from "../app/session";
|
24
|
+
import { LoadFramesOptions } from "./bitmap-utils";
|
25
25
|
/**
|
26
26
|
* Configuration options for bitmap animations
|
27
27
|
*/
|
@@ -132,7 +132,7 @@ export declare class AnimationUtils {
|
|
132
132
|
* );
|
133
133
|
* ```
|
134
134
|
*/
|
135
|
-
static createBitmapAnimationFromFrames(session: AppSession, frames: string[], config?: Omit<AnimationConfig,
|
135
|
+
static createBitmapAnimationFromFrames(session: AppSession, frames: string[], config?: Omit<AnimationConfig, "loadOptions" | "validateFrames">): AnimationController;
|
136
136
|
/**
|
137
137
|
* Create a sequence of bitmap displays with custom timing
|
138
138
|
*
|
@@ -182,7 +182,7 @@ export declare class AnimationUtils {
|
|
182
182
|
* );
|
183
183
|
* ```
|
184
184
|
*/
|
185
|
-
static getOptimizedConfig(deviceType:
|
185
|
+
static getOptimizedConfig(deviceType: "even-realities-g1" | "generic"): AnimationConfig;
|
186
186
|
/**
|
187
187
|
* Preload and cache animation frames for better performance
|
188
188
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"animation-utils.d.ts","sourceRoot":"","sources":["../../src/utils/animation-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAe,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,eAAe;
|
1
|
+
{"version":3,"file":"animation-utils.d.ts","sourceRoot":"","sources":["../../src/utils/animation-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAe,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gEAAgE;IAChE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5D,sDAAsD;IACtD,O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,OAAO,CAAC,IAAI,CAAC;IA2BhB;;;;;;;;;;;;;OAaG;WACU,aAAa,CACxB,cAAc,EAAE,MAAM,EACtB,eAAe,GAAE,MAAc,GAC9B,OAAO,CAAC,UAAU,CAAC;IA2CtB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,kBAAkB,CACvB,UAAU,EAAE,mBAAmB,GAAG,SAAS,GAC1C,eAAe;IA2BlB;;;;;;;;;;;;;;;;;OAiBG;WACU,aAAa,CACxB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,EAAE,CAAC;CAcrB"}
|
@@ -42,7 +42,7 @@ class AnimationUtils {
|
|
42
42
|
* ```
|
43
43
|
*/
|
44
44
|
static delay(ms) {
|
45
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
45
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
46
46
|
}
|
47
47
|
/**
|
48
48
|
* Create bitmap animation from files with advanced configuration
|
@@ -74,16 +74,16 @@ class AnimationUtils {
|
|
74
74
|
*/
|
75
75
|
static async createBitmapAnimation(session, basePath, frameCount, config = {}) {
|
76
76
|
const { intervalMs = 1750, // Optimized for MentraOS hardware
|
77
|
-
repeat = false, validateFrames = true, loadOptions = {}, onStart, onStop, onFrame, onError } = config;
|
77
|
+
repeat = false, validateFrames = true, loadOptions = {}, onStart, onStop, onFrame, onError, } = config;
|
78
78
|
try {
|
79
79
|
console.log(`🎬 Loading ${frameCount} animation frames from ${basePath}...`);
|
80
80
|
// Load frames with validation
|
81
81
|
const frames = await bitmap_utils_1.BitmapUtils.loadBmpFrames(basePath, frameCount, {
|
82
82
|
validateFrames,
|
83
|
-
...loadOptions
|
83
|
+
...loadOptions,
|
84
84
|
});
|
85
85
|
if (frames.length === 0) {
|
86
|
-
throw new Error(
|
86
|
+
throw new Error("No frames loaded for animation");
|
87
87
|
}
|
88
88
|
console.log(`📚 Animation ready: ${frames.length} frames at ${intervalMs}ms intervals`);
|
89
89
|
// Create enhanced animation with the loaded frames
|
@@ -93,11 +93,11 @@ class AnimationUtils {
|
|
93
93
|
onStart,
|
94
94
|
onStop,
|
95
95
|
onFrame,
|
96
|
-
onError
|
96
|
+
onError,
|
97
97
|
});
|
98
98
|
}
|
99
99
|
catch (error) {
|
100
|
-
const errorMsg = `Failed to create animation: ${error instanceof Error ? error.message :
|
100
|
+
const errorMsg = `Failed to create animation: ${error instanceof Error ? error.message : "Unknown error"}`;
|
101
101
|
console.error(`❌ ${errorMsg}`);
|
102
102
|
if (onError) {
|
103
103
|
onError(errorMsg);
|
@@ -122,9 +122,9 @@ class AnimationUtils {
|
|
122
122
|
* ```
|
123
123
|
*/
|
124
124
|
static createBitmapAnimationFromFrames(session, frames, config = {}) {
|
125
|
-
const { intervalMs = 1750, repeat = false, onStart, onStop, onFrame, onError } = config;
|
125
|
+
const { intervalMs = 1750, repeat = false, onStart, onStop, onFrame, onError, } = config;
|
126
126
|
let isRunning = false;
|
127
|
-
|
127
|
+
const currentFrame = 0;
|
128
128
|
let animationController = null;
|
129
129
|
const controller = {
|
130
130
|
stop: () => {
|
@@ -136,11 +136,11 @@ class AnimationUtils {
|
|
136
136
|
if (onStop) {
|
137
137
|
onStop();
|
138
138
|
}
|
139
|
-
console.log(
|
139
|
+
console.log("🛑 Animation stopped");
|
140
140
|
},
|
141
141
|
isRunning: () => isRunning,
|
142
142
|
getCurrentFrame: () => currentFrame,
|
143
|
-
getTotalFrames: () => frames.length
|
143
|
+
getTotalFrames: () => frames.length,
|
144
144
|
};
|
145
145
|
try {
|
146
146
|
// Start the animation using the session's built-in method
|
@@ -149,7 +149,7 @@ class AnimationUtils {
|
|
149
149
|
if (onStart) {
|
150
150
|
onStart();
|
151
151
|
}
|
152
|
-
console.log(`🎬 Animation started: ${frames.length} frames at ${intervalMs}ms${repeat ?
|
152
|
+
console.log(`🎬 Animation started: ${frames.length} frames at ${intervalMs}ms${repeat ? " (repeating)" : ""}`);
|
153
153
|
// If we have frame callbacks, we need to track timing manually
|
154
154
|
// This is a limitation of the current SDK - we can't hook into individual frame displays
|
155
155
|
if (onFrame) {
|
@@ -177,7 +177,7 @@ class AnimationUtils {
|
|
177
177
|
}
|
178
178
|
}
|
179
179
|
catch (error) {
|
180
|
-
const errorMsg = `Failed to start animation: ${error instanceof Error ? error.message :
|
180
|
+
const errorMsg = `Failed to start animation: ${error instanceof Error ? error.message : "Unknown error"}`;
|
181
181
|
console.error(`❌ ${errorMsg}`);
|
182
182
|
if (onError) {
|
183
183
|
onError(errorMsg);
|
@@ -209,7 +209,8 @@ class AnimationUtils {
|
|
209
209
|
try {
|
210
210
|
console.log(`📽️ Sequence frame ${i + 1}/${sequence.length} (${duration}ms)`);
|
211
211
|
session.layouts.showBitmapView(frame);
|
212
|
-
if (i < sequence.length - 1) {
|
212
|
+
if (i < sequence.length - 1) {
|
213
|
+
// Don't delay after the last frame
|
213
214
|
await this.delay(duration);
|
214
215
|
}
|
215
216
|
}
|
@@ -218,7 +219,7 @@ class AnimationUtils {
|
|
218
219
|
throw error;
|
219
220
|
}
|
220
221
|
}
|
221
|
-
console.log(
|
222
|
+
console.log("✅ Bitmap sequence completed");
|
222
223
|
}
|
223
224
|
/**
|
224
225
|
* Measure animation timing performance
|
@@ -237,7 +238,7 @@ class AnimationUtils {
|
|
237
238
|
static async measureTiming(targetInterval, measureDuration = 10000) {
|
238
239
|
return new Promise((resolve) => {
|
239
240
|
const timestamps = [];
|
240
|
-
|
241
|
+
const startTime = Date.now();
|
241
242
|
const measureInterval = setInterval(() => {
|
242
243
|
timestamps.push(Date.now());
|
243
244
|
}, targetInterval);
|
@@ -248,7 +249,7 @@ class AnimationUtils {
|
|
248
249
|
targetInterval,
|
249
250
|
actualInterval: targetInterval,
|
250
251
|
drift: 0,
|
251
|
-
fps: 1000 / targetInterval
|
252
|
+
fps: 1000 / targetInterval,
|
252
253
|
});
|
253
254
|
return;
|
254
255
|
}
|
@@ -264,7 +265,7 @@ class AnimationUtils {
|
|
264
265
|
targetInterval,
|
265
266
|
actualInterval,
|
266
267
|
drift,
|
267
|
-
fps
|
268
|
+
fps,
|
268
269
|
});
|
269
270
|
}, measureDuration);
|
270
271
|
});
|
@@ -285,17 +286,17 @@ class AnimationUtils {
|
|
285
286
|
*/
|
286
287
|
static getOptimizedConfig(deviceType) {
|
287
288
|
switch (deviceType) {
|
288
|
-
case
|
289
|
+
case "even-realities-g1":
|
289
290
|
return {
|
290
291
|
intervalMs: 1650, // Tested optimal timing for Even Realities G1
|
291
292
|
repeat: false,
|
292
293
|
validateFrames: true,
|
293
294
|
loadOptions: {
|
294
295
|
validateFrames: true,
|
295
|
-
skipMissingFrames: false
|
296
|
-
}
|
296
|
+
skipMissingFrames: false,
|
297
|
+
},
|
297
298
|
};
|
298
|
-
case
|
299
|
+
case "generic":
|
299
300
|
default:
|
300
301
|
return {
|
301
302
|
intervalMs: 1000,
|
@@ -303,8 +304,8 @@ class AnimationUtils {
|
|
303
304
|
validateFrames: true,
|
304
305
|
loadOptions: {
|
305
306
|
validateFrames: true,
|
306
|
-
skipMissingFrames: false
|
307
|
-
}
|
307
|
+
skipMissingFrames: false,
|
308
|
+
},
|
308
309
|
};
|
309
310
|
}
|
310
311
|
}
|
@@ -330,7 +331,7 @@ class AnimationUtils {
|
|
330
331
|
console.log(`📦 Preloading ${frameCount} frames from ${basePath}...`);
|
331
332
|
const frames = await bitmap_utils_1.BitmapUtils.loadBmpFrames(basePath, frameCount, {
|
332
333
|
validateFrames: true,
|
333
|
-
...options
|
334
|
+
...options,
|
334
335
|
});
|
335
336
|
console.log(`✅ Preloaded ${frames.length} frames (${frames.reduce((total, frame) => total + frame.length, 0)} total characters)`);
|
336
337
|
return frames;
|
@@ -70,7 +70,9 @@ export declare class BitmapUtils {
|
|
70
70
|
* session.layouts.showBitmapView(bmpHex);
|
71
71
|
* ```
|
72
72
|
*/
|
73
|
-
static
|
73
|
+
static loadBmpFromFileAsHex(filePath: string): Promise<string>;
|
74
|
+
static convert24BitTo1BitBMP(input24BitBmp: Buffer): Promise<Buffer>;
|
75
|
+
static loadBmpFromDataAsHex(bmpData: Buffer): Promise<string>;
|
74
76
|
/**
|
75
77
|
* Load multiple BMP frames as hex array for animations
|
76
78
|
*
|
@@ -123,7 +125,7 @@ export declare class BitmapUtils {
|
|
123
125
|
* const bufferData = BitmapUtils.convertFormat(base64Data, 'base64', 'buffer');
|
124
126
|
* ```
|
125
127
|
*/
|
126
|
-
static convertFormat(data: string | Buffer, fromFormat:
|
128
|
+
static convertFormat(data: string | Buffer, fromFormat: "hex" | "base64" | "buffer", toFormat: "hex" | "base64" | "buffer"): string | Buffer;
|
127
129
|
/**
|
128
130
|
* Get bitmap information without full validation
|
129
131
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"bitmap-utils.d.ts","sourceRoot":"","sources":["../../src/utils/bitmap-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
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,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