@heyputer/puter.js 2.1.15 → 2.2.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.
Files changed (40) hide show
  1. package/dist/puter.cjs +2 -2
  2. package/index.d.ts +0 -2
  3. package/package.json +2 -3
  4. package/src/index.js +100 -82
  5. package/src/lib/utils.js +42 -55
  6. package/src/modules/AI.js +8 -204
  7. package/src/modules/Apps.js +42 -11
  8. package/src/modules/Auth.js +6 -5
  9. package/src/modules/Debug.js +4 -4
  10. package/src/modules/Drivers.js +12 -17
  11. package/src/modules/FileSystem/index.js +9 -24
  12. package/src/modules/Hosting.js +5 -4
  13. package/src/modules/KV.js +67 -11
  14. package/src/modules/OS.js +6 -5
  15. package/src/modules/Perms.js +4 -3
  16. package/src/modules/PuterDialog.js +2 -2
  17. package/src/modules/UI.js +44 -28
  18. package/src/modules/UsageLimitDialog.js +208 -0
  19. package/types/modules/ai.d.ts +0 -10
  20. package/types/modules/apps.d.ts +24 -15
  21. package/types/modules/auth.d.ts +3 -1
  22. package/types/modules/filesystem.d.ts +0 -2
  23. package/types/modules/kv.d.ts +10 -0
  24. package/types/modules/networking.d.ts +1 -1
  25. package/types/modules/os.d.ts +2 -7
  26. package/types/modules/ui.d.ts +10 -7
  27. package/types/modules/util.d.ts +0 -1
  28. package/types/modules/workers.d.ts +9 -10
  29. package/types/puter.d.ts +1 -7
  30. package/src/lib/filesystem/APIFS.js +0 -65
  31. package/src/lib/filesystem/CacheFS.js +0 -243
  32. package/src/lib/filesystem/PostMessageFS.js +0 -40
  33. package/src/lib/filesystem/definitions.js +0 -40
  34. package/src/modules/Threads.js +0 -72
  35. package/src/services/APIAccess.js +0 -46
  36. package/src/services/FSRelay.js +0 -20
  37. package/src/services/Filesystem.js +0 -137
  38. package/src/services/NoPuterYet.js +0 -20
  39. package/src/services/XDIncoming.js +0 -44
  40. package/types/modules/threads.d.ts +0 -27
