desktopr 2.0.1 → 2.0.3
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-sdk/_constants.d.ts +1 -1
- package/dist-sdk/_constants.js +2 -2
- package/dist-sdk/_main.d.ts +20 -0
- package/dist-sdk/_main.js +36 -0
- package/dist-sdk/bridge.constants.json +1 -1
- package/dist-sdk/core/_main.d.ts +4 -0
- package/dist-sdk/core/_main.js +15 -0
- package/dist-sdk/desktopr/_helpers.d.ts +1 -0
- package/dist-sdk/desktopr/_helpers.js +12 -3
- package/dist-sdk/desktopr/_main.d.ts +4 -0
- package/dist-sdk/desktopr/_main.js +32 -0
- package/dist-sdk/desktopr/_types.d.ts +1 -1
- package/dist-sdk/modules/rs/diagnostics/_helpers.d.ts +3 -2
- package/dist-sdk/modules/rs/diagnostics/_helpers.js +9 -1
- package/dist-sdk/modules/rs/diagnostics/_main.js +22 -11
- package/dist-sdk/modules/rs/diagnostics/_types.d.ts +25 -17
- package/package.json +4 -3
package/dist-sdk/_constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const APP_URL: string;
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const API_VERSION: string;
|
|
3
3
|
export declare const COMAPNION_WINDOW_LABEL_PREFIX: string;
|
|
4
4
|
export declare const READY_EVENT_NAME: string;
|
|
5
5
|
export declare const WINDOWS_LABELS_TRACKER_VARIABLE_NAME: string;
|
package/dist-sdk/_constants.js
CHANGED
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.BROWSER_STORAGE_NAMESPACE = exports.WINDOWS_LABELS_TRACKER_VARIABLE_NAME = exports.READY_EVENT_NAME = exports.COMAPNION_WINDOW_LABEL_PREFIX = exports.
|
|
6
|
+
exports.BROWSER_STORAGE_NAMESPACE = exports.WINDOWS_LABELS_TRACKER_VARIABLE_NAME = exports.READY_EVENT_NAME = exports.COMAPNION_WINDOW_LABEL_PREFIX = exports.API_VERSION = exports.APP_URL = void 0;
|
|
7
7
|
const bridge_constants_json_1 = __importDefault(require("./bridge.constants.json"));
|
|
8
8
|
exports.APP_URL = bridge_constants_json_1.default.appUrl;
|
|
9
|
-
exports.
|
|
9
|
+
exports.API_VERSION = bridge_constants_json_1.default.apiVersion;
|
|
10
10
|
exports.COMAPNION_WINDOW_LABEL_PREFIX = bridge_constants_json_1.default.companionWindowLabelPrefix;
|
|
11
11
|
exports.READY_EVENT_NAME = "dtrReady";
|
|
12
12
|
exports.WINDOWS_LABELS_TRACKER_VARIABLE_NAME = "open-windows-labels-tracker-rpkw6kjzxn8bfhj5u74q";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from "./core/_main";
|
|
2
|
+
export * from "./desktopr/_main";
|
|
3
|
+
export * from "./modules/rs/files/_main";
|
|
4
|
+
export * from "./modules/rs/events/_main";
|
|
5
|
+
export * from "./modules/rs/fs/_main";
|
|
6
|
+
export * from "./modules/rs/clipboard/_main";
|
|
7
|
+
export * from "./modules/rs/shortcuts/_main";
|
|
8
|
+
export * from "./modules/rs/notifications/_main";
|
|
9
|
+
export * from "./modules/rs/app/_main";
|
|
10
|
+
export * from "./modules/rs/window/_main";
|
|
11
|
+
export * from "./modules/rs/dragdrop/_main";
|
|
12
|
+
export * from "./modules/rs/menu/_main";
|
|
13
|
+
export * from "./modules/rs/diagnostics/_main";
|
|
14
|
+
export * from "./modules/rs/network/_main";
|
|
15
|
+
export * from "./modules/rs/autostart/_main";
|
|
16
|
+
export * from "./modules/rs/badge/_main";
|
|
17
|
+
export * from "./modules/rs/worker/_main";
|
|
18
|
+
export * from "./modules/rs/contextMenu/_main";
|
|
19
|
+
export * from "./modules/rs/companion/_main";
|
|
20
|
+
export * from "./modules/rs/globalVariables/_main";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./core/_main"), exports);
|
|
18
|
+
__exportStar(require("./desktopr/_main"), exports);
|
|
19
|
+
__exportStar(require("./modules/rs/files/_main"), exports);
|
|
20
|
+
__exportStar(require("./modules/rs/events/_main"), exports);
|
|
21
|
+
__exportStar(require("./modules/rs/fs/_main"), exports);
|
|
22
|
+
__exportStar(require("./modules/rs/clipboard/_main"), exports);
|
|
23
|
+
__exportStar(require("./modules/rs/shortcuts/_main"), exports);
|
|
24
|
+
__exportStar(require("./modules/rs/notifications/_main"), exports);
|
|
25
|
+
__exportStar(require("./modules/rs/app/_main"), exports);
|
|
26
|
+
__exportStar(require("./modules/rs/window/_main"), exports);
|
|
27
|
+
__exportStar(require("./modules/rs/dragdrop/_main"), exports);
|
|
28
|
+
__exportStar(require("./modules/rs/menu/_main"), exports);
|
|
29
|
+
__exportStar(require("./modules/rs/diagnostics/_main"), exports);
|
|
30
|
+
__exportStar(require("./modules/rs/network/_main"), exports);
|
|
31
|
+
__exportStar(require("./modules/rs/autostart/_main"), exports);
|
|
32
|
+
__exportStar(require("./modules/rs/badge/_main"), exports);
|
|
33
|
+
__exportStar(require("./modules/rs/worker/_main"), exports);
|
|
34
|
+
__exportStar(require("./modules/rs/contextMenu/_main"), exports);
|
|
35
|
+
__exportStar(require("./modules/rs/companion/_main"), exports);
|
|
36
|
+
__exportStar(require("./modules/rs/globalVariables/_main"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildCore = buildCore;
|
|
4
|
+
const _helpers_1 = require("../_helpers");
|
|
5
|
+
function buildCore() {
|
|
6
|
+
return {
|
|
7
|
+
get ready() {
|
|
8
|
+
return (0, _helpers_1.ensureCore)().then(() => true);
|
|
9
|
+
},
|
|
10
|
+
async invoke(cmd, payload) {
|
|
11
|
+
const core = await (0, _helpers_1.ensureCore)();
|
|
12
|
+
return core.invoke(cmd, payload);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.platformSpecifcFilter = exports.normalizeString = void 0;
|
|
3
|
+
exports.getAppVersion = exports.platformSpecifcFilter = exports.normalizeString = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const normalizeString = (str, options = {
|
|
6
6
|
toLowerCase: true,
|
|
@@ -20,11 +20,20 @@ const normalizeString = (str, options = {
|
|
|
20
20
|
};
|
|
21
21
|
exports.normalizeString = normalizeString;
|
|
22
22
|
const platformSpecifcFilter = async (platforms) => {
|
|
23
|
-
const appInfo = await window.Desktopr?.app.info();
|
|
23
|
+
const appInfo = (await window.Desktopr?.app.info());
|
|
24
24
|
if (!appInfo)
|
|
25
25
|
throw "Failed to check platform";
|
|
26
26
|
const plat = appInfo.os;
|
|
27
|
-
if (!
|
|
27
|
+
if (!platforms.includes(plat))
|
|
28
28
|
throw `[unsupported platform] this method is not supported on ${plat}`;
|
|
29
29
|
};
|
|
30
30
|
exports.platformSpecifcFilter = platformSpecifcFilter;
|
|
31
|
+
const getAppVersion = async () => {
|
|
32
|
+
const desktopr = window?.Desktopr;
|
|
33
|
+
if (!desktopr)
|
|
34
|
+
throw "[getAppVersion] Desktopr is not available";
|
|
35
|
+
const appInfo = await desktopr.app.info();
|
|
36
|
+
const version = appInfo.version;
|
|
37
|
+
return version ?? "";
|
|
38
|
+
};
|
|
39
|
+
exports.getAppVersion = getAppVersion;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dtrReadyEventListener = exports.dtrInitiators = exports.DesktoprInstance = void 0;
|
|
4
|
+
// import { listenForEvent } from "../_helpers";
|
|
5
|
+
const _constants_1 = require("../_constants");
|
|
6
|
+
exports.DesktoprInstance = {
|
|
7
|
+
ready: () => {
|
|
8
|
+
if (!window?.Desktopr)
|
|
9
|
+
return false;
|
|
10
|
+
return true;
|
|
11
|
+
},
|
|
12
|
+
get: () => {
|
|
13
|
+
if (!exports.DesktoprInstance.ready())
|
|
14
|
+
throw ("'window.Desktopr' not found");
|
|
15
|
+
return window?.Desktopr;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const dtrInitiators = async () => {
|
|
19
|
+
try {
|
|
20
|
+
if (!exports.DesktoprInstance.ready())
|
|
21
|
+
throw ("Desktopr instance not found");
|
|
22
|
+
console.log("## READY ##");
|
|
23
|
+
const eventReady = new CustomEvent(_constants_1.READY_EVENT_NAME);
|
|
24
|
+
window?.dispatchEvent(eventReady);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error(error);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.dtrInitiators = dtrInitiators;
|
|
31
|
+
const dtrReadyEventListener = (callback) => window.addEventListener(_constants_1.READY_EVENT_NAME, () => callback());
|
|
32
|
+
exports.dtrReadyEventListener = dtrReadyEventListener;
|
|
@@ -29,7 +29,7 @@ export type DtrPlatform = "macos" | "linux" | "windows";
|
|
|
29
29
|
*/
|
|
30
30
|
export type DesktoprAPI = {
|
|
31
31
|
readonly isAvailable: boolean;
|
|
32
|
-
readonly
|
|
32
|
+
readonly apiVersion: string;
|
|
33
33
|
readonly ready: Promise<true>;
|
|
34
34
|
invoke<T = unknown>(cmd: string, payload?: Record<string, unknown>): Promise<T>;
|
|
35
35
|
isDesktop: boolean;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DesktoprAPI } from "../../../_types";
|
|
2
|
-
import { DiagnosticsTestFunctions, PrivacySettings } from "./_types";
|
|
2
|
+
import { DiagnosticsTestFunctions, PrivacySettings, PrivacySettingsCamelCase } from "./_types";
|
|
3
3
|
export declare const diagnosticsSettings: (core: {
|
|
4
4
|
invoke: DesktoprAPI["invoke"];
|
|
5
|
-
}, settings?: PrivacySettings) => Promise<
|
|
5
|
+
}, settings?: PrivacySettings) => Promise<PrivacySettingsCamelCase>;
|
|
6
|
+
export declare const deriveAppVersion: (v?: string) => Promise<string>;
|
|
6
7
|
export declare function buildDiagnosticsTestFunctions(core: {
|
|
7
8
|
invoke: DesktoprAPI["invoke"];
|
|
8
9
|
}): DiagnosticsTestFunctions;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.diagnosticsSettings = void 0;
|
|
3
|
+
exports.deriveAppVersion = exports.diagnosticsSettings = void 0;
|
|
4
4
|
exports.buildDiagnosticsTestFunctions = buildDiagnosticsTestFunctions;
|
|
5
5
|
const utils_1 = require("../../../utils");
|
|
6
|
+
const _helpers_1 = require("../../../_helpers");
|
|
6
7
|
const diagnosticsSettings = async (core, settings) => {
|
|
7
8
|
if (settings?.retentionDaysAnalytics && !utils_1.Num.isU32(settings.retentionDaysAnalytics))
|
|
8
9
|
throw ("[retentionDaysAnalytics] the value must be a U32 integer number");
|
|
@@ -21,6 +22,13 @@ const diagnosticsSettings = async (core, settings) => {
|
|
|
21
22
|
});
|
|
22
23
|
};
|
|
23
24
|
exports.diagnosticsSettings = diagnosticsSettings;
|
|
25
|
+
const deriveAppVersion = async (v) => {
|
|
26
|
+
if (v)
|
|
27
|
+
return v;
|
|
28
|
+
const version = await (0, _helpers_1.getAppVersion)();
|
|
29
|
+
return version;
|
|
30
|
+
};
|
|
31
|
+
exports.deriveAppVersion = deriveAppVersion;
|
|
24
32
|
// ==============================
|
|
25
33
|
// Test functions
|
|
26
34
|
// ==============================
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildDiagnostics = buildDiagnostics;
|
|
4
4
|
const _helpers_1 = require("./_helpers");
|
|
5
|
-
const _constants_1 = require("../../../_constants");
|
|
6
5
|
function buildDiagnostics(core) {
|
|
7
6
|
return {
|
|
8
7
|
settings: {
|
|
@@ -11,19 +10,31 @@ function buildDiagnostics(core) {
|
|
|
11
10
|
get: () => core.invoke("dtr_logs_get_privacy", {}),
|
|
12
11
|
},
|
|
13
12
|
// SOLO analytics (Rust vuole AnalyticsRecord), usa key record_type
|
|
14
|
-
newRecord: (recordType, payload, env) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
newRecord: async (recordType, payload, env, appVersion) => {
|
|
14
|
+
const v = await (0, _helpers_1.deriveAppVersion)(appVersion);
|
|
15
|
+
return await core.invoke("dtr_logs_new_record", {
|
|
16
|
+
recordType,
|
|
17
|
+
payload,
|
|
18
|
+
env,
|
|
19
|
+
appVersion: v
|
|
20
|
+
});
|
|
21
|
+
},
|
|
20
22
|
newError: {
|
|
21
|
-
js:
|
|
22
|
-
|
|
23
|
+
js: async (payload, appVersion) => {
|
|
24
|
+
const v = await (0, _helpers_1.deriveAppVersion)(appVersion);
|
|
25
|
+
return await core.invoke("dtr_logs_record_js_error", { payload, appVersion: v });
|
|
26
|
+
},
|
|
27
|
+
native: async (payload, appVersion) => {
|
|
28
|
+
const v = await (0, _helpers_1.deriveAppVersion)(appVersion);
|
|
29
|
+
return await core.invoke("dtr_logs_record_native_error", { payload, appVersion: v });
|
|
30
|
+
},
|
|
23
31
|
// Rust richiede 'env' obbligatorio: di default "generic" se non passato
|
|
24
|
-
generic: (payload, env = "generic") =>
|
|
32
|
+
generic: async (payload, env = "generic", appVersion) => {
|
|
33
|
+
const v = await (0, _helpers_1.deriveAppVersion)(appVersion);
|
|
34
|
+
return await core.invoke("dtr_logs_record_error", { payload, env, appVersion: v });
|
|
35
|
+
},
|
|
25
36
|
},
|
|
26
|
-
readRecordsFile: (relPath
|
|
37
|
+
readRecordsFile: (relPath) => core.invoke("dtr_logs_read_file", { relPath }),
|
|
27
38
|
// qui avevi chiamato dtr_logs_read_file: correggo su dtr_logs_list_files
|
|
28
39
|
listRecordsFiles: (area) => core.invoke("dtr_logs_list_files", { area }),
|
|
29
40
|
runRetention: () => core.invoke("dtr_logs_run_retention", {}),
|
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import { U32 } from "../../../utils";
|
|
1
|
+
import { U32, U64 } from "../../../utils";
|
|
2
2
|
export interface DiagnosticsInterface {
|
|
3
3
|
settings: {
|
|
4
|
-
set: (settings?: PrivacySettings) => Promise<
|
|
5
|
-
get: () => Promise<
|
|
4
|
+
set: (settings?: PrivacySettings) => Promise<PrivacySettingsCamelCase>;
|
|
5
|
+
get: () => Promise<PrivacySettingsCamelCase>;
|
|
6
6
|
};
|
|
7
|
-
newRecord: (recordType: string, payload: AnalyticsPayload, env: "js" | "native" | string) => Promise<
|
|
7
|
+
newRecord: (recordType: string, payload: AnalyticsPayload, env: "js" | "native" | string, appVersion?: string) => Promise<void>;
|
|
8
8
|
newError: {
|
|
9
|
-
js: (payload: ErrorPayload) => Promise<
|
|
10
|
-
native: (payload: ErrorPayload) => Promise<
|
|
11
|
-
generic: (payload: ErrorPayload, env?: string) => Promise<
|
|
9
|
+
js: (payload: ErrorPayload, appVersion?: string) => Promise<void>;
|
|
10
|
+
native: (payload: ErrorPayload, appVersion?: string) => Promise<void>;
|
|
11
|
+
generic: (payload: ErrorPayload, env?: string, appVersion?: string) => Promise<void>;
|
|
12
12
|
};
|
|
13
|
-
readRecordsFile: (relPath: string
|
|
14
|
-
listRecordsFiles: (area:
|
|
15
|
-
runRetention: () => Promise<
|
|
16
|
-
export: (targetZipPath: string) => Promise<
|
|
13
|
+
readRecordsFile: (relPath: string) => Promise<string>;
|
|
14
|
+
listRecordsFiles: (area: DiagnosticsArea) => Promise<ListedFile[]>;
|
|
15
|
+
runRetention: () => Promise<void>;
|
|
16
|
+
export: (targetZipPath: string) => Promise<void>;
|
|
17
17
|
test: DiagnosticsTestFunctions;
|
|
18
18
|
}
|
|
19
|
+
export type DiagnosticsArea = "logs" | "crashes" | "runtime";
|
|
19
20
|
export type DiagnosticsTestFunctions = {
|
|
20
21
|
testGenerateRecords: (n?: number) => Promise<void>;
|
|
21
22
|
testThrowJsError: () => Promise<never>;
|
|
22
23
|
testPanicRust: () => Promise<void>;
|
|
23
24
|
testExportZip: (path: string) => Promise<void>;
|
|
24
|
-
testForceRetention: (area:
|
|
25
|
+
testForceRetention: (area: DiagnosticsArea) => Promise<void>;
|
|
25
26
|
};
|
|
26
27
|
export type ErrorPayload = {
|
|
27
28
|
message: string;
|
|
28
29
|
filename?: string;
|
|
29
|
-
lineno?:
|
|
30
|
-
colno?:
|
|
30
|
+
lineno?: U32;
|
|
31
|
+
colno?: U32;
|
|
31
32
|
stack?: string;
|
|
32
33
|
};
|
|
33
34
|
export type AnalyticsPayload = {
|
|
@@ -35,9 +36,9 @@ export type AnalyticsPayload = {
|
|
|
35
36
|
props?: Record<string, unknown>;
|
|
36
37
|
};
|
|
37
38
|
export type ListedFile = {
|
|
38
|
-
|
|
39
|
-
bytes:
|
|
40
|
-
modified_ms:
|
|
39
|
+
rel_path: string;
|
|
40
|
+
bytes: U64;
|
|
41
|
+
modified_ms: U64;
|
|
41
42
|
};
|
|
42
43
|
export type RecordPayload = ErrorPayload | AnalyticsPayload;
|
|
43
44
|
export type PrivacySettings = {
|
|
@@ -47,3 +48,10 @@ export type PrivacySettings = {
|
|
|
47
48
|
retentionDaysLogs?: U32;
|
|
48
49
|
retentionDaysCrashes?: U32;
|
|
49
50
|
};
|
|
51
|
+
export type PrivacySettingsCamelCase = {
|
|
52
|
+
analytics_enabled?: boolean;
|
|
53
|
+
crash_reports_enabled?: boolean;
|
|
54
|
+
retention_days_analytics?: U32;
|
|
55
|
+
retention_days_logs?: U32;
|
|
56
|
+
retention_days_crashes?: U32;
|
|
57
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "desktopr",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Official JS/TS SDK for the Desktopr native bridge",
|
|
5
5
|
"main": "dist-sdk/sdk/index.js",
|
|
6
6
|
"types": "dist-sdk/sdk/index.d.ts",
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
"README.md"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
|
-
"
|
|
14
|
+
"syncVersion": "bash ../scripts/sync-api-version.sh",
|
|
15
|
+
"build": "rm -rf dist-sdk && npm run syncVersion && tsc -p ../tsconfig.sdk.json",
|
|
15
16
|
"pub": "npm publish --access public",
|
|
16
17
|
"prepublishOnly": "npm run build"
|
|
17
18
|
}
|
|
18
|
-
}
|
|
19
|
+
}
|