@tailor-cms/ce-accordion-server 0.0.1
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 +113 -0
- package/dist/index.d.cts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +78 -0
- package/package.json +51 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/index.ts
|
|
20
|
+
var src_exports = {};
|
|
21
|
+
__export(src_exports, {
|
|
22
|
+
afterLoaded: () => afterLoaded,
|
|
23
|
+
afterRetrieve: () => afterRetrieve,
|
|
24
|
+
afterSave: () => afterSave,
|
|
25
|
+
beforeDisplay: () => beforeDisplay,
|
|
26
|
+
beforeSave: () => beforeSave,
|
|
27
|
+
default: () => src_default,
|
|
28
|
+
hookMap: () => hookMap,
|
|
29
|
+
initState: () => initState,
|
|
30
|
+
mocks: () => mocks,
|
|
31
|
+
onUserInteraction: () => onUserInteraction,
|
|
32
|
+
type: () => type
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(src_exports);
|
|
35
|
+
|
|
36
|
+
// ../manifest/dist/index.js
|
|
37
|
+
var type = "CE_ACCORDION";
|
|
38
|
+
var initState = () => ({
|
|
39
|
+
embeds: {},
|
|
40
|
+
items: []
|
|
41
|
+
});
|
|
42
|
+
var mocks = {
|
|
43
|
+
displayContexts: [{ name: "No selection", data: {} }]
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/index.ts
|
|
47
|
+
var IS_CEK = process.env.CEK_RUNTIME;
|
|
48
|
+
var USER_STATE = {};
|
|
49
|
+
function beforeSave(element, services) {
|
|
50
|
+
console.log("Before save hook");
|
|
51
|
+
return element;
|
|
52
|
+
}
|
|
53
|
+
function afterSave(element, services) {
|
|
54
|
+
console.log("After save hook");
|
|
55
|
+
return element;
|
|
56
|
+
}
|
|
57
|
+
function afterLoaded(element, services, runtime) {
|
|
58
|
+
console.log("After loaded hook");
|
|
59
|
+
return element;
|
|
60
|
+
}
|
|
61
|
+
function afterRetrieve(element, services, runtime) {
|
|
62
|
+
console.log("After retrieve hook");
|
|
63
|
+
return element;
|
|
64
|
+
}
|
|
65
|
+
function beforeDisplay(element, context) {
|
|
66
|
+
console.log("beforeDisplay hook");
|
|
67
|
+
console.log("beforeDisplay context", context);
|
|
68
|
+
return { ...context, ...USER_STATE };
|
|
69
|
+
}
|
|
70
|
+
function onUserInteraction(element, context, payload) {
|
|
71
|
+
console.log("onUserInteraction", context, payload);
|
|
72
|
+
if (IS_CEK) {
|
|
73
|
+
USER_STATE.interactionTimestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
74
|
+
context.contextTimestamp = USER_STATE.interactionTimestamp;
|
|
75
|
+
Object.assign(USER_STATE, payload);
|
|
76
|
+
}
|
|
77
|
+
return { updateDisplayState: true };
|
|
78
|
+
}
|
|
79
|
+
var hookMap = new Map(
|
|
80
|
+
Object.entries({
|
|
81
|
+
beforeSave,
|
|
82
|
+
afterSave,
|
|
83
|
+
afterLoaded,
|
|
84
|
+
afterRetrieve,
|
|
85
|
+
onUserInteraction,
|
|
86
|
+
beforeDisplay
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
var src_default = {
|
|
90
|
+
type,
|
|
91
|
+
hookMap,
|
|
92
|
+
initState,
|
|
93
|
+
beforeSave,
|
|
94
|
+
afterSave,
|
|
95
|
+
afterLoaded,
|
|
96
|
+
afterRetrieve,
|
|
97
|
+
onUserInteraction,
|
|
98
|
+
beforeDisplay,
|
|
99
|
+
mocks
|
|
100
|
+
};
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
afterLoaded,
|
|
104
|
+
afterRetrieve,
|
|
105
|
+
afterSave,
|
|
106
|
+
beforeDisplay,
|
|
107
|
+
beforeSave,
|
|
108
|
+
hookMap,
|
|
109
|
+
initState,
|
|
110
|
+
mocks,
|
|
111
|
+
onUserInteraction,
|
|
112
|
+
type
|
|
113
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as _tailor_cms_ce_accordion_manifest from '@tailor-cms/ce-accordion-manifest';
|
|
2
|
+
import { Element } from '@tailor-cms/ce-accordion-manifest';
|
|
3
|
+
export { initState, mocks, type } from '@tailor-cms/ce-accordion-manifest';
|
|
4
|
+
import { HookServices, ServerRuntime } from '@tailor-cms/cek-common';
|
|
5
|
+
|
|
6
|
+
declare function beforeSave(element: Element, services: HookServices): Element;
|
|
7
|
+
declare function afterSave(element: Element, services: HookServices): Element;
|
|
8
|
+
declare function afterLoaded(element: Element, services: HookServices, runtime: ServerRuntime): Element;
|
|
9
|
+
declare function afterRetrieve(element: Element, services: HookServices, runtime: ServerRuntime): Element;
|
|
10
|
+
declare function beforeDisplay(element: Element, context: any): any;
|
|
11
|
+
declare function onUserInteraction(element: Element, context: any, payload: any): any;
|
|
12
|
+
declare const hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
|
|
13
|
+
declare const _default: {
|
|
14
|
+
type: string;
|
|
15
|
+
hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
|
|
16
|
+
initState: _tailor_cms_ce_accordion_manifest.DataInitializer;
|
|
17
|
+
beforeSave: typeof beforeSave;
|
|
18
|
+
afterSave: typeof afterSave;
|
|
19
|
+
afterLoaded: typeof afterLoaded;
|
|
20
|
+
afterRetrieve: typeof afterRetrieve;
|
|
21
|
+
onUserInteraction: typeof onUserInteraction;
|
|
22
|
+
beforeDisplay: typeof beforeDisplay;
|
|
23
|
+
mocks: {
|
|
24
|
+
displayContexts: {
|
|
25
|
+
name: string;
|
|
26
|
+
data: {};
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { afterLoaded, afterRetrieve, afterSave, beforeDisplay, beforeSave, _default as default, hookMap, onUserInteraction };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as _tailor_cms_ce_accordion_manifest from '@tailor-cms/ce-accordion-manifest';
|
|
2
|
+
import { Element } from '@tailor-cms/ce-accordion-manifest';
|
|
3
|
+
export { initState, mocks, type } from '@tailor-cms/ce-accordion-manifest';
|
|
4
|
+
import { HookServices, ServerRuntime } from '@tailor-cms/cek-common';
|
|
5
|
+
|
|
6
|
+
declare function beforeSave(element: Element, services: HookServices): Element;
|
|
7
|
+
declare function afterSave(element: Element, services: HookServices): Element;
|
|
8
|
+
declare function afterLoaded(element: Element, services: HookServices, runtime: ServerRuntime): Element;
|
|
9
|
+
declare function afterRetrieve(element: Element, services: HookServices, runtime: ServerRuntime): Element;
|
|
10
|
+
declare function beforeDisplay(element: Element, context: any): any;
|
|
11
|
+
declare function onUserInteraction(element: Element, context: any, payload: any): any;
|
|
12
|
+
declare const hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
|
|
13
|
+
declare const _default: {
|
|
14
|
+
type: string;
|
|
15
|
+
hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
|
|
16
|
+
initState: _tailor_cms_ce_accordion_manifest.DataInitializer;
|
|
17
|
+
beforeSave: typeof beforeSave;
|
|
18
|
+
afterSave: typeof afterSave;
|
|
19
|
+
afterLoaded: typeof afterLoaded;
|
|
20
|
+
afterRetrieve: typeof afterRetrieve;
|
|
21
|
+
onUserInteraction: typeof onUserInteraction;
|
|
22
|
+
beforeDisplay: typeof beforeDisplay;
|
|
23
|
+
mocks: {
|
|
24
|
+
displayContexts: {
|
|
25
|
+
name: string;
|
|
26
|
+
data: {};
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { afterLoaded, afterRetrieve, afterSave, beforeDisplay, beforeSave, _default as default, hookMap, onUserInteraction };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// ../manifest/dist/index.js
|
|
2
|
+
var type = "CE_ACCORDION";
|
|
3
|
+
var initState = () => ({
|
|
4
|
+
embeds: {},
|
|
5
|
+
items: []
|
|
6
|
+
});
|
|
7
|
+
var mocks = {
|
|
8
|
+
displayContexts: [{ name: "No selection", data: {} }]
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// src/index.ts
|
|
12
|
+
var IS_CEK = process.env.CEK_RUNTIME;
|
|
13
|
+
var USER_STATE = {};
|
|
14
|
+
function beforeSave(element, services) {
|
|
15
|
+
console.log("Before save hook");
|
|
16
|
+
return element;
|
|
17
|
+
}
|
|
18
|
+
function afterSave(element, services) {
|
|
19
|
+
console.log("After save hook");
|
|
20
|
+
return element;
|
|
21
|
+
}
|
|
22
|
+
function afterLoaded(element, services, runtime) {
|
|
23
|
+
console.log("After loaded hook");
|
|
24
|
+
return element;
|
|
25
|
+
}
|
|
26
|
+
function afterRetrieve(element, services, runtime) {
|
|
27
|
+
console.log("After retrieve hook");
|
|
28
|
+
return element;
|
|
29
|
+
}
|
|
30
|
+
function beforeDisplay(element, context) {
|
|
31
|
+
console.log("beforeDisplay hook");
|
|
32
|
+
console.log("beforeDisplay context", context);
|
|
33
|
+
return { ...context, ...USER_STATE };
|
|
34
|
+
}
|
|
35
|
+
function onUserInteraction(element, context, payload) {
|
|
36
|
+
console.log("onUserInteraction", context, payload);
|
|
37
|
+
if (IS_CEK) {
|
|
38
|
+
USER_STATE.interactionTimestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
39
|
+
context.contextTimestamp = USER_STATE.interactionTimestamp;
|
|
40
|
+
Object.assign(USER_STATE, payload);
|
|
41
|
+
}
|
|
42
|
+
return { updateDisplayState: true };
|
|
43
|
+
}
|
|
44
|
+
var hookMap = new Map(
|
|
45
|
+
Object.entries({
|
|
46
|
+
beforeSave,
|
|
47
|
+
afterSave,
|
|
48
|
+
afterLoaded,
|
|
49
|
+
afterRetrieve,
|
|
50
|
+
onUserInteraction,
|
|
51
|
+
beforeDisplay
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
var src_default = {
|
|
55
|
+
type,
|
|
56
|
+
hookMap,
|
|
57
|
+
initState,
|
|
58
|
+
beforeSave,
|
|
59
|
+
afterSave,
|
|
60
|
+
afterLoaded,
|
|
61
|
+
afterRetrieve,
|
|
62
|
+
onUserInteraction,
|
|
63
|
+
beforeDisplay,
|
|
64
|
+
mocks
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
afterLoaded,
|
|
68
|
+
afterRetrieve,
|
|
69
|
+
afterSave,
|
|
70
|
+
beforeDisplay,
|
|
71
|
+
beforeSave,
|
|
72
|
+
src_default as default,
|
|
73
|
+
hookMap,
|
|
74
|
+
initState,
|
|
75
|
+
mocks,
|
|
76
|
+
onUserInteraction,
|
|
77
|
+
type
|
|
78
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tailor-cms/ce-accordion-server",
|
|
3
|
+
"description": "Tailor CMS accordion element",
|
|
4
|
+
"author": "Studion <info@gostudion.com> (https://github.com/tailor-cms)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"version": "0.0.1",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@tailor-cms/cek-common": "^0.0.3",
|
|
20
|
+
"@tailor-cms/eslint-config": "0.0.2",
|
|
21
|
+
"tsup": "^7.2.0",
|
|
22
|
+
"typescript": "^5.1.6",
|
|
23
|
+
"@tailor-cms/ce-accordion-manifest": "0.0.1"
|
|
24
|
+
},
|
|
25
|
+
"tsup": {
|
|
26
|
+
"entry": [
|
|
27
|
+
"src/index.ts"
|
|
28
|
+
],
|
|
29
|
+
"target": [
|
|
30
|
+
"node14",
|
|
31
|
+
"es2022"
|
|
32
|
+
],
|
|
33
|
+
"format": [
|
|
34
|
+
"cjs",
|
|
35
|
+
"esm"
|
|
36
|
+
],
|
|
37
|
+
"bundle": true,
|
|
38
|
+
"minify": false,
|
|
39
|
+
"clean": false,
|
|
40
|
+
"dts": true
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"dev": "tsup --watch src --watch ../manifest/dist",
|
|
47
|
+
"build": "tsup",
|
|
48
|
+
"lint": "eslint --ext .js,.ts .",
|
|
49
|
+
"lint:fix": "pnpm lint --fix"
|
|
50
|
+
}
|
|
51
|
+
}
|