@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.
- package/README.md +14 -43
- package/index.d.ts +479 -0
- package/package.json +13 -3
- package/APACHE_LICENSE.txt +0 -201
- package/doc/devlog.md +0 -49
- package/src/bg.png +0 -0
- package/src/bg.webp +0 -0
- package/src/lib/APICallLogger.js +0 -110
- package/src/lib/EventListener.js +0 -51
- package/src/lib/RequestError.js +0 -6
- package/src/lib/filesystem/APIFS.js +0 -73
- package/src/lib/filesystem/CacheFS.js +0 -243
- package/src/lib/filesystem/PostMessageFS.js +0 -40
- package/src/lib/filesystem/definitions.js +0 -39
- package/src/lib/path.js +0 -509
- package/src/lib/polyfills/localStorage.js +0 -92
- package/src/lib/polyfills/xhrshim.js +0 -233
- package/src/lib/socket.io/socket.io.esm.min.js +0 -7
- package/src/lib/socket.io/socket.io.esm.min.js.map +0 -1
- package/src/lib/socket.io/socket.io.js +0 -4385
- package/src/lib/socket.io/socket.io.js.map +0 -1
- package/src/lib/socket.io/socket.io.min.js +0 -7
- package/src/lib/socket.io/socket.io.min.js.map +0 -1
- package/src/lib/socket.io/socket.io.msgpack.min.js +0 -7
- package/src/lib/socket.io/socket.io.msgpack.min.js.map +0 -1
- package/src/lib/utils.js +0 -620
- package/src/lib/xdrpc.js +0 -104
- package/src/modules/AI.js +0 -680
- package/src/modules/Apps.js +0 -215
- package/src/modules/Auth.js +0 -171
- package/src/modules/Debug.js +0 -39
- package/src/modules/Drivers.js +0 -278
- package/src/modules/FSItem.js +0 -139
- package/src/modules/FileSystem/index.js +0 -187
- package/src/modules/FileSystem/operations/copy.js +0 -64
- package/src/modules/FileSystem/operations/deleteFSEntry.js +0 -59
- package/src/modules/FileSystem/operations/getReadUrl.js +0 -42
- package/src/modules/FileSystem/operations/mkdir.js +0 -62
- package/src/modules/FileSystem/operations/move.js +0 -75
- package/src/modules/FileSystem/operations/read.js +0 -46
- package/src/modules/FileSystem/operations/readdir.js +0 -102
- package/src/modules/FileSystem/operations/rename.js +0 -58
- package/src/modules/FileSystem/operations/sign.js +0 -103
- package/src/modules/FileSystem/operations/space.js +0 -40
- package/src/modules/FileSystem/operations/stat.js +0 -95
- package/src/modules/FileSystem/operations/symlink.js +0 -55
- package/src/modules/FileSystem/operations/upload.js +0 -440
- package/src/modules/FileSystem/operations/write.js +0 -65
- package/src/modules/FileSystem/utils/getAbsolutePathForApp.js +0 -21
- package/src/modules/Hosting.js +0 -138
- package/src/modules/KV.js +0 -301
- package/src/modules/OS.js +0 -95
- package/src/modules/Perms.js +0 -109
- package/src/modules/PuterDialog.js +0 -481
- package/src/modules/Threads.js +0 -75
- package/src/modules/UI.js +0 -1555
- package/src/modules/Util.js +0 -38
- package/src/modules/Workers.js +0 -120
- package/src/modules/networking/PSocket.js +0 -87
- package/src/modules/networking/PTLS.js +0 -100
- package/src/modules/networking/PWispHandler.js +0 -89
- package/src/modules/networking/parsers.js +0 -157
- package/src/modules/networking/requests.js +0 -282
- package/src/services/APIAccess.js +0 -46
- package/src/services/FSRelay.js +0 -20
- package/src/services/Filesystem.js +0 -122
- package/src/services/NoPuterYet.js +0 -20
- package/src/services/XDIncoming.js +0 -44
- package/test/ai.test.js +0 -214
- package/test/fs.test.js +0 -798
- package/test/index.html +0 -1183
- package/test/kv.test.js +0 -548
- package/test/txt2speech.test.js +0 -178
- 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
|
-
}
|