coralite 0.22.1 → 0.23.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/lib/collection.d.ts +3 -3
- package/dist/lib/collection.d.ts.map +1 -1
- package/dist/lib/coralite.d.ts +12 -11
- package/dist/lib/coralite.d.ts.map +1 -1
- package/dist/lib/index.js +52 -11
- package/dist/lib/index.js.map +2 -2
- package/dist/lib/plugin.d.ts +1 -1
- package/dist/lib/plugin.d.ts.map +1 -1
- package/dist/lib/script-manager.d.ts +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/plugins/define-component.d.ts.map +1 -1
- package/dist/plugins/define-component.js +3 -1
- package/dist/types/collection.d.ts +35 -0
- package/dist/types/collection.d.ts.map +1 -0
- package/dist/types/core.d.ts +111 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/document.d.ts +179 -0
- package/dist/types/document.d.ts.map +1 -0
- package/dist/types/dom.d.ts +455 -0
- package/dist/types/dom.d.ts.map +1 -0
- package/dist/types/index.d.ts +55 -1089
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/module.d.ts +95 -0
- package/dist/types/module.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +202 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/script.d.ts +84 -0
- package/dist/types/script.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/lib/collection.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ declare class CoraliteCollection {
|
|
|
63
63
|
* @type {Object.<string, CoraliteCollectionItem[]>}
|
|
64
64
|
*/
|
|
65
65
|
listByPath: {
|
|
66
|
-
[x: string]: CoraliteCollectionItem[];
|
|
66
|
+
[x: string]: import("../types/collection.js").CoraliteCollectionItem[];
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
69
|
* An object mapping unique identifiers to HTMLData objects.
|
|
@@ -71,7 +71,7 @@ declare class CoraliteCollection {
|
|
|
71
71
|
* @type {Object.<string, CoraliteCollectionItem>}
|
|
72
72
|
*/
|
|
73
73
|
collection: {
|
|
74
|
-
[x: string]: CoraliteCollectionItem;
|
|
74
|
+
[x: string]: import("../types/collection.js").CoraliteCollectionItem;
|
|
75
75
|
};
|
|
76
76
|
/**
|
|
77
77
|
* Callback triggered when setting a new item
|
|
@@ -108,7 +108,7 @@ declare class CoraliteCollection {
|
|
|
108
108
|
* @param {CoraliteCollectionItem|string} value - The HTMLData object to be updated or added.
|
|
109
109
|
* @throws {Error} If invalid input is provided
|
|
110
110
|
*/
|
|
111
|
-
updateItem(value: CoraliteCollectionItem | string): Promise<CoraliteCollectionItem>;
|
|
111
|
+
updateItem(value: CoraliteCollectionItem | string): Promise<import("../types/collection.js").CoraliteCollectionItem>;
|
|
112
112
|
/**
|
|
113
113
|
* Retrieves an item by its unique identifier
|
|
114
114
|
* @param {string} id - Unique identifier of the item
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../lib/collection.js"],"names":[],"mappings":";AAKA;;;;;;;GAOG;AAEH;;;;;;;;;GASG;AACH,8CALG;IAAyB,OAAO,GAAxB,MAAM;IAC+B,KAAK,GAA1C,0BAA0B;IACc,QAAQ,GAAhD,6BAA6B;IACW,QAAQ,GAAhD,6BAA6B;CACvC,QAgDA;;IAlED;;;;;;;OAOG;IAEH;;;;;;;;;OASG;IACH,sBALG;QAAyB,OAAO,GAAxB,MAAM;QAC+B,KAAK,GAA1C,0BAA0B;QACc,QAAQ,GAAhD,6BAA6B;QACW,QAAQ,GAAhD,6BAA6B;KACvC,EAgDA;IA9CC;;OAEG;IACH,gBAAyC;IAMzC;;;OAGG;IACH,MAFU,sBAAsB,EAAE,CAEpB;IAEd;;;;OAIG;IACH;;MAAoB;IAEpB;;;;OAIG;IACH;;MAAoB;IAEpB;;;OAGG;IACH,QAFU,0BAA0B,GAAG,SAAS,CAErB;IAE3B;;;OAGG;IACH,WAFU,6BAA6B,GAAG,SAAS,CAElB;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C;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,sBAAsB,EAAE,GAAG,SAAS,CAQhD;IAED;;;;;;OAMG;IACH,sBAJW,MAAM,GACJ,OAAO,CAAC,QAAQ,CAAC,CA2B7B;;gDA9UmB,mBAAmB;mDAAnB,mBAAmB;mDAAnB,mBAAmB;4CAAnB,mBAAmB;8BAAnB,mBAAmB"}
|
package/dist/lib/coralite.d.ts
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* CoraliteDocument,
|
|
9
9
|
* CoraliteCollectionItem,
|
|
10
10
|
* CoraliteDocumentRoot,
|
|
11
|
-
* CoralitePluginInstance,
|
|
12
11
|
* CoraliteCollectionEventSet,
|
|
13
12
|
* IgnoreByAttribute,
|
|
14
13
|
* CoraliteDocumentResult,
|
|
15
14
|
* CoraliteValues,
|
|
16
|
-
* CoraliteScriptContent,
|
|
17
15
|
* InstanceContext} from '../types/index.js'
|
|
16
|
+
*
|
|
17
|
+
* @import { CoralitePluginInstance } from '../types/plugin.js'
|
|
18
18
|
*/
|
|
19
19
|
/**
|
|
20
20
|
* @import {DomSerializerOptions} from 'dom-serializer'
|
|
@@ -51,13 +51,13 @@ export class Coralite {
|
|
|
51
51
|
* CoraliteDocument,
|
|
52
52
|
* CoraliteCollectionItem,
|
|
53
53
|
* CoraliteDocumentRoot,
|
|
54
|
-
* CoralitePluginInstance,
|
|
55
54
|
* CoraliteCollectionEventSet,
|
|
56
55
|
* IgnoreByAttribute,
|
|
57
56
|
* CoraliteDocumentResult,
|
|
58
57
|
* CoraliteValues,
|
|
59
|
-
* CoraliteScriptContent,
|
|
60
58
|
* InstanceContext} from '../types/index.js'
|
|
59
|
+
*
|
|
60
|
+
* @import { CoralitePluginInstance } from '../types/plugin.js'
|
|
61
61
|
*/
|
|
62
62
|
/**
|
|
63
63
|
* @import {DomSerializerOptions} from 'dom-serializer'
|
|
@@ -87,7 +87,7 @@ export class Coralite {
|
|
|
87
87
|
templates: string;
|
|
88
88
|
pages: string;
|
|
89
89
|
plugins: CoralitePluginInstance[];
|
|
90
|
-
ignoreByAttribute: IgnoreByAttribute[];
|
|
90
|
+
ignoreByAttribute: import("../types/document.js").IgnoreByAttribute[];
|
|
91
91
|
path: {
|
|
92
92
|
templates: string;
|
|
93
93
|
pages: string;
|
|
@@ -104,6 +104,7 @@ export class Coralite {
|
|
|
104
104
|
onTemplateSet: any[];
|
|
105
105
|
onTemplateUpdate: any[];
|
|
106
106
|
onTemplateDelete: any[];
|
|
107
|
+
onAfterPageRender: any[];
|
|
107
108
|
};
|
|
108
109
|
};
|
|
109
110
|
_scriptManager: ScriptManager;
|
|
@@ -123,7 +124,7 @@ export class Coralite {
|
|
|
123
124
|
templates: string;
|
|
124
125
|
pages: string;
|
|
125
126
|
};
|
|
126
|
-
excludeByAttribute: IgnoreByAttribute[];
|
|
127
|
+
excludeByAttribute: import("../types/document.js").IgnoreByAttribute[];
|
|
127
128
|
templates: CoraliteCollection;
|
|
128
129
|
pages: CoraliteCollection;
|
|
129
130
|
};
|
|
@@ -507,24 +508,24 @@ export class Coralite {
|
|
|
507
508
|
*
|
|
508
509
|
* @internal
|
|
509
510
|
*
|
|
510
|
-
* @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onTemplateSet'|'onTemplateUpdate'|'onTemplateDelete'} name - The name of the hook to trigger.
|
|
511
|
+
* @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onTemplateSet'|'onTemplateUpdate'|'onTemplateDelete'|'onAfterPageRender'} name - The name of the hook to trigger.
|
|
511
512
|
* @param {T} data - Data to pass to each callback function.
|
|
512
513
|
* @return {Promise<Array<T>>} A promise that resolves to an array of results from all callbacks.
|
|
513
514
|
*/
|
|
514
|
-
_triggerPluginHook<T extends unknown>(name: "onPageSet" | "onPageUpdate" | "onPageDelete" | "onTemplateSet" | "onTemplateUpdate" | "onTemplateDelete", data: T): Promise<Array<T>>;
|
|
515
|
+
_triggerPluginHook<T extends unknown>(name: "onPageSet" | "onPageUpdate" | "onPageDelete" | "onTemplateSet" | "onTemplateUpdate" | "onTemplateDelete" | "onAfterPageRender", data: T): Promise<Array<T>>;
|
|
515
516
|
/**
|
|
516
517
|
* Registers a callback function under the specified hook name.
|
|
517
518
|
*
|
|
518
519
|
* @internal
|
|
519
520
|
*
|
|
520
|
-
* @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onTemplateSet'|'onTemplateUpdate'|'onTemplateDelete'} name - The name of the hook to register the callback with.
|
|
521
|
+
* @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onTemplateSet'|'onTemplateUpdate'|'onTemplateDelete'|'onAfterPageRender'} name - The name of the hook to register the callback with.
|
|
521
522
|
* @param {Function} callback - The callback function to be executed when the hook is triggered.
|
|
522
523
|
*/
|
|
523
|
-
_addPluginHook(name: "onPageSet" | "onPageUpdate" | "onPageDelete" | "onTemplateSet" | "onTemplateUpdate" | "onTemplateDelete", callback: Function): void;
|
|
524
|
+
_addPluginHook(name: "onPageSet" | "onPageUpdate" | "onPageDelete" | "onTemplateSet" | "onTemplateUpdate" | "onTemplateDelete" | "onAfterPageRender", callback: Function): void;
|
|
524
525
|
}
|
|
525
526
|
export default Coralite;
|
|
526
527
|
export type BuildPageHandler = (result: CoraliteResult) => Promise<any> | any;
|
|
527
|
-
import type { CoralitePluginInstance } from '../types/
|
|
528
|
+
import type { CoralitePluginInstance } from '../types/plugin.js';
|
|
528
529
|
import type { IgnoreByAttribute } from '../types/index.js';
|
|
529
530
|
import type { CoraliteCollectionItem } from '../types/index.js';
|
|
530
531
|
import { ScriptManager } from './script-manager.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coralite.d.ts","sourceRoot":"","sources":["../../lib/coralite.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AAEH;;;;;;;;;;;;;;GAcG;AACH,2EAZG;IAAwB,SAAS,EAAzB,MAAM;IAC6B,OAAO,GAA1C,sBAAsB,EAAE;IACR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57
57
|
newNode.children[i] = cloneNode(nodeMap, node.children[i], newNode);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
if (newNode.slots) {
|
|
61
|
+
for (let i = 0; i < newNode.slots.length; i++) {
|
|
62
|
+
const slot = newNode.slots[i];
|
|
63
|
+
if (slot.node) {
|
|
64
|
+
const clonedNode = nodeMap.get(slot.node);
|
|
65
|
+
if (clonedNode) {
|
|
66
|
+
slot.node = clonedNode;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
60
71
|
return newNode;
|
|
61
72
|
}
|
|
62
73
|
function cloneModuleInstance(originalModule) {
|
|
@@ -3353,11 +3364,12 @@ var defineComponent = createPlugin({
|
|
|
3353
3364
|
const token = tokens[key];
|
|
3354
3365
|
let result = token;
|
|
3355
3366
|
if (typeof token === "function") {
|
|
3356
|
-
result = await token(
|
|
3367
|
+
result = await token(results);
|
|
3357
3368
|
}
|
|
3358
3369
|
if (result) {
|
|
3359
3370
|
results[key] = await processTokenValue(result, {
|
|
3360
3371
|
...context,
|
|
3372
|
+
values: results,
|
|
3361
3373
|
createComponent: this.createComponent.bind(this)
|
|
3362
3374
|
});
|
|
3363
3375
|
} else {
|
|
@@ -3384,6 +3396,7 @@ var defineComponent = createPlugin({
|
|
|
3384
3396
|
if (typeof result === "string") {
|
|
3385
3397
|
const processedResult = await processTokenValue(result, {
|
|
3386
3398
|
...context,
|
|
3399
|
+
values: results,
|
|
3387
3400
|
createComponent: this.createComponent.bind(this)
|
|
3388
3401
|
});
|
|
3389
3402
|
if (Array.isArray(processedResult)) {
|
|
@@ -3612,7 +3625,8 @@ function Coralite({
|
|
|
3612
3625
|
onPageDelete: [],
|
|
3613
3626
|
onTemplateSet: [],
|
|
3614
3627
|
onTemplateUpdate: [],
|
|
3615
|
-
onTemplateDelete: []
|
|
3628
|
+
onTemplateDelete: [],
|
|
3629
|
+
onAfterPageRender: []
|
|
3616
3630
|
}
|
|
3617
3631
|
};
|
|
3618
3632
|
this._scriptManager = new ScriptManager();
|
|
@@ -3668,6 +3682,9 @@ function Coralite({
|
|
|
3668
3682
|
if (plugin.onTemplateUpdate) {
|
|
3669
3683
|
this._addPluginHook("onTemplateUpdate", plugin.onTemplateUpdate);
|
|
3670
3684
|
}
|
|
3685
|
+
if (plugin.onAfterPageRender) {
|
|
3686
|
+
this._addPluginHook("onAfterPageRender", plugin.onAfterPageRender);
|
|
3687
|
+
}
|
|
3671
3688
|
if (plugin.script) {
|
|
3672
3689
|
this._scriptManager.use(plugin.script);
|
|
3673
3690
|
}
|
|
@@ -4072,19 +4089,39 @@ Coralite.prototype.build = async function(...args) {
|
|
|
4072
4089
|
}
|
|
4073
4090
|
const task = limit(async () => {
|
|
4074
4091
|
if (signal?.aborted) throw signal.reason;
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4092
|
+
const hookResults = await this._triggerPluginHook("onAfterPageRender", result);
|
|
4093
|
+
let hookItems = [];
|
|
4094
|
+
for (const hookResult of hookResults) {
|
|
4095
|
+
if (hookResult) {
|
|
4096
|
+
if (Array.isArray(hookResult)) {
|
|
4097
|
+
hookItems.push(...hookResult);
|
|
4098
|
+
} else {
|
|
4099
|
+
hookItems.push(hookResult);
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
}
|
|
4103
|
+
const items = [result, ...hookItems];
|
|
4104
|
+
const finalResults = [];
|
|
4105
|
+
for (const item of items) {
|
|
4106
|
+
if (typeof callback === "function") {
|
|
4107
|
+
const transformed = await callback(item);
|
|
4108
|
+
if (transformed) {
|
|
4109
|
+
finalResults.push(transformed);
|
|
4110
|
+
}
|
|
4111
|
+
} else {
|
|
4112
|
+
finalResults.push(item);
|
|
4113
|
+
}
|
|
4079
4114
|
}
|
|
4115
|
+
return finalResults;
|
|
4080
4116
|
});
|
|
4081
4117
|
executing.add(task);
|
|
4082
|
-
task.then((
|
|
4083
|
-
if (
|
|
4084
|
-
results.push(
|
|
4118
|
+
task.then((callbackResults) => {
|
|
4119
|
+
if (callbackResults && callbackResults.length) {
|
|
4120
|
+
results.push(...callbackResults);
|
|
4085
4121
|
}
|
|
4086
4122
|
executing.delete(task);
|
|
4087
|
-
}).catch(() => {
|
|
4123
|
+
}).catch((err) => {
|
|
4124
|
+
console.error(err);
|
|
4088
4125
|
executing.delete(task);
|
|
4089
4126
|
});
|
|
4090
4127
|
}
|
|
@@ -4377,11 +4414,12 @@ Coralite.prototype.createComponent = async function({
|
|
|
4377
4414
|
if (component) {
|
|
4378
4415
|
const slotContextId = contextId + slotName + i2 + node.name;
|
|
4379
4416
|
const currentValues = renderContext.values[slotContextId] || {};
|
|
4417
|
+
const attribValues = cleanKeys(node.attribs);
|
|
4380
4418
|
if (typeof node.attribs === "object") {
|
|
4381
4419
|
renderContext.values[slotContextId] = {
|
|
4382
4420
|
...currentValues,
|
|
4383
4421
|
...values,
|
|
4384
|
-
...
|
|
4422
|
+
...attribValues
|
|
4385
4423
|
};
|
|
4386
4424
|
} else {
|
|
4387
4425
|
renderContext.values[slotContextId] = Object.assign(currentValues, values);
|
|
@@ -4570,6 +4608,7 @@ function createPlugin({
|
|
|
4570
4608
|
onTemplateSet,
|
|
4571
4609
|
onTemplateUpdate,
|
|
4572
4610
|
onTemplateDelete,
|
|
4611
|
+
onAfterPageRender,
|
|
4573
4612
|
script,
|
|
4574
4613
|
server
|
|
4575
4614
|
}) {
|
|
@@ -4581,6 +4620,7 @@ function createPlugin({
|
|
|
4581
4620
|
validateOptionalFunction(onTemplateSet, "onTemplateSet");
|
|
4582
4621
|
validateOptionalFunction(onTemplateUpdate, "onTemplateUpdate");
|
|
4583
4622
|
validateOptionalFunction(onTemplateDelete, "onTemplateDelete");
|
|
4623
|
+
validateOptionalFunction(onAfterPageRender, "onAfterPageRender");
|
|
4584
4624
|
validateOptionalFunction(server, "server");
|
|
4585
4625
|
validateStringArray(templates, "templates");
|
|
4586
4626
|
if (script != null) {
|
|
@@ -4623,6 +4663,7 @@ function createPlugin({
|
|
|
4623
4663
|
onTemplateSet,
|
|
4624
4664
|
onTemplateUpdate,
|
|
4625
4665
|
onTemplateDelete,
|
|
4666
|
+
onAfterPageRender,
|
|
4626
4667
|
script,
|
|
4627
4668
|
server
|
|
4628
4669
|
};
|