@sanity/sdk 3.11.0 → 3.12.0-next.20261030092717
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/dist/_exports/_internal.d.ts +7 -7
- package/dist/_exports/_internal.d.ts.map +1 -1
- package/dist/_exports/_internal.js +8 -8
- package/dist/_exports/agent.js +1 -1
- package/dist/_exports/collaboration.js +4 -4
- package/dist/_exports/dashboard.d.ts +1 -1
- package/dist/_exports/dashboard.js +2 -2
- package/dist/{authStore-CocBiuYt.js → authStore-A65hzFu3.js} +54 -11
- package/dist/authStore-A65hzFu3.js.map +1 -0
- package/dist/{buildCommentThreads-B84_NALk.js → buildCommentThreads-DvEkmq6P.js} +4 -4
- package/dist/{buildCommentThreads-B84_NALk.js.map → buildCommentThreads-DvEkmq6P.js.map} +1 -1
- package/dist/{bus-BVIS4Lwj.d.ts → bus-DEoWx5fV.d.ts} +20 -1
- package/dist/bus-DEoWx5fV.d.ts.map +1 -0
- package/dist/{clientStore-DtQjmYYe.js → clientStore-C20oRB2w.js} +2 -2
- package/dist/{clientStore-DtQjmYYe.js.map → clientStore-C20oRB2w.js.map} +1 -1
- package/dist/{commentFieldPath-C9ycqDbU.js → commentFieldPath-BbKsoQiW.js} +2 -38
- package/dist/commentFieldPath-BbKsoQiW.js.map +1 -0
- package/dist/index.js +6 -6
- package/dist/{topicStore-g-C28bpz.js → topicStore-BKyvThWM.js} +14 -11
- package/dist/topicStore-BKyvThWM.js.map +1 -0
- package/dist/{version-fBDdKP8q.js → version-DQE186TN.js} +5 -5
- package/dist/{version-fBDdKP8q.js.map → version-DQE186TN.js.map} +1 -1
- package/package.json +2 -2
- package/src/dashboard/messageBus/bus.test.ts +46 -0
- package/src/dashboard/messageBus/bus.ts +40 -15
- package/src/dashboard/messageBus/store.test.ts +10 -0
- package/src/dashboard/messageBus/store.ts +13 -11
- package/dist/authStore-CocBiuYt.js.map +0 -1
- package/dist/bus-BVIS4Lwj.d.ts.map +0 -1
- package/dist/commentFieldPath-C9ycqDbU.js.map +0 -1
- package/dist/topicStore-g-C28bpz.js.map +0 -1
|
@@ -2,7 +2,7 @@ import { m as SanityConfig, s as DocumentResource, t as SanityInstance } from ".
|
|
|
2
2
|
import { n as StateSource, r as BoundStoreAction } from "../createStateSourceAction-CzAwbNjw.js";
|
|
3
3
|
import { Bi as getSignInMethodLabel, Bt as FavoriteStatusResponse, Dt as GetUsersOptions, G as getQueryKey, Li as ProjectAccessErrorDetails, Ri as getProjectAccessErrorDetails, Vt as SetFavoriteInput, _a as MutationDefinition, ba as defineMutation, ct as PreviewValue, fa as CacheTag, fr as ApplicationStatus, ga as FetcherSnapshot, ha as FetcherDefinition, ma as Fetcher, mi as parseCommentsOptionsKey, ni as createLogger, or as getTopicState, pa as CacheWriter, pi as getCommentsOptionsKey, pr as ApplicationStatusUpdate, q as parseQueryKey, r as ApplicationBase, sr as resolveTopic, st as PreviewQueryResult, va as MutationResult, ya as defineFetcher, zt as FavoriteDocumentContext } from "../applications-DEghtEl9.js";
|
|
4
4
|
import { c as parseCommentsQueryOptionsKey, l as parseDocumentCommentsOptionsKey, o as getCommentsQueryOptionsKey, s as getDocumentCommentsOptionsKey } from "../commentsOptions-DuLgrFc5.js";
|
|
5
|
-
import { b as resetMessageBus, n as InstallMessageBusOptions, o as MessageBusConnection, s as MessageBusEmitOptions, v as installMessageBus, x as workerMessages, y as isMessageBusEnvironment } from "../bus-
|
|
5
|
+
import { b as resetMessageBus, n as InstallMessageBusOptions, o as MessageBusConnection, s as MessageBusEmitOptions, v as installMessageBus, x as workerMessages, y as isMessageBusEnvironment } from "../bus-DEoWx5fV.js";
|
|
6
6
|
import { Auth, ClientError, SanityClient } from "@sanity/client";
|
|
7
7
|
import { Observable } from "rxjs";
|
|
8
8
|
import { CurrentUser } from "@sanity/types";
|
|
@@ -40,14 +40,14 @@ export declare function getClientErrorApiBody(error: ClientError): ApiErrorBody
|
|
|
40
40
|
*
|
|
41
41
|
* @remarks
|
|
42
42
|
* One connection is made per {@link SanityInstance}, carrying that window's
|
|
43
|
-
* module identity
|
|
44
|
-
* connection. When no host bus is
|
|
45
|
-
* caching, so a later call retries
|
|
46
|
-
* a
|
|
47
|
-
* new connection.
|
|
43
|
+
* module identity and, when a host rendered it, its parent's key. The first
|
|
44
|
+
* caller wins; later callers get the cached connection. When no host bus is
|
|
45
|
+
* installed it returns `undefined` without caching, so a later call retries
|
|
46
|
+
* once a host installs the bus. It throws for a disposed instance: its dispose
|
|
47
|
+
* has already run, so nothing would close a new connection.
|
|
48
48
|
* @internal
|
|
49
49
|
*/
|
|
50
|
-
export declare function getDashboardMessageBus(instance: SanityInstance, moduleId?: string): MessageBusConnection | undefined;
|
|
50
|
+
export declare function getDashboardMessageBus(instance: SanityInstance, moduleId?: string, parentKey?: string): MessageBusConnection | undefined;
|
|
51
51
|
/**
|
|
52
52
|
* Returns the instance's message bus connection, or throws when no dashboard host has
|
|
53
53
|
* installed a bus. `action` names what the caller was about to do, e.g. `read topic "x"`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_internal.d.ts","names":["_$______store_createActionBinder0.BoundStoreAction","_$___store_fetcherStore0.MutationResult"],"sources":["../../src/applications/applicationOrigin.ts","../../src/auth/authMode.ts","../../src/auth/utils.ts","../../src/dashboard/messageBus/store.ts","../../src/dashboard/messageBus/workerStore.ts","../../src/favorites/busFavorites.ts","../../src/preview/previewConstants.ts","../../src/preview/previewProjectionUtils.ts","../../src/telemetry/telemetryManager.ts","../../src/telemetry/initTelemetry.ts","../../src/users/reducers.ts","../../src/utils/createGroqSearchFilter.ts","../../src/utils/ids.ts","../../src/utils/object.ts"],"mappings":";;;;;;;;;;;;;;;wBAWgB,qBACd,aAAa,KAAK;;;;;;wBCkCJ,eAAe,QAAQ;;KC4I3B;EACV;IAAS;IAAe;IAAsB;IAAqB;;EACnE;EACA;EACA;EACA;;;wBAIc,sBAAsB,OAAO,cAAc;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"_internal.d.ts","names":["_$______store_createActionBinder0.BoundStoreAction","_$___store_fetcherStore0.MutationResult"],"sources":["../../src/applications/applicationOrigin.ts","../../src/auth/authMode.ts","../../src/auth/utils.ts","../../src/dashboard/messageBus/store.ts","../../src/dashboard/messageBus/workerStore.ts","../../src/favorites/busFavorites.ts","../../src/preview/previewConstants.ts","../../src/preview/previewProjectionUtils.ts","../../src/telemetry/telemetryManager.ts","../../src/telemetry/initTelemetry.ts","../../src/users/reducers.ts","../../src/utils/createGroqSearchFilter.ts","../../src/utils/ids.ts","../../src/utils/object.ts"],"mappings":";;;;;;;;;;;;;;;wBAWgB,qBACd,aAAa,KAAK;;;;;;wBCkCJ,eAAe,QAAQ;;KC4I3B;EACV;IAAS;IAAe;IAAsB;IAAqB;;EACnE;EACA;EACA;EACA;;;wBAIc,sBAAsB,OAAO,cAAc;;;;;;;;;;;;;wBCjJ3C,uBACd,UAAU,gBACV,mBACA,qBACC;;;;;;wBAca,2BACd,UAAU,gBACV,iBACC;;;;;;;;;;wBAiBa,uBAAuB,UAAU;;;;;UC/EhC;EACf,KAAK,mBAAmB,UAAU,wBAAwB;EAC1D,UAAU,UAAU;;UAGZ;EACR;KAAW,eAAe;;;;;;;;;;;qBAoBf,iBAAeA,iBAAA,wBAAA,eAAA;;;;;;;;;;;;;;wBCMZ,oBACd,UAAU,gBACV,SAAS,0BACR;;;;;;;wBAwCa,mBAAmB,UAAU,iBAAiB;;;;;;;;qBAejD,iBAAc,UAAA,gBAAA,OAAA,qBAAA,QAAAC,eAAA;;;;;;;qBC7Ed;;;;;;;;;;wBCiDG,6BACd,UAAU,gBACV,kBAAkB,oBAClB,WAAW,mBACV;;;;;;;;;;;;UCrCc;;;;;;;EAOf,gBAAgB;;EAGhB,kBAAkB;IAAO;IAAmB;;;EAG5C,iBAAiB;;EAGjB,SAAS,mBAAmB;;EAG5B;;EAGA;;WAGS,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;wBCjBN,cAAc,UAAU,gBAAgB;;;;;;;wBA8IxC,oBAAoB,UAAU,iBAAiB;;;;;;;;wBAW/C,iBAAiB,UAAU,gBAAgB;;qBCjM9C,cAAW,UACZ,kBAAc,cAAA,gBAAA,WAAA,WAAA,WAOrB;;qBAWQ,gBAAa;EAGxB;EACA;EACA;EACA;EACA;;;;;;;;;;;;;;;wBCYc,uBAAuB;;;;;;;;;;;wBChCvB,SAAS;;;;;;;;;;;wBAsBT;;;;;;wBCIA,eAAe,kBAAkB,gBAAgB,GAC/D,OAAO,GACP,eAAe,MACd,KAAK,GAAG;;;;;;;;wBA2DK,YAAY,GAAG,MAAM,GAAG,OAAO"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-vyAXikos.js";
|
|
2
2
|
import { a as createActionBinder, s as defineStore } from "../createStateSourceAction-BdcaQ2os.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { J as isMessageBusEnvironment, M as getClientErrorApiBody, V as isStudioConfig, X as resetMessageBus, Z as workerMessages, et as createLogger, nt as randomUuid, q as installMessageBus, tt as randomId } from "../authStore-A65hzFu3.js";
|
|
4
|
+
import { n as defineFetcher, r as defineMutation, t as toCommentFieldPath } from "../commentFieldPath-BbKsoQiW.js";
|
|
5
5
|
import { i as pickProperties, n as isObject, t as isDeepEqual } from "../object-CxXlSVg7.js";
|
|
6
|
-
import { n as getClient } from "../clientStore-
|
|
7
|
-
import { a as getDashboardMessageBus, i as resolveTopic, o as isDashboardEnvironment, r as getTopicState, s as requireDashboardMessageBus } from "../topicStore-
|
|
8
|
-
import { C as getProjectAccessErrorDetails, S as toFavoriteDocument, T as getSignInMethodLabel, d as getUsersKey, i as parseQueryKey, n as getQueryKey, p as parseUsersKey, t as CORE_SDK_VERSION } from "../version-
|
|
6
|
+
import { n as getClient } from "../clientStore-C20oRB2w.js";
|
|
7
|
+
import { a as getDashboardMessageBus, i as resolveTopic, o as isDashboardEnvironment, r as getTopicState, s as requireDashboardMessageBus } from "../topicStore-BKyvThWM.js";
|
|
8
|
+
import { C as getProjectAccessErrorDetails, S as toFavoriteDocument, T as getSignInMethodLabel, d as getUsersKey, i as parseQueryKey, n as getQueryKey, p as parseUsersKey, t as CORE_SDK_VERSION } from "../version-DQE186TN.js";
|
|
9
9
|
import "@sanity/client";
|
|
10
10
|
import { EMPTY, catchError, defer, distinctUntilChanged, map, merge } from "rxjs";
|
|
11
11
|
import "@sanity/types";
|
|
@@ -503,9 +503,9 @@ function initTelemetry(instance, projectId) {
|
|
|
503
503
|
environment
|
|
504
504
|
}), Promise.all([
|
|
505
505
|
Promise.resolve().then(() => telemetryManager_exports),
|
|
506
|
-
import("../clientStore-
|
|
507
|
-
import("../authStore-
|
|
508
|
-
import("../authStore-
|
|
506
|
+
import("../clientStore-C20oRB2w.js").then((n) => n.t),
|
|
507
|
+
import("../authStore-A65hzFu3.js").then((n) => n.n),
|
|
508
|
+
import("../authStore-A65hzFu3.js").then((n) => n.B)
|
|
509
509
|
]).then(async ([{ createTelemetryManager }, { getClient }, { getTokenState }, { isStudioConfig }]) => {
|
|
510
510
|
if (instance.isDisposed()) {
|
|
511
511
|
initInFlight.delete(instance), logger.debug("telemetry skipped: instance disposed before imports resolved");
|
package/dist/_exports/agent.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { f as setCleanupTimeout, l as isReleasePerspective, m as isDatasetResource, n as bindActionByResource, o as UPSTREAM_CLOSE_DELAY_MS, s as defineStore, t as createStateSourceAction, u as cleanupTimer } from "../createStateSourceAction-BdcaQ2os.js";
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import { a as compareProjectOrganization, o as observeAppOrganizationId, r as project, t as buildCommentThreads } from "../buildCommentThreads-
|
|
2
|
+
import { a as getClientAuthState, i as getAuthState, nt as randomUuid, o as getCurrentUserState, tt as randomId, v as retryOnCredentialChange } from "../authStore-A65hzFu3.js";
|
|
3
|
+
import { t as toCommentFieldPath } from "../commentFieldPath-BbKsoQiW.js";
|
|
4
|
+
import { a as compareProjectOrganization, o as observeAppOrganizationId, r as project, t as buildCommentThreads } from "../buildCommentThreads-DvEkmq6P.js";
|
|
5
5
|
import { r as omitProperty } from "../object-CxXlSVg7.js";
|
|
6
|
-
import { r as getClientState } from "../clientStore-
|
|
6
|
+
import { r as getClientState } from "../clientStore-C20oRB2w.js";
|
|
7
7
|
import "@sanity/client";
|
|
8
8
|
import { EMPTY, NEVER, Observable, ReplaySubject, catchError, defer, distinctUntilChanged, filter, first, firstValueFrom, groupBy, map, merge, mergeMap, of, pairwise, partition, race, share, startWith, switchMap, take, tap, throwError } from "rxjs";
|
|
9
9
|
import "@sanity/types";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Ar as TopicName, Cr as NavigationLocation, Dr as ReplyOf, Er as RemoteModuleRef, Mr as Topics, Nr as ValueOf, Or as StateTopic, Pr as capabilities, Tr as PayloadOf, _r as DocumentActivity, br as FavoriteDocument, cr as ApplicationActivity, dr as ApplicationContext, gr as DashboardTopics, hr as CapabilityRecord, ir as TopicError, jr as TopicResult, kr as StateTopicDef, lr as ApplicationConfig, mr as Capability, rr as TopicData, ur as ApplicationConfigAppType, vr as EventTopic, wr as NavigationTarget, xr as LocalApplication, yr as EventTopicDef } from "../applications-DEghtEl9.js";
|
|
2
|
-
import { _ as connectMessageBus, a as MessageBusClient, c as MessageBusEmitResult, d as MessageBusErrorDetails, f as MessageBusHost, g as MessageBusStateSource, h as MessageBusQueryOptions, i as MessageBusAbortOptions, l as MessageBusError, m as MessageBusMeta, o as MessageBusConnection, p as MessageBusMessage, r as MessageBus, s as MessageBusEmitOptions, t as ConnectMessageBusOptions, u as MessageBusErrorCode } from "../bus-
|
|
2
|
+
import { _ as connectMessageBus, a as MessageBusClient, c as MessageBusEmitResult, d as MessageBusErrorDetails, f as MessageBusHost, g as MessageBusStateSource, h as MessageBusQueryOptions, i as MessageBusAbortOptions, l as MessageBusError, m as MessageBusMeta, o as MessageBusConnection, p as MessageBusMessage, r as MessageBus, s as MessageBusEmitOptions, t as ConnectMessageBusOptions, u as MessageBusErrorCode } from "../bus-DEoWx5fV.js";
|
|
3
3
|
export { type ApplicationActivity, type ApplicationConfig, type ApplicationConfigAppType, type ApplicationContext, type Capability, type CapabilityRecord, type ConnectMessageBusOptions, type DashboardTopics, type DocumentActivity, type EventTopic, type EventTopicDef, type FavoriteDocument, type LocalApplication, type MessageBus, type MessageBusAbortOptions, type MessageBusClient, type MessageBusConnection, type MessageBusEmitOptions, type MessageBusEmitResult, MessageBusError, type MessageBusErrorCode, type MessageBusErrorDetails, type MessageBusHost, type MessageBusMessage, type MessageBusMeta, type MessageBusQueryOptions, type MessageBusStateSource, type NavigationLocation, type NavigationTarget, type PayloadOf, type RemoteModuleRef, type ReplyOf, type StateTopic, type StateTopicDef, type TopicData, TopicError, type TopicName, type TopicResult, type Topics, type ValueOf, capabilities, connectMessageBus };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { G as MessageBusError, K as connectMessageBus, Q as capabilities } from "../authStore-
|
|
2
|
-
import { t as TopicError } from "../topicStore-
|
|
1
|
+
import { G as MessageBusError, K as connectMessageBus, Q as capabilities } from "../authStore-A65hzFu3.js";
|
|
2
|
+
import { t as TopicError } from "../topicStore-BKyvThWM.js";
|
|
3
3
|
export { MessageBusError, TopicError, capabilities, connectMessageBus };
|
|
@@ -5,6 +5,42 @@ import { BehaviorSubject, EMPTY, Observable, ReplaySubject, Subject, catchError,
|
|
|
5
5
|
import "@sanity/message-protocol";
|
|
6
6
|
import "@sanity/types";
|
|
7
7
|
import { createSelector } from "reselect";
|
|
8
|
+
/**
|
|
9
|
+
* Generates a random ID of the given length from the alphabet `[a-zA-Z0-9]`, the same shape
|
|
10
|
+
* `@sanity/client` and Sanity Studio use for short IDs such as release IDs.
|
|
11
|
+
*
|
|
12
|
+
* Ported from `@sanity/client`'s `generateReleaseId`, which uses rejection sampling to keep
|
|
13
|
+
* the output unbiased. Uses `crypto.getRandomValues`, which unlike `crypto.randomUUID` is
|
|
14
|
+
* also available on insecure origins (plain http).
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
function randomId(length = 8) {
|
|
19
|
+
let id = "";
|
|
20
|
+
for (; id.length < length;) {
|
|
21
|
+
let bytes = crypto.getRandomValues(new Uint8Array(length - id.length));
|
|
22
|
+
for (let byte of bytes) {
|
|
23
|
+
let index = byte & 63;
|
|
24
|
+
index < 62 && (id += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".charAt(index));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return id;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generates a random v4 UUID.
|
|
31
|
+
*
|
|
32
|
+
* Prefers the native `crypto.randomUUID`, which is only available in secure contexts
|
|
33
|
+
* (https, localhost). Falls back to deriving the UUID from `crypto.getRandomValues`,
|
|
34
|
+
* which has no such restriction, so ID generation also works when an app is served over
|
|
35
|
+
* plain http, e.g. when testing from a phone on a local network.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
function randomUuid() {
|
|
40
|
+
if (typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
41
|
+
let bytes = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)), hex = Array.from(bytes, (byte, index) => (index === 6 && (byte = byte & 15 | 64), index === 8 && (byte = byte & 63 | 128), byte.toString(16).padStart(2, "0"))).join("");
|
|
42
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
43
|
+
}
|
|
8
44
|
const LOG_LEVEL_PRIORITY = {
|
|
9
45
|
error: 0,
|
|
10
46
|
warn: 1,
|
|
@@ -276,13 +312,14 @@ function resolveEventSubject(registry, type) {
|
|
|
276
312
|
function settleReply(reply, outcome) {
|
|
277
313
|
reply.settled || (reply.settled = !0, reply.settlePromise ? reply.settlePromise(outcome) : reply.outcomeBeforeAwait = outcome);
|
|
278
314
|
}
|
|
279
|
-
function createEventMessage(appId, moduleId, type, payload, pendingReply) {
|
|
315
|
+
function createEventMessage({ appId, moduleId, key }, type, payload, pendingReply) {
|
|
280
316
|
let message = {
|
|
281
317
|
type,
|
|
282
318
|
payload,
|
|
283
319
|
meta: {
|
|
284
320
|
appId,
|
|
285
321
|
moduleId,
|
|
322
|
+
key,
|
|
286
323
|
timestamp: Date.now()
|
|
287
324
|
},
|
|
288
325
|
reply: (value) => {
|
|
@@ -333,13 +370,13 @@ function createLazyReply(awaitReply) {
|
|
|
333
370
|
finally: (onFinally) => awaitReply().finally(onFinally)
|
|
334
371
|
};
|
|
335
372
|
}
|
|
336
|
-
function emitEvent(registry, type, payload, options,
|
|
373
|
+
function emitEvent(registry, type, payload, options, sender) {
|
|
337
374
|
let hadResponderAtEmission = (registry.responderCounts.get(type) ?? 0) > 0, responderAbort = new AbortController(), pendingReply = {
|
|
338
375
|
responderAbort,
|
|
339
376
|
responderSignal: scopeSignal(options?.signal, responderAbort.signal),
|
|
340
377
|
settled: !1
|
|
341
378
|
};
|
|
342
|
-
resolveEventSubject(registry, type).next(createEventMessage(
|
|
379
|
+
resolveEventSubject(registry, type).next(createEventMessage(sender, type, payload, pendingReply));
|
|
343
380
|
let awaitReply = () => pendingReply.replyPromise ??= createReplyPromise(pendingReply, {
|
|
344
381
|
...options,
|
|
345
382
|
hadResponderAtEmission
|
|
@@ -347,12 +384,12 @@ function emitEvent(registry, type, payload, options, appId, moduleId) {
|
|
|
347
384
|
return createLazyReply(awaitReply);
|
|
348
385
|
}
|
|
349
386
|
const isStateTopic = (registry, type) => registry.topics.get(type)?.kind === "state", canRespond = (registry, ownership, appId) => ownership.type === "any_app" || appId === registry.appId;
|
|
350
|
-
function emit(registry, type, payload, options,
|
|
351
|
-
if (isStateTopic(registry, type)) throw new MessageBusError("OWNERSHIP_MISMATCH", `Cannot emit state topic "${type}" from app "${appId}". The host writes state to each connection through its client handle. Read it with query() or subscribe().`);
|
|
387
|
+
function emit(registry, type, payload, options, sender, connectionSignal) {
|
|
388
|
+
if (isStateTopic(registry, type)) throw new MessageBusError("OWNERSHIP_MISMATCH", `Cannot emit state topic "${type}" from app "${sender.appId}". The host writes state to each connection through its client handle. Read it with query() or subscribe().`);
|
|
352
389
|
return emitEvent(registry, type, payload, {
|
|
353
390
|
...options,
|
|
354
391
|
signal: scopeSignal(options?.signal, registry.resetAbort.signal, connectionSignal)
|
|
355
|
-
},
|
|
392
|
+
}, sender);
|
|
356
393
|
}
|
|
357
394
|
function emitState(registry, connection, type, value) {
|
|
358
395
|
connection.rejections.delete(type), connection.rejectionDetails?.delete(type);
|
|
@@ -538,6 +575,8 @@ function createClient$1(registry, record, compatibility) {
|
|
|
538
575
|
return {
|
|
539
576
|
appId: record.appId,
|
|
540
577
|
moduleId: record.moduleId,
|
|
578
|
+
key: record.key,
|
|
579
|
+
parentKey: record.parentKey,
|
|
541
580
|
closed: record.abort.signal,
|
|
542
581
|
emit: (type, value) => {
|
|
543
582
|
record.abort.signal.aborted ? console.warn(`[sanity-sdk:message-bus] "${type}" not written: connection "${record.moduleId}" has closed`) : emitState(registry, record, type, compatibility.toInstalledEmission(type, value));
|
|
@@ -557,9 +596,11 @@ function createConnectionsSource(registry, self, compatibility, completeOn) {
|
|
|
557
596
|
function createConnection(registry, config) {
|
|
558
597
|
let { appId } = config, moduleId = config.moduleId ?? appId, connectionAbort = new AbortController(), connectionSignal = connectionAbort.signal, connectionAborted$ = new ReplaySubject(1);
|
|
559
598
|
connectionSignal.addEventListener("abort", () => connectionAborted$.next(), { once: !0 });
|
|
560
|
-
let record = {
|
|
599
|
+
let key = randomId(), record = {
|
|
561
600
|
appId,
|
|
562
601
|
moduleId,
|
|
602
|
+
key,
|
|
603
|
+
parentKey: config.parentKey,
|
|
563
604
|
stateSubjects: /* @__PURE__ */ new Map(),
|
|
564
605
|
rejections: /* @__PURE__ */ new Map(),
|
|
565
606
|
rejected$: new Subject(),
|
|
@@ -575,7 +616,8 @@ function createConnection(registry, config) {
|
|
|
575
616
|
if (connectionSignal.aborted) throw new MessageBusError("ABORTED");
|
|
576
617
|
}, connection = {
|
|
577
618
|
appId,
|
|
578
|
-
|
|
619
|
+
key,
|
|
620
|
+
emit: (type, payload, options) => (throwIfDisconnected(), migrateEventReply(emit(registry, type, compatibility.toInstalledEmission(type, payload), options, record, connectionSignal), (value) => compatibility.toApplicationEventReply(type, value))),
|
|
579
621
|
query: (type, options) => connectionSignal.aborted ? Promise.reject(new MessageBusError("ABORTED")) : query(stateSource(type), type, options, connectionSignal, registry.resetAbort.signal, record),
|
|
580
622
|
subscribe: (type, handler, options) => {
|
|
581
623
|
if (throwIfDisconnected(), isState(type)) {
|
|
@@ -663,7 +705,8 @@ function connectMessageBus(options = {}) {
|
|
|
663
705
|
}
|
|
664
706
|
let connection = connectApplicationToMessageBus(installedMessageBus, {
|
|
665
707
|
appId,
|
|
666
|
-
moduleId: options.moduleId
|
|
708
|
+
moduleId: options.moduleId,
|
|
709
|
+
parentKey: options.parentKey
|
|
667
710
|
});
|
|
668
711
|
return MESSAGE_BUS_REGISTRY_KEY in connection ? connection : void 0;
|
|
669
712
|
}
|
|
@@ -1891,6 +1934,6 @@ const authStore = defineStore({
|
|
|
1891
1934
|
isDestroyingSession: !1
|
|
1892
1935
|
} }));
|
|
1893
1936
|
});
|
|
1894
|
-
export { configureLogging as $, getAuthCode as A, authMode_exports as B, API_VERSION as C, SUBMISSION_RETRY_MAX_DELAY as D, SUBMISSION_RETRY_BASE_DELAY as E, getDefaultLocation as F, MessageBusError as G, DEFAULT_API_VERSION as H, getTokenFromLocation as I, isMessageBusEnvironment as J, connectMessageBus as K, AuthStateType as L, getClientErrorApiBody as M, getClientErrorApiProjectId as N, UNVERIFIED_REVISION_RETENTION_TIME as O, getClientErrorApiType as P, capabilities as Q, getAuthLogger as R, ACL_RETRY_MAX_DELAY as S, INITIAL_OUTGOING_THROTTLE_TIME as T, DEFAULT_BASE as U, isStudioConfig as V, REQUEST_TAG_PREFIX as W, resetMessageBus as X, isMessageBusInstalled as Y, workerMessages as Z, toOAuthTokens as _, getClientAuthState as a, retryWithCredential as b, getLoginUrlState as c, runOAuthTokenRefresh as d, createLogger as et, appendResourceIndicator as f, serializeTokens as g, postTokenRequest as h, getAuthState as i, getCleanedUrl as j, createLoggedInAuthState as k, getTokenState as l, getOAuthOptions as m, authStore_exports as n, getCurrentUserState as o, createOAuthClient as p, installMessageBus as q, getAuthMethodState as r, getIsInDashboardState as s, authStore as t, setAuthToken as u, retryOnCredentialChange as v, DOCUMENT_STATE_CLEAR_DELAY as w, DocumentInaccessibleError as x, retryRead as y, getStagingApiHost as z };
|
|
1937
|
+
export { configureLogging as $, getAuthCode as A, authMode_exports as B, API_VERSION as C, SUBMISSION_RETRY_MAX_DELAY as D, SUBMISSION_RETRY_BASE_DELAY as E, getDefaultLocation as F, MessageBusError as G, DEFAULT_API_VERSION as H, getTokenFromLocation as I, isMessageBusEnvironment as J, connectMessageBus as K, AuthStateType as L, getClientErrorApiBody as M, getClientErrorApiProjectId as N, UNVERIFIED_REVISION_RETENTION_TIME as O, getClientErrorApiType as P, capabilities as Q, getAuthLogger as R, ACL_RETRY_MAX_DELAY as S, INITIAL_OUTGOING_THROTTLE_TIME as T, DEFAULT_BASE as U, isStudioConfig as V, REQUEST_TAG_PREFIX as W, resetMessageBus as X, isMessageBusInstalled as Y, workerMessages as Z, toOAuthTokens as _, getClientAuthState as a, retryWithCredential as b, getLoginUrlState as c, runOAuthTokenRefresh as d, createLogger as et, appendResourceIndicator as f, serializeTokens as g, postTokenRequest as h, getAuthState as i, getCleanedUrl as j, createLoggedInAuthState as k, getTokenState as l, getOAuthOptions as m, authStore_exports as n, randomUuid as nt, getCurrentUserState as o, createOAuthClient as p, installMessageBus as q, getAuthMethodState as r, getIsInDashboardState as s, authStore as t, randomId as tt, setAuthToken as u, retryOnCredentialChange as v, DOCUMENT_STATE_CLEAR_DELAY as w, DocumentInaccessibleError as x, retryRead as y, getStagingApiHost as z };
|
|
1895
1938
|
|
|
1896
|
-
//# sourceMappingURL=authStore-
|
|
1939
|
+
//# sourceMappingURL=authStore-A65hzFu3.js.map
|