osra 0.3.3 → 0.4.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.
@@ -1,20 +1,9 @@
1
1
  import { transfer } from '../revivables/transfer';
2
2
  export { transfer };
3
- /**
4
- * Walk a boxed message and collect the list of Transferable references that
5
- * should be moved (rather than cloned) when calling postMessage.
6
- *
7
- * The rules are:
8
- * 1. Must-transfer types (MessagePort, streams, OffscreenCanvas) are always
9
- * included — structured clone cannot represent them.
10
- * 2. Clonable types (SharedArrayBuffer) are skipped entirely.
11
- * 3. Other Transferable types (ArrayBuffer, ImageBitmap) are included only
12
- * when the walker is inside a non-degraded transfer box — i.e. when the
13
- * user explicitly opted into move semantics at the send site via
14
- * transfer() AND the platform supports transferring.
15
- *
16
- * The transfer intent is carried on the wire by the transfer revivable box;
17
- * recognising it structurally here (without importing the module) is all the
18
- * coupling this file needs.
19
- */
3
+ /** Walk a boxed message and collect Transferables to move (rather than copy)
4
+ * on postMessage:
5
+ * 1. Must-transfer types are always included.
6
+ * 2. Clonable types (SharedArrayBuffer) are skipped.
7
+ * 3. Other Transferables are included only inside a non-degraded transfer
8
+ * box (user opted in AND the platform supports transferring). */
20
9
  export declare const getTransferableObjects: (value: unknown) => Transferable[];
@@ -9,14 +9,14 @@ declare const typedArrayConstructorsByName: {
9
9
  readonly Uint16Array: Uint16ArrayConstructor;
10
10
  readonly Int32Array: Int32ArrayConstructor;
11
11
  readonly Uint32Array: Uint32ArrayConstructor;
12
- readonly Float16Array: Float16ArrayConstructor;
12
+ readonly Float16Array: Float16ArrayConstructor | undefined;
13
13
  readonly Float32Array: Float32ArrayConstructor;
14
14
  readonly Float64Array: Float64ArrayConstructor;
15
15
  readonly BigInt64Array: BigInt64ArrayConstructor;
16
16
  readonly BigUint64Array: BigUint64ArrayConstructor;
17
17
  };
18
18
  export type TypedArrayType = keyof typeof typedArrayConstructorsByName;
19
- export type TypedArrayConstructor = (typeof typedArrayConstructorsByName)[TypedArrayType];
19
+ export type TypedArrayConstructor = NonNullable<(typeof typedArrayConstructorsByName)[TypedArrayType]>;
20
20
  export type TypedArray = InstanceType<TypedArrayConstructor>;
21
21
  export declare const typedArrayToType: (value: TypedArray) => TypedArrayType;
22
22
  export declare const typedArrayTypeToTypedArrayConstructor: (value: TypedArrayType) => TypedArrayConstructor;
@@ -28,8 +28,8 @@ export declare const isDedicatedWorker: (value: unknown) => value is DedicatedWo
28
28
  export declare const isSharedWorker: (value: unknown) => value is SharedWorker;
29
29
  export declare const isOsraMessage: (value: unknown) => value is Message;
30
30
  type AnyConstructor = abstract new (...args: any[]) => unknown;
31
- /** True if `value` is an instance of any of the given (possibly undefined-on-this-platform)
32
- * constructors. Tolerates missing globals so callers don't have to guard each one. */
31
+ /** True if `value` is an instance of any of the given constructors.
32
+ * Tolerates undefined entries (constructors missing on this platform). */
33
33
  export declare const instanceOfAny: (value: unknown, ctors: readonly (AnyConstructor | undefined)[]) => boolean;
34
34
  export declare const isClonable: (value: unknown) => boolean;
35
35
  export declare const isTransferable: (value: unknown) => value is Transferable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osra",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Easy communication between workers",
5
5
  "files": [
6
6
  "build"
@@ -10,6 +10,8 @@
10
10
  "scripts": {
11
11
  "build": "vite build && tsgo --declaration --emitDeclarationOnly",
12
12
  "build-watch": "vite build --watch",
13
+ "clean": "rimraf build",
14
+ "prepublishOnly": "npm run clean && npm run build",
13
15
  "build-test": "vite build --config vite.test.config.ts",
14
16
  "build-test-watch": "vite build --config vite.test.config.ts --watch",
15
17
  "dev": "concurrently \"npm run build-test-watch\"",
@@ -23,8 +25,7 @@
23
25
  "clean-coverage": "rimraf .nyc_output coverage",
24
26
  "type-check": "tsgo --noEmit && tsgo --noEmit -p tsconfig.tests.json",
25
27
  "start-server": "http-server -p 3000",
26
- "build-extension-test": "vite build --config vite.extension-test.config.ts",
27
- "build-extension-test-watch": "vite build --config vite.extension-test.config.ts --watch",
28
+ "build-extension-test": "node build-extension-test.mjs",
28
29
  "test-extension": "npm run build-extension-test && npx playwright test -c playwright.extension.config.ts"
29
30
  },
30
31
  "repository": {