@atlaskit/editor-synced-block-provider 3.30.2 → 3.30.4

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/clients/block-service/blockSubscription.js +3 -53
  3. package/dist/cjs/clients/block-service/sharedSubscriptionUtils.js +82 -0
  4. package/dist/cjs/index.js +46 -0
  5. package/dist/cjs/providers/block-service/blockServiceAPI.js +22 -6
  6. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +25 -46
  7. package/dist/cjs/store-manager/syncBlockInMemorySessionCache.js +75 -0
  8. package/dist/cjs/utils/__generated__/relaySubscriptionUtilsSubscription.graphql.js +94 -0
  9. package/dist/cjs/utils/relayResponseConverter.js +76 -0
  10. package/dist/cjs/utils/relaySubscriptionUtils.js +130 -0
  11. package/dist/es2019/clients/block-service/blockSubscription.js +2 -67
  12. package/dist/es2019/clients/block-service/sharedSubscriptionUtils.js +91 -0
  13. package/dist/es2019/index.js +5 -0
  14. package/dist/es2019/providers/block-service/blockServiceAPI.js +22 -6
  15. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +22 -43
  16. package/dist/es2019/store-manager/syncBlockInMemorySessionCache.js +57 -0
  17. package/dist/es2019/utils/__generated__/relaySubscriptionUtilsSubscription.graphql.js +88 -0
  18. package/dist/es2019/utils/relayResponseConverter.js +69 -0
  19. package/dist/es2019/utils/relaySubscriptionUtils.js +125 -0
  20. package/dist/esm/clients/block-service/blockSubscription.js +2 -52
  21. package/dist/esm/clients/block-service/sharedSubscriptionUtils.js +76 -0
  22. package/dist/esm/index.js +5 -0
  23. package/dist/esm/providers/block-service/blockServiceAPI.js +22 -6
  24. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +25 -46
  25. package/dist/esm/store-manager/syncBlockInMemorySessionCache.js +68 -0
  26. package/dist/esm/utils/__generated__/relaySubscriptionUtilsSubscription.graphql.js +88 -0
  27. package/dist/esm/utils/relayResponseConverter.js +69 -0
  28. package/dist/esm/utils/relaySubscriptionUtils.js +123 -0
  29. package/dist/types/clients/block-service/blockSubscription.d.ts +1 -26
  30. package/dist/types/clients/block-service/sharedSubscriptionUtils.d.ts +61 -0
  31. package/dist/types/index.d.ts +5 -0
  32. package/dist/types/providers/block-service/blockServiceAPI.d.ts +7 -2
  33. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +3 -3
  34. package/dist/types/store-manager/syncBlockInMemorySessionCache.d.ts +23 -0
  35. package/dist/types/utils/__generated__/relaySubscriptionUtilsSubscription.graphql.d.ts +31 -0
  36. package/dist/types/utils/relayResponseConverter.d.ts +47 -0
  37. package/dist/types/utils/relaySubscriptionUtils.d.ts +61 -0
  38. package/dist/types/utils/validValue.d.ts +1 -1
  39. package/dist/types-ts4.5/clients/block-service/blockSubscription.d.ts +1 -26
  40. package/dist/types-ts4.5/clients/block-service/sharedSubscriptionUtils.d.ts +61 -0
  41. package/dist/types-ts4.5/index.d.ts +5 -0
  42. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +7 -2
  43. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +3 -3
  44. package/dist/types-ts4.5/store-manager/syncBlockInMemorySessionCache.d.ts +23 -0
  45. package/dist/types-ts4.5/utils/__generated__/relaySubscriptionUtilsSubscription.graphql.d.ts +31 -0
  46. package/dist/types-ts4.5/utils/relayResponseConverter.d.ts +47 -0
  47. package/dist/types-ts4.5/utils/relaySubscriptionUtils.d.ts +61 -0
  48. package/dist/types-ts4.5/utils/validValue.d.ts +1 -1
  49. package/package.json +3 -2
