@sanity/comlink
Advanced tools
Comparing version 1.0.1-canary.0 to 1.1.0
# Changelog | ||
## [1.1.0](https://github.com/sanity-io/visual-editing/compare/comlink-v1.0.0...comlink-v1.1.0) (2024-10-24) | ||
### Features | ||
* **visual-editing:** add package version mismatch warning ([#2040](https://github.com/sanity-io/visual-editing/issues/2040)) ([c112de4](https://github.com/sanity-io/visual-editing/commit/c112de453fc476e666480e5fea7b1b3ae50b6843)) | ||
## 1.0.0 (2024-10-21) | ||
@@ -4,0 +11,0 @@ |
@@ -85,4 +85,4 @@ import { v4 } from "uuid"; | ||
({ context }) => context.parentRef, | ||
({ context, self }) => (console.warn( | ||
`Received no response to message '${context.type}' on client '${context.from}' (ID: '${context.id}').` | ||
({ context, self }) => (context.suppressWarnings || console.warn( | ||
`[@sanity/comlink] Received no response to message '${context.type}' on client '${context.from}' (ID: '${context.id}').` | ||
), context.resolvable?.reject(new Error("No response received")), { type: "request.failed", requestId: self.id }) | ||
@@ -117,2 +117,3 @@ ), | ||
sources: input.sources instanceof Set ? input.sources : /* @__PURE__ */ new Set([input.sources]), | ||
suppressWarnings: input.suppressWarnings, | ||
targetOrigin: input.targetOrigin, | ||
@@ -669,3 +670,3 @@ to: input.to, | ||
resolvable: event.resolvable, | ||
signal: event.signal | ||
options: event.options | ||
} | ||
@@ -694,7 +695,8 @@ ]) | ||
responseTo: request.responseTo, | ||
signal: request.options?.signal, | ||
sources: context.target, | ||
suppressWarnings: request.options?.suppressWarnings, | ||
targetOrigin: context.targetOrigin, | ||
to: context.connectTo, | ||
type: request.type, | ||
signal: request.signal | ||
type: request.type | ||
} | ||
@@ -721,3 +723,3 @@ }); | ||
type: "request", | ||
data: context.buffer.map(({ data, resolvable, signal }) => ({ | ||
data: context.buffer.map(({ data, resolvable, options }) => ({ | ||
data: data.data, | ||
@@ -727,3 +729,3 @@ type: data.type, | ||
resolvable, | ||
signal | ||
options | ||
})) | ||
@@ -749,3 +751,3 @@ })), enqueue.emit(({ context }) => ({ | ||
resolvable: event.resolvable, | ||
signal: event.signal | ||
options: event.options | ||
} | ||
@@ -949,3 +951,3 @@ })), | ||
resolvable, | ||
signal: options?.signal | ||
options | ||
}), resolvable.promise; | ||
@@ -952,0 +954,0 @@ }, stop = () => { |
{ | ||
"name": "@sanity/comlink", | ||
"version": "1.0.1-canary.0", | ||
"version": "1.1.0", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "sanity.io", |
@@ -65,3 +65,3 @@ import {v4 as uuid} from 'uuid' | ||
data: U, | ||
options?: {signal?: AbortSignal}, | ||
options?: {signal?: AbortSignal; suppressWarnings?: boolean}, | ||
) => S extends U ? (S['type'] extends T ? Promise<S['response']> : never) : never | ||
@@ -101,3 +101,6 @@ machine: NodeActorLogic<R, S> | ||
resolvable?: PromiseWithResolvers<S['response']> | ||
signal?: AbortSignal | ||
options?: { | ||
signal?: AbortSignal | ||
suppressWarnings?: boolean | ||
} | ||
}> | ||
@@ -133,3 +136,6 @@ connectionId: string | null | ||
resolvable?: PromiseWithResolvers<S['response']> | ||
signal?: AbortSignal | ||
options?: { | ||
signal?: AbortSignal | ||
suppressWarning?: boolean | ||
} | ||
} | ||
@@ -167,3 +173,3 @@ | {type: 'request.aborted'; requestId: string} | ||
resolvable: event.resolvable, | ||
signal: event.signal, | ||
options: event.options, | ||
}, | ||
@@ -198,7 +204,8 @@ ] | ||
responseTo: request.responseTo, | ||
signal: request.options?.signal, | ||
sources: context.target!, | ||
suppressWarnings: request.options?.suppressWarnings, | ||
targetOrigin: context.targetOrigin!, | ||
to: context.connectTo, | ||
type: request.type, | ||
signal: request.signal, | ||
}, | ||
@@ -235,3 +242,3 @@ }) | ||
type: 'request', | ||
data: context.buffer.map(({data, resolvable, signal}) => ({ | ||
data: context.buffer.map(({data, resolvable, options}) => ({ | ||
data: data.data, | ||
@@ -241,3 +248,3 @@ type: data.type, | ||
resolvable, | ||
signal, | ||
options, | ||
})), | ||
@@ -270,3 +277,3 @@ })) | ||
resolvable: event.resolvable, | ||
signal: event.signal, | ||
options: event.options, | ||
}, | ||
@@ -506,3 +513,6 @@ } | ||
const fetch = (data: WithoutResponse<S>, options?: {signal?: AbortSignal}) => { | ||
const fetch = ( | ||
data: WithoutResponse<S>, | ||
options?: {signal?: AbortSignal; suppressWarnings?: boolean}, | ||
) => { | ||
const resolvable = Promise.withResolvers<S['response']>() | ||
@@ -513,3 +523,3 @@ actor.send({ | ||
resolvable, | ||
signal: options?.signal, | ||
options, | ||
}) | ||
@@ -516,0 +526,0 @@ return resolvable.promise as never |
@@ -39,2 +39,3 @@ import {EMPTY, filter, fromEvent, map, take, takeUntil, type Observable} from 'rxjs' | ||
signal: AbortSignal | undefined | ||
suppressWarnings: boolean | undefined | ||
sources: Set<MessageEventSource> | ||
@@ -88,2 +89,3 @@ targetOrigin: string | ||
sources: Set<MessageEventSource> | MessageEventSource | ||
suppressWarnings?: boolean | ||
targetOrigin: string | ||
@@ -156,6 +158,8 @@ to: string | ||
({context, self}) => { | ||
// eslint-disable-next-line no-console | ||
console.warn( | ||
`Received no response to message '${context.type}' on client '${context.from}' (ID: '${context.id}').`, | ||
) | ||
if (!context.suppressWarnings) { | ||
// eslint-disable-next-line no-console | ||
console.warn( | ||
`[@sanity/comlink] Received no response to message '${context.type}' on client '${context.from}' (ID: '${context.id}').`, | ||
) | ||
} | ||
context.resolvable?.reject(new Error('No response received')) | ||
@@ -196,2 +200,3 @@ return {type: 'request.failed', requestId: self.id} | ||
sources: input.sources instanceof Set ? input.sources : new Set([input.sources]), | ||
suppressWarnings: input.suppressWarnings, | ||
targetOrigin: input.targetOrigin, | ||
@@ -198,0 +203,0 @@ to: input.to, |
@@ -48,3 +48,6 @@ import { | ||
resolvable?: PromiseWithResolvers<S['response']> | ||
signal?: AbortSignal | ||
options?: { | ||
signal?: AbortSignal | ||
suppressWarnings?: boolean | ||
} | ||
} | ||
@@ -51,0 +54,0 @@ |
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 too big to display
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
753400
10661
0