@todesktop/shared 7.191.0 → 7.192.0

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/{base.d.ts → cjs/base.d.ts} +1 -0
  3. package/lib/cjs/base.js +22 -0
  4. package/lib/{desktopify.d.ts → cjs/desktopify.d.ts} +26 -0
  5. package/lib/cjs/desktopify.js +79 -0
  6. package/lib/cjs/desktopify2.js +80 -0
  7. package/lib/cjs/getSiteInfo.js +2 -0
  8. package/lib/cjs/hsm.js +42 -0
  9. package/lib/cjs/index.d.ts +12 -0
  10. package/lib/cjs/index.js +33 -0
  11. package/lib/cjs/introspection/__tests__/breakpoints.test.js +59 -0
  12. package/lib/cjs/introspection/breakpoints.d.ts +45 -0
  13. package/lib/cjs/introspection/breakpoints.js +48 -0
  14. package/lib/cjs/invitePermissionLabels.js +29 -0
  15. package/lib/cjs/personalAccessTokens.js +2 -0
  16. package/lib/cjs/plans.js +632 -0
  17. package/lib/cjs/plugin.js +2 -0
  18. package/lib/cjs/toDesktop.js +2 -0
  19. package/lib/cjs/translation.js +14 -0
  20. package/lib/cjs/validations.js +178 -0
  21. package/lib/esm/base.d.ts +326 -0
  22. package/lib/esm/desktopify.d.ts +365 -0
  23. package/lib/esm/desktopify2.d.ts +506 -0
  24. package/lib/esm/getSiteInfo.d.ts +24 -0
  25. package/lib/esm/hsm.d.ts +30 -0
  26. package/lib/{index.d.ts → esm/index.d.ts} +2 -1
  27. package/lib/{index.js → esm/index.js} +3 -1
  28. package/lib/esm/introspection/__tests__/breakpoints.test.js +57 -0
  29. package/lib/esm/introspection/breakpoints.d.ts +45 -0
  30. package/lib/esm/introspection/breakpoints.js +42 -0
  31. package/lib/esm/invitePermissionLabels.d.ts +13 -0
  32. package/lib/esm/personalAccessTokens.d.ts +24 -0
  33. package/lib/esm/plans.d.ts +130 -0
  34. package/lib/esm/plugin.d.ts +55 -0
  35. package/lib/esm/plugin.js +1 -0
  36. package/lib/esm/toDesktop.d.ts +191 -0
  37. package/lib/esm/toDesktop.js +1 -0
  38. package/lib/esm/translation.d.ts +2 -0
  39. package/lib/esm/validations.d.ts +102 -0
  40. package/package.json +23 -6
  41. package/src/base.ts +1 -0
  42. package/src/desktopify.ts +46 -4
  43. package/src/index.cjs.ts +19 -0
  44. package/src/index.ts +3 -1
  45. package/src/introspection/__tests__/breakpoints.test.ts +92 -0
  46. package/src/introspection/breakpoints.ts +137 -0
  47. package/tsconfig.esm.json +15 -0
  48. package/tsconfig.json +3 -4
  49. /package/lib/{desktopify2.d.ts → cjs/desktopify2.d.ts} +0 -0
  50. /package/lib/{getSiteInfo.d.ts → cjs/getSiteInfo.d.ts} +0 -0
  51. /package/lib/{hsm.d.ts → cjs/hsm.d.ts} +0 -0
  52. /package/lib/{getSiteInfo.js → cjs/introspection/__tests__/breakpoints.test.d.ts} +0 -0
  53. /package/lib/{invitePermissionLabels.d.ts → cjs/invitePermissionLabels.d.ts} +0 -0
  54. /package/lib/{personalAccessTokens.d.ts → cjs/personalAccessTokens.d.ts} +0 -0
  55. /package/lib/{plans.d.ts → cjs/plans.d.ts} +0 -0
  56. /package/lib/{plugin.d.ts → cjs/plugin.d.ts} +0 -0
  57. /package/lib/{toDesktop.d.ts → cjs/toDesktop.d.ts} +0 -0
  58. /package/lib/{translation.d.ts → cjs/translation.d.ts} +0 -0
  59. /package/lib/{validations.d.ts → cjs/validations.d.ts} +0 -0
  60. /package/lib/{base.js → esm/base.js} +0 -0
  61. /package/lib/{desktopify.js → esm/desktopify.js} +0 -0
  62. /package/lib/{desktopify2.js → esm/desktopify2.js} +0 -0
  63. /package/lib/{personalAccessTokens.js → esm/getSiteInfo.js} +0 -0
  64. /package/lib/{hsm.js → esm/hsm.js} +0 -0
  65. /package/lib/{plugin.js → esm/introspection/__tests__/breakpoints.test.d.ts} +0 -0
  66. /package/lib/{invitePermissionLabels.js → esm/invitePermissionLabels.js} +0 -0
  67. /package/lib/{toDesktop.js → esm/personalAccessTokens.js} +0 -0
  68. /package/lib/{plans.js → esm/plans.js} +0 -0
  69. /package/lib/{translation.js → esm/translation.js} +0 -0
  70. /package/lib/{validations.js → esm/validations.js} +0 -0
