osra 0.5.8 → 0.6.0
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 +4 -4
- package/build/connections/bidirectional.d.ts +1 -1
- package/build/index.js +491 -509
- package/build/index.js.map +1 -1
- package/build/revivables/fallbacks.d.ts +2 -2
- package/build/revivables/index.d.ts +1 -2
- package/build/types.d.ts +5 -5
- package/package.json +5 -5
- package/build/revivables/blob.d.ts +0 -17
|
@@ -89,7 +89,7 @@ declare const TYPED_CLONABLE_CTORS: readonly [{
|
|
|
89
89
|
new (): RTCCertificate;
|
|
90
90
|
prototype: RTCCertificate;
|
|
91
91
|
}];
|
|
92
|
-
export type Clonable = InstanceType<
|
|
92
|
+
export type Clonable = InstanceType<typeof TYPED_CLONABLE_CTORS[number]>;
|
|
93
93
|
export type BoxedClonable = BoxBaseType<'clonable'>;
|
|
94
94
|
export declare const clonable: {
|
|
95
95
|
readonly type: 'clonable';
|
|
@@ -117,7 +117,7 @@ declare const TYPED_TRANSFERABLE_CTORS: readonly [{
|
|
|
117
117
|
new (): RTCDataChannel;
|
|
118
118
|
prototype: RTCDataChannel;
|
|
119
119
|
}];
|
|
120
|
-
export type Transferable = InstanceType<
|
|
120
|
+
export type Transferable = InstanceType<typeof TYPED_TRANSFERABLE_CTORS[number]>;
|
|
121
121
|
export type BoxedTransferable = BoxBaseType<'transferable'>;
|
|
122
122
|
export declare const transferable: {
|
|
123
123
|
readonly type: 'transferable';
|
|
@@ -21,7 +21,6 @@ import * as set from './set.js';
|
|
|
21
21
|
import * as bigInt from './bigint.js';
|
|
22
22
|
import * as event from './event.js';
|
|
23
23
|
import * as eventTarget from './event-target.js';
|
|
24
|
-
import * as blob from './blob.js';
|
|
25
24
|
import * as symbol from './symbol.js';
|
|
26
25
|
import * as asyncIterator from './async-iterator.js';
|
|
27
26
|
export { identity } from './identity.js';
|
|
@@ -35,7 +34,7 @@ export type RevivableModule<T extends string = string, T2 = any, T3 extends BoxB
|
|
|
35
34
|
readonly init?: (context: RevivableContext<any>) => void;
|
|
36
35
|
readonly Messages?: T4;
|
|
37
36
|
};
|
|
38
|
-
export declare const defaultRevivableModules: readonly [typeof transfer, typeof identity, typeof arrayBuffer, typeof date, typeof headers, typeof error, typeof typedArray, typeof
|
|
37
|
+
export declare const defaultRevivableModules: readonly [typeof transfer, typeof identity, typeof arrayBuffer, typeof date, typeof headers, typeof error, typeof typedArray, typeof promise, typeof func, typeof messagePort, typeof readableStream, typeof writableStream, typeof abortSignal, typeof response, typeof request, typeof map, typeof set, typeof bigInt, typeof symbol, typeof event, typeof asyncIterator, {
|
|
39
38
|
readonly type: 'nonFiniteNumber';
|
|
40
39
|
readonly isType: (value: unknown) => value is number;
|
|
41
40
|
readonly box: (value: number, context: RevivableContext<any>) => import("./json-primitives.js").BoxedNonFiniteNumber | number;
|
package/build/types.d.ts
CHANGED
|
@@ -11,14 +11,14 @@ export type Jsonable = boolean | null | number | string | {
|
|
|
11
11
|
} | Array<Jsonable>;
|
|
12
12
|
export type Structurable = Jsonable
|
|
13
13
|
/** not really structureable but here for convenience */
|
|
14
|
-
| void | undefined | bigint | Date | RegExp |
|
|
14
|
+
| void | undefined | bigint | Date | RegExp | File | FileList | ArrayBuffer | ArrayBufferView | ImageBitmap | ImageData | {
|
|
15
15
|
[key: string]: Structurable;
|
|
16
16
|
} | Array<Structurable> | Map<Structurable, Structurable> | Set<Structurable>;
|
|
17
17
|
export type StructurableTransferable = Structurable | Transferable | {
|
|
18
18
|
[key: string]: StructurableTransferable;
|
|
19
19
|
} | Array<StructurableTransferable> | Map<StructurableTransferable, StructurableTransferable> | Set<StructurableTransferable>;
|
|
20
20
|
/** "Free" types in `Capable` - narrows to `Jsonable` on JSON transports so
|
|
21
|
-
* user code can't type a `Date`/`
|
|
21
|
+
* user code can't type a `Date`/`File`/etc. that JSON would silently coerce.
|
|
22
22
|
* Modules that DO support JSON (date, map, set, bigint, …) put their type
|
|
23
23
|
* back via `InferRevivables`. */
|
|
24
24
|
type CapableBase<Ctx extends RevivableContext> = IsJsonOnlyTransport<Ctx['transport']> extends true ? Jsonable | undefined | void : StructurableTransferable;
|
|
@@ -26,9 +26,9 @@ export type Capable<TModules extends readonly RevivableModule[] = DefaultRevivab
|
|
|
26
26
|
[key: string]: Capable<TModules, Ctx>;
|
|
27
27
|
} | Array<Capable<TModules, Ctx>> | Map<Capable<TModules, Ctx>, Capable<TModules, Ctx>> | Set<Capable<TModules, Ctx>>;
|
|
28
28
|
/** What a value looks like from the far side of the connection: functions
|
|
29
|
-
* become async (calls cross the wire),
|
|
30
|
-
*
|
|
31
|
-
export type Remote<T> = T extends (...args: infer P) => infer R ? (...args: P) => Promise<Remote<Awaited<R>>> : T extends
|
|
29
|
+
* become async (calls cross the wire), containers map recursively,
|
|
30
|
+
* everything else revives as itself. */
|
|
31
|
+
export type Remote<T> = T extends (...args: infer P) => infer R ? (...args: P) => Promise<Remote<Awaited<R>>> : T extends Promise<infer U> ? Promise<Remote<U>> : T extends Map<any, any> | Set<any> | Date | Error | RegExp | ArrayBuffer | ArrayBufferView | File | FileList | ReadableStream | WritableStream | MessagePort | EventTarget | Request | Response | Headers ? T : T extends AsyncIterable<infer U> ? AsyncIterableIterator<Remote<U>> : T extends ReadonlyArray<unknown> ? {
|
|
32
32
|
[K in keyof T]: Remote<T[K]>;
|
|
33
33
|
} : T extends object ? {
|
|
34
34
|
[K in keyof T]: Remote<T[K]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "osra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Easy communication between workers",
|
|
5
5
|
"files": [
|
|
6
6
|
"build"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"type": "module",
|
|
22
22
|
"scripts": {
|
|
23
|
-
"build": "vite build &&
|
|
23
|
+
"build": "vite build && tsc --declaration --emitDeclarationOnly",
|
|
24
24
|
"build-watch": "vite build --watch",
|
|
25
25
|
"clean": "rimraf build",
|
|
26
26
|
"prepublishOnly": "npm run clean && npm run build",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"test-with-coverage": "npm run build-test && npx playwright test && npm run print-coverage && npm run clean-coverage",
|
|
36
36
|
"print-coverage": "npx nyc report",
|
|
37
37
|
"clean-coverage": "rimraf .nyc_output coverage",
|
|
38
|
-
"type-check": "
|
|
38
|
+
"type-check": "tsc --noEmit && tsc --noEmit -p tsconfig.tests.json",
|
|
39
39
|
"start-server": "http-server -p 3000",
|
|
40
40
|
"build-extension-test": "node build-extension-test.mjs",
|
|
41
41
|
"test-extension": "npm run build-extension-test && npx playwright test -c playwright.extension.config.ts",
|
|
42
|
-
"check-consumer-types": "npm run build &&
|
|
42
|
+
"check-consumer-types": "npm run build && tsc --noEmit -p tsconfig.consumer.json"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
"@types/chrome": "^0.1.27",
|
|
63
63
|
"@types/firefox-webext-browser": "^143.0.0",
|
|
64
64
|
"@types/node": "^25.0.2",
|
|
65
|
-
"@typescript/native-preview": "7.0.0-dev.20260404.1",
|
|
66
65
|
"chai": "^5.3.3",
|
|
67
66
|
"chai-as-promised": "^8.0.1",
|
|
68
67
|
"concurrently": "^9.1.0",
|
|
@@ -70,6 +69,7 @@
|
|
|
70
69
|
"nodemon": "^3.1.10",
|
|
71
70
|
"nyc": "^17.1.0",
|
|
72
71
|
"playwright": "^1.58.2",
|
|
72
|
+
"typescript": "7.0.1-rc",
|
|
73
73
|
"vite": "^8.0.3",
|
|
74
74
|
"vite-plugin-istanbul": "^8.0.0",
|
|
75
75
|
"ws": "^8.21.0"
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { RevivableContext, BoxBase as BoxBaseType } from './utils.js';
|
|
2
|
-
import type { UnderlyingType } from '../utils/type.js';
|
|
3
|
-
import type { BoxedPromise } from './promise.js';
|
|
4
|
-
export declare const type: 'blob';
|
|
5
|
-
export type BoxedBlob<T extends Blob = Blob> = BoxBaseType<typeof type> & {
|
|
6
|
-
mimeType: string;
|
|
7
|
-
} & {
|
|
8
|
-
buffer: BoxedPromise<ArrayBuffer>;
|
|
9
|
-
} & {
|
|
10
|
-
fileName?: string;
|
|
11
|
-
lastModified?: number;
|
|
12
|
-
} & {
|
|
13
|
-
[UnderlyingType]: Promise<T>;
|
|
14
|
-
};
|
|
15
|
-
export declare const isType: (value: unknown) => value is Blob;
|
|
16
|
-
export declare const box: <T extends Blob, T2 extends RevivableContext>(value: T, context: T2) => BoxedBlob<T>;
|
|
17
|
-
export declare const revive: <T extends BoxedBlob, T2 extends RevivableContext>(value: T, context: T2) => T[UnderlyingType];
|