desktopr 2.0.0 → 2.0.2

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.
@@ -1,5 +1,5 @@
1
1
  export declare const APP_URL: string;
2
- export declare const APP_VERSION: string;
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;
@@ -3,10 +3,11 @@ 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.APP_VERSION = exports.APP_URL = void 0;
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
+ const package_json_1 = __importDefault(require("../sdk/package.json"));
8
9
  exports.APP_URL = bridge_constants_json_1.default.appUrl;
9
- exports.APP_VERSION = bridge_constants_json_1.default.appVersion;
10
+ exports.API_VERSION = package_json_1.default.version;
10
11
  exports.COMAPNION_WINDOW_LABEL_PREFIX = bridge_constants_json_1.default.companionWindowLabelPrefix;
11
12
  exports.READY_EVENT_NAME = "dtrReady";
12
13
  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,4 @@
1
+ export declare function buildCore(): {
2
+ readonly ready: Promise<true>;
3
+ invoke<T = unknown>(cmd: string, payload?: Record<string, unknown>): Promise<T>;
4
+ };
@@ -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
+ }
@@ -0,0 +1,4 @@
1
+ import { DesktoprInstanceInterface } from "../_types";
2
+ export declare const DesktoprInstance: DesktoprInstanceInterface;
3
+ export declare const dtrInitiators: () => Promise<void>;
4
+ export declare const dtrReadyEventListener: (callback: Function) => void;
@@ -0,0 +1,40 @@
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
+ try {
23
+ const appInfo = await window.Desktopr?.app.info();
24
+ if (appInfo?.version)
25
+ window.__DESKTOPR_APP_VERSION__ = appInfo.version;
26
+ }
27
+ catch (error) {
28
+ console.error(error);
29
+ }
30
+ console.log("## READY ##");
31
+ const eventReady = new CustomEvent(_constants_1.READY_EVENT_NAME);
32
+ window?.dispatchEvent(eventReady);
33
+ }
34
+ catch (error) {
35
+ console.error(error);
36
+ }
37
+ };
38
+ exports.dtrInitiators = dtrInitiators;
39
+ const dtrReadyEventListener = (callback) => window.addEventListener(_constants_1.READY_EVENT_NAME, () => callback());
40
+ exports.dtrReadyEventListener = dtrReadyEventListener;
@@ -29,7 +29,8 @@ export type DtrPlatform = "macos" | "linux" | "windows";
29
29
  */
30
30
  export type DesktoprAPI = {
31
31
  readonly isAvailable: boolean;
32
- readonly version: string;
32
+ readonly apiVersion: string;
33
+ readonly appVersion: string;
33
34
  readonly ready: Promise<true>;
34
35
  invoke<T = unknown>(cmd: string, payload?: Record<string, unknown>): Promise<T>;
35
36
  isDesktop: boolean;
@@ -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: {
@@ -15,13 +14,13 @@ function buildDiagnostics(core) {
15
14
  recordType,
16
15
  payload,
17
16
  env,
18
- appVersion: _constants_1.APP_VERSION,
17
+ get appVersion() { return window.__DESKTOPR_APP_VERSION__; },
19
18
  }),
20
19
  newError: {
21
- js: (payload) => core.invoke("dtr_logs_record_js_error", { payload, appVersion: _constants_1.APP_VERSION }),
22
- native: (payload) => core.invoke("dtr_logs_record_native_error", { payload, appVersion: _constants_1.APP_VERSION }),
20
+ js: (payload) => core.invoke("dtr_logs_record_js_error", { payload, get appVersion() { return window.__DESKTOPR_APP_VERSION__; } }),
21
+ native: (payload) => core.invoke("dtr_logs_record_native_error", { payload, get appVersion() { return window.__DESKTOPR_APP_VERSION__; } }),
23
22
  // Rust richiede 'env' obbligatorio: di default "generic" se non passato
24
- generic: (payload, env = "generic") => core.invoke("dtr_logs_record_error", { payload, appVersion: _constants_1.APP_VERSION, env }),
23
+ generic: (payload, env = "generic") => core.invoke("dtr_logs_record_error", { payload, get appVersion() { return window.__DESKTOPR_APP_VERSION__; }, env }),
25
24
  },
26
25
  readRecordsFile: (relPath, maxBytes) => core.invoke("dtr_logs_read_file", { relPath, maxBytes }),
27
26
  // qui avevi chiamato dtr_logs_read_file: correggo su dtr_logs_list_files
@@ -6,11 +6,6 @@ const _helpers_2 = require("./_helpers");
6
6
  function buildWindow(core) {
7
7
  const randomWindowLabel = `w_${Math.random().toString(36).substring(2, 2 + 8)}`;
8
8
  return {
9
- devTools: {
10
- toggle: (label) => core.invoke("dtr_toggle_devtools", { label: label ?? "main" }),
11
- open: (label) => core.invoke("dtr_open_devtools", { label: label ?? "main" }),
12
- close: (label) => core.invoke("dtr_close_devtools", { label: label ?? "main" }),
13
- },
14
9
  minimize: (label) => core.invoke("dtr_win_minimize", { label: label ?? "main" }),
15
10
  maximizeToggle: (label) => core.invoke("dtr_win_maximize", { label: label ?? "main" }),
16
11
  fullscreen: (enable, label) => core.invoke("dtr_win_fullscreen", { enable, label: label ?? "main" }),
@@ -1,11 +1,6 @@
1
1
  import { CompanionState } from "../../../_companion_context";
2
2
  export type _WindowTypesPlaceholder = unknown;
3
3
  export interface WindowInterface {
4
- devTools: {
5
- toggle: (label?: string) => Promise<void>;
6
- open: (label?: string) => Promise<void>;
7
- close: (label?: string) => Promise<void>;
8
- };
9
4
  new: (options?: NewWindowOptions) => Promise<void>;
10
5
  close: (label: string) => Promise<void>;
11
6
  minimize: () => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "desktopr",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
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",