package/src/desktopify.ts CHANGED
@@ -3,12 +3,13 @@ import {
3
3
  Configuration,
4
4
  PackagerOptions,
5
5
  PublishOptions,
6
- // app-builder-lib shouldn't be installed as a dependency for dependent
7
- // packages since it's too large
8
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
9
- // @ts-ignore
10
6
  } from 'app-builder-lib';
11
7
  import { IApp2 } from './desktopify2';
8
+ import {
9
+ BreakpointPauseLease,
10
+ BreakpointQueueEntry,
11
+ CurrentBreakpointState,
12
+ } from './introspection/breakpoints';
12
13
  import { IApp } from './toDesktop';
13
14
 
14
15
  type appBuilderLib = PackagerOptions & PublishOptions;
@@ -130,6 +131,46 @@ export interface PlatformBuild {
130
131
 
131
132
  export type CIRunner = 'azure' | 'circle';
132
133
 
134
+ export type IntrospectBreakpointStatus =
135
+ | 'error'
136
+ | 'finished'
137
+ | 'initializing'
138
+ | 'paused'
139
+ | 'ready'
140
+ | 'resuming';
141
+
142
+ export type IntrospectShellStatus =
143
+ | 'connected'
144
+ | 'connecting'
145
+ | 'disconnected'
146
+ | 'error'
147
+ | 'initializing'
148
+ | 'ready';
149
+
150
+ export interface IntrospectPlatformData {
151
+ breakpointQueue?: BreakpointQueueEntry[];
152
+ breakpointStatus: IntrospectBreakpointStatus;
153
+ connectedAt?: Date;
154
+ connectedUserId?: string;
155
+ createdAt: ISODate;
156
+ currentBreakpoint?: CurrentBreakpointState;
157
+ disconnectedAt?: Date;
158
+ enabled: boolean;
159
+ error?: string;
160
+ jtiExpiresAt?: Date;
161
+ pauseLease?: BreakpointPauseLease;
162
+ sessionJti?: string;
163
+ shellStatus: IntrospectShellStatus;
164
+ tunnelUrl?: string;
165
+ usedJti?: string;
166
+ }
167
+
168
+ export interface IntrospectData {
169
+ linux: IntrospectPlatformData;
170
+ mac: IntrospectPlatformData;
171
+ windows: IntrospectPlatformData;
172
+ }
173
+
133
174
  export interface Build {
134
175
  appCustomDomain?: string;
135
176
  appName: string;
@@ -161,6 +202,7 @@ export interface Build {
161
202
  hash?: string;
162
203
  icon?: string;
163
204
  id: string;
205
+ introspect?: IntrospectData;
164
206
  isArtifactsPruned?: boolean;
165
207
  isBeingCancelled?: boolean;
166
208
  linux?: PlatformBuild;
@@ -0,0 +1,19 @@
1
+ /* eslint-disable @typescript-eslint/no-require-imports */
2
+ // CJS-specific entry point
3
+ // Path is relative to lib/cjs/ output directory
4
+ const packageJson = require('../../package.json');
5
+
6
+ export * from './base';
7
+ export * from './desktopify';
8
+ export * from './desktopify2';
9
+ export * from './getSiteInfo';
10
+ export * from './hsm';
11
+ export * from './invitePermissionLabels';
12
+ export * from './personalAccessTokens';
13
+ export * from './plans';
14
+ export * from './plugin';
15
+ export * from './toDesktop';
16
+
17
+ export * from './validations';
18
+
19
+ export const schemaVersion = packageJson.version;
package/src/index.ts CHANGED
@@ -1,10 +1,12 @@
1
- import packageJson from '../package.json' with { type: 'json' };
1
+ // Path is relative to lib/esm/ output directory
2
+ import packageJson from '../../package.json' with { type: 'json' };
2
3
 
3
4
  export * from './base.js';
4
5
  export * from './desktopify.js';
5
6
  export * from './desktopify2.js';
6
7
  export * from './getSiteInfo.js';
7
8
  export * from './hsm.js';
9
+ export * from './introspection/breakpoints.js';
8
10
  export * from './invitePermissionLabels.js';
9
11
  export * from './personalAccessTokens.js';
10
12
  export * from './plans.js';
@@ -0,0 +1,92 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import {
3
+ cloneBreakpointQueue,
4
+ isSameBreakpoint,
5
+ markQueueSkipped,
6
+ } from '../breakpoints';
7
+ import type { BreakpointQueueEntry } from '../breakpoints';
8
+
9
+ describe('isSameBreakpoint', () => {
10
+ it('matches identical phase breakpoints', () => {
11
+ expect(
12
+ isSameBreakpoint(
13
+ { id: 'beforeInstall', type: 'phase' },
14
+ { id: 'beforeInstall', type: 'phase' },
15
+ ),
16
+ ).toBe(true);
17
+ });
18
+
19
+ it('fails when breakpoint types differ', () => {
20
+ expect(
21
+ isSameBreakpoint(
22
+ { id: 'beforeInstall', type: 'phase' },
23
+ { id: 'todesktop:beforeInstall', position: 'before', type: 'hook' },
24
+ ),
25
+ ).toBe(false);
26
+ });
27
+
28
+ it('considers hook positions', () => {
29
+ expect(
30
+ isSameBreakpoint(
31
+ { id: 'todesktop:beforeBuild', position: 'before', type: 'hook' },
32
+ { id: 'todesktop:beforeBuild', position: 'after', type: 'hook' },
33
+ ),
34
+ ).toBe(false);
35
+ });
36
+
37
+ it('returns false when either side is undefined', () => {
38
+ expect(
39
+ isSameBreakpoint(undefined, { id: 'afterInstall', type: 'phase' }),
40
+ ).toBe(false);
41
+ });
42
+ });
43
+
44
+ describe('cloneBreakpointQueue', () => {
45
+ it('produces a deep copy of the queue', () => {
46
+ const original: ReadonlyArray<BreakpointQueueEntry> = [
47
+ { hitAt: undefined, id: 'beforeInstall', type: 'phase' },
48
+ {
49
+ id: 'todesktop:afterPack',
50
+ position: 'after',
51
+ skipped: true,
52
+ type: 'hook',
53
+ },
54
+ ];
55
+
56
+ const copy = cloneBreakpointQueue(original);
57
+
58
+ expect(copy).toEqual(original);
59
+ expect(copy).not.toBe(original);
60
+ expect(copy[0]).not.toBe(original[0]);
61
+ });
62
+ });
63
+
64
+ describe('markQueueSkipped', () => {
65
+ it('marks the starting entry as skipped and adds fallback timestamps', () => {
66
+ const queue: ReadonlyArray<BreakpointQueueEntry> = [
67
+ { id: 'beforeInstall', type: 'phase' },
68
+ { id: 'afterInstall', type: 'phase' },
69
+ ];
70
+ const fallbackHitAt = '2024-01-01T00:00:00.000Z';
71
+
72
+ const updated = markQueueSkipped(queue, 0, { fallbackHitAt });
73
+
74
+ expect(updated[0]).toMatchObject({
75
+ hitAt: fallbackHitAt,
76
+ skipped: true,
77
+ });
78
+ expect(updated[1]).toMatchObject({ skipped: true });
79
+ expect(queue[0].skipped).toBeUndefined();
80
+ });
81
+
82
+ it('returns a cloned queue when index is out of bounds', () => {
83
+ const queue: ReadonlyArray<BreakpointQueueEntry> = [
84
+ { id: 'beforeInstall', type: 'phase' },
85
+ ];
86
+
87
+ const updated = markQueueSkipped(queue, 2);
88
+
89
+ expect(updated).toEqual(queue);
90
+ expect(updated).not.toBe(queue);
91
+ });
92
+ });
@@ -0,0 +1,137 @@
1
+ const MINUTE = 60 * 1000;
2
+ export const BREAKPOINT_DEFAULT_LEASE_MS = 20 * MINUTE; // 20 minutes
3
+ export const BREAKPOINT_RENEW_INCREMENT_MS = 10 * MINUTE; // 10 minutes
4
+ export const BREAKPOINT_MAX_REMAINING_MS = 20 * MINUTE; // 20 minutes
5
+
6
+ export type PhaseBreakpointId =
7
+ | 'afterInstall'
8
+ | 'afterPack'
9
+ | 'afterSourcePrep'
10
+ | 'afterUpload'
11
+ | 'beforeFinalize'
12
+ | 'beforeInstall'
13
+ | 'beforePack'
14
+ | 'beforeUpload';
15
+
16
+ export type HookBreakpointName =
17
+ | 'todesktop:afterPack'
18
+ | 'todesktop:beforeBuild'
19
+ | 'todesktop:beforeInstall';
20
+
21
+ export type HookBreakpointPosition = 'after' | 'before';
22
+
23
+ interface PhaseBreakpointConfig {
24
+ id: PhaseBreakpointId;
25
+ type: 'phase';
26
+ }
27
+
28
+ interface HookBreakpointConfig {
29
+ id: HookBreakpointName;
30
+ position: HookBreakpointPosition;
31
+ type: 'hook';
32
+ }
33
+
34
+ export type BreakpointConfig = HookBreakpointConfig | PhaseBreakpointConfig;
35
+
36
+ export type BreakpointQueueEntry = {
37
+ autoResumed?: boolean;
38
+ hitAt?: string;
39
+ skipped?: boolean;
40
+ } & BreakpointConfig;
41
+
42
+ export interface BreakpointRenewal {
43
+ renewedAt: string;
44
+ renewedByUserId: string;
45
+ }
46
+
47
+ export type CurrentBreakpointState = {
48
+ createdAt: string;
49
+ expiresAt: string;
50
+ renewals?: BreakpointRenewal[];
51
+ resumedAt?: string;
52
+ resumedByUserId?: string;
53
+ skipped?: boolean;
54
+ wasAutoResumed?: boolean;
55
+ } & BreakpointConfig;
56
+
57
+ export interface BreakpointPauseLease {
58
+ createdAt: string;
59
+ createdByUserId: string;
60
+ defaultDurationMs: number;
61
+ }
62
+
63
+ export function isSameBreakpoint(
64
+ a:
65
+ | BreakpointConfig
66
+ | BreakpointQueueEntry
67
+ | CurrentBreakpointState
68
+ | undefined,
69
+ b:
70
+ | BreakpointConfig
71
+ | BreakpointQueueEntry
72
+ | CurrentBreakpointState
73
+ | undefined,
74
+ ): boolean {
75
+ if (!a || !b) {
76
+ return false;
77
+ }
78
+
79
+ if (a.type !== b.type) {
80
+ return false;
81
+ }
82
+
83
+ if (a.id !== b.id) {
84
+ return false;
85
+ }
86
+
87
+ if (isHookBreakpointConfig(a) && isHookBreakpointConfig(b)) {
88
+ return a.position === b.position;
89
+ }
90
+
91
+ return true;
92
+ }
93
+
94
+ function isHookBreakpointConfig(
95
+ config: BreakpointConfig | BreakpointQueueEntry | CurrentBreakpointState,
96
+ ): config is HookBreakpointConfig {
97
+ return config.type === 'hook';
98
+ }
99
+
100
+ export function cloneBreakpointQueue(
101
+ queue?: null | ReadonlyArray<BreakpointQueueEntry>,
102
+ ): BreakpointQueueEntry[] {
103
+ return Array.isArray(queue) ? queue.map((entry) => ({ ...entry })) : [];
104
+ }
105
+
106
+ export function markQueueSkipped(
107
+ queue: ReadonlyArray<BreakpointQueueEntry>,
108
+ startIndex: number,
109
+ options: { fallbackHitAt?: string } = {},
110
+ ): BreakpointQueueEntry[] {
111
+ const updated = cloneBreakpointQueue(queue);
112
+ const { fallbackHitAt } = options;
113
+
114
+ if (startIndex < 0 || startIndex >= updated.length) {
115
+ return updated;
116
+ }
117
+
118
+ const current = updated[startIndex];
119
+ const hitAt = current.hitAt ?? fallbackHitAt;
120
+
121
+ updated[startIndex] = {
122
+ ...current,
123
+ skipped: true,
124
+ ...(hitAt ? { hitAt } : {}),
125
+ };
126
+
127
+ for (let i = startIndex + 1; i < updated.length; i += 1) {
128
+ if (!updated[i].hitAt) {
129
+ updated[i] = {
130
+ ...updated[i],
131
+ skipped: true,
132
+ };
133
+ }
134
+ }
135
+
136
+ return updated;
137
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "@todesktop/dev-config/tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "target": "es2016",
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "declaration": true,
8
+ "outDir": "./lib/esm",
9
+ "rootDir": "./src",
10
+ "resolveJsonModule": true,
11
+ "strict": true
12
+ },
13
+ "include": ["src/**/*"],
14
+ "exclude": ["node_modules", "lib", "src/index.cjs.ts"]
15
+ }
package/tsconfig.json CHANGED
@@ -2,14 +2,13 @@
2
2
  "extends": "@todesktop/dev-config/tsconfig.base.json",
3
3
  "compilerOptions": {
4
4
  "target": "es2016",
5
- "module": "ESNext",
6
- "moduleResolution": "bundler",
5
+ "module": "commonjs",
7
6
  "declaration": true,
8
- "outDir": "./lib",
7
+ "outDir": "./lib/cjs",
9
8
  "rootDir": "./src",
10
9
  "resolveJsonModule": true,
11
10
  "strict": true
12
11
  },
13
12
  "include": ["src/**/*"],
14
- "exclude": ["node_modules", "lib"]
13
+ "exclude": ["node_modules", "lib", "src/index.ts"]
15
14
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes