@tailor-cms/ce-accordion-server 0.1.0 → 2.0.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 +17 -235
- package/dist/index.d.cts +7 -30
- package/dist/index.d.mts +8 -0
- package/dist/index.mjs +11 -0
- package/package.json +18 -23
- package/dist/index.d.ts +0 -31
- package/dist/index.js +0 -202
package/dist/index.cjs
CHANGED
|
@@ -1,237 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 index_exports = {};
|
|
21
|
-
__export(index_exports, {
|
|
22
|
-
afterLoaded: () => afterLoaded,
|
|
23
|
-
afterRetrieve: () => afterRetrieve,
|
|
24
|
-
afterSave: () => afterSave,
|
|
25
|
-
ai: () => ai,
|
|
26
|
-
beforeDisplay: () => beforeDisplay,
|
|
27
|
-
beforeSave: () => beforeSave,
|
|
28
|
-
default: () => index_default,
|
|
29
|
-
hookMap: () => hookMap,
|
|
30
|
-
initState: () => initState,
|
|
31
|
-
onUserInteraction: () => onUserInteraction,
|
|
32
|
-
type: () => type
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(index_exports);
|
|
35
|
-
|
|
36
|
-
// ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/stringify.js
|
|
37
|
-
var byteToHex = [];
|
|
38
|
-
for (let i = 0; i < 256; ++i) {
|
|
39
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
40
|
-
}
|
|
41
|
-
function unsafeStringify(arr, offset = 0) {
|
|
42
|
-
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/rng.js
|
|
46
|
-
var import_crypto = require("crypto");
|
|
47
|
-
var rnds8Pool = new Uint8Array(256);
|
|
48
|
-
var poolPtr = rnds8Pool.length;
|
|
49
|
-
function rng() {
|
|
50
|
-
if (poolPtr > rnds8Pool.length - 16) {
|
|
51
|
-
(0, import_crypto.randomFillSync)(rnds8Pool);
|
|
52
|
-
poolPtr = 0;
|
|
53
|
-
}
|
|
54
|
-
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/native.js
|
|
58
|
-
var import_crypto2 = require("crypto");
|
|
59
|
-
var native_default = { randomUUID: import_crypto2.randomUUID };
|
|
60
|
-
|
|
61
|
-
// ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/v4.js
|
|
62
|
-
function v4(options, buf, offset) {
|
|
63
|
-
var _a;
|
|
64
|
-
if (native_default.randomUUID && !buf && !options) {
|
|
65
|
-
return native_default.randomUUID();
|
|
66
|
-
}
|
|
67
|
-
options = options || {};
|
|
68
|
-
const rnds = options.random ?? ((_a = options.rng) == null ? void 0 : _a.call(options)) ?? rng();
|
|
69
|
-
if (rnds.length < 16) {
|
|
70
|
-
throw new Error("Random bytes length must be >= 16");
|
|
71
|
-
}
|
|
72
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
73
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
74
|
-
if (buf) {
|
|
75
|
-
offset = offset || 0;
|
|
76
|
-
if (offset < 0 || offset + 16 > buf.length) {
|
|
77
|
-
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
78
|
-
}
|
|
79
|
-
for (let i = 0; i < 16; ++i) {
|
|
80
|
-
buf[offset + i] = rnds[i];
|
|
81
|
-
}
|
|
82
|
-
return buf;
|
|
83
|
-
}
|
|
84
|
-
return unsafeStringify(rnds);
|
|
85
|
-
}
|
|
86
|
-
var v4_default = v4;
|
|
87
|
-
|
|
88
|
-
// ../manifest/dist/index.js
|
|
89
|
-
var id1 = v4_default();
|
|
90
|
-
var id2 = v4_default();
|
|
91
|
-
var type = "ACCORDION";
|
|
92
|
-
var initState = () => ({
|
|
93
|
-
embeds: {},
|
|
94
|
-
items: {
|
|
95
|
-
[id1]: {
|
|
96
|
-
id: id1,
|
|
97
|
-
header: "Accordion Item Title",
|
|
98
|
-
body: {},
|
|
99
|
-
position: 1
|
|
100
|
-
},
|
|
101
|
-
[id2]: {
|
|
102
|
-
id: id2,
|
|
103
|
-
header: "Accordion Item Title",
|
|
104
|
-
body: {},
|
|
105
|
-
position: 1
|
|
106
|
-
}
|
|
107
|
-
}
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
108
4
|
});
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
type: "array",
|
|
118
|
-
minItems: 2,
|
|
119
|
-
items: {
|
|
120
|
-
type: "object",
|
|
121
|
-
properties: {
|
|
122
|
-
header: { type: "string" },
|
|
123
|
-
content: { type: "string" }
|
|
124
|
-
},
|
|
125
|
-
required: ["header", "content"],
|
|
126
|
-
additionalProperties: false
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
required: ["items"],
|
|
131
|
-
additionalProperties: false
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
getPrompt: () => `
|
|
135
|
-
Generate a accordion content element as an object with the following
|
|
136
|
-
properties:
|
|
137
|
-
{
|
|
138
|
-
"items": [
|
|
139
|
-
{
|
|
140
|
-
"header": "",
|
|
141
|
-
"content": ""
|
|
142
|
-
}
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
where:
|
|
146
|
-
- 'items' is an array of accordion item objects where:
|
|
147
|
-
- 'header' is the title of the accordion item.
|
|
148
|
-
- 'content' is the text to be displayed in the accordion item.
|
|
149
|
-
The content should be relevant to the topic of the accordion and
|
|
150
|
-
have a few paragraphs about the topic.
|
|
151
|
-
`,
|
|
152
|
-
processResponse: (val) => {
|
|
153
|
-
return val.items.reduce(
|
|
154
|
-
(acc, { header, content }, index) => {
|
|
155
|
-
const embedId = v4_default();
|
|
156
|
-
const itemId = v4_default();
|
|
157
|
-
acc.embeds[embedId] = {
|
|
158
|
-
id: embedId,
|
|
159
|
-
data: { content },
|
|
160
|
-
embedded: true,
|
|
161
|
-
position: 1,
|
|
162
|
-
type: "TIPTAP_HTML"
|
|
163
|
-
};
|
|
164
|
-
acc.items[itemId] = {
|
|
165
|
-
id: itemId,
|
|
166
|
-
body: { [embedId]: true },
|
|
167
|
-
header,
|
|
168
|
-
position: index + 1
|
|
169
|
-
};
|
|
170
|
-
return acc;
|
|
171
|
-
},
|
|
172
|
-
{ items: {}, embeds: {} }
|
|
173
|
-
);
|
|
174
|
-
}
|
|
5
|
+
let _tailor_cms_ce_accordion_manifest = require("@tailor-cms/ce-accordion-manifest");
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
const hookMap = /* @__PURE__ */ new Map();
|
|
8
|
+
const serverModule = {
|
|
9
|
+
type: _tailor_cms_ce_accordion_manifest.type,
|
|
10
|
+
initState: _tailor_cms_ce_accordion_manifest.initState,
|
|
11
|
+
hookMap,
|
|
12
|
+
ai: _tailor_cms_ce_accordion_manifest.ai
|
|
175
13
|
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
function afterSave(element, _services) {
|
|
184
|
-
return element;
|
|
185
|
-
}
|
|
186
|
-
function afterLoaded(element, _services, _runtime) {
|
|
187
|
-
return element;
|
|
188
|
-
}
|
|
189
|
-
function afterRetrieve(element, _services, _runtime) {
|
|
190
|
-
return element;
|
|
191
|
-
}
|
|
192
|
-
function beforeDisplay(_element, context) {
|
|
193
|
-
return { ...context, ...USER_STATE };
|
|
194
|
-
}
|
|
195
|
-
function onUserInteraction(_element, context, payload) {
|
|
196
|
-
if (IS_CEK) {
|
|
197
|
-
USER_STATE.interactionTimestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
198
|
-
context.contextTimestamp = USER_STATE.interactionTimestamp;
|
|
199
|
-
Object.assign(USER_STATE, payload);
|
|
200
|
-
}
|
|
201
|
-
return { updateDisplayState: true };
|
|
202
|
-
}
|
|
203
|
-
var hookMap = new Map(
|
|
204
|
-
Object.entries({
|
|
205
|
-
beforeSave,
|
|
206
|
-
afterSave,
|
|
207
|
-
afterLoaded,
|
|
208
|
-
afterRetrieve,
|
|
209
|
-
onUserInteraction,
|
|
210
|
-
beforeDisplay
|
|
211
|
-
})
|
|
212
|
-
);
|
|
213
|
-
var index_default = {
|
|
214
|
-
type,
|
|
215
|
-
hookMap,
|
|
216
|
-
initState,
|
|
217
|
-
beforeSave,
|
|
218
|
-
afterSave,
|
|
219
|
-
afterLoaded,
|
|
220
|
-
afterRetrieve,
|
|
221
|
-
onUserInteraction,
|
|
222
|
-
beforeDisplay,
|
|
223
|
-
ai
|
|
224
|
-
};
|
|
225
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
226
|
-
0 && (module.exports = {
|
|
227
|
-
afterLoaded,
|
|
228
|
-
afterRetrieve,
|
|
229
|
-
afterSave,
|
|
230
|
-
ai,
|
|
231
|
-
beforeDisplay,
|
|
232
|
-
beforeSave,
|
|
233
|
-
hookMap,
|
|
234
|
-
initState,
|
|
235
|
-
onUserInteraction,
|
|
236
|
-
type
|
|
237
|
-
});
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.ai = _tailor_cms_ce_accordion_manifest.ai;
|
|
16
|
+
exports.default = serverModule;
|
|
17
|
+
exports.hookMap = hookMap;
|
|
18
|
+
exports.initState = _tailor_cms_ce_accordion_manifest.initState;
|
|
19
|
+
exports.type = _tailor_cms_ce_accordion_manifest.type;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import * as _tailor_cms_ce_accordion_manifest from '@tailor-cms/ce-accordion-manifest';
|
|
4
|
-
import { Element } from '@tailor-cms/ce-accordion-manifest';
|
|
5
|
-
export { ai, initState, type } from '@tailor-cms/ce-accordion-manifest';
|
|
1
|
+
import { Element, ai, initState, type } from "@tailor-cms/ce-accordion-manifest";
|
|
2
|
+
import { HookMap, ServerModule } from "@tailor-cms/cek-common";
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
declare
|
|
9
|
-
declare
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
declare function onUserInteraction(_element: Element, context: any, payload: any): any;
|
|
13
|
-
declare const hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
|
|
14
|
-
declare const _default: {
|
|
15
|
-
type: string;
|
|
16
|
-
hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
|
|
17
|
-
initState: _tailor_cms_ce_accordion_manifest.DataInitializer;
|
|
18
|
-
beforeSave: typeof beforeSave;
|
|
19
|
-
afterSave: typeof afterSave;
|
|
20
|
-
afterLoaded: typeof afterLoaded;
|
|
21
|
-
afterRetrieve: typeof afterRetrieve;
|
|
22
|
-
onUserInteraction: typeof onUserInteraction;
|
|
23
|
-
beforeDisplay: typeof beforeDisplay;
|
|
24
|
-
ai: {
|
|
25
|
-
Schema: _tailor_cms_cek_common.OpenAISchema;
|
|
26
|
-
getPrompt: () => string;
|
|
27
|
-
processResponse: (val: any) => any;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export { afterLoaded, afterRetrieve, afterSave, beforeDisplay, beforeSave, _default as default, hookMap, onUserInteraction };
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
declare const hookMap: HookMap<Element>;
|
|
6
|
+
declare const serverModule: ServerModule<Element>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ai, serverModule as default, hookMap, initState, type };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Element, ai, initState, type } from "@tailor-cms/ce-accordion-manifest";
|
|
2
|
+
import { HookMap, ServerModule } from "@tailor-cms/cek-common";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
declare const hookMap: HookMap<Element>;
|
|
6
|
+
declare const serverModule: ServerModule<Element>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ai, serverModule as default, hookMap, initState, type };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ai, initState, type } from "@tailor-cms/ce-accordion-manifest";
|
|
2
|
+
//#region src/index.ts
|
|
3
|
+
const hookMap = /* @__PURE__ */ new Map();
|
|
4
|
+
const serverModule = {
|
|
5
|
+
type,
|
|
6
|
+
initState,
|
|
7
|
+
hookMap,
|
|
8
|
+
ai
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ai, serverModule as default, hookMap, initState, type };
|
package/package.json
CHANGED
|
@@ -3,48 +3,43 @@
|
|
|
3
3
|
"description": "Tailor CMS accordion element",
|
|
4
4
|
"author": "Studion <info@gostudion.com> (https://github.com/tailor-cms)",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "2.0.0",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"import": "./dist/index.
|
|
9
|
+
"import": "./dist/index.mjs",
|
|
10
10
|
"require": "./dist/index.cjs"
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"main": "./dist/index.cjs",
|
|
14
|
-
"types": "./dist/index.d.
|
|
14
|
+
"types": "./dist/index.d.mts",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@tailor-cms/cek-common": "2.0.1",
|
|
20
|
+
"@tailor-cms/ce-accordion-manifest": "2.0.0"
|
|
21
|
+
},
|
|
18
22
|
"devDependencies": {
|
|
19
|
-
"@tailor-cms/
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"typescript": "^5.8.3",
|
|
23
|
-
"@tailor-cms/ce-accordion-manifest": "0.1.0"
|
|
23
|
+
"@tailor-cms/eslint-config": "2.0.1",
|
|
24
|
+
"tsdown": "^0.21.10",
|
|
25
|
+
"typescript": "^6.0.3"
|
|
24
26
|
},
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"src/index.ts"
|
|
28
|
-
],
|
|
29
|
-
"target": [
|
|
30
|
-
"node14",
|
|
31
|
-
"es2022"
|
|
32
|
-
],
|
|
27
|
+
"tsdown": {
|
|
28
|
+
"target": "node24",
|
|
33
29
|
"format": [
|
|
34
30
|
"cjs",
|
|
35
31
|
"esm"
|
|
36
|
-
]
|
|
37
|
-
"bundle": true,
|
|
38
|
-
"minify": false,
|
|
39
|
-
"clean": false,
|
|
40
|
-
"dts": true
|
|
32
|
+
]
|
|
41
33
|
},
|
|
42
34
|
"publishConfig": {
|
|
43
35
|
"access": "public"
|
|
44
36
|
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=24"
|
|
39
|
+
},
|
|
45
40
|
"scripts": {
|
|
46
|
-
"dev": "
|
|
47
|
-
"build": "pnpm nuke:dist &&
|
|
41
|
+
"dev": "tsdown --watch src --watch ../manifest/dist",
|
|
42
|
+
"build": "pnpm nuke:dist && tsdown",
|
|
48
43
|
"lint": "eslint .",
|
|
49
44
|
"lint:fix": "pnpm lint --fix",
|
|
50
45
|
"nuke": "pnpm dlx del-cli dist node_modules",
|
package/dist/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as _tailor_cms_cek_common from '@tailor-cms/cek-common';
|
|
2
|
-
import { HookServices, ServerRuntime } from '@tailor-cms/cek-common';
|
|
3
|
-
import * as _tailor_cms_ce_accordion_manifest from '@tailor-cms/ce-accordion-manifest';
|
|
4
|
-
import { Element } from '@tailor-cms/ce-accordion-manifest';
|
|
5
|
-
export { ai, initState, type } from '@tailor-cms/ce-accordion-manifest';
|
|
6
|
-
|
|
7
|
-
declare function beforeSave(element: Element, _services: HookServices): Element;
|
|
8
|
-
declare function afterSave(element: Element, _services: HookServices): Element;
|
|
9
|
-
declare function afterLoaded(element: Element, _services: HookServices, _runtime: ServerRuntime): Element;
|
|
10
|
-
declare function afterRetrieve(element: Element, _services: HookServices, _runtime: ServerRuntime): Element;
|
|
11
|
-
declare function beforeDisplay(_element: Element, context: any): any;
|
|
12
|
-
declare function onUserInteraction(_element: Element, context: any, payload: any): any;
|
|
13
|
-
declare const hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
|
|
14
|
-
declare const _default: {
|
|
15
|
-
type: string;
|
|
16
|
-
hookMap: Map<string, typeof beforeSave | typeof afterSave | typeof afterLoaded | typeof afterRetrieve | typeof onUserInteraction | typeof beforeDisplay>;
|
|
17
|
-
initState: _tailor_cms_ce_accordion_manifest.DataInitializer;
|
|
18
|
-
beforeSave: typeof beforeSave;
|
|
19
|
-
afterSave: typeof afterSave;
|
|
20
|
-
afterLoaded: typeof afterLoaded;
|
|
21
|
-
afterRetrieve: typeof afterRetrieve;
|
|
22
|
-
onUserInteraction: typeof onUserInteraction;
|
|
23
|
-
beforeDisplay: typeof beforeDisplay;
|
|
24
|
-
ai: {
|
|
25
|
-
Schema: _tailor_cms_cek_common.OpenAISchema;
|
|
26
|
-
getPrompt: () => string;
|
|
27
|
-
processResponse: (val: any) => any;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export { afterLoaded, afterRetrieve, afterSave, beforeDisplay, beforeSave, _default as default, hookMap, onUserInteraction };
|
package/dist/index.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/stringify.js
|
|
2
|
-
var byteToHex = [];
|
|
3
|
-
for (let i = 0; i < 256; ++i) {
|
|
4
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
5
|
-
}
|
|
6
|
-
function unsafeStringify(arr, offset = 0) {
|
|
7
|
-
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/rng.js
|
|
11
|
-
import { randomFillSync } from "crypto";
|
|
12
|
-
var rnds8Pool = new Uint8Array(256);
|
|
13
|
-
var poolPtr = rnds8Pool.length;
|
|
14
|
-
function rng() {
|
|
15
|
-
if (poolPtr > rnds8Pool.length - 16) {
|
|
16
|
-
randomFillSync(rnds8Pool);
|
|
17
|
-
poolPtr = 0;
|
|
18
|
-
}
|
|
19
|
-
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/native.js
|
|
23
|
-
import { randomUUID } from "crypto";
|
|
24
|
-
var native_default = { randomUUID };
|
|
25
|
-
|
|
26
|
-
// ../../node_modules/.pnpm/uuid@11.1.0/node_modules/uuid/dist/esm/v4.js
|
|
27
|
-
function v4(options, buf, offset) {
|
|
28
|
-
var _a;
|
|
29
|
-
if (native_default.randomUUID && !buf && !options) {
|
|
30
|
-
return native_default.randomUUID();
|
|
31
|
-
}
|
|
32
|
-
options = options || {};
|
|
33
|
-
const rnds = options.random ?? ((_a = options.rng) == null ? void 0 : _a.call(options)) ?? rng();
|
|
34
|
-
if (rnds.length < 16) {
|
|
35
|
-
throw new Error("Random bytes length must be >= 16");
|
|
36
|
-
}
|
|
37
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
38
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
39
|
-
if (buf) {
|
|
40
|
-
offset = offset || 0;
|
|
41
|
-
if (offset < 0 || offset + 16 > buf.length) {
|
|
42
|
-
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
43
|
-
}
|
|
44
|
-
for (let i = 0; i < 16; ++i) {
|
|
45
|
-
buf[offset + i] = rnds[i];
|
|
46
|
-
}
|
|
47
|
-
return buf;
|
|
48
|
-
}
|
|
49
|
-
return unsafeStringify(rnds);
|
|
50
|
-
}
|
|
51
|
-
var v4_default = v4;
|
|
52
|
-
|
|
53
|
-
// ../manifest/dist/index.js
|
|
54
|
-
var id1 = v4_default();
|
|
55
|
-
var id2 = v4_default();
|
|
56
|
-
var type = "ACCORDION";
|
|
57
|
-
var initState = () => ({
|
|
58
|
-
embeds: {},
|
|
59
|
-
items: {
|
|
60
|
-
[id1]: {
|
|
61
|
-
id: id1,
|
|
62
|
-
header: "Accordion Item Title",
|
|
63
|
-
body: {},
|
|
64
|
-
position: 1
|
|
65
|
-
},
|
|
66
|
-
[id2]: {
|
|
67
|
-
id: id2,
|
|
68
|
-
header: "Accordion Item Title",
|
|
69
|
-
body: {},
|
|
70
|
-
position: 1
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
var ai = {
|
|
75
|
-
Schema: {
|
|
76
|
-
type: "json_schema",
|
|
77
|
-
name: "ce_accordion",
|
|
78
|
-
schema: {
|
|
79
|
-
type: "object",
|
|
80
|
-
properties: {
|
|
81
|
-
items: {
|
|
82
|
-
type: "array",
|
|
83
|
-
minItems: 2,
|
|
84
|
-
items: {
|
|
85
|
-
type: "object",
|
|
86
|
-
properties: {
|
|
87
|
-
header: { type: "string" },
|
|
88
|
-
content: { type: "string" }
|
|
89
|
-
},
|
|
90
|
-
required: ["header", "content"],
|
|
91
|
-
additionalProperties: false
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
required: ["items"],
|
|
96
|
-
additionalProperties: false
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
getPrompt: () => `
|
|
100
|
-
Generate a accordion content element as an object with the following
|
|
101
|
-
properties:
|
|
102
|
-
{
|
|
103
|
-
"items": [
|
|
104
|
-
{
|
|
105
|
-
"header": "",
|
|
106
|
-
"content": ""
|
|
107
|
-
}
|
|
108
|
-
]
|
|
109
|
-
}
|
|
110
|
-
where:
|
|
111
|
-
- 'items' is an array of accordion item objects where:
|
|
112
|
-
- 'header' is the title of the accordion item.
|
|
113
|
-
- 'content' is the text to be displayed in the accordion item.
|
|
114
|
-
The content should be relevant to the topic of the accordion and
|
|
115
|
-
have a few paragraphs about the topic.
|
|
116
|
-
`,
|
|
117
|
-
processResponse: (val) => {
|
|
118
|
-
return val.items.reduce(
|
|
119
|
-
(acc, { header, content }, index) => {
|
|
120
|
-
const embedId = v4_default();
|
|
121
|
-
const itemId = v4_default();
|
|
122
|
-
acc.embeds[embedId] = {
|
|
123
|
-
id: embedId,
|
|
124
|
-
data: { content },
|
|
125
|
-
embedded: true,
|
|
126
|
-
position: 1,
|
|
127
|
-
type: "TIPTAP_HTML"
|
|
128
|
-
};
|
|
129
|
-
acc.items[itemId] = {
|
|
130
|
-
id: itemId,
|
|
131
|
-
body: { [embedId]: true },
|
|
132
|
-
header,
|
|
133
|
-
position: index + 1
|
|
134
|
-
};
|
|
135
|
-
return acc;
|
|
136
|
-
},
|
|
137
|
-
{ items: {}, embeds: {} }
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
// src/index.ts
|
|
143
|
-
var IS_CEK = process.env.CEK_RUNTIME;
|
|
144
|
-
var USER_STATE = {};
|
|
145
|
-
function beforeSave(element, _services) {
|
|
146
|
-
return element;
|
|
147
|
-
}
|
|
148
|
-
function afterSave(element, _services) {
|
|
149
|
-
return element;
|
|
150
|
-
}
|
|
151
|
-
function afterLoaded(element, _services, _runtime) {
|
|
152
|
-
return element;
|
|
153
|
-
}
|
|
154
|
-
function afterRetrieve(element, _services, _runtime) {
|
|
155
|
-
return element;
|
|
156
|
-
}
|
|
157
|
-
function beforeDisplay(_element, context) {
|
|
158
|
-
return { ...context, ...USER_STATE };
|
|
159
|
-
}
|
|
160
|
-
function onUserInteraction(_element, context, payload) {
|
|
161
|
-
if (IS_CEK) {
|
|
162
|
-
USER_STATE.interactionTimestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
163
|
-
context.contextTimestamp = USER_STATE.interactionTimestamp;
|
|
164
|
-
Object.assign(USER_STATE, payload);
|
|
165
|
-
}
|
|
166
|
-
return { updateDisplayState: true };
|
|
167
|
-
}
|
|
168
|
-
var hookMap = new Map(
|
|
169
|
-
Object.entries({
|
|
170
|
-
beforeSave,
|
|
171
|
-
afterSave,
|
|
172
|
-
afterLoaded,
|
|
173
|
-
afterRetrieve,
|
|
174
|
-
onUserInteraction,
|
|
175
|
-
beforeDisplay
|
|
176
|
-
})
|
|
177
|
-
);
|
|
178
|
-
var index_default = {
|
|
179
|
-
type,
|
|
180
|
-
hookMap,
|
|
181
|
-
initState,
|
|
182
|
-
beforeSave,
|
|
183
|
-
afterSave,
|
|
184
|
-
afterLoaded,
|
|
185
|
-
afterRetrieve,
|
|
186
|
-
onUserInteraction,
|
|
187
|
-
beforeDisplay,
|
|
188
|
-
ai
|
|
189
|
-
};
|
|
190
|
-
export {
|
|
191
|
-
afterLoaded,
|
|
192
|
-
afterRetrieve,
|
|
193
|
-
afterSave,
|
|
194
|
-
ai,
|
|
195
|
-
beforeDisplay,
|
|
196
|
-
beforeSave,
|
|
197
|
-
index_default as default,
|
|
198
|
-
hookMap,
|
|
199
|
-
initState,
|
|
200
|
-
onUserInteraction,
|
|
201
|
-
type
|
|
202
|
-
};
|