osra 0.6.2 → 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/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
- } | Array<Jsonable>;
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
- } | Array<Structurable> | Map<Structurable, Structurable> | Set<Structurable>;
17
- export type StructurableTransferable = Structurable | Transferable | {
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
- } | Array<StructurableTransferable> | Map<StructurableTransferable, StructurableTransferable> | Set<StructurableTransferable>;
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
- } | Array<Capable<TModules, Ctx>> | Map<Capable<TModules, Ctx>, Capable<TModules, Ctx>> | Set<Capable<TModules, Ctx>>;
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. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osra",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Easy communication between workers",
5
5
  "homepage": "https://github.com/Banou26/osra#readme",
6
6
  "bugs": {