content-engine-lib 1.0.2 → 1.0.5
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.d.ts +6 -4
- package/dist/index.es.js +162 -147
- package/dist/index.umd.js +3 -3
- package/dist/u/{get_emitter → new_emitter}/index.d.ts +6 -2
- package/package.json +1 -1
- package/dist/l/editor/hydrator/index.d.ts +0 -8
- package/dist/l/editor/hydrator/index__OLD.d.ts +0 -19
- package/dist/l/editor/renderer/index.d.ts +0 -8
- package/dist/l/editor/renderer/index__OLD.d.ts +0 -19
- package/dist/l/editor/shared/api/component/index/index.d.ts +0 -13
- package/dist/l/editor/shared/types/index.d.ts +0 -35
- package/dist/l/table/editor/index.d.ts +0 -7
- package/dist/l/table/hydrator/index.d.ts +0 -11
- package/dist/l/table/renderer/index.d.ts +0 -8
- package/dist/l/table/shared/types/index.d.ts +0 -45
- package/dist/l/text/editor/index.d.ts +0 -7
- package/dist/l/text/hydrator/index.d.ts +0 -11
- package/dist/l/text/renderer/index.d.ts +0 -8
- package/dist/l/text/shared/types/index.d.ts +0 -35
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ declare const call_0: <K extends "msg">(event: K, ...args: Parameters<{
|
|
|
9
9
|
key: string;
|
|
10
10
|
value: string;
|
|
11
11
|
};
|
|
12
|
+
$d?: any;
|
|
13
|
+
el?: any;
|
|
12
14
|
}) => Promise<void>;
|
|
13
15
|
}[K]>) => Promise<void>;
|
|
14
16
|
declare const listen_1: <K extends "msg">(event: K, fn: {
|
|
@@ -21,6 +23,8 @@ declare const listen_1: <K extends "msg">(event: K, fn: {
|
|
|
21
23
|
key: string;
|
|
22
24
|
value: string;
|
|
23
25
|
};
|
|
26
|
+
$d?: any;
|
|
27
|
+
el?: any;
|
|
24
28
|
}) => Promise<void>;
|
|
25
29
|
}[K]) => () => void;
|
|
26
30
|
declare const renderer: (_p: renderer_p_TYP) => Promise<{
|
|
@@ -28,7 +32,7 @@ declare const renderer: (_p: renderer_p_TYP) => Promise<{
|
|
|
28
32
|
data: {
|
|
29
33
|
l: any[];
|
|
30
34
|
} | any;
|
|
31
|
-
}
|
|
35
|
+
}) => Promise<{
|
|
32
36
|
r: string;
|
|
33
37
|
style: string;
|
|
34
38
|
head: string;
|
|
@@ -39,7 +43,7 @@ declare const hydrator: (_p: hydrator_p_TYP) => Promise<{
|
|
|
39
43
|
data: {
|
|
40
44
|
l: any[];
|
|
41
45
|
} | any;
|
|
42
|
-
}
|
|
46
|
+
}) => Promise<{
|
|
43
47
|
r: string;
|
|
44
48
|
style: string;
|
|
45
49
|
}>;
|
|
@@ -49,8 +53,6 @@ declare const editor: (_p: editor_p_TYP) => Promise<{
|
|
|
49
53
|
data: {
|
|
50
54
|
l: any[];
|
|
51
55
|
};
|
|
52
|
-
}, _$cb?: {
|
|
53
|
-
change: (_v: any) => any;
|
|
54
56
|
}) => Promise<{
|
|
55
57
|
r: string;
|
|
56
58
|
style: string;
|
package/dist/index.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const g = () => ({
|
|
2
2
|
set: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
|
|
3
|
-
const
|
|
4
|
-
return (t == "x" ?
|
|
3
|
+
const r = Math.random() * 16 | 0;
|
|
4
|
+
return (t == "x" ? r : r & 3 | 8).toString(16);
|
|
5
5
|
})
|
|
6
|
-
}),
|
|
6
|
+
}), u = async () => ({
|
|
7
7
|
f: {
|
|
8
8
|
name: (t) => `${t.name}${t.id}`
|
|
9
9
|
}
|
|
@@ -13,126 +13,126 @@ const g = () => ({
|
|
|
13
13
|
try {
|
|
14
14
|
if (!t.el_id)
|
|
15
15
|
throw new Error("[el_id] is required");
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
16
|
+
const r = t.name, e = document.getElementById(t.el_id);
|
|
17
|
+
if (!e)
|
|
18
18
|
throw new Error("[el_id] is invalid");
|
|
19
|
-
((
|
|
20
|
-
const
|
|
21
|
-
((
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
19
|
+
((n) => {
|
|
20
|
+
const i = (a) => {
|
|
21
|
+
((c) => {
|
|
22
|
+
const l = c.getAttribute("data-ce");
|
|
23
|
+
if (!l)
|
|
24
24
|
return;
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
for (const
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
for (const
|
|
31
|
-
|
|
25
|
+
const s = JSON.parse(l).filter((d) => d?.k.startsWith("t-"));
|
|
26
|
+
if (s.length != 0)
|
|
27
|
+
for (const d of s) {
|
|
28
|
+
const o = d.k, h = d.v.split(" ");
|
|
29
|
+
if (o == `t-${r}-class`)
|
|
30
|
+
for (const f of h)
|
|
31
|
+
c.classList.add(f);
|
|
32
32
|
else
|
|
33
|
-
for (const
|
|
34
|
-
|
|
33
|
+
for (const f of h)
|
|
34
|
+
c.classList.remove(f);
|
|
35
35
|
}
|
|
36
|
-
})(
|
|
36
|
+
})(a);
|
|
37
37
|
};
|
|
38
|
-
for (const
|
|
39
|
-
|
|
40
|
-
n
|
|
41
|
-
})(
|
|
42
|
-
} catch (
|
|
43
|
-
const
|
|
44
|
-
throw console.log(
|
|
38
|
+
for (const a of n.getElementsByTagName("*"))
|
|
39
|
+
i(a);
|
|
40
|
+
i(n);
|
|
41
|
+
})(e);
|
|
42
|
+
} catch (r) {
|
|
43
|
+
const e = `err: [theme] ${r}`;
|
|
44
|
+
throw console.log(e), e;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
function p(t,
|
|
49
|
-
let
|
|
48
|
+
function p(t, r = 1e3) {
|
|
49
|
+
let e = {
|
|
50
50
|
cnt: 0
|
|
51
51
|
};
|
|
52
|
-
return new Promise((
|
|
53
|
-
const
|
|
54
|
-
console.log(`[setInterval] is running.. [count=${
|
|
52
|
+
return new Promise((n) => {
|
|
53
|
+
const i = () => {
|
|
54
|
+
console.log(`[setInterval] is running.. [count=${e.cnt}]`);
|
|
55
55
|
try {
|
|
56
|
-
t() && (clearInterval(
|
|
56
|
+
t() && (clearInterval(a), n());
|
|
57
57
|
} catch {
|
|
58
|
-
console.log(`warn: [wait_until] ignoring the exception in setInterval and will check again after [interval=${
|
|
58
|
+
console.log(`warn: [wait_until] ignoring the exception in setInterval and will check again after [interval=${r}]`);
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
|
|
60
|
+
e.cnt += 1;
|
|
61
|
+
}, a = setInterval(() => {
|
|
62
|
+
i();
|
|
63
|
+
}, r);
|
|
64
|
+
i();
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
let z = class {
|
|
68
68
|
listeners = {};
|
|
69
|
-
on = (
|
|
70
|
-
off = (
|
|
71
|
-
this.listeners[
|
|
69
|
+
on = (r, e) => ((this.listeners[r] ||= []).push(e), () => this.off(r, e));
|
|
70
|
+
off = (r, e) => {
|
|
71
|
+
this.listeners[r] = this.listeners[r]?.filter((n) => n !== e);
|
|
72
72
|
};
|
|
73
73
|
/** Sequential execution (await each listener) */
|
|
74
|
-
emit = async (
|
|
75
|
-
for (const
|
|
76
|
-
await
|
|
74
|
+
emit = async (r, ...e) => {
|
|
75
|
+
for (const n of this.listeners[r] ?? [])
|
|
76
|
+
await n(...e);
|
|
77
77
|
};
|
|
78
78
|
/** Parallel execution (await all listeners) */
|
|
79
|
-
emitParallel = async (
|
|
79
|
+
emitParallel = async (r, ...e) => {
|
|
80
80
|
await Promise.all(
|
|
81
|
-
(this.listeners[
|
|
81
|
+
(this.listeners[r] ?? []).map((n) => n(...e))
|
|
82
82
|
);
|
|
83
83
|
};
|
|
84
84
|
//Error-safe emit
|
|
85
|
-
emitSafe = async (
|
|
86
|
-
for (const
|
|
85
|
+
emitSafe = async (r, ...e) => {
|
|
86
|
+
for (const n of this.listeners[r] ?? [])
|
|
87
87
|
try {
|
|
88
|
-
await
|
|
89
|
-
} catch (
|
|
88
|
+
await n(...e);
|
|
89
|
+
} catch (i) {
|
|
90
90
|
this.listeners.error?.forEach(
|
|
91
|
-
(
|
|
91
|
+
(a) => a(i)
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
|
-
const
|
|
97
|
-
console.log("
|
|
96
|
+
const m = () => new z();
|
|
97
|
+
console.log("content-engine-lib");
|
|
98
98
|
let _ = {
|
|
99
99
|
lib: {
|
|
100
100
|
inbuilt_lib: [],
|
|
101
101
|
// <any>[], // [`text`,`table`,`editor`]
|
|
102
102
|
l: {},
|
|
103
103
|
set: async (t) => {
|
|
104
|
-
const
|
|
105
|
-
for (const [
|
|
106
|
-
const
|
|
107
|
-
let
|
|
108
|
-
const
|
|
109
|
-
let
|
|
110
|
-
if (
|
|
111
|
-
if (/^[a-zA-Z0-9]/.test(
|
|
112
|
-
if (
|
|
113
|
-
|
|
104
|
+
const r = t?.lib || [];
|
|
105
|
+
for (const [e, n] of r.entries()) {
|
|
106
|
+
const i = n, a = `${i.name}:${t.run_from}`, c = `${t.run_from}_src`;
|
|
107
|
+
let l = i[c];
|
|
108
|
+
const y = `${t.run_from}_src`;
|
|
109
|
+
let s = t?.lazy_lib?.[y] || null;
|
|
110
|
+
if (s && (s = s.replace("{*}", `${i.name}`)), console.log(`_lazy_src: ${s}`), console.log(`_src: ${l}`), _.lib.l.hasOwnProperty(`${a}`) == !1) {
|
|
111
|
+
if (/^[a-zA-Z0-9]/.test(l) && l.includes("/") == !1 && _.lib.inbuilt_lib.indexOf(`${i.name}`) === -1)
|
|
112
|
+
if (s)
|
|
113
|
+
l = s;
|
|
114
114
|
else
|
|
115
|
-
throw `[lib-name=${
|
|
116
|
-
if (
|
|
117
|
-
const
|
|
115
|
+
throw `[lib-name=${i.name},lib-src=${l}] not allowed or available in in-build mode. Need to use lazy-lib config.`;
|
|
116
|
+
if (l.startsWith("./") || l.startsWith("../")) {
|
|
117
|
+
const d = await import(
|
|
118
118
|
/* @vite-ignore */
|
|
119
119
|
/* webpackIgnore: true */
|
|
120
|
-
`${
|
|
120
|
+
`${l}`
|
|
121
121
|
);
|
|
122
|
-
_.lib.l[`${
|
|
123
|
-
lib:
|
|
124
|
-
src:
|
|
122
|
+
_.lib.l[`${a}`] = {
|
|
123
|
+
lib: d,
|
|
124
|
+
src: l
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
if (
|
|
128
|
-
const
|
|
127
|
+
if (l.startsWith("http://") || l.startsWith("https://")) {
|
|
128
|
+
const d = await import(
|
|
129
129
|
/* @vite-ignore */
|
|
130
130
|
/* webpackIgnore: true */
|
|
131
|
-
`${
|
|
131
|
+
`${l}`
|
|
132
132
|
);
|
|
133
|
-
_.lib.l[`${
|
|
134
|
-
lib:
|
|
135
|
-
src:
|
|
133
|
+
_.lib.l[`${a}`] = {
|
|
134
|
+
lib: d,
|
|
135
|
+
src: l
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
}
|
|
@@ -140,9 +140,9 @@ let _ = {
|
|
|
140
140
|
console.log(await _.lib.get_all({}));
|
|
141
141
|
},
|
|
142
142
|
get: async (t) => {
|
|
143
|
-
let
|
|
144
|
-
const
|
|
145
|
-
return _.lib.l.hasOwnProperty(`${
|
|
143
|
+
let r = null;
|
|
144
|
+
const e = `${t.name}:${t.run_from}`;
|
|
145
|
+
return _.lib.l.hasOwnProperty(`${e}`) == !1 && await _.lib.set({
|
|
146
146
|
lib: [
|
|
147
147
|
{
|
|
148
148
|
renderer_src: t.name,
|
|
@@ -153,34 +153,34 @@ let _ = {
|
|
|
153
153
|
],
|
|
154
154
|
run_from: t.run_from,
|
|
155
155
|
lazy_lib: t.lazy_lib
|
|
156
|
-
}),
|
|
156
|
+
}), r = _.lib.l[`${e}`], r;
|
|
157
157
|
},
|
|
158
158
|
get_all: async (t) => _.lib.l
|
|
159
159
|
},
|
|
160
160
|
path: {
|
|
161
161
|
set: (t) => {
|
|
162
|
-
let
|
|
163
|
-
const
|
|
164
|
-
if (t.src.indexOf("://localhost") !== -1 || t.src.indexOf("://127.0.0.1") !== -1 || (
|
|
165
|
-
for (const [
|
|
166
|
-
let
|
|
167
|
-
if (
|
|
168
|
-
return `${
|
|
162
|
+
let r = "", e = "";
|
|
163
|
+
const n = t.src.split("/");
|
|
164
|
+
if (t.src.indexOf("://localhost") !== -1 || t.src.indexOf("://127.0.0.1") !== -1 || (e = "/dist"), n.indexOf(t.type) !== -1)
|
|
165
|
+
for (const [i, a] of n.entries()) {
|
|
166
|
+
let c = i == 0 ? "" : "/";
|
|
167
|
+
if (r += `${c}${a}`, a == t.type)
|
|
168
|
+
return `${r}${e}${t.name}`;
|
|
169
169
|
}
|
|
170
170
|
else
|
|
171
|
-
for (const [
|
|
172
|
-
let
|
|
173
|
-
if (
|
|
174
|
-
return `${
|
|
171
|
+
for (const [i, a] of n.entries()) {
|
|
172
|
+
let c = i == 0 ? "" : "/";
|
|
173
|
+
if (r += `${c}${a}`, a == "src")
|
|
174
|
+
return `${r}${e}${t.name}`;
|
|
175
175
|
}
|
|
176
|
-
return `${
|
|
176
|
+
return `${r}${e}${t.name}`;
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
|
-
const x =
|
|
181
|
-
const
|
|
180
|
+
const x = m(), $ = m(), k = x.on, W = x.emit, E = $.emit, C = $.on, O = async (t) => {
|
|
181
|
+
const r = await u();
|
|
182
182
|
return await _.lib.set({ lib: t.lib, run_from: "renderer", lazy_lib: t.lazy_lib }), {
|
|
183
|
-
set: async (
|
|
183
|
+
set: async (e) => {
|
|
184
184
|
console.log("--renderer [set]");
|
|
185
185
|
let n = {
|
|
186
186
|
r: "",
|
|
@@ -189,80 +189,89 @@ const x = b(), $ = b(), k = x.on, W = x.emit, E = $.emit, C = $.on, O = async (t
|
|
|
189
189
|
// `<test>head-1</test>`
|
|
190
190
|
};
|
|
191
191
|
return await (async () => {
|
|
192
|
-
for (const
|
|
193
|
-
const
|
|
192
|
+
for (const a of e.data?.value?.l || e.data.l) {
|
|
193
|
+
const c = await await _.lib.get({ name: a.type, run_from: "renderer", lazy_lib: t.lazy_lib }), y = await (await c.lib.index({
|
|
194
194
|
f: {
|
|
195
|
-
name: (
|
|
196
|
-
get_lib: async (
|
|
197
|
-
set_theme: async (
|
|
198
|
-
path: (
|
|
195
|
+
name: (s) => r.f.name({ id: a.id, name: s }),
|
|
196
|
+
get_lib: async (s) => await await _.lib.get({ name: s.name, run_from: s.run_from, lazy_lib: t.lazy_lib }),
|
|
197
|
+
set_theme: async (s) => await (await w()).set(s),
|
|
198
|
+
path: (s) => _.path.set({ src: c.src, type: a.type, name: s })
|
|
199
199
|
}
|
|
200
|
-
})).set(
|
|
201
|
-
|
|
202
|
-
|
|
200
|
+
})).set(
|
|
201
|
+
{
|
|
202
|
+
data: {
|
|
203
|
+
curr: a
|
|
204
|
+
}
|
|
203
205
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
/*_$cb*/
|
|
207
|
+
);
|
|
208
|
+
n.r += y?.r || "", n.style += y?.style || "", n.head += y?.head || "";
|
|
206
209
|
}
|
|
207
210
|
})(), n;
|
|
208
211
|
}
|
|
209
212
|
};
|
|
210
213
|
}, I = async (t) => {
|
|
211
|
-
const
|
|
214
|
+
const r = await u();
|
|
212
215
|
return await _.lib.set({ lib: t.lib, run_from: "hydrator", lazy_lib: t.lazy_lib }), {
|
|
213
|
-
set: async (
|
|
216
|
+
set: async (e) => {
|
|
214
217
|
console.log("--hydrator [set]");
|
|
215
218
|
let n = {
|
|
216
219
|
r: "",
|
|
217
220
|
style: ""
|
|
218
221
|
};
|
|
219
|
-
const
|
|
220
|
-
for (const
|
|
221
|
-
const
|
|
222
|
+
const i = async () => {
|
|
223
|
+
for (const a of e.data?.value?.l || e.data.l) {
|
|
224
|
+
const c = await await _.lib.get({ name: a.type, run_from: "hydrator", lazy_lib: t.lazy_lib }), l = c.lib, y = m(), s = y.on, d = await (await l.index({
|
|
225
|
+
/**@my module can use it to set custom variables. */
|
|
226
|
+
my: {},
|
|
227
|
+
//NOTE: We cannot add or use any variable of this object, It's reserved for module.
|
|
222
228
|
f: {
|
|
223
|
-
name: (
|
|
224
|
-
get_lib: async (
|
|
225
|
-
set_theme: async (
|
|
226
|
-
path: (
|
|
229
|
+
name: (o) => r.f.name({ id: a.id, name: o }),
|
|
230
|
+
get_lib: async (o) => await await _.lib.get({ name: o.name, run_from: o.run_from, lazy_lib: t.lazy_lib }),
|
|
231
|
+
set_theme: async (o) => await (await w()).set(o),
|
|
232
|
+
path: (o) => _.path.set({ src: c.src, type: a.type, name: o }),
|
|
227
233
|
//set..
|
|
228
234
|
call: E,
|
|
229
|
-
listen:
|
|
235
|
+
listen: s,
|
|
230
236
|
//set..
|
|
231
|
-
|
|
237
|
+
new_emitter: () => m()
|
|
232
238
|
}
|
|
233
|
-
})).set(
|
|
234
|
-
|
|
235
|
-
|
|
239
|
+
})).set(
|
|
240
|
+
{
|
|
241
|
+
data: {
|
|
242
|
+
curr: a
|
|
243
|
+
}
|
|
236
244
|
}
|
|
237
|
-
|
|
238
|
-
|
|
245
|
+
/*_$cb*/
|
|
246
|
+
);
|
|
247
|
+
k("msg", async (o) => {
|
|
239
248
|
try {
|
|
240
|
-
if (Object.keys(
|
|
241
|
-
await
|
|
249
|
+
if (Object.keys(o.where || {}).length == 0) {
|
|
250
|
+
await y.emit("msg", o);
|
|
242
251
|
return;
|
|
243
252
|
}
|
|
244
253
|
} catch {
|
|
245
254
|
}
|
|
246
255
|
try {
|
|
247
|
-
if (
|
|
248
|
-
await
|
|
256
|
+
if (a?.[o.where?.key || ""] == o.where?.value) {
|
|
257
|
+
await y.emit("msg", o);
|
|
249
258
|
return;
|
|
250
259
|
}
|
|
251
260
|
} catch {
|
|
252
261
|
}
|
|
253
|
-
}), n.style +=
|
|
262
|
+
}), n.style += d.style;
|
|
254
263
|
}
|
|
255
264
|
};
|
|
256
265
|
return await p(
|
|
257
266
|
() => document.readyState === "complete" || typeof window < "u",
|
|
258
267
|
50
|
|
259
|
-
), await
|
|
268
|
+
), await i(), n;
|
|
260
269
|
}
|
|
261
270
|
};
|
|
262
|
-
}, S = async (t) => (await
|
|
263
|
-
set: async (
|
|
271
|
+
}, S = async (t) => (await u(), await _.lib.set({ lib: t.lib, run_from: "editor", lazy_lib: t.lazy_lib }), {
|
|
272
|
+
set: async (r) => {
|
|
264
273
|
console.log("--editor [set]");
|
|
265
|
-
let
|
|
274
|
+
let e = {
|
|
266
275
|
data: {
|
|
267
276
|
l: [
|
|
268
277
|
{
|
|
@@ -278,29 +287,35 @@ const x = b(), $ = b(), k = x.on, W = x.emit, E = $.emit, C = $.on, O = async (t
|
|
|
278
287
|
r: "",
|
|
279
288
|
style: ""
|
|
280
289
|
};
|
|
281
|
-
const
|
|
290
|
+
const i = O, a = I, c = await i({
|
|
282
291
|
lib: t.lib,
|
|
283
292
|
lazy_lib: t.lazy_lib
|
|
284
|
-
}),
|
|
293
|
+
}), l = await a({
|
|
285
294
|
lib: t.lib,
|
|
286
295
|
lazy_lib: t.lazy_lib
|
|
287
|
-
}),
|
|
288
|
-
data:
|
|
296
|
+
}), y = await c.set({
|
|
297
|
+
data: e.data
|
|
289
298
|
});
|
|
290
299
|
return (async () => {
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
change: (m) => {
|
|
295
|
-
r?.change(m);
|
|
300
|
+
const s = await l.set(
|
|
301
|
+
{
|
|
302
|
+
data: e.data
|
|
296
303
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
304
|
+
/*{
|
|
305
|
+
change: (_v:any) => {
|
|
306
|
+
//console.log(`--ce:editor [change]`);
|
|
307
|
+
//console.log(_v);
|
|
308
|
+
//send-cb..
|
|
309
|
+
_$cb?.change(_v);
|
|
310
|
+
}
|
|
311
|
+
}*/
|
|
312
|
+
);
|
|
313
|
+
((d) => {
|
|
314
|
+
const o = document.createElement("style");
|
|
315
|
+
o.innerHTML = `${s.style}`, d.appendChild(o);
|
|
301
316
|
})(document.head);
|
|
302
|
-
})(), n.r =
|
|
303
|
-
${
|
|
317
|
+
})(), n.r = y.r, n.style = `
|
|
318
|
+
${y.style}
|
|
304
319
|
`, n;
|
|
305
320
|
}
|
|
306
321
|
});
|
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
${
|
|
3
|
-
`,r}});
|
|
1
|
+
(function(f,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(f=typeof globalThis<"u"?globalThis:f||self,u(f["content-engine-lib"]={}))})(this,(function(f){"use strict";const u=()=>({set:()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const n=Math.random()*16|0;return(e=="x"?n:n&3|8).toString(16)})}),b=async()=>({f:{name:e=>`${e.name}${e.id}`}}),w=async()=>({set:async e=>{console.log("--theme");try{if(!e.el_id)throw new Error("[el_id] is required");const n=e.name,t=document.getElementById(e.el_id);if(!t)throw new Error("[el_id] is invalid");(r=>{const s=a=>{(_=>{const l=_.getAttribute("data-ce");if(!l)return;const i=JSON.parse(l).filter(y=>y?.k.startsWith("t-"));if(i.length!=0)for(const y of i){const o=y.k,k=y.v.split(" ");if(o==`t-${n}-class`)for(const h of k)_.classList.add(h);else for(const h of k)_.classList.remove(h)}})(a)};for(const a of r.getElementsByTagName("*"))s(a);s(r)})(t)}catch(n){const t=`err: [theme] ${n}`;throw console.log(t),t}}});function O(e,n=1e3){let t={cnt:0};return new Promise(r=>{const s=()=>{console.log(`[setInterval] is running.. [count=${t.cnt}]`);try{e()&&(clearInterval(a),r())}catch{console.log(`warn: [wait_until] ignoring the exception in setInterval and will check again after [interval=${n}]`)}t.cnt+=1},a=setInterval(()=>{s()},n);s()})}let E=class{listeners={};on=(n,t)=>((this.listeners[n]||=[]).push(t),()=>this.off(n,t));off=(n,t)=>{this.listeners[n]=this.listeners[n]?.filter(r=>r!==t)};emit=async(n,...t)=>{for(const r of this.listeners[n]??[])await r(...t)};emitParallel=async(n,...t)=>{await Promise.all((this.listeners[n]??[]).map(r=>r(...t)))};emitSafe=async(n,...t)=>{for(const r of this.listeners[n]??[])try{await r(...t)}catch(s){this.listeners.error?.forEach(a=>a(s))}}};const m=()=>new E;console.log("content-engine-lib");let c={lib:{inbuilt_lib:[],l:{},set:async e=>{const n=e?.lib||[];for(const[t,r]of n.entries()){const s=r,a=`${s.name}:${e.run_from}`,_=`${e.run_from}_src`;let l=s[_];const d=`${e.run_from}_src`;let i=e?.lazy_lib?.[d]||null;if(i&&(i=i.replace("{*}",`${s.name}`)),console.log(`_lazy_src: ${i}`),console.log(`_src: ${l}`),c.lib.l.hasOwnProperty(`${a}`)==!1){if(/^[a-zA-Z0-9]/.test(l)&&l.includes("/")==!1&&c.lib.inbuilt_lib.indexOf(`${s.name}`)===-1)if(i)l=i;else throw`[lib-name=${s.name},lib-src=${l}] not allowed or available in in-build mode. Need to use lazy-lib config.`;if(l.startsWith("./")||l.startsWith("../")){const y=await import(`${l}`);c.lib.l[`${a}`]={lib:y,src:l}}if(l.startsWith("http://")||l.startsWith("https://")){const y=await import(`${l}`);c.lib.l[`${a}`]={lib:y,src:l}}}}console.log(await c.lib.get_all({}))},get:async e=>{let n=null;const t=`${e.name}:${e.run_from}`;return c.lib.l.hasOwnProperty(`${t}`)==!1&&await c.lib.set({lib:[{renderer_src:e.name,hydrator_src:e.name,editor_src:e.name,name:e.name}],run_from:e.run_from,lazy_lib:e.lazy_lib}),n=c.lib.l[`${t}`],n},get_all:async e=>c.lib.l},path:{set:e=>{let n="",t="";const r=e.src.split("/");if(e.src.indexOf("://localhost")!==-1||e.src.indexOf("://127.0.0.1")!==-1||(t="/dist"),r.indexOf(e.type)!==-1)for(const[s,a]of r.entries()){let _=s==0?"":"/";if(n+=`${_}${a}`,a==e.type)return`${n}${t}${e.name}`}else for(const[s,a]of r.entries()){let _=s==0?"":"/";if(n+=`${_}${a}`,a=="src")return`${n}${t}${e.name}`}return`${n}${t}${e.name}`}}};const x=m(),g=m(),P=x.on,S=x.emit,T=g.emit,I=g.on,$=async e=>{const n=await b();return await c.lib.set({lib:e.lib,run_from:"renderer",lazy_lib:e.lazy_lib}),{set:async t=>{console.log("--renderer [set]");let r={r:"",style:"",head:""};return await(async()=>{for(const a of t.data?.value?.l||t.data.l){const _=await await c.lib.get({name:a.type,run_from:"renderer",lazy_lib:e.lazy_lib}),d=await(await _.lib.index({f:{name:i=>n.f.name({id:a.id,name:i}),get_lib:async i=>await await c.lib.get({name:i.name,run_from:i.run_from,lazy_lib:e.lazy_lib}),set_theme:async i=>await(await w()).set(i),path:i=>c.path.set({src:_.src,type:a.type,name:i})}})).set({data:{curr:a}});r.r+=d?.r||"",r.style+=d?.style||"",r.head+=d?.head||""}})(),r}}},p=async e=>{const n=await b();return await c.lib.set({lib:e.lib,run_from:"hydrator",lazy_lib:e.lazy_lib}),{set:async t=>{console.log("--hydrator [set]");let r={r:"",style:""};const s=async()=>{for(const a of t.data?.value?.l||t.data.l){const _=await await c.lib.get({name:a.type,run_from:"hydrator",lazy_lib:e.lazy_lib}),l=_.lib,d=m(),i=d.on,y=await(await l.index({my:{},f:{name:o=>n.f.name({id:a.id,name:o}),get_lib:async o=>await await c.lib.get({name:o.name,run_from:o.run_from,lazy_lib:e.lazy_lib}),set_theme:async o=>await(await w()).set(o),path:o=>c.path.set({src:_.src,type:a.type,name:o}),call:T,listen:i,new_emitter:()=>m()}})).set({data:{curr:a}});P("msg",async o=>{try{if(Object.keys(o.where||{}).length==0){await d.emit("msg",o);return}}catch{}try{if(a?.[o.where?.key||""]==o.where?.value){await d.emit("msg",o);return}}catch{}}),r.style+=y.style}};return await O(()=>document.readyState==="complete"||typeof window<"u",50),await s(),r}}},W=async e=>(await b(),await c.lib.set({lib:e.lib,run_from:"editor",lazy_lib:e.lazy_lib}),{set:async n=>{console.log("--editor [set]");let t={data:{l:[{id:u().set(),type:"editor",data:{l:[]}}]}},r={r:"",style:""};const s=$,a=p,_=await s({lib:e.lib,lazy_lib:e.lazy_lib}),l=await a({lib:e.lib,lazy_lib:e.lazy_lib}),d=await _.set({data:t.data});return(async()=>{const i=await l.set({data:t.data});(y=>{const o=document.createElement("style");o.innerHTML=`${i.style}`,y.appendChild(o)})(document.head)})(),r.r=d.r,r.style=`
|
|
2
|
+
${d.style}
|
|
3
|
+
`,r}});f.ce_call=S,f.ce_editor=W,f.ce_hydrator=p,f.ce_listen=I,f.ce_renderer=$,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Emitter } from '../emitter';
|
|
2
2
|
declare const index: () => Emitter<{
|
|
3
3
|
msg: (payload: {
|
|
4
|
-
/**eg=> `
|
|
4
|
+
/**eg=> `change`, `add` etc. */
|
|
5
5
|
type: string;
|
|
6
6
|
/**can pass existing `_p` variable. */
|
|
7
7
|
_p?: any;
|
|
@@ -16,6 +16,10 @@ declare const index: () => Emitter<{
|
|
|
16
16
|
/**eg=> xx776-6564-6547 (Module-Id), text (Module-Type) */
|
|
17
17
|
value: string;
|
|
18
18
|
};
|
|
19
|
+
/**can be used to pass eg=> `_$p[`data`].curr[`data`],`, `_$p[`data`].curr` */
|
|
20
|
+
$d?: any;
|
|
21
|
+
/**can be used to pass eg=> `HTMLElement` */
|
|
22
|
+
el?: any;
|
|
19
23
|
}) => Promise<void>;
|
|
20
24
|
}>;
|
|
21
|
-
export { index as
|
|
25
|
+
export { index as new_emitter };
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare const index: (_p: {
|
|
2
|
-
f: {
|
|
3
|
-
name: (v: string) => string;
|
|
4
|
-
};
|
|
5
|
-
}) => Promise<{
|
|
6
|
-
set: (_$p: {
|
|
7
|
-
data: {
|
|
8
|
-
curr: {
|
|
9
|
-
"id": "";
|
|
10
|
-
"type": "editor";
|
|
11
|
-
"data": string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
}) => Promise<{
|
|
15
|
-
r: string;
|
|
16
|
-
style: string;
|
|
17
|
-
}>;
|
|
18
|
-
}>;
|
|
19
|
-
export { index };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare const index: (_p: {
|
|
2
|
-
f: {
|
|
3
|
-
name: (v: string) => string;
|
|
4
|
-
};
|
|
5
|
-
}) => Promise<{
|
|
6
|
-
set: (_$p: {
|
|
7
|
-
data: {
|
|
8
|
-
curr: {
|
|
9
|
-
"id": "";
|
|
10
|
-
"type": "editor";
|
|
11
|
-
"data": string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
}) => Promise<{
|
|
15
|
-
r: string;
|
|
16
|
-
style: string;
|
|
17
|
-
}>;
|
|
18
|
-
}>;
|
|
19
|
-
export { index };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
type _p_TYP = {
|
|
2
|
-
f: {
|
|
3
|
-
name: (v: string) => string;
|
|
4
|
-
get_lib: (v: {
|
|
5
|
-
name: string;
|
|
6
|
-
run_from: any;
|
|
7
|
-
}) => any;
|
|
8
|
-
set_theme: (v: {
|
|
9
|
-
name: string;
|
|
10
|
-
el_id: string;
|
|
11
|
-
}) => any;
|
|
12
|
-
path: (v: string) => string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
type _$p_TYP = {
|
|
16
|
-
data: {
|
|
17
|
-
curr: {
|
|
18
|
-
"id": "";
|
|
19
|
-
"type": "editor";
|
|
20
|
-
"data": {
|
|
21
|
-
"l": any[];
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
type _$cb_TYP = {
|
|
27
|
-
change: (_v: {
|
|
28
|
-
_$p: _$p_TYP;
|
|
29
|
-
}) => any;
|
|
30
|
-
add: (_v: {
|
|
31
|
-
$d: _$p_TYP[`data`][`curr`][`data`];
|
|
32
|
-
el: HTMLElement;
|
|
33
|
-
}) => any;
|
|
34
|
-
};
|
|
35
|
-
export type { _p_TYP, _$p_TYP, _$cb_TYP };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { _$cb_TYP, _$p_TYP, _p_TYP } from '../shared/types';
|
|
2
|
-
declare const index: (_p: _p_TYP) => Promise<{
|
|
3
|
-
set: (_$p: _$p_TYP, _$cb: _$cb_TYP) => Promise<{
|
|
4
|
-
r: string;
|
|
5
|
-
style: string;
|
|
6
|
-
evt: {
|
|
7
|
-
change: () => void;
|
|
8
|
-
};
|
|
9
|
-
}>;
|
|
10
|
-
}>;
|
|
11
|
-
export { index, index as hydrator };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
type _p_TYP = {
|
|
2
|
-
f: {
|
|
3
|
-
name: (v: string) => string;
|
|
4
|
-
get_lib: (v: {
|
|
5
|
-
name: string;
|
|
6
|
-
run_from: any;
|
|
7
|
-
}) => any;
|
|
8
|
-
set_theme: (v: {
|
|
9
|
-
name: string;
|
|
10
|
-
el_id: string;
|
|
11
|
-
}) => any;
|
|
12
|
-
path: (v: string) => string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
type _$p_TYP = {
|
|
16
|
-
data: {
|
|
17
|
-
curr: {
|
|
18
|
-
"id": "";
|
|
19
|
-
"type": "table";
|
|
20
|
-
"data": {
|
|
21
|
-
sortBy: string;
|
|
22
|
-
sortDirection: string;
|
|
23
|
-
columns: {
|
|
24
|
-
key: string;
|
|
25
|
-
title: string;
|
|
26
|
-
type: 'number' | 'string';
|
|
27
|
-
sortable: boolean;
|
|
28
|
-
}[];
|
|
29
|
-
rows: {
|
|
30
|
-
id: string;
|
|
31
|
-
}[];
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
type _$cb_TYP = {
|
|
37
|
-
change: (_v: {
|
|
38
|
-
_$p: _$p_TYP;
|
|
39
|
-
}) => any;
|
|
40
|
-
add: (_v: {
|
|
41
|
-
$d: _$p_TYP[`data`][`curr`][`data`][`columns`][`0`] | _$p_TYP[`data`][`curr`][`data`][`rows`][`0`] | any;
|
|
42
|
-
el: HTMLElement;
|
|
43
|
-
}) => any;
|
|
44
|
-
};
|
|
45
|
-
export type { _p_TYP, _$p_TYP, _$cb_TYP };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { _p_TYP, _$cb_TYP, _$p_TYP } from '../shared/types';
|
|
2
|
-
declare const index: (_p: _p_TYP) => Promise<{
|
|
3
|
-
set: (_$p: _$p_TYP, _$cb?: _$cb_TYP) => Promise<{
|
|
4
|
-
r: string;
|
|
5
|
-
style: string;
|
|
6
|
-
evt: {
|
|
7
|
-
change: () => void;
|
|
8
|
-
};
|
|
9
|
-
}>;
|
|
10
|
-
}>;
|
|
11
|
-
export { index, index as hydrator };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
type _p_TYP = {
|
|
2
|
-
f: {
|
|
3
|
-
name: (v: string) => string;
|
|
4
|
-
get_lib: (v: {
|
|
5
|
-
name: string;
|
|
6
|
-
run_from: any;
|
|
7
|
-
}) => any;
|
|
8
|
-
set_theme: (v: {
|
|
9
|
-
name: string;
|
|
10
|
-
el_id: string;
|
|
11
|
-
}) => any;
|
|
12
|
-
path: (v: string) => string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
type _$p_TYP = {
|
|
16
|
-
data: {
|
|
17
|
-
curr: {
|
|
18
|
-
"id": "";
|
|
19
|
-
"type": "text";
|
|
20
|
-
"data": {
|
|
21
|
-
"data": string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
type _$cb_TYP = {
|
|
27
|
-
change: (_v: {
|
|
28
|
-
_$p: _$p_TYP;
|
|
29
|
-
}) => any;
|
|
30
|
-
add: (_v: {
|
|
31
|
-
$d: _$p_TYP[`data`][`curr`][`data`];
|
|
32
|
-
el: HTMLElement;
|
|
33
|
-
}) => any;
|
|
34
|
-
};
|
|
35
|
-
export type { _p_TYP, _$p_TYP, _$cb_TYP };
|