@atlaskit/node-data-provider 3.0.1 → 3.1.0
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/CHANGELOG.md +12 -0
- package/dist/cjs/consumption/_lru-cache.js +3 -2
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugin-hooks.js +4 -1
- package/dist/es2019/cache.js +2 -2
- package/dist/es2019/consumption/_internal-context.js +1 -1
- package/dist/es2019/consumption/_lru-cache.js +2 -0
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/plugin-hooks.js +6 -3
- package/dist/esm/consumption/_lru-cache.js +3 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/plugin-hooks.js +4 -1
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/node-data-provider
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#109060](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109060)
|
|
8
|
+
[`4660ec858a305`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4660ec858a305) -
|
|
9
|
+
Update `React` from v16 to v18
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 3.0.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -13,7 +13,7 @@ var LRUCache = exports.LRUCache = /*#__PURE__*/function () {
|
|
|
13
13
|
this.capacity = capacity;
|
|
14
14
|
this.cache = new Map();
|
|
15
15
|
}
|
|
16
|
-
(0, _createClass2.default)(LRUCache, [{
|
|
16
|
+
return (0, _createClass2.default)(LRUCache, [{
|
|
17
17
|
key: "get",
|
|
18
18
|
value: function get(key) {
|
|
19
19
|
if (!this.cache.has(key)) {
|
|
@@ -21,6 +21,8 @@ var LRUCache = exports.LRUCache = /*#__PURE__*/function () {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Move the used key to the end to mark it as most recently used
|
|
24
|
+
// Ignored via go/ees005
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
24
26
|
var value = this.cache.get(key);
|
|
25
27
|
this.cache.delete(key);
|
|
26
28
|
this.cache.set(key, value);
|
|
@@ -40,5 +42,4 @@ var LRUCache = exports.LRUCache = /*#__PURE__*/function () {
|
|
|
40
42
|
this.cache.set(key, value);
|
|
41
43
|
}
|
|
42
44
|
}]);
|
|
43
|
-
return LRUCache;
|
|
44
45
|
}();
|
package/dist/cjs/index.js
CHANGED
|
@@ -120,7 +120,7 @@ var NodeDataProvider = exports.NodeDataProvider = /*#__PURE__*/function () {
|
|
|
120
120
|
* @see {@link buildCaches}
|
|
121
121
|
*
|
|
122
122
|
*/
|
|
123
|
-
(0, _createClass2.default)(NodeDataProvider, [{
|
|
123
|
+
return (0, _createClass2.default)(NodeDataProvider, [{
|
|
124
124
|
key: "updateCache",
|
|
125
125
|
value: function updateCache(cache, options) {
|
|
126
126
|
switch (options.strategy) {
|
|
@@ -166,6 +166,7 @@ var NodeDataProvider = exports.NodeDataProvider = /*#__PURE__*/function () {
|
|
|
166
166
|
if (!this.pending[key]) {
|
|
167
167
|
var abortController = new AbortController();
|
|
168
168
|
this.pending[key] = {
|
|
169
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
169
170
|
resolving: new Promise( /*#__PURE__*/function () {
|
|
170
171
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(res, rej) {
|
|
171
172
|
var result;
|
|
@@ -225,7 +226,6 @@ var NodeDataProvider = exports.NodeDataProvider = /*#__PURE__*/function () {
|
|
|
225
226
|
return this.pending[key].resolving;
|
|
226
227
|
}
|
|
227
228
|
}]);
|
|
228
|
-
return NodeDataProvider;
|
|
229
229
|
}(); // The purpose of this type is to ensure that either a DocNode or a PMNode is passed in
|
|
230
230
|
// to the provider.
|
|
231
231
|
// It is not opinionated about which nodes are used, so `any` is used here to allow
|
package/dist/cjs/plugin-hooks.js
CHANGED
|
@@ -28,7 +28,10 @@ var _react = require("react");
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
function useNodeDataProviderGet(options) {
|
|
31
|
-
var getResult = (0, _react.useMemo)(
|
|
31
|
+
var getResult = (0, _react.useMemo)(
|
|
32
|
+
// Ignored via go/ees005
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
34
|
+
function () {
|
|
32
35
|
return options.provider.get(options.node);
|
|
33
36
|
}, [options.provider, options.node]);
|
|
34
37
|
var _useState = (0, _react.useState)(getResult !== undefined && !isPromise(getResult) ? getResult : undefined),
|
package/dist/es2019/cache.js
CHANGED
|
@@ -49,8 +49,8 @@ export async function buildCaches({
|
|
|
49
49
|
signal = new AbortController().signal,
|
|
50
50
|
existingProvidersCache
|
|
51
51
|
}) {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const visitors = {};
|
|
53
|
+
const promises = [];
|
|
54
54
|
for (const _nodeDataProvider of Object.values(nodeDataProviders)) {
|
|
55
55
|
// widen type to avoid typescript errors with the specific node data provider types
|
|
56
56
|
const nodeDataProvider = _nodeDataProvider;
|
|
@@ -46,7 +46,7 @@ setupOptions) {
|
|
|
46
46
|
if (contentKeyRef.current !== currentContentKey) {
|
|
47
47
|
contentKeyRef.current = currentContentKey;
|
|
48
48
|
const cachedContentNdps = contentTypeNdpCaches === null || contentTypeNdpCaches === void 0 ? void 0 : contentTypeNdpCaches.get(content.contentId);
|
|
49
|
-
|
|
49
|
+
const nodeDataProviders = cachedContentNdps || setupOptions.getNodeDataProviders();
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Note: while this will remove old NodeDataProviders from the cache -- these are passed directly to consumers,
|
|
@@ -9,6 +9,8 @@ export class LRUCache {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
// Move the used key to the end to mark it as most recently used
|
|
12
|
+
// Ignored via go/ees005
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12
14
|
const value = this.cache.get(key);
|
|
13
15
|
this.cache.delete(key);
|
|
14
16
|
this.cache.set(key, value);
|
package/dist/es2019/index.js
CHANGED
|
@@ -144,10 +144,11 @@ export class NodeDataProvider {
|
|
|
144
144
|
// When a get is cancelled -- we only want to cancel the shared resolve if all signals are aborted
|
|
145
145
|
// so we keep track of all signals that are not aborted.
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
const originalSignal = (_ === null || _ === void 0 ? void 0 : _.signal) || new AbortController().signal;
|
|
148
148
|
if (!this.pending[key]) {
|
|
149
149
|
const abortController = new AbortController();
|
|
150
150
|
this.pending[key] = {
|
|
151
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
151
152
|
resolving: new Promise(async (res, rej) => {
|
|
152
153
|
try {
|
|
153
154
|
const result = await this.resolve(node, {
|
|
@@ -17,8 +17,11 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export function useNodeDataProviderGet(options) {
|
|
20
|
-
const getResult = useMemo(
|
|
21
|
-
|
|
20
|
+
const getResult = useMemo(
|
|
21
|
+
// Ignored via go/ees005
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
23
|
+
() => options.provider.get(options.node), [options.provider, options.node]);
|
|
24
|
+
const [resolved, setResolved] = useState(getResult !== undefined && !isPromise(getResult) ? getResult : undefined);
|
|
22
25
|
useEffect(() => {
|
|
23
26
|
if (!isPromise(getResult)) {
|
|
24
27
|
return;
|
|
@@ -26,7 +29,7 @@ export function useNodeDataProviderGet(options) {
|
|
|
26
29
|
let cancelled = false;
|
|
27
30
|
(async function () {
|
|
28
31
|
try {
|
|
29
|
-
|
|
32
|
+
const resolved = await getResult;
|
|
30
33
|
if (!cancelled) {
|
|
31
34
|
if (resolved === undefined) {
|
|
32
35
|
setResolved('error');
|
|
@@ -6,7 +6,7 @@ export var LRUCache = /*#__PURE__*/function () {
|
|
|
6
6
|
this.capacity = capacity;
|
|
7
7
|
this.cache = new Map();
|
|
8
8
|
}
|
|
9
|
-
_createClass(LRUCache, [{
|
|
9
|
+
return _createClass(LRUCache, [{
|
|
10
10
|
key: "get",
|
|
11
11
|
value: function get(key) {
|
|
12
12
|
if (!this.cache.has(key)) {
|
|
@@ -14,6 +14,8 @@ export var LRUCache = /*#__PURE__*/function () {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// Move the used key to the end to mark it as most recently used
|
|
17
|
+
// Ignored via go/ees005
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
17
19
|
var value = this.cache.get(key);
|
|
18
20
|
this.cache.delete(key);
|
|
19
21
|
this.cache.set(key, value);
|
|
@@ -33,5 +35,4 @@ export var LRUCache = /*#__PURE__*/function () {
|
|
|
33
35
|
this.cache.set(key, value);
|
|
34
36
|
}
|
|
35
37
|
}]);
|
|
36
|
-
return LRUCache;
|
|
37
38
|
}();
|
package/dist/esm/index.js
CHANGED
|
@@ -113,7 +113,7 @@ export var NodeDataProvider = /*#__PURE__*/function () {
|
|
|
113
113
|
* @see {@link buildCaches}
|
|
114
114
|
*
|
|
115
115
|
*/
|
|
116
|
-
_createClass(NodeDataProvider, [{
|
|
116
|
+
return _createClass(NodeDataProvider, [{
|
|
117
117
|
key: "updateCache",
|
|
118
118
|
value: function updateCache(cache, options) {
|
|
119
119
|
switch (options.strategy) {
|
|
@@ -159,6 +159,7 @@ export var NodeDataProvider = /*#__PURE__*/function () {
|
|
|
159
159
|
if (!this.pending[key]) {
|
|
160
160
|
var abortController = new AbortController();
|
|
161
161
|
this.pending[key] = {
|
|
162
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
162
163
|
resolving: new Promise( /*#__PURE__*/function () {
|
|
163
164
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(res, rej) {
|
|
164
165
|
var result;
|
|
@@ -218,7 +219,6 @@ export var NodeDataProvider = /*#__PURE__*/function () {
|
|
|
218
219
|
return this.pending[key].resolving;
|
|
219
220
|
}
|
|
220
221
|
}]);
|
|
221
|
-
return NodeDataProvider;
|
|
222
222
|
}();
|
|
223
223
|
|
|
224
224
|
// The purpose of this type is to ensure that either a DocNode or a PMNode is passed in
|
package/dist/esm/plugin-hooks.js
CHANGED
|
@@ -21,7 +21,10 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export function useNodeDataProviderGet(options) {
|
|
24
|
-
var getResult = useMemo(
|
|
24
|
+
var getResult = useMemo(
|
|
25
|
+
// Ignored via go/ees005
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
27
|
+
function () {
|
|
25
28
|
return options.provider.get(options.node);
|
|
26
29
|
}, [options.provider, options.node]);
|
|
27
30
|
var _useState = useState(getResult !== undefined && !isPromise(getResult) ? getResult : undefined),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/node-data-provider",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Node data provider for @atlaskit/editor-core plugins and @atlaskit/renderer",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
32
|
-
"@atlaskit/adf-utils": "^19.
|
|
33
|
-
"@atlaskit/emoji": "^67.
|
|
32
|
+
"@atlaskit/adf-utils": "^19.18.0",
|
|
33
|
+
"@atlaskit/emoji": "^67.13.0",
|
|
34
34
|
"@babel/runtime": "^7.0.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@atlaskit/editor-test-helpers": "*",
|
|
41
|
-
"@testing-library/react": "^
|
|
41
|
+
"@testing-library/react": "^13.4.0",
|
|
42
42
|
"@testing-library/react-hooks": "^8.0.1",
|
|
43
43
|
"typescript": "~5.4.2"
|
|
44
44
|
},
|
|
@@ -56,11 +56,12 @@
|
|
|
56
56
|
"analytics": [
|
|
57
57
|
"analytics-next"
|
|
58
58
|
],
|
|
59
|
-
"deprecation":
|
|
60
|
-
"no-deprecated-imports"
|
|
61
|
-
],
|
|
59
|
+
"deprecation": "no-deprecated-imports",
|
|
62
60
|
"imports": [
|
|
63
61
|
"import-no-extraneous-disable-for-examples-and-docs"
|
|
62
|
+
],
|
|
63
|
+
"styling": [
|
|
64
|
+
"emotion"
|
|
64
65
|
]
|
|
65
66
|
}
|
|
66
67
|
},
|