package/src/modules/OS.js CHANGED
@@ -9,10 +9,11 @@ class OS {
9
9
  * @param {string} APIOrigin - Origin of the API server. Used to build the API endpoint URLs.
10
10
  * @param {string} appID - ID of the app to use.
11
11
  */
12
- constructor (context) {
13
- this.authToken = context.authToken;
14
- this.APIOrigin = context.APIOrigin;
15
- this.appID = context.appID;
12
+ constructor (puter) {
13
+ this.puter = puter;
14
+ this.authToken = puter.authToken;
15
+ this.APIOrigin = puter.APIOrigin;
16
+ this.appID = puter.appID;
16
17
  }
17
18
 
18
19
  /**
@@ -92,4 +93,4 @@ class OS {
92
93
  };
93
94
  }
94
95
 
95
- export default OS;
96
+ export default OS;
@@ -1,7 +1,8 @@
1
1
  export default class Perms {
2
- constructor (context) {
3
- this.authToken = context.authToken;
4
- this.APIOrigin = context.APIOrigin;
2
+ constructor (puter) {
3
+ this.puter = puter;
4
+ this.authToken = puter.authToken;
5
+ this.APIOrigin = puter.APIOrigin;
5
6
  }
6
7
  setAuthToken (authToken) {
7
8
  this.authToken = authToken;
@@ -434,7 +434,7 @@ class PuterDialog extends (globalThis.HTMLElement || Object) { // It will fall b
434
434
  // Add event listener to the button
435
435
  this.shadowRoot.querySelector('#launch-auth-popup')?.addEventListener('click', () => {
436
436
  let w = 600;
437
- let h = 400;
437
+ let h = 600;
438
438
  let title = 'Puter';
439
439
  var left = (screen.width / 2) - (w / 2);
440
440
  var top = (screen.height / 2) - (h / 2);
@@ -454,7 +454,7 @@ class PuterDialog extends (globalThis.HTMLElement || Object) { // It will fall b
454
454
  open () {
455
455
  if ( this.hasUserActivation() ) {
456
456
  let w = 600;
457
- let h = 400;
457
+ let h = 600;
458
458
  let title = 'Puter';
459
459
  var left = (screen.width / 2) - (w / 2);
460
460
  var top = (screen.height / 2) - (h / 2);
package/src/modules/UI.js CHANGED
@@ -1,8 +1,17 @@
1
- import putility from '@heyputer/putility';
2
1
  import EventListener from '../lib/EventListener.js';
3
2
  import FSItem from './FSItem.js';
4
3
  import PuterDialog from './PuterDialog.js';
5
4
 
5
+ const createDeferred = () => {
6
+ let resolve;
7
+ let reject;
8
+ const promise = new Promise((res, rej) => {
9
+ resolve = res;
10
+ reject = rej;
11
+ });
12
+ return { promise, resolve, reject };
13
+ };
14
+
6
15
  const FILE_SAVE_CANCELLED = Symbol('FILE_SAVE_CANCELLED');
7
16
  const FILE_OPEN_CANCELLED = Symbol('FILE_OPEN_CANCELLED');
8
17
 
@@ -22,10 +31,12 @@ class AppConnection extends EventListener {
22
31
  // (Closing and close events will still function.)
23
32
  #usesSDK;
24
33
 
25
- static from (values, context) {
26
- const connection = new AppConnection(context, {
34
+ static from (values, puter, { messageTarget, appInstanceID }) {
35
+ const connection = new AppConnection(puter, {
27
36
  target: values.appInstanceID,
28
37
  usesSDK: values.usesSDK,
38
+ messageTarget,
39
+ appInstanceID,
29
40
  });
30
41
 
31
42
  // When a connection is established the app is able to
@@ -35,23 +46,23 @@ class AppConnection extends EventListener {
35
46
  return connection;
36
47
  }
37
48
 
38
- constructor (context, { target, usesSDK }) {
49
+ constructor (puter, { target, usesSDK, messageTarget, appInstanceID }) {
39
50
  super([
40
51
  'message', // The target sent us something with postMessage()
41
52
  'close', // The target app was closed
42
53
  ]);
43
- this.messageTarget = context.messageTarget;
44
- this.appInstanceID = context.appInstanceID;
54
+ this.messageTarget = messageTarget;
55
+ this.appInstanceID = appInstanceID;
45
56
  this.targetAppInstanceID = target;
46
57
  this.#isOpen = true;
47
58
  this.#usesSDK = usesSDK;
48
59
 
49
- this.log = context.puter.logger.fields({
60
+ this.log = puter.logger.fields({
50
61
  category: 'ipc',
51
62
  });
52
63
  this.log.fields({
53
- cons_source: context.appInstanceID,
54
- source: context.puter.appInstanceID,
64
+ cons_source: appInstanceID,
65
+ source: puter.appInstanceID,
55
66
  target,
56
67
  }).info(`AppConnection created to ${target}`, this);
57
68
 
@@ -232,7 +243,7 @@ class UI extends EventListener {
232
243
  return ret;
233
244
  };
234
245
 
235
- constructor (context, { appInstanceID, parentInstanceID }) {
246
+ constructor (puter, { appInstanceID, parentInstanceID }) {
236
247
  const eventNames = [
237
248
  'localeChanged',
238
249
  'themeChanged',
@@ -240,12 +251,12 @@ class UI extends EventListener {
240
251
  ];
241
252
  super(eventNames);
242
253
  this.#eventNames = eventNames;
243
- this.context = context;
254
+ this.puter = puter;
244
255
  this.appInstanceID = appInstanceID;
245
256
  this.parentInstanceID = parentInstanceID;
246
- this.appID = context.appID;
247
- this.env = context.env;
248
- this.util = context.util;
257
+ this.appID = puter.appID;
258
+ this.env = puter.env;
259
+ this.util = puter.util;
249
260
 
250
261
  if ( this.env === 'app' ) {
251
262
  this.messageTarget = window.parent;
@@ -254,16 +265,12 @@ class UI extends EventListener {
254
265
  return;
255
266
  }
256
267
 
257
- // Context to pass to AppConnection instances
258
- this.context = this.context.sub({
259
- appInstanceID: this.appInstanceID,
260
- messageTarget: this.messageTarget,
261
- });
262
-
263
268
  if ( this.parentInstanceID ) {
264
- this.#parentAppConnection = new AppConnection(this.context, {
269
+ this.#parentAppConnection = new AppConnection(this.puter, {
265
270
  target: this.parentInstanceID,
266
271
  usesSDK: true,
272
+ messageTarget: this.messageTarget,
273
+ appInstanceID: this.appInstanceID,
267
274
  });
268
275
  }
269
276
 
@@ -535,7 +542,10 @@ class UI extends EventListener {
535
542
  }
536
543
  else if ( e.data.msg === 'connection' ) {
537
544
  e.data.usesSDK = true; // we can safely assume this
538
- const conn = AppConnection.from(e.data, this.context);
545
+ const conn = AppConnection.from(e.data, this.puter, {
546
+ messageTarget: this.messageTarget,
547
+ appInstanceID: this.appInstanceID,
548
+ });
539
549
  const accept = value => {
540
550
  this.messageTarget?.postMessage({
541
551
  $: 'connection-resp',
@@ -743,7 +753,7 @@ class UI extends EventListener {
743
753
  };
744
754
 
745
755
  showOpenFilePicker (options, callback) {
746
- const undefinedOnCancel = new putility.libs.promise.TeePromise();
756
+ const undefinedOnCancel = createDeferred();
747
757
  const resolveOnlyPromise = new Promise((resolve, reject) => {
748
758
  if ( ! globalThis.open ) {
749
759
  return reject('This API is not compatible in Web Workers.');
@@ -779,7 +789,7 @@ class UI extends EventListener {
779
789
  resolve(maybe_result);
780
790
  };
781
791
  });
782
- resolveOnlyPromise.undefinedOnCancel = undefinedOnCancel;
792
+ resolveOnlyPromise.undefinedOnCancel = undefinedOnCancel.promise;
783
793
  return resolveOnlyPromise;
784
794
  };
785
795
 
@@ -802,7 +812,7 @@ class UI extends EventListener {
802
812
  };
803
813
 
804
814
  showSaveFilePicker (content, suggestedName, type) {
805
- const undefinedOnCancel = new putility.libs.promise.TeePromise();
815
+ const undefinedOnCancel = createDeferred();
806
816
  const resolveOnlyPromise = new Promise((resolve, reject) => {
807
817
  if ( ! globalThis.open ) {
808
818
  return reject('This API is not compatible in Web Workers.');
@@ -870,7 +880,7 @@ class UI extends EventListener {
870
880
  };
871
881
  });
872
882
 
873
- resolveOnlyPromise.undefinedOnCancel = undefinedOnCancel;
883
+ resolveOnlyPromise.undefinedOnCancel = undefinedOnCancel.promise;
874
884
 
875
885
  return resolveOnlyPromise;
876
886
  };
@@ -1203,7 +1213,10 @@ class UI extends EventListener {
1203
1213
  },
1204
1214
  });
1205
1215
 
1206
- return AppConnection.from(app_info, this.context);
1216
+ return AppConnection.from(app_info, this.puter, {
1217
+ messageTarget: this.messageTarget,
1218
+ appInstanceID: this.appInstanceID,
1219
+ });
1207
1220
  };
1208
1221
 
1209
1222
  connectToInstance = async function connectToInstance (app_name) {
@@ -1214,7 +1227,10 @@ class UI extends EventListener {
1214
1227
  },
1215
1228
  });
1216
1229
 
1217
- return AppConnection.from(app_info, this.context);
1230
+ return AppConnection.from(app_info, this.puter, {
1231
+ messageTarget: this.messageTarget,
1232
+ appInstanceID: this.appInstanceID,
1233
+ });
1218
1234
  };
1219
1235
 
1220
1236
  parentApp () {
@@ -0,0 +1,208 @@
1
+ class UsageLimitDialog extends (globalThis.HTMLElement || Object) {
2
+ constructor (message) {
3
+ super();
4
+ this.message = message || 'You have reached your usage limit for this account.';
5
+
6
+ this.attachShadow({ mode: 'open' });
7
+
8
+ this.shadowRoot.innerHTML = `
9
+ <style>
10
+ dialog {
11
+ background: transparent;
12
+ border: none;
13
+ box-shadow: none;
14
+ outline: none;
15
+ padding: 0;
16
+ max-width: 90vw;
17
+ }
18
+
19
+ dialog::backdrop {
20
+ background: rgba(0, 0, 0, 0.5);
21
+ }
22
+
23
+ .dialog-content {
24
+ border: 1px solid #e8e8e8;
25
+ border-radius: 12px;
26
+ padding: 32px;
27
+ background: white;
28
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
29
+ -webkit-font-smoothing: antialiased;
30
+ color: #333;
31
+ position: relative;
32
+ max-width: 420px;
33
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
34
+ }
35
+
36
+ .close-btn {
37
+ position: absolute;
38
+ right: 16px;
39
+ top: 12px;
40
+ font-size: 20px;
41
+ color: #999;
42
+ cursor: pointer;
43
+ width: 28px;
44
+ height: 28px;
45
+ display: flex;
46
+ align-items: center;
47
+ justify-content: center;
48
+ border-radius: 50%;
49
+ transition: background 0.2s, color 0.2s;
50
+ }
51
+
52
+ .close-btn:hover {
53
+ background: #f0f0f0;
54
+ color: #333;
55
+ }
56
+
57
+ .icon-container {
58
+ width: 64px;
59
+ height: 64px;
60
+ margin: 0 auto 20px;
61
+ background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
62
+ border-radius: 50%;
63
+ display: flex;
64
+ align-items: center;
65
+ justify-content: center;
66
+ }
67
+
68
+ .icon-container svg {
69
+ width: 32px;
70
+ height: 32px;
71
+ color: #f57c00;
72
+ }
73
+
74
+ h2 {
75
+ margin: 0 0 12px;
76
+ font-size: 20px;
77
+ font-weight: 600;
78
+ text-align: center;
79
+ color: #1a1a1a;
80
+ }
81
+
82
+ .message {
83
+ text-align: center;
84
+ font-size: 14px;
85
+ line-height: 1.5;
86
+ color: #666;
87
+ margin-bottom: 24px;
88
+ }
89
+
90
+ .buttons {
91
+ display: flex;
92
+ gap: 12px;
93
+ justify-content: center;
94
+ }
95
+
96
+ .button {
97
+ padding: 10px 24px;
98
+ border-radius: 8px;
99
+ font-size: 14px;
100
+ font-weight: 500;
101
+ cursor: pointer;
102
+ transition: all 0.2s;
103
+ border: none;
104
+ font-family: inherit;
105
+ }
106
+
107
+ .button-secondary {
108
+ background: #f5f5f5;
109
+ color: #666;
110
+ }
111
+
112
+ .button-secondary:hover {
113
+ background: #e8e8e8;
114
+ }
115
+
116
+ .button-primary {
117
+ background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
118
+ color: white;
119
+ }
120
+
121
+ .button-primary:hover {
122
+ background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
123
+ box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
124
+ }
125
+ </style>
126
+ <dialog>
127
+ <div class="dialog-content">
128
+ <span class="close-btn">&#x2715;</span>
129
+ <div class="icon-container">
130
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
131
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
132
+ </svg>
133
+ </div>
134
+ <h2>Low Balance</h2>
135
+ <p class="message">${this.message}</p>
136
+ <div class="buttons">
137
+ <button class="button button-secondary" id="close-btn">Close</button>
138
+ <button class="button button-primary" id="upgrade-btn">Upgrade Now</button>
139
+ </div>
140
+ </div>
141
+ </dialog>
142
+ `;
143
+ }
144
+
145
+ connectedCallback () {
146
+ const dialog = this.shadowRoot.querySelector('dialog');
147
+
148
+ this.shadowRoot.querySelector('.close-btn').addEventListener('click', () => {
149
+ this.close();
150
+ });
151
+
152
+ this.shadowRoot.querySelector('#close-btn').addEventListener('click', () => {
153
+ this.close();
154
+ });
155
+
156
+ this.shadowRoot.querySelector('#upgrade-btn').addEventListener('click', () => {
157
+ window.open('https://puter.com/dashboard', '_blank');
158
+ this.close();
159
+ });
160
+
161
+ // Close on backdrop click
162
+ dialog.addEventListener('click', (e) => {
163
+ if ( e.target === dialog ) {
164
+ this.close();
165
+ }
166
+ });
167
+ }
168
+
169
+ open () {
170
+ this.shadowRoot.querySelector('dialog').showModal();
171
+ }
172
+
173
+ close () {
174
+ this.shadowRoot.querySelector('dialog').close();
175
+ this.remove();
176
+ }
177
+ }
178
+
179
+ // Only define custom element in environments with DOM support
180
+ if ( typeof globalThis.HTMLElement !== 'undefined' && globalThis.customElements ) {
181
+ if ( ! customElements.get('usage-limit-dialog') ) {
182
+ customElements.define('usage-limit-dialog', UsageLimitDialog);
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Shows a usage limit dialog to the user
188
+ * @param {string} message - The message to display
189
+ */
190
+ export function showUsageLimitDialog (message) {
191
+ // Only log in non-browser environments
192
+ if ( typeof globalThis.document === 'undefined' ) {
193
+ console.warn('[Puter]', message);
194
+ return;
195
+ }
196
+
197
+ // Check if dialog is already shown to prevent duplicates
198
+ if ( document.querySelector('usage-limit-dialog') ) {
199
+ return;
200
+ }
201
+
202
+ const dialog = new UsageLimitDialog(message);
203
+ document.body.appendChild(dialog);
204
+ dialog.open();
205
+ }
206
+
207
+ export default UsageLimitDialog;
208
+
@@ -158,24 +158,14 @@ export interface Speech2SpeechOptions {
158
158
  file?: string | File | Blob;
159
159
  provider?: string;
160
160
  model?: string;
161
- modelId?: string;
162
- model_id?: string;
163
161
  voice?: string;
164
- voiceId?: string;
165
- voice_id?: string;
166
162
  output_format?: string;
167
- outputFormat?: string;
168
163
  voice_settings?: Record<string, unknown>;
169
- voiceSettings?: Record<string, unknown>;
170
164
  seed?: number;
171
165
  file_format?: string;
172
- fileFormat?: string;
173
166
  remove_background_noise?: boolean;
174
- removeBackgroundNoise?: boolean;
175
167
  optimize_streaming_latency?: number;
176
- optimizeStreamingLatency?: number;
177
168
  enable_logging?: boolean;
178
- enableLogging?: boolean;
179
169
  test_mode?: boolean;
180
170
  }
181
171
 
@@ -1,6 +1,6 @@
1
- import type { PaginationOptions, RequestCallbacks } from '../shared.d.ts';
1
+ import type { RequestCallbacks } from '../shared.d.ts';
2
2
 
3
- export interface AppRecord {
3
+ export interface App {
4
4
  uid: string;
5
5
  name: string;
6
6
  index_url: string;
@@ -16,12 +16,25 @@ export interface AppRecord {
16
16
  user_count?: number;
17
17
  }
18
18
 
19
- export interface AppListOptions extends PaginationOptions {
19
+ export interface CreateAppResult {
20
+ uid: string;
21
+ name: string;
22
+ title: string;
23
+ index_url: string;
24
+ subdomain: string;
25
+ owner: {
26
+ username: string;
27
+ uuid: string;
28
+ };
29
+ app_owner?: Record<string, unknown>;
30
+ }
31
+
32
+ export interface AppListOptions {
20
33
  stats_period?: string;
21
34
  icon_size?: null | 16 | 32 | 64 | 128 | 256 | 512;
22
35
  }
23
36
 
24
- export interface CreateAppOptions extends RequestCallbacks<AppRecord> {
37
+ export interface CreateAppOptions {
25
38
  name: string;
26
39
  indexURL: string;
27
40
  title?: string;
@@ -34,7 +47,7 @@ export interface CreateAppOptions extends RequestCallbacks<AppRecord> {
34
47
  dedupeName?: boolean;
35
48
  }
36
49
 
37
- export interface UpdateAppAttributes extends RequestCallbacks<AppRecord> {
50
+ export interface UpdateAppAttributes {
38
51
  name?: string;
39
52
  indexURL?: string;
40
53
  title?: string;
@@ -47,16 +60,12 @@ export interface UpdateAppAttributes extends RequestCallbacks<AppRecord> {
47
60
  }
48
61
 
49
62
  export class Apps {
50
- constructor (context: { authToken?: string; APIOrigin: string; appID?: string });
51
-
52
- setAuthToken (authToken: string): void;
53
- setAPIOrigin (APIOrigin: string): void;
54
-
55
- list (options?: AppListOptions): Promise<AppRecord[]>;
56
- create (name: string, indexURL: string, title?: string): Promise<AppRecord>;
57
- create (options: CreateAppOptions): Promise<AppRecord>;
58
- update (name: string, attributes: UpdateAppAttributes): Promise<AppRecord>;
59
- get (name: string, options?: AppListOptions): Promise<AppRecord>;
63
+ list (options?: AppListOptions): Promise<App[]>;
64
+ create (name: string, indexURL: string, title?: string): Promise<CreateAppResult>;
65
+ create (options: CreateAppOptions): Promise<CreateAppResult>;
66
+ update (name: string, attributes: UpdateAppAttributes): Promise<App>;
67
+ get (name: string, options?: AppListOptions): Promise<App>;
60
68
  delete (name: string): Promise<{ success?: boolean }>;
61
69
  getDeveloperProfile (options?: RequestCallbacks<Record<string, unknown>>): Promise<Record<string, unknown>>;
70
+ getDeveloperProfile (success: (value: Record<string, unknown>) => void, error?: (reason: unknown) => void): Promise<Record<string, unknown>>;
62
71
  }
@@ -1,3 +1,5 @@
1
+ import { RequestCallbacks } from "../shared";
2
+
1
3
  export interface User {
2
4
  uuid: string;
3
5
  username: string;
@@ -55,7 +57,7 @@ export class Auth {
55
57
  signIn (options?: { attempt_temp_user_creation?: boolean }): Promise<SignInResult>;
56
58
  signOut (): void;
57
59
  isSignedIn (): boolean;
58
- getUser (): Promise<User>;
60
+ getUser (options:? RequestCallbacks<User>): Promise<User>;
59
61
  whoami (): Promise<User>;
60
62
  getMonthlyUsage (): Promise<MonthlyUsage>;
61
63
  getDetailedAppUsage (appId: string): Promise<DetailedAppUsage>;
@@ -43,7 +43,6 @@ export interface DeleteOptions extends RequestCallbacks<void> {
43
43
  paths?: string | string[];
44
44
  recursive?: boolean;
45
45
  descendantsOnly?: boolean;
46
- descendants_only?: boolean;
47
46
  }
48
47
 
49
48
  export interface ReadOptions extends RequestCallbacks<Blob> {
@@ -100,7 +99,6 @@ export interface WriteOptions extends RequestCallbacks<FSItem> {
100
99
  dedupeName?: boolean;
101
100
  createMissingParents?: boolean;
102
101
  createMissingAncestors?: boolean;
103
- name?: string;
104
102
  init?: (operationId: string, xhr: XMLHttpRequest) => void;
105
103
  start?: () => void;
106
104
  progress?: (operationId: string, progress: number) => void;
@@ -10,6 +10,14 @@ export interface KVIncrementPath {
10
10
  [path: string]: number;
11
11
  }
12
12
 
13
+ export interface KVUpdatePath {
14
+ [path: string]: KVValue;
15
+ }
16
+
17
+ export interface KVAddPath {
18
+ [path: string]: KVValue | KVValue[];
19
+ }
20
+
13
21
  export class KV {
14
22
  readonly MAX_KEY_SIZE: number;
15
23
  readonly MAX_VALUE_SIZE: number;
@@ -19,6 +27,8 @@ export class KV {
19
27
  del (key: string): Promise<boolean>;
20
28
  incr (key: string, amount?: number | KVIncrementPath): Promise<number>;
21
29
  decr (key: string, amount?: number | KVIncrementPath): Promise<number>;
30
+ add (key: string, value?: KVValue | KVAddPath): Promise<KVValue>;
31
+ update (key: string, pathAndValueMap: KVUpdatePath, ttlSeconds?: number): Promise<KVValue>;
22
32
  expire (key: string, ttlSeconds: number): Promise<boolean>;
23
33
  expireAt (key: string, timestampSeconds: number): Promise<boolean>;
24
34
  list (pattern?: string, returnValues?: false): Promise<string[]>;
@@ -14,7 +14,7 @@ export class PSocket {
14
14
  close (): void;
15
15
  on (event: 'open', handler: () => void): void;
16
16
  on (event: 'data', handler: (buffer: Uint8Array) => void): void;
17
- on (event: 'error', handler: (reason: unknown) => void): void;
17
+ on (event: 'error', handler: (reason: string) => void): void;
18
18
  on (event: 'close', handler: (hadError: boolean) => void): void;
19
19
  addListener (event: SocketEvent, handler: (...args: unknown[]) => void): void;
20
20
  }
@@ -1,12 +1,7 @@
1
1
  import type { RequestCallbacks } from '../shared.d.ts';
2
- import type { AuthUser } from './auth.d.ts';
2
+ import type { User } from './auth.d.ts';
3
3
 
4
4
  export class OS {
5
- constructor (context: { authToken?: string; APIOrigin: string; appID?: string });
6
-
7
- setAuthToken (authToken: string): void;
8
- setAPIOrigin (APIOrigin: string): void;
9
-
10
- user (options?: RequestCallbacks<AuthUser> & { query?: Record<string, string> }): Promise<AuthUser>;
5
+ user (options?: RequestCallbacks<User> & { query?: Record<string, string> }): Promise<User>;
11
6
  version (options?: RequestCallbacks<Record<string, unknown>>): Promise<Record<string, unknown>>;
12
7
  }
@@ -1,4 +1,3 @@
1
- import type { RequestCallbacks } from '../shared.d.ts';
2
1
  import type { FSItem } from './fs-item.d.ts';
3
2
 
4
3
  export interface AlertButton {
@@ -36,8 +35,12 @@ export interface WindowOptions {
36
35
 
37
36
  export interface LaunchAppOptions {
38
37
  name?: string;
38
+ app_name?: string;
39
39
  args?: Record<string, unknown>;
40
- appInstanceID?: string;
40
+ file_paths?: string[];
41
+ items?: FSItem[];
42
+ pseudonym?: string;
43
+ callback?: (connection: AppConnection) => void;
41
44
  }
42
45
 
43
46
  export interface ThemeData {
@@ -90,17 +93,17 @@ export class AppConnection {
90
93
  }
91
94
 
92
95
  export class UI {
93
- constructor (context: Record<string, unknown>, parameters: { appInstanceID?: string; parentInstanceID?: string });
94
-
95
96
  alert (message?: string, buttons?: AlertButton[]): Promise<string>;
96
- prompt (message?: string, defaultValue?: string): Promise<string | null>;
97
- authenticateWithPuter (): Promise<unknown>;
97
+ prompt (message?: string, placeholder?: string): Promise<string | null>;
98
+ authenticateWithPuter (): Promise<void>;
98
99
  contextMenu (options: ContextMenuOptions): void;
99
100
  createWindow (options?: WindowOptions): void;
100
101
  exit (statusCode?: number): void;
101
102
  getLanguage (): Promise<string>;
102
103
  hideSpinner (): void;
104
+ hideWindow (): void;
103
105
  showSpinner (): void;
106
+ showWindow (): void;
104
107
  showColorPicker (defaultColor?: string | Record<string, unknown>): Promise<string>;
105
108
  showDirectoryPicker (options?: DirectoryPickerOptions): Promise<FSItem | FSItem[]>;
106
109
  showFontPicker (defaultFont?: string | Record<string, unknown>): Promise<{ fontFamily: string }>;
@@ -127,7 +130,7 @@ export class UI {
127
130
  on (eventName: 'localeChanged', handler: (data: { language: string }) => void): void;
128
131
  on (eventName: 'themeChanged', handler: (data: ThemeData) => void): void;
129
132
  parentApp (): AppConnection | null;
130
- launchApp (appName?: string, args?: Record<string, unknown>): Promise<AppConnection>;
133
+ launchApp (appName?: string, args?: Record<string, unknown>, callback?: (connection: AppConnection) => void): Promise<AppConnection>;
131
134
  launchApp (options: LaunchAppOptions): Promise<AppConnection>;
132
135
 
133
136
  getEntriesFromDataTransferItems (dataTransferItems: DataTransferItemList, options?: { raw?: boolean }): Promise<Array<File | FileSystemEntry>>;
@@ -7,6 +7,5 @@ export class UtilRPC {
7
7
  }
8
8
 
9
9
  export default class Util {
10
- constructor ();
11
10
  rpc: UtilRPC;
12
11
  }