amateras 0.14.1 → 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.
- package/README.md +12 -12
- package/build/core.js +1 -1
- package/build/css-keyframes.js +1 -1
- package/build/css-property.js +1 -1
- package/build/css-variable.js +1 -1
- package/build/css.js +1 -1
- package/build/for.js +1 -1
- package/build/i18n.js +1 -1
- package/build/idb.js +1 -1
- package/build/if.js +1 -1
- package/build/import-map.js +1 -1
- package/build/markdown.js +1 -1
- package/build/match.js +1 -1
- package/build/meta.js +1 -1
- package/build/prefetch.js +1 -1
- package/build/router.js +1 -1
- package/build/signal.js +1 -1
- package/build/store.js +1 -1
- package/build/ui.js +1 -1
- package/build/utils.js +1 -1
- package/build/widget.js +1 -1
- package/package.json +1 -1
- package/packages/core/src/index.ts +32 -29
- package/packages/core/src/lib/hmr.ts +119 -133
- package/packages/core/src/lib/virtual_scroll.ts +29 -0
- package/packages/core/src/structure/ElementProto.ts +29 -25
- package/packages/core/src/structure/GlobalState.ts +5 -5
- package/packages/core/src/structure/NodeProto.ts +8 -13
- package/packages/core/src/structure/Proto.ts +49 -41
- package/packages/core/src/structure/ProxyProto.ts +2 -2
- package/packages/css/src/ext/fluent.ts +18 -0
- package/packages/css/src/ext/keyframes.ts +5 -6
- package/packages/css/src/ext/property.ts +6 -7
- package/packages/css/src/ext/variable.ts +7 -8
- package/packages/css/src/index.ts +13 -13
- package/packages/css/src/lib/cache.ts +2 -1
- package/packages/css/src/lib/colorAssign.ts +3 -3
- package/packages/css/src/lib/createRule.ts +4 -4
- package/packages/css/src/structure/$CSSFluent.ts +73 -0
- package/packages/css/src/structure/$CSSProperty.ts +2 -2
- package/packages/css/src/structure/$CSSRule.ts +6 -6
- package/packages/for/src/global.ts +12 -2
- package/packages/for/src/structure/For.ts +18 -18
- package/packages/hmr/src/index.ts +28 -3
- package/packages/i18n/src/index.ts +7 -7
- package/packages/i18n/src/structure/I18n.ts +2 -2
- package/packages/i18n/src/structure/I18nDictionary.ts +4 -4
- package/packages/i18n/src/structure/I18nSession.ts +4 -4
- package/packages/i18n/src/structure/I18nTranslation.ts +3 -3
- package/packages/i18n/src/types.ts +4 -5
- package/packages/idb/src/index.ts +3 -3
- package/packages/idb/src/lib/$IDBRequest.ts +1 -3
- package/packages/idb/src/structure/$IDB.ts +6 -6
- package/packages/idb/src/structure/$IDBCursor.ts +2 -2
- package/packages/idb/src/structure/$IDBIndex.ts +2 -2
- package/packages/idb/src/structure/$IDBStore.ts +2 -2
- package/packages/idb/src/structure/$IDBStoreBase.ts +0 -1
- package/packages/idb/src/structure/$IDBTransaction.ts +3 -3
- package/packages/idb/src/structure/builder/$IDBBuilder.ts +25 -25
- package/packages/idb/src/structure/builder/$IDBStoreBuilder.ts +1 -1
- package/packages/if/src/index.ts +6 -6
- package/packages/if/src/structure/Condition.ts +8 -8
- package/packages/if/src/structure/ConditionStatement.ts +3 -3
- package/packages/markdown/src/lib/util.ts +2 -2
- package/packages/markdown/src/structure/MarkdownLexer.ts +3 -3
- package/packages/markdown/src/structure/MarkdownParser.ts +3 -3
- package/packages/markdown/src/syntax/alert.ts +2 -2
- package/packages/markdown/src/syntax/link.ts +2 -2
- package/packages/markdown/src/syntax/list.ts +3 -3
- package/packages/markdown/src/syntax/table.ts +2 -2
- package/packages/match/src/index.ts +5 -5
- package/packages/match/src/structure/Case.ts +2 -2
- package/packages/match/src/structure/Match.ts +8 -8
- package/packages/meta/src/index.ts +5 -5
- package/packages/meta/src/lib/resolveMeta.ts +5 -5
- package/packages/prefetch/src/index.ts +60 -15
- package/packages/router/src/index.ts +7 -7
- package/packages/router/src/structure/Link.ts +2 -2
- package/packages/router/src/structure/NavLink.ts +14 -3
- package/packages/router/src/structure/Page.ts +4 -4
- package/packages/router/src/structure/Route.ts +6 -6
- package/packages/router/src/structure/RouteNode.ts +3 -3
- package/packages/router/src/structure/RouteSlot.ts +5 -5
- package/packages/router/src/structure/Router.ts +37 -26
- package/packages/signal/src/index.ts +14 -14
- package/packages/signal/src/structure/Signal.ts +25 -25
- package/packages/store/src/index.ts +2 -2
- package/packages/store/src/structure/Store.ts +2 -2
- package/packages/ui/src/index.ts +5 -2
- package/packages/ui/src/lib/float.ts +29 -17
- package/packages/ui/src/lib/toCSS.ts +7 -3
- package/packages/ui/src/structure/Accordion.ts +5 -5
- package/packages/ui/src/structure/Badge.ts +2 -2
- package/packages/ui/src/structure/Button.ts +8 -3
- package/packages/ui/src/structure/Card.ts +6 -6
- package/packages/ui/src/structure/Combobox/Combobox.ts +54 -46
- package/packages/ui/src/structure/Combobox/ComboboxChips.ts +108 -56
- package/packages/ui/src/structure/Combobox/ComboboxList.ts +56 -42
- package/packages/ui/src/structure/ContextMenu.ts +8 -8
- package/packages/ui/src/structure/DescriptionList.ts +6 -5
- package/packages/ui/src/structure/Field.ts +30 -7
- package/packages/ui/src/structure/Icon.ts +2 -2
- package/packages/ui/src/structure/Input.ts +2 -2
- package/packages/ui/src/structure/Radio.ts +5 -6
- package/packages/ui/src/structure/Searchbar.ts +209 -0
- package/packages/ui/src/structure/Select/Select.ts +21 -28
- package/packages/ui/src/structure/Select/SelectArrow.ts +2 -2
- package/packages/ui/src/structure/Select/SelectContent.ts +24 -5
- package/packages/ui/src/structure/Select/SelectItem.ts +33 -62
- package/packages/ui/src/structure/Select/SelectTrigger.ts +27 -7
- package/packages/ui/src/structure/Select/SelectValue.ts +7 -7
- package/packages/ui/src/structure/Slideshow.ts +5 -5
- package/packages/ui/src/structure/Switch.ts +4 -2
- package/packages/ui/src/structure/Tabs.ts +8 -8
- package/packages/ui/src/structure/TextArea.ts +22 -0
- package/packages/ui/src/structure/TextBlock.ts +17 -0
- package/packages/ui/src/structure/Toast.ts +101 -0
- package/packages/ui/src/structure/Toggle.ts +6 -6
- package/packages/ui/src/structure/Waterfall.ts +60 -24
- package/packages/ui/src/style/content_style.ts +1 -2
- package/packages/ui/src/style/input_style.ts +2 -2
- package/packages/utils/package.json +2 -1
- package/packages/utils/src/index.bun.ts +2 -2
- package/packages/utils/src/index.ts +3 -2
- package/packages/utils/src/lib/array.ts +1 -0
- package/packages/utils/src/lib/call.ts +1 -0
- package/packages/utils/src/lib/debounce.ts +18 -0
- package/packages/utils/src/lib/forEach.ts +25 -0
- package/packages/utils/src/lib/isEqual.ts +30 -0
- package/packages/utils/src/lib/json.ts +2 -0
- package/packages/utils/src/lib/map.ts +11 -0
- package/packages/utils/src/lib/object.ts +3 -0
- package/packages/utils/src/lib/primitive.ts +2 -0
- package/packages/utils/src/lib/randstr.ts +13 -0
- package/packages/utils/src/lib/remove.ts +1 -0
- package/packages/utils/src/lib/sleep.ts +1 -0
- package/packages/utils/src/lib/toArray.ts +3 -0
- package/packages/utils/src/lib/trycatch.ts +17 -0
- package/packages/utils/src/lib/type.ts +16 -0
- package/packages/utils/src/lib/uppercase.ts +7 -0
- package/packages/utils/src/lib/url.ts +7 -0
- package/packages/utils/src/lib/utils.ts +17 -152
- package/packages/utils/src/structure/UID.ts +2 -2
- package/packages/widget/src/index.ts +3 -3
- package/packages/widget/src/structure/Widget.ts +6 -3
- 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 |
|
|
68
|
-
| widget | 0.
|
|
69
|
-
| signal | 3.
|
|
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.
|
|
72
|
-
| for | 1.
|
|
73
|
-
| if | 4.
|
|
74
|
-
| match | 1.
|
|
75
|
-
| router | 6.
|
|
76
|
-
| i18n | 3.38 kB | 1.
|
|
77
|
-
| idb | 5.
|
|
78
|
-
| markdown | 7.48 kB | 2.
|
|
79
|
-
| 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{
|
|
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};
|
package/build/css-keyframes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/build/css-property.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/build/css-variable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{onclient as e,_document as t}from"@amateras/core";import{
|
|
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{
|
|
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{
|
|
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{
|
|
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{
|
|
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
|
|
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"});
|
package/build/import-map.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=`https://unpkg.com/amateras@${"0.
|
|
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{
|
|
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([["&","&"],["<","<"],[">",">"],['"',"""],["'","'"]],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{
|
|
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{
|
|
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,
|
|
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
|
|
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{
|
|
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{
|
|
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};
|