content-engine-lib 1.0.2 → 1.0.4
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.es.js
CHANGED
|
@@ -25,13 +25,13 @@ const g = () => ({
|
|
|
25
25
|
const c = JSON.parse(s).filter((l) => l?.k.startsWith("t-"));
|
|
26
26
|
if (c.length != 0)
|
|
27
27
|
for (const l of c) {
|
|
28
|
-
const m = l.k,
|
|
28
|
+
const m = l.k, f = l.v.split(" ");
|
|
29
29
|
if (m == `t-${e}-class`)
|
|
30
|
-
for (const
|
|
31
|
-
i.classList.add(
|
|
30
|
+
for (const b of f)
|
|
31
|
+
i.classList.add(b);
|
|
32
32
|
else
|
|
33
|
-
for (const
|
|
34
|
-
i.classList.remove(
|
|
33
|
+
for (const b of f)
|
|
34
|
+
i.classList.remove(b);
|
|
35
35
|
}
|
|
36
36
|
})(o);
|
|
37
37
|
};
|
|
@@ -93,9 +93,9 @@ let z = class {
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
|
-
const
|
|
96
|
+
const u = () => new z();
|
|
97
97
|
console.log("content_engine_lib");
|
|
98
|
-
let
|
|
98
|
+
let y = {
|
|
99
99
|
lib: {
|
|
100
100
|
inbuilt_lib: [],
|
|
101
101
|
// <any>[], // [`text`,`table`,`editor`]
|
|
@@ -107,8 +107,8 @@ let _ = {
|
|
|
107
107
|
let s = n[i];
|
|
108
108
|
const d = `${t.run_from}_src`;
|
|
109
109
|
let c = t?.lazy_lib?.[d] || null;
|
|
110
|
-
if (c && (c = c.replace("{*}", `${n.name}`)), console.log(`_lazy_src: ${c}`), console.log(`_src: ${s}`),
|
|
111
|
-
if (/^[a-zA-Z0-9]/.test(s) && s.includes("/") == !1 &&
|
|
110
|
+
if (c && (c = c.replace("{*}", `${n.name}`)), console.log(`_lazy_src: ${c}`), console.log(`_src: ${s}`), y.lib.l.hasOwnProperty(`${o}`) == !1) {
|
|
111
|
+
if (/^[a-zA-Z0-9]/.test(s) && s.includes("/") == !1 && y.lib.inbuilt_lib.indexOf(`${n.name}`) === -1)
|
|
112
112
|
if (c)
|
|
113
113
|
s = c;
|
|
114
114
|
else
|
|
@@ -119,7 +119,7 @@ let _ = {
|
|
|
119
119
|
/* webpackIgnore: true */
|
|
120
120
|
`${s}`
|
|
121
121
|
);
|
|
122
|
-
|
|
122
|
+
y.lib.l[`${o}`] = {
|
|
123
123
|
lib: l,
|
|
124
124
|
src: s
|
|
125
125
|
};
|
|
@@ -130,19 +130,19 @@ let _ = {
|
|
|
130
130
|
/* webpackIgnore: true */
|
|
131
131
|
`${s}`
|
|
132
132
|
);
|
|
133
|
-
|
|
133
|
+
y.lib.l[`${o}`] = {
|
|
134
134
|
lib: l,
|
|
135
135
|
src: s
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
console.log(await
|
|
140
|
+
console.log(await y.lib.get_all({}));
|
|
141
141
|
},
|
|
142
142
|
get: async (t) => {
|
|
143
143
|
let e = null;
|
|
144
144
|
const r = `${t.name}:${t.run_from}`;
|
|
145
|
-
return
|
|
145
|
+
return y.lib.l.hasOwnProperty(`${r}`) == !1 && await y.lib.set({
|
|
146
146
|
lib: [
|
|
147
147
|
{
|
|
148
148
|
renderer_src: t.name,
|
|
@@ -153,9 +153,9 @@ let _ = {
|
|
|
153
153
|
],
|
|
154
154
|
run_from: t.run_from,
|
|
155
155
|
lazy_lib: t.lazy_lib
|
|
156
|
-
}), e =
|
|
156
|
+
}), e = y.lib.l[`${r}`], e;
|
|
157
157
|
},
|
|
158
|
-
get_all: async (t) =>
|
|
158
|
+
get_all: async (t) => y.lib.l
|
|
159
159
|
},
|
|
160
160
|
path: {
|
|
161
161
|
set: (t) => {
|
|
@@ -177,9 +177,9 @@ let _ = {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
|
-
const x =
|
|
180
|
+
const x = u(), $ = u(), k = x.on, W = x.emit, E = $.emit, C = $.on, O = async (t) => {
|
|
181
181
|
const e = await h();
|
|
182
|
-
return await
|
|
182
|
+
return await y.lib.set({ lib: t.lib, run_from: "renderer", lazy_lib: t.lazy_lib }), {
|
|
183
183
|
set: async (r, a) => {
|
|
184
184
|
console.log("--renderer [set]");
|
|
185
185
|
let n = {
|
|
@@ -190,12 +190,12 @@ const x = b(), $ = b(), k = x.on, W = x.emit, E = $.emit, C = $.on, O = async (t
|
|
|
190
190
|
};
|
|
191
191
|
return await (async () => {
|
|
192
192
|
for (const i of r.data?.value?.l || r.data.l) {
|
|
193
|
-
const s = await await
|
|
193
|
+
const s = await await y.lib.get({ name: i.type, run_from: "renderer", lazy_lib: t.lazy_lib }), c = await (await s.lib.index({
|
|
194
194
|
f: {
|
|
195
195
|
name: (l) => e.f.name({ id: i.id, name: l }),
|
|
196
|
-
get_lib: async (l) => await await
|
|
196
|
+
get_lib: async (l) => await await y.lib.get({ name: l.name, run_from: l.run_from, lazy_lib: t.lazy_lib }),
|
|
197
197
|
set_theme: async (l) => await (await w()).set(l),
|
|
198
|
-
path: (l) =>
|
|
198
|
+
path: (l) => y.path.set({ src: s.src, type: i.type, name: l })
|
|
199
199
|
}
|
|
200
200
|
})).set({
|
|
201
201
|
data: {
|
|
@@ -209,7 +209,7 @@ const x = b(), $ = b(), k = x.on, W = x.emit, E = $.emit, C = $.on, O = async (t
|
|
|
209
209
|
};
|
|
210
210
|
}, I = async (t) => {
|
|
211
211
|
const e = await h();
|
|
212
|
-
return await
|
|
212
|
+
return await y.lib.set({ lib: t.lib, run_from: "hydrator", lazy_lib: t.lazy_lib }), {
|
|
213
213
|
set: async (r, a) => {
|
|
214
214
|
console.log("--hydrator [set]");
|
|
215
215
|
let n = {
|
|
@@ -218,39 +218,42 @@ const x = b(), $ = b(), k = x.on, W = x.emit, E = $.emit, C = $.on, O = async (t
|
|
|
218
218
|
};
|
|
219
219
|
const o = async () => {
|
|
220
220
|
for (const i of r.data?.value?.l || r.data.l) {
|
|
221
|
-
const s = await await
|
|
221
|
+
const s = await await y.lib.get({ name: i.type, run_from: "hydrator", lazy_lib: t.lazy_lib }), d = s.lib, c = u(), l = c.on, m = await (await d.index({
|
|
222
|
+
/**@my module can use it to set custom variables. */
|
|
223
|
+
my: {},
|
|
224
|
+
//NOTE: We cannot add or use any variable of this object, It's reserved for module.
|
|
222
225
|
f: {
|
|
223
|
-
name: (
|
|
224
|
-
get_lib: async (
|
|
225
|
-
set_theme: async (
|
|
226
|
-
path: (
|
|
226
|
+
name: (_) => e.f.name({ id: i.id, name: _ }),
|
|
227
|
+
get_lib: async (_) => await await y.lib.get({ name: _.name, run_from: _.run_from, lazy_lib: t.lazy_lib }),
|
|
228
|
+
set_theme: async (_) => await (await w()).set(_),
|
|
229
|
+
path: (_) => y.path.set({ src: s.src, type: i.type, name: _ }),
|
|
227
230
|
//set..
|
|
228
231
|
call: E,
|
|
229
232
|
listen: l,
|
|
230
233
|
//set..
|
|
231
|
-
|
|
234
|
+
new_emitter: () => u()
|
|
232
235
|
}
|
|
233
236
|
})).set({
|
|
234
237
|
data: {
|
|
235
238
|
curr: i
|
|
236
239
|
}
|
|
237
240
|
}, a);
|
|
238
|
-
k("msg", async (
|
|
241
|
+
k("msg", async (_) => {
|
|
239
242
|
try {
|
|
240
|
-
if (Object.keys(
|
|
241
|
-
await c.emit("msg",
|
|
243
|
+
if (Object.keys(_.where || {}).length == 0) {
|
|
244
|
+
await c.emit("msg", _);
|
|
242
245
|
return;
|
|
243
246
|
}
|
|
244
247
|
} catch {
|
|
245
248
|
}
|
|
246
249
|
try {
|
|
247
|
-
if (i?.[
|
|
248
|
-
await c.emit("msg",
|
|
250
|
+
if (i?.[_.where?.key || ""] == _.where?.value) {
|
|
251
|
+
await c.emit("msg", _);
|
|
249
252
|
return;
|
|
250
253
|
}
|
|
251
254
|
} catch {
|
|
252
255
|
}
|
|
253
|
-
}), n.style +=
|
|
256
|
+
}), n.style += m.style;
|
|
254
257
|
}
|
|
255
258
|
};
|
|
256
259
|
return await p(
|
|
@@ -259,7 +262,7 @@ const x = b(), $ = b(), k = x.on, W = x.emit, E = $.emit, C = $.on, O = async (t
|
|
|
259
262
|
), await o(), n;
|
|
260
263
|
}
|
|
261
264
|
};
|
|
262
|
-
}, S = async (t) => (await h(), await
|
|
265
|
+
}, S = async (t) => (await h(), await y.lib.set({ lib: t.lib, run_from: "editor", lazy_lib: t.lazy_lib }), {
|
|
263
266
|
set: async (e, r) => {
|
|
264
267
|
console.log("--editor [set]");
|
|
265
268
|
let a = {
|
|
@@ -296,8 +299,8 @@ const x = b(), $ = b(), k = x.on, W = x.emit, E = $.emit, C = $.on, O = async (t
|
|
|
296
299
|
}
|
|
297
300
|
});
|
|
298
301
|
((m) => {
|
|
299
|
-
const
|
|
300
|
-
|
|
302
|
+
const _ = document.createElement("style");
|
|
303
|
+
_.innerHTML = `${l.style}`, m.appendChild(_);
|
|
301
304
|
})(document.head);
|
|
302
305
|
})(), n.r = c.r, n.style = `
|
|
303
306
|
${c.style}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(y,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(y=typeof globalThis<"u"?globalThis:y||self,m(y["content-engine-lib"]={}))})(this,(function(y){"use strict";const m=()=>({set:()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}),
|
|
1
|
+
(function(y,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(y=typeof globalThis<"u"?globalThis:y||self,m(y["content-engine-lib"]={}))})(this,(function(y){"use strict";const m=()=>({set:()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}),w=async()=>({f:{name:e=>`${e.name}${e.id}`}}),g=async()=>({set:async e=>{console.log("--theme");try{if(!e.el_id)throw new Error("[el_id] is required");const t=e.name,n=document.getElementById(e.el_id);if(!n)throw new Error("[el_id] is invalid");(a=>{const r=o=>{(s=>{const i=s.getAttribute("data-ce");if(!i)return;const c=JSON.parse(i).filter(l=>l?.k.startsWith("t-"));if(c.length!=0)for(const l of c){const u=l.k,h=l.v.split(" ");if(u==`t-${t}-class`)for(const x of h)s.classList.add(x);else for(const x of h)s.classList.remove(x)}})(o)};for(const o of a.getElementsByTagName("*"))r(o);r(a)})(n)}catch(t){const n=`err: [theme] ${t}`;throw console.log(n),n}}});function O(e,t=1e3){let n={cnt:0};return new Promise(a=>{const r=()=>{console.log(`[setInterval] is running.. [count=${n.cnt}]`);try{e()&&(clearInterval(o),a())}catch{console.log(`warn: [wait_until] ignoring the exception in setInterval and will check again after [interval=${t}]`)}n.cnt+=1},o=setInterval(()=>{r()},t);r()})}let E=class{listeners={};on=(t,n)=>((this.listeners[t]||=[]).push(n),()=>this.off(t,n));off=(t,n)=>{this.listeners[t]=this.listeners[t]?.filter(a=>a!==n)};emit=async(t,...n)=>{for(const a of this.listeners[t]??[])await a(...n)};emitParallel=async(t,...n)=>{await Promise.all((this.listeners[t]??[]).map(a=>a(...n)))};emitSafe=async(t,...n)=>{for(const a of this.listeners[t]??[])try{await a(...n)}catch(r){this.listeners.error?.forEach(o=>o(r))}}};const b=()=>new E;console.log("content_engine_lib");let _={lib:{inbuilt_lib:[],l:{},set:async e=>{const t=e?.lib||[];for(const[n,a]of t.entries()){const r=a,o=`${r.name}:${e.run_from}`,s=`${e.run_from}_src`;let i=r[s];const f=`${e.run_from}_src`;let c=e?.lazy_lib?.[f]||null;if(c&&(c=c.replace("{*}",`${r.name}`)),console.log(`_lazy_src: ${c}`),console.log(`_src: ${i}`),_.lib.l.hasOwnProperty(`${o}`)==!1){if(/^[a-zA-Z0-9]/.test(i)&&i.includes("/")==!1&&_.lib.inbuilt_lib.indexOf(`${r.name}`)===-1)if(c)i=c;else throw`[lib-name=${r.name},lib-src=${i}] not allowed or available in in-build mode. Need to use lazy-lib config.`;if(i.startsWith("./")||i.startsWith("../")){const l=await import(`${i}`);_.lib.l[`${o}`]={lib:l,src:i}}if(i.startsWith("http://")||i.startsWith("https://")){const l=await import(`${i}`);_.lib.l[`${o}`]={lib:l,src:i}}}}console.log(await _.lib.get_all({}))},get:async e=>{let t=null;const n=`${e.name}:${e.run_from}`;return _.lib.l.hasOwnProperty(`${n}`)==!1&&await _.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}),t=_.lib.l[`${n}`],t},get_all:async e=>_.lib.l},path:{set:e=>{let t="",n="";const a=e.src.split("/");if(e.src.indexOf("://localhost")!==-1||e.src.indexOf("://127.0.0.1")!==-1||(n="/dist"),a.indexOf(e.type)!==-1)for(const[r,o]of a.entries()){let s=r==0?"":"/";if(t+=`${s}${o}`,o==e.type)return`${t}${n}${e.name}`}else for(const[r,o]of a.entries()){let s=r==0?"":"/";if(t+=`${s}${o}`,o=="src")return`${t}${n}${e.name}`}return`${t}${n}${e.name}`}}};const $=b(),p=b(),P=$.on,S=$.emit,T=p.emit,I=p.on,z=async e=>{const t=await w();return await _.lib.set({lib:e.lib,run_from:"renderer",lazy_lib:e.lazy_lib}),{set:async(n,a)=>{console.log("--renderer [set]");let r={r:"",style:"",head:""};return await(async()=>{for(const s of n.data?.value?.l||n.data.l){const i=await await _.lib.get({name:s.type,run_from:"renderer",lazy_lib:e.lazy_lib}),c=await(await i.lib.index({f:{name:l=>t.f.name({id:s.id,name:l}),get_lib:async l=>await await _.lib.get({name:l.name,run_from:l.run_from,lazy_lib:e.lazy_lib}),set_theme:async l=>await(await g()).set(l),path:l=>_.path.set({src:i.src,type:s.type,name:l})}})).set({data:{curr:s}},a);r.r+=c?.r||"",r.style+=c?.style||"",r.head+=c?.head||""}})(),r}}},k=async e=>{const t=await w();return await _.lib.set({lib:e.lib,run_from:"hydrator",lazy_lib:e.lazy_lib}),{set:async(n,a)=>{console.log("--hydrator [set]");let r={r:"",style:""};const o=async()=>{for(const s of n.data?.value?.l||n.data.l){const i=await await _.lib.get({name:s.type,run_from:"hydrator",lazy_lib:e.lazy_lib}),f=i.lib,c=b(),l=c.on,u=await(await f.index({my:{},f:{name:d=>t.f.name({id:s.id,name:d}),get_lib:async d=>await await _.lib.get({name:d.name,run_from:d.run_from,lazy_lib:e.lazy_lib}),set_theme:async d=>await(await g()).set(d),path:d=>_.path.set({src:i.src,type:s.type,name:d}),call:T,listen:l,new_emitter:()=>b()}})).set({data:{curr:s}},a);P("msg",async d=>{try{if(Object.keys(d.where||{}).length==0){await c.emit("msg",d);return}}catch{}try{if(s?.[d.where?.key||""]==d.where?.value){await c.emit("msg",d);return}}catch{}}),r.style+=u.style}};return await O(()=>document.readyState==="complete"||typeof window<"u",50),await o(),r}}},W=async e=>(await w(),await _.lib.set({lib:e.lib,run_from:"editor",lazy_lib:e.lazy_lib}),{set:async(t,n)=>{console.log("--editor [set]");let a={data:{l:[{id:m().set(),type:"editor",data:{l:[]}}]}},r={r:"",style:""};const o=z,s=k,i=await o({lib:e.lib,lazy_lib:e.lazy_lib}),f=await s({lib:e.lib,lazy_lib:e.lazy_lib}),c=await i.set({data:a.data});return(async()=>{const l=await f.set({data:a.data},{change:u=>{n?.change(u)}});(u=>{const d=document.createElement("style");d.innerHTML=`${l.style}`,u.appendChild(d)})(document.head)})(),r.r=c.r,r.style=`
|
|
2
2
|
${c.style}
|
|
3
3
|
`,r}});y.ce_call=S,y.ce_editor=W,y.ce_hydrator=k,y.ce_listen=I,y.ce_renderer=z,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED