osra 0.6.1 → 0.6.3
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 +23 -24
- package/build/connections/utils.d.ts +3 -1
- package/build/index.js +12 -9
- package/build/index.js.map +1 -1
- package/build/revivables/fallbacks.d.ts +4 -2
- package/build/revivables/typed-array.d.ts +2 -1
- package/build/types.d.ts +11 -5
- package/build/utils/type-guards.d.ts +1 -1
- package/package.json +23 -19
|
@@ -91,10 +91,11 @@ declare const TYPED_CLONABLE_CTORS: readonly [{
|
|
|
91
91
|
}];
|
|
92
92
|
export type Clonable = InstanceType<typeof TYPED_CLONABLE_CTORS[number]>;
|
|
93
93
|
export type BoxedClonable = BoxBaseType<'clonable'>;
|
|
94
|
+
declare const isClonable: (value: unknown) => value is Clonable;
|
|
94
95
|
export declare const clonable: {
|
|
95
96
|
readonly type: 'clonable';
|
|
96
97
|
readonly capableOnly: true;
|
|
97
|
-
readonly isType:
|
|
98
|
+
readonly isType: typeof isClonable;
|
|
98
99
|
readonly box: (value: Clonable, _context: RevivableContext<any>) => Clonable;
|
|
99
100
|
readonly revive: (value: BoxedClonable, _context: RevivableContext<any>) => Clonable;
|
|
100
101
|
};
|
|
@@ -119,10 +120,11 @@ declare const TYPED_TRANSFERABLE_CTORS: readonly [{
|
|
|
119
120
|
}];
|
|
120
121
|
export type Transferable = InstanceType<typeof TYPED_TRANSFERABLE_CTORS[number]>;
|
|
121
122
|
export type BoxedTransferable = BoxBaseType<'transferable'>;
|
|
123
|
+
declare const isTransferable: (value: unknown) => value is Transferable;
|
|
122
124
|
export declare const transferable: {
|
|
123
125
|
readonly type: 'transferable';
|
|
124
126
|
readonly capableOnly: true;
|
|
125
|
-
readonly isType:
|
|
127
|
+
readonly isType: typeof isTransferable;
|
|
126
128
|
readonly box: (value: Transferable, _context: RevivableContext<any>) => Transferable;
|
|
127
129
|
readonly revive: (value: BoxedTransferable, _context: RevivableContext<any>) => Transferable;
|
|
128
130
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RevivableContext, UnderlyingType, BoxedBuffer } from './utils.js';
|
|
2
2
|
import type { TypedArray, TypedArrayType } from '../utils/type-guards.js';
|
|
3
3
|
import { BoxBase } from './utils.js';
|
|
4
|
+
import { isTypedArray } from '../utils/type-guards.js';
|
|
4
5
|
export declare const type: 'typedArray';
|
|
5
6
|
type BoxedTypedArray<T extends TypedArray, T2 extends RevivableContext> = typeof BoxBase & {
|
|
6
7
|
type: typeof type;
|
|
@@ -9,7 +10,7 @@ type BoxedTypedArray<T extends TypedArray, T2 extends RevivableContext> = typeof
|
|
|
9
10
|
} & BoxedBuffer<T2> & {
|
|
10
11
|
[UnderlyingType]: T;
|
|
11
12
|
};
|
|
12
|
-
export declare const isType:
|
|
13
|
+
export declare const isType: typeof isTypedArray;
|
|
13
14
|
export declare const box: <T extends TypedArray, T2 extends RevivableContext>(value: T, context: T2) => BoxedTypedArray<T, T2>;
|
|
14
15
|
export declare const revive: <T extends BoxedTypedArray<TypedArray, RevivableContext>>(value: T, _context: RevivableContext) => T[UnderlyingType];
|
|
15
16
|
export {};
|
package/build/types.d.ts
CHANGED
|
@@ -8,15 +8,21 @@ export declare const OSRA_BOX: '__OSRA_BOX__';
|
|
|
8
8
|
export type Uuid = `${string}-${string}-${string}-${string}-${string}`;
|
|
9
9
|
export type Jsonable = boolean | null | number | string | {
|
|
10
10
|
[key: string]: Jsonable;
|
|
11
|
-
} |
|
|
11
|
+
} | ReadonlyArray<Jsonable>;
|
|
12
12
|
export type Structurable = Jsonable
|
|
13
13
|
/** not really structureable but here for convenience */
|
|
14
14
|
| void | undefined | bigint | Date | RegExp | File | FileList | ArrayBuffer | ArrayBufferView | ImageBitmap | ImageData | {
|
|
15
15
|
[key: string]: Structurable;
|
|
16
|
-
} |
|
|
17
|
-
|
|
16
|
+
} | ReadonlyArray<Structurable> | Map<Structurable, Structurable> | Set<Structurable>;
|
|
17
|
+
/** lib.dom declares some `Transferable` members as EMPTY interfaces
|
|
18
|
+
* (`MediaSourceHandle` as of TS 5.x/7.x). With no members they structurally
|
|
19
|
+
* absorb every object type, which would let `WeakMap` & co. slip past the
|
|
20
|
+
* `Capable` check unnoticed. Drop member-less types from the compile-time
|
|
21
|
+
* union; runtime transfer of those exotic types is unaffected. */
|
|
22
|
+
type NonAbsorbing<T> = T extends unknown ? keyof T extends never ? never : T : never;
|
|
23
|
+
export type StructurableTransferable = Structurable | NonAbsorbing<Transferable> | {
|
|
18
24
|
[key: string]: StructurableTransferable;
|
|
19
|
-
} |
|
|
25
|
+
} | ReadonlyArray<StructurableTransferable> | Map<StructurableTransferable, StructurableTransferable> | Set<StructurableTransferable>;
|
|
20
26
|
/** "Free" types in `Capable` - narrows to `Jsonable` on JSON transports so
|
|
21
27
|
* user code can't type a `Date`/`File`/etc. that JSON would silently coerce.
|
|
22
28
|
* Modules that DO support JSON (date, map, set, bigint, …) put their type
|
|
@@ -24,7 +30,7 @@ export type StructurableTransferable = Structurable | Transferable | {
|
|
|
24
30
|
type CapableBase<Ctx extends RevivableContext> = IsJsonOnlyTransport<Ctx['transport']> extends true ? Jsonable | undefined | void : StructurableTransferable;
|
|
25
31
|
export type Capable<TModules extends readonly RevivableModule[] = DefaultRevivableModules, Ctx extends RevivableContext = RevivableContext> = CapableBase<Ctx> | InferRevivables<TModules, Ctx> | {
|
|
26
32
|
[key: string]: Capable<TModules, Ctx>;
|
|
27
|
-
} |
|
|
33
|
+
} | ReadonlyArray<Capable<TModules, Ctx>> | Map<Capable<TModules, Ctx>, Capable<TModules, Ctx>> | Set<Capable<TModules, Ctx>>;
|
|
28
34
|
/** What a value looks like from the far side of the connection: functions
|
|
29
35
|
* become async (calls cross the wire), containers map recursively,
|
|
30
36
|
* everything else revives as itself. */
|
|
@@ -39,7 +39,7 @@ export declare const instanceOfAny: (value: unknown, ctors: readonly (AnyConstru
|
|
|
39
39
|
export declare const isSharedArrayBuffer: (value: unknown) => boolean;
|
|
40
40
|
/** @deprecated Renamed - this only ever checked SharedArrayBuffer, unlike
|
|
41
41
|
* the unrelated clonable fallback module. Use isSharedArrayBuffer. */
|
|
42
|
-
export declare const isClonable:
|
|
42
|
+
export declare const isClonable: typeof isSharedArrayBuffer;
|
|
43
43
|
export declare const isTransferable: (value: unknown) => value is Transferable;
|
|
44
44
|
export type WebExtRuntime = Runtime.Static;
|
|
45
45
|
export declare const isWebExtensionRuntime: (value: unknown) => value is WebExtRuntime;
|
package/package.json
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "osra",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Easy communication between workers",
|
|
5
|
+
"homepage": "https://github.com/Banou26/osra#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/Banou26/osra/issues"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": "Banou26",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/Banou26/osra.git"
|
|
14
|
+
},
|
|
5
15
|
"files": [
|
|
6
16
|
"build"
|
|
7
17
|
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"sideEffects": false,
|
|
8
20
|
"main": "build/index.js",
|
|
9
21
|
"types": "./build/index.d.ts",
|
|
10
22
|
"exports": {
|
|
@@ -18,14 +30,13 @@
|
|
|
18
30
|
},
|
|
19
31
|
"./package.json": "./package.json"
|
|
20
32
|
},
|
|
21
|
-
"type": "module",
|
|
22
33
|
"scripts": {
|
|
23
|
-
"build": "
|
|
24
|
-
"build-watch": "
|
|
34
|
+
"build": "vp build && tsc --declaration --emitDeclarationOnly",
|
|
35
|
+
"build-watch": "vp build --watch",
|
|
25
36
|
"clean": "rimraf build",
|
|
26
37
|
"prepublishOnly": "npm run clean && npm run build",
|
|
27
|
-
"build-test": "
|
|
28
|
-
"build-test-watch": "
|
|
38
|
+
"build-test": "vp build --config vite.test.config.ts",
|
|
39
|
+
"build-test-watch": "vp build --config vite.test.config.ts --watch",
|
|
29
40
|
"dev": "concurrently \"npm run build-test-watch\"",
|
|
30
41
|
"_dev": "concurrently \"npm run build-watch\" \"npm run build-test-watch\" \"npm run test-watch\"",
|
|
31
42
|
"dev2": "concurrently \"npm run build-watch\" \"npm run build-test-watch\" \"npm run test-watch-headful\"",
|
|
@@ -41,16 +52,6 @@
|
|
|
41
52
|
"test-extension": "npm run build-extension-test && npx playwright test -c playwright.extension.config.ts",
|
|
42
53
|
"check-consumer-types": "npm run build && tsc --noEmit -p tsconfig.consumer.json"
|
|
43
54
|
},
|
|
44
|
-
"repository": {
|
|
45
|
-
"type": "git",
|
|
46
|
-
"url": "git+https://github.com/Banou26/osra.git"
|
|
47
|
-
},
|
|
48
|
-
"author": "Banou26",
|
|
49
|
-
"license": "MIT",
|
|
50
|
-
"bugs": {
|
|
51
|
-
"url": "https://github.com/Banou26/osra/issues"
|
|
52
|
-
},
|
|
53
|
-
"homepage": "https://github.com/Banou26/osra#readme",
|
|
54
55
|
"dependencies": {
|
|
55
56
|
"@types/webextension-polyfill": "^0.12.4"
|
|
56
57
|
},
|
|
@@ -69,10 +70,13 @@
|
|
|
69
70
|
"nodemon": "^3.1.10",
|
|
70
71
|
"nyc": "^17.1.0",
|
|
71
72
|
"playwright": "^1.58.2",
|
|
72
|
-
"typescript": "7.0.
|
|
73
|
-
"vite": "
|
|
73
|
+
"typescript": "^7.0.2",
|
|
74
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
|
|
74
75
|
"vite-plugin-istanbul": "^8.0.0",
|
|
76
|
+
"vite-plus": "0.2.4",
|
|
75
77
|
"ws": "^8.21.0"
|
|
76
78
|
},
|
|
77
|
-
"
|
|
79
|
+
"overrides": {
|
|
80
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.4"
|
|
81
|
+
}
|
|
78
82
|
}
|