wowojs-cdn 1.3.0 → 1.3.1

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 CHANGED
@@ -9,10 +9,9 @@ Gunakan **Wowojs** langsung di browser tanpa install NPM. Cocok buat prototyping
9
9
  Cukup tempelkan script ini di dalam tag `<head>` atau sebelum penutup `</body>`:
10
10
 
11
11
  ```html
12
- <script src="https://cdn.jsdelivr.net/npm/wowojs-cdn@1.3.0/dist/wowo.min.js"></script>
12
+ <script src="https://cdn.jsdelivr.net/npm/wowojs-cdn@1.3.1/dist/wowo.min.js"></script>
13
13
  <!-- ATAU -->
14
14
  <script src="https://unpkg.com/wowojs-cdn/dist/wowo.min.js"></script>
15
- 1
16
15
  ```
17
16
 
18
17
  ## Contoh penggunaan cepat
@@ -21,7 +20,7 @@ Cukup tempelkan script ini di dalam tag `<head>` atau sebelum penutup `</body>`:
21
20
  <!DOCTYPE html>
22
21
  <html lang="id">
23
22
  <head>
24
- <script src="https://cdn.jsdelivr.net/npm/wowojs-cdn@1.3.0/dist/wowo.min.js"></script>
23
+ <script src="https://cdn.jsdelivr.net/npm/wowojs-cdn@1.3.1/dist/wowo.min.js"></script>
25
24
  </head>
26
25
  <body>
27
26
  <wowo-halo></wowo-halo>
