cradova 3.1.4 → 3.1.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.
Files changed (2) hide show
  1. package/dist/index.js +50 -18
  2. package/package.json +4 -2
package/dist/index.js CHANGED
@@ -105,6 +105,13 @@ function loop(datalist2, component) {
105
105
  }
106
106
  return Array.isArray(datalist2) ? datalist2.map(component) : void 0;
107
107
  }
108
+ function SNRU(url) {
109
+ let key = 0;
110
+ for (let i2 = 0; i2 < url.length; i2++) {
111
+ key += url.charCodeAt(i2);
112
+ }
113
+ return key.toString();
114
+ }
108
115
  var Ref = class {
109
116
  constructor(component) {
110
117
  this.effects = [];
@@ -113,26 +120,24 @@ var Ref = class {
113
120
  this.published = false;
114
121
  this.preRendered = null;
115
122
  this.reference = new reference();
116
- // hooks management
123
+ //? hooks management
117
124
  this._state = [];
118
125
  this._state_track = {};
119
126
  this._state_index = 0;
120
127
  this.component = component.bind(this);
128
+ const Recusr = () => {
129
+ CradovaEvent.addEventListener("onTransition", () => {
130
+ this.current_id = SNRU(location.href);
131
+ Recusr();
132
+ });
133
+ };
134
+ Recusr();
121
135
  }
122
- preRender(data2) {
123
- let html = this.component(data2);
124
- if (typeof html === "function") {
125
- html = html();
126
- }
127
- if (isNode(html)) {
128
- this.preRendered = html;
129
- }
130
- if (!this.preRendered) {
131
- throw new Error(
132
- " \u2718 Cradova err : Invalid component type for cradova Ref got - " + this.preRendered
133
- );
134
- }
135
- this.reference._appendDomForce("html", this.preRendered);
136
+ preRender(data2, stash) {
137
+ this.reference._appendDomForce(
138
+ this.current_id,
139
+ this.render(data2, stash)
140
+ );
136
141
  }
137
142
  destroyPreRendered() {
138
143
  this.preRendered = null;
@@ -158,7 +163,10 @@ var Ref = class {
158
163
  this.stash = data2;
159
164
  }
160
165
  if (isNode(html)) {
161
- this.reference._appendDomForce("html", html);
166
+ this.reference._appendDomForce(
167
+ this.current_id,
168
+ html
169
+ );
162
170
  this.effector.apply(this);
163
171
  this.rendered = true;
164
172
  this.published = true;
@@ -204,6 +212,7 @@ var Ref = class {
204
212
  * @returns
205
213
  */
206
214
  updateState(data2, stash) {
215
+ this.current_id = SNRU(location.href);
207
216
  if (!this.rendered) {
208
217
  this.effectuate = () => {
209
218
  if (this.published) {
@@ -233,7 +242,10 @@ var Ref = class {
233
242
  this.reference.html.insertAdjacentElement("beforebegin", html);
234
243
  this.reference.html.remove();
235
244
  this.published = true;
236
- this.reference._appendDomForce("html", html);
245
+ this.reference._appendDomForce(
246
+ this.current_id,
247
+ html
248
+ );
237
249
  CradovaEvent.dispatchEvent("onmountEvent");
238
250
  } else {
239
251
  console.error(" \u2718 Cradova err : Invalid html content, got - " + html);
@@ -278,12 +290,25 @@ var lazy = class {
278
290
  }
279
291
  };
280
292
  var reference = class {
293
+ /**
294
+ * Bind a DOM element to a reference name.
295
+ * @param name - The name to reference the DOM element by.
296
+ */
281
297
  bindAs(name) {
282
298
  return [this, name];
283
299
  }
300
+ /**
301
+ * Retrieve a referenced DOM element.
302
+ * @param name - The name of the referenced DOM element.
303
+ */
284
304
  dom(name) {
285
305
  return this[name];
286
306
  }
307
+ /**
308
+ * Append a DOM element to the reference, overwriting any existing reference.
309
+ * @param name - The name to reference the DOM element by.
310
+ * @param element - The DOM element to reference.
311
+ */
287
312
  _appendDomForce(name, Element) {
288
313
  this[name] = Element;
289
314
  }
@@ -736,6 +761,7 @@ RouterBox["routes"] = {};
736
761
  RouterBox["pageevents"] = [];
737
762
  RouterBox["paused"] = false;
738
763
  RouterBox["start_pageevents"] = async function(url) {
764
+ CradovaEvent.dispatchEvent("onTransition");
739
765
  setTimeout(() => {
740
766
  for (let ci = 0; ci < RouterBox["pageevents"].length; ci++) {
741
767
  RouterBox["pageevents"][ci](url);
@@ -1308,6 +1334,11 @@ var track = cra("track");
1308
1334
  var u = cra("u");
1309
1335
  var ul = cra("ul");
1310
1336
  var video = cra("video");
1337
+ var ___svg = (svg, properties) => {
1338
+ const span2 = document.createElement("span");
1339
+ span2.innerHTML = svg;
1340
+ return makeElement(span2, [properties]);
1341
+ };
1311
1342
 
1312
1343
  // lib/parts/ajax.ts
1313
1344
  function Ajax(url, opts = {}) {
@@ -1390,7 +1421,8 @@ var _2 = (...element_initials) => {
1390
1421
  }
1391
1422
  return makeElement(element, element_initials);
1392
1423
  };
1424
+ _2.__proto__.svg = ___svg;
1393
1425
  var lib_default = _2;
1394
1426
  //! get url hash here and scroll into view
1395
1427
 
1396
- export { Ajax, CradovaEvent, Ref, Rhoda, Router, Screen, a, area, article, aside, assert, assertOr, audio, b, base, blockquote, br, button, canvas, caption, code, col, colgroup, cradovaEvent, createSignal, css, data, datalist, lib_default as default, details, dialog, div, em, embed, figure, footer, form, frag, h1, h2, h3, h4, h5, h6, head, header, hr, i, iframe, img, input, isNode, label, lazy, legend, li, link, loop, main, make, makeElement, menu, nav, object, ol, optgroup, option, p, pre, progress, q, reference, section, select, source, span, strong, summary, table, tbody, td, template, textarea, th, title, tr, track, u, ul, useEffect, useRef, useState, video };
1428
+ export { Ajax, CradovaEvent, Ref, Rhoda, Router, Screen, ___svg, a, area, article, aside, assert, assertOr, audio, b, base, blockquote, br, button, canvas, caption, code, col, colgroup, createSignal, css, data, datalist, lib_default as default, details, dialog, div, em, embed, figure, footer, form, frag, h1, h2, h3, h4, h5, h6, head, header, hr, i, iframe, img, input, isNode, label, lazy, legend, li, link, loop, main, make, makeElement, menu, nav, object, ol, optgroup, option, p, pre, progress, q, reference, section, select, source, span, strong, summary, table, tbody, td, template, textarea, th, title, tr, track, u, ul, useEffect, useRef, useState, video };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
4
4
  "description": "Web framework for building web apps and PWAs",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -62,7 +62,6 @@
62
62
  "@types/jest": "^29.2.4",
63
63
  "@typescript-eslint/eslint-plugin": "^5.47.0",
64
64
  "@typescript-eslint/parser": "^5.47.0",
65
- "csstype": "^3.1.2",
66
65
  "eslint": "^8.30.0",
67
66
  "eslint-config-prettier": "^8.5.0",
68
67
  "eslint-plugin-prettier": "^4.2.1",
@@ -71,5 +70,8 @@
71
70
  "ts-jest": "^29.0.3",
72
71
  "tsup": "^6.7.0",
73
72
  "typescript": "^4.9.4"
73
+ },
74
+ "dependencies": {
75
+ "csstype": "^3.1.2"
74
76
  }
75
77
  }