@newcms/core 0.1.0 → 0.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/dist/index.cjs +1003 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +569 -0
- package/dist/index.d.ts +569 -6
- package/dist/index.js +963 -4
- package/dist/index.js.map +1 -1
- package/package.json +8 -4
- package/dist/hook-engine.d.ts +0 -134
- package/dist/hook-engine.d.ts.map +0 -1
- package/dist/hook-engine.js +0 -370
- package/dist/hook-engine.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/post-type-registry.d.ts +0 -50
- package/dist/post-type-registry.d.ts.map +0 -1
- package/dist/post-type-registry.js +0 -159
- package/dist/post-type-registry.js.map +0 -1
- package/dist/taxonomy-registry.d.ts +0 -20
- package/dist/taxonomy-registry.d.ts.map +0 -1
- package/dist/taxonomy-registry.js +0 -71
- package/dist/taxonomy-registry.js.map +0 -1
- package/dist/types.d.ts +0 -124
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -34
- package/dist/types.js.map +0 -1
package/dist/hook-engine.js
DELETED
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates a unique identifier for a hook callback.
|
|
3
|
-
*
|
|
4
|
-
* For named functions, uses the function name + priority.
|
|
5
|
-
* For anonymous/arrow functions, uses a counter-based ID.
|
|
6
|
-
*/
|
|
7
|
-
let anonymousCounter = 0;
|
|
8
|
-
function generateCallbackId(callback, priority) {
|
|
9
|
-
if (callback.name && callback.name !== '') {
|
|
10
|
-
return `${callback.name}::${priority}`;
|
|
11
|
-
}
|
|
12
|
-
anonymousCounter++;
|
|
13
|
-
return `__anonymous_${anonymousCounter}::${priority}`;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* HookEngine — the backbone of the CMS extensibility system.
|
|
17
|
-
*
|
|
18
|
-
* Implements a WordPress-compatible hook system with actions and filters.
|
|
19
|
-
* Actions are hooks that perform side effects. Filters are hooks that
|
|
20
|
-
* transform a value through a pipeline of callbacks.
|
|
21
|
-
*
|
|
22
|
-
* Features:
|
|
23
|
-
* - Priority-based execution (lower number = earlier execution)
|
|
24
|
-
* - Recursive hook execution support
|
|
25
|
-
* - Universal "all" hook that fires for every hook
|
|
26
|
-
* - Execution stack tracking
|
|
27
|
-
* - Fire counters per hook
|
|
28
|
-
* - Precise removal by callback + priority
|
|
29
|
-
*/
|
|
30
|
-
export class HookEngine {
|
|
31
|
-
/**
|
|
32
|
-
* Map of hook name → array of handlers, kept sorted by priority.
|
|
33
|
-
*/
|
|
34
|
-
hooks = new Map();
|
|
35
|
-
/**
|
|
36
|
-
* Stack of hooks currently being executed (supports recursion).
|
|
37
|
-
*/
|
|
38
|
-
currentStack = [];
|
|
39
|
-
/**
|
|
40
|
-
* Counter of how many times each hook has been fired.
|
|
41
|
-
*/
|
|
42
|
-
fireCount = new Map();
|
|
43
|
-
/**
|
|
44
|
-
* Register a callback for a hook.
|
|
45
|
-
*
|
|
46
|
-
* @param hookName - The hook identifier
|
|
47
|
-
* @param callback - The function to execute
|
|
48
|
-
* @param options - Priority and accepted args configuration
|
|
49
|
-
* @returns The generated handler ID
|
|
50
|
-
*/
|
|
51
|
-
addHook(hookName, callback, options = {}) {
|
|
52
|
-
const priority = options.priority ?? 10;
|
|
53
|
-
const acceptedArgs = options.acceptedArgs ?? 1;
|
|
54
|
-
const id = generateCallbackId(callback, priority);
|
|
55
|
-
const handler = {
|
|
56
|
-
callback,
|
|
57
|
-
priority,
|
|
58
|
-
acceptedArgs,
|
|
59
|
-
id,
|
|
60
|
-
};
|
|
61
|
-
const existing = this.hooks.get(hookName) ?? [];
|
|
62
|
-
existing.push(handler);
|
|
63
|
-
// Stable sort by priority (preserves insertion order for same priority)
|
|
64
|
-
existing.sort((a, b) => a.priority - b.priority);
|
|
65
|
-
this.hooks.set(hookName, existing);
|
|
66
|
-
return id;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Remove a specific callback from a hook.
|
|
70
|
-
*
|
|
71
|
-
* Both the callback reference AND priority must match for removal.
|
|
72
|
-
*
|
|
73
|
-
* @param hookName - The hook identifier
|
|
74
|
-
* @param callback - The callback to remove
|
|
75
|
-
* @param priority - The priority it was registered with (default: 10)
|
|
76
|
-
* @returns true if a handler was removed
|
|
77
|
-
*/
|
|
78
|
-
removeHook(hookName, callback, priority = 10) {
|
|
79
|
-
const handlers = this.hooks.get(hookName);
|
|
80
|
-
if (!handlers)
|
|
81
|
-
return false;
|
|
82
|
-
const initialLength = handlers.length;
|
|
83
|
-
const filtered = handlers.filter((h) => !(h.callback === callback && h.priority === priority));
|
|
84
|
-
if (filtered.length === initialLength)
|
|
85
|
-
return false;
|
|
86
|
-
if (filtered.length === 0) {
|
|
87
|
-
this.hooks.delete(hookName);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
this.hooks.set(hookName, filtered);
|
|
91
|
-
}
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Remove all callbacks from a hook, optionally only for a specific priority.
|
|
96
|
-
*
|
|
97
|
-
* @param hookName - The hook identifier
|
|
98
|
-
* @param priority - If provided, only remove handlers at this priority
|
|
99
|
-
* @returns true if any handlers were removed
|
|
100
|
-
*/
|
|
101
|
-
removeAllHooks(hookName, priority) {
|
|
102
|
-
if (priority === undefined) {
|
|
103
|
-
return this.hooks.delete(hookName);
|
|
104
|
-
}
|
|
105
|
-
const handlers = this.hooks.get(hookName);
|
|
106
|
-
if (!handlers)
|
|
107
|
-
return false;
|
|
108
|
-
const filtered = handlers.filter((h) => h.priority !== priority);
|
|
109
|
-
if (filtered.length === handlers.length)
|
|
110
|
-
return false;
|
|
111
|
-
if (filtered.length === 0) {
|
|
112
|
-
this.hooks.delete(hookName);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
this.hooks.set(hookName, filtered);
|
|
116
|
-
}
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Check if a hook has registered handlers.
|
|
121
|
-
*
|
|
122
|
-
* @param hookName - The hook identifier
|
|
123
|
-
* @param callback - If provided, check for this specific callback
|
|
124
|
-
* @returns false if no handlers, or the priority of the matching handler
|
|
125
|
-
*/
|
|
126
|
-
hasHook(hookName, callback) {
|
|
127
|
-
const handlers = this.hooks.get(hookName);
|
|
128
|
-
if (!handlers || handlers.length === 0)
|
|
129
|
-
return false;
|
|
130
|
-
if (callback === undefined) {
|
|
131
|
-
// Return the lowest priority (first handler)
|
|
132
|
-
return handlers[0].priority;
|
|
133
|
-
}
|
|
134
|
-
const found = handlers.find((h) => h.callback === callback);
|
|
135
|
-
return found ? found.priority : false;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Execute an action hook. All registered callbacks are called in priority order.
|
|
139
|
-
* The "all" universal hook fires before the specific hook.
|
|
140
|
-
*
|
|
141
|
-
* @param hookName - The hook identifier
|
|
142
|
-
* @param args - Arguments to pass to callbacks
|
|
143
|
-
*/
|
|
144
|
-
async doAction(hookName, ...args) {
|
|
145
|
-
// Fire the universal "all" hook first (if we're not already in "all")
|
|
146
|
-
if (hookName !== 'all') {
|
|
147
|
-
await this.fireUniversalHook(hookName, args);
|
|
148
|
-
}
|
|
149
|
-
const handlers = this.hooks.get(hookName);
|
|
150
|
-
this.incrementFireCount(hookName);
|
|
151
|
-
if (!handlers || handlers.length === 0)
|
|
152
|
-
return;
|
|
153
|
-
// Push onto execution stack
|
|
154
|
-
const stackEntry = { name: hookName, currentIndex: 0 };
|
|
155
|
-
this.currentStack.push(stackEntry);
|
|
156
|
-
try {
|
|
157
|
-
for (let i = 0; i < handlers.length; i++) {
|
|
158
|
-
stackEntry.currentIndex = i;
|
|
159
|
-
const handler = handlers[i];
|
|
160
|
-
const slicedArgs = args.slice(0, handler.acceptedArgs);
|
|
161
|
-
await handler.callback(...slicedArgs);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
finally {
|
|
165
|
-
this.currentStack.pop();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Execute an action hook synchronously.
|
|
170
|
-
*/
|
|
171
|
-
doActionSync(hookName, ...args) {
|
|
172
|
-
if (hookName !== 'all') {
|
|
173
|
-
this.fireUniversalHookSync(hookName, args);
|
|
174
|
-
}
|
|
175
|
-
const handlers = this.hooks.get(hookName);
|
|
176
|
-
this.incrementFireCount(hookName);
|
|
177
|
-
if (!handlers || handlers.length === 0)
|
|
178
|
-
return;
|
|
179
|
-
const stackEntry = { name: hookName, currentIndex: 0 };
|
|
180
|
-
this.currentStack.push(stackEntry);
|
|
181
|
-
try {
|
|
182
|
-
for (let i = 0; i < handlers.length; i++) {
|
|
183
|
-
stackEntry.currentIndex = i;
|
|
184
|
-
const handler = handlers[i];
|
|
185
|
-
const slicedArgs = args.slice(0, handler.acceptedArgs);
|
|
186
|
-
handler.callback(...slicedArgs);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
finally {
|
|
190
|
-
this.currentStack.pop();
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Execute a filter hook. The first argument is the value being filtered.
|
|
195
|
-
* Each callback receives the (possibly modified) value and returns a new value.
|
|
196
|
-
* The "all" universal hook fires before the specific hook.
|
|
197
|
-
*
|
|
198
|
-
* @param hookName - The hook identifier
|
|
199
|
-
* @param value - The initial value to filter
|
|
200
|
-
* @param args - Additional arguments passed to each callback
|
|
201
|
-
* @returns The filtered value after all callbacks have processed it
|
|
202
|
-
*/
|
|
203
|
-
async applyFilters(hookName, value, ...args) {
|
|
204
|
-
// Fire the universal "all" hook first
|
|
205
|
-
if (hookName !== 'all') {
|
|
206
|
-
await this.fireUniversalHook(hookName, [value, ...args]);
|
|
207
|
-
}
|
|
208
|
-
const handlers = this.hooks.get(hookName);
|
|
209
|
-
this.incrementFireCount(hookName);
|
|
210
|
-
if (!handlers || handlers.length === 0)
|
|
211
|
-
return value;
|
|
212
|
-
const stackEntry = { name: hookName, currentIndex: 0 };
|
|
213
|
-
this.currentStack.push(stackEntry);
|
|
214
|
-
let filteredValue = value;
|
|
215
|
-
try {
|
|
216
|
-
for (let i = 0; i < handlers.length; i++) {
|
|
217
|
-
stackEntry.currentIndex = i;
|
|
218
|
-
const handler = handlers[i];
|
|
219
|
-
const callArgs = [filteredValue, ...args].slice(0, handler.acceptedArgs);
|
|
220
|
-
filteredValue = await handler.callback(filteredValue, ...callArgs.slice(1));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
finally {
|
|
224
|
-
this.currentStack.pop();
|
|
225
|
-
}
|
|
226
|
-
return filteredValue;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Execute a filter hook synchronously.
|
|
230
|
-
*/
|
|
231
|
-
applyFiltersSync(hookName, value, ...args) {
|
|
232
|
-
if (hookName !== 'all') {
|
|
233
|
-
this.fireUniversalHookSync(hookName, [value, ...args]);
|
|
234
|
-
}
|
|
235
|
-
const handlers = this.hooks.get(hookName);
|
|
236
|
-
this.incrementFireCount(hookName);
|
|
237
|
-
if (!handlers || handlers.length === 0)
|
|
238
|
-
return value;
|
|
239
|
-
const stackEntry = { name: hookName, currentIndex: 0 };
|
|
240
|
-
this.currentStack.push(stackEntry);
|
|
241
|
-
let filteredValue = value;
|
|
242
|
-
try {
|
|
243
|
-
for (let i = 0; i < handlers.length; i++) {
|
|
244
|
-
stackEntry.currentIndex = i;
|
|
245
|
-
const handler = handlers[i];
|
|
246
|
-
const callArgs = [filteredValue, ...args].slice(0, handler.acceptedArgs);
|
|
247
|
-
filteredValue = handler.callback(filteredValue, ...callArgs.slice(1));
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
finally {
|
|
251
|
-
this.currentStack.pop();
|
|
252
|
-
}
|
|
253
|
-
return filteredValue;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Get how many times a hook has been fired.
|
|
257
|
-
*/
|
|
258
|
-
getFireCount(hookName) {
|
|
259
|
-
return this.fireCount.get(hookName) ?? 0;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Check if a specific hook is currently being executed.
|
|
263
|
-
*/
|
|
264
|
-
isDoingHook(hookName) {
|
|
265
|
-
if (hookName === undefined) {
|
|
266
|
-
return this.currentStack.length > 0;
|
|
267
|
-
}
|
|
268
|
-
return this.currentStack.some((entry) => entry.name === hookName);
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Get the name of the hook currently being executed (top of stack).
|
|
272
|
-
* Returns undefined if no hook is executing.
|
|
273
|
-
*/
|
|
274
|
-
currentHook() {
|
|
275
|
-
if (this.currentStack.length === 0)
|
|
276
|
-
return undefined;
|
|
277
|
-
return this.currentStack[this.currentStack.length - 1].name;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Get a snapshot of the current execution stack.
|
|
281
|
-
*/
|
|
282
|
-
getExecutionStack() {
|
|
283
|
-
return [...this.currentStack];
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Check if a hook has ever been fired (fire count > 0).
|
|
287
|
-
*/
|
|
288
|
-
didHook(hookName) {
|
|
289
|
-
return this.getFireCount(hookName) > 0;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Get the number of handlers registered for a hook.
|
|
293
|
-
*/
|
|
294
|
-
getHandlerCount(hookName) {
|
|
295
|
-
return this.hooks.get(hookName)?.length ?? 0;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Reset the engine — useful for testing.
|
|
299
|
-
*/
|
|
300
|
-
reset() {
|
|
301
|
-
this.hooks.clear();
|
|
302
|
-
this.currentStack = [];
|
|
303
|
-
this.fireCount.clear();
|
|
304
|
-
anonymousCounter = 0;
|
|
305
|
-
}
|
|
306
|
-
// --- Convenience aliases matching WordPress API names ---
|
|
307
|
-
addAction(hookName, callback, options) {
|
|
308
|
-
return this.addHook(hookName, callback, options);
|
|
309
|
-
}
|
|
310
|
-
addFilter(hookName, callback, options) {
|
|
311
|
-
return this.addHook(hookName, callback, options);
|
|
312
|
-
}
|
|
313
|
-
removeAction(hookName, callback, priority) {
|
|
314
|
-
return this.removeHook(hookName, callback, priority);
|
|
315
|
-
}
|
|
316
|
-
removeFilter(hookName, callback, priority) {
|
|
317
|
-
return this.removeHook(hookName, callback, priority);
|
|
318
|
-
}
|
|
319
|
-
hasAction(hookName, callback) {
|
|
320
|
-
return this.hasHook(hookName, callback);
|
|
321
|
-
}
|
|
322
|
-
hasFilter(hookName, callback) {
|
|
323
|
-
return this.hasHook(hookName, callback);
|
|
324
|
-
}
|
|
325
|
-
didAction(hookName) {
|
|
326
|
-
return this.didHook(hookName);
|
|
327
|
-
}
|
|
328
|
-
didFilter(hookName) {
|
|
329
|
-
return this.didHook(hookName);
|
|
330
|
-
}
|
|
331
|
-
// --- Private helpers ---
|
|
332
|
-
incrementFireCount(hookName) {
|
|
333
|
-
this.fireCount.set(hookName, (this.fireCount.get(hookName) ?? 0) + 1);
|
|
334
|
-
}
|
|
335
|
-
async fireUniversalHook(hookName, args) {
|
|
336
|
-
const allHandlers = this.hooks.get('all');
|
|
337
|
-
if (!allHandlers || allHandlers.length === 0)
|
|
338
|
-
return;
|
|
339
|
-
const stackEntry = { name: 'all', currentIndex: 0 };
|
|
340
|
-
this.currentStack.push(stackEntry);
|
|
341
|
-
try {
|
|
342
|
-
for (let i = 0; i < allHandlers.length; i++) {
|
|
343
|
-
stackEntry.currentIndex = i;
|
|
344
|
-
const handler = allHandlers[i];
|
|
345
|
-
await handler.callback(hookName, ...args);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
finally {
|
|
349
|
-
this.currentStack.pop();
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
fireUniversalHookSync(hookName, args) {
|
|
353
|
-
const allHandlers = this.hooks.get('all');
|
|
354
|
-
if (!allHandlers || allHandlers.length === 0)
|
|
355
|
-
return;
|
|
356
|
-
const stackEntry = { name: 'all', currentIndex: 0 };
|
|
357
|
-
this.currentStack.push(stackEntry);
|
|
358
|
-
try {
|
|
359
|
-
for (let i = 0; i < allHandlers.length; i++) {
|
|
360
|
-
stackEntry.currentIndex = i;
|
|
361
|
-
const handler = allHandlers[i];
|
|
362
|
-
handler.callback(hookName, ...args);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
finally {
|
|
366
|
-
this.currentStack.pop();
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
//# sourceMappingURL=hook-engine.js.map
|
package/dist/hook-engine.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hook-engine.js","sourceRoot":"","sources":["../src/hook-engine.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,SAAS,kBAAkB,CAAC,QAAsB,EAAE,QAAgB;IACnE,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,KAAK,EAAE,EAAE,CAAC;QAC3C,OAAO,GAAG,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;IACxC,CAAC;IACD,gBAAgB,EAAE,CAAC;IACnB,OAAO,eAAe,gBAAgB,KAAK,QAAQ,EAAE,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,UAAU;IACtB;;OAEG;IACK,KAAK,GAA+B,IAAI,GAAG,EAAE,CAAC;IAEtD;;OAEG;IACK,YAAY,GAAqB,EAAE,CAAC;IAE5C;;OAEG;IACK,SAAS,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEnD;;;;;;;OAOG;IACH,OAAO,CAAC,QAAgB,EAAE,QAAsB,EAAE,UAA0B,EAAE;QAC7E,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;QACxC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,CAA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AY,CAAC,GAAG,EAAE,CAAC;QACzB,CAAC;IACF,CAAC;CACD"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,YAAY,EACX,YAAY,EACZ,WAAW,EACX,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { PostTypeDefinition } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Registry for content types (post types).
|
|
4
|
-
*
|
|
5
|
-
* Manages registration and lookup of all content types in the system.
|
|
6
|
-
* Built-in types (post, page, attachment, revision, nav_menu_item) are
|
|
7
|
-
* registered during bootstrap; custom types are registered by extensions.
|
|
8
|
-
*/
|
|
9
|
-
export declare class PostTypeRegistry {
|
|
10
|
-
private types;
|
|
11
|
-
/**
|
|
12
|
-
* Register a new post type.
|
|
13
|
-
*
|
|
14
|
-
* @throws If a type with the same name is already registered
|
|
15
|
-
*/
|
|
16
|
-
register(definition: PostTypeDefinition): void;
|
|
17
|
-
/**
|
|
18
|
-
* Get a post type definition by name.
|
|
19
|
-
*/
|
|
20
|
-
get(name: string): PostTypeDefinition | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Check if a post type is registered.
|
|
23
|
-
*/
|
|
24
|
-
has(name: string): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Get all registered post types.
|
|
27
|
-
*/
|
|
28
|
-
getAll(): PostTypeDefinition[];
|
|
29
|
-
/**
|
|
30
|
-
* Get only public post types (for REST API, search, etc).
|
|
31
|
-
*/
|
|
32
|
-
getPublic(): PostTypeDefinition[];
|
|
33
|
-
/**
|
|
34
|
-
* Get post types that are exposed via REST API.
|
|
35
|
-
*/
|
|
36
|
-
getRestVisible(): PostTypeDefinition[];
|
|
37
|
-
/**
|
|
38
|
-
* Unregister a post type. Only custom types can be unregistered.
|
|
39
|
-
*/
|
|
40
|
-
unregister(name: string): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Reset registry — for testing only.
|
|
43
|
-
*/
|
|
44
|
-
reset(): void;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Built-in post type definitions, registered during bootstrap.
|
|
48
|
-
*/
|
|
49
|
-
export declare const BUILTIN_POST_TYPES: PostTypeDefinition[];
|
|
50
|
-
//# sourceMappingURL=post-type-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"post-type-registry.d.ts","sourceRoot":"","sources":["../src/post-type-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,KAAK,CAA8C;IAE3D;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,IAAI;IAO9C;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIjD;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACH,MAAM,IAAI,kBAAkB,EAAE;IAI9B;;OAEG;IACH,SAAS,IAAI,kBAAkB,EAAE;IAIjC;;OAEG;IACH,cAAc,IAAI,kBAAkB,EAAE;IAItC;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC;;OAEG;IACH,KAAK,IAAI,IAAI;CAGb;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAAkB,EA2FlD,CAAC"}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registry for content types (post types).
|
|
3
|
-
*
|
|
4
|
-
* Manages registration and lookup of all content types in the system.
|
|
5
|
-
* Built-in types (post, page, attachment, revision, nav_menu_item) are
|
|
6
|
-
* registered during bootstrap; custom types are registered by extensions.
|
|
7
|
-
*/
|
|
8
|
-
export class PostTypeRegistry {
|
|
9
|
-
types = new Map();
|
|
10
|
-
/**
|
|
11
|
-
* Register a new post type.
|
|
12
|
-
*
|
|
13
|
-
* @throws If a type with the same name is already registered
|
|
14
|
-
*/
|
|
15
|
-
register(definition) {
|
|
16
|
-
if (this.types.has(definition.name)) {
|
|
17
|
-
throw new Error(`Post type "${definition.name}" is already registered.`);
|
|
18
|
-
}
|
|
19
|
-
this.types.set(definition.name, definition);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Get a post type definition by name.
|
|
23
|
-
*/
|
|
24
|
-
get(name) {
|
|
25
|
-
return this.types.get(name);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Check if a post type is registered.
|
|
29
|
-
*/
|
|
30
|
-
has(name) {
|
|
31
|
-
return this.types.has(name);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Get all registered post types.
|
|
35
|
-
*/
|
|
36
|
-
getAll() {
|
|
37
|
-
return [...this.types.values()];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get only public post types (for REST API, search, etc).
|
|
41
|
-
*/
|
|
42
|
-
getPublic() {
|
|
43
|
-
return this.getAll().filter((t) => t.public !== false);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Get post types that are exposed via REST API.
|
|
47
|
-
*/
|
|
48
|
-
getRestVisible() {
|
|
49
|
-
return this.getAll().filter((t) => t.showInRest === true);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Unregister a post type. Only custom types can be unregistered.
|
|
53
|
-
*/
|
|
54
|
-
unregister(name) {
|
|
55
|
-
return this.types.delete(name);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Reset registry — for testing only.
|
|
59
|
-
*/
|
|
60
|
-
reset() {
|
|
61
|
-
this.types.clear();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Built-in post type definitions, registered during bootstrap.
|
|
66
|
-
*/
|
|
67
|
-
export const BUILTIN_POST_TYPES = [
|
|
68
|
-
{
|
|
69
|
-
name: 'post',
|
|
70
|
-
label: 'Posts',
|
|
71
|
-
labels: { singular: 'Post', plural: 'Posts' },
|
|
72
|
-
public: true,
|
|
73
|
-
hierarchical: false,
|
|
74
|
-
showInRest: true,
|
|
75
|
-
restBase: 'posts',
|
|
76
|
-
supports: [
|
|
77
|
-
'title',
|
|
78
|
-
'editor',
|
|
79
|
-
'author',
|
|
80
|
-
'thumbnail',
|
|
81
|
-
'excerpt',
|
|
82
|
-
'trackbacks',
|
|
83
|
-
'custom-fields',
|
|
84
|
-
'comments',
|
|
85
|
-
'revisions',
|
|
86
|
-
'post-formats',
|
|
87
|
-
],
|
|
88
|
-
taxonomies: ['category', 'post_tag'],
|
|
89
|
-
hasArchive: true,
|
|
90
|
-
rewrite: { slug: '', withFront: true },
|
|
91
|
-
menuPosition: 5,
|
|
92
|
-
capability_type: 'post',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'page',
|
|
96
|
-
label: 'Pages',
|
|
97
|
-
labels: { singular: 'Page', plural: 'Pages' },
|
|
98
|
-
public: true,
|
|
99
|
-
hierarchical: true,
|
|
100
|
-
showInRest: true,
|
|
101
|
-
restBase: 'pages',
|
|
102
|
-
supports: [
|
|
103
|
-
'title',
|
|
104
|
-
'editor',
|
|
105
|
-
'author',
|
|
106
|
-
'thumbnail',
|
|
107
|
-
'page-attributes',
|
|
108
|
-
'custom-fields',
|
|
109
|
-
'comments',
|
|
110
|
-
'revisions',
|
|
111
|
-
],
|
|
112
|
-
taxonomies: [],
|
|
113
|
-
hasArchive: false,
|
|
114
|
-
rewrite: { slug: '', withFront: false },
|
|
115
|
-
menuPosition: 20,
|
|
116
|
-
capability_type: 'page',
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: 'attachment',
|
|
120
|
-
label: 'Media',
|
|
121
|
-
labels: { singular: 'Media', plural: 'Media' },
|
|
122
|
-
public: true,
|
|
123
|
-
hierarchical: false,
|
|
124
|
-
showInRest: true,
|
|
125
|
-
restBase: 'media',
|
|
126
|
-
supports: ['title', 'author', 'comments'],
|
|
127
|
-
taxonomies: [],
|
|
128
|
-
hasArchive: false,
|
|
129
|
-
rewrite: false,
|
|
130
|
-
capability_type: 'post',
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: 'revision',
|
|
134
|
-
label: 'Revisions',
|
|
135
|
-
labels: { singular: 'Revision', plural: 'Revisions' },
|
|
136
|
-
public: false,
|
|
137
|
-
hierarchical: false,
|
|
138
|
-
showInRest: false,
|
|
139
|
-
supports: ['author'],
|
|
140
|
-
taxonomies: [],
|
|
141
|
-
hasArchive: false,
|
|
142
|
-
rewrite: false,
|
|
143
|
-
capability_type: 'post',
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
name: 'nav_menu_item',
|
|
147
|
-
label: 'Navigation Menu Items',
|
|
148
|
-
labels: { singular: 'Navigation Menu Item', plural: 'Navigation Menu Items' },
|
|
149
|
-
public: false,
|
|
150
|
-
hierarchical: false,
|
|
151
|
-
showInRest: false,
|
|
152
|
-
supports: [],
|
|
153
|
-
taxonomies: ['nav_menu'],
|
|
154
|
-
hasArchive: false,
|
|
155
|
-
rewrite: false,
|
|
156
|
-
capability_type: 'post',
|
|
157
|
-
},
|
|
158
|
-
];
|
|
159
|
-
//# sourceMappingURL=post-type-registry.js.map
|
|
@@ -1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ACD;QACC,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAC9C,MAAM,EAAE,IAAI;QACZ,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,OAAO;QACjB,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC;QACzC,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;QACd,eAAe,EAAE,MAAM;KACvB;IACD;QACC,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,WAAW;QAClB,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE;QACrD,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,CAAC,QAAQ,CAAC;QACpB,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;QACd,eAAe,EAAE,MAAM;KACvB;IACD;QACC,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,uBAAuB;QAC9B,MAAM,EAAE,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,EAAE,uBAAuB,EAAE;QAC7E,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,CAAC,UAAU,CAAC;QACxB,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;QACd,eAAe,EAAE,MAAM;KACvB;CACD,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { TaxonomyDefinition } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Registry for taxonomies (categories, tags, custom taxonomies).
|
|
4
|
-
*/
|
|
5
|
-
export declare class TaxonomyRegistry {
|
|
6
|
-
private taxonomies;
|
|
7
|
-
register(definition: TaxonomyDefinition): void;
|
|
8
|
-
get(name: string): TaxonomyDefinition | undefined;
|
|
9
|
-
has(name: string): boolean;
|
|
10
|
-
getAll(): TaxonomyDefinition[];
|
|
11
|
-
/**
|
|
12
|
-
* Get taxonomies assigned to a specific object type (e.g., 'post').
|
|
13
|
-
*/
|
|
14
|
-
getForObjectType(objectType: string): TaxonomyDefinition[];
|
|
15
|
-
getRestVisible(): TaxonomyDefinition[];
|
|
16
|
-
unregister(name: string): boolean;
|
|
17
|
-
reset(): void;
|
|
18
|
-
}
|
|
19
|
-
export declare const BUILTIN_TAXONOMIES: TaxonomyDefinition[];
|
|
20
|
-
//# sourceMappingURL=taxonomy-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"taxonomy-registry.d.ts","sourceRoot":"","sources":["../src/taxonomy-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;GAEG;AACH,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,UAAU,CAA8C;IAEhE,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,IAAI;IAO9C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIjD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,MAAM,IAAI,kBAAkB,EAAE;IAI9B;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,EAAE;IAI1D,cAAc,IAAI,kBAAkB,EAAE;IAItC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC,KAAK,IAAI,IAAI;CAGb;AAED,eAAO,MAAM,kBAAkB,EAAE,kBAAkB,EAiClD,CAAC"}
|