@@ -0,0 +1,61 @@
1
+ import type { IEnvironment } from 'relay-runtime';
2
+ import type { ResourceId } from '../common/types';
3
+ import type { BlockSubscriptionErrorCallback, BlockUpdateCallback, Unsubscribe } from '../providers/types';
4
+ /**
5
+ * Configuration for creating a Relay block subscription.
6
+ */
7
+ export interface RelayBlockSubscriptionConfig {
8
+ /** Cloud ID for generating block ARIs */
9
+ cloudId: string;
10
+ /** Optional callback when subscription errors occur */
11
+ onError?: BlockSubscriptionErrorCallback;
12
+ /** Callback when block updates are received */
13
+ onUpdate: BlockUpdateCallback;
14
+ /** Relay environment to use for the subscription */
15
+ relayEnvironment: IEnvironment;
16
+ /** The resource ID to subscribe to */
17
+ resourceId: ResourceId;
18
+ }
19
+ /**
20
+ * Creates a Relay-based block subscription without needing to wrap providers.
21
+ * This is a clean utility function that can be used directly in components or hooks.
22
+ *
23
+ * @param config - Configuration for the subscription
24
+ * @returns An unsubscribe function to dispose the subscription
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const unsubscribe = createRelayBlockSubscription({
29
+ * relayEnvironment: environment,
30
+ * cloudId: 'my-cloud-id',
31
+ * resourceId: 'my-resource-id',
32
+ * onUpdate: (blockInstance) => {
33
+ * console.log('Block updated:', blockInstance);
34
+ * },
35
+ * onError: (error) => {
36
+ * console.error('Subscription error:', error);
37
+ * }
38
+ * });
39
+ *
40
+ * // Later, when component unmounts or subscription is no longer needed
41
+ * unsubscribe();
42
+ * ```
43
+ */
44
+ export declare function createRelayBlockSubscription(config: RelayBlockSubscriptionConfig): Unsubscribe;
45
+ /**
46
+ * Hook-like function to create a subscription function that can be passed to providers.
47
+ * This creates a function with the same signature as subscribeToBlockUpdates that uses Relay.
48
+ *
49
+ * @param cloudId - Cloud ID for generating block ARIs
50
+ * @param relayEnvironment - Optional Relay environment. If not provided, will attempt to use global environment
51
+ * @returns A function that can be used as subscribeToBlockUpdates in provider configurations
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const relaySubscribeToBlockUpdates = createRelaySubscriptionFunction(cloudId, environment);
56
+ *
57
+ * // Can be used directly as a subscribeToBlockUpdates replacement
58
+ * const unsubscribe = relaySubscribeToBlockUpdates(resourceId, onUpdate, onError);
59
+ * ```
60
+ */
61
+ export declare function createRelaySubscriptionFunction(cloudId: string, relayEnvironment?: IEnvironment): (resourceId: ResourceId, onUpdate: BlockUpdateCallback, onError?: BlockSubscriptionErrorCallback) => Unsubscribe;
@@ -1,3 +1,3 @@
1
- import type { SyncBlockProduct, SyncBlockStatus } from "../common/types";
1
+ import type { SyncBlockProduct, SyncBlockStatus } from '../common/types';
2
2
  export declare const normaliseSyncBlockProduct: (value: string | null | undefined) => SyncBlockProduct | undefined;
3
3
  export declare const normaliseSyncBlockStatus: (value: string | null | undefined) => SyncBlockStatus | undefined;
