amateras 0.14.0 → 0.15.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.
Files changed (149) hide show
  1. package/README.md +12 -12
  2. package/build/core.js +1 -1
  3. package/build/css-keyframes.js +1 -1
  4. package/build/css-property.js +1 -1
  5. package/build/css-variable.js +1 -1
  6. package/build/css.js +1 -1
  7. package/build/for.js +1 -1
  8. package/build/i18n.js +1 -1
  9. package/build/idb.js +1 -1
  10. package/build/if.js +1 -1
  11. package/build/import-map.js +1 -1
  12. package/build/markdown.js +1 -1
  13. package/build/match.js +1 -1
  14. package/build/meta.js +1 -1
  15. package/build/prefetch.js +1 -1
  16. package/build/router.js +1 -1
  17. package/build/signal.js +1 -1
  18. package/build/store.js +1 -1
  19. package/build/ui.js +1 -1
  20. package/build/utils.js +1 -1
  21. package/build/widget.js +1 -1
  22. package/package.json +1 -1
  23. package/packages/core/src/index.ts +43 -34
  24. package/packages/core/src/lib/hmr.ts +119 -133
  25. package/packages/core/src/lib/virtual_scroll.ts +29 -0
  26. package/packages/core/src/structure/ElementProto.ts +42 -45
  27. package/packages/core/src/structure/GlobalState.ts +5 -5
  28. package/packages/core/src/structure/NodeProto.ts +20 -8
  29. package/packages/core/src/structure/Proto.ts +65 -47
  30. package/packages/core/src/structure/ProxyProto.ts +2 -2
  31. package/packages/core/src/structure/TextProto.ts +1 -0
  32. package/packages/css/src/ext/fluent.ts +18 -0
  33. package/packages/css/src/ext/keyframes.ts +5 -6
  34. package/packages/css/src/ext/property.ts +6 -7
  35. package/packages/css/src/ext/variable.ts +7 -8
  36. package/packages/css/src/index.ts +13 -13
  37. package/packages/css/src/lib/cache.ts +2 -1
  38. package/packages/css/src/lib/colorAssign.ts +3 -3
  39. package/packages/css/src/lib/createRule.ts +4 -4
  40. package/packages/css/src/structure/$CSSFluent.ts +73 -0
  41. package/packages/css/src/structure/$CSSProperty.ts +2 -2
  42. package/packages/css/src/structure/$CSSRule.ts +6 -6
  43. package/packages/for/src/global.ts +12 -2
  44. package/packages/for/src/structure/For.ts +26 -25
  45. package/packages/hmr/src/index.ts +28 -3
  46. package/packages/i18n/src/index.ts +7 -7
  47. package/packages/i18n/src/structure/I18n.ts +2 -2
  48. package/packages/i18n/src/structure/I18nDictionary.ts +4 -4
  49. package/packages/i18n/src/structure/I18nSession.ts +4 -4
  50. package/packages/i18n/src/structure/I18nTranslation.ts +3 -3
  51. package/packages/i18n/src/types.ts +4 -5
  52. package/packages/idb/src/index.ts +3 -3
  53. package/packages/idb/src/lib/$IDBRequest.ts +1 -3
  54. package/packages/idb/src/structure/$IDB.ts +6 -6
  55. package/packages/idb/src/structure/$IDBCursor.ts +2 -2
  56. package/packages/idb/src/structure/$IDBIndex.ts +2 -2
  57. package/packages/idb/src/structure/$IDBStore.ts +2 -2
  58. package/packages/idb/src/structure/$IDBStoreBase.ts +0 -1
  59. package/packages/idb/src/structure/$IDBTransaction.ts +3 -3
  60. package/packages/idb/src/structure/builder/$IDBBuilder.ts +25 -25
  61. package/packages/idb/src/structure/builder/$IDBStoreBuilder.ts +1 -1
  62. package/packages/if/src/index.ts +6 -6
  63. package/packages/if/src/structure/Condition.ts +17 -10
  64. package/packages/if/src/structure/ConditionStatement.ts +8 -3
  65. package/packages/markdown/src/lib/util.ts +2 -2
  66. package/packages/markdown/src/structure/MarkdownLexer.ts +3 -3
  67. package/packages/markdown/src/structure/MarkdownParser.ts +3 -3
  68. package/packages/markdown/src/syntax/alert.ts +2 -2
  69. package/packages/markdown/src/syntax/link.ts +2 -2
  70. package/packages/markdown/src/syntax/list.ts +3 -3
  71. package/packages/markdown/src/syntax/table.ts +2 -2
  72. package/packages/match/src/index.ts +5 -5
  73. package/packages/match/src/structure/Case.ts +2 -2
  74. package/packages/match/src/structure/Match.ts +14 -8
  75. package/packages/meta/src/index.ts +5 -5
  76. package/packages/meta/src/lib/resolveMeta.ts +5 -5
  77. package/packages/prefetch/src/index.ts +60 -15
  78. package/packages/router/src/index.ts +7 -7
  79. package/packages/router/src/structure/Link.ts +2 -2
  80. package/packages/router/src/structure/NavLink.ts +14 -3
  81. package/packages/router/src/structure/Page.ts +4 -4
  82. package/packages/router/src/structure/Route.ts +6 -6
  83. package/packages/router/src/structure/RouteNode.ts +3 -3
  84. package/packages/router/src/structure/RouteSlot.ts +5 -5
  85. package/packages/router/src/structure/Router.ts +37 -26
  86. package/packages/router/src/structure/RouterConstructor.ts +3 -4
  87. package/packages/signal/src/index.ts +14 -14
  88. package/packages/signal/src/structure/Signal.ts +25 -25
  89. package/packages/store/src/index.ts +2 -2
  90. package/packages/store/src/structure/Store.ts +2 -2
  91. package/packages/ui/src/index.ts +5 -2
  92. package/packages/ui/src/lib/float.ts +29 -17
  93. package/packages/ui/src/lib/toCSS.ts +7 -3
  94. package/packages/ui/src/structure/Accordion.ts +5 -5
  95. package/packages/ui/src/structure/Badge.ts +2 -2
  96. package/packages/ui/src/structure/Button.ts +8 -3
  97. package/packages/ui/src/structure/Card.ts +6 -6
  98. package/packages/ui/src/structure/Combobox/Combobox.ts +57 -64
  99. package/packages/ui/src/structure/Combobox/ComboboxChips.ts +108 -56
  100. package/packages/ui/src/structure/Combobox/ComboboxList.ts +54 -55
  101. package/packages/ui/src/structure/ContextMenu.ts +8 -8
  102. package/packages/ui/src/structure/DescriptionList.ts +6 -5
  103. package/packages/ui/src/structure/Field.ts +30 -7
  104. package/packages/ui/src/structure/Icon.ts +2 -2
  105. package/packages/ui/src/structure/Input.ts +4 -17
  106. package/packages/ui/src/structure/Radio.ts +5 -6
  107. package/packages/ui/src/structure/Searchbar.ts +209 -0
  108. package/packages/ui/src/structure/Select/Select.ts +21 -27
  109. package/packages/ui/src/structure/Select/SelectArrow.ts +2 -2
  110. package/packages/ui/src/structure/Select/SelectContent.ts +25 -21
  111. package/packages/ui/src/structure/Select/SelectItem.ts +33 -76
  112. package/packages/ui/src/structure/Select/SelectTrigger.ts +27 -7
  113. package/packages/ui/src/structure/Select/SelectValue.ts +7 -7
  114. package/packages/ui/src/structure/Slideshow.ts +5 -5
  115. package/packages/ui/src/structure/Switch.ts +4 -2
  116. package/packages/ui/src/structure/Tabs.ts +8 -8
  117. package/packages/ui/src/structure/TextArea.ts +22 -0
  118. package/packages/ui/src/structure/TextBlock.ts +17 -0
  119. package/packages/ui/src/structure/Toast.ts +101 -0
  120. package/packages/ui/src/structure/Toggle.ts +6 -6
  121. package/packages/ui/src/structure/Waterfall.ts +60 -24
  122. package/packages/ui/src/{lib → style}/combobox_style.ts +1 -1
  123. package/packages/ui/src/style/content_style.ts +18 -0
  124. package/packages/ui/src/style/input_style.ts +19 -0
  125. package/packages/utils/package.json +2 -1
  126. package/packages/utils/src/index.bun.ts +2 -2
  127. package/packages/utils/src/index.ts +3 -2
  128. package/packages/utils/src/lib/array.ts +1 -0
  129. package/packages/utils/src/lib/call.ts +1 -0
  130. package/packages/utils/src/lib/debounce.ts +18 -0
  131. package/packages/utils/src/lib/forEach.ts +25 -0
  132. package/packages/utils/src/lib/isEqual.ts +30 -0
  133. package/packages/utils/src/lib/json.ts +2 -0
  134. package/packages/utils/src/lib/map.ts +11 -0
  135. package/packages/utils/src/lib/object.ts +3 -0
  136. package/packages/utils/src/lib/primitive.ts +2 -0
  137. package/packages/utils/src/lib/randstr.ts +13 -0
  138. package/packages/utils/src/lib/remove.ts +1 -0
  139. package/packages/utils/src/lib/sleep.ts +1 -0
  140. package/packages/utils/src/lib/toArray.ts +3 -0
  141. package/packages/utils/src/lib/trycatch.ts +17 -0
  142. package/packages/utils/src/lib/type.ts +16 -0
  143. package/packages/utils/src/lib/uppercase.ts +7 -0
  144. package/packages/utils/src/lib/url.ts +7 -0
  145. package/packages/utils/src/lib/utils.ts +17 -152
  146. package/packages/utils/src/structure/UID.ts +2 -2
  147. package/packages/widget/src/index.ts +3 -3
  148. package/packages/widget/src/structure/Widget.ts +8 -5
  149. package/packages/ui/src/structure/WaterfallItem.ts +0 -21
package/README.md CHANGED
@@ -64,19 +64,19 @@ $.render(Counter, 'body');
64
64
 
65
65
  | Modules | Size | Gziped | Description |
66
66
  | --- | --- | --- | --- |
67
- | core | 7.94 kB | 3.14 kB | Core module |
68
- | widget | 0.23 kB | 0.10 kB | Component module |
69
- | signal | 3.03 kB | 1.13 kB | Reactive data module |
67
+ | core | 8.33 kB | 3.31 kB | Core module |
68
+ | widget | 0.45 kB | 0.14 kB | Component module |
69
+ | signal | 3.02 kB | 1.10 kB | Reactive data module |
70
70
  | store | 0.51 kB | 0.19 kB | Access data between widgets |
71
- | css | 1.63 kB | 0.72 kB | CSS-in-JS module |
72
- | for | 1.21 kB | 0.39 kB | For loop control-flow |
73
- | if | 4.18 kB | 1.50 kB | If/Else/ElseIf control-flow |
74
- | match | 1.42 kB | 0.42 kB | Match/Case/Default control-flow |
75
- | router | 6.52 kB | 2.40 kB | Router module |
76
- | i18n | 3.38 kB | 1.16 kB | Translation module |
77
- | idb | 5.31 kB | 2.01 kB | IndexedDB module |
78
- | markdown | 7.48 kB | 2.93 kB | Markdown to HTML module |
79
- | prefetch | 0.72 kB | 0.34 kB | SSR data prefetch |
71
+ | css | 1.64 kB | 0.72 kB | CSS-in-JS module |
72
+ | for | 1.25 kB | 0.41 kB | For loop control-flow |
73
+ | if | 4.32 kB | 1.50 kB | If/Else/ElseIf control-flow |
74
+ | match | 1.51 kB | 0.45 kB | Match/Case/Default control-flow |
75
+ | router | 6.70 kB | 2.42 kB | Router module |
76
+ | i18n | 3.38 kB | 1.14 kB | Translation module |
77
+ | idb | 5.37 kB | 2.01 kB | IndexedDB module |
78
+ | markdown | 7.48 kB | 2.91 kB | Markdown to HTML module |
79
+ | prefetch | 1.01 kB | 0.46 kB | SSR data prefetch |
80
80
  | meta | 0.17 kB | 0.08 kB | SSR `meta` tag manager |
81
81
  | ui | 0.00 kB | 0.00 kB | UI components |
82
82
  | utils | 0.00 kB | 0.00 kB | Utilities module |
