Skip to content

Commit 3bb87b5

Browse files
committed
Expose createSyncManager and constants under private API
1 parent a2d7c94 commit 3bb87b5

File tree

11 files changed

+35
-26
lines changed

11 files changed

+35
-26
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core-data/src/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { v4 as uuid } from 'uuid';
1010
import apiFetch from '@wordpress/api-fetch';
1111
import { addQueryArgs } from '@wordpress/url';
1212
import deprecated from '@wordpress/deprecated';
13-
import { LOCAL_EDITOR_ORIGIN, syncManager } from '@wordpress/sync';
1413

1514
/**
1615
* Internal dependencies
@@ -20,6 +19,7 @@ import { receiveItems, removeItems, receiveQueriedItems } from './queried-data';
2019
import { DEFAULT_ENTITY_KEY } from './entities';
2120
import { createBatch } from './batch';
2221
import { STORE_NAME } from './name';
22+
import { LOCAL_EDITOR_ORIGIN, syncManager } from './sync';
2323
import logEntityDeprecation from './utils/log-entity-deprecation';
2424

2525
/**

packages/core-data/src/resolvers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import { camelCase } from 'change-case';
99
import { addQueryArgs } from '@wordpress/url';
1010
import { decodeEntities } from '@wordpress/html-entities';
1111
import apiFetch from '@wordpress/api-fetch';
12-
import { syncManager } from '@wordpress/sync';
1312

1413
/**
1514
* Internal dependencies
1615
*/
1716
import { STORE_NAME } from './name';
1817
import { additionalEntityConfigLoaders, DEFAULT_ENTITY_KEY } from './entities';
18+
import { syncManager } from './sync';
1919
import {
2020
forwardResolver,
2121
getNormalizedCommaSeparable,

packages/core-data/src/test/resolvers.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
* WordPress dependencies
33
*/
44
import triggerFetch from '@wordpress/api-fetch';
5-
import { syncManager } from '@wordpress/sync';
5+
6+
/**
7+
* Internal dependencies
8+
*/
9+
import { syncManager } from '../sync';
610

711
jest.mock( '@wordpress/api-fetch' );
8-
jest.mock( '@wordpress/sync', () => ( {
12+
jest.mock( '../sync', () => ( {
913
syncManager: {
1014
load: jest.fn(),
1115
},

packages/core-data/src/utils/crdt.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import {
5-
type CRDTDoc,
6-
CRDT_RECORD_MAP_KEY,
7-
type ObjectData,
8-
} from '@wordpress/sync';
4+
import { type CRDTDoc, type ObjectData } from '@wordpress/sync';
5+
6+
/**
7+
* Internal dependencies
8+
*/
9+
import { CRDT_RECORD_MAP_KEY } from '../sync';
910

1011
export function defaultApplyChangesToCRDTDoc(
1112
crdtDoc: CRDTDoc,

packages/private-apis/src/implementation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const CORE_MODULES_USING_PRIVATE_APIS = [
2929
'@wordpress/preferences',
3030
'@wordpress/reusable-blocks',
3131
'@wordpress/router',
32+
'@wordpress/sync',
3233
'@wordpress/dataviews',
3334
'@wordpress/fields',
3435
'@wordpress/media-utils',

packages/sync/README.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,9 @@ npm install @wordpress/sync --save
1414

1515
<!-- START TOKEN(Autogenerated API docs) -->
1616

17-
### CRDT_RECORD_MAP_KEY
17+
### privateApis
1818

19-
Root-level key for the CRDT document that holds the entity record data.
20-
21-
### LOCAL_EDITOR_ORIGIN
22-
23-
Origin string for CRDT document changes originating from the local editor.
24-
25-
### syncManager
26-
27-
The sync manager orchestrates the lifecycle of syncing entity records. It creates Yjs documents, connects to providers, creates awareness instances, and coordinates with the `core-data` store.
28-
29-
_Type_
30-
31-
- `SyncManager`
19+
Private @wordpress/sync APIs
3220

3321
### Y
3422

packages/sync/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"dependencies": {
4040
"@types/simple-peer": "^9.11.5",
4141
"@wordpress/hooks": "file:../hooks",
42+
"@wordpress/private-apis": "file:../private-apis",
4243
"@wordpress/url": "file:../url",
4344
"import-locals": "^2.0.0",
4445
"lib0": "^0.2.42",

packages/sync/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
*/
1212
export * as Y from 'yjs';
1313

14-
export { CRDT_RECORD_MAP_KEY, LOCAL_EDITOR_ORIGIN } from './config';
15-
export { syncManager } from './manager';
14+
export * from './private-apis';
1615
export type * from './types';

packages/sync/src/lock-unlock.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
5+
6+
export const { lock, unlock } =
7+
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
8+
'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',
9+
'@wordpress/sync'
10+
);

0 commit comments

Comments
 (0)