@@ -1,29 +1,4 @@
1
- import type { ADFEntity } from '@atlaskit/adf-utils/types';
2
- import type { SyncBlockProduct } from '../../common/types';
3
- export type BlockSubscriptionPayload = {
4
- blockAri: string;
5
- blockInstanceId: string;
6
- content: string;
7
- contentUpdatedAt?: number;
8
- createdAt: number;
9
- createdBy: string;
10
- deletionReason?: string;
11
- product: string;
12
- sourceAri: string;
13
- status: string;
14
- };
15
- export type ParsedBlockSubscriptionData = {
16
- blockAri: string;
17
- blockInstanceId: string;
18
- content: ADFEntity[];
19
- contentUpdatedAt?: string;
20
- createdAt?: string;
21
- createdBy: string;
22
- product: SyncBlockProduct;
23
- resourceId: string;
24
- sourceAri: string;
25
- status: string;
26
- };
1
+ import { type ParsedBlockSubscriptionData } from './sharedSubscriptionUtils';
27
2
  type SubscriptionCallback = (data: ParsedBlockSubscriptionData) => void;
28
3
  type ErrorCallback = (error: Error) => void;
29
4
  type Unsubscribe = () => void;
@@ -0,0 +1,61 @@
1
+ import type { ADFEntity } from '@atlaskit/adf-utils/types';
2
+ import type { SyncBlockProduct } from '../../common/types';
3
+ /**
4
+ * Shared GraphQL subscription query for block updates.
5
+ * This is the canonical subscription query used across all implementations.
6
+ */
7
+ export declare const BLOCK_SERVICE_SUBSCRIPTION_QUERY = "\nsubscription EDITOR_SYNCED_BLOCK_ON_BLOCK_UPDATED($resourceId: ID!) {\n\tblockService_onBlockUpdated(resourceId: $resourceId) {\n\t\tblockAri\n\t\tblockInstanceId\n\t\tcontent\n\t\tcontentUpdatedAt\n\t\tcreatedAt\n\t\tcreatedBy\n\t\tdeletionReason\n\t\tproduct\n\t\tsourceAri\n\t\tstatus\n\t}\n}\n";
8
+ /**
9
+ * Raw subscription payload from the GraphQL subscription.
10
+ * This represents the exact shape returned by the blockService_onBlockUpdated subscription.
11
+ */
12
+ export type BlockSubscriptionPayload = {
13
+ blockAri: string;
14
+ blockInstanceId: string;
15
+ content: string;
16
+ contentUpdatedAt?: number;
17
+ createdAt: number;
18
+ createdBy: string;
19
+ deletionReason?: string;
20
+ product: string;
21
+ sourceAri: string;
22
+ status: string;
23
+ };
24
+ /**
25
+ * Parsed and normalized block subscription data.
26
+ * This is the standardized format used across different subscription implementations.
27
+ */
28
+ export type ParsedBlockSubscriptionData = {
29
+ blockAri: string;
30
+ blockInstanceId: string;
31
+ content: ADFEntity[];
32
+ contentUpdatedAt?: string;
33
+ createdAt?: string;
34
+ createdBy: string;
35
+ product: SyncBlockProduct;
36
+ resourceId: string;
37
+ sourceAri: string;
38
+ status: string;
39
+ };
40
+ /**
41
+ * Extracts the resourceId from a block ARI.
42
+ * Block ARI format: ari:cloud:blocks:<cloudId>:synced-block/<resourceId>
43
+ * @param blockAri - The block ARI string
44
+ * @returns The resourceId portion of the ARI
45
+ */
46
+ export declare const extractResourceIdFromBlockAri: (blockAri: string) => string | null;
47
+ /**
48
+ * Converts a timestamp to ISO string.
49
+ * @param timestamp - Timestamp in milliseconds
50
+ * @returns ISO string or undefined if conversion fails
51
+ */
52
+ export declare const convertTimestampToISOString: (timestamp?: number) => string | undefined;
53
+ /**
54
+ * Parses the raw subscription payload into a standardized format.
55
+ * This function handles all the data transformation and error handling consistently
56
+ * across different subscription implementations.
57
+ *
58
+ * @param payload - The raw subscription payload
59
+ * @returns Parsed block data or null if parsing fails
60
+ */
61
+ export declare const parseSubscriptionPayload: (payload: BlockSubscriptionPayload) => ParsedBlockSubscriptionData | null;
@@ -15,7 +15,12 @@ export { fetchConfluencePageInfo } from './clients/confluence/sourceInfo';
15
15
  export { SyncedBlockProvider, useMemoizedSyncedBlockProvider } from './providers/syncBlockProvider';
