@wordpress/core-data 7.42.0 → 7.43.2-next.v.202604091042.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 -1
- package/build/entities.cjs +28 -20
- package/build/entities.cjs.map +2 -2
- package/build/hooks/index.cjs +3 -3
- package/build/hooks/index.cjs.map +1 -1
- package/build/hooks/use-entity-record.cjs +4 -4
- package/build/hooks/use-entity-record.cjs.map +2 -2
- package/build/hooks/use-entity-records.cjs +3 -3
- package/build/hooks/use-entity-records.cjs.map +2 -2
- package/build/hooks/use-query-select.cjs +2 -2
- package/build/hooks/use-query-select.cjs.map +2 -2
- package/build/hooks/use-resource-permissions.cjs +4 -4
- package/build/hooks/use-resource-permissions.cjs.map +2 -2
- package/build/private-actions.cjs +10 -0
- package/build/private-actions.cjs.map +2 -2
- package/build/private-selectors.cjs +20 -3
- package/build/private-selectors.cjs.map +2 -2
- package/build/queried-data/get-query-parts.cjs +8 -7
- package/build/queried-data/get-query-parts.cjs.map +2 -2
- package/build/queried-data/reducer.cjs +15 -9
- package/build/queried-data/reducer.cjs.map +2 -2
- package/build/queried-data/selectors.cjs +23 -22
- package/build/queried-data/selectors.cjs.map +2 -2
- package/build/reducer.cjs +16 -3
- package/build/reducer.cjs.map +2 -2
- package/build/resolvers.cjs +22 -14
- package/build/resolvers.cjs.map +2 -2
- package/build/selectors.cjs +20 -10
- package/build/selectors.cjs.map +2 -2
- package/build/utils/crdt-blocks.cjs +170 -31
- package/build/utils/crdt-blocks.cjs.map +2 -2
- package/build/utils/crdt-text.cjs +52 -0
- package/build/utils/crdt-text.cjs.map +7 -0
- package/build/utils/crdt.cjs +13 -0
- package/build/utils/crdt.cjs.map +2 -2
- package/build/utils/index.cjs +0 -3
- package/build/utils/index.cjs.map +2 -2
- package/build-module/entities.mjs +29 -20
- package/build-module/entities.mjs.map +2 -2
- package/build-module/hooks/index.mjs +6 -6
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/use-entity-record.mjs +3 -3
- package/build-module/hooks/use-entity-record.mjs.map +2 -2
- package/build-module/hooks/use-entity-records.mjs +2 -2
- package/build-module/hooks/use-entity-records.mjs.map +2 -2
- package/build-module/hooks/use-query-select.mjs +1 -1
- package/build-module/hooks/use-query-select.mjs.map +1 -1
- package/build-module/hooks/use-resource-permissions.mjs +3 -3
- package/build-module/hooks/use-resource-permissions.mjs.map +2 -2
- package/build-module/private-actions.mjs +9 -0
- package/build-module/private-actions.mjs.map +2 -2
- package/build-module/private-selectors.mjs +19 -3
- package/build-module/private-selectors.mjs.map +2 -2
- package/build-module/queried-data/get-query-parts.mjs +8 -7
- package/build-module/queried-data/get-query-parts.mjs.map +2 -2
- package/build-module/queried-data/reducer.mjs +15 -9
- package/build-module/queried-data/reducer.mjs.map +2 -2
- package/build-module/queried-data/selectors.mjs +23 -22
- package/build-module/queried-data/selectors.mjs.map +2 -2
- package/build-module/reducer.mjs +14 -2
- package/build-module/reducer.mjs.map +2 -2
- package/build-module/resolvers.mjs +20 -13
- package/build-module/resolvers.mjs.map +2 -2
- package/build-module/selectors.mjs +20 -11
- package/build-module/selectors.mjs.map +2 -2
- package/build-module/utils/crdt-blocks.mjs +169 -31
- package/build-module/utils/crdt-blocks.mjs.map +2 -2
- package/build-module/utils/crdt-text.mjs +26 -0
- package/build-module/utils/crdt-text.mjs.map +7 -0
- package/build-module/utils/crdt.mjs +13 -0
- package/build-module/utils/crdt.mjs.map +2 -2
- package/build-module/utils/index.mjs +8 -10
- package/build-module/utils/index.mjs.map +2 -2
- package/build-types/entities.d.ts +51 -32
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/hooks/index.d.ts +3 -3
- package/build-types/hooks/index.d.ts.map +1 -1
- package/build-types/hooks/use-entity-record.d.ts +1 -1
- package/build-types/hooks/use-entity-record.d.ts.map +1 -1
- package/build-types/hooks/use-entity-records.d.ts +1 -1
- package/build-types/hooks/use-entity-records.d.ts.map +1 -1
- package/build-types/hooks/use-resource-permissions.d.ts +1 -1
- package/build-types/hooks/use-resource-permissions.d.ts.map +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/private-actions.d.ts +10 -0
- package/build-types/private-actions.d.ts.map +1 -1
- package/build-types/private-selectors.d.ts +11 -4
- package/build-types/private-selectors.d.ts.map +1 -1
- package/build-types/queried-data/get-query-parts.d.ts +11 -19
- package/build-types/queried-data/get-query-parts.d.ts.map +1 -1
- package/build-types/queried-data/reducer.d.ts +11 -5
- package/build-types/queried-data/reducer.d.ts.map +1 -1
- package/build-types/queried-data/selectors.d.ts +5 -3
- package/build-types/queried-data/selectors.d.ts.map +1 -1
- package/build-types/reducer.d.ts +11 -0
- package/build-types/reducer.d.ts.map +1 -1
- package/build-types/resolvers.d.ts +3 -0
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts +1 -0
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts +11 -0
- package/build-types/utils/crdt-blocks.d.ts.map +1 -1
- package/build-types/utils/crdt-text.d.ts +16 -0
- package/build-types/utils/crdt-text.d.ts.map +1 -0
- package/build-types/utils/crdt.d.ts +7 -0
- package/build-types/utils/crdt.d.ts.map +1 -1
- package/build-types/utils/index.d.ts +0 -1
- package/package.json +18 -18
- package/src/entities.js +16 -8
- package/src/hooks/index.ts +3 -3
- package/src/hooks/test/use-entity-records.js +1 -1
- package/src/hooks/use-entity-record.ts +1 -1
- package/src/hooks/use-entity-records.ts +1 -1
- package/src/hooks/use-query-select.ts +1 -1
- package/src/hooks/use-resource-permissions.ts +1 -1
- package/src/private-actions.js +18 -0
- package/src/private-selectors.ts +37 -4
- package/src/queried-data/get-query-parts.js +14 -20
- package/src/queried-data/reducer.js +28 -15
- package/src/queried-data/selectors.js +34 -38
- package/src/queried-data/test/get-query-parts.js +11 -11
- package/src/queried-data/test/reducer.js +78 -8
- package/src/queried-data/test/selectors.js +52 -30
- package/src/reducer.js +20 -0
- package/src/resolvers.js +29 -13
- package/src/selectors.ts +28 -21
- package/src/utils/crdt-blocks.ts +348 -60
- package/src/utils/crdt-text.ts +43 -0
- package/src/utils/crdt.ts +25 -0
- package/src/utils/index.js +0 -1
- package/src/utils/test/crdt-blocks.ts +838 -6
- package/src/utils/test/crdt.ts +147 -1
- package/build/hooks/memoize.cjs +0 -38
- package/build/hooks/memoize.cjs.map +0 -7
- package/build/utils/is-raw-attribute.cjs +0 -29
- package/build/utils/is-raw-attribute.cjs.map +0 -7
- package/build-module/hooks/memoize.mjs +0 -7
- package/build-module/hooks/memoize.mjs.map +0 -7
- package/build-module/utils/is-raw-attribute.mjs +0 -8
- package/build-module/utils/is-raw-attribute.mjs.map +0 -7
- package/build-types/hooks/memoize.d.ts +0 -3
- package/build-types/hooks/memoize.d.ts.map +0 -1
- package/build-types/utils/is-raw-attribute.d.ts +0 -10
- package/build-types/utils/is-raw-attribute.d.ts.map +0 -1
- package/src/hooks/memoize.js +0 -7
- package/src/utils/is-raw-attribute.js +0 -11
- package/src/utils/test/is-raw-attribute.js +0 -22
package/src/utils/test/crdt.ts
CHANGED
|
@@ -8,12 +8,56 @@ import { Y } from '@wordpress/sync';
|
|
|
8
8
|
*/
|
|
9
9
|
import { describe, expect, it, jest, beforeEach } from '@jest/globals';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Mock getBlockTypes so CRDT merging can identify rich-text attributes.
|
|
13
|
+
*/
|
|
14
|
+
jest.mock( '@wordpress/blocks', () => {
|
|
15
|
+
const actual = jest.requireActual( '@wordpress/blocks' ) as Record<
|
|
16
|
+
string,
|
|
17
|
+
unknown
|
|
18
|
+
>;
|
|
19
|
+
return {
|
|
20
|
+
...actual,
|
|
21
|
+
getBlockTypes: () => [
|
|
22
|
+
{
|
|
23
|
+
name: 'core/paragraph',
|
|
24
|
+
attributes: { content: { type: 'rich-text' } },
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'core/table',
|
|
28
|
+
attributes: {
|
|
29
|
+
hasFixedLayout: { type: 'boolean' },
|
|
30
|
+
caption: { type: 'rich-text' },
|
|
31
|
+
body: {
|
|
32
|
+
type: 'array',
|
|
33
|
+
query: {
|
|
34
|
+
cells: {
|
|
35
|
+
type: 'array',
|
|
36
|
+
query: {
|
|
37
|
+
content: { type: 'rich-text' },
|
|
38
|
+
tag: { type: 'string' },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
} );
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* WordPress dependencies
|
|
51
|
+
*/
|
|
52
|
+
import { RichTextData } from '@wordpress/rich-text';
|
|
53
|
+
|
|
11
54
|
/**
|
|
12
55
|
* Internal dependencies
|
|
13
56
|
*/
|
|
14
57
|
import { CRDT_RECORD_MAP_KEY } from '../../sync';
|
|
15
58
|
import {
|
|
16
59
|
applyPostChangesToCRDTDoc,
|
|
60
|
+
defaultCollectionSyncConfig,
|
|
17
61
|
getPostChangesFromCRDTDoc,
|
|
18
62
|
POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE,
|
|
19
63
|
type PostChanges,
|
|
@@ -39,6 +83,43 @@ const defaultSyncedProperties = new Set< string >( [
|
|
|
39
83
|
'title',
|
|
40
84
|
] );
|
|
41
85
|
|
|
86
|
+
describe( 'defaultCollectionSyncConfig', () => {
|
|
87
|
+
it( 'has no-op applyChangesToCRDTDoc', () => {
|
|
88
|
+
const doc = new Y.Doc();
|
|
89
|
+
// Should not throw and return undefined.
|
|
90
|
+
expect(
|
|
91
|
+
defaultCollectionSyncConfig.applyChangesToCRDTDoc( doc, {
|
|
92
|
+
title: 'test',
|
|
93
|
+
} )
|
|
94
|
+
).toBeUndefined();
|
|
95
|
+
doc.destroy();
|
|
96
|
+
} );
|
|
97
|
+
|
|
98
|
+
it( 'has getChangesFromCRDTDoc that returns empty object', () => {
|
|
99
|
+
const doc = new Y.Doc();
|
|
100
|
+
const result = defaultCollectionSyncConfig.getChangesFromCRDTDoc( doc, {
|
|
101
|
+
title: 'test',
|
|
102
|
+
} );
|
|
103
|
+
expect( result ).toEqual( {} );
|
|
104
|
+
doc.destroy();
|
|
105
|
+
} );
|
|
106
|
+
|
|
107
|
+
it( 'shouldSync returns true when objectId is null (collection)', () => {
|
|
108
|
+
expect(
|
|
109
|
+
defaultCollectionSyncConfig.shouldSync?.( 'comment', null )
|
|
110
|
+
).toBe( true );
|
|
111
|
+
} );
|
|
112
|
+
|
|
113
|
+
it( 'shouldSync returns false when objectId is provided (individual record)', () => {
|
|
114
|
+
expect(
|
|
115
|
+
defaultCollectionSyncConfig.shouldSync?.( 'comment', '123' )
|
|
116
|
+
).toBe( false );
|
|
117
|
+
expect(
|
|
118
|
+
defaultCollectionSyncConfig.shouldSync?.( 'comment', 'foo' )
|
|
119
|
+
).toBe( false );
|
|
120
|
+
} );
|
|
121
|
+
} );
|
|
122
|
+
|
|
42
123
|
describe( 'crdt', () => {
|
|
43
124
|
let doc: Y.Doc;
|
|
44
125
|
|
|
@@ -515,6 +596,68 @@ describe( 'crdt', () => {
|
|
|
515
596
|
expect( changes ).toHaveProperty( 'blocks' );
|
|
516
597
|
} );
|
|
517
598
|
|
|
599
|
+
it( 'returns rich-text block attributes as RichTextData, not strings', () => {
|
|
600
|
+
// Simulate User A writing a paragraph block into the CRDT doc.
|
|
601
|
+
addBlockToDoc( map, 'block-1', 'Hello world' );
|
|
602
|
+
|
|
603
|
+
// Simulate User B reading the CRDT doc with no local blocks.
|
|
604
|
+
const editedRecord = { blocks: [] } as unknown as Post;
|
|
605
|
+
|
|
606
|
+
const changes = getPostChangesFromCRDTDoc(
|
|
607
|
+
doc,
|
|
608
|
+
editedRecord,
|
|
609
|
+
defaultSyncedProperties
|
|
610
|
+
);
|
|
611
|
+
|
|
612
|
+
const block = ( changes.blocks as any[] )?.[ 0 ];
|
|
613
|
+
expect( block ).toBeDefined();
|
|
614
|
+
expect( block.attributes.content ).toBeInstanceOf( RichTextData );
|
|
615
|
+
expect( block.attributes.content.text ).toBe( 'Hello world' );
|
|
616
|
+
} );
|
|
617
|
+
|
|
618
|
+
it( 'returns nested rich-text in array attributes as RichTextData', () => {
|
|
619
|
+
// Add a table block to the CRDT doc with nested cell content
|
|
620
|
+
// stored as plain strings.
|
|
621
|
+
let blocks = map.get( 'blocks' );
|
|
622
|
+
if ( ! ( blocks instanceof Y.Array ) ) {
|
|
623
|
+
blocks = new Y.Array< YBlock >();
|
|
624
|
+
map.set( 'blocks', blocks );
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
const tableBlock = createYMap< YBlockRecord >();
|
|
628
|
+
tableBlock.set( 'name', 'core/table' );
|
|
629
|
+
tableBlock.set( 'clientId', 'table-1' );
|
|
630
|
+
const attrs = new Y.Map();
|
|
631
|
+
attrs.set( 'body', [
|
|
632
|
+
{
|
|
633
|
+
cells: [
|
|
634
|
+
{ content: '<strong>Cell</strong>', tag: 'td' },
|
|
635
|
+
{ content: 'Plain', tag: 'td' },
|
|
636
|
+
],
|
|
637
|
+
},
|
|
638
|
+
] );
|
|
639
|
+
tableBlock.set( 'attributes', attrs );
|
|
640
|
+
tableBlock.set( 'innerBlocks', new Y.Array() );
|
|
641
|
+
( blocks as YBlocks ).push( [ tableBlock ] );
|
|
642
|
+
|
|
643
|
+
const editedRecord = { blocks: [] } as unknown as Post;
|
|
644
|
+
|
|
645
|
+
const changes = getPostChangesFromCRDTDoc(
|
|
646
|
+
doc,
|
|
647
|
+
editedRecord,
|
|
648
|
+
defaultSyncedProperties
|
|
649
|
+
);
|
|
650
|
+
|
|
651
|
+
const block = ( changes.blocks as any[] )?.[ 0 ];
|
|
652
|
+
expect( block ).toBeDefined();
|
|
653
|
+
|
|
654
|
+
const cell = block.attributes.body[ 0 ].cells[ 0 ];
|
|
655
|
+
expect( cell.content ).toBeInstanceOf( RichTextData );
|
|
656
|
+
expect( ( cell.content as RichTextData ).toHTMLString() ).toBe(
|
|
657
|
+
'<strong>Cell</strong>'
|
|
658
|
+
);
|
|
659
|
+
} );
|
|
660
|
+
|
|
518
661
|
it( 'includes undefined blocks in changes', () => {
|
|
519
662
|
map.set( 'blocks', undefined );
|
|
520
663
|
|
|
@@ -801,11 +944,13 @@ describe( 'crdt', () => {
|
|
|
801
944
|
* @param map
|
|
802
945
|
* @param clientId Block client ID.
|
|
803
946
|
* @param content Initial text content.
|
|
947
|
+
* @param name Block name (default: 'core/paragraph').
|
|
804
948
|
*/
|
|
805
949
|
function addBlockToDoc(
|
|
806
950
|
map: YMapWrap< YPostRecord >,
|
|
807
951
|
clientId: string,
|
|
808
|
-
content: string
|
|
952
|
+
content: string,
|
|
953
|
+
name = 'core/paragraph'
|
|
809
954
|
): Y.Text {
|
|
810
955
|
let blocks = map.get( 'blocks' );
|
|
811
956
|
if ( ! ( blocks instanceof Y.Array ) ) {
|
|
@@ -814,6 +959,7 @@ function addBlockToDoc(
|
|
|
814
959
|
}
|
|
815
960
|
|
|
816
961
|
const block = createYMap< YBlockRecord >();
|
|
962
|
+
block.set( 'name', name );
|
|
817
963
|
block.set( 'clientId', clientId );
|
|
818
964
|
const attrs = new Y.Map();
|
|
819
965
|
const ytext = new Y.Text( content );
|
package/build/hooks/memoize.cjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// packages/core-data/src/hooks/memoize.js
|
|
31
|
-
var memoize_exports = {};
|
|
32
|
-
__export(memoize_exports, {
|
|
33
|
-
default: () => memoize_default
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(memoize_exports);
|
|
36
|
-
var import_memize = __toESM(require("memize"));
|
|
37
|
-
var memoize_default = import_memize.default;
|
|
38
|
-
//# sourceMappingURL=memoize.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hooks/memoize.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n// re-export due to restrictive esModuleInterop setting\nexport default memoize;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAoB;AAGpB,IAAO,kBAAQ,cAAAA;",
|
|
6
|
-
"names": ["memoize"]
|
|
7
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/core-data/src/utils/is-raw-attribute.js
|
|
21
|
-
var is_raw_attribute_exports = {};
|
|
22
|
-
__export(is_raw_attribute_exports, {
|
|
23
|
-
default: () => isRawAttribute
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(is_raw_attribute_exports);
|
|
26
|
-
function isRawAttribute(entity, attribute) {
|
|
27
|
-
return (entity.rawAttributes || []).includes(attribute);
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=is-raw-attribute.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/is-raw-attribute.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Checks whether the attribute is a \"raw\" attribute or not.\n *\n * @param {Object} entity Entity record.\n * @param {string} attribute Attribute name.\n *\n * @return {boolean} Is the attribute raw\n */\nexport default function isRawAttribute( entity, attribute ) {\n\treturn ( entity.rawAttributes || [] ).includes( attribute );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQe,SAAR,eAAiC,QAAQ,WAAY;AAC3D,UAAS,OAAO,iBAAiB,CAAC,GAAI,SAAU,SAAU;AAC3D;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hooks/memoize.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n// re-export due to restrictive esModuleInterop setting\nexport default memoize;\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,aAAa;AAGpB,IAAO,kBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/utils/is-raw-attribute.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Checks whether the attribute is a \"raw\" attribute or not.\n *\n * @param {Object} entity Entity record.\n * @param {string} attribute Attribute name.\n *\n * @return {boolean} Is the attribute raw\n */\nexport default function isRawAttribute( entity, attribute ) {\n\treturn ( entity.rawAttributes || [] ).includes( attribute );\n}\n"],
|
|
5
|
-
"mappings": ";AAQe,SAAR,eAAiC,QAAQ,WAAY;AAC3D,UAAS,OAAO,iBAAiB,CAAC,GAAI,SAAU,SAAU;AAC3D;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../src/hooks/memoize.js"],"names":[],"mappings":";oBAGoB,QAAQ"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks whether the attribute is a "raw" attribute or not.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} entity Entity record.
|
|
5
|
-
* @param {string} attribute Attribute name.
|
|
6
|
-
*
|
|
7
|
-
* @return {boolean} Is the attribute raw
|
|
8
|
-
*/
|
|
9
|
-
export default function isRawAttribute(entity: any, attribute: string): boolean;
|
|
10
|
-
//# sourceMappingURL=is-raw-attribute.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-raw-attribute.d.ts","sourceRoot":"","sources":["../../src/utils/is-raw-attribute.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,+DAJW,MAAM,GAEL,OAAO,CAIlB"}
|
package/src/hooks/memoize.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks whether the attribute is a "raw" attribute or not.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} entity Entity record.
|
|
5
|
-
* @param {string} attribute Attribute name.
|
|
6
|
-
*
|
|
7
|
-
* @return {boolean} Is the attribute raw
|
|
8
|
-
*/
|
|
9
|
-
export default function isRawAttribute( entity, attribute ) {
|
|
10
|
-
return ( entity.rawAttributes || [] ).includes( attribute );
|
|
11
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { isRawAttribute } from '../';
|
|
5
|
-
|
|
6
|
-
describe( 'isRawAttribute', () => {
|
|
7
|
-
it( 'should correctly assess that the attribute is not raw', () => {
|
|
8
|
-
const entityConfig = {
|
|
9
|
-
kind: 'someKind',
|
|
10
|
-
name: 'someName',
|
|
11
|
-
};
|
|
12
|
-
expect( isRawAttribute( entityConfig, 'title' ) ).toBe( false );
|
|
13
|
-
} );
|
|
14
|
-
it( 'should correctly assess that the attribute is raw', () => {
|
|
15
|
-
const entityConfig = {
|
|
16
|
-
kind: 'someKind',
|
|
17
|
-
name: 'someName',
|
|
18
|
-
rawAttributes: [ 'title' ],
|
|
19
|
-
};
|
|
20
|
-
expect( isRawAttribute( entityConfig, 'title' ) ).toBe( true );
|
|
21
|
-
} );
|
|
22
|
-
} );
|