amateras 0.6.0 → 0.7.0

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 (282) hide show
  1. package/index.ts +1 -0
  2. package/package.json +32 -30
  3. package/packages/core/package.json +32 -0
  4. package/packages/core/src/env.browser.ts +21 -0
  5. package/packages/core/src/env.node.ts +21 -0
  6. package/packages/core/src/global.ts +18 -0
  7. package/{src/core.ts → packages/core/src/index.ts} +42 -30
  8. package/{src → packages/core/src}/lib/assignProperties.ts +1 -1
  9. package/packages/core/src/lib/chain.ts +17 -0
  10. package/packages/core/src/lib/dom.ts +20 -0
  11. package/packages/core/src/main.ts +4 -0
  12. package/{src → packages/core/src}/node/$Element.ts +22 -10
  13. package/{src → packages/core/src}/node/$EventTarget.ts +13 -10
  14. package/{src → packages/core/src}/node/$HTMLElement.ts +1 -1
  15. package/{src → packages/core/src}/node/$Node.ts +7 -11
  16. package/{src → packages/core/src}/node/$Virtual.ts +5 -5
  17. package/packages/css/package.json +17 -0
  18. package/{ext/css/src/lib → packages/css/src/ext}/colors/amber.ts +2 -2
  19. package/{ext/css/src/lib → packages/css/src/ext}/colors/blackwhite.ts +2 -2
  20. package/{ext/css/src/lib → packages/css/src/ext}/colors/blue.ts +2 -2
  21. package/{ext/css/src/lib → packages/css/src/ext}/colors/cyan.ts +2 -2
  22. package/{ext/css/src/lib → packages/css/src/ext}/colors/emerald.ts +2 -2
  23. package/{ext/css/src/lib → packages/css/src/ext}/colors/fuchsia.ts +2 -2
  24. package/{ext/css/src/lib → packages/css/src/ext}/colors/gray.ts +2 -2
  25. package/{ext/css/src/lib → packages/css/src/ext}/colors/green.ts +2 -2
  26. package/{ext/css/src/lib → packages/css/src/ext}/colors/indigo.ts +2 -2
  27. package/{ext/css/src/lib → packages/css/src/ext}/colors/lime.ts +2 -2
  28. package/{ext/css/src/lib → packages/css/src/ext}/colors/neutral.ts +2 -2
  29. package/{ext/css/src/lib → packages/css/src/ext}/colors/orange.ts +2 -2
  30. package/{ext/css/src/lib → packages/css/src/ext}/colors/pink.ts +2 -2
  31. package/{ext/css/src/lib → packages/css/src/ext}/colors/purple.ts +2 -2
  32. package/{ext/css/src/lib → packages/css/src/ext}/colors/red.ts +2 -2
  33. package/{ext/css/src/lib → packages/css/src/ext}/colors/rose.ts +2 -2
  34. package/{ext/css/src/lib → packages/css/src/ext}/colors/sky.ts +2 -2
  35. package/{ext/css/src/lib → packages/css/src/ext}/colors/slate.ts +2 -2
  36. package/{ext/css/src/lib → packages/css/src/ext}/colors/stone.ts +2 -2
  37. package/{ext/css/src/lib → packages/css/src/ext}/colors/teal.ts +2 -2
  38. package/{ext/css/src/lib → packages/css/src/ext}/colors/violet.ts +2 -2
  39. package/{ext/css/src/lib → packages/css/src/ext}/colors/yellow.ts +2 -2
  40. package/{ext/css/src/lib → packages/css/src/ext}/colors/zinc.ts +2 -2
  41. package/packages/css/src/ext/container.ts +32 -0
  42. package/packages/css/src/ext/keyframes.ts +54 -0
  43. package/packages/css/src/ext/media.ts +32 -0
  44. package/packages/css/src/ext/property.ts +48 -0
  45. package/packages/css/src/ext/variable.ts +51 -0
  46. package/{ext → packages}/css/src/index.ts +107 -183
  47. package/{ext → packages}/css/src/lib/colorAssign.ts +1 -1
  48. package/packages/css/src/lib/utils.ts +11 -0
  49. package/{ext → packages}/css/src/structure/$CSSContainerRule.ts +1 -1
  50. package/{ext → packages}/css/src/structure/$CSSKeyframesRule.ts +0 -1
  51. package/{ext → packages}/css/src/structure/$CSSMediaRule.ts +1 -1
  52. package/packages/css/src/structure/$CSSProperty.ts +19 -0
  53. package/{ext → packages}/css/src/structure/$CSSRule.ts +1 -1
  54. package/{ext → packages}/css/src/structure/$CSSStyleRule.ts +1 -1
  55. package/packages/css/src/structure/$CSSVariable.ts +30 -0
  56. package/packages/dom/package.json +20 -0
  57. package/packages/dom/src/lib/HTMLElementMap.ts +213 -0
  58. package/packages/dom/src/lib/assignAttributes.ts +16 -0
  59. package/packages/dom/src/structure/CSS.ts +7 -0
  60. package/packages/dom/src/structure/CSSStyleSheet.ts +10 -0
  61. package/packages/dom/src/structure/DOMTokenList.ts +19 -0
  62. package/packages/dom/src/structure/Document.ts +36 -0
  63. package/packages/dom/src/structure/Element.ts +106 -0
  64. package/packages/dom/src/structure/HTMLElement.ts +34 -0
  65. package/packages/dom/src/structure/History.ts +11 -0
  66. package/packages/dom/src/structure/Location.ts +9 -0
  67. package/packages/dom/src/structure/Node.ts +51 -0
  68. package/packages/dom/src/structure/NodeList.ts +10 -0
  69. package/packages/dom/src/structure/Storage.ts +8 -0
  70. package/packages/dom/src/structure/Text.ts +20 -0
  71. package/packages/dom/src/structure/Window.ts +14 -0
  72. package/packages/dom/src/structure/html/HTMLAbbrElement.ts +16 -0
  73. package/packages/dom/src/structure/html/HTMLAddressElement.ts +16 -0
  74. package/packages/dom/src/structure/html/HTMLAnchorElement.ts +25 -0
  75. package/packages/dom/src/structure/html/HTMLAreaElement.ts +26 -0
  76. package/packages/dom/src/structure/html/HTMLArticleElement.ts +16 -0
  77. package/packages/dom/src/structure/html/HTMLAsideElement.ts +16 -0
  78. package/packages/dom/src/structure/html/HTMLAudioElement.ts +16 -0
  79. package/packages/dom/src/structure/html/HTMLBDIElement.ts +16 -0
  80. package/packages/dom/src/structure/html/HTMLBDOElement.ts +16 -0
  81. package/packages/dom/src/structure/html/HTMLBElement.ts +16 -0
  82. package/packages/dom/src/structure/html/HTMLBRElement.ts +17 -0
  83. package/packages/dom/src/structure/html/HTMLBaseElement.ts +18 -0
  84. package/packages/dom/src/structure/html/HTMLBodyElement.ts +22 -0
  85. package/packages/dom/src/structure/html/HTMLButtonElement.ts +26 -0
  86. package/packages/dom/src/structure/html/HTMLCanvasElement.ts +18 -0
  87. package/packages/dom/src/structure/html/HTMLCiteElement.ts +16 -0
  88. package/packages/dom/src/structure/html/HTMLCodeElement.ts +16 -0
  89. package/packages/dom/src/structure/html/HTMLDDElement.ts +16 -0
  90. package/packages/dom/src/structure/html/HTMLDFNElement.ts +16 -0
  91. package/packages/dom/src/structure/html/HTMLDListElement.ts +17 -0
  92. package/packages/dom/src/structure/html/HTMLDTElement.ts +16 -0
  93. package/packages/dom/src/structure/html/HTMLDataElement.ts +17 -0
  94. package/packages/dom/src/structure/html/HTMLDataListElement.ts +16 -0
  95. package/packages/dom/src/structure/html/HTMLDetailsElement.ts +17 -0
  96. package/packages/dom/src/structure/html/HTMLDialogElement.ts +18 -0
  97. package/packages/dom/src/structure/html/HTMLDivElement.ts +17 -0
  98. package/packages/dom/src/structure/html/HTMLEMElement.ts +16 -0
  99. package/packages/dom/src/structure/html/HTMLEmbedElement.ts +20 -0
  100. package/packages/dom/src/structure/html/HTMLFieldSetElement.ts +19 -0
  101. package/packages/dom/src/structure/html/HTMLFigCaptionElement.ts +16 -0
  102. package/packages/dom/src/structure/html/HTMLFigureElement.ts +16 -0
  103. package/packages/dom/src/structure/html/HTMLFooterElement.ts +16 -0
  104. package/packages/dom/src/structure/html/HTMLFormElement.ts +24 -0
  105. package/packages/dom/src/structure/html/HTMLHGroupElement.ts +16 -0
  106. package/packages/dom/src/structure/html/HTMLHRElement.ts +21 -0
  107. package/packages/dom/src/structure/html/HTMLHeadElement.ts +16 -0
  108. package/packages/dom/src/structure/html/HTMLHeaderElement.ts +16 -0
  109. package/packages/dom/src/structure/html/HTMLHeadingElement.ts +17 -0
  110. package/packages/dom/src/structure/html/HTMLHtmlElement.ts +18 -0
  111. package/packages/dom/src/structure/html/HTMLIElement.ts +16 -0
  112. package/packages/dom/src/structure/html/HTMLIFrameElement.ts +31 -0
  113. package/packages/dom/src/structure/html/HTMLImageElement.ts +38 -0
  114. package/packages/dom/src/structure/html/HTMLInputElement.ts +55 -0
  115. package/packages/dom/src/structure/html/HTMLKBDElement.ts +16 -0
  116. package/packages/dom/src/structure/html/HTMLLIElement.ts +18 -0
  117. package/packages/dom/src/structure/html/HTMLLabelElement.ts +18 -0
  118. package/packages/dom/src/structure/html/HTMLLegendElement.ts +17 -0
  119. package/packages/dom/src/structure/html/HTMLLinkElement.ts +31 -0
  120. package/packages/dom/src/structure/html/HTMLMainElement.ts +16 -0
  121. package/packages/dom/src/structure/html/HTMLMapElement.ts +17 -0
  122. package/packages/dom/src/structure/html/HTMLMarkElement.ts +16 -0
  123. package/packages/dom/src/structure/html/HTMLMediaElement.ts +48 -0
  124. package/packages/dom/src/structure/html/HTMLMenuElement.ts +18 -0
  125. package/packages/dom/src/structure/html/HTMLMetaElement.ts +22 -0
  126. package/packages/dom/src/structure/html/HTMLMeterElement.ts +23 -0
  127. package/packages/dom/src/structure/html/HTMLModElement.ts +18 -0
  128. package/packages/dom/src/structure/html/HTMLNavElement.ts +16 -0
  129. package/packages/dom/src/structure/html/HTMLNoscriptElement.ts +16 -0
  130. package/packages/dom/src/structure/html/HTMLOListElement.ts +20 -0
  131. package/packages/dom/src/structure/html/HTMLObjectElement.ts +34 -0
  132. package/packages/dom/src/structure/html/HTMLOptGroupElement.ts +18 -0
  133. package/packages/dom/src/structure/html/HTMLOptionElement.ts +20 -0
  134. package/packages/dom/src/structure/html/HTMLOutputElement.ts +20 -0
  135. package/packages/dom/src/structure/html/HTMLParagraphElement.ts +17 -0
  136. package/packages/dom/src/structure/html/HTMLPictureElement.ts +16 -0
  137. package/packages/dom/src/structure/html/HTMLPreElement.ts +17 -0
  138. package/packages/dom/src/structure/html/HTMLProgressElement.ts +19 -0
  139. package/packages/dom/src/structure/html/HTMLQuoteElement.ts +17 -0
  140. package/packages/dom/src/structure/html/HTMLRPElement.ts +16 -0
  141. package/packages/dom/src/structure/html/HTMLRTElement.ts +16 -0
  142. package/packages/dom/src/structure/html/HTMLRubyElement.ts +16 -0
  143. package/packages/dom/src/structure/html/HTMLSElement.ts +16 -0
  144. package/packages/dom/src/structure/html/HTMLSampElement.ts +16 -0
  145. package/packages/dom/src/structure/html/HTMLScriptElement.ts +27 -0
  146. package/packages/dom/src/structure/html/HTMLSectionElement.ts +16 -0
  147. package/packages/dom/src/structure/html/HTMLSelectElement.ts +27 -0
  148. package/packages/dom/src/structure/html/HTMLSlotElement.ts +17 -0
  149. package/packages/dom/src/structure/html/HTMLSmallElement.ts +16 -0
  150. package/packages/dom/src/structure/html/HTMLSourceElement.ts +21 -0
  151. package/packages/dom/src/structure/html/HTMLSpanElement.ts +16 -0
  152. package/packages/dom/src/structure/html/HTMLStrongElement.ts +16 -0
  153. package/packages/dom/src/structure/html/HTMLStyleElement.ts +18 -0
  154. package/packages/dom/src/structure/html/HTMLSubElement.ts +16 -0
  155. package/packages/dom/src/structure/html/HTMLSummaryElement.ts +16 -0
  156. package/packages/dom/src/structure/html/HTMLSupElement.ts +16 -0
  157. package/packages/dom/src/structure/html/HTMLTableCaptionElement.ts +17 -0
  158. package/packages/dom/src/structure/html/HTMLTableCellElement.ts +31 -0
  159. package/packages/dom/src/structure/html/HTMLTableColElement.ts +23 -0
  160. package/packages/dom/src/structure/html/HTMLTableElement.ts +26 -0
  161. package/packages/dom/src/structure/html/HTMLTableRowElement.ts +23 -0
  162. package/packages/dom/src/structure/html/HTMLTableSectionElement.ts +20 -0
  163. package/packages/dom/src/structure/html/HTMLTemplateElement.ts +17 -0
  164. package/packages/dom/src/structure/html/HTMLTextAreaElement.ts +33 -0
  165. package/packages/dom/src/structure/html/HTMLTimeElement.ts +17 -0
  166. package/packages/dom/src/structure/html/HTMLTitleElement.ts +17 -0
  167. package/packages/dom/src/structure/html/HTMLTrackElement.ts +21 -0
  168. package/packages/dom/src/structure/html/HTMLUElement.ts +16 -0
  169. package/packages/dom/src/structure/html/HTMLUListElement.ts +18 -0
  170. package/packages/dom/src/structure/html/HTMLVarElement.ts +16 -0
  171. package/packages/dom/src/structure/html/HTMLVideoElement.ts +22 -0
  172. package/packages/dom/src/structure/html/HTMLWBRElement.ts +16 -0
  173. package/packages/html/package.json +18 -0
  174. package/{ext/html/html.ts → packages/html/src/index.ts} +1 -1
  175. package/{ext/html → packages/html/src}/node/$Anchor.ts +3 -3
  176. package/packages/html/src/node/$Canvas.ts +38 -0
  177. package/{ext/html → packages/html/src}/node/$Dialog.ts +3 -3
  178. package/{ext/html → packages/html/src}/node/$Form.ts +3 -3
  179. package/{ext/html → packages/html/src}/node/$Image.ts +3 -3
  180. package/{ext/html → packages/html/src}/node/$Input.ts +3 -3
  181. package/{ext/html → packages/html/src}/node/$Label.ts +3 -3
  182. package/{ext/html → packages/html/src}/node/$Media.ts +3 -3
  183. package/{ext/html → packages/html/src}/node/$OptGroup.ts +3 -3
  184. package/{ext/html → packages/html/src}/node/$Option.ts +3 -3
  185. package/{ext/html → packages/html/src}/node/$Select.ts +3 -3
  186. package/{ext/html → packages/html/src}/node/$TextArea.ts +3 -3
  187. package/packages/i18n/package.json +19 -0
  188. package/{ext → packages}/i18n/src/index.ts +6 -14
  189. package/{ext → packages}/i18n/src/structure/I18n.ts +2 -2
  190. package/{ext → packages}/i18n/src/structure/I18nDictionary.ts +1 -1
  191. package/{ext → packages}/i18n/src/structure/I18nTranslation.ts +10 -4
  192. package/packages/idb/package.json +19 -0
  193. package/{ext → packages}/idb/src/index.ts +2 -2
  194. package/{ext → packages}/idb/src/lib/$IDBRequest.ts +1 -1
  195. package/{ext → packages}/idb/src/structure/$IDB.ts +1 -1
  196. package/{ext → packages}/idb/src/structure/$IDBCursor.ts +1 -1
  197. package/{ext → packages}/idb/src/structure/$IDBIndex.ts +1 -1
  198. package/{ext → packages}/idb/src/structure/$IDBStore.ts +1 -1
  199. package/{ext → packages}/idb/src/structure/$IDBStoreBase.ts +1 -1
  200. package/{ext → packages}/idb/src/structure/$IDBTransaction.ts +1 -1
  201. package/{ext → packages}/idb/src/structure/builder/$IDBBuilder.ts +1 -2
  202. package/{ext → packages}/idb/src/structure/builder/$IDBStoreBuilder.ts +1 -1
  203. package/packages/markdown/package.json +19 -0
  204. package/{ext → packages}/markdown/src/lib/util.ts +1 -1
  205. package/{ext → packages}/markdown/src/structure/MarkdownLexer.ts +2 -2
  206. package/{ext → packages}/markdown/src/structure/MarkdownParser.ts +2 -1
  207. package/{ext → packages}/markdown/src/syntax/alert.ts +1 -1
  208. package/{ext → packages}/markdown/src/syntax/codeblock.ts +1 -1
  209. package/{ext → packages}/markdown/src/syntax/link.ts +2 -2
  210. package/{ext → packages}/markdown/src/syntax/list.ts +1 -1
  211. package/{ext → packages}/markdown/src/syntax/table.ts +1 -1
  212. package/packages/router/package.json +19 -0
  213. package/{ext → packages}/router/src/index.ts +4 -5
  214. package/{ext → packages}/router/src/node/Page.ts +8 -4
  215. package/{ext → packages}/router/src/node/Router.ts +79 -58
  216. package/{ext → packages}/router/src/node/RouterAnchor.ts +2 -2
  217. package/{ext → packages}/router/src/structure/PageBuilder.ts +3 -3
  218. package/{ext → packages}/router/src/structure/Route.ts +1 -1
  219. package/packages/signal/package.json +18 -0
  220. package/packages/signal/src/index.ts +221 -0
  221. package/{ext → packages}/signal/src/structure/Signal.ts +1 -1
  222. package/packages/ssr/package.json +19 -0
  223. package/packages/ssr/src/index.ts +38 -0
  224. package/{ext → packages}/ui/lib/VirtualScroll.ts +5 -5
  225. package/{ext → packages}/ui/node/Accordian.ts +4 -4
  226. package/packages/ui/node/Carousel.ts +20 -0
  227. package/{ext → packages}/ui/node/Form.ts +7 -6
  228. package/packages/ui/node/Modal.ts +45 -0
  229. package/{ext → packages}/ui/node/Table.ts +1 -1
  230. package/{ext → packages}/ui/node/Tabs.ts +28 -13
  231. package/{ext → packages}/ui/node/Toast.ts +2 -2
  232. package/packages/ui/node/Waterfall.ts +94 -0
  233. package/packages/ui/package.json +21 -0
  234. package/packages/utils/package.json +17 -0
  235. package/{src → packages/utils/src}/global.ts +5 -18
  236. package/{src/lib/native.ts → packages/utils/src/index.ts} +34 -1
  237. package/tsconfig.json +1 -1
  238. package/ext/css/package.json +0 -9
  239. package/ext/css/src/structure/$CSSVariable.ts +0 -12
  240. package/ext/html/node/$Canvas.ts +0 -16
  241. package/ext/i18n/package.json +0 -10
  242. package/ext/idb/package.json +0 -13
  243. package/ext/markdown/package.json +0 -15
  244. package/ext/router/package.json +0 -10
  245. package/ext/signal/package.json +0 -9
  246. package/ext/signal/src/index.ts +0 -128
  247. package/ext/ssr/env.ts +0 -61
  248. package/ext/ssr/index.ts +0 -49
  249. package/ext/ssr/package.json +0 -10
  250. package/ext/ui/node/Waterfall.ts +0 -72
  251. package/ext/ui/package.json +0 -11
  252. package/src/index.ts +0 -2
  253. package/src/lib/chain.ts +0 -13
  254. package/src/lib/debounce.ts +0 -7
  255. package/src/lib/env.ts +0 -2
  256. package/src/lib/randomId.ts +0 -9
  257. package/src/lib/sleep.ts +0 -3
  258. package/src/lib/toArray.ts +0 -9
  259. package/src/lib/trycatch.ts +0 -17
  260. package/src/lib/uppercase.ts +0 -3
  261. /package/{src/node.ts → packages/core/src/lib/assignNodeProperties.ts} +0 -0
  262. /package/{ext → packages}/css/README.md +0 -0
  263. /package/{ext/css/src/lib → packages/css/src/ext}/colors.ts +0 -0
  264. /package/{ext → packages}/css/src/structure/$CSSDeclaration.ts +0 -0
  265. /package/{ext → packages}/i18n/README.md +0 -0
  266. /package/{ext → packages}/idb/README.md +0 -0
  267. /package/{ext → packages}/idb/src/core.ts +0 -0
  268. /package/{ext → packages}/markdown/README.md +0 -0
  269. /package/{ext → packages}/markdown/src/index.ts +0 -0
  270. /package/{ext → packages}/markdown/src/lib/type.ts +0 -0
  271. /package/{ext → packages}/markdown/src/structure/Markdown.ts +0 -0
  272. /package/{ext → packages}/markdown/src/syntax/blockquote.ts +0 -0
  273. /package/{ext → packages}/markdown/src/syntax/bold.ts +0 -0
  274. /package/{ext → packages}/markdown/src/syntax/code.ts +0 -0
  275. /package/{ext → packages}/markdown/src/syntax/heading.ts +0 -0
  276. /package/{ext → packages}/markdown/src/syntax/horizontalRule.ts +0 -0
  277. /package/{ext → packages}/markdown/src/syntax/image.ts +0 -0
  278. /package/{ext → packages}/markdown/src/syntax/italic.ts +0 -0
  279. /package/{ext → packages}/markdown/src/syntax/text.ts +0 -0
  280. /package/{ext → packages}/router/README.md +0 -0
  281. /package/{ext → packages}/signal/README.md +0 -0
  282. /package/{ext → packages}/ui/node/Grid.ts +0 -0
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@amateras/router",
3
+ "peerDependencies": {
4
+ "@amateras/core": "workspace:*",
5
+ "@amateras/html": "workspace:*",
6
+ "@amateras/utils": "workspace:*"
7
+ },
8
+ "imports": {
9
+ "#structure/*": "./src/structure/*.ts",
10
+ "#lib/*": "./src/lib/*.ts",
11
+ "#node/*": "./src/node/*.ts"
12
+ },
13
+ "exports": {
14
+ ".": "./src/index.ts",
15
+ "./structure/*": "./src/structure/*.ts",
16
+ "./lib/*": "./src/lib/*.ts",
17
+ "./node/*": "./src/node/*.ts"
18
+ }
19
+ }
@@ -2,13 +2,12 @@ import type { Page } from "#node/Page";
2
2
  import { Router } from "#node/Router";