16
16
  export type { ADFFetchProvider, ADFWriteProvider, BlockNodeIdentifiers, BlockSubscriptionErrorCallback, BlockUpdateCallback, SyncBlockDataProviderInterface, SyncBlockInstance, MediaEmojiProviderOptions, SyncedBlockRendererProviderOptions, SyncBlockRendererProviderCreator, SyncedBlockRendererDataProviders, Unsubscribe, UpdateReferenceSyncBlockResult, WriteSyncBlockResult, SyncBlockParentInfo, SyncBlockSourceInfo, } from './providers/types';
17
17
  export { ReferenceSyncBlockStoreManager } from './store-manager/referenceSyncBlockStoreManager';
18
+ export { SyncBlockInMemorySessionCache, syncBlockInMemorySessionCache, } from './store-manager/syncBlockInMemorySessionCache';
18
19
  export { SyncBlockStoreManager, useMemoizedSyncBlockStoreManager, } from './store-manager/syncBlockStoreManager';
20
+ export { BLOCK_SERVICE_SUBSCRIPTION_QUERY } from './clients/block-service/sharedSubscriptionUtils';
21
+ export { type BlockSubscriptionPayload, parseSubscriptionPayload } from './clients/block-service/sharedSubscriptionUtils';
22
+ export { convertRelayResponseToSyncBlockInstance, type RelayBlockUpdateResponse } from './utils/relayResponseConverter';
23
+ export { createRelayBlockSubscription, createRelaySubscriptionFunction, type RelayBlockSubscriptionConfig } from './utils/relaySubscriptionUtils';
19
24
  export { resolveSyncBlockInstance } from './utils/resolveSyncBlockInstance';
20
25
  export { parseResourceId, createResourceIdForReference } from './utils/resourceId';
21
26
  export { createSyncBlockNode, convertSyncBlockPMNodeToSyncBlockData, convertSyncBlockJSONNodeToSyncBlockNode, convertPMNodesToSyncBlockNodes, getContentIdAndProductFromResourceId, } from './utils/utils';
@@ -1,3 +1,4 @@
1
+ import type { IEnvironment } from 'relay-runtime';
1
2
  import { type BlockContentResponse } from '../../clients/block-service/blockService';
2
3
  import { SyncBlockError, type ReferenceSyncBlockData, type ResourceId, type SyncBlockAttrs, type SyncBlockData, type SyncBlockProduct } from '../../common/types';
3
4
  import type { ADFFetchProvider, ADFWriteProvider, BlockNodeIdentifiers, DeleteSyncBlockResult, SyncBlockInstance, UpdateReferenceSyncBlockResult, WriteSyncBlockResult } from '../types';
