@quilted/threads
Advanced tools
Comparing version 0.0.0-preview-20240414024637 to 0.0.0-preview-20240519194810
@@ -5,2 +5,3 @@ export declare const RETAIN_METHOD: unique symbol; | ||
export declare const ENCODE_METHOD: unique symbol; | ||
export declare const TRANSFERABLE: unique symbol; | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -1,4 +0,4 @@ | ||
export { retain, release, StackFrame, isMemoryManageable } from './memory.ts'; | ||
export { retain, release, StackFrame, isMemoryManageable, markAsTransferable, } from './memory.ts'; | ||
export type { MemoryManageable, MemoryRetainer } from './memory.ts'; | ||
export { RELEASE_METHOD, RETAIN_METHOD, RETAINED_BY, ENCODE_METHOD, } from './constants.ts'; | ||
export { RELEASE_METHOD, RETAIN_METHOD, RETAINED_BY, ENCODE_METHOD, TRANSFERABLE, } from './constants.ts'; | ||
export { createThread, createThreadFromBroadcastChannel, createThreadFromBrowserWebSocket, createThreadFromIframe, createThreadFromInsideIframe, createThreadFromMessagePort, createThreadFromWebWorker, type ThreadOptions, } from './targets.ts'; | ||
@@ -5,0 +5,0 @@ export { createBasicEncoder } from './encoding.ts'; |
@@ -6,2 +6,9 @@ import { RETAINED_BY, RETAIN_METHOD, RELEASE_METHOD } from './constants.ts'; | ||
/** | ||
* Marks the value as being transferable between threads. The memory for this object | ||
* will be moved to the target thread once the object is sent. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects | ||
*/ | ||
export declare function markAsTransferable<T = unknown>(value: T): T; | ||
/** | ||
* A simple representation of a called function. This object allows this library to | ||
@@ -8,0 +15,0 @@ * release references to functions immediately when the function call that transferred |
# @quilted/threads | ||
## 0.0.0-preview-20240414024637 | ||
## 0.0.0-preview-20240519194810 | ||
### Patch Changes | ||
- Upgrade Preact and signal dependencies | ||
- Add `markAsTransferable` to define values to transfer across threads | ||
## 2.1.3 | ||
### Patch Changes | ||
- [`8477c13`](https://github.com/lemonmade/quilt/commit/8477c1398b03311c76886e037851b10bf77b9fba) Thanks [@lemonmade](https://github.com/lemonmade)! - Add `markAsTransferable` to define values to transfer across threads | ||
## 2.1.2 | ||
@@ -10,0 +16,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "0.0.0-preview-20240414024637", | ||
"version": "0.0.0-preview-20240519194810", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "engines": { |
@@ -5,1 +5,2 @@ export const RETAIN_METHOD = Symbol.for('quilt.threads.retain'); | ||
export const ENCODE_METHOD = Symbol.for('quilt.threads.encode'); | ||
export const TRANSFERABLE = Symbol.for('quilt.threads.transferable'); |
@@ -1,2 +0,2 @@ | ||
import {ENCODE_METHOD} from '../constants.ts'; | ||
import {ENCODE_METHOD, TRANSFERABLE} from '../constants.ts'; | ||
import type { | ||
@@ -93,2 +93,8 @@ ThreadEncoder, | ||
if (typeof value === 'object') { | ||
if ((value as any)[TRANSFERABLE]) { | ||
const result: EncodeResult = [value, [value as any]]; | ||
seen.set(value, result); | ||
return result; | ||
} | ||
const transferables: Transferable[] = []; | ||
@@ -95,0 +101,0 @@ const encodeValue = (value: any) => { |
@@ -1,2 +0,8 @@ | ||
export {retain, release, StackFrame, isMemoryManageable} from './memory.ts'; | ||
export { | ||
retain, | ||
release, | ||
StackFrame, | ||
isMemoryManageable, | ||
markAsTransferable, | ||
} from './memory.ts'; | ||
export type {MemoryManageable, MemoryRetainer} from './memory.ts'; | ||
@@ -8,2 +14,3 @@ export { | ||
ENCODE_METHOD, | ||
TRANSFERABLE, | ||
} from './constants.ts'; | ||
@@ -10,0 +17,0 @@ export { |
@@ -1,2 +0,7 @@ | ||
import {RETAINED_BY, RETAIN_METHOD, RELEASE_METHOD} from './constants.ts'; | ||
import { | ||
RETAINED_BY, | ||
RETAIN_METHOD, | ||
RELEASE_METHOD, | ||
TRANSFERABLE, | ||
} from './constants.ts'; | ||
import type {MemoryRetainer, MemoryManageable} from './types.ts'; | ||
@@ -8,2 +13,13 @@ | ||
/** | ||
* Marks the value as being transferable between threads. The memory for this object | ||
* will be moved to the target thread once the object is sent. | ||
* | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects | ||
*/ | ||
export function markAsTransferable<T = unknown>(value: T) { | ||
Object.assign(value as any, {[TRANSFERABLE]: true}); | ||
return value; | ||
} | ||
/** | ||
* A simple representation of a called function. This object allows this library to | ||
@@ -10,0 +26,0 @@ * release references to functions immediately when the function call that transferred |
{ | ||
"extends": "@quilted/craft/typescript/project.json", | ||
"extends": "@quilted/typescript/tsconfig.project.json", | ||
"compilerOptions": { | ||
@@ -4,0 +4,0 @@ "rootDir": "source", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
234011
3467