3
3
  import { PageBuilder } from "#structure/PageBuilder";
4
4
  import { Route, type RouteBuilder, type RouteParams } from "#structure/Route";
5
- import { _bind, _Object_assign, forEach } from "../../../src/lib/native";
6
- import type { AnchorTarget } from "../../html/node/$Anchor";
5
+ import { _Object_assign, _bind, forEach } from "@amateras/utils";
6
+ import type { AnchorTarget } from "../../html/src/node/$Anchor";
7
7
 
8
- declare module 'amateras/core' {
9
- // export function $(nodeName: 'ra'): RouterAnchor;
8
+ declare module '@amateras/core' {
10
9
  export namespace $ {
11
- export function route<Params extends RouteParams = []>(builder: (page: Page<Params>) => Page<Params>): PageBuilder<Params>;
10
+ export function route<Params extends RouteParams = []>(builder: (page: Page<Params>) => OrPromise<Page<Params>>): PageBuilder<Params>;
12
11
  export function open(url: string | URL | Nullish, target?: AnchorTarget): typeof Router;
13
12
  export function replace(url: string | URL | Nullish): typeof Router;
14
13
  export function back(): typeof Router;
@@ -1,17 +1,20 @@
1
1
  import type { RouteParams } from "#structure/Route";
2
- import { $HTMLElement } from "amateras/node/$HTMLElement";
3
- import { _null } from "../../../../src/lib/native";
2
+ import { chain } from "@amateras/core/lib/chain";
3
+ import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
4
+ import { _null } from "@amateras/utils";
4
5
  import type { Router } from "./Router";
5
- import { chain } from "../../../../src/lib/chain";
6
+
6
7
 
7
8
  export class Page<Params extends RouteParams = []> extends $HTMLElement {
8
9
  params: PageParamsResolver<Params>;
9
10
  router: null | Router = _null
10
11
  #pageTitle: string | null = _null;
11
12
  built = false;
12
- constructor(params: PageParamsResolver<Params>) {
13
+ pathId: string;
14
+ constructor(pathId: string, params: PageParamsResolver<Params>) {
13
15
  super('page');
14
16
  this.params = params;
17
+ this.pathId = pathId;
15
18
  }
16
19
 
17
20
  pageTitle(): string | null;
@@ -19,6 +22,7 @@ export class Page<Params extends RouteParams = []> extends $HTMLElement {
19
22
  pageTitle(title?: string | null) {
20
23
  return chain(this, arguments, () => this.#pageTitle, title, title => this.#pageTitle = title)
21
24
  }
25
+
22
26
  }
23
27
 
24
28
  export type PageParams = { [key: string]: string }
@@ -1,10 +1,10 @@
1
- import { $HTMLElement } from "amateras/node/$HTMLElement";
2
1
  import { Route, type RouteBuilder, type RoutePath, type RouteParamsResolver, type RouteParams, type RouteParamsStrings, type AsyncPageBuilder } from "../structure/Route";
3
- import { _document } from "amateras/lib/env";
4
- import { _instanceof, startsWith, _JSON_parse, forEach, _Object_entries, _JSON_stringify, _Object_assign, isFunction, _null } from "../../../../src/lib/native";
5
- import type { AnchorTarget } from "../../../html/node/$Anchor";
2
+ import type { AnchorTarget } from "../../../html/src/node/$Anchor";
6
3
  import { Page, type PageParams } from "./Page";
7
4
  import type { PageBuilder, PageBuilderFunction } from "#structure/PageBuilder";
5
+ import { _document } from "@amateras/core/env";
6
+ import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
7
+ import { _instanceof, startsWith, _JSON_parse, forEach, _Object_entries, _JSON_stringify, isFunction } from "@amateras/utils";
8
8
  // history index
9
9
  let index = 0;
10
10
  const _addEventListener = addEventListener;
@@ -38,15 +38,20 @@ const historyHandler = async (path: string | URL | Nullish, mode: 1 | 2, target?
38
38
  scrollRecord();
39
39
  if (mode === PUSH) index += 1;
40
40
  Router.direction = FORWARD;
41
+ Router.prevUrl = toURL(_location.href);
41
42
  _history[mode === PUSH ? 'pushState' : 'replaceState']({index}, '' , url);
43
+ Router.url = url;
42
44
  forEach(Router.routers, router => router.resolve(path))
43
45
  }
44
46
  // disable browser scroll restoration
45
47
  _history.scrollRestoration = 'manual';
46
48
 
49
+ type RouteData = { route: Route, params: PageParams, pathId: string }
47
50
  export class Router extends $HTMLElement {
48
51
  static direction: 'back' | 'forward' = FORWARD;
49
52
  static routers = new Set<Router>();
53
+ static url: URL = toURL(_location.href);
54
+ static prevUrl: URL | null = null;
50
55
  routes = new Map<RoutePath, Route>();
51
56
  pages = new Map<string, Page>();
52
57
  constructor(page?: Page) {
@@ -85,6 +90,8 @@ export class Router extends $HTMLElement {
85
90
  if (index > stateIndex) Router.direction = BACK;
86
91
  if (index < stateIndex) Router.direction = FORWARD;
87
92
  index = stateIndex;
93
+ Router.prevUrl = Router.url;
94
+ Router.url = toURL(_location.href);
88
95
  this.resolve(_location.href);
89
96
  }
90
97
  _addEventListener('popstate', resolve);
@@ -94,73 +101,37 @@ export class Router extends $HTMLElement {
94
101
  return this;
95
102
  }
96
103
 
97
- async resolve(path: string | URL): Promise<this> {
104
+ async resolve(path: string | URL, force = false): Promise<this> {
98
105
  const {pathname, href} = toURL(path);
99
- const split = (p: string) => p.replaceAll(/\/+/g, '/').replace(/^\//, '').split('/').map(path => `/${path}`);
100
- type RouteData = { route: Route, params: PageParams, pathId: string }
101
- const searchRoute = (routes: typeof this.routes, targetPath: string): RouteData[] => {
102
- let targetPathSplit = split(targetPath);
103
- if (!routes.size) return [];
104
- // check each route
105
- for (const [_, route] of routes) {
106
- // check each path pass
107
- routePathLoop: for (const [path, paramsHandle] of route.paths) {
108
- let routePathSplit = split(path);
109
- let targetPathNodePosition = 0;
110
- let params: { [key: string]: string } = isFunction(paramsHandle) ? paramsHandle() : paramsHandle ?? {};
111
- let pathId = '';
112
- // check each path node
113
- pathNodeLoop: for (let i = 0; i < routePathSplit.length; i++) {
114
- // reset target path node position
115
- targetPathNodePosition = i;
116
- const routeNode = routePathSplit[i];
117
- const targetNode = targetPathSplit[i];
118
- // path node undefined, break path loop
119
- if (!routeNode || !targetNode) continue routePathLoop;
120
- // path node is params node
121
- if (routeNode.includes(':')) {
122
- // target not matched
123
- if (targetNode === '/') continue routePathLoop;
124
- const [prefix, paramName] = routeNode.split(':') as [string, string];
125
- if (!startsWith(targetNode, prefix)) continue routePathLoop;
126
- params[paramName] = targetNode.replace(`${prefix}`, '');
127
- pathId += targetNode;
128
- continue pathNodeLoop;
129
- }
130
- // path node not matched, next path
131
- if (routeNode !== targetNode) continue routePathLoop;
132
- pathId += targetNode;
133
- }
134
- // target path node longer than route, next route
135
- if (targetPathSplit[targetPathNodePosition + 1] && !route.routes.size) continue routePathLoop;
136
- // all path node passed, route found
137
- return [{route, params, pathId}, ...searchRoute(route.routes, targetPathSplit.slice(targetPathNodePosition + 1).join('/'))]
138
- }
139
- }
140
- // no route passed
141
- const notfound = routes.get('notfound');
142
- if (notfound) return [{route: notfound, params: {}, pathId: 'notfound'}]
143
- return [];
144
- }
145
- const routes = searchRoute(this.routes, pathname);
106
+ const routes = this.getRoutes(this.routes, pathname);
107
+ const routerPageMap = new Map<Router, Page>();
146
108
  let prevRouter: Router | null = this;
109
+ let pathIdStr = '';
110
+ let paramsData = {}
147
111
  await forEach(routes, async ({route, params, pathId}) => {
112
+ pathIdStr += pathId;
113
+ paramsData = {...paramsData, ...params}
148
114
  // skip route group
149
115
  const builderResolver = route.builder;
150
116
  if (!builderResolver) return;
151
117
  // get page from cache or create new page
152
- const page = route.pages.get(pathId) ?? new Page(params);
118
+ const page = route.pages.get(pathId) ?? new Page(pathIdStr, paramsData);
153
119
  // resolve builder
154
120
  if (!page.built) await builderResolver.build(page);
155
121
  page.built = true;
156
- // set title
157
- _document && (_document.title = page.pageTitle() ?? _document.title);
158
- // check location is still same, page parent is not router before insert page
159
- if (href === _location.href && page.parentNode !== prevRouter?.node) prevRouter?.content(page);
122
+ // set router to page map
123
+ if (prevRouter) routerPageMap.set(prevRouter, page)
160
124
  // set cache
161
- route.pages.set(pathId, page);
125
+ if (!force) route.pages.set(pathId, page);
162
126
  prevRouter = page.router;
163
127
  })
128
+
129
+ forEach(routerPageMap, ([router, page]) => {
130
+ // set title
131
+ _document && (_document.title = page.pageTitle() ?? _document.title ?? '');
132
+ // check location is still same, page parent is not router before insert page
133
+ if (force || (href === _location.href && page.parentNode !== router.node)) router.content(page);
134
+ })
164
135
  // handle scroll restoration
165
136
  let { x, y } = Router.scroll ?? {x: 0, y: 0};
166
137
  scrollTo(x, y);
@@ -168,6 +139,56 @@ export class Router extends $HTMLElement {
168
139
  this.dispatchEvent(new Event('routeopen', {bubbles: true}));
169
140
  return this;
170
141
  }
142
+
143
+ protected getRoutes(routes: typeof this.routes, targetPath: string): RouteData[] {
144
+ const split = (p: string) => p.replaceAll(/\/+/g, '/').replace(/^\//, '').split('/').map(path => `/${path}`);
145
+ let targetPathSplit = split(targetPath);
146
+ if (!routes.size) return [];
147
+ // check each route
148
+ for (const [_, route] of routes) {
149
+ // check each path pass
150
+ routePathLoop: for (const [path, paramsHandle] of route.paths) {
151
+ let routePathSplit = split(path);
152
+ let targetPathNodePosition = 0;
153
+ let params: { [key: string]: string } = isFunction(paramsHandle) ? paramsHandle() : paramsHandle ?? {};
154
+ let pathId = '';
155
+ // check each path node
156
+ pathNodeLoop: for (let i = 0; i < routePathSplit.length; i++) {
157
+ // reset target path node position
158
+ targetPathNodePosition = i;
159
+ const routeNode = routePathSplit[i];
160
+ const targetNode = targetPathSplit[i];
161
+ // path node undefined, break path loop
162
+ if (!routeNode || !targetNode) continue routePathLoop;
163
+ // path node is params node
164
+ if (routeNode.includes(':')) {
165
+ // target not matched
166
+ if (targetNode === '/') continue routePathLoop;
167
+ const [prefix, paramName] = routeNode.split(':') as [string, string];
168
+ if (!startsWith(targetNode, prefix)) continue routePathLoop;
169
+ params[paramName] = targetNode.replace(`${prefix}`, '');
170
+ pathId += targetNode;
171
+ continue pathNodeLoop;
172
+ }
173
+ // path node not matched, next path
174
+ if (routeNode !== targetNode) continue routePathLoop;
175
+ pathId += targetNode;
176
+ }
177
+ // target path node longer than route, next route
178
+ if (targetPathSplit[targetPathNodePosition + 1] && !route.routes.size) continue routePathLoop;
179
+ // all path node passed, route found
180
+ return [{route, params, pathId}, ...this.getRoutes(route.routes, targetPathSplit.slice(targetPathNodePosition + 1).join('/'))]
181
+ }
182
+ }
183
+ // no route passed
184
+ const notfound = routes.get('notfound');
185
+ if (notfound) return [{route: notfound, params: {}, pathId: 'notfound'}]
186
+ return [];
187
+ }
188
+
189
+ protected getPage() {
190
+
191
+ }
171
192
  }
172
193
 
173
194
  export interface Router {
@@ -1,4 +1,4 @@
1
- import { $Anchor } from "../../../html/node/$Anchor";
1
+ import { $Anchor } from "@amateras/html/node/$Anchor";
2
2
 
3
3
  export class RouterAnchor extends $Anchor {
4
4
  constructor() {
@@ -13,7 +13,7 @@ export class RouterAnchor extends $Anchor {
13
13
  }
14
14
  }
15
15
 
16
- declare module 'amateras/core' {
16
+ declare module '@amateras/core' {
17
17
  export namespace $ {
18
18
  export interface $NodeMap {
19
19
  'ra': typeof RouterAnchor;
@@ -1,6 +1,6 @@
1
- import { Page, type PageParams } from "#node/Page";
2
- import { _instanceof, _Promise, isFunction } from "../../../../src/lib/native";
3
- import type { $NodeContentResolver } from "../../../../src/node/$Node";
1
+ import { Page } from "#node/Page";
2
+ import type { $NodeContentResolver } from "@amateras/core/node/$Node";
3
+ import { _instanceof, _Promise } from "@amateras/utils";
4
4
  import type { AsyncPageBuilder, RouteParams } from "./Route";
5
5
 
6
6
  export class PageBuilder<Params extends RouteParams = any> {
@@ -1,5 +1,5 @@
1
1
  import type { Page } from "#node/Page";
2
- import { _instanceof, _null, isUndefined } from "../../../../src/lib/native";
2
+ import { _null, _instanceof, isUndefined } from "@amateras/utils";
3
3
  import { PageBuilder, type PageBuilderFunction } from "./PageBuilder";
4
4
 
5
5
  export class Route<Path extends RoutePath = RoutePath, Params extends RouteParams = []> {
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@amateras/signal",
3
+ "peerDependencies": {
4
+ "@amateras/core": "workspace:*",
5
+ "@amateras/utils": "workspace:*"
6
+ },
7
+ "imports": {
8
+ "#structure/*": "./src/structure/*.ts",
9
+ "#lib/*": "./src/lib/*.ts",
10
+ "#node/*": "./src/node/*.ts"
11
+ },
12
+ "exports": {
13
+ ".": "./src/index.ts",
14
+ "./structure/*": "./src/structure/*.ts",
15
+ "./lib/*": "./src/lib/*.ts",
16
+ "./node/*": "./src/node/*.ts"
17
+ }
18
+ }
@@ -0,0 +1,221 @@
1
+ import { Signal } from "#structure/Signal";
2
+ import { $Node, $Text, type $NodeContentResolver } from "@amateras/core/node/$Node";
3
+ import { _instanceof, isObject, _JSON_stringify, _Object_assign, forEach, _null, _Object_defineProperty, _Object_entries, isNull, isFunction, _Promise, toArray } from "@amateras/utils";
4
+
5
+ // handle $Node content process
6
+ $Node.processors.add((_, content) => {
7
+ const signal = (content as SignalFunction<any>)?.signal;
8
+ if (_instanceof(signal, Signal)) {
9
+ const signalValue = (content as SignalFunction<any>)();
10
+ const signalHandler = (resolver: any): $NodeContentResolver<any> => {
11
+ if (_instanceof(resolver, _Promise)) {
12
+ return resolver.then(signalHandler) as any;
13
+ }
14
+ else if (_instanceof(resolver, $Node)) {
15
+ // handler signal $Node result
16
+ let node = resolver;
17
+ const set = (value: any) => {
18
+ node.replace(value);
19
+ node = value;
20
+ }
21
+ signal.subscribe(set);
22
+ return [resolver];
23
+ } else {
24
+ // handler signal other type result
25
+ const $text = new $Text()
26
+ const set = (value: any) => $text.textContent(isObject(value) ? _JSON_stringify(value) : value);
27
+ signal.subscribe(set);
28
+ set(resolver);
29
+ return [$text];
30
+ }
31
+ }
32
+ return signalHandler(signalValue);
33
+ }
34
+ })
35
+
36
+ // handle $Node native method setter
37
+ $Node.setters.add((value, set) => {
38
+ const signal = value?.signal;
39
+ if (isFunction(value) && _instanceof(signal, Signal)) {
40
+ signal.subscribe(set);
41
+ return value();
42
+ }
43
+ })
44
+
45
+ declare module '@amateras/core' {
46
+ export namespace $ {
47
+ export function signal<T>(value: T): SignalFunction<T>;
48
+ export function compute<T>(process: (untrack: UntrackHandler) => T): ComputeFunction<T>;
49
+ export function effect(process: (untrack: UntrackHandler) => void): void;
50
+ export function await<K, O extends SignalAwaitOptions<K, unknown>>(signalFn: SignalFunction<OrPromise<K>> | ComputeFunction<OrPromise<K>>, options: O): O[keyof O];
51
+ export interface $NodeContentMap {
52
+ signalFn: SignalFunction<any>;
53
+ computeFn: ComputeFunction<any>;
54
+ }
55
+ export interface $NodeParameterMap<T> {
56
+ // Distribute T type
57
+ signalFn: T extends any ? SignalFunction<Narrow<T>> : never;
58
+ computeFn: T extends any ? ComputeFunction<Narrow<T>> : never;
59
+ }
60
+ }
61
+ }
62
+
63
+ type SignalObject<T> = T extends Array<any> ? {} : T extends object ? { [key in keyof T as `${string & key}$`]: SignalFunction<T[key]> } : {};
64
+ type SignalValue<T> = T extends Promise<infer R> ? T | R : T;
65
+ export type SignalPromiseState = 'await' | 'then' | 'catch';
66
+ export type SignalAwaitOptions<T, R> = {
67
+ await: R | (() => R);
68
+ then: R | ((value: T) => R);
69
+ catch: R | ((error: any) => R);
70
+ }
71
+
72
+ export type SignalFunction<T> = {
73
+ (): T;
74
+ signal: Signal<T>;
75
+ set: (newValue: SignalValue<T> | ((oldValue: T) => SignalValue<T>)) => SignalFunction<T>;
76
+ value: () => T;
77
+ state: SignalPromiseState;
78
+ await: <R>(resolver: R) => AwaitFunction<T, R>
79
+ } & SignalObject<T>;
80
+
81
+ export type ComputeFunction<T> = {
82
+ (): T;
83
+ signal: Signal<T>;
84
+ state: SignalPromiseState;
85
+ };
86
+
87
+ export type AwaitFunction<T, R> = {
88
+ (): R;
89
+ then<D>(resolver: (value: Awaited<T>) => D): AwaitFunction<T, R | D>;
90
+ then<D>(resolver: D): AwaitFunction<T, R | D>;
91
+ catch<D>(resolver: (error: any) => D): AwaitFunction<T, R | D>;
92
+ catch<D>(resolver: D): AwaitFunction<T, R | D>;
93
+ } & ComputeFunction<T>
94
+
95
+ export type SignalListener = (signal: Signal<any>) => void;
96
+ export type UntrackHandler = <T>(fn: () => T) => T
97
+
98
+ const signalComputeListeners = new Set<SignalListener>();
99
+ const signalEffectListeners = new Set<SignalListener>();
100
+ const signalFnMap = new Map<any, SignalFunction<any> | ComputeFunction<any>>();
101
+
102
+ // experiment feature
103
+ const nestedComputeFn = (value: any, parentSignalFn: SignalFunction<any> | ComputeFunction<any>) => {
104
+ if (isObject(value) && !isNull(value)) {
105
+ forEach(_Object_entries(value), ([key, val]) => {
106
+ const cachedFn = signalFnMap.get(val);
107
+ const val$ = cachedFn ?? $.compute(() => parentSignalFn()[key]);
108
+ if (!cachedFn && isObject(val)) {
109
+ signalFnMap.set(val, val$);
110
+ nestedComputeFn(val, val$)
111
+ }
112
+ _Object_defineProperty(parentSignalFn, `${key}$`, {value: val$});
113
+ })
114
+ }
115
+ }
116
+
117
+ const AWAIT = 'await';
118
+ const THEN = 'then';
119
+ const CATCH = 'catch';
120
+
121
+ _Object_assign($, {
122
+ // signal function
123
+ signal<T>(value: T): SignalFunction<T> {
124
+ const signal = new Signal<T>(value);
125
+ const signalFn = function () {
126
+ forEach([...signalComputeListeners, ...signalEffectListeners], fn => fn(signal));
127
+ return signal.value();
128
+ } as SignalFunction<T>
129
+ nestedComputeFn(value, signalFn);
130
+ if (_instanceof(value, _Promise)) {
131
+ value.catch(err => {
132
+ signalFn.state = CATCH;
133
+ signal.value(err);
134
+ }).then(v => {
135
+ signalFn.state = THEN;
136
+ signal.value(v as any);
137
+ })
138
+ }
139
+ _Object_assign(signalFn, {
140
+ signal,
141
+ set: (newValue: T) => (signal.value(newValue), signalFn),
142
+ value: () => signal.value(),
143
+ state: _instanceof(value, _Promise) ? AWAIT : THEN,
144
+
145
+ await(awaitResolver: any) {
146
+ let thenResolver: any = _null
147
+ let catchResolver: any = _null
148
+ const awaitFn = $.compute(untrack => {
149
+ const value = signalFn();
150
+ return untrack(() => {
151
+ switch (signalFn.state) {
152
+ case AWAIT: return isFunction(awaitResolver) ? awaitResolver() : awaitResolver;
153
+ case THEN: return isFunction(thenResolver) ? thenResolver(value as any) : thenResolver;
154
+ case CATCH: return isFunction(catchResolver) ? catchResolver(value) : catchResolver;
155
+ }
156
+ })
157
+ })
158
+
159
+ _Object_assign(awaitFn, {
160
+ then(resolver: any) {
161
+ thenResolver = resolver;
162
+ return awaitFn;
163
+ },
164
+ catch(resolver: any) {
165
+ catchResolver = resolver;
166
+ return awaitFn;
167
+ }
168
+ })
169
+
170
+ return awaitFn;
171
+ }
172
+ })
173
+ return signalFn
174
+ },
175
+
176
+ // compute function
177
+ compute<T>(process: (untrack: UntrackHandler) => T): ComputeFunction<T> {
178
+ let subscribed = false;
179
+ const signalFn: SignalFunction<any> = $.signal(_null);
180
+ const computeFn = () => {
181
+ if (!subscribed) return signalFn.set(subscribe()).value();
182
+ else return signalFn.set(process(untrack)).value();
183
+ }
184
+ const untrack = <T>(fn: () => T) => {
185
+ if (subscribed) return fn();
186
+ signalComputeListeners.delete(signalListener);
187
+ const result = fn();
188
+ signalComputeListeners.add(signalListener);
189
+ return result;
190
+ }
191
+ const signalListener = (signal: Signal<any>) =>
192
+ signal.subscribe(() => signalFn.set(process(untrack)))
193
+ const subscribe = () => {
194
+ signalComputeListeners.add(signalListener);
195
+ const result = process(untrack);
196
+ signalComputeListeners.delete(signalListener);
197
+ subscribed = true;
198
+ return result;
199
+ }
200
+ _Object_assign(computeFn, { signal: signalFn.signal });
201
+ return computeFn as ComputeFunction<T>
202
+ },
203
+
204
+ // effect
205
+ effect(process: (untrack: UntrackHandler) => void) {
206
+ let subscribed = false;
207
+ const signalListener = (signal: Signal<any>) =>
208
+ signal.subscribe(_ => process(untrack));
209
+ const untrack = <T>(fn: () => T) => {
210
+ if (subscribed) return fn();
211
+ signalEffectListeners.delete(signalListener);
212
+ const result = fn();
213
+ signalEffectListeners.add(signalListener);
214
+ return result;
215
+ }
216
+ signalEffectListeners.add(signalListener);
217
+ process(untrack);
218
+ signalEffectListeners.delete(signalListener);
219
+ subscribed = true;
220
+ },
221
+ })
@@ -1,4 +1,4 @@
1
- import { _instanceof, forEach, isFunction, isUndefined } from "amateras/lib/native";
1
+ import { _instanceof, forEach, isFunction, isUndefined } from "@amateras/utils";
2
2
 
3
3
  export class Signal<T> {
4
4
  #value: T;
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@amateras/ssr",
3
+ "peerDependencies": {
4
+ "@amateras/core": "workspace:*",
5
+ "@amateras/utils": "workspace:*",
6
+ "@amateras/router": "workspace:*",
7
+ "@amateras/signal": "workspace:*"
8
+ },
9
+ "imports": {
10
+ "#structure/*": "./src/structure/*.ts",
11
+ "#lib/*": "./src/lib/*.ts",
12
+ "#node/*": "./src/node/*.ts"
13
+ },
14
+ "exports": {
15
+ "./structure/*": "./src/structure/*.ts",
16
+ "./lib/*": "./src/lib/*.ts",
17
+ "./node/*": "./src/node/*.ts"
18
+ }
19
+ }
@@ -0,0 +1,38 @@
1
+ import '@amateras/signal';
2
+ import { Page } from "@amateras/router";
3
+ import type { SignalFunction } from "@amateras/signal";
4
+ import { isAsyncFunction, isFunction } from '@amateras/utils';
5
+ import { onclient, onserver } from '@amateras/core/env';
6
+
7
+ declare global {
8
+ export var hydrate: Record<string, any>;
9
+ }
10
+
11
+ declare module '@amateras/router' {
12
+ export interface Page {
13
+ data<D>(data: D | (() => OrPromise<D>)): Promise<SignalFunction<D>>
14
+ }
15
+ }
16
+
17
+ onclient(() => {
18
+ if (typeof window.hydrate === 'undefined') window.hydrate = {};
19
+ })
20
+
21
+ //@ts-expect-error
22
+ onserver(() => global.hydrate = {})
23
+
24
+ Object.assign(Page.prototype, {
25
+ async data<D>(this: Page, data: D | (() => OrPromise<D>)) {
26
+ const hydrateData = hydrate[this.pathId];
27
+ const d = hydrateData ?? (
28
+ isFunction(data)
29
+ ? isAsyncFunction(data)
30
+ ? await data()
31
+ : data()
32
+ : data
33
+ )
34
+ const data$ = $.signal(d);
35
+ onserver(() => $.effect(() => hydrate[this.pathId] = data$()))
36
+ return data$;
37
+ }
38
+ })
@@ -1,8 +1,8 @@
1
- import { _Array_from, _instanceof, forEach } from "amateras/lib/native";
2
- import type { $Virtual } from "amateras/node/$Virtual";
3
- import { $HTMLElement } from "amateras/node/$HTMLElement";
4
- import { _document } from "amateras/lib/env";
5
- import type { $Node } from "amateras/node/$Node";
1
+ import { _document } from "@amateras/core/env";
2
+ import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
3
+ import type { $Node } from "@amateras/core/node/$Node";
4
+ import type { $Virtual } from "@amateras/core/node/$Virtual";
5
+ import { _Array_from, _instanceof, forEach } from "@amateras/utils";
6
6
 
7
7
  export const VirtualScroll = ($parent: $Virtual, scroller: $Node = $(_document)) => {
8
8
  scroller.on('scroll', () => render($parent), true);
@@ -1,7 +1,7 @@
1
- import { _Array_from, _instanceof, forEach, isNull } from "amateras/lib/native";
2
- import { $HTMLElement } from "amateras/node/$HTMLElement";
3
- import type { $Node, $NodeContentResolver } from "amateras/node/$Node";
4
- import { chain } from "../../../src/lib/chain";
1
+ import { chain } from "@amateras/core/lib/chain";
2
+ import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
3
+ import type { $Node, $NodeContentResolver } from "@amateras/core/node/$Node";
4
+ import { _Array_from, _instanceof, forEach, isNull } from "@amateras/utils";
5
5
 
6
6
  const [ACCORDIAN, ACCORDIAN_ITEM, ACCORDIAN_TRIGGER, ACCORDIAN_CONTENT, ACCORDIAN_CONTAINER] = ['accordian', 'accordian-item', 'accordian-trigger', 'accordian-content', 'accordian-container'] as const;
7
7
  forEach([
@@ -0,0 +1,20 @@
1
+ import { chain } from "@amateras/core/lib/chain";
2
+ import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
3
+
4
+ const CAROUSEL = 'carousel';
5
+ const CAROUSEL_ITEM = 'carousel-item';
6
+
7
+ export class Carousel extends $HTMLElement {
8
+ constructor() {
9
+ super(CAROUSEL);
10
+ }
11
+
12
+ }
13
+
14
+ export class CarouselItem extends $HTMLElement {
15
+ constructor() {
16
+ super(CAROUSEL_ITEM)
17
+ }
18
+ }
19
+
20
+ export type CarouselDirection = 'horizontal' | 'vertical';