amateras 0.5.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 (290) hide show
  1. package/README.md +23 -26
  2. package/index.ts +1 -0
  3. package/package.json +32 -27
  4. package/packages/core/package.json +32 -0
  5. package/packages/core/src/env.browser.ts +21 -0
  6. package/packages/core/src/env.node.ts +21 -0
  7. package/packages/core/src/global.ts +18 -0
  8. package/packages/core/src/index.ts +96 -0
  9. package/packages/core/src/lib/assignNodeProperties.ts +11 -0
  10. package/packages/core/src/lib/assignProperties.ts +57 -0
  11. package/packages/core/src/lib/chain.ts +17 -0
  12. package/packages/core/src/lib/dom.ts +20 -0
  13. package/packages/core/src/main.ts +4 -0
  14. package/{src → packages/core/src}/node/$Element.ts +25 -47
  15. package/packages/core/src/node/$EventTarget.ts +48 -0
  16. package/{src → packages/core/src}/node/$HTMLElement.ts +1 -1
  17. package/{src → packages/core/src}/node/$Node.ts +64 -73
  18. package/packages/core/src/node/$Virtual.ts +65 -0
  19. package/packages/css/package.json +17 -0
  20. package/{ext/css/src/lib → packages/css/src/ext}/colors/amber.ts +2 -2
  21. package/{ext/css/src/lib → packages/css/src/ext}/colors/blackwhite.ts +2 -2
  22. package/{ext/css/src/lib → packages/css/src/ext}/colors/blue.ts +2 -2
  23. package/{ext/css/src/lib → packages/css/src/ext}/colors/cyan.ts +2 -2
  24. package/{ext/css/src/lib → packages/css/src/ext}/colors/emerald.ts +2 -2
  25. package/{ext/css/src/lib → packages/css/src/ext}/colors/fuchsia.ts +2 -2
  26. package/{ext/css/src/lib → packages/css/src/ext}/colors/gray.ts +2 -2
  27. package/{ext/css/src/lib → packages/css/src/ext}/colors/green.ts +2 -2
  28. package/{ext/css/src/lib → packages/css/src/ext}/colors/indigo.ts +2 -2
  29. package/{ext/css/src/lib → packages/css/src/ext}/colors/lime.ts +2 -2
  30. package/{ext/css/src/lib → packages/css/src/ext}/colors/neutral.ts +2 -2
  31. package/{ext/css/src/lib → packages/css/src/ext}/colors/orange.ts +2 -2
  32. package/{ext/css/src/lib → packages/css/src/ext}/colors/pink.ts +2 -2
  33. package/{ext/css/src/lib → packages/css/src/ext}/colors/purple.ts +2 -2
  34. package/{ext/css/src/lib → packages/css/src/ext}/colors/red.ts +2 -2
  35. package/{ext/css/src/lib → packages/css/src/ext}/colors/rose.ts +2 -2
  36. package/{ext/css/src/lib → packages/css/src/ext}/colors/sky.ts +2 -2
  37. package/{ext/css/src/lib → packages/css/src/ext}/colors/slate.ts +2 -2
  38. package/{ext/css/src/lib → packages/css/src/ext}/colors/stone.ts +2 -2
  39. package/{ext/css/src/lib → packages/css/src/ext}/colors/teal.ts +2 -2
  40. package/{ext/css/src/lib → packages/css/src/ext}/colors/violet.ts +2 -2
  41. package/{ext/css/src/lib → packages/css/src/ext}/colors/yellow.ts +2 -2
  42. package/{ext/css/src/lib → packages/css/src/ext}/colors/zinc.ts +2 -2
  43. package/packages/css/src/ext/container.ts +32 -0
  44. package/packages/css/src/ext/keyframes.ts +54 -0
  45. package/packages/css/src/ext/media.ts +32 -0
  46. package/packages/css/src/ext/property.ts +48 -0
  47. package/packages/css/src/ext/variable.ts +51 -0
  48. package/{ext → packages}/css/src/index.ts +107 -183
  49. package/{ext → packages}/css/src/lib/colorAssign.ts +1 -1
  50. package/packages/css/src/lib/utils.ts +11 -0
  51. package/{ext → packages}/css/src/structure/$CSSContainerRule.ts +1 -1
  52. package/{ext → packages}/css/src/structure/$CSSKeyframesRule.ts +0 -1
  53. package/{ext → packages}/css/src/structure/$CSSMediaRule.ts +1 -1
  54. package/packages/css/src/structure/$CSSProperty.ts +19 -0
  55. package/{ext → packages}/css/src/structure/$CSSRule.ts +1 -1
  56. package/{ext → packages}/css/src/structure/$CSSStyleRule.ts +1 -1
  57. package/packages/css/src/structure/$CSSVariable.ts +30 -0
  58. package/packages/dom/package.json +20 -0
  59. package/packages/dom/src/lib/HTMLElementMap.ts +213 -0
  60. package/packages/dom/src/lib/assignAttributes.ts +16 -0
  61. package/packages/dom/src/structure/CSS.ts +7 -0
  62. package/packages/dom/src/structure/CSSStyleSheet.ts +10 -0
  63. package/packages/dom/src/structure/DOMTokenList.ts +19 -0
  64. package/packages/dom/src/structure/Document.ts +36 -0
  65. package/packages/dom/src/structure/Element.ts +106 -0
  66. package/packages/dom/src/structure/HTMLElement.ts +34 -0
  67. package/packages/dom/src/structure/History.ts +11 -0
  68. package/packages/dom/src/structure/Location.ts +9 -0
  69. package/packages/dom/src/structure/Node.ts +51 -0
  70. package/packages/dom/src/structure/NodeList.ts +10 -0
  71. package/packages/dom/src/structure/Storage.ts +8 -0
  72. package/packages/dom/src/structure/Text.ts +20 -0
  73. package/packages/dom/src/structure/Window.ts +14 -0
  74. package/packages/dom/src/structure/html/HTMLAbbrElement.ts +16 -0
  75. package/packages/dom/src/structure/html/HTMLAddressElement.ts +16 -0
  76. package/packages/dom/src/structure/html/HTMLAnchorElement.ts +25 -0
  77. package/packages/dom/src/structure/html/HTMLAreaElement.ts +26 -0
  78. package/packages/dom/src/structure/html/HTMLArticleElement.ts +16 -0
  79. package/packages/dom/src/structure/html/HTMLAsideElement.ts +16 -0
  80. package/packages/dom/src/structure/html/HTMLAudioElement.ts +16 -0
  81. package/packages/dom/src/structure/html/HTMLBDIElement.ts +16 -0
  82. package/packages/dom/src/structure/html/HTMLBDOElement.ts +16 -0
  83. package/packages/dom/src/structure/html/HTMLBElement.ts +16 -0
  84. package/packages/dom/src/structure/html/HTMLBRElement.ts +17 -0
  85. package/packages/dom/src/structure/html/HTMLBaseElement.ts +18 -0
  86. package/packages/dom/src/structure/html/HTMLBodyElement.ts +22 -0
  87. package/packages/dom/src/structure/html/HTMLButtonElement.ts +26 -0
  88. package/packages/dom/src/structure/html/HTMLCanvasElement.ts +18 -0
  89. package/packages/dom/src/structure/html/HTMLCiteElement.ts +16 -0
  90. package/packages/dom/src/structure/html/HTMLCodeElement.ts +16 -0
  91. package/packages/dom/src/structure/html/HTMLDDElement.ts +16 -0
  92. package/packages/dom/src/structure/html/HTMLDFNElement.ts +16 -0
  93. package/packages/dom/src/structure/html/HTMLDListElement.ts +17 -0
  94. package/packages/dom/src/structure/html/HTMLDTElement.ts +16 -0
  95. package/packages/dom/src/structure/html/HTMLDataElement.ts +17 -0
  96. package/packages/dom/src/structure/html/HTMLDataListElement.ts +16 -0
  97. package/packages/dom/src/structure/html/HTMLDetailsElement.ts +17 -0
  98. package/packages/dom/src/structure/html/HTMLDialogElement.ts +18 -0
  99. package/packages/dom/src/structure/html/HTMLDivElement.ts +17 -0
  100. package/packages/dom/src/structure/html/HTMLEMElement.ts +16 -0
  101. package/packages/dom/src/structure/html/HTMLEmbedElement.ts +20 -0
  102. package/packages/dom/src/structure/html/HTMLFieldSetElement.ts +19 -0
  103. package/packages/dom/src/structure/html/HTMLFigCaptionElement.ts +16 -0
  104. package/packages/dom/src/structure/html/HTMLFigureElement.ts +16 -0
  105. package/packages/dom/src/structure/html/HTMLFooterElement.ts +16 -0
  106. package/packages/dom/src/structure/html/HTMLFormElement.ts +24 -0
  107. package/packages/dom/src/structure/html/HTMLHGroupElement.ts +16 -0
  108. package/packages/dom/src/structure/html/HTMLHRElement.ts +21 -0
  109. package/packages/dom/src/structure/html/HTMLHeadElement.ts +16 -0
  110. package/packages/dom/src/structure/html/HTMLHeaderElement.ts +16 -0
  111. package/packages/dom/src/structure/html/HTMLHeadingElement.ts +17 -0
  112. package/packages/dom/src/structure/html/HTMLHtmlElement.ts +18 -0
  113. package/packages/dom/src/structure/html/HTMLIElement.ts +16 -0
  114. package/packages/dom/src/structure/html/HTMLIFrameElement.ts +31 -0
  115. package/packages/dom/src/structure/html/HTMLImageElement.ts +38 -0
  116. package/packages/dom/src/structure/html/HTMLInputElement.ts +55 -0
  117. package/packages/dom/src/structure/html/HTMLKBDElement.ts +16 -0
  118. package/packages/dom/src/structure/html/HTMLLIElement.ts +18 -0
  119. package/packages/dom/src/structure/html/HTMLLabelElement.ts +18 -0
  120. package/packages/dom/src/structure/html/HTMLLegendElement.ts +17 -0
  121. package/packages/dom/src/structure/html/HTMLLinkElement.ts +31 -0
  122. package/packages/dom/src/structure/html/HTMLMainElement.ts +16 -0
  123. package/packages/dom/src/structure/html/HTMLMapElement.ts +17 -0
  124. package/packages/dom/src/structure/html/HTMLMarkElement.ts +16 -0
  125. package/packages/dom/src/structure/html/HTMLMediaElement.ts +48 -0
  126. package/packages/dom/src/structure/html/HTMLMenuElement.ts +18 -0
  127. package/packages/dom/src/structure/html/HTMLMetaElement.ts +22 -0
  128. package/packages/dom/src/structure/html/HTMLMeterElement.ts +23 -0
  129. package/packages/dom/src/structure/html/HTMLModElement.ts +18 -0
  130. package/packages/dom/src/structure/html/HTMLNavElement.ts +16 -0
  131. package/packages/dom/src/structure/html/HTMLNoscriptElement.ts +16 -0
  132. package/packages/dom/src/structure/html/HTMLOListElement.ts +20 -0
  133. package/packages/dom/src/structure/html/HTMLObjectElement.ts +34 -0
  134. package/packages/dom/src/structure/html/HTMLOptGroupElement.ts +18 -0
  135. package/packages/dom/src/structure/html/HTMLOptionElement.ts +20 -0
  136. package/packages/dom/src/structure/html/HTMLOutputElement.ts +20 -0
  137. package/packages/dom/src/structure/html/HTMLParagraphElement.ts +17 -0
  138. package/packages/dom/src/structure/html/HTMLPictureElement.ts +16 -0
  139. package/packages/dom/src/structure/html/HTMLPreElement.ts +17 -0
  140. package/packages/dom/src/structure/html/HTMLProgressElement.ts +19 -0
  141. package/packages/dom/src/structure/html/HTMLQuoteElement.ts +17 -0
  142. package/packages/dom/src/structure/html/HTMLRPElement.ts +16 -0
  143. package/packages/dom/src/structure/html/HTMLRTElement.ts +16 -0
  144. package/packages/dom/src/structure/html/HTMLRubyElement.ts +16 -0
  145. package/packages/dom/src/structure/html/HTMLSElement.ts +16 -0
  146. package/packages/dom/src/structure/html/HTMLSampElement.ts +16 -0
  147. package/packages/dom/src/structure/html/HTMLScriptElement.ts +27 -0
  148. package/packages/dom/src/structure/html/HTMLSectionElement.ts +16 -0
  149. package/packages/dom/src/structure/html/HTMLSelectElement.ts +27 -0
  150. package/packages/dom/src/structure/html/HTMLSlotElement.ts +17 -0
  151. package/packages/dom/src/structure/html/HTMLSmallElement.ts +16 -0
  152. package/packages/dom/src/structure/html/HTMLSourceElement.ts +21 -0
  153. package/packages/dom/src/structure/html/HTMLSpanElement.ts +16 -0
  154. package/packages/dom/src/structure/html/HTMLStrongElement.ts +16 -0
  155. package/packages/dom/src/structure/html/HTMLStyleElement.ts +18 -0
  156. package/packages/dom/src/structure/html/HTMLSubElement.ts +16 -0
  157. package/packages/dom/src/structure/html/HTMLSummaryElement.ts +16 -0
  158. package/packages/dom/src/structure/html/HTMLSupElement.ts +16 -0
  159. package/packages/dom/src/structure/html/HTMLTableCaptionElement.ts +17 -0
  160. package/packages/dom/src/structure/html/HTMLTableCellElement.ts +31 -0
  161. package/packages/dom/src/structure/html/HTMLTableColElement.ts +23 -0
  162. package/packages/dom/src/structure/html/HTMLTableElement.ts +26 -0
  163. package/packages/dom/src/structure/html/HTMLTableRowElement.ts +23 -0
  164. package/packages/dom/src/structure/html/HTMLTableSectionElement.ts +20 -0
  165. package/packages/dom/src/structure/html/HTMLTemplateElement.ts +17 -0
  166. package/packages/dom/src/structure/html/HTMLTextAreaElement.ts +33 -0
  167. package/packages/dom/src/structure/html/HTMLTimeElement.ts +17 -0
  168. package/packages/dom/src/structure/html/HTMLTitleElement.ts +17 -0
  169. package/packages/dom/src/structure/html/HTMLTrackElement.ts +21 -0
  170. package/packages/dom/src/structure/html/HTMLUElement.ts +16 -0
  171. package/packages/dom/src/structure/html/HTMLUListElement.ts +18 -0
  172. package/packages/dom/src/structure/html/HTMLVarElement.ts +16 -0
  173. package/packages/dom/src/structure/html/HTMLVideoElement.ts +22 -0
  174. package/packages/dom/src/structure/html/HTMLWBRElement.ts +16 -0
  175. package/packages/html/package.json +18 -0
  176. package/{ext/html/html.ts → packages/html/src/index.ts} +1 -1
  177. package/{ext/html → packages/html/src}/node/$Anchor.ts +4 -4
  178. package/packages/html/src/node/$Canvas.ts +38 -0
  179. package/{ext/html → packages/html/src}/node/$Dialog.ts +4 -4
  180. package/{ext/html → packages/html/src}/node/$Form.ts +4 -4
  181. package/{ext/html → packages/html/src}/node/$Image.ts +4 -4
  182. package/{ext/html → packages/html/src}/node/$Input.ts +4 -4
  183. package/{ext/html → packages/html/src}/node/$Label.ts +4 -4
  184. package/{ext/html → packages/html/src}/node/$Media.ts +4 -4
  185. package/{ext/html → packages/html/src}/node/$OptGroup.ts +4 -4
  186. package/{ext/html → packages/html/src}/node/$Option.ts +4 -4
  187. package/{ext/html → packages/html/src}/node/$Select.ts +4 -4
  188. package/{ext/html → packages/html/src}/node/$TextArea.ts +4 -4
  189. package/{ext → packages}/i18n/README.md +20 -0
  190. package/packages/i18n/package.json +19 -0
  191. package/packages/i18n/src/index.ts +140 -0
  192. package/{ext → packages}/i18n/src/structure/I18n.ts +12 -8
  193. package/{ext → packages}/i18n/src/structure/I18nDictionary.ts +1 -1
  194. package/packages/i18n/src/structure/I18nTranslation.ts +41 -0
  195. package/packages/idb/package.json +19 -0
  196. package/{ext → packages}/idb/src/index.ts +2 -2
  197. package/{ext → packages}/idb/src/lib/$IDBRequest.ts +1 -1
  198. package/{ext → packages}/idb/src/structure/$IDB.ts +1 -1
  199. package/{ext → packages}/idb/src/structure/$IDBCursor.ts +1 -1
  200. package/{ext → packages}/idb/src/structure/$IDBIndex.ts +1 -1
  201. package/{ext → packages}/idb/src/structure/$IDBStore.ts +1 -1
  202. package/{ext → packages}/idb/src/structure/$IDBStoreBase.ts +1 -1
  203. package/{ext → packages}/idb/src/structure/$IDBTransaction.ts +1 -1
  204. package/{ext → packages}/idb/src/structure/builder/$IDBBuilder.ts +9 -10
  205. package/{ext → packages}/idb/src/structure/builder/$IDBStoreBuilder.ts +1 -1
  206. package/packages/markdown/README.md +53 -0
  207. package/packages/markdown/package.json +19 -0
  208. package/packages/markdown/src/index.ts +3 -0
  209. package/packages/markdown/src/lib/type.ts +26 -0
  210. package/packages/markdown/src/lib/util.ts +21 -0
  211. package/packages/markdown/src/structure/Markdown.ts +54 -0
  212. package/packages/markdown/src/structure/MarkdownLexer.ts +111 -0
  213. package/packages/markdown/src/structure/MarkdownParser.ts +34 -0
  214. package/packages/markdown/src/syntax/alert.ts +46 -0
  215. package/packages/markdown/src/syntax/blockquote.ts +35 -0
  216. package/packages/markdown/src/syntax/bold.ts +11 -0
  217. package/packages/markdown/src/syntax/code.ts +11 -0
  218. package/packages/markdown/src/syntax/codeblock.ts +44 -0
  219. package/packages/markdown/src/syntax/heading.ts +14 -0
  220. package/packages/markdown/src/syntax/horizontalRule.ts +11 -0
  221. package/packages/markdown/src/syntax/image.ts +23 -0
  222. package/packages/markdown/src/syntax/italic.ts +11 -0
  223. package/packages/markdown/src/syntax/link.ts +46 -0
  224. package/packages/markdown/src/syntax/list.ts +121 -0
  225. package/packages/markdown/src/syntax/table.ts +67 -0
  226. package/packages/markdown/src/syntax/text.ts +19 -0
  227. package/packages/router/README.md +175 -0
  228. package/packages/router/package.json +19 -0
  229. package/packages/router/src/index.ts +68 -0
  230. package/packages/router/src/node/Page.ts +38 -0
  231. package/packages/router/src/node/Router.ts +212 -0
  232. package/{ext/router → packages/router/src}/node/RouterAnchor.ts +13 -2
  233. package/packages/router/src/structure/PageBuilder.ts +24 -0
  234. package/packages/router/src/structure/Route.ts +105 -0
  235. package/packages/signal/README.md +93 -0
  236. package/packages/signal/package.json +18 -0
  237. package/packages/signal/src/index.ts +221 -0
  238. package/{src → packages/signal/src}/structure/Signal.ts +6 -10
  239. package/packages/ssr/package.json +19 -0
  240. package/packages/ssr/src/index.ts +38 -0
  241. package/packages/ui/lib/VirtualScroll.ts +25 -0
  242. package/packages/ui/node/Accordian.ts +97 -0
  243. package/packages/ui/node/Carousel.ts +20 -0
  244. package/packages/ui/node/Form.ts +54 -0
  245. package/packages/ui/node/Grid.ts +0 -0
  246. package/packages/ui/node/Modal.ts +45 -0
  247. package/packages/ui/node/Table.ts +43 -0
  248. package/packages/ui/node/Tabs.ts +129 -0
  249. package/packages/ui/node/Toast.ts +16 -0
  250. package/packages/ui/node/Waterfall.ts +94 -0
  251. package/packages/ui/package.json +21 -0
  252. package/packages/utils/package.json +17 -0
  253. package/{src → packages/utils/src}/global.ts +9 -15
  254. package/packages/utils/src/index.ts +90 -0
  255. package/tsconfig.json +1 -1
  256. package/ext/css/package.json +0 -9
  257. package/ext/css/src/structure/$CSSVariable.ts +0 -12
  258. package/ext/html/node/$Canvas.ts +0 -16
  259. package/ext/i18n/package.json +0 -10
  260. package/ext/i18n/src/index.ts +0 -54
  261. package/ext/i18n/src/node/I18nText.ts +0 -35
  262. package/ext/idb/package.json +0 -13
  263. package/ext/markdown/index.ts +0 -121
  264. package/ext/markdown/package.json +0 -8
  265. package/ext/router/README.md +0 -81
  266. package/ext/router/index.ts +0 -73
  267. package/ext/router/node/Page.ts +0 -27
  268. package/ext/router/node/Route.ts +0 -54
  269. package/ext/router/node/Router.ts +0 -149
  270. package/ext/ssr/env.ts +0 -61
  271. package/ext/ssr/index.ts +0 -49
  272. package/ext/ssr/package.json +0 -10
  273. package/src/core.ts +0 -114
  274. package/src/index.ts +0 -3
  275. package/src/lib/assign.ts +0 -38
  276. package/src/lib/assignHelper.ts +0 -18
  277. package/src/lib/chain.ts +0 -13
  278. package/src/lib/debounce.ts +0 -7
  279. package/src/lib/env.ts +0 -2
  280. package/src/lib/native.ts +0 -40
  281. package/src/lib/randomId.ts +0 -9
  282. package/src/lib/sleep.ts +0 -3
  283. package/src/lib/toArray.ts +0 -9
  284. package/src/lib/trycatch.ts +0 -17
  285. package/src/node.ts +0 -10
  286. /package/{ext → packages}/css/README.md +0 -0
  287. /package/{ext/css/src/lib → packages/css/src/ext}/colors.ts +0 -0
  288. /package/{ext → packages}/css/src/structure/$CSSDeclaration.ts +0 -0
  289. /package/{ext → packages}/idb/README.md +0 -0
  290. /package/{ext → packages}/idb/src/core.ts +0 -0
