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.
- package/index.ts +1 -0
- package/package.json +32 -30
- package/packages/core/package.json +32 -0
- package/packages/core/src/env.browser.ts +21 -0
- package/packages/core/src/env.node.ts +21 -0
- package/packages/core/src/global.ts +18 -0
- package/{src/core.ts → packages/core/src/index.ts} +42 -30
- package/{src → packages/core/src}/lib/assignProperties.ts +1 -1
- package/packages/core/src/lib/chain.ts +17 -0
- package/packages/core/src/lib/dom.ts +20 -0
- package/packages/core/src/main.ts +4 -0
- package/{src → packages/core/src}/node/$Element.ts +22 -10
- package/{src → packages/core/src}/node/$EventTarget.ts +13 -10
- package/{src → packages/core/src}/node/$HTMLElement.ts +1 -1
- package/{src → packages/core/src}/node/$Node.ts +7 -11
- package/{src → packages/core/src}/node/$Virtual.ts +5 -5
- package/packages/css/package.json +17 -0
- package/{ext/css/src/lib → packages/css/src/ext}/colors/amber.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/blackwhite.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/blue.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/cyan.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/emerald.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/fuchsia.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/gray.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/green.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/indigo.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/lime.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/neutral.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/orange.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/pink.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/purple.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/red.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/rose.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/sky.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/slate.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/stone.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/teal.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/violet.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/yellow.ts +2 -2
- package/{ext/css/src/lib → packages/css/src/ext}/colors/zinc.ts +2 -2
- package/packages/css/src/ext/container.ts +32 -0
- package/packages/css/src/ext/keyframes.ts +54 -0
- package/packages/css/src/ext/media.ts +32 -0
- package/packages/css/src/ext/property.ts +48 -0
- package/packages/css/src/ext/variable.ts +51 -0
- package/{ext → packages}/css/src/index.ts +107 -183
- package/{ext → packages}/css/src/lib/colorAssign.ts +1 -1
- package/packages/css/src/lib/utils.ts +11 -0
- package/{ext → packages}/css/src/structure/$CSSContainerRule.ts +1 -1
- package/{ext → packages}/css/src/structure/$CSSKeyframesRule.ts +0 -1
- package/{ext → packages}/css/src/structure/$CSSMediaRule.ts +1 -1
- package/packages/css/src/structure/$CSSProperty.ts +19 -0
- package/{ext → packages}/css/src/structure/$CSSRule.ts +1 -1
- package/{ext → packages}/css/src/structure/$CSSStyleRule.ts +1 -1
- package/packages/css/src/structure/$CSSVariable.ts +30 -0
- package/packages/dom/package.json +20 -0
- package/packages/dom/src/lib/HTMLElementMap.ts +213 -0
- package/packages/dom/src/lib/assignAttributes.ts +16 -0
- package/packages/dom/src/structure/CSS.ts +7 -0
- package/packages/dom/src/structure/CSSStyleSheet.ts +10 -0
- package/packages/dom/src/structure/DOMTokenList.ts +19 -0
- package/packages/dom/src/structure/Document.ts +36 -0
- package/packages/dom/src/structure/Element.ts +106 -0
- package/packages/dom/src/structure/HTMLElement.ts +34 -0
- package/packages/dom/src/structure/History.ts +11 -0
- package/packages/dom/src/structure/Location.ts +9 -0
- package/packages/dom/src/structure/Node.ts +51 -0
- package/packages/dom/src/structure/NodeList.ts +10 -0
- package/packages/dom/src/structure/Storage.ts +8 -0
- package/packages/dom/src/structure/Text.ts +20 -0
- package/packages/dom/src/structure/Window.ts +14 -0
- package/packages/dom/src/structure/html/HTMLAbbrElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLAddressElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLAnchorElement.ts +25 -0
- package/packages/dom/src/structure/html/HTMLAreaElement.ts +26 -0
- package/packages/dom/src/structure/html/HTMLArticleElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLAsideElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLAudioElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLBDIElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLBDOElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLBElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLBRElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLBaseElement.ts +18 -0
- package/packages/dom/src/structure/html/HTMLBodyElement.ts +22 -0
- package/packages/dom/src/structure/html/HTMLButtonElement.ts +26 -0
- package/packages/dom/src/structure/html/HTMLCanvasElement.ts +18 -0
- package/packages/dom/src/structure/html/HTMLCiteElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLCodeElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLDDElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLDFNElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLDListElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLDTElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLDataElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLDataListElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLDetailsElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLDialogElement.ts +18 -0
- package/packages/dom/src/structure/html/HTMLDivElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLEMElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLEmbedElement.ts +20 -0
- package/packages/dom/src/structure/html/HTMLFieldSetElement.ts +19 -0
- package/packages/dom/src/structure/html/HTMLFigCaptionElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLFigureElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLFooterElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLFormElement.ts +24 -0
- package/packages/dom/src/structure/html/HTMLHGroupElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLHRElement.ts +21 -0
- package/packages/dom/src/structure/html/HTMLHeadElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLHeaderElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLHeadingElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLHtmlElement.ts +18 -0
- package/packages/dom/src/structure/html/HTMLIElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLIFrameElement.ts +31 -0
- package/packages/dom/src/structure/html/HTMLImageElement.ts +38 -0
- package/packages/dom/src/structure/html/HTMLInputElement.ts +55 -0
- package/packages/dom/src/structure/html/HTMLKBDElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLLIElement.ts +18 -0
- package/packages/dom/src/structure/html/HTMLLabelElement.ts +18 -0
- package/packages/dom/src/structure/html/HTMLLegendElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLLinkElement.ts +31 -0
- package/packages/dom/src/structure/html/HTMLMainElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLMapElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLMarkElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLMediaElement.ts +48 -0
- package/packages/dom/src/structure/html/HTMLMenuElement.ts +18 -0
- package/packages/dom/src/structure/html/HTMLMetaElement.ts +22 -0
- package/packages/dom/src/structure/html/HTMLMeterElement.ts +23 -0
- package/packages/dom/src/structure/html/HTMLModElement.ts +18 -0
- package/packages/dom/src/structure/html/HTMLNavElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLNoscriptElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLOListElement.ts +20 -0
- package/packages/dom/src/structure/html/HTMLObjectElement.ts +34 -0
- package/packages/dom/src/structure/html/HTMLOptGroupElement.ts +18 -0
- package/packages/dom/src/structure/html/HTMLOptionElement.ts +20 -0
- package/packages/dom/src/structure/html/HTMLOutputElement.ts +20 -0
- package/packages/dom/src/structure/html/HTMLParagraphElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLPictureElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLPreElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLProgressElement.ts +19 -0
- package/packages/dom/src/structure/html/HTMLQuoteElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLRPElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLRTElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLRubyElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLSElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLSampElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLScriptElement.ts +27 -0
- package/packages/dom/src/structure/html/HTMLSectionElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLSelectElement.ts +27 -0
- package/packages/dom/src/structure/html/HTMLSlotElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLSmallElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLSourceElement.ts +21 -0
- package/packages/dom/src/structure/html/HTMLSpanElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLStrongElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLStyleElement.ts +18 -0
- package/packages/dom/src/structure/html/HTMLSubElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLSummaryElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLSupElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLTableCaptionElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLTableCellElement.ts +31 -0
- package/packages/dom/src/structure/html/HTMLTableColElement.ts +23 -0
- package/packages/dom/src/structure/html/HTMLTableElement.ts +26 -0
- package/packages/dom/src/structure/html/HTMLTableRowElement.ts +23 -0
- package/packages/dom/src/structure/html/HTMLTableSectionElement.ts +20 -0
- package/packages/dom/src/structure/html/HTMLTemplateElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLTextAreaElement.ts +33 -0
- package/packages/dom/src/structure/html/HTMLTimeElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLTitleElement.ts +17 -0
- package/packages/dom/src/structure/html/HTMLTrackElement.ts +21 -0
- package/packages/dom/src/structure/html/HTMLUElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLUListElement.ts +18 -0
- package/packages/dom/src/structure/html/HTMLVarElement.ts +16 -0
- package/packages/dom/src/structure/html/HTMLVideoElement.ts +22 -0
- package/packages/dom/src/structure/html/HTMLWBRElement.ts +16 -0
- package/packages/html/package.json +18 -0
- package/{ext/html/html.ts → packages/html/src/index.ts} +1 -1
- package/{ext/html → packages/html/src}/node/$Anchor.ts +3 -3
- package/packages/html/src/node/$Canvas.ts +38 -0
- package/{ext/html → packages/html/src}/node/$Dialog.ts +3 -3
- package/{ext/html → packages/html/src}/node/$Form.ts +3 -3
- package/{ext/html → packages/html/src}/node/$Image.ts +3 -3
- package/{ext/html → packages/html/src}/node/$Input.ts +3 -3
- package/{ext/html → packages/html/src}/node/$Label.ts +3 -3
- package/{ext/html → packages/html/src}/node/$Media.ts +3 -3
- package/{ext/html → packages/html/src}/node/$OptGroup.ts +3 -3
- package/{ext/html → packages/html/src}/node/$Option.ts +3 -3
- package/{ext/html → packages/html/src}/node/$Select.ts +3 -3
- package/{ext/html → packages/html/src}/node/$TextArea.ts +3 -3
- package/packages/i18n/package.json +19 -0
- package/{ext → packages}/i18n/src/index.ts +6 -14
- package/{ext → packages}/i18n/src/structure/I18n.ts +2 -2
- package/{ext → packages}/i18n/src/structure/I18nDictionary.ts +1 -1
- package/{ext → packages}/i18n/src/structure/I18nTranslation.ts +10 -4
- package/packages/idb/package.json +19 -0
- package/{ext → packages}/idb/src/index.ts +2 -2
- package/{ext → packages}/idb/src/lib/$IDBRequest.ts +1 -1
- package/{ext → packages}/idb/src/structure/$IDB.ts +1 -1
- package/{ext → packages}/idb/src/structure/$IDBCursor.ts +1 -1
- package/{ext → packages}/idb/src/structure/$IDBIndex.ts +1 -1
- package/{ext → packages}/idb/src/structure/$IDBStore.ts +1 -1
- package/{ext → packages}/idb/src/structure/$IDBStoreBase.ts +1 -1
- package/{ext → packages}/idb/src/structure/$IDBTransaction.ts +1 -1
- package/{ext → packages}/idb/src/structure/builder/$IDBBuilder.ts +1 -2
- package/{ext → packages}/idb/src/structure/builder/$IDBStoreBuilder.ts +1 -1
- package/packages/markdown/package.json +19 -0
- package/{ext → packages}/markdown/src/lib/util.ts +1 -1
- package/{ext → packages}/markdown/src/structure/MarkdownLexer.ts +2 -2
- package/{ext → packages}/markdown/src/structure/MarkdownParser.ts +2 -1
- package/{ext → packages}/markdown/src/syntax/alert.ts +1 -1
- package/{ext → packages}/markdown/src/syntax/codeblock.ts +1 -1
- package/{ext → packages}/markdown/src/syntax/link.ts +2 -2
- package/{ext → packages}/markdown/src/syntax/list.ts +1 -1
- package/{ext → packages}/markdown/src/syntax/table.ts +1 -1
- package/packages/router/package.json +19 -0
- package/{ext → packages}/router/src/index.ts +4 -5
- package/{ext → packages}/router/src/node/Page.ts +8 -4
- package/{ext → packages}/router/src/node/Router.ts +79 -58
- package/{ext → packages}/router/src/node/RouterAnchor.ts +2 -2
- package/{ext → packages}/router/src/structure/PageBuilder.ts +3 -3
- package/{ext → packages}/router/src/structure/Route.ts +1 -1
- package/packages/signal/package.json +18 -0
- package/packages/signal/src/index.ts +221 -0
- package/{ext → packages}/signal/src/structure/Signal.ts +1 -1
- package/packages/ssr/package.json +19 -0
- package/packages/ssr/src/index.ts +38 -0
- package/{ext → packages}/ui/lib/VirtualScroll.ts +5 -5
- package/{ext → packages}/ui/node/Accordian.ts +4 -4
- package/packages/ui/node/Carousel.ts +20 -0
- package/{ext → packages}/ui/node/Form.ts +7 -6
- package/packages/ui/node/Modal.ts +45 -0
- package/{ext → packages}/ui/node/Table.ts +1 -1
- package/{ext → packages}/ui/node/Tabs.ts +28 -13
- package/{ext → packages}/ui/node/Toast.ts +2 -2
- package/packages/ui/node/Waterfall.ts +94 -0
- package/packages/ui/package.json +21 -0
- package/packages/utils/package.json +17 -0
- package/{src → packages/utils/src}/global.ts +5 -18
- package/{src/lib/native.ts → packages/utils/src/index.ts} +34 -1
- package/tsconfig.json +1 -1
- package/ext/css/package.json +0 -9
- package/ext/css/src/structure/$CSSVariable.ts +0 -12
- package/ext/html/node/$Canvas.ts +0 -16
- package/ext/i18n/package.json +0 -10
- package/ext/idb/package.json +0 -13
- package/ext/markdown/package.json +0 -15
- package/ext/router/package.json +0 -10
- package/ext/signal/package.json +0 -9
- package/ext/signal/src/index.ts +0 -128
- package/ext/ssr/env.ts +0 -61
- package/ext/ssr/index.ts +0 -49
- package/ext/ssr/package.json +0 -10
- package/ext/ui/node/Waterfall.ts +0 -72
- package/ext/ui/package.json +0 -11
- package/src/index.ts +0 -2
- package/src/lib/chain.ts +0 -13
- package/src/lib/debounce.ts +0 -7
- package/src/lib/env.ts +0 -2
- package/src/lib/randomId.ts +0 -9
- package/src/lib/sleep.ts +0 -3
- package/src/lib/toArray.ts +0 -9
- package/src/lib/trycatch.ts +0 -17
- package/src/lib/uppercase.ts +0 -3
- /package/{src/node.ts → packages/core/src/lib/assignNodeProperties.ts} +0 -0
- /package/{ext → packages}/css/README.md +0 -0
- /package/{ext/css/src/lib → packages/css/src/ext}/colors.ts +0 -0
- /package/{ext → packages}/css/src/structure/$CSSDeclaration.ts +0 -0
- /package/{ext → packages}/i18n/README.md +0 -0
- /package/{ext → packages}/idb/README.md +0 -0
- /package/{ext → packages}/idb/src/core.ts +0 -0
- /package/{ext → packages}/markdown/README.md +0 -0
- /package/{ext → packages}/markdown/src/index.ts +0 -0
- /package/{ext → packages}/markdown/src/lib/type.ts +0 -0
- /package/{ext → packages}/markdown/src/structure/Markdown.ts +0 -0
- /package/{ext → packages}/markdown/src/syntax/blockquote.ts +0 -0
- /package/{ext → packages}/markdown/src/syntax/bold.ts +0 -0
- /package/{ext → packages}/markdown/src/syntax/code.ts +0 -0
- /package/{ext → packages}/markdown/src/syntax/heading.ts +0 -0
- /package/{ext → packages}/markdown/src/syntax/horizontalRule.ts +0 -0
- /package/{ext → packages}/markdown/src/syntax/image.ts +0 -0
- /package/{ext → packages}/markdown/src/syntax/italic.ts +0 -0
- /package/{ext → packages}/markdown/src/syntax/text.ts +0 -0
- /package/{ext → packages}/router/README.md +0 -0
- /package/{ext → packages}/signal/README.md +0 -0
- /package/{ext → packages}/ui/node/Grid.ts +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { assignAttributes } from "#lib/assignAttributes";
|
|
2
|
+
import { HTMLMediaElement } from "#structure/html/HTMLMediaElement";
|
|
3
|
+
import { _Object_assign } from "@amateras/utils";
|
|
4
|
+
|
|
5
|
+
export class HTMLVideoElement extends HTMLMediaElement {
|
|
6
|
+
static defaultAttributes = {
|
|
7
|
+
...HTMLMediaElement.defaultAttributes,
|
|
8
|
+
disablePictureInPicture: false,
|
|
9
|
+
height: '',
|
|
10
|
+
poster: '',
|
|
11
|
+
videoHeight: 0,
|
|
12
|
+
videoWidth: 0,
|
|
13
|
+
width: ''
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
super('video')
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
assignAttributes(HTMLVideoElement, HTMLVideoElement.defaultAttributes)
|
|
22
|
+
_Object_assign(globalThis, { HTMLVideoElement })
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { assignAttributes } from "#lib/assignAttributes";
|
|
2
|
+
import { HTMLElement } from "#structure/HTMLElement";
|
|
3
|
+
import { _Object_assign } from "@amateras/utils";
|
|
4
|
+
|
|
5
|
+
export class HTMLWBRElement extends HTMLElement {
|
|
6
|
+
static defaultAttributes = {
|
|
7
|
+
...HTMLElement.defaultAttributes
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super('wbr')
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
assignAttributes(HTMLWBRElement, HTMLWBRElement.defaultAttributes)
|
|
16
|
+
_Object_assign(globalThis, { HTMLWBRElement })
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amateras/html",
|
|
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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assignProperties } from "
|
|
2
|
-
import { $HTMLElement } from "
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
3
|
|
|
4
4
|
export class $Anchor extends $HTMLElement<HTMLAnchorElement> {
|
|
5
5
|
constructor() {
|
|
@@ -42,7 +42,7 @@ export interface $Anchor extends $HTMLElement<HTMLAnchorElement> {
|
|
|
42
42
|
|
|
43
43
|
export type AnchorTarget = '_self' | '_blank' | '_parent' | '_top' | '_unfenced_top' | '' | '_replace';
|
|
44
44
|
|
|
45
|
-
declare module '
|
|
45
|
+
declare module '@amateras/core' {
|
|
46
46
|
export function $(nodeName: 'a'): $Anchor
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
|
+
|
|
4
|
+
export class $Canvas extends $HTMLElement<HTMLCanvasElement> {
|
|
5
|
+
constructor() {
|
|
6
|
+
super('canvas');
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface $Canvas extends $HTMLElement<HTMLCanvasElement> {
|
|
11
|
+
/** {@link HTMLCanvasElement.height} */
|
|
12
|
+
height(height: $Parameter<number>): this;
|
|
13
|
+
height(): number;
|
|
14
|
+
/** {@link HTMLCanvasElement.width} */
|
|
15
|
+
width(width: $Parameter<number>): this;
|
|
16
|
+
width(): number;
|
|
17
|
+
|
|
18
|
+
/** {@link HTMLCanvasElement.captureStream} */
|
|
19
|
+
captureStream(frameRequestRate?: number): MediaStream;
|
|
20
|
+
/** {@link HTMLCanvasElement.getContext} */
|
|
21
|
+
getContext(contextId: "2d", options?: CanvasRenderingContext2DSettings): CanvasRenderingContext2D | null;
|
|
22
|
+
getContext(contextId: "bitmaprenderer", options?: ImageBitmapRenderingContextSettings): ImageBitmapRenderingContext | null;
|
|
23
|
+
getContext(contextId: "webgl", options?: WebGLContextAttributes): WebGLRenderingContext | null;
|
|
24
|
+
getContext(contextId: "webgl2", options?: WebGLContextAttributes): WebGL2RenderingContext | null;
|
|
25
|
+
getContext(contextId: string, options?: any): RenderingContext | null;
|
|
26
|
+
/** {@link HTMLCanvasElement.toBlob} */
|
|
27
|
+
toBlob(callback: BlobCallback, type?: string, quality?: number): this;
|
|
28
|
+
/** {@link HTMLCanvasElement.toDataURL} */
|
|
29
|
+
toDataURL(type?: string, quality?: number): string;
|
|
30
|
+
/** {@link HTMLCanvasElement.transferControlToOffscreen} */
|
|
31
|
+
transferControlToOffscreen(): OffscreenCanvas;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
assignProperties(HTMLCanvasElement, $Canvas, 'canvas');
|
|
35
|
+
|
|
36
|
+
declare module "@amateras/core" {
|
|
37
|
+
export function $(nodeName: 'canvas'): $Canvas
|
|
38
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assignProperties } from "
|
|
2
|
-
import { $HTMLElement } from "
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
3
|
|
|
4
4
|
export class $Dialog extends $HTMLElement<HTMLDialogElement> {
|
|
5
5
|
constructor() {
|
|
@@ -11,6 +11,6 @@ export interface $Dialog extends $HTMLElement<HTMLDialogElement> {}
|
|
|
11
11
|
|
|
12
12
|
assignProperties(HTMLDialogElement, $Dialog, 'dialog');
|
|
13
13
|
|
|
14
|
-
declare module
|
|
14
|
+
declare module "@amateras/core" {
|
|
15
15
|
export function $(nodeName: 'dialog'): $Dialog
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assignProperties } from "
|
|
2
|
-
import { $HTMLElement } from "
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
3
|
|
|
4
4
|
export class $Form extends $HTMLElement<HTMLFormElement> {
|
|
5
5
|
constructor() {
|
|
@@ -11,6 +11,6 @@ export interface $Form extends $HTMLElement<HTMLFormElement> {}
|
|
|
11
11
|
|
|
12
12
|
assignProperties(HTMLFormElement, $Form, 'form');
|
|
13
13
|
|
|
14
|
-
declare module
|
|
14
|
+
declare module "@amateras/core" {
|
|
15
15
|
export function $(nodeName: 'form'): $Form
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assignProperties } from "
|
|
2
|
-
import { $HTMLElement } from "
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
3
|
|
|
4
4
|
export class $Image extends $HTMLElement<HTMLImageElement> {
|
|
5
5
|
constructor() {
|
|
@@ -67,6 +67,6 @@ export interface $Image extends $HTMLElement<HTMLImageElement> {
|
|
|
67
67
|
|
|
68
68
|
assignProperties(HTMLImageElement, $Image, 'img');
|
|
69
69
|
|
|
70
|
-
declare module
|
|
70
|
+
declare module "@amateras/core" {
|
|
71
71
|
export function $(nodeName: 'img'): $Image
|
|
72
72
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assignProperties } from "
|
|
2
|
-
import { $HTMLElement } from "
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
3
|
|
|
4
4
|
export class $Input extends $HTMLElement<HTMLInputElement> {
|
|
5
5
|
constructor() {
|
|
@@ -188,6 +188,6 @@ export type InputType =
|
|
|
188
188
|
|
|
189
189
|
assignProperties(HTMLInputElement, $Input, 'input');
|
|
190
190
|
|
|
191
|
-
declare module
|
|
191
|
+
declare module "@amateras/core" {
|
|
192
192
|
export function $(nodeName: 'input'): $Input
|
|
193
193
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assignProperties } from "
|
|
2
|
-
import { $HTMLElement } from "
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
3
|
|
|
4
4
|
export class $Label extends $HTMLElement<HTMLLabelElement> {
|
|
5
5
|
constructor() {
|
|
@@ -20,6 +20,6 @@ export interface $Label extends $HTMLElement<HTMLLabelElement> {
|
|
|
20
20
|
|
|
21
21
|
assignProperties(HTMLLabelElement, $Label, 'label');
|
|
22
22
|
|
|
23
|
-
declare module
|
|
23
|
+
declare module "@amateras/core" {
|
|
24
24
|
export function $(nodeName: 'label'): $Label
|
|
25
25
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assignProperties } from "
|
|
2
|
-
import { $HTMLElement } from "
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
3
|
|
|
4
4
|
export class $Media extends $HTMLElement<HTMLMediaElement> {
|
|
5
5
|
constructor() {
|
|
@@ -11,6 +11,6 @@ export interface $Media extends $HTMLElement<HTMLMediaElement> {}
|
|
|
11
11
|
|
|
12
12
|
assignProperties(HTMLMediaElement, $Media, 'media');
|
|
13
13
|
|
|
14
|
-
declare module
|
|
14
|
+
declare module "@amateras/core" {
|
|
15
15
|
export function $(nodeName: 'media'): $Media
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assignProperties } from "
|
|
2
|
-
import { $HTMLElement } from "
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
3
|
|
|
4
4
|
export class $OptGroup extends $HTMLElement<HTMLOptGroupElement> {
|
|
5
5
|
constructor() {
|
|
@@ -18,6 +18,6 @@ export interface $OptGroup extends $HTMLElement<HTMLOptGroupElement> {
|
|
|
18
18
|
|
|
19
19
|
assignProperties(HTMLOptGroupElement, $OptGroup, 'optgroup');
|
|
20
20
|
|
|
21
|
-
declare module
|
|
21
|
+
declare module "@amateras/core" {
|
|
22
22
|
export function $(nodeName: 'optgroup'): $OptGroup
|
|
23
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assignProperties } from "
|
|
2
|
-
import { $HTMLElement } from "
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
3
|
|
|
4
4
|
export class $Option extends $HTMLElement<HTMLOptionElement> {
|
|
5
5
|
constructor() {
|
|
@@ -35,6 +35,6 @@ export interface $Option extends $HTMLElement<HTMLOptionElement> {
|
|
|
35
35
|
|
|
36
36
|
assignProperties(HTMLOptionElement, $Option, 'option');
|
|
37
37
|
|
|
38
|
-
declare module
|
|
38
|
+
declare module "@amateras/core" {
|
|
39
39
|
export function $(nodeName: 'option'): $Option
|
|
40
40
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assignProperties } from "
|
|
2
|
-
import { $HTMLElement } from "
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
3
|
|
|
4
4
|
export class $Select extends $HTMLElement<HTMLSelectElement> {
|
|
5
5
|
constructor() {
|
|
@@ -71,6 +71,6 @@ export interface $Select extends $HTMLElement<HTMLSelectElement> {
|
|
|
71
71
|
|
|
72
72
|
assignProperties(HTMLSelectElement, $Select, 'select');
|
|
73
73
|
|
|
74
|
-
declare module
|
|
74
|
+
declare module "@amateras/core" {
|
|
75
75
|
export function $(nodeName: 'select'): $Select
|
|
76
76
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assignProperties } from "
|
|
2
|
-
import { $HTMLElement } from "
|
|
1
|
+
import { assignProperties } from "@amateras/core/lib/assignProperties";
|
|
2
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
3
|
|
|
4
4
|
export class $TextArea extends $HTMLElement<HTMLTextAreaElement> {
|
|
5
5
|
constructor() {
|
|
@@ -11,6 +11,6 @@ export interface $TextArea extends $HTMLElement<HTMLTextAreaElement> {}
|
|
|
11
11
|
|
|
12
12
|
assignProperties(HTMLTextAreaElement, $TextArea, 'textarea');
|
|
13
13
|
|
|
14
|
-
declare module
|
|
14
|
+
declare module "@amateras/core" {
|
|
15
15
|
export function $(nodeName: 'textarea'): $TextArea
|
|
16
16
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amateras/i18n",
|
|
3
|
+
"peerDependencies": {
|
|
4
|
+
"@amateras/core": "workspace:*",
|
|
5
|
+
"@amateras/signal": "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
|
+
}
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "@amateras/core"
|
|
2
|
+
import { _Array_from, _instanceof, _Object_assign } from "@amateras/utils"
|
|
3
3
|
import { I18n } from "#structure/I18n"
|
|
4
4
|
import { I18nDictionary, type I18nDictionaryContext, type I18nDictionaryContextImporter } from "#structure/I18nDictionary";
|
|
5
|
-
import { $Node, $
|
|
6
|
-
import { I18nTranslation as _I18nTranslation, type I18nTranslationOptions } from "#structure/I18nTranslation";
|
|
7
|
-
|
|
8
|
-
$Node.processors.add((_, content) => {
|
|
9
|
-
if (_instanceof(content, _I18nTranslation)) {
|
|
10
|
-
const text = new $Text();
|
|
11
|
-
$.effect(() => text.textContent(content.content$()))
|
|
12
|
-
return [text]
|
|
13
|
-
}
|
|
14
|
-
})
|
|
5
|
+
import { $Node, type $NodeContentResolver } from "@amateras/core/node/$Node";
|
|
6
|
+
import { I18nTranslation as _I18nTranslation, I18nTranslation, type I18nTranslationOptions } from "#structure/I18nTranslation";
|
|
15
7
|
|
|
16
8
|
$Node.setters.add((value, set) => {
|
|
17
9
|
if (_instanceof(value, _I18nTranslation)) {
|
|
@@ -86,7 +78,7 @@ type FindParam<T extends string> =
|
|
|
86
78
|
T extends `${string}$${infer Param}$${infer Rest}`
|
|
87
79
|
? Param extends `${string}${' '}${string}`
|
|
88
80
|
? Prettify<{} & FindParam<Rest>>
|
|
89
|
-
: Prettify<Record<Param,
|
|
81
|
+
: Prettify<Record<Param, $NodeContentResolver<I18nTranslation>> & FindParam<Rest>>
|
|
90
82
|
: {}
|
|
91
83
|
|
|
92
84
|
type FindTranslationByKey<K extends string, T extends I18nDictionaryContext> =
|
|
@@ -123,7 +115,7 @@ type Mixin<A, B> =
|
|
|
123
115
|
: A[key] | B[key]
|
|
124
116
|
}
|
|
125
117
|
|
|
126
|
-
declare module "amateras/core" {
|
|
118
|
+
declare module "@amateras/core" {
|
|
127
119
|
export namespace $ {
|
|
128
120
|
export interface I18nFunction<D extends I18nDictionaryContext = {}> {
|
|
129
121
|
<K extends I18nTranslationKey<D>, P extends I18nTranslationParams<K, D>>(path: K, ...params: P extends Record<string, never> ? [] : [P]): I18nTranslation;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '@amateras/signal';
|
|
2
|
+
import { _instanceof, _null } from "@amateras/utils";
|
|
2
3
|
import { I18nDictionary } from "#structure/I18nDictionary";
|
|
3
|
-
import 'amateras/signal';
|
|
4
4
|
import { I18nTranslation, type I18nTranslationOptions } from "./I18nTranslation";
|
|
5
5
|
|
|
6
6
|
export class I18n {
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { _Array_from, _null, isUndefined } from "amateras/
|
|
1
|
+
import { _Array_from, _null, isUndefined } from "@amateras/utils";
|
|
2
2
|
import type { I18n } from "#structure/I18n";
|
|
3
|
+
import { $Node, type $NodeContentResolver, type $NodeContentTypes } from "@amateras/core/node/$Node";
|
|
4
|
+
import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
|
|
3
5
|
|
|
4
|
-
export class I18nTranslation {
|
|
6
|
+
export class I18nTranslation extends $HTMLElement {
|
|
5
7
|
i18n: I18n;
|
|
6
8
|
key: string;
|
|
7
9
|
options: I18nTranslationOptions | undefined;
|
|
8
10
|
content$ = $.signal('');
|
|
9
11
|
constructor(i18n: I18n, key: string, options?: I18nTranslationOptions) {
|
|
12
|
+
super('t')
|
|
10
13
|
this.i18n = i18n;
|
|
11
14
|
this.key = key;
|
|
12
15
|
this.options = options;
|
|
@@ -16,7 +19,10 @@ export class I18nTranslation {
|
|
|
16
19
|
|
|
17
20
|
async update() {
|
|
18
21
|
const {key, i18n, options} = this;
|
|
19
|
-
const contentUpdate = (content:
|
|
22
|
+
const contentUpdate = (content: $NodeContentResolver<this>) => {
|
|
23
|
+
this.content(content);
|
|
24
|
+
this.content$.set(this.textContent() ?? '')
|
|
25
|
+
}
|
|
20
26
|
update: {
|
|
21
27
|
const dictionary = i18n.dictionary();
|
|
22
28
|
if (!dictionary) { contentUpdate(key); break update }
|
|
@@ -25,7 +31,7 @@ export class I18nTranslation {
|
|
|
25
31
|
const snippets = target.split(/\$[a-zA-Z0-9_]+\$/);
|
|
26
32
|
if (snippets.length === 1 || !options) { contentUpdate(target); break update }
|
|
27
33
|
const matches = target.matchAll(/(\$([a-zA-Z0-9_]+)\$)/g);
|
|
28
|
-
const content = snippets.map(text => [text, options[matches.next().value?.at(2)!] ?? null]
|
|
34
|
+
const content = snippets.map(text => [text, options[matches.next().value?.at(2)!] ?? null]).flat();
|
|
29
35
|
contentUpdate(content);
|
|
30
36
|
}
|
|
31
37
|
return this;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amateras/idb",
|
|
3
|
+
"peerDependencies": {
|
|
4
|
+
"@amateras/core": "workspace:*",
|
|
5
|
+
"@amateras/signal": "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
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _Object_assign } from "amateras/
|
|
1
|
+
import { _Object_assign } from "@amateras/utils"
|
|
2
2
|
import { $IDBBuilder } from "#structure/builder/$IDBBuilder"
|
|
3
3
|
|
|
4
|
-
declare module 'amateras/core' {
|
|
4
|
+
declare module '@amateras/core' {
|
|
5
5
|
export namespace $ {
|
|
6
6
|
/**
|
|
7
7
|
* Create {@link $IDBBuilder} with IDB name and version number.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _Promise } from "
|
|
1
|
+
import { _Promise } from "@amateras/utils";
|
|
2
2
|
|
|
3
3
|
export const $IDBRequest = <T>(req: IDBRequest<T>, handle?: (req: IDBRequest<T>, resolve: (value: T) => void) => void) => {
|
|
4
4
|
return new _Promise<T>((resolve, reject) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _Array_from, _null, _Object_assign, _Object_fromEntries, _Promise, isBoolean } from "amateras/
|
|
1
|
+
import { _Array_from, _null, _Object_assign, _Object_fromEntries, _Promise, isBoolean } from "@amateras/utils";
|
|
2
2
|
import { $IDBStore, type $IDBStoreConfig } from "./$IDBStore";
|
|
3
3
|
import { $IDBTransaction } from "./$IDBTransaction";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _instanceof, _Object_assign, _Promise } from "amateras/
|
|
1
|
+
import { _instanceof, _Object_assign, _Promise } from "@amateras/utils";
|
|
2
2
|
import { $IDBRequest } from "#lib/$IDBRequest";
|
|
3
3
|
import { $IDBStore, type $IDBStoreConfig } from "./$IDBStore";
|
|
4
4
|
import { $IDBIndex } from "./$IDBIndex";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _Object_assign } from "amateras/
|
|
1
|
+
import { _Object_assign } from "@amateras/utils";
|
|
2
2
|
import type { $IDBStore, $IDBStoreConfig, QueryMultipleKeyPath } from "./$IDBStore";
|
|
3
3
|
import { $IDBStoreBase } from "./$IDBStoreBase";
|
|
4
4
|
import type { $IDBCursor } from "./$IDBCursor";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _instanceof, _Object_assign, _Promise } from "amateras/
|
|
1
|
+
import { _instanceof, _Object_assign, _Promise } from "@amateras/utils";
|
|
2
2
|
import { $IDBIndex, type $IDBIndexConfig } from "./$IDBIndex";
|
|
3
3
|
import { $IDBRequest } from "#lib/$IDBRequest";
|
|
4
4
|
import { $IDBStoreBase } from "./$IDBStoreBase";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { $IDB, type $IDBConfig } from "#structure/$IDB";
|
|
2
|
-
import { _Array_from, _instanceof, _JSON_stringify, _null, _Object_assign, _Object_fromEntries, _Promise, forEach, isFunction } from "amateras/
|
|
2
|
+
import { _Array_from, _instanceof, _JSON_stringify, _null, _Object_assign, _Object_fromEntries, _Promise, forEach, isFunction, trycatch } from "@amateras/utils";
|
|
3
3
|
import { $IDBStoreBuilder } from "./$IDBStoreBuilder";
|
|
4
4
|
import type { $IDBIndexConfig } from "#structure/$IDBIndex";
|
|
5
5
|
import type { $IDBStoreConfig } from "#structure/$IDBStore";
|
|
6
|
-
import { trycatch } from "amateras/lib/trycatch";
|
|
7
6
|
// optimizer variables
|
|
8
7
|
const objectStoreNames = 'objectStoreNames';
|
|
9
8
|
const deleteObjectStore = 'deleteObjectStore';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amateras/markdown",
|
|
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
|
+
"./syntax/*": "./src/syntax/*.ts"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BlockTokenizer, InlineTokenizer, MarkdownLexer } from "#structure/MarkdownLexer";
|
|
2
2
|
import type { MarkdownParseProcessor, MarkdownParser } from "#structure/MarkdownParser";
|
|
3
|
-
import { forEach } from "amateras/
|
|
3
|
+
import { forEach } from "@amateras/utils";
|
|
4
4
|
|
|
5
5
|
export const setBlockTokenizer = (lexer: MarkdownLexer, type: string, tokenizer: BlockTokenizer) => lexer.blockTokenizers.set(type, tokenizer);
|
|
6
6
|
export const setInlineTokenizer = (lexer: MarkdownLexer, type: string, tokenizer: InlineTokenizer) => lexer.inlineTokenizers.set(type, tokenizer);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BLOCK, EMPTY_LINE, INLINE_CONTENT, INLINE_TEXT, TEXT_LINE } from "#lib/type";
|
|
2
|
-
import { forEach, isString } from "amateras/
|
|
2
|
+
import { forEach, isString } from "@amateras/utils";
|
|
3
3
|
|
|
4
4
|
export class MarkdownLexer {
|
|
5
5
|
blockTokenizers = new Map<string, BlockTokenizer>();
|
|
6
6
|
inlineTokenizers = new Map<string, InlineTokenizer>();
|
|
7
7
|
|
|
8
8
|
blockTokenize(str: string) {
|
|
9
|
-
const lines = str
|
|
9
|
+
const lines = str?.split(/\r?\n/) ?? [];
|
|
10
10
|
const tokens: BlockToken[] = [];
|
|
11
11
|
let lineIndex = 0;
|
|
12
12
|
lineLoop: while (lineIndex < lines.length) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forEach, isString } from "
|
|
1
|
+
import { forEach, isString } from "@amateras/utils";
|
|
2
2
|
import { type Token } from "./MarkdownLexer";
|
|
3
3
|
|
|
4
4
|
export class MarkdownParser {
|
|
@@ -7,6 +7,7 @@ export class MarkdownParser {
|
|
|
7
7
|
parse(tokens: (Token)[]) {
|
|
8
8
|
let html = '';
|
|
9
9
|
let i = 0;
|
|
10
|
+
if (!tokens) return html;
|
|
10
11
|
while (i < tokens.length) {
|
|
11
12
|
const token = tokens[i]!;
|
|
12
13
|
const processor = this.processors.get(token.type);
|
|
@@ -2,7 +2,7 @@ import { ALERT, ALERT_LINE, BLOCK } from "#lib/type";
|
|
|
2
2
|
import { setBlockTokenizer, setProcessor } from "#lib/util";
|
|
3
3
|
import type { BlockToken, MarkdownLexer } from "#structure/MarkdownLexer";
|
|
4
4
|
import type { MarkdownParser } from "#structure/MarkdownParser";
|
|
5
|
-
import { uppercase } from "amateras/
|
|
5
|
+
import { uppercase } from "@amateras/utils";
|
|
6
6
|
|
|
7
7
|
export const alertProcessor = (parser: MarkdownParser) => setProcessor(parser, ALERT, (token, tokens) => {
|
|
8
8
|
let html = '';
|
|
@@ -19,7 +19,7 @@ export const codeblockProcessor = (parser: MarkdownParser) => setProcessor(parse
|
|
|
19
19
|
})
|
|
20
20
|
|
|
21
21
|
export const codeblockTokenizer = (lexer: MarkdownLexer) => setBlockTokenizer(lexer, CODE_START, {
|
|
22
|
-
regex: /^```(\w+)
|
|
22
|
+
regex: /^```(\w+)?/,
|
|
23
23
|
handle: (matches, position, lines) => {
|
|
24
24
|
const tokens: BlockToken[] = [];
|
|
25
25
|
position++;
|
|
@@ -2,12 +2,12 @@ import { LINK, QUICK_LINK } from "#lib/type";
|
|
|
2
2
|
import { setInlineTokenizer, setProcessor } from "#lib/util";
|
|
3
3
|
import type { MarkdownLexer, Token } from "#structure/MarkdownLexer";
|
|
4
4
|
import type { MarkdownParser } from "#structure/MarkdownParser";
|
|
5
|
-
import { isUndefined } from "amateras/
|
|
5
|
+
import { isUndefined } from "@amateras/utils";
|
|
6
6
|
|
|
7
7
|
export const linkProcessor = (parser: MarkdownParser) => {
|
|
8
8
|
const linkProcessor = (token: Token) => {
|
|
9
9
|
const {href, email, title} = token.data!;
|
|
10
|
-
return `<a href="${isUndefined(href) ? `mailto:${email}` : href}"${title ? ` title="${title}"` : ''}>${parser.parse(token.content!)}</a>`
|
|
10
|
+
return `<a href="${isUndefined(href) ? `mailto:${email}` : href}"${title ? ` title="${title}"` : ''}>${token.text ?? parser.parse(token.content!)}</a>`
|
|
11
11
|
}
|
|
12
12
|
setProcessor(parser, QUICK_LINK, linkProcessor)
|
|
13
13
|
setProcessor(parser, LINK, linkProcessor)
|
|
@@ -2,7 +2,7 @@ import { EMPTY_LINE, ORDERED_LIST_ITEM, TEXT_LINE, UNORDERED_LIST_ITEM } from "#
|
|
|
2
2
|
import { htmltag, setBlockTokenizer, setProcessor } from "#lib/util";
|
|
3
3
|
import type { MarkdownLexer, Token } from "#structure/MarkdownLexer";
|
|
4
4
|
import type { MarkdownParser } from "#structure/MarkdownParser";
|
|
5
|
-
import { equal, isString } from "amateras/
|
|
5
|
+
import { equal, isString } from "@amateras/utils";
|
|
6
6
|
|
|
7
7
|
export const listProcessor = (parser: MarkdownParser) => {
|
|
8
8
|
const listType = (type: string) => type === ORDERED_LIST_ITEM ? 'ol' : 'ul'
|
|
@@ -2,7 +2,7 @@ import { BLOCK, TABLE, TABLE_COLUMN, TABLE_ROW } from "#lib/type";
|
|
|
2
2
|
import { htmltag, setBlockTokenizer, setProcessor } from "#lib/util";
|
|
3
3
|
import type { BlockToken, MarkdownLexer } from "#structure/MarkdownLexer";
|
|
4
4
|
import type { MarkdownParser } from "#structure/MarkdownParser";
|
|
5
|
-
import { _Array_from } from "amateras/
|
|
5
|
+
import { _Array_from } from "@amateras/utils";
|
|
6
6
|
|
|
7
7
|
export const tableProcessor = (parser: MarkdownParser) => setProcessor(parser, TABLE, (token) => {
|
|
8
8
|
let thead = '';
|