@plaudit/gutenberg-api-extensions 2.95.0 → 2.96.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 +8 -0
- package/dist/lib/useful-types.d.ts +1 -4
- package/package.json +1 -2
- package/src/blocks/MoveError.ts +0 -7
- package/src/blocks/PathError.ts +0 -18
- package/src/blocks/SNPFlexibleItemsListComponent.tsx +0 -30
- package/src/blocks/SNPGroupComponent.tsx +0 -38
- package/src/blocks/SNPListComponent.tsx +0 -25
- package/src/blocks/SNPTreeContext.tsx +0 -13
- package/src/blocks/basic-custom-block-bindings-support.tsx +0 -248
- package/src/blocks/common-native-property-constructors.tsx +0 -927
- package/src/blocks/conditions.ts +0 -261
- package/src/blocks/csnp-api.ts +0 -221
- package/src/blocks/data-controller/actions.ts +0 -20
- package/src/blocks/data-controller/reducer.ts +0 -146
- package/src/blocks/data-controller/trigger-handlers.ts +0 -150
- package/src/blocks/data-controller/utils.ts +0 -415
- package/src/blocks/data-controller-manager.ts +0 -50
- package/src/blocks/data-controller.ts +0 -165
- package/src/blocks/hooks/built-in-suspendable-option-protocols/select.ts +0 -51
- package/src/blocks/hooks/built-in-suspendable-option-protocols/settings.ts +0 -70
- package/src/blocks/hooks/useSuspendableOptions.ts +0 -122
- package/src/blocks/index.ts +0 -23
- package/src/blocks/layered-styles-api.ts +0 -142
- package/src/blocks/layered-styles-impl.ts +0 -95
- package/src/blocks/layout/LaidOutProperty.tsx +0 -72
- package/src/blocks/layout/LaidOutPropertyRow.tsx +0 -28
- package/src/blocks/layout/NodeContext.tsx +0 -54
- package/src/blocks/layout/PanelRoot.tsx +0 -30
- package/src/blocks/layout/TabsRoot.tsx +0 -56
- package/src/blocks/layout/ToolsPanelContext.tsx +0 -22
- package/src/blocks/problematic-blocks-blocker.ts +0 -24
- package/src/blocks/problematic-variations-blocker.ts +0 -32
- package/src/blocks/shared-exportable-types.ts +0 -6
- package/src/blocks/shared-internal-types.ts +0 -18
- package/src/blocks/simple-block.tsx +0 -74
- package/src/blocks/simple-native-property-api.ts +0 -173
- package/src/blocks/simple-native-property-impl.tsx +0 -335
- package/src/blocks/simple-native-property-internal-shared.ts +0 -19
- package/src/blocks/snp-api.ts +0 -5
- package/src/blocks/snp-data-store.ts +0 -72
- package/src/blocks/utilities.ts +0 -66
- package/src/controls/AsynchronousFormTokenField.tsx +0 -86
- package/src/controls/BaseSortableItemsControl.tsx +0 -84
- package/src/controls/ExtendedFormTokenField.tsx +0 -144
- package/src/controls/ExtendedPostPicker.ts +0 -57
- package/src/controls/ExtendedRadioControl.tsx +0 -107
- package/src/controls/ExtendedTaxonomyPicker.tsx +0 -100
- package/src/controls/ExtendedTermPicker.tsx +0 -61
- package/src/controls/ExtendedTextareaControl.tsx +0 -65
- package/src/controls/ExtendedUserPicker.ts +0 -56
- package/src/controls/FileControl.tsx +0 -48
- package/src/controls/FullSizeToggleControl.tsx +0 -95
- package/src/controls/ImageControl.tsx +0 -143
- package/src/controls/InspectorPanel.tsx +0 -37
- package/src/controls/LazySuggestionsComboboxControl.tsx +0 -64
- package/src/controls/MultiSelectControl.tsx +0 -59
- package/src/controls/PickOne.tsx +0 -88
- package/src/controls/PromisableComponent.tsx +0 -56
- package/src/controls/ProperLinkControl.tsx +0 -98
- package/src/controls/SimpleToggle.tsx +0 -9
- package/src/controls/SortableFlexibleItemsControl.tsx +0 -37
- package/src/controls/SortableItemsControl.tsx +0 -22
- package/src/controls/basicNumericallyIdedItemPicker.tsx +0 -75
- package/src/controls/hooks/useImprovedTokenManager.ts +0 -163
- package/src/controls/hooks/useMultiSingleConversionLayer.ts +0 -17
- package/src/controls/hooks/useNonRenderingCounter.ts +0 -6
- package/src/controls/hooks/useOutputMemoizingFilter.ts +0 -16
- package/src/controls/hooks/useSortableItemsModel.ts +0 -196
- package/src/controls/hooks/useSuggestions.ts +0 -91
- package/src/controls/hooks/useTokenManager.ts +0 -177
- package/src/controls/index.ts +0 -24
- package/src/controls/shared.ts +0 -50
- package/src/controls/types.ts +0 -18
- package/src/editor/insert-sibling-or-child-block-shortcut.tsx +0 -60
- package/src/editor/install-insert-sole-allowed-block-shortcut-support.tsx +0 -51
- package/src/editor/simple-gutenberg-endpoints-api.ts +0 -31
- package/src/editor/simple-gutenberg-endpoints-impl.ts +0 -126
- package/src/index.ts +0 -30
- package/src/lib/compat-types.ts +0 -21
- package/src/lib/gutenberg-api-extensions-state/custom-block-bindings-support-logic.ts +0 -35
- package/src/lib/gutenberg-api-extensions-state/general-logic.ts +0 -41
- package/src/lib/gutenberg-api-extensions-state/layered-block-styles-logic.ts +0 -43
- package/src/lib/gutenberg-api-extensions-state/snp-logic.ts +0 -240
- package/src/lib/gutenberg-api-extensions-state.ts +0 -69
- package/src/lib/helpers.ts +0 -115
- package/src/lib/modified-fast-deep-equals.ts +0 -91
- package/src/lib/plaudit-icons/column-1.tsx +0 -6
- package/src/lib/plaudit-icons/column-2.tsx +0 -6
- package/src/lib/plaudit-icons/column-3.tsx +0 -6
- package/src/lib/plaudit-icons/placement-center.tsx +0 -3
- package/src/lib/plaudit-icons/placement-end.tsx +0 -3
- package/src/lib/plaudit-icons/placement-start.tsx +0 -3
- package/src/lib/plaudit-icons/placement-stretch.tsx +0 -3
- package/src/lib/plaudit-icons/plaudit-icon.tsx +0 -4
- package/src/lib/plaudit-icons/reusable-block-marker.tsx +0 -3
- package/src/lib/plaudit-icons.ts +0 -13
- package/src/lib/sectioned-cache-store.ts +0 -120
- package/src/lib/suspense/promise-handlers.ts +0 -72
- package/src/lib/suspense.tsx +0 -18
- package/src/lib/useful-types.ts +0 -82
- package/src/schemas/README.md +0 -1
- package/src/schemas/plaudit-block-schema.json +0 -818
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import {createReduxStore} from "@wordpress/data";
|
|
2
|
-
|
|
3
|
-
import {TemporalLRUCache} from "./helpers";
|
|
4
|
-
import {use, type WrappedPromise, wrapPromise} from "./suspense/promise-handlers";
|
|
5
|
-
|
|
6
|
-
type SelectorsBuilder<
|
|
7
|
-
PROPS,
|
|
8
|
-
DATA,
|
|
9
|
-
SELECTORS extends { [name in string]: (...args: any[]) => any }
|
|
10
|
-
> = (handleCacheMiss: (props: PROPS) => Promise<SectionedCacheFetchResult<DATA>>) => SELECTORS;
|
|
11
|
-
type SectionedCacheFetchResult<DATA> = {error?: false, data: DATA}|{error: true, data: string};
|
|
12
|
-
type GetCacheForPropsFunction<PROPS, DATA, KEY> = (props: PROPS) => TemporalLRUCache<KEY, WrappedPromise<SectionedCacheFetchResult<DATA>>>;
|
|
13
|
-
type WarmingPromiseGetter<PROPS, DATA, KEY> = (
|
|
14
|
-
storeChanged: () => void, props: FetchWarmingDataArgs<PROPS, DATA, KEY>[0], ...args: DropFirst<FetchWarmingDataArgs<PROPS, DATA, KEY>>
|
|
15
|
-
) => WrappedPromise<void>|undefined;
|
|
16
|
-
|
|
17
|
-
type SectionedCacheStoreArgs<
|
|
18
|
-
PROPS,
|
|
19
|
-
DATA,
|
|
20
|
-
KEY,
|
|
21
|
-
SELECTORS extends { [name in string]: (...args: any[]) => any }
|
|
22
|
-
> = {
|
|
23
|
-
keyify: (props: PROPS) => KEY
|
|
24
|
-
name: string
|
|
25
|
-
selectorsBuilder: SelectorsBuilder<PROPS, DATA, SELECTORS>
|
|
26
|
-
getCacheForProps?: GetCacheForPropsFunction<PROPS, DATA, KEY>
|
|
27
|
-
getIndividualItemFetchPromise: (props: PROPS) => Promise<SectionedCacheFetchResult<DATA>>
|
|
28
|
-
getWarmingPromise: WarmingPromiseGetter<PROPS, DATA, KEY>
|
|
29
|
-
}
|
|
30
|
-
type AddBSStateArg<S extends {[name in string]: (...args: any[]) => any}> = {[name in keyof S]: (state: any, ...args: Parameters<S[name]>) => ReturnType<S[name]>};
|
|
31
|
-
export function create<PROPS, DATA, KEY, SELECTORS extends { [name in string]: (...args: any[]) => any }>(
|
|
32
|
-
args: SectionedCacheStoreArgs<PROPS, DATA, KEY, SELECTORS>
|
|
33
|
-
) {
|
|
34
|
-
type ReduxSelectors = AddBSStateArg<SELECTORS>;
|
|
35
|
-
const {getCacheForProps = makeDefaultCacheForPropsGetter(), getIndividualItemFetchPromise, getWarmingPromise, keyify, name, selectorsBuilder} = args;
|
|
36
|
-
return {
|
|
37
|
-
name,
|
|
38
|
-
instantiate: () => {
|
|
39
|
-
const listeners = new Set<() => void>();
|
|
40
|
-
|
|
41
|
-
const storeChanged = () => {
|
|
42
|
-
for (const listener of listeners) {
|
|
43
|
-
listener();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const warmCache = (props: PROPS) => {
|
|
48
|
-
const warmingPromise = getWarmingPromise(storeChanged, props, getCacheForProps, keyify);
|
|
49
|
-
if (warmingPromise !== undefined) {
|
|
50
|
-
return use(warmingPromise);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const fetchItemContents = async (props: PROPS) => {
|
|
55
|
-
try {
|
|
56
|
-
return await getIndividualItemFetchPromise(props);
|
|
57
|
-
} catch (err) {
|
|
58
|
-
return ({error: true, data: (err?.toString() as string|undefined) ?? "EMPTY_RESPONSE"} as const) satisfies SectionedCacheFetchResult<DATA>;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const handleCacheMiss = (props: PROPS): Promise<SectionedCacheFetchResult<DATA>> => {
|
|
63
|
-
const key = keyify(props);
|
|
64
|
-
warmCache(props);
|
|
65
|
-
const cache = getCacheForProps(props);
|
|
66
|
-
const existingPromise = cache.get(key);
|
|
67
|
-
if (existingPromise !== null) {
|
|
68
|
-
return existingPromise;
|
|
69
|
-
}
|
|
70
|
-
const res = wrapPromise(fetchItemContents(props));
|
|
71
|
-
res.finally(storeChanged);
|
|
72
|
-
cache.set(key, res);
|
|
73
|
-
return res;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const selectors = selectorsBuilder(handleCacheMiss);
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
getSelectors: () => selectors,
|
|
80
|
-
getSuspendSelectors: () => selectors,
|
|
81
|
-
getActions: () => ({}),
|
|
82
|
-
subscribe: (listener: () => void) => {
|
|
83
|
-
listeners.add(listener);
|
|
84
|
-
return () => listeners.delete(listener);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
} satisfies ReturnType<typeof createReduxStore<{}, {}, ReduxSelectors>> as ReturnType<typeof createReduxStore<{}, {}, ReduxSelectors>>;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function makeDefaultCacheForPropsGetter<PROPS, DATA, KEY>() {
|
|
92
|
-
const cache: ReturnType<GetCacheForPropsFunction<PROPS, DATA, KEY>> = new TemporalLRUCache(10);
|
|
93
|
-
return () => cache;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
type DropFirst<A extends any[]> = A extends [any, ...infer R] ? R : never;
|
|
97
|
-
type FetchWarmingDataArgs<PROPS, DATA, KEY> = [props: PROPS, getCacheForProps: GetCacheForPropsFunction<PROPS, DATA, KEY>, keyify: (props: PROPS) => KEY];
|
|
98
|
-
type MakeSimpleWarmingPromisesGetterArgs<PROPS, DATA, KEY> = {
|
|
99
|
-
warmingPromisesKeyify: (props: PROPS) => string|number|undefined, // Returning undefined short-circuits the rest of the function, skipping any waiting at all
|
|
100
|
-
fetchWarmingData: (...args: FetchWarmingDataArgs<PROPS, DATA, KEY>) => Promise<void>,
|
|
101
|
-
shouldWarm?: ((props: PROPS) => boolean)
|
|
102
|
-
};
|
|
103
|
-
export function makeSimpleWarmingPromisesGetter<PROPS, DATA, KEY>(
|
|
104
|
-
{warmingPromisesKeyify, fetchWarmingData, shouldWarm = () => true}: MakeSimpleWarmingPromisesGetterArgs<PROPS, DATA, KEY>
|
|
105
|
-
): WarmingPromiseGetter<PROPS, DATA, KEY> {
|
|
106
|
-
const warmingPromises: Record<string|number, WrappedPromise<void>> = {};
|
|
107
|
-
return (storeChanged, props, ...args) => {
|
|
108
|
-
const key = warmingPromisesKeyify(props);
|
|
109
|
-
if (key === undefined) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (!warmingPromises[key]) {
|
|
113
|
-
if (!shouldWarm(props)) {
|
|
114
|
-
return; // We don't want to go back to the server for the entire dataset unless we're going to be working with most of it
|
|
115
|
-
}
|
|
116
|
-
warmingPromises[key] = wrapPromise(fetchWarmingData(props, ...args).finally(storeChanged));
|
|
117
|
-
}
|
|
118
|
-
return warmingPromises[key];
|
|
119
|
-
};
|
|
120
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
type WrappedPromiseEnhancements<T> = {value: T, status: 'fulfilled'}|{reason: unknown, status: 'rejected'};
|
|
2
|
-
export type WrappedPromise<T> = Promise<T>&({status: 'pending'}|WrappedPromiseEnhancements<T>);
|
|
3
|
-
export type PartiallyWrappedPromise<T> = Promise<T>&({status?: 'pending'}|WrappedPromiseEnhancements<T>);
|
|
4
|
-
export function isWrappedPromise<T>(promise: Promise<T>): promise is WrappedPromise<T> {
|
|
5
|
-
return 'status' in promise
|
|
6
|
-
&& (promise.status === 'pending' || (promise.status === 'fulfilled' && 'value' in promise) || (promise.status === 'rejected' && 'reason' in promise));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function use<T>(promise: PartiallyWrappedPromise<T>): T {
|
|
10
|
-
switch (promise.status) {
|
|
11
|
-
case "pending":
|
|
12
|
-
throw promise;
|
|
13
|
-
case "fulfilled":
|
|
14
|
-
return promise.value;
|
|
15
|
-
case "rejected":
|
|
16
|
-
throw promise.reason;
|
|
17
|
-
default:
|
|
18
|
-
return use(actuallyWrapPromise(promise));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function useImmediately<T>(promise: PartiallyWrappedPromise<T>): T|undefined {
|
|
23
|
-
switch (promise.status) {
|
|
24
|
-
case "pending":
|
|
25
|
-
return undefined;
|
|
26
|
-
case "fulfilled":
|
|
27
|
-
return promise.value;
|
|
28
|
-
case "rejected":
|
|
29
|
-
throw promise.reason;
|
|
30
|
-
default:
|
|
31
|
-
return useImmediately(actuallyWrapPromise(promise));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function useToPromise<T>(promise: PartiallyWrappedPromise<T>): Promise<T> {
|
|
36
|
-
switch (promise.status) {
|
|
37
|
-
case "pending":
|
|
38
|
-
throw promise;
|
|
39
|
-
case "fulfilled":
|
|
40
|
-
return Promise.resolve(promise.value);
|
|
41
|
-
case "rejected":
|
|
42
|
-
throw promise.reason;
|
|
43
|
-
default:
|
|
44
|
-
return useToPromise(actuallyWrapPromise(promise));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function wrapPromise<T>(promise: PartiallyWrappedPromise<T>): WrappedPromise<T> {
|
|
49
|
-
return isWrappedPromise(promise) ? promise : actuallyWrapPromise(promise);
|
|
50
|
-
}
|
|
51
|
-
function actuallyWrapPromise<T>(promise: PartiallyWrappedPromise<T>): WrappedPromise<T> {
|
|
52
|
-
promise.status = 'pending';
|
|
53
|
-
promise.then(
|
|
54
|
-
value => {
|
|
55
|
-
(promise as PartiallyWrappedPromise<T>).status = 'fulfilled';
|
|
56
|
-
(promise as any).value = value;
|
|
57
|
-
},
|
|
58
|
-
reason => {
|
|
59
|
-
(promise as PartiallyWrappedPromise<T>).status = 'rejected';
|
|
60
|
-
(promise as any).reason = reason;
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
return promise as WrappedPromise<T>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function getPromiseState(promise: PartiallyWrappedPromise<any>) {
|
|
67
|
-
return wrapPromise(promise).status;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function isPromise<T>(value: any): value is Promise<T> {
|
|
71
|
-
return typeof value === 'object' && !!value && ('then' in value) && typeof value['then'] === 'function';
|
|
72
|
-
}
|
package/src/lib/suspense.tsx
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {Spinner} from "@wordpress/components";
|
|
2
|
-
|
|
3
|
-
import {InspectorPanel} from "../controls";
|
|
4
|
-
|
|
5
|
-
export * from "./suspense/promise-handlers";
|
|
6
|
-
|
|
7
|
-
import {type ReactNode, Suspense, type SuspenseProps} from "react";
|
|
8
|
-
|
|
9
|
-
type OptionallySuspensefulProps = Omit<SuspenseProps, 'children'>&{children: ReactNode|(() => ReactNode), hasSuspensefulOptions: (() => boolean)|boolean};
|
|
10
|
-
export function OptionallySuspenseful({children: Children, hasSuspensefulOptions, ...props}: OptionallySuspensefulProps) {
|
|
11
|
-
if (typeof hasSuspensefulOptions === 'function' ? hasSuspensefulOptions() : hasSuspensefulOptions) {
|
|
12
|
-
return <Suspense fallback={<InspectorPanel opened initialOpen><Spinner/> Loading options</InspectorPanel>} {...props}>{
|
|
13
|
-
typeof Children === 'function' ? <Children/> : Children
|
|
14
|
-
}</Suspense>;
|
|
15
|
-
} else {
|
|
16
|
-
return typeof Children === 'function' ? <Children/> : Children;
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/lib/useful-types.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type {Block, BlockSupports, BlockVariation} from "@wordpress/blocks";
|
|
2
|
-
import type {FormTokenField} from '@wordpress/components';
|
|
3
|
-
|
|
4
|
-
import type {ComponentProps} from "react";
|
|
5
|
-
|
|
6
|
-
import type {PropertiesParameter} from "../blocks";
|
|
7
|
-
|
|
8
|
-
export type TokenItem = Exclude<NonNullable<ComponentProps<typeof FormTokenField>['value']>[number], string>;
|
|
9
|
-
export type WorkableUnknownAction = {type: "@@UNKNOWN_ACTION"};
|
|
10
|
-
|
|
11
|
-
export type SubsequentArgsOfFunc<F> = F extends (arg: any, ...args: infer R) => any ? R : never;
|
|
12
|
-
|
|
13
|
-
export type BlockName = `${string}/${string}`;
|
|
14
|
-
export function isBlockName(str: string): str is BlockName {
|
|
15
|
-
const slashIndex = str.indexOf('/');
|
|
16
|
-
return slashIndex > 0 && slashIndex < str.length - 1;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type ActualBEPAttrs = Record<string, any>&{className?: string|undefined};
|
|
20
|
-
export type ActualBlockEditProps = {attributes: ActualBEPAttrs, setAttributes: (attributes: ActualBEPAttrs) => void, name: BlockName, clientId: string};
|
|
21
|
-
export type ActualBlockListBlockProps = {
|
|
22
|
-
attributes: ActualBEPAttrs, name: BlockName, clientId: string, className?: string, style?: Record<string, unknown>, wrapperProps?: Record<string, unknown>,
|
|
23
|
-
isSelected: boolean, isValid: boolean, canMove: boolean, canRemove: boolean, isLocked: boolean
|
|
24
|
-
};
|
|
25
|
-
export type ActualBlockSaveProps = {[key: Exclude<string, 'className'|'style'>]: unknown|undefined, className?: string|undefined, style?: Record<string, unknown>};
|
|
26
|
-
|
|
27
|
-
export type BlockJsonNativePropsConfig = {
|
|
28
|
-
type: "native",
|
|
29
|
-
properties?: PropertiesParameter|undefined
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type RegisterBlockAttrs<T extends Record<string, any> = {}> = {
|
|
33
|
-
name: BlockName, attributes: Block<T>['attributes'], usesContext?: string[],
|
|
34
|
-
plaudit?: "native"|boolean|{group: any}|BlockJsonNativePropsConfig|undefined,
|
|
35
|
-
supports: BlockSupports&Record<Exclude<string, keyof BlockSupports>, any>,
|
|
36
|
-
allowedBlocks?: BlockName[], ancestor?: BlockName[], parent?: BlockName[],
|
|
37
|
-
variations?: BlockVariation|BlockVariation[],
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export function isBlockJsonNativePropsConfig(thing: unknown): thing is BlockJsonNativePropsConfig {
|
|
41
|
-
return typeof thing === 'object' && thing !== null && 'type' in thing && thing.type === "native";
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type NonEmptyArray<T> = [T, ...T[]];
|
|
45
|
-
export function arrayIsNotEmpty<T>(arr: T[]|null|undefined): arr is NonEmptyArray<T> {
|
|
46
|
-
return !!arr && arr.length > 0;
|
|
47
|
-
}
|
|
48
|
-
export type PromisifyFunctionReturns<T extends {[K in string]: (...args: any[]) => any}> = {[K in keyof T]: (...args: Parameters<T[K]>) => Promise<ReturnType<T[K]>>};
|
|
49
|
-
|
|
50
|
-
export type WPTaxonomyQuery = {
|
|
51
|
-
relation?: 'AND'|'OR',
|
|
52
|
-
clauses: Array<WPTaxonomyQuery>
|
|
53
|
-
}|WPTaxonomyQueryFirstOrderClause;
|
|
54
|
-
type WPTaxonomyQueryFirstOrderClause = {include_children?: boolean, operator?: 'AND'|'IN'|'NOT IN'|'EXISTS'|'NOT EXISTS'}&
|
|
55
|
-
(({taxonomy: string}&({terms: number|number[], field?: 'term_id'}|{terms: string|string[], field: 'slug'|'name'}))|{taxonomy?: string, terms: number|number[], field: 'term_taxonomy_id'});
|
|
56
|
-
|
|
57
|
-
export type DbSource = {label: string, value: string, help?: string};
|
|
58
|
-
|
|
59
|
-
export interface WP_Error {
|
|
60
|
-
code?: string|number;
|
|
61
|
-
message?: string;
|
|
62
|
-
data?: unknown;
|
|
63
|
-
}
|
|
64
|
-
export function is_wp_error(value: unknown): value is WP_Error {
|
|
65
|
-
if (typeof value !== 'object' || !value) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
let hasDefinedProperty = false;
|
|
69
|
-
if ('code' in value) {
|
|
70
|
-
if (value.code !== undefined && typeof value.code !== 'string' && typeof value.code !== 'number') {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
hasDefinedProperty ||= value.code !== undefined;
|
|
74
|
-
}
|
|
75
|
-
if ('message' in value) {
|
|
76
|
-
if (value.message !== undefined && typeof value.message !== 'string') {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
hasDefinedProperty ||= value.message !== undefined;
|
|
80
|
-
}
|
|
81
|
-
return hasDefinedProperty;
|
|
82
|
-
}
|
package/src/schemas/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
See `Deploy Schema` section of ../README.md
|