@rljson/bs 0.0.18 → 0.0.19

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.
@@ -4,7 +4,7 @@
4
4
  // Use of this source code is governed by terms that can be
5
5
  // found in the LICENSE file in the root of this package.
6
6
 
7
- import { BsMem, BsTestSetup } from '../src';
7
+ import { BsMem, BsTestSetup } from '@rljson/bs';
8
8
 
9
9
  // .............................................................................
10
10
  /**
package/dist/index.d.ts CHANGED
@@ -1,3 +1,10 @@
1
1
  export { BsMem } from './bs-mem.js';
2
+ export { BsMulti, type BsMultiBs } from './bs-multi.js';
3
+ export { BsPeerBridge } from './bs-peer-bridge.js';
4
+ export { BsPeer } from './bs-peer.js';
5
+ export { BsServer } from './bs-server.js';
2
6
  export type { BsTestSetup } from './bs-test-setup.js';
3
7
  export type { BlobProperties, Bs, DownloadBlobOptions, ListBlobsOptions, ListBlobsResult, } from './bs.js';
8
+ export { PeerSocketMock } from './peer-socket-mock.js';
9
+ export { SocketMock } from './socket-mock.js';
10
+ export type { Socket } from './socket.js';
@@ -0,0 +1,48 @@
1
+ import { Bs } from './bs.ts';
2
+ import { Socket } from './socket.ts';
3
+ /**
4
+ * Mock socket implementation that directly invokes Bs methods.
5
+ * Used for testing without network layer - simulates peer connection in-process.
6
+ */
7
+ export declare class PeerSocketMock implements Socket {
8
+ private _bs;
9
+ private _listenersMap;
10
+ connected: boolean;
11
+ disconnected: boolean;
12
+ constructor(_bs: Bs);
13
+ /**
14
+ * Removes a specific listener for the specified event.
15
+ * @param eventName - The event name
16
+ * @param listener - The listener function to remove
17
+ * @returns This socket instance for chaining
18
+ */
19
+ off(eventName: string | symbol, listener: (...args: any[]) => void): this;
20
+ /**
21
+ * Removes all listeners for the specified event, or all listeners if no event is specified.
22
+ * @param eventName - Optional event name
23
+ * @returns This socket instance for chaining
24
+ */
25
+ removeAllListeners(eventName?: string | symbol): this;
26
+ /**
27
+ * Registers an event listener for the specified event.
28
+ * @param eventName - The event name
29
+ * @param listener - The listener function to register
30
+ * @returns This socket instance for chaining
31
+ */
32
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
33
+ /**
34
+ * Simulates a connection event.
35
+ */
36
+ connect(): this;
37
+ /**
38
+ * Simulates a disconnection event.
39
+ */
40
+ disconnect(): this;
41
+ /**
42
+ * Emits an event, invoking the corresponding method on the Bs instance.
43
+ * @param eventName - The event name
44
+ * @param args - Event arguments
45
+ * @returns True if the event was handled
46
+ */
47
+ emit(eventName: string | symbol, ...args: unknown[]): boolean;
48
+ }
@@ -0,0 +1,26 @@
1
+ import { Socket } from './socket.ts';
2
+ /**
3
+ * Mock implementation of Socket for testing purposes.
4
+ * Provides full event emitter functionality without network communication.
5
+ */
6
+ export declare class SocketMock implements Socket {
7
+ connected: boolean;
8
+ disconnected: boolean;
9
+ private _listeners;
10
+ private _onceListeners;
11
+ connect(): void;
12
+ disconnect(): void;
13
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
14
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
15
+ off(eventName: string | symbol, listener?: (...args: any[]) => void): this;
16
+ emit(eventName: string | symbol, ...args: any[]): boolean;
17
+ removeAllListeners(eventName?: string | symbol): this;
18
+ listenerCount(eventName: string | symbol): number;
19
+ listeners(eventName: string | symbol): Array<(...args: any[]) => void>;
20
+ eventNames(): Array<string | symbol>;
21
+ reset(): void;
22
+ simulateError(error: Error): void;
23
+ simulateMessage(message: any): void;
24
+ getListeners(): Map<string | symbol, Array<(...args: any[]) => void>>;
25
+ getOnceListeners(): Map<string | symbol, Array<(...args: any[]) => void>>;
26
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Interface for a generic Socket, similar to Node.js EventEmitter.
3
+ * This abstraction allows different transport implementations (WebSocket, Socket.IO, etc.)
4
+ */
5
+ export interface Socket {
6
+ connected: boolean;
7
+ disconnected: boolean;
8
+ connect(): void;
9
+ disconnect(): void;
10
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
11
+ emit(eventName: string | symbol, ...args: any[]): boolean | this;
12
+ off(eventName: string | symbol, listener: (...args: any[]) => void): this;
13
+ removeAllListeners(eventName?: string | symbol): this;
14
+ }
15
+ export declare const socketExample: () => Socket;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/bs",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
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",
@@ -19,30 +19,22 @@
19
19
  "dist"
20
20
  ],
21
21
  "type": "module",
22
- "scripts": {
23
- "build": "pnpx vite build && tsc && node scripts/copy-readme-to-dist.js && node scripts/deploy-conformance-tests.js",
24
- "test": "pnpx vitest run --coverage && pnpm run lint",
25
- "prebuild": "npm run test",
26
- "prepublishOnly": "npm run build",
27
- "lint": "pnpx eslint",
28
- "updateGoldens": "cross-env UPDATE_GOLDENS=true pnpm test"
29
- },
30
22
  "devDependencies": {
31
- "@types/node": "^25.0.9",
32
- "@typescript-eslint/eslint-plugin": "^8.53.0",
33
- "@typescript-eslint/parser": "^8.53.0",
23
+ "@types/node": "^25.0.10",
24
+ "@typescript-eslint/eslint-plugin": "^8.53.1",
25
+ "@typescript-eslint/parser": "^8.53.1",
34
26
  "@vitest/coverage-v8": "^4.0.17",
35
27
  "cross-env": "^10.1.0",
36
28
  "eslint": "^9.39.2",
37
- "eslint-plugin-jsdoc": "^62.0.0",
29
+ "eslint-plugin-jsdoc": "^62.3.0",
38
30
  "eslint-plugin-tsdoc": "^0.5.0",
39
31
  "globals": "^17.0.0",
40
32
  "jsdoc": "^4.0.5",
41
33
  "read-pkg": "^10.0.0",
42
34
  "typescript": "~5.9.3",
43
- "typescript-eslint": "^8.53.0",
35
+ "typescript-eslint": "^8.53.1",
44
36
  "vite": "^7.3.1",
45
- "vite-node": "^5.2.0",
37
+ "vite-node": "^5.3.0",
46
38
  "vite-plugin-dts": "^4.5.4",
47
39
  "vite-tsconfig-paths": "^6.0.4",
48
40
  "vitest": "^4.0.17",
@@ -51,12 +43,13 @@
51
43
  "dependencies": {
52
44
  "@rljson/hash": "^0.0.18",
53
45
  "@rljson/json": "^0.0.23",
54
- "@rljson/rljson": "^0.0.73"
46
+ "@rljson/rljson": "^0.0.74"
55
47
  },
56
- "pnpm": {
57
- "onlyBuiltDependencies": [
58
- "esbuild"
59
- ]
60
- },
61
- "packageManager": "pnpm@10.11.0"
62
- }
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",
53
+ "updateGoldens": "cross-env UPDATE_GOLDENS=true pnpm test"
54
+ }
55
+ }