package/build/core.js CHANGED
@@ -1 +1 @@
1
- import{forEach as t,_Object_assign as e,_null as s,map as i,_Array_from as o,_Object_entries as r,isFunction as n,isUndefined as l,isNull as h,toArray as a,_instanceof as d,isString as p,isArray as c}from"@amateras/utils";const u=window,f=document,m=t=>!t||t(),b=t=>!1,g=/* @__PURE__ */Symbol("ProtoType"),P=/* @__PURE__ */Symbol("Statement"),y=/* @__PURE__ */Symbol("Signal");class v{static disposers=/* @__PURE__ */new Set;promises=/* @__PURE__ */new Set;root;static initials=/* @__PURE__ */new Set;constructor(s){t(v.initials,t=>{const s=t(this);s&&e(this,s)}),this.root=s,s.listen("dispose",()=>this.dispose())}dispose(){this.promises.clear(),this.root=s,t(v.disposers,t=>t(this))}static assign(t){this.initials.add(t)}asyncTask(t){return this.promises.add(t),t.finally(()=>this.promises.delete(t)),t}}class M{static proto=s;static[g]="Proto";static[P]=!1;layout;parent=s;global=M.proto?.global??new v(this);sibling=s;firstProto=s;lastProto=s;builded=!1;visible=!0;listeners=s;constructor(t){this.layout=t??s}dispose(){this.dispatch("dispose",[this]),t(this.protos,t=>t.dispose()),this.global=s,this.sibling=s,this.firstProto=s,this.lastProto=s,this.parent=s,this.layout=s}get children(){return i(Array.from(this.protos).filter(t=>t.visible),t=>t.constructor[P]?t.children:t).flat()}get protos(){let t=/* @__PURE__ */new Set,e=this.firstProto;if(e){let s=e;for(;s;)t.add(s),s=s.sibling}return t}append(...e){t(e,t=>{if(t.parent!==this&&t.parent?.removeProtos(t),this.lastProto){if(this.lastProto===t)return;this.firstProto===t&&(this.firstProto=t.sibling),t.sibling=s,this.lastProto.sibling=t,this.lastProto=t}else this.firstProto=t,this.lastProto=t;t.parent=this,t.global=this.global})}replaceProtos(...t){this.clear(),this.processProtos(...t)}insert(t,e=-1){if(0===e)this.firstProto&&(t.sibling=this.firstProto),this.firstProto=t;else{let s=o(this.protos),i=e<0?s.length+e+1:e;s.splice(i,0,t),this.processProtos(...s)}t.parent=this,t.global=this.global}remove(){this.parent?.removeProtos(this)}removeProtos(...e){let s=this.protos;t(e,t=>{t.parent=null,t.sibling=null,s.delete(t)}),this.processProtos(...s)}processProtos(...e){let i=s;e.length?t(e,(t,e)=>{0===e&&(this.firstProto=t),i&&(i.sibling=t),t.sibling=s,i=t,t.parent=this}):this.firstProto=s,this.lastProto=i}build(e=!0,s=!0){return s&&this.clear(!0),$.context(M,this,()=>this.layout?.(this)),this.builded=!0,e&&t(this.protos,t=>{t.build()}),this.dispatch("builded",[this]),this}toString(){return i(o(this.protos).filter(t=>t.visible),t=>`${t}`).join("")}toDOM(t=!0){return t?i(o(this.protos).filter(t=>t.visible),e=>e.toDOM(t)).flat():[]}ondispose(t){this.listen("dispose",t)}removeNode(){t(this.protos,t=>t.removeNode())}clear(e=!1){let s=this.protos;this.removeProtos(...s),e&&t(s,t=>t.dispose())}findAbove(t){let e=this.parent;return e?t(e)?e:e.findAbove(t):s}findBelow(t){for(let e of this.protos){if(t(e))return e;let s=e.findBelow(t);if(s)return s}return s}findBelowAll(t){let e=[];for(let s of this.protos)t(s)&&e.push(s),e.push(...s.findBelowAll(t));return e}mutate(){}get text(){return this.children.map(t=>t.text).join("")}dispatch(e,s,i){let o=this.listeners?.[e],r=!1;if(i?.bubbles){let t=this.parent?.dispatch(e,s,i);r||(r=t??!1)}return t(o,t=>{let e=t(...s)??!1;r||(r=e)}),r}listen(t,e){let s=this.listeners??{};this.listeners=s;let i=s[t]??/* @__PURE__ */new Set;this.listeners[t]=i,i.add(e)}}class w extends M{node=s;constructor(t){super(t)}ondom(t){this.listen("dom",t)}dispose(){super.dispose(),this.node=s}inDOM(){return!!m()&&document.contains(this.node)}removeNode(){this.node?.remove()}}const S=["img","hr","br","input","link","meta"];class _ extends w{tagname;#t={};#e="";__props__;constructor(t,e,s){super(()=>s?.(this)),this.tagname=t,this.__props__=e}dispose(){super.dispose(),this.layout=null}build(t){return this.__props__&&(this.props(this.__props__),this.__props__=s),super.build(t),this}props({...e}){let{class:s,...i}=e;s&&this.addClass(...s.split(" ")),t(r(i),([t,e])=>{t.startsWith("on")&&n(e)&&(this.on(t.replace("on",""),e),delete i[t])}),this.attrProcess(i)}on(t,e,s){let i=i=>{i.addEventListener(t,e,s),this.listen("dispose",()=>this.node?.removeEventListener(t,e))};this.node?i(this.node):this.listen("dom",i)}toString(){return this.parseHTML()}parseHTML(t){let e=this.tagname,s=t?.children??(this.#e||i(this.protos,t=>t.visible?`${t}`:"").join("")),o=t?.attr??i(r(this.#t),([t,e])=>e.length?`${t}="${e}"`:t).join(" "),n=o.length?" "+o:"";return S.includes(e)?`<${e}${n} />`:`<${e}${n}>${s}</${e}>`}toDOM(e=!0){let s=this.node??document.createElement(this.tagname);return this.node=s,this.#e&&this.node.innerHTML!==this.#e?this.node.innerHTML=this.#e:e&&this.DOMProcess(),t(r(this.#t),([t,e])=>s.setAttribute(t,e)),this.dispatch("dom",[this.node]),[s]}DOMProcess(){let e=this.node;if(e){let r=i(o(this.protos).filter(t=>t.visible),t=>t.toDOM()).flat(),n=s;t(r,(t,i)=>{let o=e.childNodes[i];o!==t&&(n=r.includes(o)?e.childNodes[i+1]??s:o??s,e.insertBefore(t,n))})}}attrProcess(e){t(r(e),([t,e])=>{for(let s of $.process.attr){let i=s(t,e,this);if(!l(i))return}this.attr(t,e)})}innerHTML(t){this.#e=t,this.node&&(this.node.innerHTML=t)}attr(t,e){return arguments.length?l(e)?this.#t[t]??s:(h(e)?(delete this.#t[t],this.node?.removeAttribute(t)):(this.#t[t]=e,this.node?.setAttribute(t,e)),this):this.#t}addClass(...t){this.token("add","class",...t),this.node?.classList.add(...t)}removeClass(...t){this.token("delete","class",...t),this.node?.classList.remove(...t)}style(t){let s=()=>this.node&&e(this.node.style,t);s(),this.node||this.ondom(s)}token(e,s,...i){let r=this.#t[s],n=new Set(r?.split(" ")??[]);t(i,t=>n[e](t)),this.#t[s]=o(n).join(" ")}}class T extends w{#s;constructor(t){super(),this.#s=t}get content(){return this.#s}set content(t){this.#s=t,this.node&&(this.node.textContent=t)}toString(){return this.#s}toDOM(){if(this.node)return[this.node];let t=new Text(this.#s);return this.node=t,this.dispatch("dom",[this.node]),[t]}get text(){return this.#s}}class L extends w{constructor(t){super(t),m()&&(this.node=new Text)}toDOM(){return[this.node,...super.toDOM()]}removeNode(){super.removeNode(),t(this.protos,t=>t.removeNode())}}function x(e,...i){const o=M.proto,r=[],h=t=>{e&&o?.append(t),r.push(t)};for(let t of H.process.craft){let e=t(...i);if(!l(e))return h(e),e}const[a,u,f]=i;if(d(a,M))return h(a),a;if(p(a)){let t=n(u)?[,u]:[u,f],e=new _(a,...t);return h(e),e}if(n(a)){let t=u?[u,f]:[f];d(a.prototype,_)&&(t=n(u)?[{},u]:[u,f]);let e=new a(...t);if(d(e,M))return h(e),e}if(c(a)){let e=t=>{for(let s of H.process.text){let e=s(t);if(!l(e))return h(e)}let e=l(t)?s:new T(`${t}`);e&&h(e)},[o,...n]=i;return o.raw?t(o,(t,i)=>{let o=t.length?new T(t):s,r=n[i];o&&h(o),e(r)}):t(o,t=>e(t)),r}}function H(...t){return x(!0,...t)}var D;(D=H||(H={})).process={craft:/* @__PURE__ */new Set,text:/* @__PURE__ */new Set,attr:/* @__PURE__ */new Set},D.craft=(...t)=>x(!1,...t),D.render=(t,e)=>{let s=D(t).build().toDOM();document.querySelector(e)?.replaceChildren(...s)},D.context=(t,e,s)=>{let i=t.proto;t.proto=e,s(),t.proto=i},D.call=t=>t(),D.match=(t,e)=>{var s=/* @__PURE__ */new Map,i=/* @__PURE__ */Symbol("default"),o={case:(t,e)=>(s.set(t,e),o),default:t=>(s.set(i,t),o)};return e(o),s.get(t)?.()??s.get(i)?.()},D.tuple=(...t)=>t,D.async=t=>M.proto?.global.asyncTask(t(M.proto))??t(M.proto),D.stylesheet=m()?new CSSStyleSheet:s,D.styleMap=/* @__PURE__ */new Map,D.style=(e,s)=>{let i=a(s);if(e){let s=D.styleMap.get(e)??/* @__PURE__ */new Set;t(i,t=>s.add(t)),D.styleMap.set(e,s)}D.stylesheet&&t(i,t=>D.stylesheet.insertRule(t))},D.stylesheet&&document.adoptedStyleSheets.push(D.stylesheet),m()&&document.querySelector("style#__ssr__")?.remove(),globalThis.$=H;export{H as $,_ as ElementProto,v as GlobalState,w as NodeProto,M as Proto,L as ProxyProto,T as TextProto,f as _document,u as _window,m as onclient,b as onserver,g as symbol_ProtoType,y as symbol_Signal,P as symbol_Statement};
1
+ import{Utils as t}from"@amateras/utils";const e=window,s=document,i=t=>!t||t(),o=t=>!1,r=/* @__PURE__ */Symbol("ProtoType"),n=/* @__PURE__ */Symbol("Statement"),l=/* @__PURE__ */Symbol("Signal");class h{static disposers=/* @__PURE__ */new Set;promises=/* @__PURE__ */new Set;root;static initials=/* @__PURE__ */new Set;constructor(e){t.forEach(h.initials,e=>{const s=e(this);s&&t.assign(this,s)}),this.root=e,e.listen("dispose",()=>this.dispose())}dispose(){this.promises.clear(),this.root=t.Null,t.forEach(h.disposers,t=>t(this))}static assign(t){this.initials.add(t)}asyncTask(t){return this.promises.add(t),t.finally(()=>this.promises.delete(t)),t}}class a{static proto=t.Null;static[r]="Proto";static[n]=!1;static eventMap=/* @__PURE__ */new WeakMap;layout;parent=t.Null;global=a.proto?.global??new h(this);sibling=t.Null;firstProto=t.Null;lastProto=t.Null;builded=!1;visible=!0;virtual=!1;constructor(e){this.layout=e??t.Null}dispose(e=!0){this.dispatch("dispose",[this]),e&&t.forEach(this.protos,t=>t.dispose()),a.eventMap.delete(this),this.global=t.Null,this.sibling=t.Null,this.firstProto=t.Null,this.lastProto=t.Null,this.parent=t.Null,this.layout=t.Null}get children(){return t.map(this.protos,t=>t.constructor[n]?t.children:t).flat()}get visibleChildren(){return this.children.filter(t=>t.visible)}get protos(){let t=[],e=this.firstProto;if(e){let s=e;for(;s;)t.push(s),s=s.sibling}return t}append(...e){t.forEach(e,e=>{if(e.parent!==this&&e.parent?.removeProtos(e),this.lastProto){if(this.lastProto===e)return;this.firstProto===e&&(this.firstProto=e.sibling),e.sibling=t.Null,this.lastProto.sibling=e,this.lastProto=e}else this.firstProto=e,this.lastProto=e;e.parent=this,e.global=this.global})}replaceProtos(...t){this.clear(),this.processProtos(...t)}replace(t,...e){const s=this.protos;s.splice(s.indexOf(t),1,...e),this.processProtos(...s)}insert(t,e=-1){if(0===e)this.firstProto&&(t.sibling=this.firstProto),this.firstProto=t;else{let s=this.protos,i=e<0?s.length+e+1:e;s.splice(i,0,t),this.processProtos(...s)}t.parent=this,t.global=this.global}remove(){this.parent?.removeProtos(this)}removeProtos(...e){let s=new Set(this.protos);t.forEach(e,t=>{t.parent=null,t.sibling=null,s.delete(t)}),this.processProtos(...s)}processProtos(...e){let s=t.Null;e.length?t.forEach(e,(e,i)=>{0===i&&(this.firstProto=e),s&&(s.sibling=e),e.sibling=t.Null,s=e,e.parent=this}):this.firstProto=t.Null,this.lastProto=s}build(e=!0,s=!0){return s&&this.clear(!0),$.context(a,this,()=>this.layout?.(this)),this.builded=!0,e&&t.forEach(this.protos,t=>{t.build()}),this.dispatch("builded",[this]),this}toString(){return t.map(this.protos.filter(t=>t.visible),t=>`${t}`).join("")}toDOM(e=!0){let s=[];return t.forEach(this.protos,t=>{t.visible?e&&s.push(...t.toDOM()):t.removeNode()}),s}removeNode(){t.forEach(this.protos,t=>t.removeNode())}clear(e=!1){let s=this.protos;this.removeProtos(...s),e&&t.forEach(s,t=>t.dispose())}findAbove(e){let s=this.parent;return s?e(s)?s:s.findAbove(e):t.Null}findBelow(e){for(let t of this.protos){if(e(t))return t;let s=t.findBelow(e);if(s)return s}return t.Null}findBelowAll(t){let e=[];for(let s of this.protos)t(s)&&e.push(s),e.push(...s.findBelowAll(t));return e}mutate(){}get text(){return this.children.map(t=>t.text).join("")}get listeners(){return a.eventMap.get(this)}dispatch(e,s,i){let o=this.listeners?.[e],r=!1;if(i?.bubbles){let t=this.parent?.dispatch(e,s,i);r||(r=t??!1)}return t.forEach(o,t=>{let e=t(...s)??!1;r||(r=e)}),r}listen(t,e){let s=this.listeners??{};a.eventMap.set(this,s);let i=s[t]??/* @__PURE__ */new Set;s[t]=i,i.add(e)}}class d extends a{node=t.Null;constructor(t){super(t)}dispose(){super.dispose(),this.node=t.Null}inDOM(){return!!i()&&document.contains(this.node)}removeNode(){this.node?.remove()}DOMProcess(){let e=this.node;if(e){let s=this.protos,i=t.map(s.filter(t=>t.visible),t=>t.toDOM()).flat(),o=t.Null;t.forEach(i,(s,r)=>{let n=e.childNodes[r];n!==s&&(o=i.includes(n)?e.childNodes[r+1]??t.Null:n??t.Null,e.insertBefore(s,o))})}}}const u=["img","hr","br","input","link","meta"];class c extends d{tagname;#t={};static[r]="Element";#e="";__props__;constructor(t,e,s){super(()=>s?.(this)),this.tagname=t,this.__props__=e}static attrProcess(e,s){t.forEach(t.entries(s),([s,i])=>{for(let o of $.process.attr){let r=o(s,i,e);if(!t.isUndefined(r))return}e.attr(s,i)})}dispose(){super.dispose(),this.layout=null}build(e){return this.__props__&&(this.props(this.__props__),this.__props__=t.Null),super.build(e),this}props({...e}){let{class:s,...i}=e;s&&this.addClass(...s.split(" ")),t.forEach(t.entries(i),([e,s])=>{e.startsWith("on")&&t.isFunction(s)&&(this.on(e.replace("on",""),s),delete i[e])}),c.attrProcess(this,i)}on(t,e,s){let i=i=>{i.addEventListener(t,e,s),this.listen("dispose",()=>this.node?.removeEventListener(t,e))};this.node&&i(this.node),this.listen("dom",i)}toString(){return this.parseHTML()}parseHTML(e){let s=this.tagname,i=e?.children??(this.#e||t.map(this.protos,t=>t.visible?`${t}`:"").join("")),o=e?.attr??t.map(t.entries(this.#t),([t,e])=>e.length?`${t}="${e}"`:t).join(" "),r=o.length?" "+o:"";return u.includes(s)?`<${s}${r} />`:`<${s}${r}>${i}</${s}>`}toDOM(e=!0){super.toDOM();let s=!!this.node,i=this.node??document.createElement(this.tagname);return this.node=i,e&&(this.#e&&!s?this.node.innerHTML=this.#e:s&&!this.virtual||this.DOMProcess()),s||t.forEach(t.entries(this.#t),([t,e])=>i.setAttribute(t,e)),s||this.dispatch("dom",[this.node]),[i]}innerHTML(t){this.#e=t,this.node&&(this.node.innerHTML=t)}attr(e,s){return arguments.length?t.isUndefined(s)?this.#t[e]??t.Null:(t.isNull(s)?(delete this.#t[e],this.node?.removeAttribute(e)):(this.#t[e]=s,this.node?.setAttribute(e,s)),this):this.#t}hasAttr(e){return!t.isNull(this.attr(e))}addClass(...t){this.token("add","class",...t),this.node?.classList.add(...t)}removeClass(...t){this.token("delete","class",...t),this.node?.classList.remove(...t)}style(e){let s=()=>this.node&&t.assign(this.node.style,e);s(),this.node||this.listen("dom",s)}token(e,s,...i){let o=this.#t[s],r=new Set(o?.split(" ")??[]);t.forEach(i,t=>r[e](t)),this.#t[s]=t.arrayFrom(r).join(" ")}}class p extends d{#s;constructor(t){super(),this.#s=t}get content(){return this.#s}set content(t){this.#s=t,this.node&&(this.node.textContent=t)}toString(){return this.#s}toDOM(){if(super.toDOM(),this.node)return[this.node];let t=new Text(this.#s);return this.node=t,this.dispatch("dom",[this.node]),[t]}get text(){return this.#s}}class f extends d{constructor(t){super(t),i()&&(this.node=new Text)}toDOM(){return[this.node,...super.toDOM()]}removeNode(){super.removeNode(),t.forEach(this.protos,t=>t.removeNode())}}const m=t=>{i()&&(document.addEventListener("scroll",()=>b(t),!0),t.listen("dom",e=>new ResizeObserver(()=>b(t)).observe(e)),t.listen("mutate",()=>b(t)),t.virtual=!0)},b=e=>{if(!e.inDOM())return;if(!e.node)return;const s=e.node?.getBoundingClientRect();t.forEach(e.children,e=>{if(!t.isInstanceof(e,c))return;if(!e.node)return;if(e.node.contains(document.activeElement))return e.visible=!0;const{translate:i}=e.node.style,o=i.split(" ")[1],r=s.top+parseInt(o);r+e.node.offsetHeight<-200||r>outerHeight+200?e.visible=!1:e.visible=!0}),e.toDOM()};function g(e,...s){const i=a.proto,o=[],r=t=>{e&&i?.append(t),o.push(t)};for(let a of v.process.craft){let e=a(...s);if(!t.isUndefined(e))return r(e),e}const[n,l,h]=s;if(t.isInstanceof(n,a))return r(n),n;if(t.isString(n)){let e=t.isFunction(l)?[,l]:[l,h],s=new c(n,...e);return r(s),s}if(t.isFunction(n)){let e=l?[l,h]:[h];t.isInstanceof(n.prototype,c)&&(e=t.isFunction(l)?[{},l]:[l,h]);let s=new n(...e);if(t.isInstanceof(s,a))return r(s),s}if(t.isArray(n)){let e=e=>{for(let i of v.process.text){let s=i(e);if(!t.isUndefined(s))return r(s)}let s=t.isUndefined(e)?t.Null:new p(`${e}`);s&&r(s)},[i,...n]=s;return i.raw?t.forEach(i,(s,i)=>{let o=s.length?new p(s):t.Null,l=n[i];o&&r(o),e(l)}):t.forEach(i,t=>e(t)),o}}function v(...t){return g(!0,...t)}var N;(N=v||(v={})).process={craft:/* @__PURE__ */new Set,text:/* @__PURE__ */new Set,attr:/* @__PURE__ */new Set},N.craft=(...t)=>g(!1,...t),N.render=async(t,e)=>{let s=N(t),o=s.build().toDOM(),r=document.querySelector(e);r&&(await Promise.all(s.global.promises),r?.replaceChildren(...o),i()&&document.querySelector("style#__ssr__")?.remove())},N.context=(t,e,s)=>{let i=t.proto;t.proto=e,s(),t.proto=i},N.match=(t,e)=>{var s=/* @__PURE__ */new Map,i=/* @__PURE__ */Symbol("default"),o={case:(t,e)=>(s.set(t,e),o),default:t=>(s.set(i,t),o)};return e(o),s.get(t)?.()??s.get(i)?.()},N.tuple=(...t)=>t,N.async=t=>a.proto?.global.asyncTask(t(a.proto))??t(a.proto),N.stylesheet=i()?new CSSStyleSheet:t.Null,N.styleMap=/* @__PURE__ */new Map,N.style=(e,s)=>{let i=t.toArray(s);if(e){let s=N.styleMap.get(e)??/* @__PURE__ */new Set;t.forEach(i,t=>s.add(t)),N.styleMap.set(e,s)}N.stylesheet&&t.forEach(i,t=>N.stylesheet.insertRule(t))},N.stylesheet&&document.adoptedStyleSheets.push(N.stylesheet),N.stylesheet?.insertRule("@layer base, ui"),globalThis.$=v;export{v as $,c as ElementProto,h as GlobalState,d as NodeProto,a as Proto,f as ProxyProto,p as TextProto,m as VirtualScroll,s as _document,e as _window,i as onclient,o as onserver,r as symbol_ProtoType,l as symbol_Signal,n as symbol_Statement};
@@ -1 +1 @@
1
- import{_null as e,map as t,_Object_entries as s,isString as r,isNumber as a,_instanceof as l,_JSON_stringify as n,_Object_assign as c,_Object_fromEntries as o,UID as i}from"@amateras/utils";const p=/* @__PURE__ */new Set,u=$.call(()=>/* @__PURE__ */new Map);class f{}class h extends f{declarations=/* @__PURE__ */new Map;rules=/* @__PURE__ */new Map;selector;parent=e;css;constructor(e,t,s){super(),this.selector=e,this.parent=s,t&&m(this,t),this.css=t}toString(){let e=t(this.declarations,([e,t])=>`${e.replaceAll(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${t};`),s=t(this.rules,([e,t])=>`${t}`);return`${this.selector} { ${[...e,...s].join(" ")} }`}}const m=(e,t)=>{for(let[n,c]of s(t))if("__selector__"!==n)if(r(c)||a(c)||l(c,f))e.declarations.set(n,`${c}`);else{let t=e.selector.startsWith("@")&&!e.parent?n:`${/^[@]|&/.test(n)?n:`& ${n}`}`;e.rules.set(t,new h(t,c,e))}};class w extends f{name;constructor(e){super(),this.name=e}toString(){return`${this.name.replace("@keyframes ","")}`}}const d="@keyframes ";c($.css,{keyframes:r=>o(t(s(r),([t,s])=>{let r=((t,s,r=!0)=>{let a=r?n(s):"";if(r){let e=u.get(a);if(e)return e}let l=new h(t(),s,e);return $.style(e,`${l}`),r&&u.set(a,l),l})(()=>`${d}${t}_${i.generate("css-keyframes")}`,s);return p.add(r),[t,new w(r.selector.replace(`${d} `,""))]}))});export{w as $CSSKeyframes};
1
+ import{Utils as e,UID as s}from"@amateras/utils";const t=/* @__PURE__ */new Set,r=e.call(()=>/* @__PURE__ */new Map);class n{}class a extends n{declarations=/* @__PURE__ */new Map;rules=/* @__PURE__ */new Map;selector;parent=e.Null;css;constructor(e,s,t){super(),this.selector=e,this.parent=t,s&&l(this,s),this.css=s}toString(){let s=e.map(this.declarations,([e,s])=>`${e.replaceAll(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${s};`),t=e.map(this.rules,([e,s])=>`${s}`);return`${this.selector} { ${[...s,...t].join(" ")} }`}}const l=(s,t)=>{for(let[r,l]of e.entries(t))if("__selector__"!==r)if(e.isString(l)||e.isNumber(l)||e.isInstanceof(l,n))s.declarations.set(r,`${l}`);else{let e=s.selector.startsWith("@")&&!s.parent?r:`${/^[@]|&/.test(r)?r:`& ${r}`}`;s.rules.set(e,new a(e,l,s))}};class i extends n{name;constructor(e){super(),this.name=e}toString(){return`${this.name.replace("@keyframes ","")}`}}const c="@keyframes ";e.assign($.css,{keyframes:n=>e.fromEntries(e.map(e.entries(n),([n,l])=>{let o=((s,t,n=!0)=>{let l=n?e.stringify(t):"";if(n){let e=r.get(l);if(e)return e}let i=new a(s(),t,e.Null);return $.style(e.Null,`${i}`),n&&r.set(l,i),i})(()=>`${c}${n}_${s.generate("css-keyframes")}`,l);return t.add(o),[n,new i(o.selector.replace(`${c} `,""))]}))});export{i as $CSSKeyframes};
@@ -1 +1 @@
1
- import{_null as e,map as t,_Object_entries as r,isString as s,isNumber as i,_instanceof as l,_JSON_stringify as a,_Object_assign as n,UID as o,isUndefined as c,forEach as p}from"@amateras/utils";const u=/* @__PURE__ */new Set,h=$.call(()=>/* @__PURE__ */new Map);class w{}class d extends w{declarations=/* @__PURE__ */new Map;rules=/* @__PURE__ */new Map;selector;parent=e;css;constructor(e,t,r){super(),this.selector=e,this.parent=r,t&&y(this,t),this.css=t}toString(){let e=t(this.declarations,([e,t])=>`${e.replaceAll(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${t};`),r=t(this.rules,([e,t])=>`${t}`);return`${this.selector} { ${[...e,...r].join(" ")} }`}}const y=(e,t)=>{for(let[a,n]of r(t))if("__selector__"!==a)if(s(n)||i(n)||l(n,w))e.declarations.set(a,`${n}`);else{let t=e.selector.startsWith("@")&&!e.parent?a:`${/^[@]|&/.test(a)?a:`& ${a}`}`;e.rules.set(t,new d(t,n,e))}},f=(t,r,s=!0)=>{let i=s?a(r):"";if(s){let e=h.get(i);if(e)return e}let l=new d(t(),r,e);return $.style(e,`${l}`),s&&h.set(i,l),l};class g extends w{constructor(e){super(),n(this,e)}toString(){return`var(${this.name})`}declare(e){return{[this.name]:`${e??this.initialValue}`}}}n($.css,{property(e,t,i){let l=o.generate("css-property",{lettercase:"lower"});if(s(e)){if(c(t)||c(i))throw"Register CSS Property Error";let r=`--${l}`,s=new g({name:r,syntax:e,initialValue:`${t}`,inherits:i}),a=f(()=>`@property ${r}`,{syntax:`'${e}'`,inherits:`${i??!0}`,...t?{initialValue:t}:{}},!1);return u.add(a),s}{let t={};return p(r(e),([e,[r,s,i]])=>{let a=`--${o=e,o.replaceAll(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}-${l}`;var o;let $=new g({name:a,syntax:r,initialValue:`${s}`,inherits:i});n(t,{[e]:$});let c=f(()=>`@property ${a}`,{syntax:`'${r}'`,inherits:`${i??!0}`,...s?{initialValue:s}:{}},!1);u.add(c)}),t}}});export{g as $CSSProperty};
1
+ import{Utils as e,UID as t}from"@amateras/utils";const s=/* @__PURE__ */new Set,r=e.call(()=>/* @__PURE__ */new Map);class i{}class n extends i{declarations=/* @__PURE__ */new Map;rules=/* @__PURE__ */new Map;selector;parent=e.Null;css;constructor(e,t,s){super(),this.selector=e,this.parent=s,t&&a(this,t),this.css=t}toString(){let t=e.map(this.declarations,([e,t])=>`${e.replaceAll(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${t};`),s=e.map(this.rules,([e,t])=>`${t}`);return`${this.selector} { ${[...t,...s].join(" ")} }`}}const a=(t,s)=>{for(let[r,a]of e.entries(s))if("__selector__"!==r)if(e.isString(a)||e.isNumber(a)||e.isInstanceof(a,i))t.declarations.set(r,`${a}`);else{let e=t.selector.startsWith("@")&&!t.parent?r:`${/^[@]|&/.test(r)?r:`& ${r}`}`;t.rules.set(e,new n(e,a,t))}},l=(t,s,i=!0)=>{let a=i?e.stringify(s):"";if(i){let e=r.get(a);if(e)return e}let l=new n(t(),s,e.Null);return $.style(e.Null,`${l}`),i&&r.set(a,l),l};class o extends i{constructor(t){super(),e.assign(this,t)}toString(){return`var(${this.name})`}declare(e){return{[this.name]:`${e??this.initialValue}`}}}e.assign($.css,{property(r,i,n){let a=t.generate("css-property",{lettercase:"lower"});if(e.isString(r)){if(e.isUndefined(i)||e.isUndefined(n))throw"Register CSS Property Error";let t=`--${a}`,c=new o({name:t,syntax:r,initialValue:`${i}`,inherits:n}),$=l(()=>`@property ${t}`,{syntax:`'${r}'`,inherits:`${n??!0}`,...i?{initialValue:i}:{}},!1);return s.add($),c}{let t={};return e.forEach(e.entries(r),([r,[i,n,c]])=>{let $=`--${u=r,u.replaceAll(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}-${a}`;var u;let p=new o({name:$,syntax:i,initialValue:`${n}`,inherits:c});e.assign(t,{[r]:p});let h=l(()=>`@property ${$}`,{syntax:`'${i}'`,inherits:`${c??!0}`,...n?{initialValue:n}:{}},!1);s.add(h)}),t}}});export{o as $CSSProperty};
@@ -1 +1 @@
1
- import{onclient as e,_document as t}from"@amateras/core";import{_Object_assign as r,UID as a,isObject as s,_Object_fromEntries as n,map as o,_Object_entries as l}from"@amateras/utils";class u{}class m extends u{name;value;constructor(e,t){super(),this.name=e,this.value=t}set(r){return e()&&t.documentElement.style.setProperty(`${this.name}`,r),this}reset(){return e()&&t.documentElement.style.removeProperty(`${this.name}`),this}default(e){return`var(${this.name}, ${e})`}declare(e){return{[this.name]:`${e??this.value}`}}toString(){return`var(${this.name})`}}r($.css,{variable(e,t){let r=t?.unique?"_"+a.generate("css-variable",{lettercase:"lower"}):"";if(s(e)){const a=n(o(l(e),([e,a])=>{return[e,new m(`--${t?.prefix??""}${s=e,s.replaceAll(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}${r}`,`${a}`)];var s}));return $.CSS({":root":n(o(l(a),([e,{name:t,value:r}])=>[t,r]))}),a}{const t=new m(`--${r}`,e);return $.CSS({":root":{[t.name]:t.value}}),t}}});export{m as $CSSVariable};
1
+ import{onclient as e,_document as t}from"@amateras/core";import{Utils as r,UID as s}from"@amateras/utils";class a{}class n extends a{name;value;constructor(e,t){super(),this.name=e,this.value=t}set(r){return e()&&t.documentElement.style.setProperty(`${this.name}`,r),this}reset(){return e()&&t.documentElement.style.removeProperty(`${this.name}`),this}default(e){return`var(${this.name}, ${e})`}declare(e){return{[this.name]:`${e??this.value}`}}toString(){return`var(${this.name})`}}r.assign($.css,{variable(e,t){let a=t?.unique?"_"+s.generate("css-variable",{lettercase:"lower"}):"";if(r.isObject(e)){const s=r.fromEntries(r.map(r.entries(e),([e,r])=>{return[e,new n(`--${t?.prefix??""}${s=e,s.replaceAll(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}${a}`,`${r}`)];var s}));return $.CSS({":root":r.fromEntries(r.map(r.entries(s),([e,{name:t,value:r}])=>[t,r]))}),s}{const t=new n(`--${a}`,e);return $.CSS({":root":{[t.name]:t.value}}),t}}});export{n as $CSSVariable};
package/build/css.js CHANGED
@@ -1 +1 @@
1
- import{_null as e,map as t,_Object_entries as s,isString as r,isNumber as l,_instanceof as a,_JSON_stringify as n,_Object_assign as o,forEach as c,_Array_from as i,toArray as u,UID as d}from"@amateras/utils";import{ElementProto as p,onserver as h}from"@amateras/core";const w=/* @__PURE__ */new WeakMap,f=/* @__PURE__ */new Set,S=$.call(()=>/* @__PURE__ */new Map);class _{}class g extends _{declarations=/* @__PURE__ */new Map;rules=/* @__PURE__ */new Map;selector;parent=e;css;constructor(e,t,s){super(),this.selector=e,this.parent=s,t&&m(this,t),this.css=t}toString(){let e=t(this.declarations,([e,t])=>`${e.replaceAll(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${t};`),s=t(this.rules,([e,t])=>`${t}`);return`${this.selector} { ${[...e,...s].join(" ")} }`}}const m=(e,t)=>{for(let[n,o]of s(t))if("__selector__"!==n)if(r(o)||l(o)||a(o,_))e.declarations.set(n,`${o}`);else{let t=e.selector.startsWith("@")&&!e.parent?n:`${/^[@]|&/.test(n)?n:`& ${n}`}`;e.rules.set(t,new g(t,o,e))}},C=(t,s,r=!0)=>{let l=r?n(s):"";if(r){let e=S.get(l);if(e)return e}let a=new g(t(),s,e);return $.style(e,`${a}`),r&&S.set(l,a),a};o($,{css:e=>a(e,g)?e:C(()=>`.${d.generate("css")}`,e),CSS:e=>t(s(e),([e,t])=>{let s=C(()=>e,{...t,__selector__:e});return f.add(s),s})}),o(p.prototype,{css(...e){return c(e,e=>M(this,e)),this}});const M=(e,t)=>{let s=$.css(t),r=s.selector.slice(1);e.addClass(r);const l=w.get(e)??/* @__PURE__ */new Set;l.add(s),w.set(e,l)};h()&&o($.CSS,{rules(e){let t=/* @__PURE__ */new Set;return c([e,...e.protos],s=>{let r=w.get(s);c(r,e=>t.add(e)),e!==s&&c(this.rules(s),e=>t.add(e))}),i(t)},text(e){return[...f,...this.rules(e)].join("\n")}}),$.process.attr.add((e,t,s)=>{if("css"===e)return c(u(t),e=>M(s,e)),!0});export{_ as $CSS,g as $CSSRule,M as assignCSS};
1
+ import{Utils as e,UID as t}from"@amateras/utils";import{ElementProto as s,onserver as r}from"@amateras/core";const a=/* @__PURE__ */new WeakMap,n=/* @__PURE__ */new Set,l=e.call(()=>/* @__PURE__ */new Map);class o{}class i extends o{declarations=/* @__PURE__ */new Map;rules=/* @__PURE__ */new Map;selector;parent=e.Null;css;constructor(e,t,s){super(),this.selector=e,this.parent=s,t&&c(this,t),this.css=t}toString(){let t=e.map(this.declarations,([e,t])=>`${e.replaceAll(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${t};`),s=e.map(this.rules,([e,t])=>`${t}`);return`${this.selector} { ${[...t,...s].join(" ")} }`}}const c=(t,s)=>{for(let[r,a]of e.entries(s))if("__selector__"!==r)if(e.isString(a)||e.isNumber(a)||e.isInstanceof(a,o))t.declarations.set(r,`${a}`);else{let e=t.selector.startsWith("@")&&!t.parent?r:`${/^[@]|&/.test(r)?r:`& ${r}`}`;t.rules.set(e,new i(e,a,t))}},u=(t,s,r=!0)=>{let a=r?e.stringify(s):"";if(r){let e=l.get(a);if(e)return e}let n=new i(t(),s,e.Null);return $.style(e.Null,`${n}`),r&&l.set(a,n),n};e.assign($,{css:s=>e.isInstanceof(s,i)?s:u(()=>`.${t.generate("css")}`,s),CSS:t=>e.map(e.entries(t),([e,t])=>{let s=u(()=>e,{...t,__selector__:e});return n.add(s),s})}),e.assign(s.prototype,{css(...t){return e.forEach(t,e=>p(this,e)),this}});const p=(e,t)=>{let s=$.css(t),r=s.selector.slice(1);e.addClass(r);const n=a.get(e)??/* @__PURE__ */new Set;n.add(s),a.set(e,n)};r()&&e.assign($.CSS,{rules(t){let s=/* @__PURE__ */new Set;return e.forEach([t,...t.protos],r=>{let n=a.get(r);e.forEach(n,e=>s.add(e)),t!==r&&e.forEach(this.rules(r),e=>s.add(e))}),e.arrayFrom(s)},text(e){return[...n,...this.rules(e)].join("\n")}}),$.process.attr.add((t,s,r)=>{if("css"===t)return e.forEach(e.toArray(s),e=>p(r,e)),!0});export{o as $CSS,i as $CSSRule,p as assignCSS};
package/build/for.js CHANGED
@@ -1 +1 @@
1
- import{ProxyProto as t,symbol_Statement as e,Proto as s}from"@amateras/core";import{forEach as i,_Array_from as o,_null as r}from"@amateras/utils";class l extends t{static[e]=!0;#t;list$;#e=/* @__PURE__ */new Map;constructor(t,e){super(),this.list$=t,this.#t=e;let s=()=>{const t=this.exec();i(this.protos,t=>t.builded||t.build()),i(t,t=>t.removeNode());let e=this.node,s=e?.parentNode;if(e&&s){let t=this.toDOM(),l=o(s.childNodes).indexOf(e),a=r;i(t,i=>{if(i!==e){let e=s.childNodes[l];e!==i&&(a=t.includes(e)?s.childNodes[l+1]??r:e??r,s.insertBefore(i,a))}l++})}this.parent?.mutate()};this.list$.subscribe(s),this.listen("dispose",()=>this.list$.unsubscribe(s))}build(){return this.#e=/* @__PURE__ */new Map,this.exec(),this.protos.forEach(t=>t.builded||t.build()),this}exec(){let t=this.protos,e=/* @__PURE__ */new Set;return i(this.list$.value,(i,o)=>{$.context(s,this,()=>{let s=this.#t,r=this.#e.get(i)??new a(()=>s(i,o));this.#e.set(i,r),t.delete(r),e.add(r)})}),this.replaceProtos(...e),t}removeNode(){this.node?.remove(),i(this.protos,t=>t.removeNode())}dispose(){super.dispose(),i(this.#e.values(),t=>t.dispose()),this.#e.clear()}}class a extends s{static[e]=!0}globalThis.For=l,$.process.craft.add((t,e,s)=>{if(t===l)return new l(e,s)});export{l as For,a as ForItem};
1
+ import{ProxyProto as t,symbol_Statement as e,Proto as s}from"@amateras/core";import{Utils as i}from"@amateras/utils";class o extends t{static[e]=!0;#t;list$;#e=/* @__PURE__ */new Map;constructor(t,e){super(),this.list$=t,this.#t=e;let s=()=>{const t=this.exec();i.forEach(this.protos,t=>t.builded||t.build()),i.forEach(t,t=>t.removeNode());let e=this.node,s=e?.parentNode;if(e&&s){let t=this.toDOM(),o=i.arrayFrom(s.childNodes).indexOf(e),r=i.Null;i.forEach(t,a=>{if(a!==e){let e=s.childNodes[o];e!==a&&(r=t.includes(e)?s.childNodes[o+1]??i.Null:e??i.Null,s.insertBefore(a,r))}o++})}this.parent?.mutate(),this.parent?.dispatch("mutate",[],{bubbles:!0})};this.list$.subscribe(s),this.listen("dispose",()=>this.list$.unsubscribe(s))}build(){return this.#e=/* @__PURE__ */new Map,this.exec(),this.protos.forEach(t=>t.builded||t.build()),this}exec(){let t=new Set(this.protos),e=/* @__PURE__ */new Set;return i.forEach(i.arrayFrom(this.list$.value),(i,o)=>{$.context(s,this,()=>{let s=this.#t,a=this.#e.get(i)??new r(()=>s(i,o));this.#e.set(i,a),t.delete(a),e.add(a)})}),this.replaceProtos(...e),t}dispose(){super.dispose(),i.forEach(this.#e.values(),t=>t.dispose()),this.#e.clear()}mutate(){super.mutate(),this.parent?.mutate()}}class r extends s{static[e]=!0}globalThis.For=o,$.process.craft.add((t,e,s)=>{if(t===o)return new o(e,s)});export{o as For,r as ForItem};
package/build/i18n.js CHANGED
@@ -1 +1 @@
1
- import{onclient as t,Proto as e,GlobalState as s,ProxyProto as i}from"@amateras/core";import{isFunction as n,isAsyncFunction as o,isObject as a,map as r,forEach as l,isUndefined as h,_null as c,_Object_assign as u,_instanceof as d}from"@amateras/utils";class p{#t=null;#e=null;constructor(t){n(t)?this.#e=t:this.#t=t}async context(){let e=()=>t()&&window.dispatchEvent(new Event("i18ncontext"));if(this.#t)return o(this.#t)?await this.#t.finally(e):this.#t;if(!this.#e)throw"I18n Context Fetch Error";return this.#t=this.#e().then(t=>t.default).finally(e)}async find(t,e){e||(e=await this.context());const[s,...i]=t.split("."),n=e[s];return a(n)?i.length?this.find(i.join("."),n):n._:i.length?t:n}}class g{session;key;options;updating=!1;updaters=[];constructor(t,e,s){this.session=t,this.key=e,this.options=s,this.session.translations.add(this)}async update(){if(this.updating)return;this.updating=!0;const t=this.session.fetch(this.key,this.options);this.session.global.asyncTask(t);const{text:e,args:s}=await t,i=r(e,(t,e)=>e<s.length?[t,s[e]]:[t]).flat();return l(this.updaters,t=>t(i)),this.updating=!1,this}onupdate(t){this.updaters.push(t)}}class f{translations=/* @__PURE__ */new Set;i18n;#s;global;constructor(t,e){this.i18n=t,this.global=e,this.#s=t.locale(),t.sessions.add(this)}async fetch(t,e){const s=this.i18n.dictionaries.get(this.#s);if(!s)return{text:[t],args:[]};const i=await s.find(t);if(h(i))return{text:[t],args:[]};const n=i.split(/\$[a-zA-Z0-9_]+\$/);if(1===n.length||!e)return{text:[i],args:[]};const o=i.matchAll(/(\$([a-zA-Z0-9_]+)\$)/g);return{text:n,args:r(o,([,,t])=>e[t])}}locale(e){if(!arguments.length)return this.#s;if(e){if(!this.i18n.dictionaries.get(e)){let t=e.split("-");if(1===t.length)return;return this.locale(t[0])}}return e&&e!==this.#s?(this.#s=e,new Promise(async e=>{await Promise.all(r(this.translations,t=>t.update())),e(),t()&&dispatchEvent(new Event("localeupdate"))})):void 0}}class w{#s;dictionaries=/* @__PURE__ */new Map;defaultLocale;sessions=/* @__PURE__ */new Set;path="";static key="__locale__";constructor(t){this.defaultLocale=t,this.#s=t}add(t,e){return this.dictionaries.set(t,new p(e)),this}delete(t){return this.dictionaries.delete(t),this}t(t,e){return new g(this.getSession(),this.getFullPath(t),e)}async text(t,e){let s=await this.getSession().fetch(this.getFullPath(t),e);return s.text.reduce((t,e,i)=>t+e+(s.args[i]||""),"")}dir(t){let e=this;return{t:(s,i)=>e.t(`${t}.${s}`,i),text:(s,i)=>e.text(`${t}.${s}`,i),dir:s=>e.dir(`${t}.${s}`)}}locale(t){if(!arguments.length)return this.readStoreLocale(),this.#s;if(!t)return;if(!this.dictionaries.get(t)){let e=t.split("-");if(1===e.length)return;return this.locale(e[0])}return this.#s=t,this.writeStoreLocale(t),Promise.all(r(this.sessions,e=>e.locale(t)))}getFullPath(t){return this.path?`${this.path}.${t}`:t}getSession(){let t=e.proto;if(t){let e=t.global.i18n.session??new f(this,t.global);return t.global.i18n.session=e,e}throw"I18n.getSession(): session not found from Proto.proto"}readStoreLocale(){t()&&(this.#s=localStorage.getItem(w.key)??this.defaultLocale)}writeStoreLocale(e){t()&&localStorage.setItem(w.key,e)}}s.assign(()=>({i18n:{session:c}})),s.disposers.add(t=>{t.i18n.session=c}),u($,{i18n:t=>new w(t)}),$.process.text.add(t=>{if(d(t,g)){const e=new i;return t.onupdate(t=>{e.layout=()=>$([...t]),l(e.protos,t=>t.removeNode()),e.build(),e.node?.replaceWith(...e.toDOM()),e.dispatch("i18nupdate",[void 0],{bubbles:!0})}),t.update(),e}}),$.process.attr.add((t,e,s)=>{d(e,g)&&(e.onupdate(e=>{s.attr(t,e.join(""))}),e.update())});export{w as I18n,p as I18nDictionary,g as I18nTranslation};
1
+ import{onclient as t,Proto as e,GlobalState as s,ProxyProto as i}from"@amateras/core";import{Utils as n}from"@amateras/utils";class a{#t=null;#e=null;constructor(t){n.isFunction(t)?this.#e=t:this.#t=t}async context(){let e=()=>t()&&window.dispatchEvent(new Event("i18ncontext"));if(this.#t)return n.isAsyncFunction(this.#t)?await this.#t.finally(e):this.#t;if(!this.#e)throw"I18n Context Fetch Error";return this.#t=this.#e().then(t=>t.default).finally(e)}async find(t,e){e||(e=await this.context());const[s,...i]=t.split("."),a=e[s];return n.isObject(a)?i.length?this.find(i.join("."),a):a._:i.length?t:a}}class o{session;key;options;updating=!1;updaters=[];constructor(t,e,s){this.session=t,this.key=e,this.options=s,this.session.translations.add(this)}async update(){if(this.updating)return;this.updating=!0;const t=this.session.fetch(this.key,this.options);this.session.global.asyncTask(t);const{text:e,args:s}=await t,i=n.map(e,(t,e)=>e<s.length?[t,s[e]]:[t]).flat();return n.forEach(this.updaters,t=>t(i)),this.updating=!1,this}onupdate(t){this.updaters.push(t)}}class l{translations=/* @__PURE__ */new Set;i18n;#s;global;constructor(t,e){this.i18n=t,this.global=e,this.#s=t.locale(),t.sessions.add(this)}async fetch(t,e){const s=this.i18n.dictionaries.get(this.#s);if(!s)return{text:[t],args:[]};const i=await s.find(t);if(n.isUndefined(i))return{text:[t],args:[]};const a=i.split(/\$[a-zA-Z0-9_]+\$/);if(1===a.length||!e)return{text:[i],args:[]};const o=i.matchAll(/(\$([a-zA-Z0-9_]+)\$)/g);return{text:a,args:n.map(o,([,,t])=>e[t])}}locale(e){if(!arguments.length)return this.#s;if(e){if(!this.i18n.dictionaries.get(e)){let t=e.split("-");if(1===t.length)return;return this.locale(t[0])}}return e&&e!==this.#s?(this.#s=e,new Promise(async e=>{await Promise.all(n.map(this.translations,t=>t.update())),e(),t()&&dispatchEvent(new Event("localeupdate"))})):void 0}}class r{#s;dictionaries=/* @__PURE__ */new Map;defaultLocale;sessions=/* @__PURE__ */new Set;path="";static key="__locale__";constructor(t){this.defaultLocale=t,this.#s=t}add(t,e){return this.dictionaries.set(t,new a(e)),this}delete(t){return this.dictionaries.delete(t),this}t(t,e){return new o(this.getSession(),this.getFullPath(t),e)}async text(t,e){let s=await this.getSession().fetch(this.getFullPath(t),e);return s.text.reduce((t,e,i)=>t+e+(s.args[i]||""),"")}dir(t){let e=this;return{t:(s,i)=>e.t(`${t}.${s}`,i),text:(s,i)=>e.text(`${t}.${s}`,i),dir:s=>e.dir(`${t}.${s}`)}}locale(t){if(!arguments.length)return this.readStoreLocale(),this.#s;if(!t)return;if(!this.dictionaries.get(t)){let e=t.split("-");if(1===e.length)return;return this.locale(e[0])}return this.#s=t,this.writeStoreLocale(t),Promise.all(n.map(this.sessions,e=>e.locale(t)))}getFullPath(t){return this.path?`${this.path}.${t}`:t}getSession(){let t=e.proto;if(t){let e=t.global.i18n.session??new l(this,t.global);return t.global.i18n.session=e,e}throw"I18n.getSession(): session not found from Proto.proto"}readStoreLocale(){t()&&(this.#s=localStorage.getItem(r.key)??this.defaultLocale)}writeStoreLocale(e){t()&&localStorage.setItem(r.key,e)}}s.assign(()=>({i18n:{session:n.Null}})),s.disposers.add(t=>{t.i18n.session=n.Null}),n.assign($,{i18n:t=>new r(t)}),$.process.text.add(t=>{if(n.isInstanceof(t,o)){const e=new i;return t.onupdate(t=>{e.layout=()=>$([...t]),n.forEach(e.protos,t=>t.removeNode()),e.build(),e.node?.replaceWith(...e.toDOM()),e.dispatch("i18nupdate",[void 0],{bubbles:!0})}),t.update(),e}}),$.process.attr.add((t,e,s)=>{n.isInstanceof(e,o)&&(e.onupdate(e=>{s.attr(t,e.join(""))}),e.update())});export{r as I18n,a as I18nDictionary,o as I18nTranslation};
package/build/idb.js CHANGED
@@ -1 +1 @@
1
- import{_Promise as e,_instanceof as t,_Object_assign as r,forEach as s,_Array_from as n,isBoolean as o,isFunction as i,_Object_fromEntries as a,_null as c,trycatch as u,_JSON_stringify as d}from"@amateras/utils";const h=(t,r)=>new e((e,s)=>{t.onsuccess=s=>r?r(t,e):e(t.result),t.onerror=e=>s(t.error)});class l{#e;store;direction;constructor(e,r){this.#e=r,this.store=t(e,y)?e.store:e,this.direction=r.direction}get value(){return this.#e.value}get key(){return this.#e.key}get primaryKey(){return this.#e.primaryKey}async update(e){return h(this.#e.update(e))}async delete(){return h(this.#e.delete())}continue(e){this.#e.continue(e)}continuePrimaryKey(e,t){this.#e.continuePrimaryKey(e,t)}advance(e){this.#e.advance(e)}abort(){this.#e.request.transaction?.abort()}}class m{#t;constructor(e){this.#t=e}cursor(e,t,r){return h(this.#t.openCursor(t,r),(t,r)=>t.result?e(new l(this,t.result)):r(null))}keyCursor(e,t,r){return h(this.#t.openCursor(t,r),(t,r)=>t.result?e(new l(this,t.result)):r(null))}count(e){return h(this.#t.count(e))}get(e){return h(this.#t.get(e))}getAll(e){return h(this.#t.getAll(e))}}class y extends m{store;constructor(e,t,s){super(t),this.store=e,r(this,s)}}class p extends m{#r;constructor(e,t){super(e),this.#r=e,r(this,t)}put(e,t){return h(this.#r.put(e,t))}add(e,t){return h(this.#r.add(e,t))}delete(e){return h(this.#r.delete(e))}clear(){return h(this.#r.clear())}index(e){return new y(this,this.#r.index(e),this.indexes[e])}}class g{#s;#n;writable;stores={};durability;constructor(e,t){this.#s=t,this.#n=e,this.writable="readonly"!==t.mode,this.durability=t.durability,s(n(t.objectStoreNames),t=>{r(this.stores,{[t]:e.stores[t]})})}store(e){return new p(this.#s.objectStore(e),this.#n.stores[e])}commit(){return this.#s.commit()}abort(){return this.#s.abort()}}class b{idb;name;version;constructor(e,t){this.idb=e,this.name=e.name,this.version=e.version,r(this,t)}async store(e,t,r){return o(t)?this.transaction(e,t,t=>r(t.store(e))):this.transaction(e,r=>t(r.store(e)))}async transaction(t,r,s){s=o(r)?s:r,r=!!o(r)&&r;const n=this.idb.transaction(t,r?"readwrite":"readonly"),i=s(new g(this,n));return new e((e,t)=>{n.oncomplete=t=>e(i),n.onerror=n.onabort=e=>n.error&&t(n.error)})}}class w{config;upgrades=/* @__PURE__ */new Map;indexes=/* @__PURE__ */new Map;constructor(e){this.config=e}keyPath(e){return this.config.keyPath=e,this}autoIncrement(e){return this.config.autoIncrement=e,this}schema(){return this}index(e,t){return this.indexes.set(e,{...t,name:e,multiEntry:t.multiEntry??!1,unique:t.unique??!1}),this}upgrade(e,t){return this.upgrades.set(e,t),this}}const v="objectStoreNames",f="deleteObjectStore",x="createObjectStore",k=indexedDB,I="onupgradeneeded",M="onsuccess";class P{#o=!1;storeMap=/* @__PURE__ */new Map;#i=!1;constructor(e){r(this,e)}devMode(e){return this.#i=e,this}deleteUnused(e){return this.#o=e,this}store(e,t){return this.storeMap.set(e,i(t)?t(new w({autoIncrement:!1,keyPath:null,indexes:{},name:e,schema:null})):t),this}async open(){return new e((e,t)=>{const{version:r,name:o,storeMap:i}=this,h=k.open(o),l=/* @__PURE__ */new Map,m=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map,p=/* @__PURE__ */new Map,g=[],w=e=>this.#i&&console.debug(`[$IDBBuilder (${o})]`,e),P=a(n(i).map(([e,{config:{keyPath:t,autoIncrement:r},indexes:s}])=>[e,{autoIncrement:r,keyPath:t,name:e,schema:c,indexes:a(n(s).map(([e,{keyPath:t,multiEntry:r,unique:s}])=>[e,{keyPath:t,multiEntry:r,unique:s}]))}])),S={version:r,name:o,stores:P},$=e=>{w("Upgrade DB");const t=e.result,r=e.transaction;s(l,([e,{config:r}])=>{t[x](e,r),w(`Store Created: ${e}`)}),s(y,([e,{config:r}])=>{t[f](e),t[x](e,r),w(`Store Upgraded: ${e}`)}),s(m,([{config:{name:e}},t])=>{const n=r.objectStore(e);s(t,([t,{keyPath:r,...s}])=>{n.indexNames.contains(t)&&n.deleteIndex(t),n.createIndex(t,r,s),w(`Store '${e}' Index Created: ${t}`)})}),this.#o&&s(g,e=>{t[f](e),w(`Unused Store Deleted: ${e}`)}),s(p,([e,t])=>{const n=r.objectStore(e);s(t,({key:e,value:t})=>{n.autoIncrement||n.keyPath?n.add(t):n.add(t,e)}),w(`Recovered Store Objects: ${t.length} objects of store '${e}'`)})};h[I]=()=>{w("No IDB detected, create IDB");const{transaction:e,result:t}=h;s(i,([e,t])=>{l.set(e,t),m.set(t,new Map(t.indexes))}),t.version===r?$(h):e.oncomplete=e=>{const t=indexedDB.open(o,r);t.onupgradeneeded=e=>$(t)}},h[M]=async()=>{w("IDB Detected");const t=h.result,a=new b(t,S),c=t[v].length?t.transaction(n(t[v]),"readonly"):null,f=()=>{w("No Upgrade"),e(a)};if(t.version===r)return f();if(c&&s(n(c[v]),e=>i.has(e)&&g.push(e)),s(i,([e,o])=>{const{keyPath:i,autoIncrement:a}=o.config,h=/* @__PURE__ */new Map,p=()=>s(o.indexes,([e,t])=>{const[r]=u(()=>g?.index(e)),s=d(t.keyPath)!==d(r?.keyPath)||!!t.multiEntry!==r?.multiEntry||!!t.unique!==r?.unique;r&&!s||(h.set(e,t),m.set(o,h))}),[g]=u(()=>c?.objectStore(e));if(!g)return l.set(e,o),p();const b=n(o.upgrades).find(([e])=>r>=e&&t.version<e),w=d(i)!==d(g.keyPath)||a!==g?.autoIncrement,v=b||w;p(),g&&!v||y.set(e,o)}),!(r!==t.version||l.size||y.size||g.length||m.size))return f();for(const[e,s]of y){const o=[],i=n(s.upgrades).filter(([e])=>r>=e&&t.version<e).sort((e,t)=>e[0]-t[0]).map(e=>e[1]);await a.transaction(e,!1,async t=>{p.set(e,o),await t.store(e).cursor(async e=>{o.push({key:e.key,value:e.value}),e.continue()})});for(const t of i)p.set(e,await t(o,a))}t.close();const x=k.open(o,r);x[I]=e=>$(x),x[M]=t=>{w("IDB Upgrade Completed"),e(new b(x.result,S))}},h.onerror=e=>t(h.error)})}}r($,{idb:(e,t)=>new P({name:e,version:t,stores:{}})});
1
+ import{Utils as e}from"@amateras/utils";const t=(e,t)=>new Promise((r,s)=>{e.onsuccess=s=>t?t(e,r):r(e.result),e.onerror=t=>s(e.error)});class r{#e;store;direction;constructor(t,r){this.#e=r,this.store=e.isInstanceof(t,n)?t.store:t,this.direction=r.direction}get value(){return this.#e.value}get key(){return this.#e.key}get primaryKey(){return this.#e.primaryKey}async update(e){return t(this.#e.update(e))}async delete(){return t(this.#e.delete())}continue(e){this.#e.continue(e)}continuePrimaryKey(e,t){this.#e.continuePrimaryKey(e,t)}advance(e){this.#e.advance(e)}abort(){this.#e.request.transaction?.abort()}}class s{#t;constructor(e){this.#t=e}cursor(e,s,n){return t(this.#t.openCursor(s,n),(t,s)=>t.result?e(new r(this,t.result)):s(null))}keyCursor(e,s,n){return t(this.#t.openCursor(s,n),(t,s)=>t.result?e(new r(this,t.result)):s(null))}count(e){return t(this.#t.count(e))}get(e){return t(this.#t.get(e))}getAll(e){return t(this.#t.getAll(e))}}class n extends s{store;constructor(t,r,s){super(r),this.store=t,e.assign(this,s)}}class o extends s{#r;constructor(t,r){super(t),this.#r=t,e.assign(this,r)}put(e,r){return t(this.#r.put(e,r))}add(e,r){return t(this.#r.add(e,r))}delete(e){return t(this.#r.delete(e))}clear(){return t(this.#r.clear())}index(e){return new n(this,this.#r.index(e),this.indexes[e])}}class i{#s;#n;writable;stores={};durability;constructor(t,r){this.#s=r,this.#n=t,this.writable="readonly"!==r.mode,this.durability=r.durability,e.forEach(e.arrayFrom(r.objectStoreNames),r=>{e.assign(this.stores,{[r]:t.stores[r]})})}store(e){return new o(this.#s.objectStore(e),this.#n.stores[e])}commit(){return this.#s.commit()}abort(){return this.#s.abort()}}class a{idb;name;version;constructor(t,r){this.idb=t,this.name=t.name,this.version=t.version,e.assign(this,r)}async store(t,r,s){return e.isBoolean(r)?this.transaction(t,r,e=>s(e.store(t))):this.transaction(t,e=>r(e.store(t)))}async transaction(t,r,s){s=e.isBoolean(r)?s:r,r=!!e.isBoolean(r)&&r;const n=this.idb.transaction(t,r?"readwrite":"readonly"),o=s(new i(this,n));return new Promise((e,t)=>{n.oncomplete=t=>e(o),n.onerror=n.onabort=e=>n.error&&t(n.error)})}}class c{config;upgrades=/* @__PURE__ */new Map;indexes=/* @__PURE__ */new Map;constructor(e){this.config=e}keyPath(e){return this.config.keyPath=e,this}autoIncrement(e){return this.config.autoIncrement=e,this}schema(){return this}index(e,t){return this.indexes.set(e,{...t,name:e,multiEntry:t.multiEntry??!1,unique:t.unique??!1}),this}upgrade(e,t){return this.upgrades.set(e,t),this}}const u="objectStoreNames",h="deleteObjectStore",d="createObjectStore",l=indexedDB,m="onupgradeneeded",y="onsuccess";class p{#o=!1;storeMap=/* @__PURE__ */new Map;#i=!1;constructor(t){e.assign(this,t)}devMode(e){return this.#i=e,this}deleteUnused(e){return this.#o=e,this}store(t,r){return this.storeMap.set(t,e.isFunction(r)?r(new c({autoIncrement:!1,keyPath:null,indexes:{},name:t,schema:null})):r),this}async open(){return new Promise((t,r)=>{const{version:s,name:n,storeMap:o}=this,i=l.open(n),c=/* @__PURE__ */new Map,p=/* @__PURE__ */new Map,g=/* @__PURE__ */new Map,f=/* @__PURE__ */new Map,b=[],w=e=>this.#i&&console.debug(`[$IDBBuilder (${n})]`,e),v=e.fromEntries(e.arrayFrom(o).map(([t,{config:{keyPath:r,autoIncrement:s},indexes:n}])=>[t,{autoIncrement:s,keyPath:r,name:t,schema:e.Null,indexes:e.fromEntries(e.arrayFrom(n).map(([e,{keyPath:t,multiEntry:r,unique:s}])=>[e,{keyPath:t,multiEntry:r,unique:s}]))}])),x={version:s,name:n,stores:v},E=t=>{w("Upgrade DB");const r=t.result,s=t.transaction;e.forEach(c,([e,{config:t}])=>{r[d](e,t),w(`Store Created: ${e}`)}),e.forEach(g,([e,{config:t}])=>{r[h](e),r[d](e,t),w(`Store Upgraded: ${e}`)}),e.forEach(p,([{config:{name:t}},r])=>{const n=s.objectStore(t);e.forEach(r,([e,{keyPath:r,...s}])=>{n.indexNames.contains(e)&&n.deleteIndex(e),n.createIndex(e,r,s),w(`Store '${t}' Index Created: ${e}`)})}),this.#o&&e.forEach(b,e=>{r[h](e),w(`Unused Store Deleted: ${e}`)}),e.forEach(f,([t,r])=>{const n=s.objectStore(t);e.forEach(r,({key:e,value:t})=>{n.autoIncrement||n.keyPath?n.add(t):n.add(t,e)}),w(`Recovered Store Objects: ${r.length} objects of store '${t}'`)})};i[m]=()=>{w("No IDB detected, create IDB");const{transaction:t,result:r}=i;e.forEach(o,([e,t])=>{c.set(e,t),p.set(t,new Map(t.indexes))}),r.version===s?E(i):t.oncomplete=e=>{const t=indexedDB.open(n,s);t.onupgradeneeded=e=>E(t)}},i[y]=async()=>{w("IDB Detected");const r=i.result,h=new a(r,x),d=r[u].length?r.transaction(e.arrayFrom(r[u]),"readonly"):null,v=()=>{w("No Upgrade"),t(h)};if(r.version===s)return v();if(d&&e.forEach(e.arrayFrom(d[u]),e=>o.has(e)&&b.push(e)),e.forEach(o,([t,n])=>{const{keyPath:o,autoIncrement:i}=n.config,a=/* @__PURE__ */new Map,u=()=>e.forEach(n.indexes,([t,r])=>{const[s]=e.trycatch(()=>h?.index(t)),o=e.stringify(r.keyPath)!==e.stringify(s?.keyPath)||!!r.multiEntry!==s?.multiEntry||!!r.unique!==s?.unique;s&&!o||(a.set(t,r),p.set(n,a))}),[h]=e.trycatch(()=>d?.objectStore(t));if(!h)return c.set(t,n),u();const l=e.arrayFrom(n.upgrades).find(([e])=>s>=e&&r.version<e),m=e.stringify(o)!==e.stringify(h.keyPath)||i!==h?.autoIncrement,y=l||m;u(),h&&!y||g.set(t,n)}),!(s!==r.version||c.size||g.size||b.length||p.size))return v();for(const[t,n]of g){const o=[],i=e.arrayFrom(n.upgrades).filter(([e])=>s>=e&&r.version<e).sort((e,t)=>e[0]-t[0]).map(e=>e[1]);await h.transaction(t,!1,async e=>{f.set(t,o),await e.store(t).cursor(async e=>{o.push({key:e.key,value:e.value}),e.continue()})});for(const e of i)f.set(t,await e(o,h))}r.close();const k=l.open(n,s);k[m]=e=>E(k),k[y]=e=>{w("IDB Upgrade Completed"),t(new a(k.result,x))}},i.onerror=e=>r(i.error)})}}e.assign($,{idb:(e,t)=>new p({name:e,version:t,stores:{}})});
package/build/if.js CHANGED
@@ -1 +1 @@
1
- import{Proto as s,symbol_Statement as e,ProxyProto as t}from"@amateras/core";import{_null as i,toArray as r,forEach as a,_instanceof as l,isIncluded as o,isArray as p}from"@amateras/utils";import{Signal as d}from"@amateras/signal";class n extends s{static[e]=!0;exps;constructor(s,e){super(()=>e(...this.exps??[])),this.exps=s?r(s):i}dispose(){super.dispose(),this.exps=i}validate(){return!this.exps||!this.exps.find(s=>!s.value)}}class u extends n{}class h extends n{}class f extends n{}class b extends t{static[e]=!0;statement=i;build(){super.build(!1,!1),this.validate()?.build();let s=()=>{let s=this.validate();s?.builded||s?.build(),this.statement!==s&&(this.statement=s??i,a(this.protos,s=>!s.visible&&s.removeNode()),this.node?.replaceWith(...this.toDOM()),this.parent?.mutate())};return a(this.protos,e=>{a(e.exps,t=>{t?.subscribe(s),e.listen("dispose",()=>{t?.unsubscribe(s)})})}),this}get protos(){return super.protos}dispose(){super.dispose(),this.statement=i}validate(){a(this.protos,s=>s.visible=!1);for(let s of this.protos)if(s.validate())return s.visible=!0,s}}globalThis.If=f,globalThis.Else=u,globalThis.ElseIf=h;let m=null;$.process.craft.add((s,e,t)=>{if(s===f&&(m=new b),l(m,b)){if(o(s,[f,u,h])){{let r=new s(...l(e,d)||p(e)?[e,t]:[i,e]);m.append(r)}return m}m=i}else if(o(s,[u,h]))throw"ElseIf/Else must be after If or ElseIf"});
1
+ import{Proto as s,symbol_Statement as t,ProxyProto as e}from"@amateras/core";import{Utils as i}from"@amateras/utils";import{Signal as a}from"@amateras/signal";class l extends s{static[t]=!0;exps;constructor(s,t){super(()=>t(...this.exps??[])),this.exps=s?i.toArray(s):i.Null}dispose(){super.dispose(),this.exps=i.Null}mutate(){super.mutate(),this.parent?.mutate()}validate(){return!this.exps||!this.exps.find(s=>!s.value)}}class r extends l{}class o extends l{}class u extends l{}class p extends e{static[t]=!0;statement=i.Null;virtual=!0;build(){super.build(!1,!1),this.validate()?.build();let s=()=>{let s=this.validate();s?.builded||s?.build(),this.statement!==s&&(this.statement=s??i.Null,i.forEach(this.protos,s=>!s.visible&&s.removeNode()),this.node?.replaceWith(...this.toDOM()),this.parent?.mutate(),this.parent?.dispatch("mutate",[],{bubbles:!0}))};return i.forEach(this.protos,t=>{i.forEach(t.exps,e=>{e?.subscribe(s),t.listen("dispose",()=>{e?.unsubscribe(s)})})}),this}get protos(){return super.protos}dispose(){super.dispose(),this.statement=i.Null}mutate(){super.mutate(),this.parent?.mutate()}validate(){i.forEach(this.protos,s=>s.visible=!1);for(let s of this.protos)if(s.validate())return s.visible=!0,s}}globalThis.If=u,globalThis.Else=r,globalThis.ElseIf=o;let n=null;$.process.craft.add((s,t,e)=>{if(s===u&&(n=new p),i.isInstanceof(n,p)){if(i.isIncluded(s,[u,r,o])){{let l=new s(...i.isInstanceof(t,a)||i.isArray(t)?[t,e]:[i.Null,t]);n.append(l)}return n}n=i.Null}else if(i.isIncluded(s,[r,o]))throw"ElseIf/Else must be after If or ElseIf"});
@@ -1 +1 @@
1
- const e=`https://unpkg.com/amateras@${"0.14.0"}/build`,t={amateras:`${e}/core.js`},s=[{name:"core",description:"Core module",entry:"core/src/index.ts",mapped:!0,listed:!0},{name:"widget",description:"Component module",entry:"widget/src/index.ts",mapped:!0,listed:!0},{name:"signal",description:"Reactive data module",entry:"signal/src/index.ts",mapped:!0,listed:!0},{name:"store",description:"Access data between widgets",entry:"store/src/index.ts",mapped:!0,listed:!0},{name:"css",description:"CSS-in-JS module",entry:"css/src/index.ts",mapped:!0,listed:!0},{name:"css-variable",description:"CSS variable module",entry:"css/src/ext/variable.ts",mapped:!0,listed:!1},{name:"css-keyframes",description:"CSS keyframes module",entry:"css/src/ext/keyframes.ts",mapped:!0,listed:!1},{name:"css-property",description:"CSS property module",entry:"css/src/ext/property.ts",mapped:!0,listed:!1},{name:"for",description:"For loop control-flow",entry:"for/src/index.ts",mapped:!0,listed:!0},{name:"if",description:"If/Else/ElseIf control-flow",entry:"if/src/index.ts",mapped:!0,listed:!0},{name:"match",description:"Match/Case/Default control-flow",entry:"match/src/index.ts",mapped:!0,listed:!0},{name:"router",description:"Router module",entry:"router/src/index.ts",mapped:!0,listed:!0},{name:"i18n",description:"Translation module",entry:"i18n/src/index.ts",mapped:!0,listed:!0},{name:"idb",description:"IndexedDB module",entry:"idb/src/index.ts",mapped:!0,listed:!0},{name:"markdown",description:"Markdown to HTML module",codeInsert:'import { Markdown } from "amateras/markdown"; new Markdown();',entry:"markdown/src/index.ts",mapped:!0,listed:!0},{name:"prefetch",description:"SSR data prefetch",entry:"prefetch/src/index.ts",mapped:!0,listed:!0},{name:"meta",description:"SSR `meta` tag manager",entry:"meta/src/index.ts",mapped:!0,listed:!0},{name:"ui",description:"UI components",entry:"ui/src/index.ts",mapped:!0,listed:!0},{name:"utils",description:"Utilities module",entry:"utils/src/index.ts",mapped:!0,listed:!0}].map(e=>e.name),r={...t,...Object.fromEntries(s.map(t=>{const s=`amateras/${t}`,r=`${e}/${t}.js`;return[[s,r],[`@${s}`,r]]}).flat())},n=document.querySelector('script[type="importmap"]');if(n){const e=JSON.parse(n.innerHTML);e.imports={...e.imports,...r},n.innerHTML=JSON.stringify(e,null,"\t")}else{const e=document.createElement("script");e.setAttribute("type","importmap"),e.innerHTML=JSON.stringify({imports:r},null,"\t"),document.head.prepend(e)}
1
+ const e=`https://unpkg.com/amateras@${"0.15.1"}/build`,t={amateras:`${e}/core.js`},s=[{name:"core",description:"Core module",entry:"core/src/index.ts",mapped:!0,listed:!0},{name:"widget",description:"Component module",entry:"widget/src/index.ts",mapped:!0,listed:!0},{name:"signal",description:"Reactive data module",entry:"signal/src/index.ts",mapped:!0,listed:!0},{name:"store",description:"Access data between widgets",entry:"store/src/index.ts",mapped:!0,listed:!0},{name:"css",description:"CSS-in-JS module",entry:"css/src/index.ts",mapped:!0,listed:!0},{name:"css-variable",description:"CSS variable module",entry:"css/src/ext/variable.ts",mapped:!0,listed:!1},{name:"css-keyframes",description:"CSS keyframes module",entry:"css/src/ext/keyframes.ts",mapped:!0,listed:!1},{name:"css-property",description:"CSS property module",entry:"css/src/ext/property.ts",mapped:!0,listed:!1},{name:"for",description:"For loop control-flow",entry:"for/src/index.ts",mapped:!0,listed:!0},{name:"if",description:"If/Else/ElseIf control-flow",entry:"if/src/index.ts",mapped:!0,listed:!0},{name:"match",description:"Match/Case/Default control-flow",entry:"match/src/index.ts",mapped:!0,listed:!0},{name:"router",description:"Router module",entry:"router/src/index.ts",mapped:!0,listed:!0},{name:"i18n",description:"Translation module",entry:"i18n/src/index.ts",mapped:!0,listed:!0},{name:"idb",description:"IndexedDB module",entry:"idb/src/index.ts",mapped:!0,listed:!0},{name:"markdown",description:"Markdown to HTML module",codeInsert:'import { Markdown } from "amateras/markdown"; new Markdown();',entry:"markdown/src/index.ts",mapped:!0,listed:!0},{name:"prefetch",description:"SSR data prefetch",entry:"prefetch/src/index.ts",mapped:!0,listed:!0},{name:"meta",description:"SSR `meta` tag manager",entry:"meta/src/index.ts",mapped:!0,listed:!0},{name:"ui",description:"UI components",entry:"ui/src/index.ts",mapped:!0,listed:!0},{name:"utils",description:"Utilities module",entry:"utils/src/index.ts",mapped:!0,listed:!0}].map(e=>e.name),r={...t,...Object.fromEntries(s.map(t=>{const s=`amateras/${t}`,r=`${e}/${t}.js`;return[[s,r],[`@${s}`,r]]}).flat())},n=document.querySelector('script[type="importmap"]');if(n){const e=JSON.parse(n.innerHTML);e.imports={...e.imports,...r},n.innerHTML=JSON.stringify(e,null,"\t")}else{const e=document.createElement("script");e.setAttribute("type","importmap"),e.innerHTML=JSON.stringify({imports:r},null,"\t"),document.head.prepend(e)}
package/build/markdown.js CHANGED
@@ -1 +1 @@
1
- import{isString as t,forEach as e,uppercase as n,isUndefined as o,isIncluded as a,_Array_from as s}from"@amateras/utils";const r="BLOCK",l="IMAGE",i="LINK",c="QUICK_LINK",h="CODE",p="ITALIC",u="BOLD",d="TEXT_LINE",k="HEADING",T="CODE_START",g="CODE_END",f="UNORDERED_LIST_ITEM",m="ORDERED_LIST_ITEM",E="BLOCKQUOTE",y="ALERT",w="ALERT_LINE",L="HORIZONTAL_RULE",b="TABLE",x="EMPTY_LINE",I="INLINE_TEXT";class ${blockTokenizers=/* @__PURE__ */new Map;inlineTokenizers=/* @__PURE__ */new Map;blockTokenize(t){const e=t?.split(/\r?\n/)??[],n=[];let o=0;t:for(;o<e.length;){let t,a=e[o];if(void 0===a)throw"LINE ERROR";for(const[s,l]of this.blockTokenizers){const i=a.match(l.regex);if(i){const{content:a,multiLine:c,data:h}=l.handle(i,o,e);if(t={layout:r,type:s,content:a,data:h},c){n.push(t),n.push(...c.tokens),o=c.skip;continue t}break}}t||(t={layout:r,...a.length?{type:d,content:this.inlineTokenize(a)}:{type:x,content:[]}}),n.push(t),o++}return n}inlineTokenize(e){const n=[];let o=e;for(;o.length;){let e;for(const[a,s]of this.inlineTokenizers){const r=o.match(s.regex);if(r){const{index:l,0:i}=r;0!=l&&n.push(...this.inlineTokenize(o.substring(0,l)));const{content:c,data:h}=s.handle(r);e={type:a,...t(c)?{layout:I,text:c}:{layout:"INLINE_CONTENT",content:c}},h&&(e.data=h),o=o.substring(l+i.length);break}}e||(e={type:"TEXT",layout:I,text:o},o=""),n.push(e)}return n}use(...t){return e(t,t=>t(this)),this}}class N{processors=/* @__PURE__ */new Map;parse(e){let n="",o=0;if(!e)return n;for(;o<e.length;){const a=e[o],s=this.processors.get(a.type);if(s){const r=s(a,e.slice(o));t(r)?n+=r:(n+=r.html,o+=r.skipTokens)}o++}return n}use(...t){return e(t,t=>t(this)),this}}const z=(t,e,n)=>t.blockTokenizers.set(e,n),O=(t,e,n)=>t.inlineTokenizers.set(e,n),_=(t,e,n)=>t.processors.set(e,n),A=(t,e)=>`<${t}>${e}</${t}>`,R=t=>(e([["&","&amp;"],["<","&lt;"],[">","&gt;"],['"',"&quot;"],["'","&#39;"]],e=>t=t.replaceAll(...e)),t),C=t=>_(t,y,(e,o)=>{let a="",s=1;for(;s<o.length;){const e=o[s];if(e.type!==w)break;a+=t.parse(e.content[0].content),s++}const r=e.data?.alertType;return{html:`<blockquote class="alert alert-${r}"><p class="alert-title">${n(r,0,1)}</p>${a}</blockquote>`,skipTokens:s}}),M=t=>z(t,y,{regex:/^> ?\[!(?:(?:NOTE)|(?:TIP)|(?:IMPORTANT)|(?:WARNING)|(?:CAUTION))\]/,handle(e,n,o){const a=[],s=o[n].match(/> ?\[!(.+?)\]/),l=s?.[1]?.toLowerCase();for(n++;n<o.length;){const e=o[n].match(/^> ?(.+)/);if(!e)break;a.push({layout:r,type:w,content:t.blockTokenize(e[1])}),n++}return{content:[],data:{alertType:l},multiLine:{skip:n,tokens:a}}}}),D=t=>_(t,E,(e,n)=>{let o=0;const a=e=>{let s="";for(;o<n.length;){const{type:r,content:l,data:i}=n[o];if(r!==E)break;if(i.deep>e)s+=a(i.deep);else{if(i.deep<e)break;s+=t.parse(l),o++}}return A("blockquote",s)};return{html:a(e.data.deep),skipTokens:o}}),B=t=>z(t,E,{regex:/^(>+) ?(.+)?/,handle:e=>({content:t.blockTokenize(e[2]??""),data:{deep:e[1].length-1}})}),U=t=>_(t,u,e=>A("b",t.parse(e.content))),X=t=>O(t,u,{regex:/\*\*(.+?\*?)\*\*/,handle:e=>({content:t.inlineTokenize(e[1])})}),K=t=>_(t,h,t=>A("code",R(t.text))),S=t=>O(t,h,{regex:/`(.+?)`/,handle:t=>({content:t[1]})}),q=t=>_(t,T,(t,e)=>{let n="",o=1;for(;o<e.length;){const t=e[o];if(t.type===g)break;n+=t.content[0].text,o++}return{html:`<pre><code${t.data?.lang?` lang="${t.data.lang}"`:""}>${R(n)}</code></pre>`,skipTokens:o}}),v=t=>z(t,T,{regex:/^```(\w+)?/,handle:(t,e,n)=>{const o=[];for(e++;e<n.length;){const t=n[e];if(e++,t.includes("```")){o.push({layout:r,type:g,content:[]});break}o.push({layout:r,type:"CODE_LINE",content:[{layout:"INLINE_TEXT",type:"CODE_TEXT",text:`${t}\n`}]})}return{content:[],data:{lang:t[1]},multiLine:{skip:e,tokens:o}}}}),G=t=>_(t,k,e=>{const n=`h${e.data.level}`;return A(n,t.parse(e.content))}),H=t=>z(t,k,{regex:/^(#+) (.+)/,handle:e=>({content:t.inlineTokenize(e[2]),data:{level:e[1].length}})}),P=t=>_(t,L,t=>"<hr>"),j=t=>z(t,L,{regex:/^---/,handle:t=>({content:[]})}),Q=t=>_(t,l,e=>{const{url:n,title:o}=e.data;return`<img alt="${t.parse(e.content)}" src="${n}"${o?` title="${o}"`:""}>`}),W=t=>O(t,l,{regex:/^!\[(.+?)\]\((.+?)\)/,handle:e=>{const[n,o,a]=e,[s,r,l]=a.match(/(\w\w+?:\/\/[^\s]+)(?: "(.+?)")?/);return{content:t.inlineTokenize(o),data:{url:r,title:l}}}}),Y=t=>_(t,p,e=>`<i>${t.parse(e.content)}</i>`),Z=t=>O(t,p,{regex:/\*(.+?)\*/,handle:e=>({content:t.inlineTokenize(e[1])})}),F=t=>{const e=e=>{const{href:n,email:a,title:s}=e.data;return`<a href="${o(n)?`mailto:${a}`:n}"${s?` title="${s}"`:""}>${e.text??t.parse(e.content)}</a>`};_(t,c,e),_(t,i,e)},J=t=>{O(t,i,{regex:/\[(.+?)\]\(((?:\w+?@(?:\w|\.\w)+)|(?:\w\w+?:[^\s)]+))(?: "(.+)?")?\)/,handle:e=>{const[n,o,a,s]=e,r=a.match(/(?:\w+?@(?:\w|\.\w)+)|(?:\w\w+?:\/\/[^\s]+)/),[l]=r,i=l.includes("@")?{email:l}:{href:l};return{content:t.inlineTokenize(o),data:{title:s,...i}}}}),O(t,c,{regex:/<((?:\w+?@(?:\w|\.\w)+)|(?:\w\w+?:[^\s>]+))>/,handle:t=>{const[e,n]=t,o=n.match(/(?:\w+?@(?:\w|\.\w)+)|(?:\w\w+?:\/\/[^\s]+)/),[a]=o,s=a.includes("@")?{email:a}:{href:a};return{content:a,data:s}}})},V=e=>{const n=t=>t===m?"ol":"ul",o=(t,o)=>{let l=0;const i=/* @__PURE__ */new Map,c=(t,h)=>{const p=i.get(h),u=p&&n(t)===p.tagname?p:r(n(t),[]);for(i.set(h,u);l<o.length;){const n=o[l],r=n.type;if(!a(r,[m,f,x,d])){l--;break}if(r===d){const t=n.content[0]?.text;if(t?.match(/^\s\s/)){const e=t.match(/^(\s+)(.+)?/);if(!e[2]){l++;continue}n.data={deep:Math.trunc(e[1].length/2)-1}}else{if(!t?.match(/^\t/)){l--;break}{const e=t.match(/^(\t+)(.+)?/);if(!e[2]){l++;continue}n.data={deep:e[1].length-1}}}}if(r===x)l++;else if(n.data.deep!==h){if(!(n.data.deep>h)){i.delete(h);break}i.get(h)?.items.at(-1)?.content.push(c(r,n.data.deep))}else if(r===d)u.paragraph=!0,u.items.at(-1)?.content.push(e.parse(n.content)),l++;else{if(r!==t){i.delete(h);break}u.items.push(s([e.parse(n.content)])),l++}}return u};return{html:`${c(t.type,t.data.deep)}`,skipTokens:l}},s=t=>({content:t,toString(){return A("li",this.content.join(""))}}),r=(e,n)=>({tagname:e,items:n,paragraph:!1,toString(){return this.paragraph&&this.items.forEach(e=>e.content.forEach((n,o)=>t(n)&&(e.content[o]=A("p",n)))),A(this.tagname,this.items.join(""))}});_(e,f,o),_(e,m,o)},tt=t=>{const e=e=>{const n=e[0].split(/[-*]/)[0],o=n.match(/\s/)?.length??0,a=n.match(/\t/)?.length??0;return{content:t.inlineTokenize(e[1]),data:{deep:Math.trunc(a+o/2)}}};z(t,f,{regex:/^(?:[\s\t]+)?[-*] (.+)/,handle:e}),z(t,m,{regex:/^(?:[\s\t]+)?\d+\. (.+)/,handle:e})},et=t=>_(t,b,e=>{let n="",o="",a=0;for(const s of e.content){let r="";for(let n=0;n<s.content.length;n++){const o=s.content[n],l=0===a?"th":"td";r+=`<${l} align="${e.data.align[n]??"left"}">${t.parse(o.content)}</${l}>`}0===a?n+=A("thead",A("tr",r)):o+=A("tr",r),a++}return o=A("tbody",o),A("table",n+o)}),nt=t=>z(t,b,{regex:/\|(?:.+\|)+/,handle(e,n,o){const a=[],l=[];for(;n<o.length;){const e={type:"TABLE_ROW",layout:r,content:[]},i=o[n],c=s(i.matchAll(/\| ([^|]+)/g));if(!c.length)break;for(const n of c){const o=n[1],a=o.match(/(:)?---+(:)?/);if(a){const[t,e,n]=a;l.push(n?e?"center":"right":"left");continue}e.content.push({type:"TABLE_COLUMN",content:t.inlineTokenize(o.trim()),layout:r})}e.content.length&&a.push(e),n++}return{content:a,data:{align:l},multiLine:{skip:n,tokens:[]}}}}),ot=t=>_(t,"TEXT",t=>t.text),at=t=>_(t,d,(e,n)=>{let o="",a=0;for(const s of n){if(s.type===x)break;o+=t.parse(s.content),a++}return{html:A("p",o),skipTokens:a}});class st{lexer=new $;parser=new N;constructor(){this.lexer.use(H,v,tt,nt,M,B,j,W,J,S,X,Z),this.parser.use(ot,Q,F,K,Y,U,at,G,q,V,et,C,D,P)}parseHTML(t){return this.parser.parse(this.lexer.blockTokenize(t))}}export{st as Markdown,$ as MarkdownLexer,N as MarkdownParser};
1
+ import{Utils as e}from"@amateras/utils";const t="BLOCK",n="IMAGE",o="LINK",a="QUICK_LINK",s="CODE",r="ITALIC",i="BOLD",l="TEXT_LINE",c="HEADING",h="CODE_START",p="CODE_END",u="UNORDERED_LIST_ITEM",d="ORDERED_LIST_ITEM",g="BLOCKQUOTE",k="ALERT",T="ALERT_LINE",f="HORIZONTAL_RULE",m="TABLE",E="EMPTY_LINE",y="INLINE_TEXT";class w{blockTokenizers=/* @__PURE__ */new Map;inlineTokenizers=/* @__PURE__ */new Map;blockTokenize(e){const n=e?.split(/\r?\n/)??[],o=[];let a=0;e:for(;a<n.length;){let e,s=n[a];if(void 0===s)throw"LINE ERROR";for(const[r,i]of this.blockTokenizers){const l=s.match(i.regex);if(l){const{content:s,multiLine:c,data:h}=i.handle(l,a,n);if(e={layout:t,type:r,content:s,data:h},c){o.push(e),o.push(...c.tokens),a=c.skip;continue e}break}}e||(e={layout:t,...s.length?{type:l,content:this.inlineTokenize(s)}:{type:E,content:[]}}),o.push(e),a++}return o}inlineTokenize(t){const n=[];let o=t;for(;o.length;){let t;for(const[a,s]of this.inlineTokenizers){const r=o.match(s.regex);if(r){const{index:i,0:l}=r;0!=i&&n.push(...this.inlineTokenize(o.substring(0,i)));const{content:c,data:h}=s.handle(r);t={type:a,...e.isString(c)?{layout:y,text:c}:{layout:"INLINE_CONTENT",content:c}},h&&(t.data=h),o=o.substring(i+l.length);break}}t||(t={type:"TEXT",layout:y,text:o},o=""),n.push(t)}return n}use(...t){return e.forEach(t,e=>e(this)),this}}class L{processors=/* @__PURE__ */new Map;parse(t){let n="",o=0;if(!t)return n;for(;o<t.length;){const a=t[o],s=this.processors.get(a.type);if(s){const r=s(a,t.slice(o));e.isString(r)?n+=r:(n+=r.html,o+=r.skipTokens)}o++}return n}use(...t){return e.forEach(t,e=>e(this)),this}}const b=(e,t,n)=>e.blockTokenizers.set(t,n),x=(e,t,n)=>e.inlineTokenizers.set(t,n),I=(e,t,n)=>e.processors.set(t,n),$=(e,t)=>`<${e}>${t}</${e}>`,N=t=>(e.forEach([["&","&amp;"],["<","&lt;"],[">","&gt;"],['"',"&quot;"],["'","&#39;"]],e=>t=t.replaceAll(...e)),t),z=t=>I(t,k,(n,o)=>{let a="",s=1;for(;s<o.length;){const e=o[s];if(e.type!==T)break;a+=t.parse(e.content[0].content),s++}const r=n.data?.alertType;return{html:`<blockquote class="alert alert-${r}"><p class="alert-title">${e.uppercase(r,0,1)}</p>${a}</blockquote>`,skipTokens:s}}),O=e=>b(e,k,{regex:/^> ?\[!(?:(?:NOTE)|(?:TIP)|(?:IMPORTANT)|(?:WARNING)|(?:CAUTION))\]/,handle(n,o,a){const s=[],r=a[o].match(/> ?\[!(.+?)\]/),i=r?.[1]?.toLowerCase();for(o++;o<a.length;){const n=a[o].match(/^> ?(.+)/);if(!n)break;s.push({layout:t,type:T,content:e.blockTokenize(n[1])}),o++}return{content:[],data:{alertType:i},multiLine:{skip:o,tokens:s}}}}),_=e=>I(e,g,(t,n)=>{let o=0;const a=t=>{let s="";for(;o<n.length;){const{type:r,content:i,data:l}=n[o];if(r!==g)break;if(l.deep>t)s+=a(l.deep);else{if(l.deep<t)break;s+=e.parse(i),o++}}return $("blockquote",s)};return{html:a(t.data.deep),skipTokens:o}}),A=e=>b(e,g,{regex:/^(>+) ?(.+)?/,handle:t=>({content:e.blockTokenize(t[2]??""),data:{deep:t[1].length-1}})}),R=e=>I(e,i,t=>$("b",e.parse(t.content))),C=e=>x(e,i,{regex:/\*\*(.+?\*?)\*\*/,handle:t=>({content:e.inlineTokenize(t[1])})}),M=e=>I(e,s,e=>$("code",N(e.text))),D=e=>x(e,s,{regex:/`(.+?)`/,handle:e=>({content:e[1]})}),S=e=>I(e,h,(e,t)=>{let n="",o=1;for(;o<t.length;){const e=t[o];if(e.type===p)break;n+=e.content[0].text,o++}return{html:`<pre><code${e.data?.lang?` lang="${e.data.lang}"`:""}>${N(n)}</code></pre>`,skipTokens:o}}),U=e=>b(e,h,{regex:/^```(\w+)?/,handle:(e,n,o)=>{const a=[];for(n++;n<o.length;){const e=o[n];if(n++,e.includes("```")){a.push({layout:t,type:p,content:[]});break}a.push({layout:t,type:"CODE_LINE",content:[{layout:"INLINE_TEXT",type:"CODE_TEXT",text:`${e}\n`}]})}return{content:[],data:{lang:e[1]},multiLine:{skip:n,tokens:a}}}}),B=e=>I(e,c,t=>{const n=`h${t.data.level}`;return $(n,e.parse(t.content))}),X=e=>b(e,c,{regex:/^(#+) (.+)/,handle:t=>({content:e.inlineTokenize(t[2]),data:{level:t[1].length}})}),K=e=>I(e,f,e=>"<hr>"),q=e=>b(e,f,{regex:/^---/,handle:e=>({content:[]})}),v=e=>I(e,n,t=>{const{url:n,title:o}=t.data;return`<img alt="${e.parse(t.content)}" src="${n}"${o?` title="${o}"`:""}>`}),G=e=>x(e,n,{regex:/^!\[(.+?)\]\((.+?)\)/,handle:t=>{const[n,o,a]=t,[s,r,i]=a.match(/(\w\w+?:\/\/[^\s]+)(?: "(.+?)")?/);return{content:e.inlineTokenize(o),data:{url:r,title:i}}}}),H=e=>I(e,r,t=>`<i>${e.parse(t.content)}</i>`),P=e=>x(e,r,{regex:/\*(.+?)\*/,handle:t=>({content:e.inlineTokenize(t[1])})}),j=t=>{const n=n=>{const{href:o,email:a,title:s}=n.data;return`<a href="${e.isUndefined(o)?`mailto:${a}`:o}"${s?` title="${s}"`:""}>${n.text??t.parse(n.content)}</a>`};I(t,a,n),I(t,o,n)},Q=e=>{x(e,o,{regex:/\[(.+?)\]\(((?:\w+?@(?:\w|\.\w)+)|(?:\w\w+?:[^\s)]+))(?: "(.+)?")?\)/,handle:t=>{const[n,o,a,s]=t,r=a.match(/(?:\w+?@(?:\w|\.\w)+)|(?:\w\w+?:\/\/[^\s]+)/),[i]=r,l=i.includes("@")?{email:i}:{href:i};return{content:e.inlineTokenize(o),data:{title:s,...l}}}}),x(e,a,{regex:/<((?:\w+?@(?:\w|\.\w)+)|(?:\w\w+?:[^\s>]+))>/,handle:e=>{const[t,n]=e,o=n.match(/(?:\w+?@(?:\w|\.\w)+)|(?:\w\w+?:\/\/[^\s]+)/),[a]=o,s=a.includes("@")?{email:a}:{href:a};return{content:a,data:s}}})},W=t=>{const n=e=>e===d?"ol":"ul",o=(o,r)=>{let i=0;const c=/* @__PURE__ */new Map,h=(o,p)=>{const g=c.get(p),k=g&&n(o)===g.tagname?g:s(n(o),[]);for(c.set(p,k);i<r.length;){const n=r[i],s=n.type;if(!e.isIncluded(s,[d,u,E,l])){i--;break}if(s===l){const e=n.content[0]?.text;if(e?.match(/^\s\s/)){const t=e.match(/^(\s+)(.+)?/);if(!t[2]){i++;continue}n.data={deep:Math.trunc(t[1].length/2)-1}}else{if(!e?.match(/^\t/)){i--;break}{const t=e.match(/^(\t+)(.+)?/);if(!t[2]){i++;continue}n.data={deep:t[1].length-1}}}}if(s===E)i++;else if(n.data.deep!==p){if(!(n.data.deep>p)){c.delete(p);break}c.get(p)?.items.at(-1)?.content.push(h(s,n.data.deep))}else if(s===l)k.paragraph=!0,k.items.at(-1)?.content.push(t.parse(n.content)),i++;else{if(s!==o){c.delete(p);break}k.items.push(a([t.parse(n.content)])),i++}}return k};return{html:`${h(o.type,o.data.deep)}`,skipTokens:i}},a=e=>({content:e,toString(){return $("li",this.content.join(""))}}),s=(t,n)=>({tagname:t,items:n,paragraph:!1,toString(){return this.paragraph&&this.items.forEach(t=>t.content.forEach((n,o)=>e.isString(n)&&(t.content[o]=$("p",n)))),$(this.tagname,this.items.join(""))}});I(t,u,o),I(t,d,o)},F=e=>{const t=t=>{const n=t[0].split(/[-*]/)[0],o=n.match(/\s/)?.length??0,a=n.match(/\t/)?.length??0;return{content:e.inlineTokenize(t[1]),data:{deep:Math.trunc(a+o/2)}}};b(e,u,{regex:/^(?:[\s\t]+)?[-*] (.+)/,handle:t}),b(e,d,{regex:/^(?:[\s\t]+)?\d+\. (.+)/,handle:t})},Y=e=>I(e,m,t=>{let n="",o="",a=0;for(const s of t.content){let r="";for(let n=0;n<s.content.length;n++){const o=s.content[n],i=0===a?"th":"td";r+=`<${i} align="${t.data.align[n]??"left"}">${e.parse(o.content)}</${i}>`}0===a?n+=$("thead",$("tr",r)):o+=$("tr",r),a++}return o=$("tbody",o),$("table",n+o)}),Z=n=>b(n,m,{regex:/\|(?:.+\|)+/,handle(o,a,s){const r=[],i=[];for(;a<s.length;){const o={type:"TABLE_ROW",layout:t,content:[]},l=s[a],c=e.arrayFrom(l.matchAll(/\| ([^|]+)/g));if(!c.length)break;for(const e of c){const a=e[1],s=a.match(/(:)?---+(:)?/);if(s){const[e,t,n]=s;i.push(n?t?"center":"right":"left");continue}o.content.push({type:"TABLE_COLUMN",content:n.inlineTokenize(a.trim()),layout:t})}o.content.length&&r.push(o),a++}return{content:r,data:{align:i},multiLine:{skip:a,tokens:[]}}}}),J=e=>I(e,"TEXT",e=>e.text),V=e=>I(e,l,(t,n)=>{let o="",a=0;for(const s of n){if(s.type===E)break;o+=e.parse(s.content),a++}return{html:$("p",o),skipTokens:a}});class ee{lexer=new w;parser=new L;constructor(){this.lexer.use(X,U,F,Z,O,A,q,G,Q,D,C,P),this.parser.use(J,v,j,M,H,R,V,B,S,W,Y,z,_,K)}parseHTML(e){return this.parser.parse(this.lexer.blockTokenize(e))}}export{ee as Markdown,w as MarkdownLexer,L as MarkdownParser};
package/build/match.js CHANGED
@@ -1 +1 @@
1
- import{Proto as t,symbol_Statement as e,ProxyProto as s}from"@amateras/core";import{isArray as i,_null as a,forEach as d,is as h}from"@amateras/utils";class l extends t{static[e]=!0;condition;constructor(t,e){super(e),this.condition=i(t)?t:[t]}}class r extends t{static[e]=!0;constructor(t){super(t)}}class c extends s{static[e]=!0;exp$;cases=/* @__PURE__ */new Set;matched=a;#t=a;constructor(t,e){super(()=>{e((t,e,s)=>{$(t,e,s)})}),this.exp$=t}dispose(){d(this.cases,t=>t.dispose()),this.#t?.dispose(),this.matched=a,this.#t=a,this.cases.clear()}build(){super.build(!1),this.validate();let t=()=>{let t=this.matched,e=this.validate();t!==e&&(d(this.cases,t=>t!==e&&t.removeNode()),e!==this.#t&&this.#t?.removeNode(),this.node?.replaceWith(...this.toDOM()),this.parent?.mutate())};return d(this.cases,e=>{this.exp$.subscribe(t),e.listen("dispose",()=>this.exp$.unsubscribe(t))}),this}case(t,e){let s=new l(t,e);return this.cases.add(s),s}default(t){let e=new r(t);return this.#t=e,e}validate(){this.clear();for(let t of this.cases)if(t.condition.includes(this.exp$.value))return this.append(t),t.builded||t.build(),this.matched=t;if(this.#t)return this.append(this.#t),this.#t.builded||this.#t.build(),this.matched=this.#t}}globalThis.Match=c,globalThis.Case=l,globalThis.Default=r,$.process.craft.add((e,s,i)=>e===c?new c(s,i):e===l?h(t.proto,c)?.case(s,i):e===r?h(t.proto,c)?.default(s):void 0);
1
+ import{Proto as t,symbol_Statement as e,ProxyProto as s}from"@amateras/core";import{Utils as i}from"@amateras/utils";class a extends t{static[e]=!0;condition;constructor(t,e){super(e),this.condition=i.isArray(t)?t:[t]}}class l extends t{static[e]=!0;constructor(t){super(t)}}class d extends s{static[e]=!0;exp$;cases=/* @__PURE__ */new Set;matched=i.Null;#t=i.Null;constructor(t,e){super(()=>{e((t,e,s)=>{$(t,e,s)})}),this.exp$=t}dispose(){i.forEach(this.cases,t=>t.dispose()),this.#t?.dispose(),this.matched=i.Null,this.#t=i.Null,this.cases.clear()}build(){super.build(!1),this.validate();let t=()=>{let t=this.matched,e=this.validate();t!==e&&(i.forEach(this.cases,t=>t!==e&&t.removeNode()),e!==this.#t&&this.#t?.removeNode(),this.node?.replaceWith(...this.toDOM()),this.parent?.mutate(),this.parent?.dispatch("mutate",[],{bubbles:!0}))};return i.forEach(this.cases,e=>{this.exp$.subscribe(t),e.listen("dispose",()=>this.exp$.unsubscribe(t))}),this}mutate(){super.mutate(),this.parent?.mutate()}case(t,e){let s=new a(t,e);return this.cases.add(s),s}default(t){let e=new l(t);return this.#t=e,e}validate(){this.clear();for(let t of this.cases)if(t.condition.includes(this.exp$.value))return this.append(t),t.builded||t.build(),this.matched=t;if(this.#t)return this.append(this.#t),this.#t.builded||this.#t.build(),this.matched=this.#t}}globalThis.Match=d,globalThis.Case=a,globalThis.Default=l,$.process.craft.add((e,s,h)=>e===d?new d(s,h):e===a?i.is(t.proto,d)?.case(s,h):e===l?i.is(t.proto,d)?.default(s):void 0);
package/build/meta.js CHANGED
@@ -1 +1 @@
1
- import{_Object_entries as t,isString as o,isArray as e,forEach as r,_Object_assign as n,isNull as a,isObject as m}from"@amateras/utils";import{Proto as i,onclient as s,onserver as c}from"@amateras/core";const p=(n,a,m,i)=>{let s=t=>m?`${m}:${t}`:t,c=(t,o)=>a.push({[i]:s(t),content:o});for(const[f,l]of t(n))o(l)?c(f,l):e(l)?r(l,t=>{o(t)?c(f,t):p(t,a,s(f),i)}):p(l,a,s(f),i)};function f(o,e){for(const[r,n]of t(e))!a(n)&&m(n)&&o[r]?f(o[r],n):o[r]=n;return o}n($,{meta(t,o=i.proto){s()||o&&(o.global.meta=f(o.global.meta??{},t))}}),c()&&n($.meta,{resolve:function(t){let o=[],{description:e,og:r,twitter:n}=t;return e&&o.push({name:"description",content:e}),r&&p(r,o,"og","property"),n&&p(n,o,"twitter","name"),o}});
1
+ import{Utils as t}from"@amateras/utils";import{Proto as r,onclient as e,onserver as o}from"@amateras/core";const n=(r,e,o,i)=>{let s=t=>o?`${o}:${t}`:t,a=(t,r)=>e.push({[i]:s(t),content:r});for(const[c,m]of t.entries(r))t.isString(m)?a(c,m):t.isArray(m)?t.forEach(m,r=>{t.isString(r)?a(c,r):n(r,e,s(c),i)}):n(m,e,s(c),i)};function i(r,e){for(const[o,n]of t.entries(e))!t.isNull(n)&&t.isObject(n)&&r[o]?i(r[o],n):r[o]=n;return r}t.assign($,{meta(t,o=r.proto){e()||o&&(o.global.meta=i(o.global.meta??{},t))}}),o()&&t.assign($.meta,{resolve:function(t){let r=[],{description:e,og:o,twitter:i}=t;return e&&r.push({name:"description",content:e}),o&&n(o,r,"og","property"),i&&n(i,r,"twitter","name"),r}});
package/build/prefetch.js CHANGED
@@ -1 +1 @@
1
- import{GlobalState as e,Proto as r,onclient as t,onserver as a}from"@amateras/core";import{_Object_assign as o,toURL as i,_null as c,isAsyncFunction as h}from"@amateras/utils";e.assign(()=>({prefetch:{caches:{},req:null}})),globalThis.prefetch||(globalThis.prefetch={}),o($,{async fetch(e,o,l=r.proto){e=i(e,$.fetch.origin);let s=t()?prefetch[e.href]:c,n=o?.then,f=new Promise(async t=>{if(s&&Date.now()<s.expired){let e=n?.(s.data);return void t({record:s.data,result:e})}let{origin:i,server:c}=$.fetch,f=l?.global.prefetch.req?.headers.get("cookie")||"",d=e.origin===i&&c?await c.fetch(new Request(e,{...o,headers:{...o?.headers,Cookie:f}})):await fetch(e,o),g=o?.record;if(g){let o,i=h(g)?await g(d):g(d);a()&&l&&(l.global.prefetch.caches[e.href]={data:i,expired:Date.now()+3e4}),$.context(r,l,()=>{o=n?.(i)}),t({record:i,result:o})}});return a()&&l?.global.asyncTask(f),f}}),o($.fetch,{origin:t()?location.origin:"http://localhost",server:null});
1
+ import{GlobalState as e,onclient as t,Proto as r,onserver as o}from"@amateras/core";import{Utils as i}from"@amateras/utils";e.assign(()=>({prefetch:{caches:{},req:null,expired:Date.now()+3e4}})),e.disposers.add(e=>{e.prefetch.caches=i.Null,e.prefetch.req=i.Null,e.prefetch=i.Null}),t()&&!globalThis.prefetch&&(globalThis.prefetch={caches:{},expired:Date.now()}),i.assign($,{async fetch(e,c,l=r.proto){e=i.toURL(e,$.fetch.origin);let h=t()&&Date.now()<prefetch.expired?s(e,c):i.Null,n=c?.then,d=new Promise(async t=>{if(h){let e=n?.(h.data);return void t({record:h.data,result:e})}let{origin:s,server:d}=$.fetch,f=l?.global.prefetch.req?.headers.get("cookie")||"",p=e.origin===s&&d?await d.fetch(new Request(e,{...c,headers:{...c?.headers,Cookie:f}})):await fetch(e,c),u=c?.record;if(u){let s,h=i.isAsyncFunction(u)?await u(p):u(p);o()&&l&&a(l,e,h,c),$.context(r,l,()=>{s=n?.(h)}),t({record:h,result:s})}});return o()&&l?.global.asyncTask(d),d}});const a=(e,t,r,o)=>{const a=e.global.prefetch.caches[t.href]??[],s=i.isUndefined(o?.body)?"":i.isString(o.body)?o.body:i.Null;i.isNull(s)||(a.push({data:r,method:o?.method??"GET",body:s}),e.global.prefetch.caches[t.href]=a)},s=(e,t)=>{const r=prefetch.caches[e.href],o=i.isUndefined(t?.body)?"":i.isString(t.body)?t.body:i.Null;if(!i.isNull(o)&&r)return r.find(e=>{if(e.method===(t?.method??"GET"))return e.body===o||void 0})};i.assign($.fetch,{origin:t()?location.origin:"http://localhost",server:null});
package/build/router.js CHANGED
@@ -1 +1 @@
1
- import{ElementProto as t,onclient as e,Proto as s,ProxyProto as r,symbol_ProtoType as o,GlobalState as i}from"@amateras/core";import{_undefined as l,toURL as a,_null as n,forEach as h,map as c,_JSON_parse as u,_Object_entries as p,_JSON_stringify as d,is as f,_instanceof as g,isUndefined as v,isFunction as w,isArray as y,_Object_assign as b}from"@amateras/utils";class m extends t{constructor(t,e){super("a",t,e),this.on("click",t=>{if(t.shiftKey||t.ctrlKey)return;t.preventDefault();let e=this.attr("target"),s=this.attr("href");s&&("_replace"===e?$.replace(s):$.open(s,e??l))})}}let P=0;const[k,x]=[1,2],[S,T]=["forward","back"],E="__scroll_history__",R=e()?sessionStorage:n,_=e()?window.addEventListener:n,A=e()?window.removeEventListener:n;e()&&(history.scrollRestoration="manual");const L=t=>{const e=M.scrollHistory;if(t){let s=t.target;"#document"===s.nodeName?e[P]={[s.nodeName]:{x:window.scrollX,y:window.scrollY}}:""!==s.id&&(e[P]={[s.id]:{x:s.scrollLeft,y:s.scrollTop}})}else h(p(e),([t])=>+t>=P&&delete e[+t]);R?.setItem(E,d(e))};class M extends s{static direction=S;prev=n;url=n;routes=/* @__PURE__ */new Map;slot=new Q;static routers=/* @__PURE__ */new Set;constructor(){super(()=>$(this.slot)),e()&&M.routers.add(this)}set href(t){this.global.router.href=t}build(){if(e()){const t=()=>{const t=history.state?.index??0;P>t&&(M.direction=T),P<t&&(M.direction=S),P=t,this.prev=this.href,this.href=a(location.href),this.resolve(location.href)};t(),_?.("popstate",t),_?.("scroll",L,{capture:!0,passive:!1}),this.listen("dispose",()=>{A?.("popstate",t),A?.("scroll",L,{capture:!0})})}return super.build()}async resolve(t){if(!t)return;let e=a(t);this.global.router.scrollQueue.clear();for(let[,s]of this.routes){let t=await s.resolve(e.pathname,this.slot,{});if(t){this.global.router.routes=t;let e=[""],s=[];h(t,t=>(e=c(t.validPaths,t=>c(e,e=>e+t)).flat(),s.push(...e),e)),this.global.router.matchPaths=s;break}}this.url=e,h(this.global.router.navlinks,t=>t.checkActive()),M.dispatchEvent(),Promise.all(this.global.router.scrollQueue).then(()=>{e===this.url&&M.scrollRestoration()})}static open(t,e="_self"){a(t).origin!==origin?open(t,e):M.writeState(t,k,e)}static forward(){history.forward()}static back(){history.back()}static replace(t){M.writeState(t,x)}static get scrollData(){return this.scrollHistory[P]??{}}static get scrollHistory(){return u(R?.getItem(E)??"{}")}static scrollRestoration(){if(e()){let t=M.scrollData??{x:0,y:0},e=p(t);e.length?h(e,([t,{x:e,y:s}])=>{"#document"===t?window.scrollTo(e,s):document.getElementById(t)?.scrollTo(e,s)}):(document.querySelectorAll("*").forEach(t=>t.scrollTo(0,0)),window.scrollTo(0,0))}}static writeState(t,s,r){if(!t)return;let o=a(t);if(!e()||o.href!==location.href){if(r&&"_self"!==r)return open(o,r);s===k&&P++,e()&&L(),h(this.routers,r=>{M.direction=S,e()&&(r.prev=a(location.href),history[s===k?"pushState":"replaceState"]({index:P},"",o)),r.href=o,r.resolve(t)}),M.dispatchEvent()}}static dispatchEvent(){e()&&window.dispatchEvent(new Event("pathchange"))}}class Q extends r{page=n;prevPage=n;constructor(){super()}switch(t){this.page!==t&&(this.prevPage=this.page,this.clear(),this.layout=()=>$(t),this.append(t),this.page=t,t.builded||t.build(),t.updateTitle(),this.dispatch("pageswitch",[this,M.direction],{bubbles:!0})||this.render())}render(){if(e()){this.prevPage?.removeNode();let t=this.toDOM();this.node?.replaceWith(...t)}}dispose(){super.dispose(),this.page=n,this.prevPage=n}}class D extends s{slot=new Q;route;title=n;constructor(t,e,s){super(()=>e({params:s,slot:this.slot})),this.route=t}updateTitle(){let t=this.title??this.findAbove(t=>f(t,D)?.title)?.title??n,s=t=>{e()&&(document.title=t),this.global.title=t};t&&(g(t,Promise)?t.then(t=>{this.title=t,s(t)}):s(t))}}class N{routes=/* @__PURE__ */new Map;path;paths=/* @__PURE__ */new Map;validPaths=[];constructor(t){this.path=t,this.paths.set(t,l)}routing(t){let e=t.split("/"),s={},r="";t:for(let[i,l]of this.paths){s={};let t=i.split("/"),o=[];for(let s=0;s<Math.max(e.length,t.length);s++)o.push([t[s],e[s]]);e:for(let[e,i]of o){let t=()=>{r=""},o=()=>{r+=("/"!==r?"/":"")+i};if(v(e))break e;if(v(i)){t();continue t}if(e?.includes(":")){let[r,l]=e.split(":");if(!i.startsWith(r)){t();continue t}s[l]=i.replace(r,""),o();continue e}if(e!==i){t();continue t}o()}if(r){s={...s,...w(l)?l():l};break t}}if(!r)return;let o=N.resolvePath(this.path,s);return this.validPaths=c(this.paths,t=>N.resolvePath(t[0],s)),[o,r,s]}static resolvePath(t,e){return t.replaceAll(/:([^/]+)/g,(t,s)=>`${e[s]}`)}alias(t,e){return this.paths.set(t,e),this}}class H extends N{constructor(t){super(t)}async resolve(t,e,s){let r=this.routing(t);if(!r)return;let[,o,i]=r;s={...s,...i};let l=t.replace(o,"");for(let[a,n]of this.routes){let t=await n.resolve(l||"/",e,s);if(t)return[this,...t]}return[this]}}class I extends N{pages=/* @__PURE__ */new Map;page=n;#t;constructor(t,e){super(t),this.#t=e}async resolve(t,e,s){let r=this.routing(t);if(!r)return;let[o,i,l]=r;s={...s,...l};let a=await this.usePage(o,s,e),n=t.replace(i,"");for(let[h,c]of this.routes){let t=await c.resolve(n||"/",a.slot,s);if(t)return[this,...t]}return n?void 0:[this]}async usePage(t,r,i){let l=this.pages.get(t);if(!l){let a,n=this.#t;if(y(n)){let t=n[0]();e()&&t.catch(()=>location.reload());let s=await t.then(t=>t.default);a=()=>$(s,r,()=>$(l.slot))}else a="Widget"===this.#t[o]?()=>$(this.#t,r,()=>$(l.slot)):this.#t;$.context(s,i,()=>{l=new D(this,a,r)}),this.pages.set(t,l)}return this.page=l,i.switch(l),l}}const W=t=>class extends M{static[o]="Router";constructor(){super(),t(this)}};let K={route(t,e,s){let r=new I(t,e);return this.routes.set(t,r),s?.(r),this},group(t,e){let s=new H(t);return this.routes.set(t,s),e?.(s),this},notfound(){}};b(N.prototype,K),b(M.prototype,K),i.assign(()=>({router:{routers:/* @__PURE__ */new Set,resolve(t){return c(this.routers,e=>e.resolve(t))},href:new URL("http://localhost"),routes:[],matchPaths:[],navlinks:/* @__PURE__ */new Set,scrollQueue:/* @__PURE__ */new Set,postScrollRestoration(t){t.finally(()=>this.scrollQueue.delete(t)),this.scrollQueue.add(t)}}})),i.disposers.add(({router:t})=>{t.routers.clear(),t.routes=[],t.matchPaths=[],t.navlinks.clear()}),b($,{router:t=>W(t),open:M.open,replace:M.replace,back:M.back,forward:M.forward,scrollRestoration:M.scrollRestoration,title(t,e=s.proto){let r=e?.findAbove(t=>f(t,D));r&&(r.title=t,r.updateTitle())}}),globalThis.Link=m,globalThis.NavLink=class extends m{constructor(t,e){super(t,e),this.global.router.navlinks.add(this)}checkActive(){let t=this.attr("href");if(t){for(let e of this.global.router.matchPaths)if(a(e).href===a(t).href)return this.attr("active","");this.attr("active",n)}}},$.process.craft.add(t=>{if(w(t)&&"Router"===t[o]){let e=s.proto,r=new t;return e?.global.router.routers.add(r),r}});export{m as Link,D as Page,N as Route,H as RouteGroup,I as RouteNode,Q as RouteSlot,M as Router};
1
+ import{ElementProto as t,onclient as e,Proto as s,ProxyProto as r,symbol_ProtoType as i,GlobalState as o}from"@amateras/core";import{Utils as l}from"@amateras/utils";class a extends t{constructor(t,e){super("a",t,e),this.on("click",t=>{if(t.shiftKey||t.ctrlKey)return;t.preventDefault();let e=this.attr("target"),s=this.attr("href");s&&("_replace"===e?$.replace(s):$.open(s,e??l.Undefined))})}}let n=0;const[h,c]=[1,2],[u,p]=["forward","back"],d="__scroll_history__",f=e()?sessionStorage:l.Null,g=e()?window.addEventListener:l.Null,v=e()?window.removeEventListener:l.Null;e()&&(history.scrollRestoration="manual");const w=t=>{const e=y.scrollHistory;if(t){let s=t.target;"#document"===s.nodeName?e[n]={[s.nodeName]:{x:window.scrollX,y:window.scrollY}}:""!==s.id&&(e[n]={[s.id]:{x:s.scrollLeft,y:s.scrollTop}})}else l.forEach(l.entries(e),([t])=>+t>=n&&delete e[+t]);f?.setItem(d,l.stringify(e))};class y extends s{static direction=u;prev=l.Null;url=l.Null;routes=/* @__PURE__ */new Map;slot=new b;static routers=/* @__PURE__ */new Set;constructor(){super(()=>$(this.slot)),e()&&y.routers.add(this)}set href(t){this.global.router.href=t}build(){if(e()){const t=()=>{const t=history.state?.index??0;n>t&&(y.direction=p),n<t&&(y.direction=u),n=t,this.prev=this.href,this.href=l.toURL(location.href),this.resolve(location.href)};t(),g?.("popstate",t),g?.("scroll",w,{capture:!0,passive:!1}),this.listen("dispose",()=>{v?.("popstate",t),v?.("scroll",w,{capture:!0})})}return super.build()}dispose(t){super.dispose(t),y.routers.delete(this)}async resolve(t){if(!t)return;let e=l.toURL(t);this.global.router.scrollQueue.clear();for(let[,s]of this.routes){let t=await s.resolve(e.pathname,this.slot,{});if(t){this.global.router.routes=t;let e=[""],s=[];l.forEach(t,t=>(e=l.map(t.validPaths,t=>l.map(e,e=>e+t)).flat(),s.push(...e),e)),this.global.router.matchPaths=s;break}}this.url=e,l.forEach(this.global.router.navlinks,t=>t.checkActive()),y.dispatchEvent(),Promise.all(this.global.router.scrollQueue).then(()=>{e===this.url&&y.scrollRestoration()})}static open(t,e="_self"){l.toURL(t).origin!==origin?open(t,e):y.writeState(t,h,e)}static forward(){history.forward()}static back(){history.back()}static replace(t){y.writeState(t,c)}static get scrollData(){return this.scrollHistory[n]??{}}static get scrollHistory(){return l.json(f?.getItem(d)??"{}")}static scrollRestoration(){if(e()){let t=y.scrollData??{x:0,y:0},e=l.entries(t);e.length?l.forEach(e,([t,{x:e,y:s}])=>{"#document"===t?window.scrollTo(e,s):document.getElementById(t)?.scrollTo(e,s)}):(document.querySelectorAll("*").forEach(t=>t.scrollTo(0,0)),window.scrollTo(0,0))}}static writeState(t,s,r){if(!t)return;let i=l.toURL(t);if(!e()||i.href!==location.href){if(r&&"_self"!==r)return open(i,r);s===h&&n++,e()&&w(),y.direction=u,l.forEach(this.routers,t=>{e()&&(t.prev=l.toURL(location.href)),t.href=i}),e()&&history[s===h?"pushState":"replaceState"]({index:n},"",i),l.forEach(this.routers,e=>e.resolve(t)),y.dispatchEvent()}}static dispatchEvent(){e()&&window.dispatchEvent(new Event("pathchange"))}}class b extends r{page=l.Null;prevPage=l.Null;constructor(){super()}switch(t){this.page!==t&&(this.prevPage=this.page,this.clear(),this.layout=()=>$(t),this.append(t),this.page=t,t.builded||t.build(),t.updateTitle(),this.dispatch("pageswitch",[this,y.direction],{bubbles:!0})||this.render())}render(){if(e()){this.prevPage?.removeNode();let t=this.toDOM();this.node?.replaceWith(...t)}}dispose(){super.dispose(),this.page=l.Null,this.prevPage=l.Null}}class m extends s{slot=new b;route;title=l.Null;constructor(t,e,s){super(()=>e({params:s,slot:this.slot})),this.route=t}updateTitle(){let t=this.title??this.findAbove(t=>l.is(t,m)?.title)?.title??l.Null,s=t=>{e()&&(document.title=t),this.global.title=t};t&&(l.isInstanceof(t,Promise)?t.then(t=>{this.title=t,s(t)}):s(t))}}class k{routes=/* @__PURE__ */new Map;path;paths=/* @__PURE__ */new Map;validPaths=[];constructor(t){this.path=t,this.paths.set(t,l.Undefined)}routing(t){let e=t.split("/"),s={},r="";t:for(let[o,a]of this.paths){s={};let t=o.split("/"),i=[];for(let s=0;s<Math.max(e.length,t.length);s++)i.push([t[s],e[s]]);e:for(let[e,o]of i){let t=()=>{r=""},i=()=>{r+=("/"!==r?"/":"")+o};if(l.isUndefined(e))break e;if(l.isUndefined(o)){t();continue t}if(e?.includes(":")){let[r,l]=e.split(":");if(!o.startsWith(r)){t();continue t}s[l]=o.replace(r,""),i();continue e}if(e!==o){t();continue t}i()}if(r){s={...s,...l.isFunction(a)?a():a};break t}}if(!r)return;let i=k.resolvePath(this.path,s);return this.validPaths=l.map(this.paths,t=>k.resolvePath(t[0],s)),[i,r,s]}static resolvePath(t,e){return t.replaceAll(/:([^/]+)/g,(t,s)=>`${e[s]}`)}alias(t,e){return this.paths.set(t,e),this}}class P extends k{constructor(t){super(t)}async resolve(t,e,s){let r=this.routing(t);if(!r)return;let[,i,o]=r;s={...s,...o};let l=t.replace(i,"");for(let[a,n]of this.routes){let t=await n.resolve(l||"/",e,s);if(t)return[this,...t]}return[this]}}class x extends k{pages=/* @__PURE__ */new Map;page=l.Null;#t;constructor(t,e){super(t),this.#t=e}async resolve(t,e,s){let r=this.routing(t);if(!r)return;let[i,o,l]=r;s={...s,...l};let a=await this.usePage(i,s,e),n=t.replace(o,"");for(let[h,c]of this.routes){let t=await c.resolve(n||"/",a.slot,s);if(t)return[this,...t]}return n?void 0:[this]}async usePage(t,r,o){let a=this.pages.get(t);if(!a){let n,h=this.#t;if(l.isArray(h)){let t=h[0]();e()&&t.catch(()=>location.reload());let s=await t.then(t=>t.default);n=()=>$(s,r,()=>$(a.slot))}else n="Widget"===this.#t[i]?()=>$(this.#t,r,()=>$(a.slot)):this.#t;$.context(s,o,()=>{a=new m(this,n,r)}),this.pages.set(t,a)}return this.page=a,o.switch(a),a}}const N=t=>class extends y{static[i]="Router";constructor(){super(),t(this)}};let R={route(t,e,s){let r=new x(t,e);return this.routes.set(t,r),s?.(r),this},group(t,e){let s=new P(t);return this.routes.set(t,s),e?.(s),this},notfound(){}};l.assign(k.prototype,R),l.assign(y.prototype,R),o.assign(()=>({router:{routers:/* @__PURE__ */new Set,resolve(t){return l.map(this.routers,e=>e.resolve(t))},href:new URL("http://localhost"),routes:[],matchPaths:[],navlinks:/* @__PURE__ */new Set,scrollQueue:/* @__PURE__ */new Set,postScrollRestoration(t){t.finally(()=>this.scrollQueue.delete(t)),this.scrollQueue.add(t)}}})),o.disposers.add(({router:t})=>{t.routers.clear(),t.routes=[],t.matchPaths=[],t.navlinks.clear()}),l.assign($,{router:t=>N(t),open:y.open,replace:y.replace,back:y.back,forward:y.forward,scrollRestoration:y.scrollRestoration,title(t,e=s.proto){let r=e?.findAbove(t=>l.is(t,m));r&&(r.title=t,r.updateTitle())}}),globalThis.Link=a,globalThis.NavLink=class extends a{constructor(t,e){super(t,e),this.global.router.navlinks.add(this)}dispose(){this.global.router.navlinks.delete(this),super.dispose()}checkActive(){let t=this.attr("href");if(t){for(let e of this.global.router.matchPaths)if(l.toURL(e).href===l.toURL(t).href)return this.attr("active","");this.attr("active",l.Null)}}build(t){return super.build(t),this.checkActive(),this}},$.process.craft.add(t=>{if(l.isFunction(t)&&"Router"===t[i]){let e=s.proto,r=new t;return e?.global.router.routers.add(r),r}});export{a as Link,m as Page,k as Route,P as RouteGroup,x as RouteNode,b as RouteSlot,y as Router};
package/build/signal.js CHANGED
@@ -1 +1 @@
1
- import{_null as e,_instanceof as s,isSymbol as t,isString as i,isObject as l,isNull as u,forEach as a,_Object_entries as r,isFunction as n,isUndefined as h,_Object_assign as o,isBoolean as c,isNumber as p,_undefined as d}from"@amateras/utils";import{symbol_Signal as b,Proto as m,GlobalState as v,ProxyProto as f}from"@amateras/core";let g=!1,k=/* @__PURE__ */new Set,w=e=>{g=!1;let s=e();return g=!0,s},x=e=>{g=!0;let s=e(w);return g=!1,s},_=new FinalizationRegistry(({signal:e,ref:s})=>{e.computes?.delete(s)});class y extends Function{[b]=!0;linked=e;_value;subs=e;map=e;exec=e;computes=e;constructor(e){return super(),m.proto?.global.signals.add(this),this._value=e,s(e,y)&&this.link(e),new Proxy(this,{apply:()=>this._exec(),get:(e,s)=>{if(t(s)||i(s)&&!s.endsWith("$"))return this[s];s=s.slice(0,-1),this.map||(this.map={});const a=this.map[s];if(a)return a;{const e=this.map[s]??new y(null);return this.map[s]=e,this.setPropValue(e,s),e.subscribe(e=>{l(this.value)&&!u(this.value)&&Object.getOwnPropertyDescriptor(this.value,s)?.writable&&(this.value[s]=e),u(this.value)||this.emit()}),this.subscribe(()=>this.setPropValue(e,s)),e}}})}_exec(){return g&&k.add(this),this.value}setPropValue(e,s){if(l(this.value)&&!u(this.value)){const t=this.value[s];e.set(t)}else e._value=null}get value(){return this.linked?this.linked.value:this._value}dispose(){this.subs=e,this.linked=e,a(this.computes,e=>e.deref()?.dispose()),this.computes=e,this.exec=e,this._value=e,this.map&&a(r(this.map),([e,s])=>s.dispose()),this.map=e}set(t){s(t,y)?this.link(t):n(t)?this.set(t(this.value)):this.value!==t&&(this._value=t,this.linked=e,this.emit())}modify(e){e(this.value),this.linked?.emit(),this.emit()}emit(){a(this.subs,e=>e(this.value)),a(this.computes,e=>{let s=e.deref();s||this.computes?.delete(e),s?.exec?.()})}subscribe(e){this.subs=this.subs??[],this.subs.push(e)}unsubscribe(e){let s=this.subs?.indexOf(e);h(s)||-1===s||this.subs?.splice(s,1)}link(e){if(this===e)throw"Signal.link(): cannot link self";this.linked=e,this.emit(),e.subscribe(()=>this.emit())}is(e){return e(this)}toString(){return`${this.value}`}}v.assign(()=>({signals:/* @__PURE__ */new Set})),v.disposers.add(e=>{a(e.signals,e=>e.dispose()),e.signals.clear()}),o($,{signal:e=>new y(e),effect(e,s=[]){x(e),a(s,e=>k.add(e)),a(k,s=>s.subscribe(s=>e(w))),k.clear()},compute(e){let s=x(e),t=$.signal(s),i=m.proto;return t.exec=()=>{$.context(m,i,()=>{t.set(e(w))})},a(k,e=>{e.computes=e.computes??/* @__PURE__ */new Set;let s=new WeakRef(t);e.computes.add(s),_.register(t,{signal:e,ref:s})}),k.clear(),t},optional:s=>s.value?s:e,resolve:(e,t)=>s(e,y)?(t&&(e.subscribe(t),t(e.value)),e.value):(t?.(e),e)});let P=e=>{if(s(e,y)){let s=new f,t=d,l=e=>{i(e)||c(e)||p(e)?(t?t.content=`${e}`:s.layout=()=>t=$([e]).at(0),s.builded||s.build()):(t=d,s.layout=()=>$([e]),a(s.protos,e=>e.removeNode()),s.clear(!0),s.builded&&s.build(),s.node?.replaceWith(...s.toDOM()))};return e.subscribe(l),s.listen("dispose",()=>e.unsubscribe(l)),l(e.value),s}};$.process.text.add(P),$.process.craft.add(P),$.process.attr.add((e,t,i)=>{if(s(t,y)){let s=()=>i.attr(e,t.value);return t.subscribe(s),s(),i.listen("dispose",()=>t.unsubscribe(s)),!0}});export{y as Signal};
1
+ import{Utils as e}from"@amateras/utils";import{symbol_Signal as s,Proto as t,GlobalState as i,ProxyProto as l}from"@amateras/core";let u=!1,a=/* @__PURE__ */new Set,r=e=>{u=!1;let s=e();return u=!0,s},n=e=>{u=!0;let s=e(r);return u=!1,s},o=new FinalizationRegistry(({signal:e,ref:s})=>{e.computes?.delete(s)});class h extends Function{[s]=!0;linked=e.Null;_value;subs=e.Null;map=e.Null;exec=e.Null;computes=e.Null;constructor(s){return super(),t.proto?.global.signals.add(this),this._value=s,e.isInstanceof(s,h)&&this.link(s),new Proxy(this,{apply:()=>this._exec(),get:(s,t)=>{if(e.isSymbol(t)||e.isString(t)&&!t.endsWith("$"))return this[t];t=t.slice(0,-1),this.map||(this.map={});const i=this.map[t];if(i)return i;{const s=this.map[t]??new h(null);return this.map[t]=s,this.setPropValue(s,t),s.subscribe(s=>{e.isObject(this.value)&&!e.isNull(this.value)&&Object.getOwnPropertyDescriptor(this.value,t)?.writable&&(this.value[t]=s),e.isNull(this.value)||this.emit()}),this.subscribe(()=>this.setPropValue(s,t)),s}}})}_exec(){return u&&a.add(this),this.value}setPropValue(s,t){if(e.isObject(this.value)&&!e.isNull(this.value)){const e=this.value[t];s.set(e)}else s._value=null}get value(){return this.linked?this.linked.value:this._value}dispose(){this.subs=e.Null,this.linked=e.Null,e.forEach(this.computes,e=>e.deref()?.dispose()),this.computes=e.Null,this.exec=e.Null,this._value=e.Null,this.map&&e.forEach(e.entries(this.map),([e,s])=>s.dispose()),this.map=e.Null}set(s){e.isInstanceof(s,h)?this.link(s):e.isFunction(s)?this.set(s(this.value)):this.value!==s&&(this._value=s,this.linked=e.Null,this.emit())}modify(e){e(this.value),this.linked?.emit(),this.emit()}emit(){e.forEach(this.subs,e=>e(this.value)),e.forEach(this.computes,e=>{let s=e.deref();s||this.computes?.delete(e),s?.exec?.()})}subscribe(e){this.subs=this.subs??[],this.subs.push(e)}unsubscribe(s){let t=this.subs?.indexOf(s);e.isUndefined(t)||-1===t||this.subs?.splice(t,1)}link(e){if(this===e)throw"Signal.link(): cannot link self";this.linked=e,this.emit(),e.subscribe(()=>this.emit())}is(e){return e(this)}toString(){return`${this.value}`}}i.assign(()=>({signals:/* @__PURE__ */new Set})),i.disposers.add(s=>{e.forEach(s.signals,e=>e.dispose()),s.signals.clear()}),e.assign($,{signal:e=>new h(e),effect(s,t=[]){n(s),e.forEach(t,e=>a.add(e)),e.forEach(a,e=>e.subscribe(e=>s(r))),a.clear()},compute(s){let i=n(s),l=$.signal(i),u=t.proto;return l.exec=()=>{$.context(t,u,()=>{l.set(s(r))})},e.forEach(a,e=>{e.computes=e.computes??/* @__PURE__ */new Set;let s=new WeakRef(l);e.computes.add(s),o.register(l,{signal:e,ref:s})}),a.clear(),l},optional:s=>s.value?s:e.Null,resolve:(s,t)=>e.isInstanceof(s,h)?(t&&(s.subscribe(t),t(s.value)),s.value):(t?.(s),s)});let c=s=>{if(e.isInstanceof(s,h)){let t=new l,i=e.Undefined,u=s=>{e.isString(s)||e.isBoolean(s)||e.isNumber(s)?(i?i.content=`${s}`:t.layout=()=>i=$([s]).at(0),t.builded||t.build()):(i=e.Undefined,t.layout=()=>$([s]),e.forEach(t.protos,e=>e.removeNode()),t.clear(!0),t.builded&&t.build(),t.node?.replaceWith(...t.toDOM()))};return s.subscribe(u),t.listen("dispose",()=>s.unsubscribe(u)),u(s.value),t}};$.process.text.add(c),$.process.craft.add(c),$.process.attr.add((s,t,i)=>{if(e.isInstanceof(t,h)){let e=()=>i.attr(s,t.value);return t.subscribe(e),e(),i.listen("dispose",()=>t.unsubscribe(e)),!0}});export{h as Signal};
package/build/store.js CHANGED
@@ -1 +1 @@
1
- import{Proto as t}from"@amateras/core";import{isUndefined as o,_Object_assign as e}from"@amateras/utils";class r{init;map=/* @__PURE__ */new WeakMap;constructor(t){this.init=t}create(...o){const e=t.proto;if(!e)throw`Store.create(): ${i}`;const r=this.init(...o);return this.map.set(e,r),e.listen("dispose",()=>this.map.delete(e)),r}get(){const e=t.proto;if(!e)throw`Store.get(): ${i}`;const r=this.getValueFromProto(e);if(o(r))throw"Store.get(): value not found";return r}getValueFromProto(t){if(!t)return;return this.map.get(t)??this.getValueFromProto(t.parent)}}const i="should be called inside proto layout function";e($,{store:t=>new r(t)});export{r as Store};
1
+ import{Proto as t}from"@amateras/core";import{Utils as e}from"@amateras/utils";class o{init;map=/* @__PURE__ */new WeakMap;constructor(t){this.init=t}create(...e){const o=t.proto;if(!o)throw`Store.create(): ${r}`;const i=this.init(...e);return this.map.set(o,i),o.listen("dispose",()=>this.map.delete(o)),i}get(){const o=t.proto;if(!o)throw`Store.get(): ${r}`;const i=this.getValueFromProto(o);if(e.isUndefined(i))throw"Store.get(): value not found";return i}getValueFromProto(t){if(!t)return;return this.map.get(t)??this.getValueFromProto(t.parent)}}const r="should be called inside proto layout function";e.assign($,{store:t=>new o(t)});export{o as Store};