@manifest-editor/creator-api 1.4.3 → 2.0.1-next.0.ede7d58
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/dist/index.cjs +1 -662
- package/dist/index.d.cts +274 -232
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +274 -232
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -651
- package/dist/index.js.map +1 -0
- package/package.json +18 -23
package/dist/index.d.cts
CHANGED
|
@@ -1,273 +1,315 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
3
|
-
import {
|
|
4
|
-
import { resources } from
|
|
5
|
-
import { ReactNode } from
|
|
1
|
+
import { Entities, Vault } from "@iiif/helpers/vault";
|
|
2
|
+
import * as _iiif_presentation_329 from "@iiif/presentation-3";
|
|
3
|
+
import { Annotation, DescriptiveProperties, LinkingProperties, NavPlaceExtension, Reference, SpecificResource, StructuralProperties, TechnicalProperties } from "@iiif/presentation-3";
|
|
4
|
+
import { resources } from "@manifest-editor/editor-api";
|
|
5
|
+
import { ReactNode } from "react";
|
|
6
|
+
import { SupportedSelector } from "@iiif/helpers";
|
|
6
7
|
|
|
8
|
+
//#region src/ReferencedResource.d.ts
|
|
7
9
|
declare class ReferencedResource {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
created?: string | undefined;
|
|
49
|
-
generated?: string | undefined;
|
|
50
|
-
modified?: string | undefined;
|
|
51
|
-
creator?: _iiif_presentation_3.Creator | undefined;
|
|
52
|
-
generator?: _iiif_presentation_3.Creator | undefined;
|
|
53
|
-
audience?: (_iiif_presentation_3.Audience | _iiif_presentation_3.Audience[]) | undefined;
|
|
54
|
-
accessibility?: string | string[] | undefined;
|
|
55
|
-
motivation?: (_iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[]) | undefined;
|
|
56
|
-
rights?: string | string[] | undefined;
|
|
57
|
-
canonical?: string | undefined;
|
|
58
|
-
via?: string | string[] | undefined;
|
|
59
|
-
role?: string | undefined;
|
|
60
|
-
id?: string | undefined;
|
|
61
|
-
type: "SpecificResource";
|
|
62
|
-
state?: (_iiif_presentation_3.State | _iiif_presentation_3.State[]) | undefined;
|
|
63
|
-
purpose?: (_iiif_presentation_3.AnyMotivation | _iiif_presentation_3.AnyMotivation[]) | undefined;
|
|
64
|
-
selector?: (_iiif_presentation_3.Selector | _iiif_presentation_3.Selector[]) | undefined;
|
|
65
|
-
styleClass?: string | undefined;
|
|
66
|
-
renderedVia?: (_iiif_presentation_3.Agent | _iiif_presentation_3.Agent[]) | undefined;
|
|
67
|
-
scope?: _iiif_presentation_3.LinkedResource;
|
|
10
|
+
vault: Vault;
|
|
11
|
+
original: Reference | SpecificResource;
|
|
12
|
+
reference: Reference;
|
|
13
|
+
resource: SpecificResource;
|
|
14
|
+
constructor(reference: Reference | SpecificResource, vault: Vault);
|
|
15
|
+
ref(): {
|
|
16
|
+
type: string;
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
specificResource(): {
|
|
20
|
+
created?: string | undefined;
|
|
21
|
+
generated?: string | undefined;
|
|
22
|
+
modified?: string | undefined;
|
|
23
|
+
creator?: _iiif_presentation_329.Creator | undefined;
|
|
24
|
+
generator?: _iiif_presentation_329.Creator | undefined;
|
|
25
|
+
audience?: (_iiif_presentation_329.Audience | _iiif_presentation_329.Audience[]) | undefined;
|
|
26
|
+
accessibility?: string | string[] | undefined;
|
|
27
|
+
motivation?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
|
|
28
|
+
rights?: string | string[] | undefined;
|
|
29
|
+
canonical?: string | undefined;
|
|
30
|
+
via?: string | string[] | undefined;
|
|
31
|
+
role?: string | undefined;
|
|
32
|
+
id?: string | undefined;
|
|
33
|
+
type: "SpecificResource";
|
|
34
|
+
state?: (_iiif_presentation_329.State | _iiif_presentation_329.State[]) | undefined;
|
|
35
|
+
purpose?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
|
|
36
|
+
source?: any;
|
|
37
|
+
selector?: (_iiif_presentation_329.Selector | _iiif_presentation_329.Selector[]) | undefined;
|
|
38
|
+
styleClass?: string | undefined;
|
|
39
|
+
renderedVia?: (_iiif_presentation_329.Agent | _iiif_presentation_329.Agent[]) | undefined;
|
|
40
|
+
scope?: _iiif_presentation_329.LinkedResource;
|
|
41
|
+
};
|
|
42
|
+
optionalSpecificResource(): {
|
|
43
|
+
type: string;
|
|
44
|
+
id: string;
|
|
45
|
+
} | {
|
|
46
|
+
source: {
|
|
47
|
+
id: any;
|
|
48
|
+
type: any;
|
|
68
49
|
};
|
|
69
|
-
|
|
50
|
+
created?: string | undefined;
|
|
51
|
+
generated?: string | undefined;
|
|
52
|
+
modified?: string | undefined;
|
|
53
|
+
creator?: _iiif_presentation_329.Creator | undefined;
|
|
54
|
+
generator?: _iiif_presentation_329.Creator | undefined;
|
|
55
|
+
audience?: (_iiif_presentation_329.Audience | _iiif_presentation_329.Audience[]) | undefined;
|
|
56
|
+
accessibility?: string | string[] | undefined;
|
|
57
|
+
motivation?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
|
|
58
|
+
rights?: string | string[] | undefined;
|
|
59
|
+
canonical?: string | undefined;
|
|
60
|
+
via?: string | string[] | undefined;
|
|
61
|
+
role?: string | undefined;
|
|
62
|
+
id?: string | undefined;
|
|
63
|
+
type: "SpecificResource";
|
|
64
|
+
state?: (_iiif_presentation_329.State | _iiif_presentation_329.State[]) | undefined;
|
|
65
|
+
purpose?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
|
|
66
|
+
selector?: (_iiif_presentation_329.Selector | _iiif_presentation_329.Selector[]) | undefined;
|
|
67
|
+
styleClass?: string | undefined;
|
|
68
|
+
renderedVia?: (_iiif_presentation_329.Agent | _iiif_presentation_329.Agent[]) | undefined;
|
|
69
|
+
scope?: _iiif_presentation_329.LinkedResource;
|
|
70
|
+
};
|
|
71
|
+
get(): any;
|
|
70
72
|
}
|
|
71
|
-
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/CreatorResource.d.ts
|
|
72
75
|
declare class CreatorResource {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
76
|
+
resource: any;
|
|
77
|
+
warnings: string[];
|
|
78
|
+
errors: string[];
|
|
79
|
+
partOf: any;
|
|
80
|
+
references: ReferencedResource[];
|
|
81
|
+
embedded: CreatorResource[];
|
|
82
|
+
vault: Vault;
|
|
83
|
+
specificResource?: SpecificResource;
|
|
84
|
+
constructor(inputData: any, vault: Vault);
|
|
85
|
+
get(): any;
|
|
86
|
+
getSpecificResource(): {
|
|
87
|
+
created?: string | undefined;
|
|
88
|
+
generated?: string | undefined;
|
|
89
|
+
modified?: string | undefined;
|
|
90
|
+
creator?: _iiif_presentation_329.Creator | undefined;
|
|
91
|
+
generator?: _iiif_presentation_329.Creator | undefined;
|
|
92
|
+
audience?: (_iiif_presentation_329.Audience | _iiif_presentation_329.Audience[]) | undefined;
|
|
93
|
+
accessibility?: string | string[] | undefined;
|
|
94
|
+
motivation?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
|
|
95
|
+
rights?: string | string[] | undefined;
|
|
96
|
+
canonical?: string | undefined;
|
|
97
|
+
via?: string | string[] | undefined;
|
|
98
|
+
role?: string | undefined;
|
|
99
|
+
id?: string | undefined;
|
|
100
|
+
type: "SpecificResource";
|
|
101
|
+
state?: (_iiif_presentation_329.State | _iiif_presentation_329.State[]) | undefined;
|
|
102
|
+
purpose?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
|
|
103
|
+
source?: any;
|
|
104
|
+
selector?: (_iiif_presentation_329.Selector | _iiif_presentation_329.Selector[]) | undefined;
|
|
105
|
+
styleClass?: string | undefined;
|
|
106
|
+
renderedVia?: (_iiif_presentation_329.Agent | _iiif_presentation_329.Agent[]) | undefined;
|
|
107
|
+
scope?: _iiif_presentation_329.LinkedResource;
|
|
108
|
+
} | {
|
|
109
|
+
type: string;
|
|
110
|
+
source: {
|
|
111
|
+
id: any;
|
|
112
|
+
type: any;
|
|
108
113
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
};
|
|
115
|
+
ref(): {
|
|
116
|
+
created?: string | undefined;
|
|
117
|
+
generated?: string | undefined;
|
|
118
|
+
modified?: string | undefined;
|
|
119
|
+
creator?: _iiif_presentation_329.Creator | undefined;
|
|
120
|
+
generator?: _iiif_presentation_329.Creator | undefined;
|
|
121
|
+
audience?: (_iiif_presentation_329.Audience | _iiif_presentation_329.Audience[]) | undefined;
|
|
122
|
+
accessibility?: string | string[] | undefined;
|
|
123
|
+
motivation?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
|
|
124
|
+
rights?: string | string[] | undefined;
|
|
125
|
+
canonical?: string | undefined;
|
|
126
|
+
via?: string | string[] | undefined;
|
|
127
|
+
role?: string | undefined;
|
|
128
|
+
id?: string | undefined;
|
|
129
|
+
type: "SpecificResource";
|
|
130
|
+
state?: (_iiif_presentation_329.State | _iiif_presentation_329.State[]) | undefined;
|
|
131
|
+
purpose?: (_iiif_presentation_329.AnyMotivation | _iiif_presentation_329.AnyMotivation[]) | undefined;
|
|
132
|
+
source?: any;
|
|
133
|
+
selector?: (_iiif_presentation_329.Selector | _iiif_presentation_329.Selector[]) | undefined;
|
|
134
|
+
styleClass?: string | undefined;
|
|
135
|
+
renderedVia?: (_iiif_presentation_329.Agent | _iiif_presentation_329.Agent[]) | undefined;
|
|
136
|
+
scope?: _iiif_presentation_329.LinkedResource;
|
|
137
|
+
} | {
|
|
138
|
+
id: any;
|
|
139
|
+
type: any;
|
|
140
|
+
};
|
|
141
|
+
getAllReferencedResources(): ReferencedResource[];
|
|
142
|
+
getAllEmbeddedResources(): CreatorResource[];
|
|
143
|
+
getVaultResource(): any;
|
|
144
|
+
setPartOf(id: string): void;
|
|
113
145
|
}
|
|
114
|
-
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/CreatorInstance.d.ts
|
|
115
148
|
declare class CreatorInstance implements CreatorFunctionContext {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
149
|
+
vault: Vault;
|
|
150
|
+
previewVault: Vault;
|
|
151
|
+
configs: CreatorDefinition[];
|
|
152
|
+
options: CreatorOptions;
|
|
153
|
+
target: CreatorOptions["target"];
|
|
154
|
+
selector: SupportedSelector | undefined | null;
|
|
155
|
+
serialisedSelector: {
|
|
156
|
+
type: string;
|
|
157
|
+
value: string;
|
|
158
|
+
} | null;
|
|
159
|
+
constructor(vault: Vault, options: CreatorOptions, createConfigs: CreatorDefinition[], previewVault: Vault);
|
|
160
|
+
getPreviewVault(): Vault;
|
|
161
|
+
setSelector(selector: SupportedSelector): void;
|
|
162
|
+
getSerialisedSelector(): {
|
|
163
|
+
type: "SvgSelector";
|
|
164
|
+
id: string;
|
|
165
|
+
} | {
|
|
166
|
+
type: string;
|
|
167
|
+
value: string;
|
|
168
|
+
} | null;
|
|
169
|
+
getTarget(): SpecificResource | Reference | undefined;
|
|
170
|
+
getParent(): Reference | undefined;
|
|
171
|
+
getParentResource(): SpecificResource | undefined;
|
|
172
|
+
generateId(type: string, parent?: Reference | ReferencedResource): string;
|
|
173
|
+
ref(idOrRef: string | Reference): ReferencedResource;
|
|
174
|
+
embed(data: any): CreatorResource;
|
|
175
|
+
create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<any>;
|
|
129
176
|
}
|
|
130
|
-
|
|
131
|
-
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/creator-register.d.ts
|
|
179
|
+
declare function defineCreator<const Payload$1 = any, const ID$1 = Readonly<string>, const ResourceType$1 extends AllAvailableParentTypes = never, const AdditionalResourceTypes$1 extends Array<AllAvailableParentTypes> = [], const AllResourceTypes$1 = [ResourceType$1, ...AdditionalResourceTypes$1], const SupportsParentTypes$1 extends Array<AllAvailableParentTypes> = AllParentTypes, const SupportsParentFields$1 extends Array<AllProperties> = [], const CreateReturnType$1 = any>(options: SpecificCreatorDefinition<Payload$1, ID$1, ResourceType$1, AdditionalResourceTypes$1, AllResourceTypes$1, SupportsParentTypes$1, SupportsParentFields$1, CreateReturnType$1>): SpecificCreatorDefinition<Payload$1, ID$1, ResourceType$1, AdditionalResourceTypes$1, AllResourceTypes$1, SupportsParentTypes$1, SupportsParentFields$1, CreateReturnType$1>;
|
|
132
180
|
declare namespace IIIFManifestEditor {
|
|
133
|
-
|
|
134
|
-
}
|
|
181
|
+
interface CreatorDefinitions {}
|
|
135
182
|
}
|
|
136
183
|
type ExtractCreatorGenerics<T extends CreatorDefinition> = T extends SpecificCreatorDefinition<infer Payload, infer ID, infer ResourceType, infer AdditionalResourceTypes, infer AllResourceTypes, infer SupportsParentTypes, infer SupportsParentFields, infer CreateReturnType> ? {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
184
|
+
Payload: Payload;
|
|
185
|
+
ID: ID;
|
|
186
|
+
ResourceType: ResourceType;
|
|
187
|
+
AdditionalResourceTypes: AdditionalResourceTypes;
|
|
188
|
+
AllResourceTypes: AllResourceTypes;
|
|
189
|
+
SupportsParentTypes: SupportsParentTypes;
|
|
190
|
+
SupportsParentFields: SupportsParentFields;
|
|
191
|
+
CreateReturnType: CreateReturnType;
|
|
145
192
|
} : never;
|
|
146
193
|
type CreatorSupportsParentTypes<T, Type extends AllAvailableParentTypes> = T extends CreatorDefinition ? ExtractCreatorGenerics<T>["SupportsParentTypes"] extends never ? false : HelperInArray<Type, ExtractCreatorGenerics<T>["SupportsParentTypes"]> : false;
|
|
147
194
|
type CreatorSupportsParentFields<T, Field extends AllProperties> = T extends CreatorDefinition ? ExtractCreatorGenerics<T>["SupportsParentFields"] extends never ? false : HelperInArray<Field, ExtractCreatorGenerics<T>["SupportsParentFields"]> : false;
|
|
148
195
|
type CreatorSupportsParent<T, Type extends AllAvailableParentTypes, Field extends AllProperties> = T extends CreatorDefinition ? CreatorSupportsParentTypes<T, Type> extends true ? CreatorSupportsParentFields<T, Field> extends true ? true : false : false : false;
|
|
149
|
-
type HelperInArray<ToFind, Array extends readonly any[]> = Array extends readonly [infer Head, ...infer Tail] ? Head extends ToFind ? true : HelperInArray<ToFind, Tail> : false;
|
|
150
|
-
type CreatorDefinitionFilterByParent<Type extends AllAvailableParentTypes, Field extends AllProperties = AllProperties, CD extends IIIFManifestEditor.CreatorDefinitions = IIIFManifestEditor.CreatorDefinitions> = {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
196
|
+
type HelperInArray<ToFind, Array$1 extends readonly any[]> = Array$1 extends readonly [infer Head, ...infer Tail] ? Head extends ToFind ? true : HelperInArray<ToFind, Tail> : false;
|
|
197
|
+
type CreatorDefinitionFilterByParent<Type extends AllAvailableParentTypes, Field extends AllProperties = AllProperties, CD extends IIIFManifestEditor.CreatorDefinitions = IIIFManifestEditor.CreatorDefinitions> = { [K in keyof CD]: CreatorSupportsParent<CD[K], Type, Field> extends true ? CD[K] : never }[keyof CD];
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/types.d.ts
|
|
154
200
|
interface CreatorContext<T = any> {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
201
|
+
vault: Vault;
|
|
202
|
+
options: CreatorOptions;
|
|
203
|
+
validate: (payload: T) => Promise<boolean> | boolean;
|
|
204
|
+
runCreate: (payload: T) => void;
|
|
159
205
|
}
|
|
160
206
|
type ResolvedCreatorReturn<T extends CreatorDefinition> = Awaited<ExtractCreatorGenerics<T>["CreateReturnType"]> extends any[] ? CreatorResource[] : CreatorResource;
|
|
161
207
|
interface CreatorFunctionContext {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
208
|
+
vault: Vault;
|
|
209
|
+
options: CreatorOptions;
|
|
210
|
+
ref(idOrRef: string | Reference): ReferencedResource;
|
|
211
|
+
embed(data: any): CreatorResource;
|
|
212
|
+
create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<CreatorResource | CreatorResource[]>;
|
|
213
|
+
create<Definition extends CreatorDefinition = any>(definition: Definition["id"], payload: GetCreatorPayload<Definition>, options?: Partial<CreatorOptions>): Promise<ResolvedCreatorReturn<Definition>>;
|
|
214
|
+
generateId(type: string, parent?: Reference | ReferencedResource): string;
|
|
215
|
+
getParent(): Reference | undefined;
|
|
216
|
+
getTarget(): SpecificResource | Reference | undefined;
|
|
217
|
+
getParentResource(): SpecificResource | undefined;
|
|
218
|
+
getPreviewVault(): Vault;
|
|
173
219
|
}
|
|
174
220
|
type GetCreatorPayload<T extends CreatorDefinition> = T extends CreatorDefinition<infer Payload> ? Payload : never;
|
|
175
221
|
interface CreatorParent {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
222
|
+
resource: Reference;
|
|
223
|
+
property: string;
|
|
224
|
+
atIndex?: number;
|
|
179
225
|
}
|
|
180
226
|
interface CreatorOptions {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
227
|
+
targetType: string;
|
|
228
|
+
target?: Reference;
|
|
229
|
+
parent?: CreatorParent;
|
|
230
|
+
initialData?: any;
|
|
231
|
+
rootId?: string;
|
|
185
232
|
}
|
|
186
233
|
type AllAvailableParentTypes = keyof typeof resources.supported;
|
|
187
234
|
type GetSupportedResourceFields<Resource extends AllAvailableParentTypes> = {} & (typeof resources.supported)[Resource]["allowed"][number];
|
|
188
235
|
type AllProperties = ({} & keyof LinkingProperties) | ({} & keyof StructuralProperties<any>) | ({} & keyof TechnicalProperties) | ({} & keyof DescriptiveProperties) | ({} & keyof Annotation) | ({} & keyof NavPlaceExtension);
|
|
189
|
-
type AllParentTypes = [
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
initialData?: boolean;
|
|
221
|
-
parentTypes?: SupportsParentTypes;
|
|
222
|
-
parentFields?: SupportsParentFields;
|
|
223
|
-
parentFieldMap?: Record<string, string[]>;
|
|
224
|
-
custom?: (parent: CreatorParent, vault: Vault) => boolean;
|
|
225
|
-
disallowPainting?: boolean;
|
|
226
|
-
};
|
|
227
|
-
sideEffects?: Array<CreatorSideEffect>;
|
|
236
|
+
type AllParentTypes = ["Collection", "Manifest", "Canvas", "Annotation", "AnnotationPage", "Range", "AnnotationCollection", "ContentResource", "Agent"];
|
|
237
|
+
interface SpecificCreatorDefinition<Payload$1 = any, ID$1 = Readonly<string>, ResourceType$1 extends AllAvailableParentTypes = never, AdditionalResourceTypes$1 extends Array<AllAvailableParentTypes> = [], AllResourceTypes$1 = [ResourceType$1, ...AdditionalResourceTypes$1], SupportsParentTypes$1 extends Array<AllAvailableParentTypes> = AllParentTypes, SupportsParentFields$1 extends Array<AllProperties> = [], CreateReturnType$1 = any | Promise<any> | any[] | Promise<any[]>> {
|
|
238
|
+
readonly id: ID$1;
|
|
239
|
+
label: string;
|
|
240
|
+
summary?: string;
|
|
241
|
+
icon?: any;
|
|
242
|
+
dependencies?: string[];
|
|
243
|
+
tags?: string[];
|
|
244
|
+
create: (payload: Payload$1, ctx: CreatorInstance) => CreateReturnType$1;
|
|
245
|
+
validate?: (payload: Payload$1, vault: Vault) => void | Promise<void>;
|
|
246
|
+
render?: (ctx: CreatorContext<Payload$1>) => ReactNode;
|
|
247
|
+
renderCanvas?: (ctx: CreatorContext<Payload$1>) => ReactNode | null;
|
|
248
|
+
renderModal?: (ctx: CreatorContext<Payload$1>) => ReactNode;
|
|
249
|
+
resourceType: ResourceType$1;
|
|
250
|
+
additionalTypes?: AdditionalResourceTypes$1;
|
|
251
|
+
actionButton?: string;
|
|
252
|
+
resourceFields: string[];
|
|
253
|
+
embeddedResources?: string[];
|
|
254
|
+
staticFields?: Record<string, any>;
|
|
255
|
+
allowModal?: boolean;
|
|
256
|
+
hiddenModal?: boolean;
|
|
257
|
+
supports: {
|
|
258
|
+
initialData?: boolean;
|
|
259
|
+
parentTypes?: SupportsParentTypes$1;
|
|
260
|
+
parentFields?: SupportsParentFields$1;
|
|
261
|
+
parentFieldMap?: Record<string, string[]>;
|
|
262
|
+
custom?: (parent: CreatorParent, vault: Vault) => boolean;
|
|
263
|
+
disallowPainting?: boolean;
|
|
264
|
+
onlyPainting?: boolean;
|
|
265
|
+
};
|
|
266
|
+
sideEffects?: Array<CreatorSideEffect>;
|
|
228
267
|
}
|
|
229
|
-
type CreatorDefinition<Payload = any> = SpecificCreatorDefinition<Payload, any, any, any, any, any, any>;
|
|
268
|
+
type CreatorDefinition<Payload$1 = any> = SpecificCreatorDefinition<Payload$1, any, any, any, any, any, any>;
|
|
230
269
|
interface CreatorSideEffect {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
270
|
+
run?: (result: any, ctx: {
|
|
271
|
+
options: CreatorOptions;
|
|
272
|
+
vault: Vault;
|
|
273
|
+
}) => void | Promise<void>;
|
|
274
|
+
temporal?: boolean;
|
|
275
|
+
spatial?: boolean;
|
|
276
|
+
replaceSiblings?: boolean;
|
|
277
|
+
canvasInteraction?: boolean;
|
|
239
278
|
}
|
|
240
279
|
interface CreatableResource {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
280
|
+
type: string;
|
|
281
|
+
parent?: Reference;
|
|
282
|
+
property?: string;
|
|
283
|
+
index?: number;
|
|
284
|
+
onlyReference?: boolean;
|
|
285
|
+
target?: Reference;
|
|
286
|
+
initialData?: any;
|
|
287
|
+
isPainting?: boolean;
|
|
288
|
+
filter?: string;
|
|
289
|
+
initialCreator?: string;
|
|
251
290
|
}
|
|
252
|
-
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/Creator.d.ts
|
|
253
293
|
declare class Creator {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
294
|
+
configs: CreatorDefinition[];
|
|
295
|
+
vault: Vault;
|
|
296
|
+
previewVault: Vault;
|
|
297
|
+
constructor(vault: Vault, configs: CreatorDefinition[], previewVault?: Vault);
|
|
298
|
+
matchBasedOnResource(resource: CreatableResource): CreatorDefinition[];
|
|
299
|
+
create(definition: string, payload: any, options?: Partial<CreatorOptions>): Promise<Reference | Reference[]>;
|
|
260
300
|
}
|
|
261
|
-
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/utils.d.ts
|
|
262
303
|
declare function resolveType(type: string): keyof Entities;
|
|
263
304
|
declare function getEmptyType(type: string): any;
|
|
264
305
|
declare function randomId(): string;
|
|
265
306
|
declare function matchBasedOnResource(resource: CreatableResource, list: CreatorDefinition[], options: {
|
|
266
|
-
|
|
307
|
+
vault: Vault;
|
|
267
308
|
}): CreatorDefinition[];
|
|
268
|
-
declare function creatorHelper<const ResourceType extends AllAvailableParentTypes, const Parent extends {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}, const ResourceField extends GetSupportedResourceFields<ResourceType>, const CID extends CreatorDefinitionFilterByParent<ResourceType, ResourceField>["id"], Payload = GetCreatorPayload<IIIFManifestEditor.CreatorDefinitions[CID]>, Return = ResolvedCreatorReturn<IIIFManifestEditor.CreatorDefinitions[CID]>>(ctx: CreatorFunctionContext, parent: Parent | ResourceType, property: ResourceField, definition: CID): (payload: Payload, options?: Partial<CreatorOptions>) => Promise<Return>;
|
|
272
|
-
|
|
273
|
-
export {
|
|
309
|
+
declare function creatorHelper<const ResourceType$1 extends AllAvailableParentTypes, const Parent extends {
|
|
310
|
+
id: string;
|
|
311
|
+
type: ResourceType$1;
|
|
312
|
+
}, const ResourceField extends GetSupportedResourceFields<ResourceType$1>, const CID extends CreatorDefinitionFilterByParent<ResourceType$1, ResourceField>["id"], Payload$1 = GetCreatorPayload<IIIFManifestEditor.CreatorDefinitions[CID]>, Return = ResolvedCreatorReturn<IIIFManifestEditor.CreatorDefinitions[CID]>>(ctx: CreatorFunctionContext, parent: Parent | ResourceType$1, property: ResourceField, definition: CID): (payload: Payload$1, options?: Partial<CreatorOptions>) => Promise<Return>;
|
|
313
|
+
//#endregion
|
|
314
|
+
export { AllAvailableParentTypes, AllParentTypes, AllProperties, CreatableResource, Creator, CreatorContext, CreatorDefinition, CreatorDefinitionFilterByParent, CreatorFunctionContext, CreatorOptions, CreatorResource, CreatorSideEffect, ExtractCreatorGenerics, GetCreatorPayload, GetSupportedResourceFields, IIIFManifestEditor, ResolvedCreatorReturn, SpecificCreatorDefinition, creatorHelper, defineCreator, getEmptyType, matchBasedOnResource, randomId, resolveType };
|
|
315
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/ReferencedResource.ts","../src/CreatorResource.ts","../src/CreatorInstance.ts","../src/creator-register.ts","../src/types.ts","../src/Creator.ts","../src/utils.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAIa,kBAAA;SACJ;YACG,YAAY;aACX;YACD;yBACa,YAAY,yBAAyB;EALjD,GAAA,CAAA,CAAA,EAAA;IACJ,IAAA,EAAA,MAAA;IACG,EAAA,EAAA,MAAA;EAAY,CAAA;EACX,gBAAA,CAAA,CAAA,EAAA;IACD,OAAA,CAAA,EAAA,MAAA,GAAA,SAAA;IACa,SAAA,CAAA,EAAA,MAAA,GAAA,SAAA;IAAY,QAAA,CAAA,EAAA,MAAA,GAAA,SAAA;IAAyB,OAAA,CAAA,EAAK,sBAAA,CAAA,OAAA,GAAL,SAAA;IAAK,SAAA,CA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