@@ -36,6 +37,7 @@ export declare const batchFetchData: (cloudId: string, parentAri: string | undef
36
37
  interface BlockServiceADFFetchProviderProps {
37
38
  cloudId: string;
38
39
  parentAri: string | undefined;
40
+ relayEnvironment?: IEnvironment;
39
41
  }
40
42
  /**
41
43
  * ADFFetchProvider implementation that fetches synced block data from Block Service API
@@ -43,7 +45,8 @@ interface BlockServiceADFFetchProviderProps {
43
45
  declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
44
46
  private cloudId;
45
47
  private parentAri;
46
- constructor({ cloudId, parentAri }: BlockServiceADFFetchProviderProps);
48
+ private relayEnvironment?;
49
+ constructor({ cloudId, parentAri, relayEnvironment }: BlockServiceADFFetchProviderProps);
47
50
  fetchData(resourceId: string): Promise<SyncBlockInstance>;
48
51
  fetchReferences(referenceResourceId: string): Promise<ReferenceSyncBlockData>;
49
52
  /**
@@ -54,6 +57,7 @@ declare class BlockServiceADFFetchProvider implements ADFFetchProvider {
54
57
  batchFetchData(blockNodeIdentifiers: BlockNodeIdentifiers[]): Promise<SyncBlockInstance[]>;
55
58
  /**
56
59
  * Subscribes to real-time updates for a specific block using GraphQL WebSocket subscriptions.
60
+ * If a Relay environment is provided, uses Relay subscriptions; otherwise falls back to WebSocket.
57
61
  * @param resourceId - The resource ID of the block to subscribe to
58
62
  * @param onUpdate - Callback function invoked when the block is updated
59
63
  * @param onError - Optional callback function invoked on subscription errors
@@ -91,8 +95,9 @@ interface BlockServiceAPIProvidersProps {
91
95
  parentAri: string | undefined;
92
96
  parentId?: string;
93
97
  product: SyncBlockProduct;
98
+ relayEnvironment?: IEnvironment;
94
99
  }
95
- export declare const useMemoizedBlockServiceAPIProviders: ({ cloudId, parentAri, parentId, product, getVersion, }: BlockServiceAPIProvidersProps) => {
100
+ export declare const useMemoizedBlockServiceAPIProviders: ({ cloudId, parentAri, parentId, product, getVersion, relayEnvironment, }: BlockServiceAPIProvidersProps) => {
96
101
  fetchProvider: BlockServiceADFFetchProvider;
97
102
  writeProvider: BlockServiceADFWriteProvider;
98
103
  };
@@ -73,8 +73,8 @@ export declare class ReferenceSyncBlockStoreManager {
73
73
  generateResourceIdForReference(sourceId: ResourceId): ResourceId;
74
74
  updateFireAnalyticsEvent(fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void): void;
75
75
  getInitialSyncBlockData(resourceId: ResourceId): SyncBlockInstance | undefined;
76
- private updateCacheInSessionStorage;
77
- private getSyncBlockDataFromSessionStorage;
76
+ private updateSessionCache;
77
+ private getFromSessionCache;
78
78
  /**
79
79
  * Refreshes the subscriptions for all sync blocks.
80
80
  * This is a fallback polling mechanism when real-time subscriptions are not enabled.
@@ -125,7 +125,7 @@ export declare class ReferenceSyncBlockStoreManager {
125
125
  getFromCache(resourceId: ResourceId): SyncBlockInstance | undefined;
126
126
  private deleteFromCache;
127
127
  private debouncedBatchedFetchSyncBlocks;
128
- private setSSRDataInSessionStorage;
128
+ private setSSRDataInSessionCache;
129
129
  subscribeToSyncBlock(resourceId: string, localId: string, callback: SubscriptionCallback): () => void;
130
130
  subscribeToSourceTitle(node: PMNode, callback: TitleSubscriptionCallback): () => void;
131
131
  subscribe(node: PMNode, callback: SubscriptionCallback): () => void;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * In-memory session cache for sync block data with size-based LRU eviction.
3
+ *
4
+ * Backed by a plain Map so that potentially private ADF content is never
5
+ * written to any browser-persistent storage (sessionStorage, localStorage,
6
+ * IndexedDB). The module-level singleton survives SPA transitions (no full
7
+ * page reload) and is naturally cleared on hard navigation or tab close.
8
+ *
9
+ * Uses JavaScript Map's insertion-order guarantee to implement LRU:
10
+ * on every read or write the accessed entry is moved to the end of the
11
+ * iteration order; when total cached size exceeds `maxSize`, the oldest
12
+ * (least-recently-used) entries are evicted first.
13
+ */
14
+ export declare class SyncBlockInMemorySessionCache {
15
+ private store;
16
+ private currentSize;
17
+ private maxSize;
18
+ constructor(maxSize?: number);
19
+ getItem(key: string): string | null;
20
+ setItem(key: string, value: string): void;
21
+ removeItem(key: string): void;
22
+ }
23
+ export declare const syncBlockInMemorySessionCache: SyncBlockInMemorySessionCache;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @generated SignedSource<<559b4fb25d0e5bc72be383427a939e2d>>
3
+ * @relayHash 38684212c43376e58fea2d6095011652
4
+ * @lightSyntaxTransform
5
+ * @nogrep
6
+ * @codegen-command: yarn relay
7
+ */
8
+ import type { ConcreteRequest } from 'relay-runtime';
9
+ export type relaySubscriptionUtilsSubscription$variables = {
10
+ resourceId: string;
11
+ };
12
+ export type relaySubscriptionUtilsSubscription$data = {
13
+ readonly blockService_onBlockUpdated: {
14
+ readonly blockAri: string;
15
+ readonly blockInstanceId: string;
16
+ readonly content: string;
17
+ readonly contentUpdatedAt: number | null | undefined;
18
+ readonly createdAt: number;
19
+ readonly createdBy: string;
20
+ readonly deletionReason: string | null | undefined;
21
+ readonly product: string;
22
+ readonly sourceAri: string;
23
+ readonly status: string;
24
+ } | null | undefined;
25
+ };
26
+ export type relaySubscriptionUtilsSubscription = {
27
+ response: relaySubscriptionUtilsSubscription$data;
28
+ variables: relaySubscriptionUtilsSubscription$variables;
29
+ };
30
+ declare const node: ConcreteRequest;
31
+ export default node;
@@ -0,0 +1,47 @@
1
+ import { type ParsedBlockSubscriptionData } from '../clients/block-service/sharedSubscriptionUtils';
2
+ import type { ResourceId } from '../common/types';
3
+ import type { SyncBlockInstance } from '../providers/types';
4
+ export type RelayBlockUpdateResponse = {
5
+ blockAri: string;
6
+ blockInstanceId: string;
7
+ content: string;
8
+ contentUpdatedAt?: number | null;
9
+ createdAt: number;
10
+ createdBy: string;
11
+ deletionReason?: string | null;
12
+ product: string;
13
+ sourceAri: string;
14
+ status: string;
15
+ };
16
+ /**
17
+ * Converts parsed subscription data to SyncBlockInstance format.
18
+ *
19
+ * @param parsed - The parsed subscription data
20
+ * @param resourceId - The resource ID for the block
21
+ * @returns A SyncBlockInstance
22
+ */
23
+ export declare function convertParsedDataToSyncBlockInstance(parsed: ParsedBlockSubscriptionData, resourceId: ResourceId): SyncBlockInstance;
24
+ /**
25
+ * Converts a Relay subscription response to SyncBlockInstance format using shared parsing logic.
26
+
27
+ * @param response - The Relay subscription response containing block update data
28
+ * @param resourceId - The resource ID for the block
29
+ * @returns A SyncBlockInstance or null if parsing fails
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * // In a Relay subscription handler
34
+ * onNext: (response) => {
35
+ * if (response?.blockService_onBlockUpdated) {
36
+ * const syncBlockInstance = convertRelayResponseToSyncBlockInstance(
37
+ * response.blockService_onBlockUpdated,
38
+ * resourceId,
39
+ * );
40
+ * if (syncBlockInstance) {
41
+ * onUpdate(syncBlockInstance);
42
+ * }
43
+ * }
44
+ * }
45
+ * ```
46
+ */
47
+ export declare function convertRelayResponseToSyncBlockInstance(response: RelayBlockUpdateResponse, resourceId: ResourceId): SyncBlockInstance | null;
@@ -0,0 +1,61 @@
1
+ import type { IEnvironment } from 'relay-runtime';
2
+ import type { ResourceId } from '../common/types';
3
+ import type { BlockSubscriptionErrorCallback, BlockUpdateCallback, Unsubscribe } from '../providers/types';
4
+ /**
5
+ * Configuration for creating a Relay block subscription.
6
+ */
7
+ export interface RelayBlockSubscriptionConfig {
8
+ /** Cloud ID for generating block ARIs */
9
+ cloudId: string;
10
+ /** Optional callback when subscription errors occur */
11
+ onError?: BlockSubscriptionErrorCallback;
12
+ /** Callback when block updates are received */
13
+ onUpdate: BlockUpdateCallback;
14
+ /** Relay environment to use for the subscription */
15
+ relayEnvironment: IEnvironment;
16
+ /** The resource ID to subscribe to */
17
+ resourceId: ResourceId;
18
+ }
19
+ /**
20
+ * Creates a Relay-based block subscription without needing to wrap providers.
21
+ * This is a clean utility function that can be used directly in components or hooks.
22
+ *
23
+ * @param config - Configuration for the subscription
24
+ * @returns An unsubscribe function to dispose the subscription
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const unsubscribe = createRelayBlockSubscription({
29
+ * relayEnvironment: environment,
30
+ * cloudId: 'my-cloud-id',
31
+ * resourceId: 'my-resource-id',
32
+ * onUpdate: (blockInstance) => {
33
+ * console.log('Block updated:', blockInstance);
34
+ * },
35
+ * onError: (error) => {
36
+ * console.error('Subscription error:', error);
37
+ * }
38
+ * });
39
+ *
40
+ * // Later, when component unmounts or subscription is no longer needed
41
+ * unsubscribe();
42
+ * ```
43
+ */
44
+ export declare function createRelayBlockSubscription(config: RelayBlockSubscriptionConfig): Unsubscribe;
45
+ /**
46
+ * Hook-like function to create a subscription function that can be passed to providers.
47
+ * This creates a function with the same signature as subscribeToBlockUpdates that uses Relay.
48
+ *
49
+ * @param cloudId - Cloud ID for generating block ARIs
50
+ * @param relayEnvironment - Optional Relay environment. If not provided, will attempt to use global environment
51
+ * @returns A function that can be used as subscribeToBlockUpdates in provider configurations
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const relaySubscribeToBlockUpdates = createRelaySubscriptionFunction(cloudId, environment);
56
+ *
57
+ * // Can be used directly as a subscribeToBlockUpdates replacement
58
+ * const unsubscribe = relaySubscribeToBlockUpdates(resourceId, onUpdate, onError);
59
+ * ```
60
+ */
61
+ export declare function createRelaySubscriptionFunction(cloudId: string, relayEnvironment?: IEnvironment): (resourceId: ResourceId, onUpdate: BlockUpdateCallback, onError?: BlockSubscriptionErrorCallback) => Unsubscribe;
@@ -1,3 +1,3 @@
1
- import type { SyncBlockProduct, SyncBlockStatus } from "../common/types";
1
+ import type { SyncBlockProduct, SyncBlockStatus } from '../common/types';
2
2
  export declare const normaliseSyncBlockProduct: (value: string | null | undefined) => SyncBlockProduct | undefined;
3
3
  export declare const normaliseSyncBlockStatus: (value: string | null | undefined) => SyncBlockStatus | undefined;
package/package.json CHANGED
@@ -34,10 +34,11 @@
34
34
  "graphql-ws": "^5.14.2",
35
35
  "lodash": "^4.17.21",
36
36
  "raf-schd": "^4.0.3",
37
+ "relay-runtime": "npm:atl-relay-runtime@0.0.0-main-39e79f66",
37
38
  "uuid": "^3.1.0"
38
39
  },
39
40
  "peerDependencies": {
40
- "@atlaskit/editor-common": "^111.16.0",
41
+ "@atlaskit/editor-common": "^111.17.0",
41
42
  "react": "^18.2.0"
42
43
  },
43
44
  "devDependencies": {
@@ -80,7 +81,7 @@
80
81
  }
81
82
  },
82
83
  "name": "@atlaskit/editor-synced-block-provider",
83
- "version": "3.30.2",
84
+ "version": "3.30.4",
84
85
  "description": "Synced Block Provider for @atlaskit/editor-plugin-synced-block",
85
86
  "author": "Atlassian Pty Ltd",
86
87
  "license": "Apache-2.0",