@rljson/bs 0.0.20 → 0.0.22

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.
@@ -5,7 +5,7 @@ import { Socket } from './socket.ts';
5
5
  * Allows multiple clients to access the same blob storage instance remotely.
6
6
  */
7
7
  export declare class BsServer {
8
- private readonly _bs;
8
+ private _bs;
9
9
  private _sockets;
10
10
  constructor(_bs: Bs);
11
11
  /**
@@ -24,9 +24,10 @@ export declare class BsServer {
24
24
  */
25
25
  private _addTransportLayer;
26
26
  /**
27
- * Generates a transport layer object for the given Bs instance.
28
- * @param bs - The Bs instance to generate the transport layer for.
29
- * @returns An object containing methods that correspond to the Bs interface.
27
+ * Generates a transport layer object that always delegates to the current
28
+ * this._bs. Each method is an arrow function reading this._bs at call
29
+ * time so that external code can replace _bs after construction and all
30
+ * existing socket handlers pick up the new instance.
30
31
  */
31
- private _generateTransportLayer;
32
+ private _generateTransportLayerCRUD;
32
33
  }
package/dist/bs.js CHANGED
@@ -909,8 +909,8 @@ class BsServer {
909
909
  * @param socket - The socket to add the transport layer to.
910
910
  */
911
911
  async _addTransportLayer(socket) {
912
- const methods = this._generateTransportLayer(this._bs);
913
- for (const [key, fn] of Object.entries(methods)) {
912
+ const crud = this._generateTransportLayerCRUD();
913
+ for (const [key, fn] of Object.entries(crud)) {
914
914
  socket.on(key, (...args) => {
915
915
  const cb = args[args.length - 1];
916
916
  fn.apply(this, args.slice(0, -1)).then((result) => {
@@ -923,19 +923,20 @@ class BsServer {
923
923
  }
924
924
  // ...........................................................................
925
925
  /**
926
- * Generates a transport layer object for the given Bs instance.
927
- * @param bs - The Bs instance to generate the transport layer for.
928
- * @returns An object containing methods that correspond to the Bs interface.
926
+ * Generates a transport layer object that always delegates to the current
927
+ * this._bs. Each method is an arrow function reading this._bs at call
928
+ * time so that external code can replace _bs after construction and all
929
+ * existing socket handlers pick up the new instance.
929
930
  */
930
- _generateTransportLayer = (bs) => ({
931
- setBlob: (content) => bs.setBlob(content),
932
- getBlob: (blobId, options) => bs.getBlob(blobId, options),
933
- getBlobStream: (blobId) => bs.getBlobStream(blobId),
934
- deleteBlob: (blobId) => bs.deleteBlob(blobId),
935
- blobExists: (blobId) => bs.blobExists(blobId),
936
- getBlobProperties: (blobId) => bs.getBlobProperties(blobId),
937
- listBlobs: (options) => bs.listBlobs(options),
938
- generateSignedUrl: (blobId, expiresIn, permissions) => bs.generateSignedUrl(blobId, expiresIn, permissions)
931
+ _generateTransportLayerCRUD = () => ({
932
+ setBlob: (content) => this._bs.setBlob(content),
933
+ getBlob: (blobId, options) => this._bs.getBlob(blobId, options),
934
+ getBlobStream: (blobId) => this._bs.getBlobStream(blobId),
935
+ deleteBlob: (blobId) => this._bs.deleteBlob(blobId),
936
+ blobExists: (blobId) => this._bs.blobExists(blobId),
937
+ getBlobProperties: (blobId) => this._bs.getBlobProperties(blobId),
938
+ listBlobs: (options) => this._bs.listBlobs(options),
939
+ generateSignedUrl: (blobId, expiresIn, permissions) => this._bs.generateSignedUrl(blobId, expiresIn, permissions)
939
940
  });
940
941
  }
941
942
  class SocketMock {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/bs",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "Blob storage interface and implementations for rljson",
5
5
  "homepage": "https://github.com/rljson/bs",
6
6
  "bugs": "https://github.com/rljson/bs/issues",
@@ -20,36 +20,36 @@
20
20
  ],
21
21
  "type": "module",
22
22
  "devDependencies": {
23
- "@types/node": "^25.1.0",
24
- "@typescript-eslint/eslint-plugin": "^8.54.0",
25
- "@typescript-eslint/parser": "^8.54.0",
23
+ "@types/node": "^25.2.3",
24
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
25
+ "@typescript-eslint/parser": "^8.56.0",
26
26
  "@vitest/coverage-v8": "^4.0.18",
27
27
  "cross-env": "^10.1.0",
28
- "eslint": "^9.39.2",
29
- "eslint-plugin-jsdoc": "^62.5.0",
28
+ "eslint": "~9.39.2",
29
+ "eslint-plugin-jsdoc": "^62.5.5",
30
30
  "eslint-plugin-tsdoc": "^0.5.0",
31
- "globals": "^17.2.0",
31
+ "globals": "^17.3.0",
32
32
  "jsdoc": "^4.0.5",
33
- "read-pkg": "^10.0.0",
33
+ "read-pkg": "^10.1.0",
34
34
  "typescript": "~5.9.3",
35
- "typescript-eslint": "^8.54.0",
35
+ "typescript-eslint": "^8.56.0",
36
36
  "vite": "^7.3.1",
37
37
  "vite-node": "^5.3.0",
38
38
  "vite-plugin-dts": "^4.5.4",
39
- "vite-tsconfig-paths": "^6.0.5",
39
+ "vite-tsconfig-paths": "^6.1.1",
40
40
  "vitest": "^4.0.18",
41
41
  "vitest-dom": "^0.1.1"
42
42
  },
43
43
  "dependencies": {
44
44
  "@rljson/hash": "^0.0.18",
45
45
  "@rljson/json": "^0.0.23",
46
- "@rljson/rljson": "^0.0.75"
46
+ "@rljson/rljson": "^0.0.76"
47
47
  },
48
48
  "scripts": {
49
- "build": "pnpx vite build && tsc && node scripts/copy-readme-to-dist.js && node scripts/deploy-conformance-tests.js",
50
- "test": "pnpx vitest run --coverage && pnpm run lint",
51
- "prebuild": "npm run test",
52
- "lint": "pnpx eslint",
49
+ "build": "pnpm exec vite build && tsc && node scripts/copy-readme-to-dist.js && node scripts/deploy-conformance-tests.js",
50
+ "test": "pnpm exec vitest run --coverage && pnpm run lint",
51
+ "prebuild": "pnpm run test",
52
+ "lint": "pnpm exec eslint",
53
53
  "updateGoldens": "cross-env UPDATE_GOLDENS=true pnpm test"
54
54
  }
55
55
  }