@@ -1,121 +0,0 @@
1
- import { _Array_from, forEach } from "amateras/lib/native";
2
-
3
- const blockProcesses = new Set<MarkdownBlockProcessOptions>();
4
- const inlineProcesses = new Set<MarkdownProcessFunction>();
5
-
6
- export class Markdown {
7
- blockProcessSet = new Set(blockProcesses);
8
- inlineProcessSet = new Set(inlineProcesses);
9
- constructor() {}
10
-
11
- blockProcess(options: MarkdownBlockProcessOptions) {
12
- this.blockProcessSet.add(options);
13
- return this;
14
- }
15
-
16
- inlineProcess(handle: MarkdownProcessFunction) {
17
- this.inlineProcessSet.add(handle);
18
- return this;
19
- }
20
-
21
- toHTML(text: string) {
22
- const blocks = _Array_from(text.matchAll(/(?:.+?\n?)+/gm));
23
- return blocks.map(block => {
24
- let matched, blockText = block[0]
25
- for (const blockProcess of blockProcesses) {
26
- matched = blockText.match(blockProcess.regexp);
27
- if (!matched) continue;
28
- blockText = blockProcess.handle(blockText);
29
- const removeHTML = blockText.replaceAll(/<.+>[^<]+?<\/.+>/gm, '');
30
- if (!removeHTML) break;
31
- }
32
- if (!matched) blockText = paragraph(blockText);
33
- inlineProcesses.forEach(fn => blockText = fn(blockText))
34
- return blockText;
35
- }).join('')
36
- }
37
-
38
- toDOM(text: string) {
39
- return $('article').innerHTML(this.toHTML(text))
40
- }
41
- }
42
-
43
- export type MarkdownProcessFunction = (text: string) => string;
44
- export interface MarkdownBlockProcessOptions {
45
- regexp: RegExp,
46
- handle: (text: string) => string;
47
- }
48
-
49
- const blockProcess = (options: MarkdownBlockProcessOptions) => blockProcesses.add(options);
50
- const inlineProcess = (handle: MarkdownProcessFunction) => inlineProcesses.add(handle);
51
- const replaceAll = (str: string, searchValue: string | RegExp, replacer: ((substring: string, ...args: any[]) => string) | string): string => str.replaceAll(searchValue, replacer as any);
52
- const trim = (str: string) => str.trim();
53
- const paragraph = (str: string) => replaceAll(str, /(?:.+?\n?)+/gm, $0 => `<p>${trim($0)}</p>`);
54
- // Headings
55
- blockProcess({
56
- regexp: /^(#+) (.+)/gm,
57
- handle: text => replaceAll(text, /^(#+) (.+)/gm, (_, $1: string, $2) => `<h${$1.length}>${$2}</h${$1.length}>`)
58
- });
59
- blockProcess({
60
- regexp: /^(.+)\n==+$/gm,
61
- handle: text => replaceAll(text, /^(.+)\n==+$/gm, (_, $1) => `<h1>${$1}</h1>`)
62
- });
63
- blockProcess({
64
- regexp: /^(.+)\n--+$/gm,
65
- handle: text => replaceAll(text, /^(.+)\n--+$/gm, (_, $1) => `<h2>${$1}</h2>`)
66
- });
67
- // Blockquote
68
- blockProcess({
69
- regexp: /(?:^> ?.*(?:\n|$))+/gm,
70
- handle: text => {
71
- const fn = (str: string) => {
72
- const blocks = _Array_from(str.matchAll(/(?:^> ?.*(?:\n|$))+/gm));
73
- forEach(blocks, block => {
74
- const blocked = fn(replaceAll(block[0], /^> ?/gm, ''));
75
- str = str.replace(block[0], `<blockquote>\n${paragraph(blocked)}\n</blockquote>`);
76
- })
77
- return str;
78
- }
79
- return fn(text);
80
- }
81
- });
82
- // List
83
- blockProcess({
84
- regexp: /(?:^(?:\t|(?: )+)?(?:-|[0-9]+\.) (?:.+\n?))+/gm,
85
- handle: text => {
86
- const fn = (str: string) => {
87
- const blocks = _Array_from(str.matchAll(/(?:^(?:\t|(?: )+)?(?:-|[0-9]+\.) (?:.+\n?))+/gm));
88
- forEach(blocks, block => {
89
- let haveList = false // check this loop have list
90
- const type = block[0].match(/^(-|[0-9]+\.) /)?.[1] === '-' ? 'ul' : 'ol';
91
- const listed = replaceAll(block[0], /^(?:-|[0-9]+\.) (.+)/gm, (_, $1: string) => (haveList = true, `<li>\n${trim($1)}\n</li>`));
92
- const clearTabbed = replaceAll(listed, /^(?:\t|(?: ))/gm, '');
93
- const convertedList = fn(clearTabbed);
94
- str = str.replace(block[0], haveList ? `<${type}>\n${trim(convertedList)}\n</${type}>` : convertedList);
95
- })
96
- return str;
97
- }
98
- return fn(text);
99
- }
100
- })
101
- // Codeblock
102
- blockProcess({
103
- regexp: /^```([^`\n]+)\n([^`]+)?```/gm,
104
- handle: text => replaceAll(text, /^```([^`\n]+)\n([^`]+)?```/gm, (_, $1, $2: string) => `<pre><code>\n${trim($2)}\n</code></pre>`)
105
- })
106
- // Horizontal Rule
107
- blockProcess({
108
- regexp: /^(?:---|\*\*\*|___)(\s+)?$/gm,
109
- handle: text => replaceAll(text, /^(?:---|\*\*\*|___)(\s+)?$/gm, _ => `<hr>`)
110
- })
111
- // Bold
112
- inlineProcess(text => replaceAll(text, /\*\*([^*]+?)\*\*/g, (_, $1) => `<b>${$1}</b>`));
113
- // Italic
114
- inlineProcess(text => replaceAll(text, /\*([^*]+?)\*/g, (_, $1) => `<i>${$1}</i>`));
115
- // Image
116
- inlineProcess(text => replaceAll(text, /!\[(.+?)\]\((.+?)(?: "(.+?)?")?\)/g, (_, alt, src, title) => `<img src="${src}" alt="${alt}"${title ? ` title="${title}"` : ''}>`));
117
- // Link
118
- inlineProcess(text => replaceAll(text, /\[(.+?)\]\((?:(\w\w+?:[^\s]+?)(?: "(.+?)?")?)\)/g, (_, content, href, title) => `<a href="${href}"${title ? ` title="${title}"` : ''}>${content}</a>`));
119
- inlineProcess(text => replaceAll(text, /\[(.+?)\]\((?:(\w+?@(?:\w|\.\w)+?)(?: "(.+)?")?)\)/g, (_, content, mail, title) => `<a href="mailto:${mail}"${title ? ` title="${title}"` : ''}>${content}</a>`));
120
- inlineProcess(text => replaceAll(text, /<(\w\w+?:[^\s]+?)>/g, (_, href) => `<a href="${href}">${href}</a>`));
121
- inlineProcess(text => replaceAll(text, /<(\w+?@(?:\w|\.\w)+?)>/g, (_, mail) => `<a href="mailto:${mail}">${mail}</a>`));
@@ -1,8 +0,0 @@
1
- {
2
- "name": "@amateras/markdown",
3
- "peerDependencies": {
4
- "amateras": "../../"
5
- },
6
- "imports": {
7
- }
8
- }
@@ -1,81 +0,0 @@
1
- # amateras/router
2
-
3
- ## Usage
4
- ```ts
5
- import 'amateras';
6
- import 'amateras/router';
7
- ```
8
-
9
- ## Create Route Map
10
- ```ts
11
- // create home page route
12
- const HomePage = $('route', '/', page => page
13
- .pageTitle('Home')
14
- .content([
15
- $('h1').content('Home')
16
- ])
17
- )
18
- // append router and mapping home page route into router
19
- $(document.body).content([
20
- $('router')
21
- .route('/', HomePage)
22
- .route('/hello', page => 'Hello!')
23
- .listen() // start to listen path change
24
- ])
25
- ```
26
-
27
- ## Router Anchor
28
- Use `RouterAnchor` to prevent load page when open link by default `HTMLAnchorElement` element.
29
- ```ts
30
- $('ra').content('Contact').href('/contact');
31
- ```
32
-
33
- ## Common Methods
34
- - `$.open(url)`: Open page without load page.
35
- - `$.replace(url)`: Replace history state with url and open page.
36
- - `$.forward()`: Forward page.
37
- - `$.back()`: Back page.
38
-
39
- ## Path Parameter and Query
40
- ```ts
41
- $('router')
42
- .route('/user/@:username', page => {
43
- console.log(page.params)
44
- })
45
- .route('/posts?search'), page => {
46
- console.log(page.query)
47
- }
48
- .listen()
49
- // simulate page open
50
- .resolve('/user/@amateras') // { username: 'amateras' }
51
- .resolve('/posts"') // { }
52
- .resolve('/posts?search=tsukimi&user') // { search: 'tsukimi', user: '' }
53
- ```
54
-
55
- ## Nesting Route
56
- ```ts
57
- const ContactPage = $('route', '/contact', page => page
58
- .pageTitle('Home')
59
- .content([
60
- $('h1').content('Contact'),
61
- // append router with page, nested routes will show in this router
62
- $('router', page)
63
- ])
64
- )
65
-
66
- const ContactEmailPage = $('route', '/contact/email', () => 'amateras@example.com')
67
-
68
- $('router')
69
- .route('/', HomePage)
70
- .route('/contact', ContactPage, route => route
71
- .route('/', () => 'My name is Amateras.')
72
- .route('/phone', () => '0123456789')
73
- .route('/email', ContactEmailPage)
74
- )
75
- ```
76
-
77
- ## Async Route
78
- ```ts
79
- $('router')
80
- .route('/about', () => import('./pages/about.ts'))
81
- ```
@@ -1,73 +0,0 @@
1
- import type { AnchorTarget } from "#html/$Anchor";
2
- import { _bind, _Object_assign, forEach } from "#lib/native";
3
- import type { $NodeContentResolver } from "#node/$Node";
4
- import type { Page } from "./node/Page";
5
- import { Route } from "./node/Route";
6
- import { Router } from "./node/Router";
7
- import { RouterAnchor } from "./node/RouterAnchor";
8
- export * from "./node/Route";
9
- export * from "./node/Router";
10
- export * from "./node/Page";
11
- export * from "./node/RouterAnchor";
12
-
13
- declare module 'amateras/core' {
14
- export function $<P extends string>(nodeName: 'route', path: P, builder: RouteBuilder<Route<P>, RouteDataResolver<P>>): Route<P>;
15
- export function $(nodeName: 'router', page?: Page<any>): Router;
16
- export function $(nodeName: 'ra'): RouterAnchor;
17
- export namespace $ {
18
- export function open(url: string | URL | Nullish, target?: AnchorTarget): typeof Router;
19
- export function replace(url: string | URL | Nullish): typeof Router;
20
- export function back(): typeof Router;
21
- export function forward(): typeof Router;
22
- }
23
- }
24
-
25
- declare global {
26
- interface GlobalEventHandlersEventMap {
27
- 'routeopen': Event;
28
- }
29
- }
30
-
31
- // assign methods
32
- _Object_assign($, {
33
- open: _bind(Router.open, Router),
34
- replace: _bind(Router.replace, Router),
35
- back: _bind(Router.back, Router),
36
- forward: _bind(Router.forward, Router)
37
- });
38
- // define styles
39
- forEach([
40
- `router{display:block}`,
41
- `page{display:block}`
42
- ], $.style);
43
- // assign nodes
44
- $.assign([
45
- ['router', Router],
46
- ['route', Route],
47
- ['ra', RouterAnchor]
48
- ])
49
-
50
- export type RouteData = { params: any, query: any }
51
- export type RouteDataResolver<P extends string> = { params: Prettify<PathParams<P>>, query: Prettify<PathQuery<P>> }
52
- export type AsyncRoute<P extends string> = () => Promise<{default: Route<P>}>
53
- export type RouteBuilder<R extends Route<any>, D extends RouteData> = (page: Page<R, D>) => OrPromise<$NodeContentResolver<Page<R, D>>>;
54
-
55
- type PathParams<Path> = Path extends `${infer Segment}/${infer Rest}`
56
- ? Segment extends `${string}:${infer Param}`
57
- ? Record<Param, string> & PathParams<Rest>
58
- : PathParams<Rest>
59
- : Path extends `${string}:${infer Param}?${infer Query}`
60
- ? Record<Param, string>
61
- : Path extends `${string}:${infer Param}`
62
- ? Record<Param, string>
63
- : {}
64
-
65
- type PathQuery<Path> = Path extends `${string}?${infer Segment}`
66
- ? PathQuery_SetRecord<Segment>
67
- : Path extends `&${infer Segment}`
68
- ? PathQuery_SetRecord<Segment>
69
- : {}
70
-
71
- type PathQuery_SetRecord<Segment extends string> = Segment extends `${infer Param}&${infer Rest}`
72
- ? Record<Param, string> & PathQuery<`&${Rest}`>
73
- : Record<Segment, string>
@@ -1,27 +0,0 @@
1
- import { chain } from "#lib/chain";
2
- import { isUndefined } from "#lib/native";
3
- import { $HTMLElement } from "#node/$HTMLElement";
4
- import type { RouteData } from "..";
5
- import type { Route } from "./Route";
6
-
7
- export class Page<R extends Route<any> = any, Data extends RouteData = any> extends $HTMLElement {
8
- route: R;
9
- page: this;
10
- params: Data['params'];
11
- query: Data['query'];
12
- #pageTitle: null | string = null;
13
- initial = false;
14
- constructor(route: R, data?: {params: any, query: any}) {
15
- super('page');
16
- this.route = route;
17
- this.page = this;
18
- this.params = data?.params ?? {};
19
- this.query = data?.query ?? {};
20
- }
21
-
22
- pageTitle(): string | null;
23
- pageTitle(title: string | null): this;
24
- pageTitle(title?: string | null) {
25
- return chain(this, arguments, () => this.#pageTitle, title, title => this.#pageTitle = title)
26
- }
27
- }
@@ -1,54 +0,0 @@
1
- import { _instanceof, _Object_fromEntries, _Array_from, _Promise } from "#lib/native";
2
- import { $Element } from "#node/$Element";
3
- import type { AsyncRoute, RouteBuilder, RouteDataResolver } from "..";
4
- import { Page } from "./Page";
5
-
6
- export abstract class BaseRouteNode<Path extends string = string> extends $Element {
7
- readonly path: Path;
8
- routes = new Map<string, Route<any>>()
9
- parent: BaseRouteNode<any> | null = null;
10
- builder: RouteBuilder<Route<Path>, RouteDataResolver<Path>> | AsyncRoute<Path>
11
- constructor(path: Path, builder: RouteBuilder<Route<Path>, RouteDataResolver<Path>> | AsyncRoute<Path>, nodeName: string) {
12
- super(nodeName);
13
- this.path = path;
14
- this.builder = builder;
15
- }
16
-
17
- route<P extends string, J extends `${Path}${P}`>(
18
- path: P,
19
- resolver: RouteBuilder<Route<J>, RouteDataResolver<J>> | Route<J> | AsyncRoute<J>,
20
- fn?: (route: Route<J>) => Route<J>
21
- ) {
22
- const fullPath = `${this.path}${path}`;
23
- if (_instanceof(resolver, Route) && fullPath !== resolver.path) throw `Pathname not matched: ${path}`
24
- const route = resolver instanceof Route ? resolver : new Route(fullPath as J, resolver);
25
- route.parent = this;
26
- fn && fn(route);
27
- this.routes.set(path, route);
28
- return this;
29
- }
30
- }
31
-
32
- export class Route<Path extends string = string> extends BaseRouteNode<Path> {
33
- constructor(path: Path, builder: RouteBuilder<Route<Path>, RouteDataResolver<Path>> | AsyncRoute<Path>) {
34
- super(path, builder, 'route');
35
- }
36
-
37
- async build(data: {params: any, query: any} = {params: {}, query: {}}, page?: Page) {
38
- page = page ?? new Page(this, data);
39
- page.params = data.params;
40
- page.initial = true;
41
- let resolver: any = this.builder(page);
42
- if (_instanceof(resolver, _Promise)) {
43
- const result = await resolver as any;
44
- // Module import
45
- if (result[Symbol.toStringTag] === 'Module') {
46
- page.route = this;
47
- resolver = result.default.builder(page);
48
- }
49
- else resolver = result;
50
- }
51
- if (!_instanceof(resolver, Page)) page.content(resolver);
52
- return page;
53
- }
54
- }
@@ -1,149 +0,0 @@
1
- import type { AnchorTarget } from "#html/$Anchor";
2
- import { _document } from "#lib/env";
3
- import { _Array_from, _instanceof, _JSON_parse, _JSON_stringify, _Object_entries, _Object_fromEntries, forEach, startsWith } from "#lib/native";
4
- import { Page } from "./Page";
5
- import { BaseRouteNode, Route } from "./Route";
6
-
7
- // history index
8
- let index = 0;
9
- const _addEventListener = addEventListener;
10
- const _location = location;
11
- const {origin} = _location;
12
- const _history = history;
13
- const _sessionStorage = sessionStorage;
14
- const documentElement = _document.documentElement;
15
- const [PUSH, REPLACE] = [1, 2] as const;
16
- const [FORWARD, BACK] = ['forward', 'back'] as const;
17
- const scrollStorageKey = '__scroll__';
18
- /** convert path string to URL object */
19
- const toURL = (path: string | URL) =>
20
- _instanceof(path, URL) ? path : startsWith(path, 'http') ? new URL(path) : new URL(startsWith(path, origin) ? path : origin + path);
21
-
22
- type ScrollData = {[key: number]: {x: number, y: number}};
23
- const scrollRecord = (e?: Event) => {
24
- const data = _JSON_parse(_sessionStorage.getItem(scrollStorageKey) ?? '{}') as ScrollData;
25
- data[index] = { x: documentElement.scrollLeft, y: documentElement.scrollTop };
26
- // e is Event when called from scroll or beforeload
27
- if (!e) forEach(_Object_entries(data), ([i]) => +i > index && delete data[+i])
28
- _sessionStorage.setItem(scrollStorageKey, _JSON_stringify(data));
29
- }
30
- /** handle history state with push and replace state. */
31
- const historyHandler = async (path: string | URL | Nullish, mode: 1 | 2, target?: AnchorTarget) => {
32
- if (!path) return;
33
- const url = toURL(path);
34
- if (url.href === _location.href) return;
35
- if (target && target !== '_self') return open(url, target);
36
- if (url.origin !== origin) return open(url, target);
37
- scrollRecord();
38
- if (mode === PUSH) index += 1;
39
- Router.direction = FORWARD;
40
- _history[mode === PUSH ? 'pushState' : 'replaceState']({index}, '' , url);
41
- for (let router of Router.routers) router.routes.size && await router.resolve(path);
42
- }
43
- // disable browser scroll restoration
44
- _history.scrollRestoration = 'manual';
45
-
46
- export class Router extends BaseRouteNode<''> {
47
- static pageRouters = new Map<Page, Router>();
48
- static routers = new Set<Router>();
49
- pageMap = new Map<string, Page>();
50
- static direction: 'back' | 'forward' = FORWARD;
51
- constructor(page?: Page) {
52
- super('', () => [], 'router')
53
- Router.routers.add(this);
54
- if (page) Router.pageRouters.set(page, this);
55
- }
56
-
57
- static open(path: string | URL | Nullish, target?: AnchorTarget) {
58
- historyHandler(path, PUSH, target);
59
- return this;
60
- }
61
-
62
- static back() {
63
- _history.back();
64
- return this;
65
- }
66
-
67
- static forward() {
68
- _history.forward();
69
- return this;
70
- }
71
-
72
- static replace(path: string | URL | Nullish) {
73
- historyHandler(path, REPLACE);
74
- return this;
75
- }
76
-
77
- async resolve(path: string | URL) {
78
- const {pathname, searchParams, hash, href} = toURL(path);
79
- const routeData = { params: {} as {[key: string]: string}, query: _Object_fromEntries(searchParams) }
80
- const split = (p: string) => p.replaceAll(/\/+/g, '/').split('/').map(path => `/${path}`);
81
-
82
- function determineRoute(parentRoute: BaseRouteNode<any>, path: string, hash: string | undefined): [route: Route | null, pathId: string][] {
83
- const targetPathSplit = split(path);
84
- hash && targetPathSplit.push(hash);
85
- if (!parentRoute.routes.size) return [];
86
- routeLoop: for (const route of _Array_from(parentRoute.routes.values()).sort((a, b) => b.path.length - a.path.length)) {
87
- const routePathSplit = split(route.path);
88
- let pathId = '';
89
- splitLoop: for (let i = 0; i < routePathSplit.length; i++) {
90
- const pass = () => pathId += targetSnippet;
91
- const [routeSnippet, targetSnippet] = [routePathSplit[i], targetPathSplit[i]];
92
- if (!routeSnippet || !targetSnippet) continue routeLoop;
93
- // process params in path
94
- if (routeSnippet.includes(':')) {
95
- if (targetSnippet === '/') continue routeLoop;
96
- const [prefix, paramName] = routeSnippet.split(':') as [string, string];
97
- if (!startsWith(targetSnippet, prefix)) continue routeLoop;
98
- routeData.params[paramName] = targetSnippet.replace(`${prefix}`, '');
99
- pass();
100
- continue splitLoop;
101
- }
102
- if (routeSnippet === '/' && route.routes.size) continue splitLoop;
103
- if (routeSnippet !== targetSnippet) continue routeLoop;
104
- pass()
105
- }
106
- return [[route, pathId], ...determineRoute(route, path, hash)];
107
- }
108
- return [[null, parentRoute.path + '$$NOT_FOUND$$']];
109
- }
110
- // analytics
111
- const targetRoutes = determineRoute(this, pathname + '/', hash);
112
- // build pages
113
- let prevPage: null | Page = null, prevRoute: BaseRouteNode<any> = this;
114
- const appendPage = (prevRouter: Router | undefined, page: Page) => page.parentNode !== prevRouter?.node && prevRouter?.content(page);
115
-
116
- for (const [route, pathId] of targetRoutes) {
117
- const page = this.pageMap.get(pathId) ?? new Page(route ?? prevRoute.routes.get('404') ?? new Route('404', () => null), routeData);
118
- if (!page.initial) await route?.build(routeData, page);
119
- _document && (_document.title = page.pageTitle() ?? _document.title);
120
- this.pageMap.set(pathId, page);
121
- if (href === _location.href) appendPage(prevPage ? Router.pageRouters.get(prevPage) : this, page);
122
- prevPage = page;
123
- if (route) prevRoute = route;
124
- }
125
- let { x, y } = Router.scroll ?? {x: 0, y: 0};
126
- scrollTo(x, y);
127
- this.dispatchEvent(new Event('routeopen', {bubbles: true}));
128
- return this;
129
- }
130
-
131
- listen() {
132
- const resolve = () => {
133
- const stateIndex = _history.state?.index ?? 0;
134
- if (index > stateIndex) Router.direction = BACK;
135
- if (index < stateIndex) Router.direction = FORWARD;
136
- index = stateIndex;
137
- this.resolve(_location.href);
138
- }
139
- _addEventListener('popstate', resolve);
140
- _addEventListener('beforeunload', scrollRecord);
141
- _addEventListener('scroll', scrollRecord, false);
142
- resolve();
143
- return this;
144
- }
145
-
146
- static get scroll(): ScrollData[number] {
147
- return _JSON_parse(_sessionStorage.getItem(scrollStorageKey) ?? '{}')[index] ?? {x: 0, y: 0}
148
- }
149
- }
package/ext/ssr/env.ts DELETED
@@ -1,61 +0,0 @@
1
- import { NODE } from "esm-env";
2
- import { _Array_from, _Object_assign, _Object_entries, isNull } from "../../src/lib/native";
3
- import type { $Node } from "../../src/node/$Node";
4
-
5
- if (NODE) {
6
- //@ts-expect-error
7
- global.window = undefined;
8
- //@ts-expect-error
9
- global.document = undefined;
10
- //@ts-expect-error
11
- global.Node = class Node {
12
- nodeName: string;
13
- attributes = {};
14
- childNodes = new Set<Node>();
15
- parent?: Node;
16
- $!: $Node;
17
- constructor(nodeName: string) {
18
- this.nodeName = nodeName.toUpperCase();
19
- }
20
- get textContent() { return _Array_from(this.childNodes.values()).map(node => node.textContent).join() }
21
- set textContent(content: string | null) {
22
- this.childNodes.clear();
23
- content && this.childNodes.add(new Text(content) as unknown as Node);
24
- }
25
- appendChild(node: Node) {
26
- if (this.childNodes.has(node)) this.childNodes.delete(node);
27
- this.childNodes.add(node);
28
- node.parent = this;
29
- }
30
- addEventListener(type: string, cb: () => void) { }
31
- setAttribute(key: string, value: string) { _Object_assign(this.attributes, {[key]: value}) }
32
- remove() {
33
- this.parent?.removeChild(this);
34
- }
35
- removeChild(node: Node) {
36
- this.childNodes.delete(node);
37
- }
38
-
39
- get outerHTML() {
40
- const attr = _Object_entries(this.attributes).map(([key, value]) => `${key}="${value}"`).join(' ');
41
- const tagName = this.nodeName.toLowerCase();
42
- const IS_VOID_ELEMENT = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'].includes(tagName);
43
- return `<${tagName}${attr ? ` ${attr}` : ''}>${_Array_from(this.childNodes).map(node => `${node.$}`).join('')}${IS_VOID_ELEMENT && !this.childNodes.size ? '' : `</${tagName}>`}`;
44
- }
45
- }
46
- //@ts-expect-error
47
- global.Element = class Element {}
48
- //@ts-expect-error
49
- global.HTMLElement = class HTMLElement {}
50
- //@ts-expect-error
51
- global.Text = class Text {
52
- textContent: string;
53
- $: this;
54
- constructor(textContent: string) {
55
- this.textContent = textContent;
56
- this.$ = this;
57
- }
58
-
59
- toString() { return this.textContent }
60
- }
61
- }
package/ext/ssr/index.ts DELETED
@@ -1,49 +0,0 @@
1
- import './env';
2
- import 'amateras';
3
- import { _Array_from, _instanceof, _Object_assign, _Object_defineProperty, forEach } from "amateras/lib/native";
4
- import { $Element } from 'amateras/node/$Element';
5
- import { BROWSER, NODE } from 'esm-env';
6
- import { $Node, $Text } from 'amateras/node/$Node';
7
- import { _document } from '../../src/lib/env';
8
-
9
- declare module 'amateras/core' {
10
- export namespace $ {
11
- export function mount(id: string, $node: $Element): void;
12
- export function serverSide(cb: () => any): void;
13
- }
14
- }
15
-
16
- export function onserver<T>(cb: () => T): T | '' {
17
- if (NODE) return cb();
18
- return '';
19
- }
20
-
21
- export function onclient<T>(cb: () => T): T | undefined {
22
- if (BROWSER) return cb();
23
- return;
24
- }
25
-
26
- _Object_assign($, {
27
- mount(id: string, $node: $Element) {
28
- if (!BROWSER) return;
29
- const node = _document.querySelector(`#${id}`);
30
- if (!node) throw 'Target node of mounting not found';
31
- getData(node, $node);
32
- node.replaceWith($node.node);
33
-
34
- function getData(node: Node, $node: $Node) {
35
- if (node.nodeName === 'SIGNAL' && _instanceof(node, Element) && _instanceof($node, $Text)) {
36
- const type = $(node).attr()['type'];
37
- return forEach($node.signals, signal => signal.value(type === 'number' ? Number(node.textContent) : type === 'boolean' ? node.textContent == 'true' ? true : false : node.textContent));
38
- }
39
- if (_instanceof(node, Text)) return $node.textContent(node.textContent);
40
- if (_instanceof(node, Element) && _instanceof($node, $Element)) $node.attr($(node).attr());
41
- const arr = _Array_from($node.childNodes);
42
- forEach(node.childNodes, (_node, i) => {
43
- const targetChildNode = arr.at(i);
44
- if (!targetChildNode) throw 'Target DOM tree not matched';
45
- getData(_node, targetChildNode.$)
46
- })
47
- }
48
- }
49
- })
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@amateras/ssr",
3
- "peerDependencies": {
4
- "amateras": "../../",
5
- "esm-env": "^1.2.2"
6
- },
7
- "imports": {
8
- "#structure/*": "./src/structure/*.ts"
9
- }
10
- }