cradova 3.3.4 → 3.3.6
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/README.md +2 -2
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1098 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -511,9 +511,9 @@ Join Us on [telegram](https://t.me/UiedbookHQ).
|
|
|
511
511
|
|
|
512
512
|
If you contribute code to this project, you are implicitly allowing your code to be distributed under same license. You are also implicitly verifying that all code is your original work.
|
|
513
513
|
|
|
514
|
-
## Supporting
|
|
514
|
+
## Supporting Exabase development
|
|
515
515
|
|
|
516
|
-
Your Support is a good force for change anytime you do it, you can ensure Our projects, growth, Cradova,
|
|
516
|
+
Your Support is a good force for change anytime you do it, you can ensure Our projects, growth, Cradova, Exabase, JetPath etc, growth and improvement by making a re-occuring or fixed sponsorship
|
|
517
517
|
to [github sponsors](https://github.com/sponsors/FridayCandour):
|
|
518
518
|
or crypto using
|
|
519
519
|
etheruen: `0xD7DDD4312A4e514751A582AF725238C7E6dF206c`,
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*! *****************************************************************************
|
|
2
|
+
Copyright 2022 Friday Candour. All rights reserved.
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
4
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
5
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
8
|
+
and limitations under the License.
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
export * from "./primitives/classes";
|
|
11
|
+
export * from "./primitives/functions";
|
|
12
|
+
export * from "./primitives/dom-objects";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,1098 @@
|
|
|
1
|
+
// src/primitives/functions.ts
|
|
2
|
+
function Rhoda(l) {
|
|
3
|
+
const fg = new DocumentFragment;
|
|
4
|
+
for (let ch of l) {
|
|
5
|
+
if (Array.isArray(ch)) {
|
|
6
|
+
fg.appendChild(Rhoda(ch));
|
|
7
|
+
} else {
|
|
8
|
+
if (ch instanceof Ref) {
|
|
9
|
+
ch = ch.render(undefined);
|
|
10
|
+
}
|
|
11
|
+
if (typeof ch === "function") {
|
|
12
|
+
ch = ch();
|
|
13
|
+
if (typeof ch === "function") {
|
|
14
|
+
ch = ch();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (typeof ch === "string" || typeof ch === "number") {
|
|
18
|
+
fg.appendChild(document.createTextNode(ch));
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (ch instanceof HTMLElement || ch instanceof DocumentFragment) {
|
|
22
|
+
fg.appendChild(ch);
|
|
23
|
+
} else {
|
|
24
|
+
if (typeof ch !== "undefined") {
|
|
25
|
+
throw new Error(" \u2718 Cradova err: invalid child type: " + ch + " (" + typeof ch + ")");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return fg;
|
|
31
|
+
}
|
|
32
|
+
function $if(condition, ...elements) {
|
|
33
|
+
if (condition) {
|
|
34
|
+
return elements;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function $ifelse(condition, ifTrue, ifFalse) {
|
|
38
|
+
if (condition) {
|
|
39
|
+
return ifTrue;
|
|
40
|
+
}
|
|
41
|
+
return ifFalse;
|
|
42
|
+
}
|
|
43
|
+
function $case(value, ...elements) {
|
|
44
|
+
return (key) => {
|
|
45
|
+
if (key === value) {
|
|
46
|
+
return elements;
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function $switch(key, ...cases) {
|
|
52
|
+
if (cases.length) {
|
|
53
|
+
for (let i = 0;i < cases.length; i++) {
|
|
54
|
+
const case_N = cases[i];
|
|
55
|
+
const elements = case_N(key);
|
|
56
|
+
if (elements) {
|
|
57
|
+
return elements;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
function loop(datalist, component) {
|
|
64
|
+
if (typeof component !== "function") {
|
|
65
|
+
throw new Error(" \u2718 Cradova err : Invalid component type, must be a function that returns html ");
|
|
66
|
+
}
|
|
67
|
+
return Array.isArray(datalist) ? datalist.map(component) : undefined;
|
|
68
|
+
}
|
|
69
|
+
function useState(initialValue, ActiveRef) {
|
|
70
|
+
ActiveRef._state_index += 1;
|
|
71
|
+
const idx = ActiveRef._state_index;
|
|
72
|
+
if (!ActiveRef._state_track[idx]) {
|
|
73
|
+
ActiveRef._roll_state(initialValue, idx);
|
|
74
|
+
ActiveRef._state_track[idx] = true;
|
|
75
|
+
}
|
|
76
|
+
function setState(newState) {
|
|
77
|
+
ActiveRef._roll_state(newState, idx);
|
|
78
|
+
ActiveRef.updateState();
|
|
79
|
+
}
|
|
80
|
+
return [ActiveRef._roll_state(null, idx, true), setState];
|
|
81
|
+
}
|
|
82
|
+
function useEffect(effect, ActiveRef) {
|
|
83
|
+
ActiveRef._effect(effect);
|
|
84
|
+
}
|
|
85
|
+
function useRef() {
|
|
86
|
+
return new reference;
|
|
87
|
+
}
|
|
88
|
+
var makeElement = (element, ElementChildrenAndPropertyList) => {
|
|
89
|
+
let props = {}, text = null;
|
|
90
|
+
if (ElementChildrenAndPropertyList.length !== 0) {
|
|
91
|
+
for (let i = 0;i < ElementChildrenAndPropertyList.length; i++) {
|
|
92
|
+
let child = ElementChildrenAndPropertyList[i];
|
|
93
|
+
if (typeof child === "function") {
|
|
94
|
+
child = child();
|
|
95
|
+
}
|
|
96
|
+
if (child instanceof Ref) {
|
|
97
|
+
child = child.render();
|
|
98
|
+
}
|
|
99
|
+
if (child instanceof HTMLElement || child instanceof DocumentFragment) {
|
|
100
|
+
element.appendChild(child);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (Array.isArray(child)) {
|
|
104
|
+
element.appendChild(Rhoda(child));
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (typeof child === "string" || typeof child === "number") {
|
|
108
|
+
text = child;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (typeof child === "object") {
|
|
112
|
+
props = Object.assign(props, child);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
return element;
|
|
118
|
+
}
|
|
119
|
+
if (typeof props === "object" && element) {
|
|
120
|
+
for (const [prop, value] of Object.entries(props)) {
|
|
121
|
+
if (prop === "style" && typeof value === "object") {
|
|
122
|
+
Object.assign(element.style, value);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (prop.includes("data-")) {
|
|
126
|
+
element.setAttribute(prop, value);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (prop.includes("aria-")) {
|
|
130
|
+
element.setAttribute(prop, value);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (prop === "href" && typeof value === "string") {
|
|
134
|
+
const href = value || "";
|
|
135
|
+
if (!href.includes("://")) {
|
|
136
|
+
element.addEventListener("click", (e) => {
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
Router.navigate(element.pathname);
|
|
139
|
+
//! get url hash here and scroll into view
|
|
140
|
+
if (href.includes("#")) {
|
|
141
|
+
const l = href.split("#").at(-1);
|
|
142
|
+
document.getElementById("#" + l)?.scrollIntoView();
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
element.setAttribute(prop, value);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (typeof element.style[prop] !== "undefined" && prop !== "src") {
|
|
150
|
+
element.style[prop] = value;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (Array.isArray(value)) {
|
|
154
|
+
if (prop == "reference" && value[0] instanceof reference) {
|
|
155
|
+
value[0]._appendDomForce(value[1], element);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (value[0] instanceof createSignal) {
|
|
159
|
+
value[0].bindRef(element, {
|
|
160
|
+
_element_property: prop,
|
|
161
|
+
signalProperty: value[1]
|
|
162
|
+
});
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (prop === "onmount" && typeof props["onmount"] === "function") {
|
|
167
|
+
const ev = () => {
|
|
168
|
+
props.onmount?.apply(element);
|
|
169
|
+
props["onmount"] = undefined;
|
|
170
|
+
};
|
|
171
|
+
CradovaEvent.addEventListener("onmountEvent", ev);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
element[prop] = value;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (text) {
|
|
178
|
+
element.appendChild(document.createTextNode(text));
|
|
179
|
+
}
|
|
180
|
+
return element;
|
|
181
|
+
};
|
|
182
|
+
var cra = (tag) => {
|
|
183
|
+
const extend = (...Children_and_Properties) => makeElement(document.createElement(tag), Children_and_Properties);
|
|
184
|
+
return extend;
|
|
185
|
+
};
|
|
186
|
+
var SNRU = {
|
|
187
|
+
snru: "",
|
|
188
|
+
memo_SNRU() {
|
|
189
|
+
let key = 0;
|
|
190
|
+
const url = window.location.href;
|
|
191
|
+
for (let i = 0;i < url.length; i++) {
|
|
192
|
+
key += url.charCodeAt(i);
|
|
193
|
+
}
|
|
194
|
+
this.snru = key.toString();
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
var frag = function(children) {
|
|
198
|
+
const par = document.createDocumentFragment();
|
|
199
|
+
for (let i = 0;i < children.length; i++) {
|
|
200
|
+
let html = children[i];
|
|
201
|
+
if (typeof html === "function") {
|
|
202
|
+
html = html();
|
|
203
|
+
}
|
|
204
|
+
if (html instanceof HTMLElement || html instanceof DocumentFragment) {
|
|
205
|
+
par.appendChild(html);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (html instanceof String) {
|
|
209
|
+
par.appendChild(document.createTextNode(html));
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
console.error(" \u2718 Cradova err: wrong element type" + html);
|
|
213
|
+
throw new TypeError(" \u2718 Cradova err: invalid element");
|
|
214
|
+
}
|
|
215
|
+
return par;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// src/primitives/classes.ts
|
|
219
|
+
class cradovaEvent {
|
|
220
|
+
listeners = {};
|
|
221
|
+
active_listeners = {};
|
|
222
|
+
async addEventListener(eventName, callback) {
|
|
223
|
+
if (!this.listeners[eventName]) {
|
|
224
|
+
this.listeners[eventName] = [];
|
|
225
|
+
}
|
|
226
|
+
this.listeners[eventName].push(callback);
|
|
227
|
+
}
|
|
228
|
+
async addActiveEventListener(eventName, callback) {
|
|
229
|
+
if (!this.active_listeners[eventName]) {
|
|
230
|
+
this.active_listeners[eventName] = [];
|
|
231
|
+
}
|
|
232
|
+
this.active_listeners[eventName].push(callback);
|
|
233
|
+
}
|
|
234
|
+
async dispatchEvent(eventName, eventArgs) {
|
|
235
|
+
const eventListeners = this.listeners[eventName] || [];
|
|
236
|
+
for (;eventListeners.length !== 0; ) {
|
|
237
|
+
eventListeners.shift()(eventArgs);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
async dispatchActiveEvent(eventName, eventArgs) {
|
|
241
|
+
const eventListeners = this.active_listeners[eventName] || [];
|
|
242
|
+
eventListeners.length && SNRU.memo_SNRU();
|
|
243
|
+
for (let i = 0;i < eventListeners.length; i++) {
|
|
244
|
+
eventListeners[i](eventArgs);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
var CradovaEvent = new cradovaEvent;
|
|
249
|
+
|
|
250
|
+
class Ref {
|
|
251
|
+
component;
|
|
252
|
+
effects = [];
|
|
253
|
+
effectuate = null;
|
|
254
|
+
methods = {};
|
|
255
|
+
rendered = false;
|
|
256
|
+
published = false;
|
|
257
|
+
preRendered = null;
|
|
258
|
+
reference = new reference;
|
|
259
|
+
Signal;
|
|
260
|
+
_state = [];
|
|
261
|
+
_state_track = {};
|
|
262
|
+
_state_index = 0;
|
|
263
|
+
stash;
|
|
264
|
+
constructor(component) {
|
|
265
|
+
this.component = component.bind(this);
|
|
266
|
+
CradovaEvent.addActiveEventListener("active-Refs", () => {
|
|
267
|
+
this._state_index = 0;
|
|
268
|
+
this.published = false;
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
preRender(data, stash) {
|
|
272
|
+
this.preRendered = this.render(data, stash);
|
|
273
|
+
}
|
|
274
|
+
destroyPreRendered() {
|
|
275
|
+
this.preRendered = null;
|
|
276
|
+
}
|
|
277
|
+
define(methodName, method) {
|
|
278
|
+
if (typeof methodName == "string" && typeof method == "function" && !Object.prototype.hasOwnProperty.call(this, methodName)) {
|
|
279
|
+
this.methods[methodName] = method.bind(this);
|
|
280
|
+
} else {
|
|
281
|
+
console.error(" \u2718 Cradova err : Invalid Ref.define parameters");
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
render(data, stash) {
|
|
285
|
+
this.effects = [];
|
|
286
|
+
this.rendered = false;
|
|
287
|
+
if (stash) {
|
|
288
|
+
this.stash = data;
|
|
289
|
+
}
|
|
290
|
+
if (!this.preRendered) {
|
|
291
|
+
const html = this.component(data);
|
|
292
|
+
if (html instanceof HTMLElement || html instanceof DocumentFragment) {
|
|
293
|
+
this.reference._appendDomForce("html", html);
|
|
294
|
+
this.effector.apply(this);
|
|
295
|
+
this.rendered = true;
|
|
296
|
+
this.published = true;
|
|
297
|
+
} else {
|
|
298
|
+
console.error(" \u2718 Cradova err : Invalid html content, got - " + html);
|
|
299
|
+
}
|
|
300
|
+
return html;
|
|
301
|
+
} else {
|
|
302
|
+
return this.preRendered;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
instance() {
|
|
306
|
+
return this.reference.current("html");
|
|
307
|
+
}
|
|
308
|
+
_setExtra(Extra) {
|
|
309
|
+
this.Signal = Extra;
|
|
310
|
+
}
|
|
311
|
+
_roll_state(data, idx, get = false) {
|
|
312
|
+
if (!get) {
|
|
313
|
+
this._state[idx] = data;
|
|
314
|
+
}
|
|
315
|
+
return this._state[idx];
|
|
316
|
+
}
|
|
317
|
+
_effect(fn) {
|
|
318
|
+
if (!this.rendered) {
|
|
319
|
+
this.effects.push(fn.bind(this));
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async effector() {
|
|
323
|
+
for (let i = 0;i < this.effects.length; i++) {
|
|
324
|
+
await this.effects[i].apply(this);
|
|
325
|
+
}
|
|
326
|
+
this.effects = [];
|
|
327
|
+
if (this.effectuate) {
|
|
328
|
+
this.effectuate();
|
|
329
|
+
this.effectuate = null;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
updateState(data, stash) {
|
|
333
|
+
if (!this.rendered) {
|
|
334
|
+
this.effectuate = () => {
|
|
335
|
+
if (this.published) {
|
|
336
|
+
this.Activate(data);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
} else {
|
|
340
|
+
if (this.published) {
|
|
341
|
+
this.Activate(data);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (stash) {
|
|
345
|
+
this.stash = data;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
async Activate(data) {
|
|
349
|
+
this._state_index = 0;
|
|
350
|
+
this.published = false;
|
|
351
|
+
if (!this.rendered) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
const html = this.component(data);
|
|
355
|
+
if (html instanceof HTMLElement || html instanceof DocumentFragment) {
|
|
356
|
+
const node = this.reference.current("html");
|
|
357
|
+
if (node) {
|
|
358
|
+
node.insertAdjacentElement("beforebegin", html);
|
|
359
|
+
node.remove();
|
|
360
|
+
}
|
|
361
|
+
this.published = true;
|
|
362
|
+
this.reference._appendDomForce("html", html);
|
|
363
|
+
CradovaEvent.dispatchEvent("onmountEvent");
|
|
364
|
+
} else {
|
|
365
|
+
console.error(" \u2718 Cradova err : Invalid html content, got - " + html);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
class lazy {
|
|
371
|
+
content;
|
|
372
|
+
_cb;
|
|
373
|
+
constructor(cb) {
|
|
374
|
+
this._cb = cb;
|
|
375
|
+
}
|
|
376
|
+
async load() {
|
|
377
|
+
let content = await this._cb();
|
|
378
|
+
if (typeof content === "function") {
|
|
379
|
+
content = await content();
|
|
380
|
+
} else {
|
|
381
|
+
content = await content;
|
|
382
|
+
}
|
|
383
|
+
const def = content;
|
|
384
|
+
if (def.default) {
|
|
385
|
+
this.content = def?.default;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
class reference {
|
|
391
|
+
tree = {};
|
|
392
|
+
globalTree = {};
|
|
393
|
+
bindAs(name) {
|
|
394
|
+
return [this, name];
|
|
395
|
+
}
|
|
396
|
+
current(name) {
|
|
397
|
+
if (this.tree[SNRU.snru]) {
|
|
398
|
+
return this.tree[SNRU.snru][name];
|
|
399
|
+
}
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
_appendDomForce(name, Element) {
|
|
403
|
+
if (this.tree[SNRU.snru]) {
|
|
404
|
+
this.tree[SNRU.snru][name] = Element;
|
|
405
|
+
} else {
|
|
406
|
+
this.tree[SNRU.snru] = {};
|
|
407
|
+
this.tree[SNRU.snru][name] = Element;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
_appendDomForceGlobal(name, Element) {
|
|
411
|
+
this.globalTree[name] = Element;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
var localTree = new reference;
|
|
415
|
+
|
|
416
|
+
class createSignal {
|
|
417
|
+
callback;
|
|
418
|
+
persistName = "";
|
|
419
|
+
actions = {};
|
|
420
|
+
ref = [];
|
|
421
|
+
value;
|
|
422
|
+
constructor(initial, props) {
|
|
423
|
+
this.value = initial;
|
|
424
|
+
if (props && props.persistName) {
|
|
425
|
+
this.persistName = props.persistName;
|
|
426
|
+
const key = localStorage.getItem(props.persistName);
|
|
427
|
+
if (key && key !== "undefined") {
|
|
428
|
+
this.value = JSON.parse(key);
|
|
429
|
+
}
|
|
430
|
+
if (typeof initial === "object") {
|
|
431
|
+
for (const key2 in initial) {
|
|
432
|
+
if (!Object.prototype.hasOwnProperty.call(this.value, key2)) {
|
|
433
|
+
this.value[key2] = initial[key2];
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
set(value, shouldRefRender) {
|
|
440
|
+
if (typeof value === "function") {
|
|
441
|
+
this.value = value(this.value);
|
|
442
|
+
} else {
|
|
443
|
+
this.value = value;
|
|
444
|
+
}
|
|
445
|
+
if (this.persistName) {
|
|
446
|
+
localStorage.setItem(this.persistName, JSON.stringify(this.value));
|
|
447
|
+
}
|
|
448
|
+
if (this.ref.length && shouldRefRender !== false) {
|
|
449
|
+
this._updateState();
|
|
450
|
+
}
|
|
451
|
+
if (this.callback) {
|
|
452
|
+
this.callback(this.value);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
setKey(key, value, shouldRefRender) {
|
|
456
|
+
if (typeof this.value === "object" && !Array.isArray(this.value)) {
|
|
457
|
+
this.value[key] = value;
|
|
458
|
+
if (this.persistName) {
|
|
459
|
+
localStorage.setItem(this.persistName, JSON.stringify(this.value));
|
|
460
|
+
}
|
|
461
|
+
if (this.ref.length && shouldRefRender !== false) {
|
|
462
|
+
this._updateState();
|
|
463
|
+
}
|
|
464
|
+
if (this.callback) {
|
|
465
|
+
this.callback(this.value);
|
|
466
|
+
}
|
|
467
|
+
} else {
|
|
468
|
+
throw new Error(`\u2718 Cradova err : can't set key ${String(key)} . store.value is not a javascript object`);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
createAction(name, action) {
|
|
472
|
+
if (typeof name === "string" && typeof action === "function") {
|
|
473
|
+
this.actions[name] = action;
|
|
474
|
+
} else {
|
|
475
|
+
throw new Error(`\u2718 Cradova err : can't create action, ${name} is not a function`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
createActions(Actions) {
|
|
479
|
+
for (const [name, action] of Object.entries(Actions)) {
|
|
480
|
+
if (typeof name === "string" && typeof action === "function") {
|
|
481
|
+
this.actions[name] = action;
|
|
482
|
+
} else {
|
|
483
|
+
throw new Error(`\u2718 Cradova err : can't create action, ${name} is not a function`);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
fireAction(key, data) {
|
|
488
|
+
this._updateState(key, data);
|
|
489
|
+
if (typeof this.actions[key] === "function") {
|
|
490
|
+
return this.actions[key].call(this, data);
|
|
491
|
+
} else {
|
|
492
|
+
throw Error("\u2718 Cradova err : action " + key + " does not exist!");
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
bind(prop) {
|
|
496
|
+
if (typeof this.value === "object" && typeof this.value[prop] !== "undefined") {
|
|
497
|
+
return [this, prop];
|
|
498
|
+
} else {
|
|
499
|
+
throw new Error("\u2718 Cradova err : can't bind an unavailable property! " + prop);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
_updateState(name, data) {
|
|
503
|
+
if (name && data) {
|
|
504
|
+
this.ref.map((ent) => {
|
|
505
|
+
if (ent._event === name) {
|
|
506
|
+
if (ent._element_property && ent._signalProperty) {
|
|
507
|
+
ent.ref.updateState({
|
|
508
|
+
[ent._element_property]: data[ent._signalProperty]
|
|
509
|
+
});
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
if (ent._element_property) {
|
|
513
|
+
ent.ref.updateState({
|
|
514
|
+
[ent._element_property]: data
|
|
515
|
+
});
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
if (ent._signalProperty) {
|
|
519
|
+
ent.ref.updateState(data[ent._signalProperty]);
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
} else {
|
|
525
|
+
for (let i = 0;i < this.ref.length; i++) {
|
|
526
|
+
const ent = this.ref[i];
|
|
527
|
+
if (ent._element_property && ent._signalProperty) {
|
|
528
|
+
ent.ref.updateState({
|
|
529
|
+
[ent._element_property]: this.value[ent._signalProperty]
|
|
530
|
+
});
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
if (ent._element_property) {
|
|
534
|
+
ent.ref.updateState({
|
|
535
|
+
[ent._element_property]: this.value
|
|
536
|
+
});
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
if (ent._signalProperty) {
|
|
540
|
+
ent.ref.updateState(this.value[ent._signalProperty]);
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
if (!ent._element_property && !ent._signalProperty) {
|
|
544
|
+
ent.ref.updateState(this.value);
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
bindRef(ref, binding = { signalProperty: "", _element_property: "" }) {
|
|
551
|
+
ref.render = ref.render.bind(ref, this.value);
|
|
552
|
+
ref._setExtra(this);
|
|
553
|
+
this.ref.push({
|
|
554
|
+
ref,
|
|
555
|
+
_signalProperty: binding.signalProperty,
|
|
556
|
+
_element_property: binding._element_property,
|
|
557
|
+
_event: binding.event
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
listen(callback) {
|
|
561
|
+
this.callback = callback;
|
|
562
|
+
}
|
|
563
|
+
clearPersist() {
|
|
564
|
+
if (this.persistName) {
|
|
565
|
+
localStorage.removeItem(this.persistName);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
class Screen {
|
|
571
|
+
_name;
|
|
572
|
+
_html;
|
|
573
|
+
_packed = false;
|
|
574
|
+
_template = document.createElement("div");
|
|
575
|
+
_callBack;
|
|
576
|
+
_deCallBack;
|
|
577
|
+
_persist = true;
|
|
578
|
+
_delegatedRoutesCount = -1;
|
|
579
|
+
_dropped = false;
|
|
580
|
+
_errorHandler = null;
|
|
581
|
+
constructor(cradova_screen_initials) {
|
|
582
|
+
const { template, name, persist, renderInParallel } = cradova_screen_initials;
|
|
583
|
+
if (template instanceof Ref) {
|
|
584
|
+
this._html = () => template.render({});
|
|
585
|
+
} else {
|
|
586
|
+
this._html = template;
|
|
587
|
+
}
|
|
588
|
+
this._name = name || "Document";
|
|
589
|
+
this._template.setAttribute("id", "cradova-screen-set");
|
|
590
|
+
if (renderInParallel === true) {
|
|
591
|
+
this._delegatedRoutesCount = 0;
|
|
592
|
+
this._persist = false;
|
|
593
|
+
} else {
|
|
594
|
+
if (typeof persist === "boolean") {
|
|
595
|
+
this._persist = persist;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
_derive() {
|
|
600
|
+
return {
|
|
601
|
+
_name: this._name,
|
|
602
|
+
_callBack: this._callBack,
|
|
603
|
+
_deCallBack: this._deCallBack
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
_apply_derivation(derivation) {
|
|
607
|
+
this._name = derivation._name;
|
|
608
|
+
this._callBack = derivation._callBack;
|
|
609
|
+
this._deCallBack = derivation._deCallBack;
|
|
610
|
+
}
|
|
611
|
+
get _delegatedRoutes() {
|
|
612
|
+
if (this._delegatedRoutesCount > 100) {
|
|
613
|
+
return -1;
|
|
614
|
+
}
|
|
615
|
+
return this._delegatedRoutesCount;
|
|
616
|
+
}
|
|
617
|
+
set _delegatedRoutes(count) {
|
|
618
|
+
if (count) {
|
|
619
|
+
this._delegatedRoutesCount += 1;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
setErrorHandler(errorHandler) {
|
|
623
|
+
this._errorHandler = errorHandler;
|
|
624
|
+
}
|
|
625
|
+
async _package() {
|
|
626
|
+
SNRU.memo_SNRU();
|
|
627
|
+
if (typeof this._html === "function") {
|
|
628
|
+
let html = await this._html.apply(this);
|
|
629
|
+
if (typeof html === "function") {
|
|
630
|
+
html = html();
|
|
631
|
+
if (html instanceof HTMLElement || html instanceof DocumentFragment) {
|
|
632
|
+
this._template.innerHTML = "";
|
|
633
|
+
this._template.appendChild(html);
|
|
634
|
+
}
|
|
635
|
+
} else {
|
|
636
|
+
if (html instanceof HTMLElement || html instanceof DocumentFragment) {
|
|
637
|
+
this._template.innerHTML = "";
|
|
638
|
+
this._template.appendChild(html);
|
|
639
|
+
} else {
|
|
640
|
+
throw new Error(` \u2718 Cradova err: template function for the screen with name '${this._name}' returned ${html} instead of html`);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
onActivate(cb) {
|
|
646
|
+
this._callBack = cb;
|
|
647
|
+
}
|
|
648
|
+
onDeactivate(cb) {
|
|
649
|
+
this._deCallBack = cb;
|
|
650
|
+
}
|
|
651
|
+
async _deActivate() {
|
|
652
|
+
this._deCallBack && await this._deCallBack(localTree.globalTree["doc"]);
|
|
653
|
+
}
|
|
654
|
+
drop(state) {
|
|
655
|
+
if (typeof state === "boolean") {
|
|
656
|
+
this._dropped = state;
|
|
657
|
+
return;
|
|
658
|
+
} else
|
|
659
|
+
return this._dropped;
|
|
660
|
+
}
|
|
661
|
+
async _Activate(force = false) {
|
|
662
|
+
if (this._dropped) {
|
|
663
|
+
history.go(-1);
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
CradovaEvent.dispatchActiveEvent("active-Refs");
|
|
667
|
+
if (!this._persist || force || !this._packed) {
|
|
668
|
+
await this._package();
|
|
669
|
+
this._packed = true;
|
|
670
|
+
}
|
|
671
|
+
document.title = this._name;
|
|
672
|
+
localTree.globalTree["doc"].innerHTML = "";
|
|
673
|
+
localTree.globalTree["doc"].appendChild(this._template);
|
|
674
|
+
CradovaEvent.dispatchEvent("onmountEvent");
|
|
675
|
+
window.scrollTo({
|
|
676
|
+
top: 0,
|
|
677
|
+
left: 0,
|
|
678
|
+
behavior: "instant"
|
|
679
|
+
});
|
|
680
|
+
this._callBack && await this._callBack(localTree.globalTree["doc"]);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
class RouterBoxClass {
|
|
685
|
+
lastNavigatedRouteController;
|
|
686
|
+
nextRouteController;
|
|
687
|
+
lastNavigatedRoute;
|
|
688
|
+
pageShow = null;
|
|
689
|
+
pageHide = null;
|
|
690
|
+
errorHandler;
|
|
691
|
+
loadingScreen = null;
|
|
692
|
+
params = {};
|
|
693
|
+
routes = {};
|
|
694
|
+
pageevents = [];
|
|
695
|
+
paused = false;
|
|
696
|
+
async start_pageevents(url) {
|
|
697
|
+
setTimeout(() => {
|
|
698
|
+
for (let ci = 0;ci < this.pageevents.length; ci++) {
|
|
699
|
+
this.pageevents[ci](url);
|
|
700
|
+
}
|
|
701
|
+
}, 50);
|
|
702
|
+
}
|
|
703
|
+
route(path, screen) {
|
|
704
|
+
if (typeof screen !== "undefined") {
|
|
705
|
+
if (screen && !screen) {
|
|
706
|
+
console.error(" \u2718 Cradova err: not a valid screen ", screen);
|
|
707
|
+
throw new Error(" \u2718 Cradova err: Not a valid cradova screen component");
|
|
708
|
+
}
|
|
709
|
+
return this.routes[path] = screen;
|
|
710
|
+
}
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
async router(_e, _force) {
|
|
714
|
+
let url = window.location.pathname, route, params;
|
|
715
|
+
if (this.paused) {
|
|
716
|
+
window.location.hash = "paused";
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
if (url === this.lastNavigatedRoute) {
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
if (this.nextRouteController) {
|
|
723
|
+
route = this.nextRouteController;
|
|
724
|
+
this.nextRouteController = undefined;
|
|
725
|
+
} else {
|
|
726
|
+
[route, params] = this.checker(url);
|
|
727
|
+
}
|
|
728
|
+
if (typeof route !== "undefined") {
|
|
729
|
+
try {
|
|
730
|
+
if (typeof route === "function") {
|
|
731
|
+
if (this.loadingScreen instanceof Screen) {
|
|
732
|
+
await this.loadingScreen._Activate();
|
|
733
|
+
}
|
|
734
|
+
route = await route();
|
|
735
|
+
if (!route) {
|
|
736
|
+
if (this.lastNavigatedRoute) {
|
|
737
|
+
history.pushState({}, url, this.lastNavigatedRoute);
|
|
738
|
+
}
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
if (route._delegatedRoutes !== -1) {
|
|
743
|
+
route._delegatedRoutes = 1;
|
|
744
|
+
const a = route._derive();
|
|
745
|
+
route = new Screen({
|
|
746
|
+
template: route._html
|
|
747
|
+
});
|
|
748
|
+
route._apply_derivation(a);
|
|
749
|
+
this.routes[url] = route;
|
|
750
|
+
}
|
|
751
|
+
if (params) {
|
|
752
|
+
this.params.params = params;
|
|
753
|
+
}
|
|
754
|
+
await route._Activate(_force);
|
|
755
|
+
this.start_pageevents(url);
|
|
756
|
+
this.lastNavigatedRouteController && this.lastNavigatedRouteController._deActivate();
|
|
757
|
+
this.lastNavigatedRoute = url;
|
|
758
|
+
this.lastNavigatedRouteController = route;
|
|
759
|
+
} catch (error) {
|
|
760
|
+
if (route && route["_errorHandler"]) {
|
|
761
|
+
route._errorHandler(error);
|
|
762
|
+
} else {
|
|
763
|
+
if (typeof this.errorHandler === "function") {
|
|
764
|
+
this.errorHandler(error);
|
|
765
|
+
} else {
|
|
766
|
+
console.error(error);
|
|
767
|
+
throw new Error(" \u2718 Cradova err: consider adding error boundary to the specific screen ");
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
} else {
|
|
772
|
+
if (this.routes["*"]) {
|
|
773
|
+
await this.routes["*"]._Activate(_force);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
checker(url) {
|
|
778
|
+
if (this.routes[url]) {
|
|
779
|
+
return [this.routes[url], { path: url }];
|
|
780
|
+
}
|
|
781
|
+
if (this.routes[url + "/"]) {
|
|
782
|
+
return [this.routes[url], { path: url }];
|
|
783
|
+
}
|
|
784
|
+
for (const path in this.routes) {
|
|
785
|
+
if (!path.includes(":")) {
|
|
786
|
+
continue;
|
|
787
|
+
}
|
|
788
|
+
const urlFixtures = url.split("/");
|
|
789
|
+
const pathFixtures = path.split("/");
|
|
790
|
+
if (url.endsWith("/")) {
|
|
791
|
+
urlFixtures.pop();
|
|
792
|
+
}
|
|
793
|
+
let fixturesX = 0;
|
|
794
|
+
let fixturesY = 0;
|
|
795
|
+
urlFixtures.shift();
|
|
796
|
+
pathFixtures.shift();
|
|
797
|
+
if (pathFixtures.length === urlFixtures.length) {
|
|
798
|
+
const routesParams = { _path: "" };
|
|
799
|
+
for (let i = 0;i < pathFixtures.length; i++) {
|
|
800
|
+
if (pathFixtures[i].includes(":")) {
|
|
801
|
+
fixturesY++;
|
|
802
|
+
continue;
|
|
803
|
+
}
|
|
804
|
+
if (urlFixtures[i] === pathFixtures[i]) {
|
|
805
|
+
fixturesX++;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
if (fixturesX + fixturesY === pathFixtures.length) {
|
|
809
|
+
for (let i = 0;i < pathFixtures.length; i++) {
|
|
810
|
+
if (pathFixtures[i].includes(":")) {
|
|
811
|
+
routesParams[pathFixtures[i].split(":")[1]] = urlFixtures[i];
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
routesParams["_path"] = path;
|
|
815
|
+
return [this.routes[path], routesParams];
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return [];
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
var RouterBox = new RouterBoxClass;
|
|
823
|
+
|
|
824
|
+
class Router {
|
|
825
|
+
static BrowserRoutes(obj) {
|
|
826
|
+
for (const path in obj) {
|
|
827
|
+
let screen = obj[path];
|
|
828
|
+
if (typeof screen === "object" && typeof screen.then === "function" || typeof screen === "function") {
|
|
829
|
+
RouterBox.routes[path] = async () => {
|
|
830
|
+
screen = await (typeof screen === "function" ? await screen() : await screen);
|
|
831
|
+
return RouterBox.route(path, screen?.default || screen);
|
|
832
|
+
};
|
|
833
|
+
} else {
|
|
834
|
+
RouterBox.route(path, screen);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
Router._mount();
|
|
838
|
+
}
|
|
839
|
+
static back() {
|
|
840
|
+
history.go(-1);
|
|
841
|
+
}
|
|
842
|
+
static forward() {
|
|
843
|
+
history.go(1);
|
|
844
|
+
}
|
|
845
|
+
static pauseNaviagtion() {
|
|
846
|
+
RouterBox["paused"] = true;
|
|
847
|
+
window.location.hash = "paused";
|
|
848
|
+
}
|
|
849
|
+
static resumeNaviagtion() {
|
|
850
|
+
RouterBox["paused"] = false;
|
|
851
|
+
window.location.replace(window.location.pathname + window.location.search);
|
|
852
|
+
history.go(-1);
|
|
853
|
+
}
|
|
854
|
+
static navigate(href, data = null, force = false) {
|
|
855
|
+
if (typeof href !== "string") {
|
|
856
|
+
throw new TypeError(" \u2718 Cradova err: href must be a defined path but got " + href + " instead");
|
|
857
|
+
}
|
|
858
|
+
let route = null, params;
|
|
859
|
+
if (href.includes("://")) {
|
|
860
|
+
window.location.href = href;
|
|
861
|
+
} else {
|
|
862
|
+
if (href === window.location.pathname) {
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
[route, params] = RouterBox.checker(href);
|
|
866
|
+
if (route) {
|
|
867
|
+
RouterBox.nextRouteController = route;
|
|
868
|
+
window.history.pushState({}, "", href);
|
|
869
|
+
}
|
|
870
|
+
RouterBox.params.params = params;
|
|
871
|
+
RouterBox.params.data = data;
|
|
872
|
+
RouterBox.router(null, force);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
static setLoadingScreen(screen) {
|
|
876
|
+
if (screen instanceof Screen) {
|
|
877
|
+
RouterBox.loadingScreen = screen;
|
|
878
|
+
} else {
|
|
879
|
+
throw new Error(" \u2718 Cradova err: Loading Screen should be a cradova screen class");
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
static onPageEvent(callback) {
|
|
883
|
+
if (typeof callback === "function") {
|
|
884
|
+
RouterBox["pageevents"].push(callback);
|
|
885
|
+
} else {
|
|
886
|
+
throw new Error(" \u2718 Cradova err: callback for pageShow event is not a function");
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
static async packageScreen(path) {
|
|
890
|
+
if (!RouterBox.routes[path]) {
|
|
891
|
+
console.error(" \u2718 Cradova err: no screen with path " + path);
|
|
892
|
+
throw new Error(" \u2718 Cradova err: cradova err: Not a defined screen path");
|
|
893
|
+
}
|
|
894
|
+
let [route] = RouterBox.checker(path);
|
|
895
|
+
if (typeof route === "function") {
|
|
896
|
+
route = await route();
|
|
897
|
+
}
|
|
898
|
+
if (route._delegatedRoutes !== -1) {
|
|
899
|
+
route._delegatedRoutes = 1;
|
|
900
|
+
const a = route._derive();
|
|
901
|
+
route = new Screen({
|
|
902
|
+
template: route._html
|
|
903
|
+
});
|
|
904
|
+
route._apply_derivation(a);
|
|
905
|
+
RouterBox.routes[path] = route;
|
|
906
|
+
}
|
|
907
|
+
route._package();
|
|
908
|
+
route._packed = true;
|
|
909
|
+
}
|
|
910
|
+
static get Params() {
|
|
911
|
+
return RouterBox.params;
|
|
912
|
+
}
|
|
913
|
+
static addErrorHandler(callback) {
|
|
914
|
+
if (typeof callback === "function") {
|
|
915
|
+
RouterBox["errorHandler"] = callback;
|
|
916
|
+
} else {
|
|
917
|
+
throw new Error(" \u2718 Cradova err: callback for error event is not a function");
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
static _mount() {
|
|
921
|
+
let doc = document.querySelector("[data-wrapper=app]");
|
|
922
|
+
if (!doc) {
|
|
923
|
+
doc = document.createElement("div");
|
|
924
|
+
doc.setAttribute("data-wrapper", "app");
|
|
925
|
+
document.body.appendChild(doc);
|
|
926
|
+
localTree._appendDomForceGlobal("doc", doc);
|
|
927
|
+
} else {
|
|
928
|
+
localTree._appendDomForceGlobal("doc", doc);
|
|
929
|
+
}
|
|
930
|
+
window.addEventListener("pageshow", () => RouterBox.router());
|
|
931
|
+
window.addEventListener("popstate", (_e) => {
|
|
932
|
+
_e.preventDefault();
|
|
933
|
+
RouterBox.router();
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
// src/primitives/dom-objects.ts
|
|
938
|
+
var a = cra("a");
|
|
939
|
+
var article = cra("article");
|
|
940
|
+
var audio = cra("audio");
|
|
941
|
+
var br = cra("br");
|
|
942
|
+
var button = cra("button");
|
|
943
|
+
var canvas = cra("canvas");
|
|
944
|
+
var caption = cra("caption");
|
|
945
|
+
var col = cra("col");
|
|
946
|
+
var colgroup = cra("colgroup");
|
|
947
|
+
var datalist = cra("datalist");
|
|
948
|
+
var details = cra("details");
|
|
949
|
+
var dialog = cra("dialog");
|
|
950
|
+
var div = cra("div");
|
|
951
|
+
var figure = cra("figure");
|
|
952
|
+
var footer = cra("footer");
|
|
953
|
+
var form = cra("form");
|
|
954
|
+
var h1 = cra("h1");
|
|
955
|
+
var h2 = cra("h2");
|
|
956
|
+
var h3 = cra("h3");
|
|
957
|
+
var h4 = cra("h4");
|
|
958
|
+
var h5 = cra("h5");
|
|
959
|
+
var h6 = cra("h6");
|
|
960
|
+
var head = cra("head");
|
|
961
|
+
var header = cra("header");
|
|
962
|
+
var hr = cra("hr");
|
|
963
|
+
var i = cra("i");
|
|
964
|
+
var iframe = cra("iframe");
|
|
965
|
+
var img = cra("img");
|
|
966
|
+
var input = cra("input");
|
|
967
|
+
var label = cra("label");
|
|
968
|
+
var li = cra("li");
|
|
969
|
+
var main = cra("main");
|
|
970
|
+
var nav = cra("nav");
|
|
971
|
+
var ol = cra("ol");
|
|
972
|
+
var optgroup = cra("optgroup");
|
|
973
|
+
var option = cra("option");
|
|
974
|
+
var p = cra("p");
|
|
975
|
+
var progress = cra("progress");
|
|
976
|
+
var q = cra("q");
|
|
977
|
+
var section = cra("section");
|
|
978
|
+
var select = cra("select");
|
|
979
|
+
var source = cra("source");
|
|
980
|
+
var span = cra("span");
|
|
981
|
+
var strong = cra("strong");
|
|
982
|
+
var summary = cra("summary");
|
|
983
|
+
var table = cra("table");
|
|
984
|
+
var tbody = cra("tbody");
|
|
985
|
+
var td = cra("td");
|
|
986
|
+
var template = cra("template");
|
|
987
|
+
var textarea = cra("textarea");
|
|
988
|
+
var th = cra("th");
|
|
989
|
+
var title = cra("title");
|
|
990
|
+
var tr = cra("tr");
|
|
991
|
+
var track = cra("track");
|
|
992
|
+
var u = cra("u");
|
|
993
|
+
var ul = cra("ul");
|
|
994
|
+
var video = cra("video");
|
|
995
|
+
var svg = (svg2, properties) => {
|
|
996
|
+
const span2 = document.createElement("span");
|
|
997
|
+
span2.innerHTML = svg2;
|
|
998
|
+
return makeElement(span2, properties);
|
|
999
|
+
};
|
|
1000
|
+
var raw = (html) => {
|
|
1001
|
+
const div2 = document.createElement("div");
|
|
1002
|
+
div2.innerHTML = html;
|
|
1003
|
+
const df = new DocumentFragment;
|
|
1004
|
+
df.append(...Array.from(div2.children));
|
|
1005
|
+
return df;
|
|
1006
|
+
};
|
|
1007
|
+
|
|
1008
|
+
// src/index.ts
|
|
1009
|
+
/*! *****************************************************************************
|
|
1010
|
+
Copyright 2022 Friday Candour. All rights reserved.
|
|
1011
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
1012
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
1013
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1014
|
+
|
|
1015
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
1016
|
+
and limitations under the License.
|
|
1017
|
+
********************************************************************************/
|
|
1018
|
+
export {
|
|
1019
|
+
video,
|
|
1020
|
+
useState,
|
|
1021
|
+
useRef,
|
|
1022
|
+
useEffect,
|
|
1023
|
+
ul,
|
|
1024
|
+
u,
|
|
1025
|
+
track,
|
|
1026
|
+
tr,
|
|
1027
|
+
title,
|
|
1028
|
+
th,
|
|
1029
|
+
textarea,
|
|
1030
|
+
template,
|
|
1031
|
+
td,
|
|
1032
|
+
tbody,
|
|
1033
|
+
table,
|
|
1034
|
+
svg,
|
|
1035
|
+
summary,
|
|
1036
|
+
strong,
|
|
1037
|
+
span,
|
|
1038
|
+
source,
|
|
1039
|
+
select,
|
|
1040
|
+
section,
|
|
1041
|
+
reference,
|
|
1042
|
+
raw,
|
|
1043
|
+
q,
|
|
1044
|
+
progress,
|
|
1045
|
+
p,
|
|
1046
|
+
option,
|
|
1047
|
+
optgroup,
|
|
1048
|
+
ol,
|
|
1049
|
+
nav,
|
|
1050
|
+
makeElement,
|
|
1051
|
+
main,
|
|
1052
|
+
loop,
|
|
1053
|
+
li,
|
|
1054
|
+
lazy,
|
|
1055
|
+
label,
|
|
1056
|
+
input,
|
|
1057
|
+
img,
|
|
1058
|
+
iframe,
|
|
1059
|
+
i,
|
|
1060
|
+
hr,
|
|
1061
|
+
header,
|
|
1062
|
+
head,
|
|
1063
|
+
h6,
|
|
1064
|
+
h5,
|
|
1065
|
+
h4,
|
|
1066
|
+
h3,
|
|
1067
|
+
h2,
|
|
1068
|
+
h1,
|
|
1069
|
+
frag,
|
|
1070
|
+
form,
|
|
1071
|
+
footer,
|
|
1072
|
+
figure,
|
|
1073
|
+
div,
|
|
1074
|
+
dialog,
|
|
1075
|
+
details,
|
|
1076
|
+
datalist,
|
|
1077
|
+
createSignal,
|
|
1078
|
+
cra,
|
|
1079
|
+
colgroup,
|
|
1080
|
+
col,
|
|
1081
|
+
caption,
|
|
1082
|
+
canvas,
|
|
1083
|
+
button,
|
|
1084
|
+
br,
|
|
1085
|
+
audio,
|
|
1086
|
+
article,
|
|
1087
|
+
a,
|
|
1088
|
+
Screen,
|
|
1089
|
+
SNRU,
|
|
1090
|
+
Router,
|
|
1091
|
+
Rhoda,
|
|
1092
|
+
Ref,
|
|
1093
|
+
CradovaEvent,
|
|
1094
|
+
$switch,
|
|
1095
|
+
$ifelse,
|
|
1096
|
+
$if,
|
|
1097
|
+
$case
|
|
1098
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cradova",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.6",
|
|
4
4
|
"description": "Web framework for building powerful web apps",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist/index.d.ts",
|
|
9
|
-
"dist/primitives/**",
|
|
10
9
|
"dist/index.js"
|
|
11
10
|
],
|
|
12
11
|
"repository": {
|
|
@@ -66,7 +65,9 @@
|
|
|
66
65
|
"eslint": "^8.30.0",
|
|
67
66
|
"eslint-config-prettier": "^8.5.0",
|
|
68
67
|
"eslint-plugin-prettier": "^4.2.1",
|
|
69
|
-
"prettier": "^2.8.1"
|
|
68
|
+
"prettier": "^2.8.1",
|
|
69
|
+
"tsup": "^6.7.0",
|
|
70
|
+
"typescript": "^4.9.4"
|
|
70
71
|
},
|
|
71
72
|
"dependencies": {
|
|
72
73
|
"csstype": "^3.1.2"
|