@sanity/sdk-react 0.0.1 → 0.0.3
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/README.md +3 -3
- package/dist/index.d.ts +364 -287
- package/dist/index.js +125 -149
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/_exports/sdk-react.ts +10 -10
- package/src/hooks/comlink/useWindowConnection.test.tsx +145 -0
- package/src/hooks/comlink/useWindowConnection.ts +32 -30
- package/src/hooks/{comlink → dashboard}/useManageFavorite.test.ts +84 -134
- package/src/hooks/{comlink → dashboard}/useManageFavorite.ts +4 -39
- package/src/hooks/dashboard/useNavigateToStudioDocument.test.ts +2 -73
- package/src/hooks/dashboard/useNavigateToStudioDocument.ts +20 -27
- package/src/hooks/dashboard/useRecordDocumentHistoryEvent.test.ts +69 -0
- package/src/hooks/{comlink → dashboard}/useRecordDocumentHistoryEvent.ts +17 -10
- package/src/hooks/dashboard/useStudioWorkspacesByProjectIdDataset.test.tsx +14 -85
- package/src/hooks/dashboard/useStudioWorkspacesByProjectIdDataset.ts +33 -8
- package/src/hooks/document/useApplyDocumentActions.ts +4 -4
- package/src/hooks/document/useDocument.test.ts +8 -10
- package/src/hooks/document/useDocument.ts +50 -33
- package/src/hooks/document/useDocumentEvent.ts +2 -2
- package/src/hooks/document/useDocumentSyncStatus.ts +1 -1
- package/src/hooks/document/useEditDocument.ts +15 -15
- package/src/hooks/documents/useDocuments.ts +5 -5
- package/src/hooks/paginatedDocuments/usePaginatedDocuments.ts +5 -5
- package/src/hooks/preview/{usePreview.test.tsx → useDocumentPreview.test.tsx} +5 -5
- package/src/hooks/preview/{usePreview.tsx → useDocumentPreview.tsx} +11 -8
- package/src/hooks/projection/{useProjection.test.tsx → useDocumentProjection.test.tsx} +5 -5
- package/src/hooks/projection/{useProjection.ts → useDocumentProjection.ts} +22 -17
- package/src/hooks/query/useQuery.ts +5 -5
- package/src/hooks/comlink/useRecordDocumentHistoryEvent.test.ts +0 -85
- package/src/hooks/comlink/useWindowConnection.test.ts +0 -135
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
-
import { getAuthState, getLoginUrlState, observeOrganizationVerificationState, handleAuthCallback, logout, AuthStateType, createSanityInstance, getTokenState, getCurrentUserState, getDashboardOrganizationId, getClientState, getOrCreateController, getOrCreateChannel, releaseChannel,
|
|
3
|
+
import { getAuthState, getLoginUrlState, observeOrganizationVerificationState, handleAuthCallback, logout, AuthStateType, createSanityInstance, getTokenState, getCurrentUserState, getDashboardOrganizationId, getClientState, getOrCreateController, getOrCreateChannel, releaseChannel, getNodeState, getFavoritesState, resolveFavoritesState, resolveDatasets, getDatasetsState, applyDocumentActions, resolveDocument, getDocumentState, subscribeDocumentEvents, getPermissionsState, getDocumentSyncStatus, editDocument, getQueryKey, parseQueryKey, getQueryState, resolveQuery, createGroqSearchFilter, getPreviewState, resolvePreview, getProjectionState, resolveProjection, resolveProject, getProjectState, resolveProjects, getProjectsState, getActiveReleasesState, getPerspectiveState, getUsersKey, parseUsersKey, getUsersState, resolveUsers, loadMoreUsers } from "@sanity/sdk";
|
|
4
4
|
export * from "@sanity/sdk";
|
|
5
5
|
import { createContext, useContext, useSyncExternalStore, useState, useEffect, useRef, Suspense, useMemo, useCallback, useInsertionEffect, useTransition } from "react";
|
|
6
6
|
import { ErrorBoundary } from "react-error-boundary";
|
|
@@ -329,52 +329,50 @@ function useFrameConnection(options) {
|
|
|
329
329
|
function _temp$4(unsub) {
|
|
330
330
|
return unsub();
|
|
331
331
|
}
|
|
332
|
+
const useNodeState = createStateSourceHook({
|
|
333
|
+
getState: getNodeState,
|
|
334
|
+
shouldSuspend: (instance, nodeInput) => getNodeState(instance, nodeInput).getCurrent() === void 0,
|
|
335
|
+
suspender: (instance, nodeInput) => firstValueFrom(getNodeState(instance, nodeInput).observable.pipe(filter(Boolean)))
|
|
336
|
+
});
|
|
332
337
|
function useWindowConnection(t0) {
|
|
333
|
-
const $ = c(
|
|
338
|
+
const $ = c(19), {
|
|
334
339
|
name,
|
|
335
340
|
connectTo,
|
|
336
|
-
onMessage
|
|
337
|
-
|
|
338
|
-
} = t0, nodeRef = useRef(null);
|
|
341
|
+
onMessage
|
|
342
|
+
} = t0;
|
|
339
343
|
let t1;
|
|
340
|
-
$[0]
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
$[
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
};
|
|
358
|
-
}, t3 = [instance, name, connectTo, onMessage, onStatus], $[1] = connectTo, $[2] = instance, $[3] = name, $[4] = onMessage, $[5] = onStatus, $[6] = t2, $[7] = t3) : (t2 = $[6], t3 = $[7]), useEffect(t2, t3);
|
|
344
|
+
$[0] !== connectTo || $[1] !== name ? (t1 = {
|
|
345
|
+
name,
|
|
346
|
+
connectTo
|
|
347
|
+
}, $[0] = connectTo, $[1] = name, $[2] = t1) : t1 = $[2];
|
|
348
|
+
const {
|
|
349
|
+
node
|
|
350
|
+
} = useNodeState(t1);
|
|
351
|
+
let t2;
|
|
352
|
+
$[3] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[3] = t2) : t2 = $[3];
|
|
353
|
+
const messageUnsubscribers = useRef(t2), instance = useSanityInstance();
|
|
354
|
+
let t3;
|
|
355
|
+
$[4] !== node || $[5] !== onMessage ? (t3 = () => (onMessage && Object.entries(onMessage).forEach((t42) => {
|
|
356
|
+
const [type, handler] = t42, messageUnsubscribe = node.on(type, handler);
|
|
357
|
+
messageUnsubscribe && messageUnsubscribers.current.push(messageUnsubscribe);
|
|
358
|
+
}), () => {
|
|
359
|
+
messageUnsubscribers.current.forEach(_temp$3), messageUnsubscribers.current = [];
|
|
360
|
+
}), $[4] = node, $[5] = onMessage, $[6] = t3) : t3 = $[6];
|
|
359
361
|
let t4;
|
|
360
|
-
$[8]
|
|
361
|
-
if (!nodeRef.current)
|
|
362
|
-
throw new Error("Cannot send message before connection is established");
|
|
363
|
-
nodeRef.current.post(type_0, data);
|
|
364
|
-
}, $[8] = t4) : t4 = $[8];
|
|
365
|
-
const sendMessage = t4;
|
|
362
|
+
$[7] !== instance || $[8] !== name || $[9] !== node || $[10] !== onMessage ? (t4 = [instance, name, onMessage, node], $[7] = instance, $[8] = name, $[9] = node, $[10] = onMessage, $[11] = t4) : t4 = $[11], useEffect(t3, t4);
|
|
366
363
|
let t5;
|
|
367
|
-
$[
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
}, $[9] = t5) : t5 = $[9];
|
|
372
|
-
const fetch = t5;
|
|
364
|
+
$[12] !== node ? (t5 = (type_0, data) => {
|
|
365
|
+
node.post(type_0, data);
|
|
366
|
+
}, $[12] = node, $[13] = t5) : t5 = $[13];
|
|
367
|
+
const sendMessage = t5;
|
|
373
368
|
let t6;
|
|
374
|
-
|
|
369
|
+
$[14] !== node ? (t6 = (type_1, data_0, fetchOptions) => node.fetch(type_1, data_0, fetchOptions ?? {}), $[14] = node, $[15] = t6) : t6 = $[15];
|
|
370
|
+
const fetch = t6;
|
|
371
|
+
let t7;
|
|
372
|
+
return $[16] !== fetch || $[17] !== sendMessage ? (t7 = {
|
|
375
373
|
sendMessage,
|
|
376
374
|
fetch
|
|
377
|
-
}, $[
|
|
375
|
+
}, $[16] = fetch, $[17] = sendMessage, $[18] = t7) : t7 = $[18], t7;
|
|
378
376
|
}
|
|
379
377
|
function _temp$3(unsubscribe) {
|
|
380
378
|
return unsubscribe();
|
|
@@ -388,12 +386,11 @@ function useManageFavorite({
|
|
|
388
386
|
resourceType,
|
|
389
387
|
schemaName
|
|
390
388
|
}) {
|
|
391
|
-
const
|
|
389
|
+
const {
|
|
392
390
|
fetch
|
|
393
391
|
} = useWindowConnection({
|
|
394
392
|
name: SDK_NODE_NAME,
|
|
395
|
-
connectTo: SDK_CHANNEL_NAME
|
|
396
|
-
onStatus: setStatus
|
|
393
|
+
connectTo: SDK_CHANNEL_NAME
|
|
397
394
|
}), instance = useSanityInstance(), {
|
|
398
395
|
config
|
|
399
396
|
} = instance, instanceProjectId = config?.projectId, instanceDataset = config?.dataset, projectId = paramProjectId ?? instanceProjectId, dataset = paramDataset ?? instanceDataset;
|
|
@@ -408,8 +405,8 @@ function useManageFavorite({
|
|
|
408
405
|
resourceId,
|
|
409
406
|
resourceType,
|
|
410
407
|
schemaName
|
|
411
|
-
}), [documentId, documentType, resourceId, resourceType, schemaName]), favoriteState = getFavoritesState(instance, context),
|
|
412
|
-
if (!(
|
|
408
|
+
}), [documentId, documentType, resourceId, resourceType, schemaName]), favoriteState = getFavoritesState(instance, context), isFavorited = useSyncExternalStore(favoriteState.subscribe, favoriteState.getCurrent)?.isFavorited ?? !1, handleFavoriteAction = useCallback(async (action) => {
|
|
409
|
+
if (!(!fetch || !documentId || !documentType || !resourceType))
|
|
413
410
|
try {
|
|
414
411
|
const payload = {
|
|
415
412
|
eventType: action,
|
|
@@ -429,100 +426,33 @@ function useManageFavorite({
|
|
|
429
426
|
} catch (err) {
|
|
430
427
|
throw console.error(`Failed to ${action === "added" ? "favorite" : "unfavorite"} document:`, err), err;
|
|
431
428
|
}
|
|
432
|
-
}, [fetch, documentId, documentType, resourceId, resourceType, schemaName, instance, context
|
|
433
|
-
if (!state)
|
|
434
|
-
try {
|
|
435
|
-
throw resolveFavoritesState(instance, context);
|
|
436
|
-
} catch (err_0) {
|
|
437
|
-
if (err_0 instanceof Error && err_0.message === "Favorites service connection timeout")
|
|
438
|
-
return {
|
|
439
|
-
favorite: async () => {
|
|
440
|
-
},
|
|
441
|
-
unfavorite: async () => {
|
|
442
|
-
},
|
|
443
|
-
isFavorited: !1,
|
|
444
|
-
isConnected: !1
|
|
445
|
-
};
|
|
446
|
-
throw err_0;
|
|
447
|
-
}
|
|
429
|
+
}, [fetch, documentId, documentType, resourceId, resourceType, schemaName, instance, context]), favorite = useCallback(() => handleFavoriteAction("added"), [handleFavoriteAction]), unfavorite = useCallback(() => handleFavoriteAction("removed"), [handleFavoriteAction]);
|
|
448
430
|
return {
|
|
449
431
|
favorite,
|
|
450
432
|
unfavorite,
|
|
451
|
-
isFavorited
|
|
452
|
-
isConnected: status === "connected"
|
|
433
|
+
isFavorited
|
|
453
434
|
};
|
|
454
435
|
}
|
|
455
|
-
function useRecordDocumentHistoryEvent(t0) {
|
|
456
|
-
const $ = c(11), {
|
|
457
|
-
documentId,
|
|
458
|
-
documentType,
|
|
459
|
-
resourceType,
|
|
460
|
-
resourceId,
|
|
461
|
-
schemaName
|
|
462
|
-
} = t0, [status, setStatus] = useState("idle");
|
|
463
|
-
let t1;
|
|
464
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = {
|
|
465
|
-
name: SDK_NODE_NAME,
|
|
466
|
-
connectTo: SDK_CHANNEL_NAME,
|
|
467
|
-
onStatus: setStatus
|
|
468
|
-
}, $[0] = t1) : t1 = $[0];
|
|
469
|
-
const {
|
|
470
|
-
sendMessage
|
|
471
|
-
} = useWindowConnection(t1);
|
|
472
|
-
if (resourceType !== "studio" && !resourceId)
|
|
473
|
-
throw new Error("resourceId is required for media-library and canvas resources");
|
|
474
|
-
let t2;
|
|
475
|
-
$[1] !== documentId || $[2] !== documentType || $[3] !== resourceId || $[4] !== resourceType || $[5] !== schemaName || $[6] !== sendMessage ? (t2 = (eventType) => {
|
|
476
|
-
try {
|
|
477
|
-
const message = {
|
|
478
|
-
type: "dashboard/v1/events/history",
|
|
479
|
-
data: {
|
|
480
|
-
eventType,
|
|
481
|
-
document: {
|
|
482
|
-
id: documentId,
|
|
483
|
-
type: documentType,
|
|
484
|
-
resource: {
|
|
485
|
-
id: resourceId,
|
|
486
|
-
type: resourceType,
|
|
487
|
-
schemaName
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
};
|
|
492
|
-
sendMessage(message.type, message.data);
|
|
493
|
-
} catch (t32) {
|
|
494
|
-
const error = t32;
|
|
495
|
-
throw console.error("Failed to record history event:", error), error;
|
|
496
|
-
}
|
|
497
|
-
}, $[1] = documentId, $[2] = documentType, $[3] = resourceId, $[4] = resourceType, $[5] = schemaName, $[6] = sendMessage, $[7] = t2) : t2 = $[7];
|
|
498
|
-
const recordEvent = t2, t3 = status === "connected";
|
|
499
|
-
let t4;
|
|
500
|
-
return $[8] !== recordEvent || $[9] !== t3 ? (t4 = {
|
|
501
|
-
recordEvent,
|
|
502
|
-
isConnected: t3
|
|
503
|
-
}, $[8] = recordEvent, $[9] = t3, $[10] = t4) : t4 = $[10], t4;
|
|
504
|
-
}
|
|
505
436
|
function useStudioWorkspacesByProjectIdDataset() {
|
|
506
|
-
const $ = c(
|
|
437
|
+
const $ = c(8);
|
|
507
438
|
let t0;
|
|
508
439
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {}, $[0] = t0) : t0 = $[0];
|
|
509
|
-
const [workspacesByProjectIdAndDataset, setWorkspacesByProjectIdAndDataset] = useState(t0), [
|
|
440
|
+
const [workspacesByProjectIdAndDataset, setWorkspacesByProjectIdAndDataset] = useState(t0), [error, setError] = useState(null);
|
|
510
441
|
let t1;
|
|
511
442
|
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t1 = {
|
|
512
443
|
name: SDK_NODE_NAME,
|
|
513
|
-
connectTo: SDK_CHANNEL_NAME
|
|
514
|
-
onStatus: setStatus
|
|
444
|
+
connectTo: SDK_CHANNEL_NAME
|
|
515
445
|
}, $[1] = t1) : t1 = $[1];
|
|
516
446
|
const {
|
|
517
447
|
fetch
|
|
518
448
|
} = useWindowConnection(t1);
|
|
519
449
|
let t2, t3;
|
|
520
|
-
$[2] !== fetch
|
|
521
|
-
if (!fetch
|
|
450
|
+
$[2] !== fetch ? (t2 = () => {
|
|
451
|
+
if (!fetch)
|
|
522
452
|
return;
|
|
523
453
|
const fetchWorkspaces = async function(signal) {
|
|
524
454
|
try {
|
|
525
|
-
const data = await fetch("dashboard/v1/
|
|
455
|
+
const data = await fetch("dashboard/v1/context", void 0, {
|
|
526
456
|
signal
|
|
527
457
|
}), workspaceMap = {}, noProjectIdAndDataset = [];
|
|
528
458
|
data.context.availableResources.forEach((resource) => {
|
|
@@ -547,39 +477,31 @@ function useStudioWorkspacesByProjectIdDataset() {
|
|
|
547
477
|
return fetchWorkspaces(controller.signal), () => {
|
|
548
478
|
controller.abort();
|
|
549
479
|
};
|
|
550
|
-
}, t3 = [fetch
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
return $[6] !== error || $[7] !== t4 || $[8] !== workspacesByProjectIdAndDataset ? (t5 = {
|
|
480
|
+
}, t3 = [fetch], $[2] = fetch, $[3] = t2, $[4] = t3) : (t2 = $[3], t3 = $[4]), useEffect(t2, t3);
|
|
481
|
+
let t4;
|
|
482
|
+
return $[5] !== error || $[6] !== workspacesByProjectIdAndDataset ? (t4 = {
|
|
554
483
|
workspacesByProjectIdAndDataset,
|
|
555
|
-
error
|
|
556
|
-
|
|
557
|
-
}, $[6] = error, $[7] = t4, $[8] = workspacesByProjectIdAndDataset, $[9] = t5) : t5 = $[9], t5;
|
|
484
|
+
error
|
|
485
|
+
}, $[5] = error, $[6] = workspacesByProjectIdAndDataset, $[7] = t4) : t4 = $[7], t4;
|
|
558
486
|
}
|
|
559
487
|
function useNavigateToStudioDocument(documentHandle, preferredStudioUrl) {
|
|
560
|
-
const $ = c(
|
|
561
|
-
workspacesByProjectIdAndDataset
|
|
562
|
-
|
|
563
|
-
} = useStudioWorkspacesByProjectIdDataset(), [status, setStatus] = useState("idle");
|
|
488
|
+
const $ = c(8), {
|
|
489
|
+
workspacesByProjectIdAndDataset
|
|
490
|
+
} = useStudioWorkspacesByProjectIdDataset();
|
|
564
491
|
let t0;
|
|
565
492
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
566
493
|
name: SDK_NODE_NAME,
|
|
567
|
-
connectTo: SDK_CHANNEL_NAME
|
|
568
|
-
onStatus: setStatus
|
|
494
|
+
connectTo: SDK_CHANNEL_NAME
|
|
569
495
|
}, $[0] = t0) : t0 = $[0];
|
|
570
496
|
const {
|
|
571
497
|
sendMessage
|
|
572
498
|
} = useWindowConnection(t0);
|
|
573
499
|
let t1;
|
|
574
|
-
$[1] !== documentHandle || $[2] !== preferredStudioUrl || $[3] !== sendMessage || $[4] !==
|
|
500
|
+
$[1] !== documentHandle || $[2] !== preferredStudioUrl || $[3] !== sendMessage || $[4] !== workspacesByProjectIdAndDataset ? (t1 = () => {
|
|
575
501
|
const {
|
|
576
502
|
projectId,
|
|
577
503
|
dataset
|
|
578
504
|
} = documentHandle;
|
|
579
|
-
if (!workspacesConnected || status !== "connected") {
|
|
580
|
-
console.warn("Not connected to Dashboard");
|
|
581
|
-
return;
|
|
582
|
-
}
|
|
583
505
|
if (!projectId || !dataset) {
|
|
584
506
|
console.warn("Project ID and dataset are required to navigate to a studio document");
|
|
585
507
|
return;
|
|
@@ -604,13 +526,60 @@ function useNavigateToStudioDocument(documentHandle, preferredStudioUrl) {
|
|
|
604
526
|
}
|
|
605
527
|
};
|
|
606
528
|
sendMessage(message.type, message.data);
|
|
607
|
-
}, $[1] = documentHandle, $[2] = preferredStudioUrl, $[3] = sendMessage, $[4] =
|
|
608
|
-
const navigateToStudioDocument = t1
|
|
529
|
+
}, $[1] = documentHandle, $[2] = preferredStudioUrl, $[3] = sendMessage, $[4] = workspacesByProjectIdAndDataset, $[5] = t1) : t1 = $[5];
|
|
530
|
+
const navigateToStudioDocument = t1;
|
|
531
|
+
let t2;
|
|
532
|
+
return $[6] !== navigateToStudioDocument ? (t2 = {
|
|
533
|
+
navigateToStudioDocument
|
|
534
|
+
}, $[6] = navigateToStudioDocument, $[7] = t2) : t2 = $[7], t2;
|
|
535
|
+
}
|
|
536
|
+
function useRecordDocumentHistoryEvent(t0) {
|
|
537
|
+
const $ = c(10), {
|
|
538
|
+
documentId,
|
|
539
|
+
documentType,
|
|
540
|
+
resourceType,
|
|
541
|
+
resourceId,
|
|
542
|
+
schemaName
|
|
543
|
+
} = t0;
|
|
544
|
+
let t1;
|
|
545
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = {
|
|
546
|
+
name: SDK_NODE_NAME,
|
|
547
|
+
connectTo: SDK_CHANNEL_NAME
|
|
548
|
+
}, $[0] = t1) : t1 = $[0];
|
|
549
|
+
const {
|
|
550
|
+
sendMessage
|
|
551
|
+
} = useWindowConnection(t1);
|
|
552
|
+
if (resourceType !== "studio" && !resourceId)
|
|
553
|
+
throw new Error("resourceId is required for media-library and canvas resources");
|
|
554
|
+
let t2;
|
|
555
|
+
$[1] !== documentId || $[2] !== documentType || $[3] !== resourceId || $[4] !== resourceType || $[5] !== schemaName || $[6] !== sendMessage ? (t2 = (eventType) => {
|
|
556
|
+
try {
|
|
557
|
+
const message = {
|
|
558
|
+
type: "dashboard/v1/events/history",
|
|
559
|
+
data: {
|
|
560
|
+
eventType,
|
|
561
|
+
document: {
|
|
562
|
+
id: documentId,
|
|
563
|
+
type: documentType,
|
|
564
|
+
resource: {
|
|
565
|
+
id: resourceId,
|
|
566
|
+
type: resourceType,
|
|
567
|
+
schemaName
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
sendMessage(message.type, message.data);
|
|
573
|
+
} catch (t32) {
|
|
574
|
+
const error = t32;
|
|
575
|
+
throw console.error("Failed to record history event:", error), error;
|
|
576
|
+
}
|
|
577
|
+
}, $[1] = documentId, $[2] = documentType, $[3] = resourceId, $[4] = resourceType, $[5] = schemaName, $[6] = sendMessage, $[7] = t2) : t2 = $[7];
|
|
578
|
+
const recordEvent = t2;
|
|
609
579
|
let t3;
|
|
610
|
-
return $[8] !==
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}, $[8] = navigateToStudioDocument, $[9] = t2, $[10] = t3) : t3 = $[10], t3;
|
|
580
|
+
return $[8] !== recordEvent ? (t3 = {
|
|
581
|
+
recordEvent
|
|
582
|
+
}, $[8] = recordEvent, $[9] = t3) : t3 = $[9], t3;
|
|
614
583
|
}
|
|
615
584
|
const useDatasets = createStateSourceHook({
|
|
616
585
|
getState: getDatasetsState,
|
|
@@ -620,7 +589,7 @@ const useDatasets = createStateSourceHook({
|
|
|
620
589
|
),
|
|
621
590
|
suspender: resolveDatasets,
|
|
622
591
|
getConfig: identity
|
|
623
|
-
}), useApplyDocumentActions = createCallbackHook(applyDocumentActions),
|
|
592
|
+
}), useApplyDocumentActions = createCallbackHook(applyDocumentActions), useDocumentValue = createStateSourceHook({
|
|
624
593
|
// Pass options directly to getDocumentState
|
|
625
594
|
getState: (instance, options) => getDocumentState(instance, options),
|
|
626
595
|
// Pass options directly to getDocumentState for checking current value
|
|
@@ -631,7 +600,14 @@ const useDatasets = createStateSourceHook({
|
|
|
631
600
|
// Extract handle part for resolveDocument
|
|
632
601
|
suspender: (instance, options) => resolveDocument(instance, options),
|
|
633
602
|
getConfig: identity
|
|
634
|
-
})
|
|
603
|
+
}), wrapHookWithData = (useValue) => {
|
|
604
|
+
function useHook(...params) {
|
|
605
|
+
return {
|
|
606
|
+
data: useValue(...params)
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
return useHook;
|
|
610
|
+
}, useDocument = wrapHookWithData(useDocumentValue);
|
|
635
611
|
function useDocumentEvent(options) {
|
|
636
612
|
const $ = c(9);
|
|
637
613
|
let datasetHandle, onEvent;
|
|
@@ -942,7 +918,7 @@ function _temp2(str) {
|
|
|
942
918
|
function _temp(i) {
|
|
943
919
|
return typeof i == "string";
|
|
944
920
|
}
|
|
945
|
-
function
|
|
921
|
+
function useDocumentPreview(t0) {
|
|
946
922
|
const $ = c(13);
|
|
947
923
|
let docHandle, ref;
|
|
948
924
|
$[0] !== t0 ? ({
|
|
@@ -982,7 +958,7 @@ function usePreview(t0) {
|
|
|
982
958
|
return currentState;
|
|
983
959
|
}, $[9] = docHandle, $[10] = instance, $[11] = stateSource, $[12] = t3) : t3 = $[12], useSyncExternalStore(subscribe, t3);
|
|
984
960
|
}
|
|
985
|
-
function
|
|
961
|
+
function useDocumentProjection(t0) {
|
|
986
962
|
const $ = c(12);
|
|
987
963
|
let docHandle, projection, ref;
|
|
988
964
|
$[0] !== t0 ? ({
|
|
@@ -1070,7 +1046,7 @@ function useUsers(options) {
|
|
|
1070
1046
|
loadMore
|
|
1071
1047
|
};
|
|
1072
1048
|
}
|
|
1073
|
-
var version = "0.0.
|
|
1049
|
+
var version = "0.0.3";
|
|
1074
1050
|
function getEnv(key) {
|
|
1075
1051
|
if (typeof import.meta < "u" && import.meta.env)
|
|
1076
1052
|
return import.meta.env[key];
|
|
@@ -1097,6 +1073,8 @@ export {
|
|
|
1097
1073
|
useDocument,
|
|
1098
1074
|
useDocumentEvent,
|
|
1099
1075
|
useDocumentPermissions,
|
|
1076
|
+
useDocumentPreview,
|
|
1077
|
+
useDocumentProjection,
|
|
1100
1078
|
useDocumentSyncStatus,
|
|
1101
1079
|
useDocuments,
|
|
1102
1080
|
useEditDocument,
|
|
@@ -1108,9 +1086,7 @@ export {
|
|
|
1108
1086
|
useNavigateToStudioDocument,
|
|
1109
1087
|
usePaginatedDocuments,
|
|
1110
1088
|
usePerspective,
|
|
1111
|
-
usePreview,
|
|
1112
1089
|
useProject,
|
|
1113
|
-
useProjection,
|
|
1114
1090
|
useProjects,
|
|
1115
1091
|
useQuery,
|
|
1116
1092
|
useRecordDocumentHistoryEvent,
|