@sanity/comlink
Advanced tools
Comparing version 2.0.1-release.3 to 2.0.1
# Changelog | ||
## [2.0.1](https://github.com/sanity-io/visual-editing/compare/comlink-v2.0.0...comlink-v2.0.1) (2024-12-05) | ||
### Bug Fixes | ||
* **comlink:** require data param if defined on post and fetch methods ([#2262](https://github.com/sanity-io/visual-editing/issues/2262)) ([d2491ad](https://github.com/sanity-io/visual-editing/commit/d2491ad3b7cb373936b9f77273773c7ce330a7f8)) | ||
## [2.0.0](https://github.com/sanity-io/visual-editing/compare/comlink-v1.1.4...comlink-v2.0.0) (2024-11-28) | ||
@@ -4,0 +11,0 @@ |
@@ -600,3 +600,4 @@ import { v4 } from "uuid"; | ||
} | ||
const post = (type, data) => { | ||
const post = (...params) => { | ||
const [type, data] = params; | ||
connections.forEach((connection) => { | ||
@@ -603,0 +604,0 @@ connection.post(type, data); |
{ | ||
"name": "@sanity/comlink", | ||
"version": "2.0.1-release.3", | ||
"version": "2.0.1", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "sanity.io", |
@@ -65,3 +65,5 @@ import {v4 as uuid} from 'uuid' | ||
onStatus: (handler: (status: Status) => void) => () => void | ||
post: <T extends S['type'], U extends Extract<S, {type: T}>>(type: T, data?: U['data']) => void | ||
post: <T extends S['type'], U extends Extract<S, {type: T}>>( | ||
...params: (U['data'] extends undefined ? [T] : never) | [T, U['data']] | ||
) => void | ||
setTarget: (target: MessageEventSource) => void | ||
@@ -514,3 +516,6 @@ start: () => () => void | ||
const post = <T extends S['type'], U extends Extract<S, {type: T}>>(type: T, data: U['data']) => { | ||
const post = <T extends S['type'], U extends Extract<S, {type: T}>>( | ||
type: T, | ||
data?: U['data'], | ||
) => { | ||
const _data = {type, data} as WithoutResponse<U> | ||
@@ -517,0 +522,0 @@ actor.send({type: 'post', data: _data}) |
@@ -32,3 +32,5 @@ import { | ||
onStatus: (handler: (event: StatusEvent) => void) => void | ||
post: <T extends S['type'], U extends Extract<S, {type: T}>>(type: T, data?: U['data']) => void | ||
post: <T extends S['type'], U extends Extract<S, {type: T}>>( | ||
...params: (U['data'] extends undefined ? [T] : never) | [T, U['data']] | ||
) => void | ||
start: () => () => void | ||
@@ -202,3 +204,4 @@ stop: () => void | ||
const post: ChannelInstance<S, R>['post'] = (type, data) => { | ||
const post: ChannelInstance<S, R>['post'] = (...params) => { | ||
const [type, data] = params | ||
connections.forEach((connection) => { | ||
@@ -205,0 +208,0 @@ connection.post(type, data) |
@@ -65,5 +65,6 @@ import {v4 as uuid} from 'uuid' | ||
fetch: <T extends S['type'], U extends Extract<S, {type: T}>>( | ||
type: T, | ||
data?: U['data'], | ||
options?: {signal?: AbortSignal; suppressWarnings?: boolean}, | ||
...params: | ||
| (U['data'] extends undefined ? [T] : never) | ||
| [T, U['data']] | ||
| [T, U['data'], {signal?: AbortSignal; suppressWarnings?: boolean}] | ||
) => S extends U ? (S['type'] extends T ? Promise<S['response']> : never) : never | ||
@@ -76,3 +77,5 @@ machine: NodeActorLogic<S, R> | ||
onStatus: (handler: (status: Status) => void) => () => void | ||
post: <T extends S['type'], U extends Extract<S, {type: T}>>(type: T, data?: U['data']) => void | ||
post: <T extends S['type'], U extends Extract<S, {type: T}>>( | ||
...params: (U['data'] extends undefined ? [T] : never) | [T, U['data']] | ||
) => void | ||
start: () => () => void | ||
@@ -521,3 +524,6 @@ stop: () => void | ||
const post = <T extends S['type'], U extends Extract<S, {type: T}>>(type: T, data: U['data']) => { | ||
const post = <T extends S['type'], U extends Extract<S, {type: T}>>( | ||
type: T, | ||
data?: U['data'], | ||
) => { | ||
const _data = {type, data} as WithoutResponse<U> | ||
@@ -529,3 +535,3 @@ actor.send({type: 'post', data: _data}) | ||
type: T, | ||
data: U['data'], | ||
data?: U['data'], | ||
options?: { | ||
@@ -532,0 +538,0 @@ responseTimeout?: number |
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
776036
10854
0