@mentra/sdk 2.1.27 → 2.1.28
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/api-client.d.ts.map +1 -1
- package/dist/app/session/dashboard.d.ts +5 -8
- package/dist/app/session/dashboard.d.ts.map +1 -1
- package/dist/app/session/events.d.ts +2 -1
- package/dist/app/session/events.d.ts.map +1 -1
- package/dist/app/session/index.d.ts +62 -3
- package/dist/app/session/index.d.ts.map +1 -1
- package/dist/app/session/modules/audio.d.ts +33 -4
- package/dist/app/session/modules/audio.d.ts.map +1 -1
- package/dist/app/session/modules/camera-managed-extension.d.ts +2 -3
- package/dist/app/session/modules/camera-managed-extension.d.ts.map +1 -1
- package/dist/app/session/modules/camera.d.ts +5 -5
- package/dist/app/session/modules/camera.d.ts.map +1 -1
- package/dist/app/session/modules/led.d.ts +141 -0
- package/dist/app/session/modules/led.d.ts.map +1 -0
- package/dist/app/session/modules/location.d.ts +1 -2
- package/dist/app/session/modules/location.d.ts.map +1 -1
- package/dist/app/session/modules/simple-storage.d.ts.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5347 -112
- package/dist/index.js.map +45 -0
- package/dist/logging/logger.d.ts +1 -1
- package/dist/logging/logger.d.ts.map +1 -1
- package/dist/types/capabilities.d.ts +3 -0
- package/dist/types/capabilities.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -14
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/message-types.d.ts +8 -1
- package/dist/types/message-types.d.ts.map +1 -1
- package/dist/types/messages/app-to-cloud.d.ts +48 -2
- package/dist/types/messages/app-to-cloud.d.ts.map +1 -1
- package/dist/types/messages/cloud-to-app.d.ts +16 -6
- package/dist/types/messages/cloud-to-app.d.ts.map +1 -1
- package/dist/types/messages/cloud-to-glasses.d.ts +29 -1
- package/dist/types/messages/cloud-to-glasses.d.ts.map +1 -1
- package/dist/types/messages/glasses-to-cloud.d.ts +24 -1
- package/dist/types/messages/glasses-to-cloud.d.ts.map +1 -1
- package/dist/types/rtmp-stream.d.ts +1 -1
- package/dist/types/rtmp-stream.d.ts.map +1 -1
- package/dist/types/streams.d.ts +28 -1
- package/dist/types/streams.d.ts.map +1 -1
- package/package.json +9 -3
- package/dist/app/index.js +0 -24
- package/dist/app/server/index.js +0 -658
- package/dist/app/session/api-client.js +0 -101
- package/dist/app/session/dashboard.js +0 -149
- package/dist/app/session/events.js +0 -315
- package/dist/app/session/index.js +0 -1573
- package/dist/app/session/layouts.js +0 -372
- package/dist/app/session/modules/audio.js +0 -321
- package/dist/app/session/modules/camera-managed-extension.js +0 -310
- package/dist/app/session/modules/camera.js +0 -607
- package/dist/app/session/modules/index.js +0 -19
- package/dist/app/session/modules/location.js +0 -61
- package/dist/app/session/modules/simple-storage.js +0 -232
- package/dist/app/session/settings.js +0 -358
- package/dist/app/token/index.js +0 -22
- package/dist/app/token/utils.js +0 -144
- package/dist/app/webview/index.js +0 -382
- package/dist/constants/index.js +0 -16
- package/dist/constants/log-messages/color.js +0 -14
- package/dist/constants/log-messages/logos.js +0 -48
- package/dist/constants/log-messages/updates.js +0 -55
- package/dist/constants/log-messages/warning.js +0 -89
- package/dist/examples/managed-rtmp-streaming-example.js +0 -158
- package/dist/examples/managed-rtmp-streaming-with-restream-example.js +0 -124
- package/dist/examples/rtmp-streaming-example.js +0 -102
- package/dist/logging/logger.js +0 -79
- package/dist/types/capabilities.js +0 -9
- package/dist/types/dashboard/index.js +0 -12
- package/dist/types/enums.js +0 -75
- package/dist/types/index.js +0 -101
- package/dist/types/layouts.js +0 -3
- package/dist/types/message-types.js +0 -212
- package/dist/types/messages/app-to-cloud.js +0 -95
- package/dist/types/messages/base.js +0 -3
- package/dist/types/messages/cloud-to-app.js +0 -78
- package/dist/types/messages/cloud-to-glasses.js +0 -68
- package/dist/types/messages/glasses-to-cloud.js +0 -140
- package/dist/types/models.js +0 -101
- package/dist/types/photo-data.js +0 -2
- package/dist/types/rtmp-stream.js +0 -3
- package/dist/types/streams.js +0 -306
- package/dist/types/token.js +0 -7
- package/dist/types/webhooks.js +0 -28
- package/dist/utils/animation-utils.js +0 -340
- package/dist/utils/bitmap-utils.js +0 -475
- package/dist/utils/permissions-utils.js +0 -263
- package/dist/utils/resource-tracker.js +0 -153
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// src/messages/glasses-to-cloud.ts
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.PhotoStage = exports.PhotoErrorCode = void 0;
|
|
5
|
-
exports.isControlAction = isControlAction;
|
|
6
|
-
exports.isEvent = isEvent;
|
|
7
|
-
exports.isConnectionInit = isConnectionInit;
|
|
8
|
-
exports.isRequestSettings = isRequestSettings;
|
|
9
|
-
exports.isStartApp = isStartApp;
|
|
10
|
-
exports.isStopApp = isStopApp;
|
|
11
|
-
exports.isButtonPress = isButtonPress;
|
|
12
|
-
exports.isHeadPosition = isHeadPosition;
|
|
13
|
-
exports.isGlassesBatteryUpdate = isGlassesBatteryUpdate;
|
|
14
|
-
exports.isPhoneBatteryUpdate = isPhoneBatteryUpdate;
|
|
15
|
-
exports.isGlassesConnectionState = isGlassesConnectionState;
|
|
16
|
-
exports.isLocationUpdate = isLocationUpdate;
|
|
17
|
-
exports.isCalendarEvent = isCalendarEvent;
|
|
18
|
-
exports.isVad = isVad;
|
|
19
|
-
exports.isPhoneNotification = isPhoneNotification;
|
|
20
|
-
exports.isPhoneNotificationDismissed = isPhoneNotificationDismissed;
|
|
21
|
-
exports.isRtmpStreamStatus = isRtmpStreamStatus;
|
|
22
|
-
exports.isPhotoResponse = isPhotoResponse;
|
|
23
|
-
exports.isKeepAliveAck = isKeepAliveAck;
|
|
24
|
-
exports.isPhotoTaken = isPhotoTaken;
|
|
25
|
-
exports.isAudioPlayResponse = isAudioPlayResponse;
|
|
26
|
-
exports.isLocalTranscription = isLocalTranscription;
|
|
27
|
-
const message_types_1 = require("../message-types");
|
|
28
|
-
// ===========================================================
|
|
29
|
-
// Mentra Live
|
|
30
|
-
// ===========================================================
|
|
31
|
-
/**
|
|
32
|
-
* Photo error codes for detailed error reporting
|
|
33
|
-
*/
|
|
34
|
-
var PhotoErrorCode;
|
|
35
|
-
(function (PhotoErrorCode) {
|
|
36
|
-
PhotoErrorCode["CAMERA_INIT_FAILED"] = "CAMERA_INIT_FAILED";
|
|
37
|
-
PhotoErrorCode["CAMERA_CAPTURE_FAILED"] = "CAMERA_CAPTURE_FAILED";
|
|
38
|
-
PhotoErrorCode["CAMERA_TIMEOUT"] = "CAMERA_TIMEOUT";
|
|
39
|
-
PhotoErrorCode["CAMERA_BUSY"] = "CAMERA_BUSY";
|
|
40
|
-
PhotoErrorCode["UPLOAD_FAILED"] = "UPLOAD_FAILED";
|
|
41
|
-
PhotoErrorCode["UPLOAD_TIMEOUT"] = "UPLOAD_TIMEOUT";
|
|
42
|
-
PhotoErrorCode["BLE_TRANSFER_FAILED"] = "BLE_TRANSFER_FAILED";
|
|
43
|
-
PhotoErrorCode["BLE_TRANSFER_BUSY"] = "BLE_TRANSFER_BUSY";
|
|
44
|
-
PhotoErrorCode["BLE_TRANSFER_FAILED_TO_START"] = "BLE_TRANSFER_FAILED_TO_START";
|
|
45
|
-
PhotoErrorCode["BLE_TRANSFER_TIMEOUT"] = "BLE_TRANSFER_TIMEOUT";
|
|
46
|
-
PhotoErrorCode["COMPRESSION_FAILED"] = "COMPRESSION_FAILED";
|
|
47
|
-
PhotoErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
|
|
48
|
-
PhotoErrorCode["STORAGE_FULL"] = "STORAGE_FULL";
|
|
49
|
-
PhotoErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
50
|
-
// Phone-side error codes
|
|
51
|
-
PhotoErrorCode["PHONE_GLASSES_NOT_CONNECTED"] = "PHONE_GLASSES_NOT_CONNECTED";
|
|
52
|
-
PhotoErrorCode["PHONE_BLE_TRANSFER_FAILED"] = "PHONE_BLE_TRANSFER_FAILED";
|
|
53
|
-
PhotoErrorCode["PHONE_UPLOAD_FAILED"] = "PHONE_UPLOAD_FAILED";
|
|
54
|
-
PhotoErrorCode["PHONE_TIMEOUT"] = "PHONE_TIMEOUT";
|
|
55
|
-
PhotoErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
56
|
-
})(PhotoErrorCode || (exports.PhotoErrorCode = PhotoErrorCode = {}));
|
|
57
|
-
/**
|
|
58
|
-
* Photo processing stages for error context
|
|
59
|
-
*/
|
|
60
|
-
var PhotoStage;
|
|
61
|
-
(function (PhotoStage) {
|
|
62
|
-
PhotoStage["REQUEST_RECEIVED"] = "REQUEST_RECEIVED";
|
|
63
|
-
PhotoStage["CAMERA_INIT"] = "CAMERA_INIT";
|
|
64
|
-
PhotoStage["PHOTO_CAPTURE"] = "PHOTO_CAPTURE";
|
|
65
|
-
PhotoStage["COMPRESSION"] = "COMPRESSION";
|
|
66
|
-
PhotoStage["UPLOAD_START"] = "UPLOAD_START";
|
|
67
|
-
PhotoStage["UPLOAD_PROGRESS"] = "UPLOAD_PROGRESS";
|
|
68
|
-
PhotoStage["BLE_TRANSFER"] = "BLE_TRANSFER";
|
|
69
|
-
PhotoStage["RESPONSE_SENT"] = "RESPONSE_SENT";
|
|
70
|
-
})(PhotoStage || (exports.PhotoStage = PhotoStage = {}));
|
|
71
|
-
//===========================================================
|
|
72
|
-
// Type guards
|
|
73
|
-
//===========================================================
|
|
74
|
-
function isControlAction(message) {
|
|
75
|
-
return message_types_1.ControlActionTypes.includes(message.type);
|
|
76
|
-
}
|
|
77
|
-
function isEvent(message) {
|
|
78
|
-
return message_types_1.EventTypes.includes(message.type);
|
|
79
|
-
}
|
|
80
|
-
// Individual type guards
|
|
81
|
-
function isConnectionInit(message) {
|
|
82
|
-
return message.type === message_types_1.GlassesToCloudMessageType.CONNECTION_INIT;
|
|
83
|
-
}
|
|
84
|
-
function isRequestSettings(message) {
|
|
85
|
-
return message.type === message_types_1.GlassesToCloudMessageType.REQUEST_SETTINGS;
|
|
86
|
-
}
|
|
87
|
-
function isStartApp(message) {
|
|
88
|
-
return message.type === message_types_1.GlassesToCloudMessageType.START_APP;
|
|
89
|
-
}
|
|
90
|
-
function isStopApp(message) {
|
|
91
|
-
return message.type === message_types_1.GlassesToCloudMessageType.STOP_APP;
|
|
92
|
-
}
|
|
93
|
-
function isButtonPress(message) {
|
|
94
|
-
return message.type === message_types_1.GlassesToCloudMessageType.BUTTON_PRESS;
|
|
95
|
-
}
|
|
96
|
-
function isHeadPosition(message) {
|
|
97
|
-
return message.type === message_types_1.GlassesToCloudMessageType.HEAD_POSITION;
|
|
98
|
-
}
|
|
99
|
-
function isGlassesBatteryUpdate(message) {
|
|
100
|
-
return message.type === message_types_1.GlassesToCloudMessageType.GLASSES_BATTERY_UPDATE;
|
|
101
|
-
}
|
|
102
|
-
function isPhoneBatteryUpdate(message) {
|
|
103
|
-
return message.type === message_types_1.GlassesToCloudMessageType.PHONE_BATTERY_UPDATE;
|
|
104
|
-
}
|
|
105
|
-
function isGlassesConnectionState(message) {
|
|
106
|
-
return message.type === message_types_1.GlassesToCloudMessageType.GLASSES_CONNECTION_STATE;
|
|
107
|
-
}
|
|
108
|
-
function isLocationUpdate(message) {
|
|
109
|
-
return message.type === message_types_1.GlassesToCloudMessageType.LOCATION_UPDATE;
|
|
110
|
-
}
|
|
111
|
-
function isCalendarEvent(message) {
|
|
112
|
-
return message.type === message_types_1.GlassesToCloudMessageType.CALENDAR_EVENT;
|
|
113
|
-
}
|
|
114
|
-
function isVad(message) {
|
|
115
|
-
return message.type === message_types_1.GlassesToCloudMessageType.VAD;
|
|
116
|
-
}
|
|
117
|
-
function isPhoneNotification(message) {
|
|
118
|
-
return message.type === message_types_1.GlassesToCloudMessageType.PHONE_NOTIFICATION;
|
|
119
|
-
}
|
|
120
|
-
function isPhoneNotificationDismissed(message) {
|
|
121
|
-
return (message.type === message_types_1.GlassesToCloudMessageType.PHONE_NOTIFICATION_DISMISSED);
|
|
122
|
-
}
|
|
123
|
-
function isRtmpStreamStatus(message) {
|
|
124
|
-
return message.type === message_types_1.GlassesToCloudMessageType.RTMP_STREAM_STATUS;
|
|
125
|
-
}
|
|
126
|
-
function isPhotoResponse(message) {
|
|
127
|
-
return message.type === message_types_1.GlassesToCloudMessageType.PHOTO_RESPONSE;
|
|
128
|
-
}
|
|
129
|
-
function isKeepAliveAck(message) {
|
|
130
|
-
return message.type === message_types_1.GlassesToCloudMessageType.KEEP_ALIVE_ACK;
|
|
131
|
-
}
|
|
132
|
-
function isPhotoTaken(message) {
|
|
133
|
-
return message.type === message_types_1.GlassesToCloudMessageType.PHOTO_TAKEN;
|
|
134
|
-
}
|
|
135
|
-
function isAudioPlayResponse(message) {
|
|
136
|
-
return message.type === message_types_1.GlassesToCloudMessageType.AUDIO_PLAY_RESPONSE;
|
|
137
|
-
}
|
|
138
|
-
function isLocalTranscription(message) {
|
|
139
|
-
return message.type === message_types_1.GlassesToCloudMessageType.LOCAL_TRANSCRIPTION;
|
|
140
|
-
}
|
package/dist/types/models.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// @mentra/sdk
|
|
3
|
-
// packages/sdk/types/src/models.ts - Core models
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.LEGACY_PERMISSION_MAP = exports.PermissionType = void 0;
|
|
6
|
-
exports.validateAppConfig = validateAppConfig;
|
|
7
|
-
const enums_1 = require("./enums");
|
|
8
|
-
// Define PermissionType enum with legacy support
|
|
9
|
-
var PermissionType;
|
|
10
|
-
(function (PermissionType) {
|
|
11
|
-
PermissionType["MICROPHONE"] = "MICROPHONE";
|
|
12
|
-
PermissionType["LOCATION"] = "LOCATION";
|
|
13
|
-
PermissionType["BACKGROUND_LOCATION"] = "BACKGROUND_LOCATION";
|
|
14
|
-
PermissionType["CALENDAR"] = "CALENDAR";
|
|
15
|
-
PermissionType["CAMERA"] = "CAMERA";
|
|
16
|
-
// Legacy notification permission (backward compatibility)
|
|
17
|
-
PermissionType["NOTIFICATIONS"] = "NOTIFICATIONS";
|
|
18
|
-
// New granular notification permissions
|
|
19
|
-
PermissionType["READ_NOTIFICATIONS"] = "READ_NOTIFICATIONS";
|
|
20
|
-
PermissionType["POST_NOTIFICATIONS"] = "POST_NOTIFICATIONS";
|
|
21
|
-
PermissionType["ALL"] = "ALL";
|
|
22
|
-
})(PermissionType || (exports.PermissionType = PermissionType = {}));
|
|
23
|
-
// Legacy permission mapping for backward compatibility
|
|
24
|
-
exports.LEGACY_PERMISSION_MAP = new Map([
|
|
25
|
-
[PermissionType.NOTIFICATIONS, [PermissionType.READ_NOTIFICATIONS]],
|
|
26
|
-
]);
|
|
27
|
-
/**
|
|
28
|
-
* Validate a App configuration object
|
|
29
|
-
* @param config Object to validate
|
|
30
|
-
* @returns True if the config is valid
|
|
31
|
-
*/
|
|
32
|
-
function validateAppConfig(config) {
|
|
33
|
-
if (!config || typeof config !== "object")
|
|
34
|
-
return false;
|
|
35
|
-
// Check required string properties
|
|
36
|
-
if (typeof config.name !== "string" ||
|
|
37
|
-
typeof config.description !== "string" ||
|
|
38
|
-
typeof config.version !== "string") {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
// Check settings array
|
|
42
|
-
if (!Array.isArray(config.settings))
|
|
43
|
-
return false;
|
|
44
|
-
// Validate each setting
|
|
45
|
-
return config.settings.every((setting) => {
|
|
46
|
-
// Group settings just need a title
|
|
47
|
-
if (setting.type === "group") {
|
|
48
|
-
return typeof setting.title === "string";
|
|
49
|
-
}
|
|
50
|
-
// TITLE_VALUE settings just need label and value
|
|
51
|
-
if (setting.type === "titleValue") {
|
|
52
|
-
return typeof setting.label === "string" && "value" in setting;
|
|
53
|
-
}
|
|
54
|
-
// Regular settings need key and label
|
|
55
|
-
if (typeof setting.key !== "string" || typeof setting.label !== "string") {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
// Type-specific validation
|
|
59
|
-
switch (setting.type) {
|
|
60
|
-
case enums_1.AppSettingType.TOGGLE:
|
|
61
|
-
return typeof setting.defaultValue === "boolean";
|
|
62
|
-
case enums_1.AppSettingType.TEXT:
|
|
63
|
-
case enums_1.AppSettingType.TEXT_NO_SAVE_BUTTON:
|
|
64
|
-
return (setting.defaultValue === undefined ||
|
|
65
|
-
typeof setting.defaultValue === "string");
|
|
66
|
-
case enums_1.AppSettingType.SELECT:
|
|
67
|
-
case enums_1.AppSettingType.SELECT_WITH_SEARCH:
|
|
68
|
-
return (Array.isArray(setting.options) &&
|
|
69
|
-
setting.options.every((opt) => typeof opt.label === "string" && "value" in opt));
|
|
70
|
-
case enums_1.AppSettingType.MULTISELECT:
|
|
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)));
|
|
75
|
-
case enums_1.AppSettingType.SLIDER:
|
|
76
|
-
return (typeof setting.defaultValue === "number" &&
|
|
77
|
-
typeof setting.min === "number" &&
|
|
78
|
-
typeof setting.max === "number" &&
|
|
79
|
-
setting.min <= setting.max);
|
|
80
|
-
case enums_1.AppSettingType.NUMERIC_INPUT:
|
|
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"));
|
|
88
|
-
case enums_1.AppSettingType.TIME_PICKER:
|
|
89
|
-
return ((setting.defaultValue === undefined ||
|
|
90
|
-
typeof setting.defaultValue === "number") &&
|
|
91
|
-
(setting.showSeconds === undefined ||
|
|
92
|
-
typeof setting.showSeconds === "boolean"));
|
|
93
|
-
case enums_1.AppSettingType.GROUP:
|
|
94
|
-
return typeof setting.title === "string";
|
|
95
|
-
case enums_1.AppSettingType.TITLE_VALUE:
|
|
96
|
-
return typeof setting.label === "string" && "value" in setting;
|
|
97
|
-
default:
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
package/dist/types/photo-data.js
DELETED
package/dist/types/streams.js
DELETED
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// src/streams.ts
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.STREAM_CATEGORIES = exports.StreamCategory = exports.StreamType = void 0;
|
|
5
|
-
exports.isValidLanguageCode = isValidLanguageCode;
|
|
6
|
-
exports.parseLanguageStream = parseLanguageStream;
|
|
7
|
-
exports.createTranscriptionStream = createTranscriptionStream;
|
|
8
|
-
exports.createTranslationStream = createTranslationStream;
|
|
9
|
-
exports.isValidStreamType = isValidStreamType;
|
|
10
|
-
exports.isStreamCategory = isStreamCategory;
|
|
11
|
-
exports.getStreamTypesByCategory = getStreamTypesByCategory;
|
|
12
|
-
exports.getBaseStreamType = getBaseStreamType;
|
|
13
|
-
exports.isLanguageStream = isLanguageStream;
|
|
14
|
-
exports.getLanguageInfo = getLanguageInfo;
|
|
15
|
-
/**
|
|
16
|
-
* Types of streams that Apps can subscribe to
|
|
17
|
-
*
|
|
18
|
-
* These are events and data that Apps can receive from the cloud.
|
|
19
|
-
* Not all message types can be subscribed to as streams.
|
|
20
|
-
*/
|
|
21
|
-
var StreamType;
|
|
22
|
-
(function (StreamType) {
|
|
23
|
-
// Hardware streams
|
|
24
|
-
StreamType["BUTTON_PRESS"] = "button_press";
|
|
25
|
-
StreamType["HEAD_POSITION"] = "head_position";
|
|
26
|
-
StreamType["GLASSES_BATTERY_UPDATE"] = "glasses_battery_update";
|
|
27
|
-
StreamType["PHONE_BATTERY_UPDATE"] = "phone_battery_update";
|
|
28
|
-
StreamType["GLASSES_CONNECTION_STATE"] = "glasses_connection_state";
|
|
29
|
-
StreamType["LOCATION_UPDATE"] = "location_update";
|
|
30
|
-
StreamType["LOCATION_STREAM"] = "location_stream";
|
|
31
|
-
StreamType["VPS_COORDINATES"] = "vps_coordinates";
|
|
32
|
-
// Audio streams
|
|
33
|
-
StreamType["TRANSCRIPTION"] = "transcription";
|
|
34
|
-
StreamType["TRANSLATION"] = "translation";
|
|
35
|
-
StreamType["VAD"] = "VAD";
|
|
36
|
-
StreamType["AUDIO_CHUNK"] = "audio_chunk";
|
|
37
|
-
// Phone streams
|
|
38
|
-
StreamType["PHONE_NOTIFICATION"] = "phone_notification";
|
|
39
|
-
StreamType["PHONE_NOTIFICATION_DISMISSED"] = "phone_notification_dismissed";
|
|
40
|
-
StreamType["CALENDAR_EVENT"] = "calendar_event";
|
|
41
|
-
// System streams
|
|
42
|
-
StreamType["START_APP"] = "start_app";
|
|
43
|
-
StreamType["STOP_APP"] = "stop_app";
|
|
44
|
-
StreamType["OPEN_DASHBOARD"] = "open_dashboard";
|
|
45
|
-
StreamType["CORE_STATUS_UPDATE"] = "core_status_update";
|
|
46
|
-
// Video streams
|
|
47
|
-
StreamType["VIDEO"] = "video";
|
|
48
|
-
StreamType["PHOTO_REQUEST"] = "photo_request";
|
|
49
|
-
StreamType["PHOTO_RESPONSE"] = "photo_response";
|
|
50
|
-
StreamType["RTMP_STREAM_STATUS"] = "rtmp_stream_status";
|
|
51
|
-
StreamType["MANAGED_STREAM_STATUS"] = "managed_stream_status";
|
|
52
|
-
// Special subscription types
|
|
53
|
-
StreamType["ALL"] = "all";
|
|
54
|
-
StreamType["WILDCARD"] = "*";
|
|
55
|
-
// New stream type
|
|
56
|
-
StreamType["MENTRAOS_SETTINGS_UPDATE_REQUEST"] = "settings_update_request";
|
|
57
|
-
StreamType["CUSTOM_MESSAGE"] = "custom_message";
|
|
58
|
-
StreamType["PHOTO_TAKEN"] = "photo_taken";
|
|
59
|
-
})(StreamType || (exports.StreamType = StreamType = {}));
|
|
60
|
-
/**
|
|
61
|
-
* Categories of stream data
|
|
62
|
-
*/
|
|
63
|
-
var StreamCategory;
|
|
64
|
-
(function (StreamCategory) {
|
|
65
|
-
/** Data from hardware sensors */
|
|
66
|
-
StreamCategory["HARDWARE"] = "hardware";
|
|
67
|
-
/** Audio processing results */
|
|
68
|
-
StreamCategory["AUDIO"] = "audio";
|
|
69
|
-
/** Phone-related events */
|
|
70
|
-
StreamCategory["PHONE"] = "phone";
|
|
71
|
-
/** System-level events */
|
|
72
|
-
StreamCategory["SYSTEM"] = "system";
|
|
73
|
-
})(StreamCategory || (exports.StreamCategory = StreamCategory = {}));
|
|
74
|
-
/**
|
|
75
|
-
* Map of stream categories for each stream type
|
|
76
|
-
*/
|
|
77
|
-
exports.STREAM_CATEGORIES = {
|
|
78
|
-
[StreamType.BUTTON_PRESS]: StreamCategory.HARDWARE,
|
|
79
|
-
[StreamType.HEAD_POSITION]: StreamCategory.HARDWARE,
|
|
80
|
-
[StreamType.GLASSES_BATTERY_UPDATE]: StreamCategory.HARDWARE,
|
|
81
|
-
[StreamType.PHONE_BATTERY_UPDATE]: StreamCategory.HARDWARE,
|
|
82
|
-
[StreamType.GLASSES_CONNECTION_STATE]: StreamCategory.HARDWARE,
|
|
83
|
-
[StreamType.LOCATION_UPDATE]: StreamCategory.HARDWARE,
|
|
84
|
-
[StreamType.LOCATION_STREAM]: StreamCategory.HARDWARE,
|
|
85
|
-
[StreamType.VPS_COORDINATES]: StreamCategory.HARDWARE,
|
|
86
|
-
[StreamType.TRANSCRIPTION]: StreamCategory.AUDIO,
|
|
87
|
-
[StreamType.TRANSLATION]: StreamCategory.AUDIO,
|
|
88
|
-
[StreamType.VAD]: StreamCategory.AUDIO,
|
|
89
|
-
[StreamType.AUDIO_CHUNK]: StreamCategory.AUDIO,
|
|
90
|
-
[StreamType.PHONE_NOTIFICATION]: StreamCategory.PHONE,
|
|
91
|
-
[StreamType.PHONE_NOTIFICATION_DISMISSED]: StreamCategory.PHONE,
|
|
92
|
-
[StreamType.CALENDAR_EVENT]: StreamCategory.PHONE,
|
|
93
|
-
[StreamType.START_APP]: StreamCategory.SYSTEM,
|
|
94
|
-
[StreamType.STOP_APP]: StreamCategory.SYSTEM,
|
|
95
|
-
[StreamType.OPEN_DASHBOARD]: StreamCategory.SYSTEM,
|
|
96
|
-
[StreamType.CORE_STATUS_UPDATE]: StreamCategory.SYSTEM,
|
|
97
|
-
[StreamType.VIDEO]: StreamCategory.HARDWARE,
|
|
98
|
-
[StreamType.PHOTO_REQUEST]: StreamCategory.HARDWARE,
|
|
99
|
-
[StreamType.PHOTO_RESPONSE]: StreamCategory.HARDWARE,
|
|
100
|
-
[StreamType.RTMP_STREAM_STATUS]: StreamCategory.HARDWARE,
|
|
101
|
-
[StreamType.MANAGED_STREAM_STATUS]: StreamCategory.HARDWARE,
|
|
102
|
-
[StreamType.ALL]: StreamCategory.SYSTEM,
|
|
103
|
-
[StreamType.WILDCARD]: StreamCategory.SYSTEM,
|
|
104
|
-
[StreamType.MENTRAOS_SETTINGS_UPDATE_REQUEST]: StreamCategory.SYSTEM,
|
|
105
|
-
[StreamType.CUSTOM_MESSAGE]: StreamCategory.SYSTEM,
|
|
106
|
-
[StreamType.PHOTO_TAKEN]: StreamCategory.HARDWARE,
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Create a language-branded stream type
|
|
110
|
-
* This is a type helper to ensure type safety for language-specific streams
|
|
111
|
-
*/
|
|
112
|
-
function createLanguageStream(type) {
|
|
113
|
-
return type;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Check if a string is a valid language code
|
|
117
|
-
* Simple validation for language code format: xx-XX (e.g., en-US)
|
|
118
|
-
*/
|
|
119
|
-
function isValidLanguageCode(code) {
|
|
120
|
-
return /^[a-z]{2,3}-[A-Z]{2}$/.test(code);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Parse a subscription string to extract language information
|
|
124
|
-
*
|
|
125
|
-
* @param subscription Subscription string (e.g., "transcription:en-US" or "translation:es-ES-to-en-US" or "transcription:en-US?no-language-identification=true")
|
|
126
|
-
* @returns Parsed language stream info or null if not a language-specific subscription
|
|
127
|
-
*/
|
|
128
|
-
function parseLanguageStream(subscription) {
|
|
129
|
-
// console.log(`🎤 Parsing language stream: ${subscription}`);
|
|
130
|
-
if (typeof subscription !== "string") {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
// Handle transcription format (transcription:en-US or transcription:en-US?options)
|
|
134
|
-
if (subscription.startsWith(`${StreamType.TRANSCRIPTION}:`)) {
|
|
135
|
-
const [baseType, rest] = subscription.split(":");
|
|
136
|
-
const [languageCode, queryString] = rest?.split("?") ?? [];
|
|
137
|
-
if (languageCode && isValidLanguageCode(languageCode)) {
|
|
138
|
-
const options = {};
|
|
139
|
-
// Parse query parameters if present
|
|
140
|
-
if (queryString) {
|
|
141
|
-
const params = new URLSearchParams(queryString);
|
|
142
|
-
for (const [key, value] of params.entries()) {
|
|
143
|
-
// Convert string values to boolean when appropriate
|
|
144
|
-
if (value === "true") {
|
|
145
|
-
options[key] = true;
|
|
146
|
-
}
|
|
147
|
-
else if (value === "false") {
|
|
148
|
-
options[key] = false;
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
options[key] = value;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return {
|
|
156
|
-
type: StreamType.TRANSCRIPTION,
|
|
157
|
-
baseType,
|
|
158
|
-
transcribeLanguage: languageCode,
|
|
159
|
-
options: Object.keys(options).length > 0 ? options : undefined,
|
|
160
|
-
original: subscription,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
// Handle translation format (translation:es-ES-to-en-US or translation:es-ES-to-en-US?options)
|
|
165
|
-
if (subscription.startsWith(`${StreamType.TRANSLATION}:`)) {
|
|
166
|
-
const [baseType, rest] = subscription.split(":");
|
|
167
|
-
const [languagePair, queryString] = rest?.split("?") ?? [];
|
|
168
|
-
const [sourceLanguage, targetLanguage] = languagePair?.split("-to-") ?? [];
|
|
169
|
-
if (sourceLanguage &&
|
|
170
|
-
targetLanguage &&
|
|
171
|
-
isValidLanguageCode(sourceLanguage) &&
|
|
172
|
-
isValidLanguageCode(targetLanguage)) {
|
|
173
|
-
const options = {};
|
|
174
|
-
// Parse query parameters if present
|
|
175
|
-
if (queryString) {
|
|
176
|
-
const params = new URLSearchParams(queryString);
|
|
177
|
-
for (const [key, value] of params.entries()) {
|
|
178
|
-
// Convert string values to boolean when appropriate
|
|
179
|
-
if (value === "true") {
|
|
180
|
-
options[key] = true;
|
|
181
|
-
}
|
|
182
|
-
else if (value === "false") {
|
|
183
|
-
options[key] = false;
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
options[key] = value;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
type: StreamType.TRANSLATION,
|
|
192
|
-
baseType,
|
|
193
|
-
transcribeLanguage: sourceLanguage,
|
|
194
|
-
translateLanguage: targetLanguage,
|
|
195
|
-
options: Object.keys(options).length > 0 ? options : undefined,
|
|
196
|
-
original: subscription,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Create a transcription stream identifier for a specific language
|
|
204
|
-
* Returns a type-safe stream type that can be used like a StreamType
|
|
205
|
-
*
|
|
206
|
-
* @param language Language code (e.g., "en-US")
|
|
207
|
-
* @returns Typed stream identifier
|
|
208
|
-
*/
|
|
209
|
-
function createTranscriptionStream(language, options) {
|
|
210
|
-
console.log(`🎤 Creating transcription stream for language: ${language}`);
|
|
211
|
-
console.log(`🎤 Options: ${JSON.stringify(options)}`);
|
|
212
|
-
// Defensively remove any query string from the language parameter
|
|
213
|
-
const languageCode = language.split("?")[0];
|
|
214
|
-
if (!isValidLanguageCode(languageCode)) {
|
|
215
|
-
throw new Error(`Invalid language code: ${languageCode}`);
|
|
216
|
-
}
|
|
217
|
-
const base = `${StreamType.TRANSCRIPTION}:${languageCode}`;
|
|
218
|
-
if (options?.disableLanguageIdentification) {
|
|
219
|
-
return `${base}?no-language-identification=true`;
|
|
220
|
-
}
|
|
221
|
-
return base;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Create a translation stream identifier for a language pair
|
|
225
|
-
* Returns a type-safe stream type that can be used like a StreamType
|
|
226
|
-
*
|
|
227
|
-
* @param sourceLanguage Source language code (e.g., "es-ES")
|
|
228
|
-
* @param targetLanguage Target language code (e.g., "en-US")
|
|
229
|
-
* @param options Optional configuration options
|
|
230
|
-
* @returns Typed stream identifier
|
|
231
|
-
*/
|
|
232
|
-
function createTranslationStream(sourceLanguage, targetLanguage, options) {
|
|
233
|
-
// Defensively remove any query string from the language parameters
|
|
234
|
-
const cleanSourceLanguage = sourceLanguage.split("?")[0];
|
|
235
|
-
const cleanTargetLanguage = targetLanguage.split("?")[0];
|
|
236
|
-
if (!isValidLanguageCode(cleanSourceLanguage) ||
|
|
237
|
-
!isValidLanguageCode(cleanTargetLanguage)) {
|
|
238
|
-
throw new Error(`Invalid language code(s): ${cleanSourceLanguage}, ${cleanTargetLanguage}`);
|
|
239
|
-
}
|
|
240
|
-
const base = `${StreamType.TRANSLATION}:${cleanSourceLanguage}-to-${cleanTargetLanguage}`;
|
|
241
|
-
if (options?.disableLanguageIdentification) {
|
|
242
|
-
return `${base}?no-language-identification=true`;
|
|
243
|
-
}
|
|
244
|
-
return createLanguageStream(base);
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Check if a subscription is a valid stream type
|
|
248
|
-
* This handles both enum-based StreamType values and language-specific stream formats
|
|
249
|
-
*
|
|
250
|
-
* @param subscription Subscription to validate
|
|
251
|
-
* @returns True if valid, false otherwise
|
|
252
|
-
*/
|
|
253
|
-
function isValidStreamType(subscription) {
|
|
254
|
-
// Check if it's a standard StreamType
|
|
255
|
-
if (Object.values(StreamType).includes(subscription)) {
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
// Check if it's a valid language-specific stream
|
|
259
|
-
const languageStream = parseLanguageStream(subscription);
|
|
260
|
-
return languageStream !== null;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Helper function to check if a stream type is of a particular category
|
|
264
|
-
* Works with both standard and language-specific stream types
|
|
265
|
-
*/
|
|
266
|
-
function isStreamCategory(streamType, category) {
|
|
267
|
-
const baseType = getBaseStreamType(streamType);
|
|
268
|
-
return baseType ? exports.STREAM_CATEGORIES[baseType] === category : false;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Helper function to get all stream types in a category
|
|
272
|
-
*/
|
|
273
|
-
function getStreamTypesByCategory(category) {
|
|
274
|
-
return Object.entries(exports.STREAM_CATEGORIES)
|
|
275
|
-
.filter(([_, cat]) => cat === category)
|
|
276
|
-
.map(([type]) => type);
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Get the base StreamType for a subscription
|
|
280
|
-
* Works with both standard StreamType values and language-specific formats
|
|
281
|
-
*
|
|
282
|
-
* @param subscription Subscription string or StreamType
|
|
283
|
-
* @returns The base StreamType enum value
|
|
284
|
-
*/
|
|
285
|
-
function getBaseStreamType(subscription) {
|
|
286
|
-
// Check if it's already a standard StreamType
|
|
287
|
-
if (Object.values(StreamType).includes(subscription)) {
|
|
288
|
-
return subscription;
|
|
289
|
-
}
|
|
290
|
-
// Check if it's a language-specific stream
|
|
291
|
-
const languageStream = parseLanguageStream(subscription);
|
|
292
|
-
return languageStream?.type ?? null;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Check if a stream is a language-specific stream
|
|
296
|
-
*/
|
|
297
|
-
function isLanguageStream(subscription) {
|
|
298
|
-
return parseLanguageStream(subscription) !== null;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Get language information from a stream type
|
|
302
|
-
* Returns null for regular stream types
|
|
303
|
-
*/
|
|
304
|
-
function getLanguageInfo(subscription) {
|
|
305
|
-
return parseLanguageStream(subscription);
|
|
306
|
-
}
|
package/dist/types/token.js
DELETED
package/dist/types/webhooks.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// src/webhook.ts
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.WebhookRequestType = void 0;
|
|
5
|
-
exports.isSessionWebhookRequest = isSessionWebhookRequest;
|
|
6
|
-
exports.isStopWebhookRequest = isStopWebhookRequest;
|
|
7
|
-
/**
|
|
8
|
-
* Types of webhook requests that can be sent to Apps
|
|
9
|
-
*/
|
|
10
|
-
var WebhookRequestType;
|
|
11
|
-
(function (WebhookRequestType) {
|
|
12
|
-
/** Request to start a App session */
|
|
13
|
-
WebhookRequestType["SESSION_REQUEST"] = "session_request";
|
|
14
|
-
/** Request to stop a App session */
|
|
15
|
-
WebhookRequestType["STOP_REQUEST"] = "stop_request";
|
|
16
|
-
})(WebhookRequestType || (exports.WebhookRequestType = WebhookRequestType = {}));
|
|
17
|
-
/**
|
|
18
|
-
* Type guard to check if a webhook request is a session request
|
|
19
|
-
*/
|
|
20
|
-
function isSessionWebhookRequest(request) {
|
|
21
|
-
return request.type === WebhookRequestType.SESSION_REQUEST;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Type guard to check if a webhook request is a stop request
|
|
25
|
-
*/
|
|
26
|
-
function isStopWebhookRequest(request) {
|
|
27
|
-
return request.type === WebhookRequestType.STOP_REQUEST;
|
|
28
|
-
}
|