@heyputer/puter.js 1.0.1 → 2.0.1

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 (74) hide show
  1. package/README.md +14 -43
  2. package/index.d.ts +479 -0
  3. package/package.json +13 -3
  4. package/APACHE_LICENSE.txt +0 -201
  5. package/doc/devlog.md +0 -49
  6. package/src/bg.png +0 -0
  7. package/src/bg.webp +0 -0
  8. package/src/lib/APICallLogger.js +0 -110
  9. package/src/lib/EventListener.js +0 -51
  10. package/src/lib/RequestError.js +0 -6
  11. package/src/lib/filesystem/APIFS.js +0 -73
  12. package/src/lib/filesystem/CacheFS.js +0 -243
  13. package/src/lib/filesystem/PostMessageFS.js +0 -40
  14. package/src/lib/filesystem/definitions.js +0 -39
  15. package/src/lib/path.js +0 -509
  16. package/src/lib/polyfills/localStorage.js +0 -92
  17. package/src/lib/polyfills/xhrshim.js +0 -233
  18. package/src/lib/socket.io/socket.io.esm.min.js +0 -7
  19. package/src/lib/socket.io/socket.io.esm.min.js.map +0 -1
  20. package/src/lib/socket.io/socket.io.js +0 -4385
  21. package/src/lib/socket.io/socket.io.js.map +0 -1
  22. package/src/lib/socket.io/socket.io.min.js +0 -7
  23. package/src/lib/socket.io/socket.io.min.js.map +0 -1
  24. package/src/lib/socket.io/socket.io.msgpack.min.js +0 -7
  25. package/src/lib/socket.io/socket.io.msgpack.min.js.map +0 -1
  26. package/src/lib/utils.js +0 -620
  27. package/src/lib/xdrpc.js +0 -104
  28. package/src/modules/AI.js +0 -680
  29. package/src/modules/Apps.js +0 -215
  30. package/src/modules/Auth.js +0 -171
  31. package/src/modules/Debug.js +0 -39
  32. package/src/modules/Drivers.js +0 -278
  33. package/src/modules/FSItem.js +0 -139
  34. package/src/modules/FileSystem/index.js +0 -187
  35. package/src/modules/FileSystem/operations/copy.js +0 -64
  36. package/src/modules/FileSystem/operations/deleteFSEntry.js +0 -59
  37. package/src/modules/FileSystem/operations/getReadUrl.js +0 -42
  38. package/src/modules/FileSystem/operations/mkdir.js +0 -62
  39. package/src/modules/FileSystem/operations/move.js +0 -75
  40. package/src/modules/FileSystem/operations/read.js +0 -46
  41. package/src/modules/FileSystem/operations/readdir.js +0 -102
  42. package/src/modules/FileSystem/operations/rename.js +0 -58
  43. package/src/modules/FileSystem/operations/sign.js +0 -103
  44. package/src/modules/FileSystem/operations/space.js +0 -40
  45. package/src/modules/FileSystem/operations/stat.js +0 -95
  46. package/src/modules/FileSystem/operations/symlink.js +0 -55
  47. package/src/modules/FileSystem/operations/upload.js +0 -440
  48. package/src/modules/FileSystem/operations/write.js +0 -65
  49. package/src/modules/FileSystem/utils/getAbsolutePathForApp.js +0 -21
  50. package/src/modules/Hosting.js +0 -138
  51. package/src/modules/KV.js +0 -301
  52. package/src/modules/OS.js +0 -95
  53. package/src/modules/Perms.js +0 -109
  54. package/src/modules/PuterDialog.js +0 -481
  55. package/src/modules/Threads.js +0 -75
  56. package/src/modules/UI.js +0 -1555
  57. package/src/modules/Util.js +0 -38
  58. package/src/modules/Workers.js +0 -120
  59. package/src/modules/networking/PSocket.js +0 -87
  60. package/src/modules/networking/PTLS.js +0 -100
  61. package/src/modules/networking/PWispHandler.js +0 -89
  62. package/src/modules/networking/parsers.js +0 -157
  63. package/src/modules/networking/requests.js +0 -282
  64. package/src/services/APIAccess.js +0 -46
  65. package/src/services/FSRelay.js +0 -20
  66. package/src/services/Filesystem.js +0 -122
  67. package/src/services/NoPuterYet.js +0 -20
  68. package/src/services/XDIncoming.js +0 -44
  69. package/test/ai.test.js +0 -214
  70. package/test/fs.test.js +0 -798
  71. package/test/index.html +0 -1183
  72. package/test/kv.test.js +0 -548
  73. package/test/txt2speech.test.js +0 -178
  74. package/webpack.config.js +0 -25