package/dist/wowo.min.js CHANGED
@@ -1 +1 @@
1
- var Wowo=function(e){"use strict";function t({namaWilayah:e,isiWilayah:t,style:a="",methods:o={},deskripsi:r,noShadow:i=!1}){n({modul:"Component: $BuatWilayah",detail:{namaWilayah:e,isiWilayah:t,style:a||"tidak ada",methods:o||"tidak ada",deskripsi:r||"tidak ada",noShadow:i||!1}});const s=`wowo-${e.toLowerCase()}`;customElements.get(s)||customElements.define(s,class extends HTMLElement{constructor(){super(),i||this.attachShadow({mode:"open"})}connectedCallback(){this.render()}getProps(){const e={};for(let t of this.attributes)e[t.name]=t.value;return e}render(){const e=this.getProps(),n="function"==typeof t?t(e):t;let r=a?`<style>${a}</style>`:"";const s=i?this:this.shadowRoot;if(s){s.innerHTML=n+r;s.querySelectorAll("*").forEach(t=>{[...t.attributes].forEach(a=>{if(a.name.startsWith("@")){const n=a.name.slice(1),r=a.value.replace("()","");o[r]&&(t.addEventListener(n,t=>{o[r](t,e),this.render()}),t.removeAttribute(a.name))}})})}}})}function a(e,t){if(n({modul:"State: $antek2",detail:{nama:e,value:t}}),1===arguments.length){if(void 0!==cacheAntek[e])return cacheAntek[e];const t=sessionStorage.getItem(e);try{const a=null!==t?JSON.parse(t):null;return cacheAntek[e]=a,a}catch(r){return console.error(`Data "${e}" korup, isinya:`,t),null}}let o;if("function"==typeof t){o=t(a(e))}else o=t;try{const t=JSON.stringify(o);return sessionStorage.setItem(e,t),cacheAntek[e]=o,o}catch(r){return console.error(`Gagal menyimpan "${e}":`,r),o}}function n({modul:e,detail:t,aktif:a=!1}){history.push({waktu:(new Date).toLocaleTimeString(),modul:e,detail:t}),a&&console.dir(history)}function o(e){window.history.pushState({},"",e),window.dispatchEvent(new PopStateEvent("popstate"))}return window.$BuatWilayah=t,window.$antek2=a,window.$PecatAntek2=function(e){n({modul:"State: $PecatAntek2",detail:{nama:e}}),delete cacheAntek[e],sessionStorage.removeItem(e)},window.$BangunEkonomi=function(e){n({modul:"Render: $BangunEkonomi",detail:e}),(Array.isArray(e)?e:[e]).forEach(e=>{!function(e){const t=()=>{const t=document.querySelectorAll(e);t.length>0?t.forEach(e=>{"function"==typeof e.render&&e.render()}):console.warn(`[WowoJS] Gagal bangun ekonomi: ${e} tidak ditemukan di DOM.`)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}(e)})},window.$UrusKeuangan=function(e,t){n({modul:"Reducer: $UrusKeuangan",detail:[{reducer:e,action:t}]});try{return e(t)}catch(a){console.error(`terjadi error ${e} \n ${a}`)}},window.$CuriData=async function({data:e,state:t,request:o={},reload:r=!1}){try{const i={cache:"no-store",...o},s=await fetch(e,i);if(!s.ok)throw new Error(`Status: ${s.status} - Lu mau curi apa? Gak ada datanya!`);const c=await s.json();if(null===c||"object"!=typeof c)throw new Error(`Data dari ${e} bukan JSON yang bener, kocak`);return a(t,c),n({modul:"API: $CuriData",detail:{data:e,state:t}}),r&&requestAnimationFrame(()=>{const e=document.querySelector("wowo-router");e&&"function"==typeof e.render&&e.render()}),c}catch(i){return console.error("[WowoJS Error] Gagal curi data:",i.message),null}},window.$Sejarah=n,window.$Ke=o,window.$Router=function(e){const n=()=>{const t=window.location.pathname||"/",n=(o=t).length>1&&o.endsWith("/")?o.slice(0,-1):o;var o;let r={},i=null;for(const a of e){let e=a.route.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/:(\w+)/g,"([^/]+)");const t=new RegExp("^"+e+"$"),o=n.match(t);if(o){i=a;(a.route.match(/:(\w+)/g)||[]).map(e=>e.slice(1)).forEach((e,t)=>{r[e]=o[t+1]});break}}if(i||(i=e.find(e=>"*"===e.route)),i){a("params",r||{}),a("halaman_aktif",Array.isArray(i.wilayah)?i.wilayah[0]:i.wilayah),queueMicrotask(()=>{const e=document.querySelector("wowo-router");e&&"function"==typeof e.render&&e.render()})}};n(),t({namaWilayah:"router",noShadow:!0,isiWilayah:()=>a("halaman_aktif")||""});const r=e=>{const t=e.target.closest("a");if(t&&t.href.startsWith(window.location.origin)){const a=t.getAttribute("href");!a||a.startsWith("#")||t.target||(e.preventDefault(),o(a))}};window.removeEventListener("click",r),window.addEventListener("click",r),window.onpopstate=()=>n()},e.$Ke=o,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
1
+ var Wowo=function(e){"use strict";function t({namaWilayah:e,isiWilayah:t,style:a="",methods:n={},deskripsi:r,noShadow:i=!1}){o({modul:"Component: $BuatWilayah",detail:{namaWilayah:e,isiWilayah:t,style:a||"tidak ada",methods:n||"tidak ada",deskripsi:r||"tidak ada",noShadow:i||!1}});const c=`wowo-${e.toLowerCase()}`;customElements.get(c)||customElements.define(c,class extends HTMLElement{constructor(){super(),i||this.attachShadow({mode:"open"})}connectedCallback(){this.render()}getProps(){const e={};for(let t of this.attributes)e[t.name]=t.value;return e}render(){const e=this.getProps(),o="function"==typeof t?t(e):t;let r=a?`<style>${a}</style>`:"";const c=i?this:this.shadowRoot;if(c){c.innerHTML=o+r;c.querySelectorAll("*").forEach(t=>{[...t.attributes].forEach(a=>{if(a.name.startsWith("@")){const o=a.name.slice(1),r=a.value.replace("()","");n[r]&&(t.addEventListener(o,t=>{n[r](t,e),this.render()}),t.removeAttribute(a.name))}})})}}})}function a(e,t){if(o({modul:"State: $antek2",detail:{nama:e,value:t}}),1===arguments.length){if(void 0!==cacheAntek[e])return cacheAntek[e];const t=sessionStorage.getItem(e);try{const a=null!==t?JSON.parse(t):null;return cacheAntek[e]=a,a}catch(r){return console.error(`Data "${e}" korup, isinya:`,t),null}}let n;if("function"==typeof t){n=t(a(e))}else n=t;try{const t=JSON.stringify(n);return sessionStorage.setItem(e,t),cacheAntek[e]=n,n}catch(r){return console.error(`Gagal menyimpan "${e}":`,r),n}}let n=[];function o({modul:e,detail:t,aktif:a=!1}){n.push({waktu:(new Date).toLocaleTimeString(),modul:e,detail:t}),a&&console.dir(n)}function r(e){window.history.pushState({},"",e),window.dispatchEvent(new PopStateEvent("popstate"))}return window.$BuatWilayah=t,window.$antek2=a,window.$PecatAntek2=function(e){o({modul:"State: $PecatAntek2",detail:{nama:e}}),delete cacheAntek[e],sessionStorage.removeItem(e)},window.$BangunEkonomi=function(e){o({modul:"Render: $BangunEkonomi",detail:e}),(Array.isArray(e)?e:[e]).forEach(e=>{!function(e){const t=()=>{const t=document.querySelectorAll(e);t.length>0?t.forEach(e=>{"function"==typeof e.render&&e.render()}):console.warn(`[WowoJS] Gagal bangun ekonomi: ${e} tidak ditemukan di DOM.`)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}(e)})},window.$UrusKeuangan=function(e,t){o({modul:"Reducer: $UrusKeuangan",detail:[{reducer:e,action:t}]});try{return e(t)}catch(a){console.error(`terjadi error ${e} \n ${a}`)}},window.$CuriData=async function({data:e,state:t,request:n={},reload:r=!1}){try{const i={cache:"no-store",...n},c=await fetch(e,i);if(!c.ok)throw new Error(`Status: ${c.status} - Lu mau curi apa? Gak ada datanya!`);const s=await c.json();if(null===s||"object"!=typeof s)throw new Error(`Data dari ${e} bukan JSON yang bener, kocak`);return a(t,s),o({modul:"API: $CuriData",detail:{data:e,state:t}}),r&&requestAnimationFrame(()=>{const e=document.querySelector("wowo-router");e&&"function"==typeof e.render&&e.render()}),s}catch(i){return console.error("[WowoJS Error] Gagal curi data:",i.message),null}},window.$Sejarah=o,window.$Ke=r,window.$Router=function(e){const n=()=>{const t=window.location.pathname||"/",n=(o=t).length>1&&o.endsWith("/")?o.slice(0,-1):o;var o;let r={},i=null;for(const a of e){let e=a.route.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/:(\w+)/g,"([^/]+)");const t=new RegExp("^"+e+"$"),o=n.match(t);if(o){i=a;(a.route.match(/:(\w+)/g)||[]).map(e=>e.slice(1)).forEach((e,t)=>{r[e]=o[t+1]});break}}if(i||(i=e.find(e=>"*"===e.route)),i){a("params",r||{}),a("halaman_aktif",Array.isArray(i.wilayah)?i.wilayah[0]:i.wilayah),queueMicrotask(()=>{const e=document.querySelector("wowo-router");e&&"function"==typeof e.render&&e.render()})}};n(),t({namaWilayah:"router",noShadow:!0,isiWilayah:()=>a("halaman_aktif")||""});const o=e=>{const t=e.target.closest("a");if(t&&t.href.startsWith(window.location.origin)){const a=t.getAttribute("href");!a||a.startsWith("#")||t.target||(e.preventDefault(),r(a))}};window.removeEventListener("click",o),window.addEventListener("click",o),window.onpopstate=()=>n()},e.$Ke=r,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wowojs-cdn",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Akses wowojs lewat CDN",
5
5
  "main": "wowo.js",
6
6
  "unpkg": "dist/wowo.min.js",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "keywords": [],
13
13
  "author": "",
14
- "license": "ISC",
14
+ "license": "MIT",
15
15
  "dependencies": {
16
16
  "vite": "^7.3.1",
17
17
  "wowojs": "^1.5.0"
package/wowo.js CHANGED
@@ -233,7 +233,7 @@ function $UrusKeuangan(reducer, action) {
233
233
  ${error}`);
234
234
  }
235
235
  }
236
-
236
+ let history = [];
237
237
  function $Sejarah({ modul, detail, aktif = false }) {
238
238
  history.push({
239
239
  waktu: new Date().toLocaleTimeString(),