@atlaskit/node-data-provider 4.1.2 → 4.2.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 +9 -0
- package/dist/cjs/index.js +1 -232
- package/dist/es2019/index.js +0 -191
- package/dist/esm/index.js +0 -227
- package/dist/types/index.d.ts +0 -134
- package/dist/types-ts4.5/index.d.ts +0 -134
- package/package.json +2 -10
- package/cache/package.json +0 -15
- package/content/package.json +0 -15
- package/dist/cjs/cache.js +0 -145
- package/dist/cjs/consumption/_global-ndp-caches.js +0 -21
- package/dist/cjs/consumption/_internal-context.js +0 -77
- package/dist/cjs/consumption/_lru-cache.js +0 -45
- package/dist/cjs/consumption/content.js +0 -56
- package/dist/cjs/get-providers/confluence-page.js +0 -15
- package/dist/cjs/internal-types.js +0 -5
- package/dist/cjs/plugin-hooks.js +0 -100
- package/dist/cjs/providers/emoji.js +0 -54
- package/dist/es2019/cache.js +0 -96
- package/dist/es2019/consumption/_global-ndp-caches.js +0 -13
- package/dist/es2019/consumption/_internal-context.js +0 -71
- package/dist/es2019/consumption/_lru-cache.js +0 -30
- package/dist/es2019/consumption/content.js +0 -49
- package/dist/es2019/get-providers/confluence-page.js +0 -10
- package/dist/es2019/internal-types.js +0 -1
- package/dist/es2019/plugin-hooks.js +0 -69
- package/dist/es2019/providers/emoji.js +0 -26
- package/dist/esm/cache.js +0 -141
- package/dist/esm/consumption/_global-ndp-caches.js +0 -13
- package/dist/esm/consumption/_internal-context.js +0 -71
- package/dist/esm/consumption/_lru-cache.js +0 -38
- package/dist/esm/consumption/content.js +0 -49
- package/dist/esm/get-providers/confluence-page.js +0 -9
- package/dist/esm/internal-types.js +0 -1
- package/dist/esm/plugin-hooks.js +0 -93
- package/dist/esm/providers/emoji.js +0 -47
- package/dist/types/cache.d.ts +0 -61
- package/dist/types/consumption/_global-ndp-caches.d.ts +0 -8
- package/dist/types/consumption/_internal-context.d.ts +0 -32
- package/dist/types/consumption/_lru-cache.d.ts +0 -7
- package/dist/types/consumption/content.d.ts +0 -65
- package/dist/types/get-providers/confluence-page.d.ts +0 -6
- package/dist/types/internal-types.d.ts +0 -2
- package/dist/types/plugin-hooks.d.ts +0 -32
- package/dist/types/providers/emoji.d.ts +0 -10
- package/dist/types-ts4.5/cache.d.ts +0 -61
- package/dist/types-ts4.5/consumption/_global-ndp-caches.d.ts +0 -8
- package/dist/types-ts4.5/consumption/_internal-context.d.ts +0 -32
- package/dist/types-ts4.5/consumption/_lru-cache.d.ts +0 -7
- package/dist/types-ts4.5/consumption/content.d.ts +0 -65
- package/dist/types-ts4.5/get-providers/confluence-page.d.ts +0 -6
- package/dist/types-ts4.5/internal-types.d.ts +0 -2
- package/dist/types-ts4.5/plugin-hooks.d.ts +0 -32
- package/dist/types-ts4.5/providers/emoji.d.ts +0 -10
- package/emoji-provider/package.json +0 -15
- package/get-confluence-page-providers/package.json +0 -15
- package/plugin-hooks/package.json +0 -15
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type { NodeDataProvider } from './index';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This hook is intended to simplify accessing data via the one tick providers.
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* const value = useNodeDataProviderGet(emojiProvider, emojiNode);
|
|
10
|
-
*
|
|
11
|
-
* if (value.state === 'loading') {
|
|
12
|
-
* return <Loading />;
|
|
13
|
-
* }
|
|
14
|
-
* if (value.state === 'failed') {
|
|
15
|
-
* return <Fallback />;
|
|
16
|
-
* }
|
|
17
|
-
* return <Emoji properties=(value.result) />
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function useNodeDataProviderGet<_NodeDataProvider extends NodeDataProvider<any, any>>(options: {
|
|
21
|
-
provider: _NodeDataProvider;
|
|
22
|
-
node: PMNode;
|
|
23
|
-
}): {
|
|
24
|
-
state: 'loading';
|
|
25
|
-
result: undefined;
|
|
26
|
-
} | {
|
|
27
|
-
state: 'failed';
|
|
28
|
-
result: undefined;
|
|
29
|
-
} | {
|
|
30
|
-
state: 'resolved';
|
|
31
|
-
result: _NodeDataProvider['cache'][string];
|
|
32
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type EmojiAttributes } from '@atlaskit/adf-schema';
|
|
2
|
-
import type { EmojiDescriptionWithVariations, EmojiProvider } from '@atlaskit/emoji';
|
|
3
|
-
import { NodeDataProvider } from '../index';
|
|
4
|
-
export declare function createEmojiNodeDataProvider({ emojiProvider, existingCache, }: {
|
|
5
|
-
emojiProvider: Promise<EmojiProvider>;
|
|
6
|
-
existingCache?: Record<string, EmojiDescriptionWithVariations>;
|
|
7
|
-
}): EmojiNodeDataProvider;
|
|
8
|
-
export type EmojiNodeDataProvider = NodeDataProvider<{
|
|
9
|
-
attrs: EmojiAttributes;
|
|
10
|
-
}, EmojiDescriptionWithVariations>;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
|
-
import { type AnyNodeDataProvider } from './internal-types';
|
|
3
|
-
import { type EmojiNodeDataProvider } from './providers/emoji';
|
|
4
|
-
export type NodeDataProvidersCache = {
|
|
5
|
-
[nodeName: string]: Record<string, any>;
|
|
6
|
-
};
|
|
7
|
-
export type NodeDataProviders = {
|
|
8
|
-
emoji: EmojiNodeDataProvider;
|
|
9
|
-
[nodeName: string]: AnyNodeDataProvider;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Builds {@link NodeDataProvider}s caches for a document.
|
|
13
|
-
*
|
|
14
|
-
* It will traverse the document and call the resolve method for each node.
|
|
15
|
-
* When all promises are resolved, NodeDataProviders will have their caches populated.
|
|
16
|
-
*
|
|
17
|
-
* The providers will then be ready for use with an Editor.
|
|
18
|
-
*
|
|
19
|
-
* To limit the time spent building the cache, a signal can be provided to abort the request.
|
|
20
|
-
*
|
|
21
|
-
* ## Usage
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* buildCaches({
|
|
26
|
-
* adf: doc,
|
|
27
|
-
* nodeDataProviders: { emoji: emojiNodeDataProvider, ... },
|
|
28
|
-
* signal: AbortSignal.timeout(5000),
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* ### Using caches
|
|
33
|
-
*
|
|
34
|
-
* To make use of a cache in another provider (ie. for a cache created on the server), you can retrieve the cache
|
|
35
|
-
* from the provider and pass it to the new provider.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```tsx
|
|
39
|
-
* // SSR env
|
|
40
|
-
* const ssrProvidersCaches = await buildCaches({adf, nodeDataProviders: { emoji }})
|
|
41
|
-
*
|
|
42
|
-
* // Client env (providersCaches is the cache from the server)
|
|
43
|
-
* <ContentNodeDataProviders ... existingProvidersCache={ssrProvidersCaches} />
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* *Note:* On the client - buildCache is not expected to be used directly.
|
|
47
|
-
*
|
|
48
|
-
* @see {@link ContentNodeDataProviders} for expected client usage.
|
|
49
|
-
*/
|
|
50
|
-
export declare function buildCaches({ adf, nodeDataProviders, signal, existingProvidersCache, }: {
|
|
51
|
-
adf?: DocNode;
|
|
52
|
-
/**
|
|
53
|
-
* Providers to build caches for
|
|
54
|
-
*/
|
|
55
|
-
nodeDataProviders: NodeDataProviders;
|
|
56
|
-
/**
|
|
57
|
-
* Signal to abort cache building -- the caches will be built up to the point of abort.
|
|
58
|
-
*/
|
|
59
|
-
signal?: AbortSignal;
|
|
60
|
-
existingProvidersCache?: NodeDataProvidersCache;
|
|
61
|
-
}): Promise<NodeDataProvidersCache>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type NodeDataProviders } from '../cache';
|
|
2
|
-
import { type LRUCache } from './_lru-cache';
|
|
3
|
-
type GlobalNdpCachesContextValue = {
|
|
4
|
-
[contentType: string]: LRUCache<NodeDataProviders>;
|
|
5
|
-
};
|
|
6
|
-
export declare function useGlobalNdpCachesContext(): GlobalNdpCachesContextValue;
|
|
7
|
-
export declare function _resetGlobalNdpCachesContext(): void;
|
|
8
|
-
export {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { type DocNode } from '@atlaskit/adf-schema';
|
|
2
|
-
import { type NodeDataProviders, type NodeDataProvidersCache } from '../cache';
|
|
3
|
-
/**
|
|
4
|
-
* Sets up nodeview data providers for a content node.
|
|
5
|
-
*
|
|
6
|
-
* This will return the cached node data providers if they exist, otherwise it will call the provided getNodeDataProviders function.
|
|
7
|
-
*
|
|
8
|
-
* Note: Calling this has side effects where caches for the nodeview data providers will continue to be built
|
|
9
|
-
* in the background after this resolves to a set of nodeview data providers that can be used.
|
|
10
|
-
*/
|
|
11
|
-
export declare function useContentNodeDataProvidersSetup(content: {
|
|
12
|
-
/**
|
|
13
|
-
* The type of content.
|
|
14
|
-
*/
|
|
15
|
-
contentType: 'page';
|
|
16
|
-
contentId: string;
|
|
17
|
-
},
|
|
18
|
-
/**
|
|
19
|
-
* Note: changes to this object will not be reflected in the cache.
|
|
20
|
-
*/
|
|
21
|
-
setupOptions: {
|
|
22
|
-
/**
|
|
23
|
-
* Note: this will only be used if no existing NodeDataProviders are found for the content.
|
|
24
|
-
*/
|
|
25
|
-
adfToUpdateWith?: DocNode;
|
|
26
|
-
existingProvidersCache?: NodeDataProvidersCache;
|
|
27
|
-
getNodeDataProviders: () => NodeDataProviders;
|
|
28
|
-
onCacheWarmed?: (_: {
|
|
29
|
-
warmedNodeDataProvidersCache: NodeDataProvidersCache;
|
|
30
|
-
nodeDataProviders: NodeDataProviders;
|
|
31
|
-
}) => void;
|
|
32
|
-
}): NodeDataProviders | undefined;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type DocNode } from '@atlaskit/adf-schema';
|
|
3
|
-
import { type NodeDataProviders, type NodeDataProvidersCache } from '../cache';
|
|
4
|
-
import { _resetGlobalNdpCachesContext } from './_global-ndp-caches';
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* <ContentNodeDataProviders
|
|
10
|
-
* contentType="page" contentId="9001"
|
|
11
|
-
* adf={doc}
|
|
12
|
-
* placeholder={<Spinner />}
|
|
13
|
-
* existingProvidersCache={ssrProvidersCache}
|
|
14
|
-
* getNodeDataProviders={getPageNodeDataProviders}
|
|
15
|
-
* onCacheWarmed={trackCacheWarmed}
|
|
16
|
-
* >
|
|
17
|
-
* <Editor />
|
|
18
|
-
* </ContentNodeDataProviders>
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function ContentNodeDataProviders(props: {
|
|
22
|
-
/**
|
|
23
|
-
* The type of content, this is used to group the resulting providers cache
|
|
24
|
-
*
|
|
25
|
-
* Note: Providers Caches are stored in an internal LRU cache, are grouped by content type.
|
|
26
|
-
*/
|
|
27
|
-
contentType: 'page';
|
|
28
|
-
/**
|
|
29
|
-
* The type of content, this is used to group the resulting providers cache
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
contentId: string;
|
|
33
|
-
/**
|
|
34
|
-
* This is optional - when passed the caches in the data providers will be warmed
|
|
35
|
-
* based on this document.
|
|
36
|
-
*/
|
|
37
|
-
adf?: DocNode;
|
|
38
|
-
/**
|
|
39
|
-
* This is optional, and supports passing in an existing providers cache.
|
|
40
|
-
*
|
|
41
|
-
* An example of this is when you have a server-side rendered providers cache that you want to use on the client.
|
|
42
|
-
*/
|
|
43
|
-
existingProvidersCache?: NodeDataProvidersCache;
|
|
44
|
-
/**
|
|
45
|
-
* Returns a set of `NodeDataProviders` which are put in context for use when creating an editor or renderer.
|
|
46
|
-
* These will be pre-warmed if adf is passed in.
|
|
47
|
-
*/
|
|
48
|
-
getNodeDataProviders: () => NodeDataProviders;
|
|
49
|
-
/**
|
|
50
|
-
* Called when the cache is warmed.
|
|
51
|
-
*/
|
|
52
|
-
onCacheWarmed?: (_: {
|
|
53
|
-
warmedNodeDataProvidersCache: NodeDataProvidersCache;
|
|
54
|
-
nodeDataProviders: NodeDataProviders;
|
|
55
|
-
}) => void;
|
|
56
|
-
children: React.ReactNode;
|
|
57
|
-
}): React.JSX.Element;
|
|
58
|
-
export declare function useContentNodeDataProviders(): NodeDataProviders | undefined;
|
|
59
|
-
export {
|
|
60
|
-
/**
|
|
61
|
-
* Exported for testing purposes only.
|
|
62
|
-
*
|
|
63
|
-
* This API will change.
|
|
64
|
-
*/
|
|
65
|
-
_resetGlobalNdpCachesContext as __testOnly_resetGlobalNdpCachesContext, };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type { NodeDataProvider } from './index';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This hook is intended to simplify accessing data via the one tick providers.
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* const value = useNodeDataProviderGet(emojiProvider, emojiNode);
|
|
10
|
-
*
|
|
11
|
-
* if (value.state === 'loading') {
|
|
12
|
-
* return <Loading />;
|
|
13
|
-
* }
|
|
14
|
-
* if (value.state === 'failed') {
|
|
15
|
-
* return <Fallback />;
|
|
16
|
-
* }
|
|
17
|
-
* return <Emoji properties=(value.result) />
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function useNodeDataProviderGet<_NodeDataProvider extends NodeDataProvider<any, any>>(options: {
|
|
21
|
-
provider: _NodeDataProvider;
|
|
22
|
-
node: PMNode;
|
|
23
|
-
}): {
|
|
24
|
-
state: 'loading';
|
|
25
|
-
result: undefined;
|
|
26
|
-
} | {
|
|
27
|
-
state: 'failed';
|
|
28
|
-
result: undefined;
|
|
29
|
-
} | {
|
|
30
|
-
state: 'resolved';
|
|
31
|
-
result: _NodeDataProvider['cache'][string];
|
|
32
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type EmojiAttributes } from '@atlaskit/adf-schema';
|
|
2
|
-
import type { EmojiDescriptionWithVariations, EmojiProvider } from '@atlaskit/emoji';
|
|
3
|
-
import { NodeDataProvider } from '../index';
|
|
4
|
-
export declare function createEmojiNodeDataProvider({ emojiProvider, existingCache, }: {
|
|
5
|
-
emojiProvider: Promise<EmojiProvider>;
|
|
6
|
-
existingCache?: Record<string, EmojiDescriptionWithVariations>;
|
|
7
|
-
}): EmojiNodeDataProvider;
|
|
8
|
-
export type EmojiNodeDataProvider = NodeDataProvider<{
|
|
9
|
-
attrs: EmojiAttributes;
|
|
10
|
-
}, EmojiDescriptionWithVariations>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/node-data-provider/emoji-provider",
|
|
3
|
-
"main": "../dist/cjs/providers/emoji.js",
|
|
4
|
-
"module": "../dist/esm/providers/emoji.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/providers/emoji.js",
|
|
6
|
-
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/providers/emoji.d.ts",
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.4": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/providers/emoji.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/node-data-provider/get-confluence-page-providers",
|
|
3
|
-
"main": "../dist/cjs/get-providers/confluence-page.js",
|
|
4
|
-
"module": "../dist/esm/get-providers/confluence-page.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/get-providers/confluence-page.js",
|
|
6
|
-
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/get-providers/confluence-page.d.ts",
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.4": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/get-providers/confluence-page.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/node-data-provider/plugin-hooks",
|
|
3
|
-
"main": "../dist/cjs/plugin-hooks.js",
|
|
4
|
-
"module": "../dist/esm/plugin-hooks.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/plugin-hooks.js",
|
|
6
|
-
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/plugin-hooks.d.ts",
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.4": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/plugin-hooks.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|