package/src/lib/xdrpc.js DELETED
@@ -1,104 +0,0 @@
1
- /**
2
- * This module provides a simple RPC mechanism for cross-document
3
- * (iframe / window.postMessage) communication.
4
- */
5
-
6
- // Since `Symbol` is not clonable, we use a UUID to identify RPCs.
7
- export const $SCOPE = '9a9c83a4-7897-43a0-93b9-53217b84fde6';
8
-
9
- /**
10
- * The CallbackManager is used to manage callbacks for RPCs.
11
- * It is used by the dehydrator and hydrator to store and retrieve
12
- * the functions that are being called remotely.
13
- */
14
- export class CallbackManager {
15
- #messageId = 1;
16
-
17
- constructor () {
18
- this.callbacks = new Map();
19
- }
20
-
21
- register_callback (callback) {
22
- const id = this.#messageId++;
23
- this.callbacks.set(id, callback);
24
- return id;
25
- }
26
-
27
- attach_to_source (source) {
28
- source.addEventListener('message', event => {
29
- const { data } = event;
30
- if (data && typeof data === 'object' && data.$SCOPE === $SCOPE) {
31
- const { id, args } = data;
32
- const callback = this.callbacks.get(id);
33
- if (callback) {
34
- callback(...args);
35
- }
36
- }
37
- });
38
- }
39
- }
40
-
41
- /**
42
- * The dehydrator replaces functions in an object with identifiers,
43
- * so that hydrate() can be called on the other side of the frame
44
- * to bind RPC stubs. The original functions are stored in a map
45
- * so that they can be called when the RPC is invoked.
46
- */
47
- export class Dehydrator {
48
- constructor ({ callbackManager }) {
49
- this.callbackManager = callbackManager;
50
- }
51
- dehydrate (value) {
52
- return this.dehydrate_value_(value);
53
- }
54
- dehydrate_value_ (value) {
55
- if (typeof value === 'function') {
56
- const id = this.callbackManager.register_callback(value);
57
- return { $SCOPE, id };
58
- } else if (Array.isArray(value)) {
59
- return value.map(this.dehydrate_value_.bind(this));
60
- } else if (typeof value === 'object' && value !== null) {
61
- const result = {};
62
- for (const key in value) {
63
- result[key] = this.dehydrate_value_(value[key]);
64
- }
65
- return result;
66
- } else {
67
- return value;
68
- }
69
- }
70
- }
71
-
72
- /**
73
- * The hydrator binds RPC stubs to the functions that were
74
- * previously dehydrated. This allows the RPC to be invoked
75
- * on the other side of the frame.
76
- */
77
- export class Hydrator {
78
- constructor ({ target }) {
79
- this.target = target;
80
- }
81
- hydrate (value) {
82
- return this.hydrate_value_(value);
83
- }
84
- hydrate_value_ (value) {
85
- if (
86
- value && typeof value === 'object' &&
87
- value.$SCOPE === $SCOPE
88
- ) {
89
- const { id } = value;
90
- return (...args) => {
91
- this.target.postMessage({ $SCOPE, id, args }, '*');
92
- };
93
- } else if (Array.isArray(value)) {
94
- return value.map(this.hydrate_value_.bind(this));
95
- } else if (typeof value === 'object' && value !== null) {
96
- const result = {};
97
- for (const key in value) {
98
- result[key] = this.hydrate_value_(value[key]);
99
- }
100
- return result;
101
- }
102
- return value;
103
- }
104
- }