@statewalker/webrun-files-rpc 0.1.1 → 0.1.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.
- package/dist/cjs/index.cjs +4 -8
- package/dist/esm/index.js +4 -8
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// src/client.ts
|
|
3
3
|
const toBytes$1 = (v) => v instanceof Uint8Array ? v : ArrayBuffer.isView(v) ? new Uint8Array(v.buffer, v.byteOffset, v.byteLength) : new Uint8Array(v);
|
|
4
4
|
const newStreamId$1 = () => crypto.randomUUID().replace(/-/g, "");
|
|
5
5
|
/** Cuts any sequence of byte arrays into chunks of exactly `size` bytes (the last may be shorter). */
|
|
@@ -166,8 +166,7 @@ var FilesRpcClient = class {
|
|
|
166
166
|
function newFilesRpcClient(options) {
|
|
167
167
|
return new FilesRpcClient(options);
|
|
168
168
|
}
|
|
169
|
-
|
|
170
|
-
//#region src/errors.ts
|
|
169
|
+
// src/errors.ts
|
|
171
170
|
/**
|
|
172
171
|
* An error of the protocol itself. The code also leads the message (`UNKNOWN_STREAM: …`), since
|
|
173
172
|
* a structured clone keeps an error's name and message but not its other properties:
|
|
@@ -196,8 +195,7 @@ const CODES = /* @__PURE__ */ new Set([
|
|
|
196
195
|
]);
|
|
197
196
|
/** A message led by a code, as FilesRpcError writes it (`CODE: …`). */
|
|
198
197
|
const LEADING_CODE = new RegExp(`^(${[...CODES].join("|")}):`);
|
|
199
|
-
|
|
200
|
-
//#region src/keyed.ts
|
|
198
|
+
// src/keyed.ts
|
|
201
199
|
/**
|
|
202
200
|
* Values kept by key, and waiters for keys that have no value yet: what both ends of a stream
|
|
203
201
|
* use to keep chunks by chunkId and wait for the ones still on their way.
|
|
@@ -260,8 +258,7 @@ var Keyed = class {
|
|
|
260
258
|
this.#waiters.clear();
|
|
261
259
|
}
|
|
262
260
|
};
|
|
263
|
-
|
|
264
|
-
//#region src/server.ts
|
|
261
|
+
// src/server.ts
|
|
265
262
|
/**
|
|
266
263
|
* Whether a write's outcome is the FilesApi's alone: every chunk was handed to it (an emulated
|
|
267
264
|
* append, until its write-back starts, can still be cancelled).
|
|
@@ -788,7 +785,6 @@ function newFilesRpcServer(options) {
|
|
|
788
785
|
timer?.unref?.();
|
|
789
786
|
return server;
|
|
790
787
|
}
|
|
791
|
-
//#endregion
|
|
792
788
|
exports.FilesRpcClient = FilesRpcClient;
|
|
793
789
|
exports.FilesRpcError = FilesRpcError;
|
|
794
790
|
exports.errorCode = errorCode;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/client.ts
|
|
2
2
|
const toBytes$1 = (v) => v instanceof Uint8Array ? v : ArrayBuffer.isView(v) ? new Uint8Array(v.buffer, v.byteOffset, v.byteLength) : new Uint8Array(v);
|
|
3
3
|
const newStreamId$1 = () => crypto.randomUUID().replace(/-/g, "");
|
|
4
4
|
/** Cuts any sequence of byte arrays into chunks of exactly `size` bytes (the last may be shorter). */
|
|
@@ -165,8 +165,7 @@ var FilesRpcClient = class {
|
|
|
165
165
|
function newFilesRpcClient(options) {
|
|
166
166
|
return new FilesRpcClient(options);
|
|
167
167
|
}
|
|
168
|
-
|
|
169
|
-
//#region src/errors.ts
|
|
168
|
+
// src/errors.ts
|
|
170
169
|
/**
|
|
171
170
|
* An error of the protocol itself. The code also leads the message (`UNKNOWN_STREAM: …`), since
|
|
172
171
|
* a structured clone keeps an error's name and message but not its other properties:
|
|
@@ -195,8 +194,7 @@ const CODES = /* @__PURE__ */ new Set([
|
|
|
195
194
|
]);
|
|
196
195
|
/** A message led by a code, as FilesRpcError writes it (`CODE: …`). */
|
|
197
196
|
const LEADING_CODE = new RegExp(`^(${[...CODES].join("|")}):`);
|
|
198
|
-
|
|
199
|
-
//#region src/keyed.ts
|
|
197
|
+
// src/keyed.ts
|
|
200
198
|
/**
|
|
201
199
|
* Values kept by key, and waiters for keys that have no value yet: what both ends of a stream
|
|
202
200
|
* use to keep chunks by chunkId and wait for the ones still on their way.
|
|
@@ -259,8 +257,7 @@ var Keyed = class {
|
|
|
259
257
|
this.#waiters.clear();
|
|
260
258
|
}
|
|
261
259
|
};
|
|
262
|
-
|
|
263
|
-
//#region src/server.ts
|
|
260
|
+
// src/server.ts
|
|
264
261
|
/**
|
|
265
262
|
* Whether a write's outcome is the FilesApi's alone: every chunk was handed to it (an emulated
|
|
266
263
|
* append, until its write-back starts, can still be cancelled).
|
|
@@ -787,5 +784,4 @@ function newFilesRpcServer(options) {
|
|
|
787
784
|
timer?.unref?.();
|
|
788
785
|
return server;
|
|
789
786
|
}
|
|
790
|
-
//#endregion
|
|
791
787
|
export { FilesRpcClient, FilesRpcError, errorCode, newFilesRpcClient, newFilesRpcServer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statewalker/webrun-files-rpc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "FilesApi over any RPC: streamed reads and writes as chunks kept and awaited by (streamId, chunkId)",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"src"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@statewalker/webrun-files": "^0.10.
|
|
37
|
+
"@statewalker/webrun-files": "^0.10.5"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^26.6.4",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"rolldown": "^1.2.12",
|
|
43
43
|
"typescript": "^7.0.2",
|
|
44
44
|
"vitest": "^4.1.4 || ^5.0.3",
|
|
45
|
-
"@statewalker/webrun-files-
|
|
46
|
-
"@statewalker/webrun-files-
|
|
45
|
+
"@statewalker/webrun-files-tests": "^3.0.0",
|
|
46
|
+
"@statewalker/webrun-files-mem": "^0.10.5"
|
|
47
47
|
},
|
|
48
48
|
"sideEffects": false,
|
|
49
49
|
"publishConfig": {
|