amateras 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +1 -0
- package/package.json +31 -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/{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
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@amateras/core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amateras",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Amateras is a DOM Utility library.",
|
|
5
5
|
"module": "index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -14,36 +14,37 @@
|
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://github.com/defaultkavy/amateras",
|
|
16
16
|
"license": "MIT",
|
|
17
|
-
"imports": {
|
|
18
|
-
"#core": "./src/core.ts",
|
|
19
|
-
"#node/*": "./src/node/*.ts",
|
|
20
|
-
"#lib/*": "./src/lib/*.ts",
|
|
21
|
-
"#structure/*": "./src/structure/*.ts",
|
|
22
|
-
"#html": "./ext/html/html.ts",
|
|
23
|
-
"#html/*": "./ext/html/node/*.ts"
|
|
24
|
-
},
|
|
25
17
|
"exports": {
|
|
26
|
-
".": "./
|
|
27
|
-
"./
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
".": "./index.ts",
|
|
19
|
+
"./env": {
|
|
20
|
+
"browser": "./packages/core/src/env.browser.ts",
|
|
21
|
+
"node": "./packages/core/src/env.node.ts",
|
|
22
|
+
"default": "./packages/core/src/env.browser.ts"
|
|
23
|
+
},
|
|
24
|
+
"./node/*": "./packages/core/src/node/*.ts",
|
|
25
|
+
"./lib/*": "./packages/core/src/lib/*.ts",
|
|
30
26
|
"./structure/*": "./src/structure/*.ts",
|
|
31
|
-
"./
|
|
32
|
-
"./
|
|
33
|
-
"./
|
|
34
|
-
"./
|
|
35
|
-
"./css
|
|
36
|
-
"./
|
|
37
|
-
"./
|
|
38
|
-
"./i18n": "./
|
|
39
|
-
"./idb": "./
|
|
40
|
-
"./idb/core": "./
|
|
41
|
-
"./markdown": "./
|
|
42
|
-
"./markdown/syntax/*": "./
|
|
43
|
-
"./signal": "./
|
|
44
|
-
"./ui/*": "./
|
|
27
|
+
"./core": "./packages/core/src/index.ts",
|
|
28
|
+
"./utils": "./packages/utils/src/index.ts",
|
|
29
|
+
"./html": "./packages/html/src/index.ts",
|
|
30
|
+
"./html/*": "./packages/html/node/*.ts",
|
|
31
|
+
"./css": "./packages/css/src/index.ts",
|
|
32
|
+
"./css/*": "./packages/css/src/ext/*.ts",
|
|
33
|
+
"./router": "./packages/router/src/index.ts",
|
|
34
|
+
"./i18n": "./packages/i18n/src/index.ts",
|
|
35
|
+
"./idb": "./packages/idb/src/index.ts",
|
|
36
|
+
"./idb/core": "./packages/idb/src/core.ts",
|
|
37
|
+
"./markdown": "./packages/markdown/src/index.ts",
|
|
38
|
+
"./markdown/syntax/*": "./packages/markdown/src/syntax/*.ts",
|
|
39
|
+
"./signal": "./packages/signal/src/index.ts",
|
|
40
|
+
"./ui/*": "./packages/ui/*.ts"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@amateras/core": "workspace:*"
|
|
45
44
|
},
|
|
46
|
-
"workspaces":
|
|
47
|
-
"
|
|
48
|
-
|
|
45
|
+
"workspaces": {
|
|
46
|
+
"packages": [
|
|
47
|
+
"packages/*"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
49
50
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amateras/core",
|
|
3
|
+
"dependencies": {
|
|
4
|
+
"@amateras/utils": "workspace:*",
|
|
5
|
+
"@amateras/dom": "workspace:*"
|
|
6
|
+
},
|
|
7
|
+
"imports": {
|
|
8
|
+
"#structure/*": "./src/structure/*.ts",
|
|
9
|
+
"#lib/*": "./src/lib/*.ts",
|
|
10
|
+
"#node/*": "./src/node/*.ts",
|
|
11
|
+
"#env": {
|
|
12
|
+
"browser": "./src/env.browser.ts",
|
|
13
|
+
"node": "./src/env.node.ts",
|
|
14
|
+
"default": "./src/env.browser.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"browser": "./src/index.ts",
|
|
20
|
+
"node": "./src/main.ts",
|
|
21
|
+
"default": "./src/index.ts"
|
|
22
|
+
},
|
|
23
|
+
"./env": {
|
|
24
|
+
"browser": "./src/env.browser.ts",
|
|
25
|
+
"node": "./src/env.node.ts",
|
|
26
|
+
"default": "./src/env.browser.ts"
|
|
27
|
+
},
|
|
28
|
+
"./structure/*": "./src/structure/*.ts",
|
|
29
|
+
"./lib/*": "./src/lib/*.ts",
|
|
30
|
+
"./node/*": "./src/node/*.ts"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// window and document
|
|
2
|
+
export const _window = window;
|
|
3
|
+
export const _document = document;
|
|
4
|
+
|
|
5
|
+
interface onclient {
|
|
6
|
+
(): boolean;
|
|
7
|
+
(fn: Function): void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface onserver {
|
|
11
|
+
(): boolean;
|
|
12
|
+
(fn: Function): void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const onclient: onclient = (fn?: Function) => {
|
|
16
|
+
if (fn) return fn();
|
|
17
|
+
return true
|
|
18
|
+
}
|
|
19
|
+
export const onserver: onserver = (fn?: Function) => {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// window and document
|
|
2
|
+
export const _window = window;
|
|
3
|
+
export const _document = document;
|
|
4
|
+
|
|
5
|
+
interface onclient {
|
|
6
|
+
(): boolean;
|
|
7
|
+
(fn: Function): void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface onserver {
|
|
11
|
+
(): boolean;
|
|
12
|
+
(fn: Function): void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const onclient: onclient = (fn?: Function) => {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
export const onserver: onserver = (fn?: Function) => {
|
|
19
|
+
if (fn) return fn();
|
|
20
|
+
return true
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { $Element } from '#node/$Element';
|
|
2
|
+
import type { $Node } from '#node/$Node';
|
|
3
|
+
import * as core from './index';
|
|
4
|
+
import type { $EventTarget } from '#node/$EventTarget';
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
export import $ = core.$;
|
|
8
|
+
type $Parameter<T> = T | undefined | $.$NodeParameterExtends<T>
|
|
9
|
+
interface Node {
|
|
10
|
+
readonly $: $Node
|
|
11
|
+
}
|
|
12
|
+
interface EventTarget {
|
|
13
|
+
readonly $: $EventTarget
|
|
14
|
+
}
|
|
15
|
+
interface Element {
|
|
16
|
+
readonly $: $Element
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,42 +1,55 @@
|
|
|
1
1
|
import './global';
|
|
2
|
-
import './
|
|
2
|
+
import './lib/assignNodeProperties';
|
|
3
3
|
import { $Element } from "#node/$Element";
|
|
4
4
|
import { $Node, type $NodeContentResolver, type $NodeContentTypes } from '#node/$Node';
|
|
5
|
-
import { _instanceof, isString, isFunction, _Object_assign, isObject, isNull, _Object_entries, _Object_defineProperty, forEach, isNumber, _Array_from, isUndefined, _bind, _null } from '
|
|
5
|
+
import { _instanceof, isString, isFunction, _Object_assign, isObject, isNull, _Object_entries, _Object_defineProperty, forEach, isNumber, _Array_from, isUndefined, _bind, _null } from '@amateras/utils';
|
|
6
6
|
import { $HTMLElement } from '#node/$HTMLElement';
|
|
7
|
-
import { _document } from '#
|
|
7
|
+
import { _document } from '#env';
|
|
8
8
|
import { $EventTarget, type $Event } from '#node/$EventTarget';
|
|
9
9
|
|
|
10
10
|
const nodeNameMap: {[key: string]: Constructor<$EventTarget>} = {}
|
|
11
|
-
const _stylesheet = new CSSStyleSheet();
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export function $
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export function $<
|
|
30
|
-
|
|
12
|
+
type $NodeBuilder = (...args: any[]) => $NodeContentResolver<$Node>
|
|
13
|
+
type BuilderResultResolver<F> = F extends Constructor<$Node> ? InstanceType<F> : F extends $NodeBuilder ? ReturnType<F> : never;
|
|
14
|
+
type BuilderParameterResolver<F> = F extends Constructor<$Node> ? ConstructorParameters<F> : F extends $NodeBuilder ? Parameters<F> : never;
|
|
15
|
+
|
|
16
|
+
type $Type<T extends EventTarget> = T extends HTMLElement ? $HTMLElement : T extends Element ? $Element : T extends (Node | ChildNode) ? $Node : T extends EventTarget ? $EventTarget : never;
|
|
17
|
+
|
|
18
|
+
/** Builder function */
|
|
19
|
+
export function $<F extends $NodeBuilder | Constructor<$Node> | number, T extends $NodeBuilder | Constructor<$Node>>(
|
|
20
|
+
resolver: F,
|
|
21
|
+
...args: F extends number ? [T, ...BuilderParameterResolver<T>] : BuilderParameterResolver<F>
|
|
22
|
+
): F extends number
|
|
23
|
+
? number extends F
|
|
24
|
+
? BuilderResultResolver<T>[]
|
|
25
|
+
: Repeat<BuilderResultResolver<T>, F>
|
|
26
|
+
: BuilderResultResolver<F>;
|
|
27
|
+
/** Get {@link $Node} from {@link NodeList} */
|
|
28
|
+
export function $<T extends HTMLElement | Element | Node | ChildNode>(nodes: NodeListOf<T>): $Type<T>[];
|
|
29
|
+
/** Get self */
|
|
30
|
+
export function $<E extends $EventTarget | null | undefined>($node: E, ...args: any[]): E extends $EventTarget ? E : null;
|
|
31
|
+
/** Convert {@link Window} to {@link $EventTarget} */
|
|
31
32
|
export function $<W extends Window>(node: W): $EventTarget<WindowEventMap>;
|
|
32
|
-
|
|
33
|
-
export function $<
|
|
33
|
+
/** Convert {@link Document} to {@link $Node} */
|
|
34
|
+
export function $<D extends Document>(node: D): $Node<DocumentEventMap>;
|
|
35
|
+
/** Convert {@link EventTarget} base to {@link $EventTarget} base*/
|
|
36
|
+
export function $<H extends EventTarget | null | undefined>(target: H, ...args: any[]): H extends EventTarget ? $Type<H> : null;
|
|
37
|
+
export function $<E extends Record<string, Event>>(target: EventTarget, ...args: any[]): $EventTarget<E>;
|
|
38
|
+
/** Convert string and variables to {@link $NodeContentTypes} array */
|
|
34
39
|
export function $<K extends TemplateStringsArray>(string: K, ...values: any[]): $NodeContentTypes[];
|
|
40
|
+
/** Get {@link Event.currentTarget} in {@link $EventTarget} type from {@link Event} */
|
|
35
41
|
export function $<Ev extends $Event<$Element, Event>>(event: Ev): Ev['currentTarget']['$'];
|
|
36
|
-
|
|
37
|
-
export function $<
|
|
38
|
-
|
|
39
|
-
export function
|
|
42
|
+
/** Create {@link $Node} base object from extensions */
|
|
43
|
+
export function $<K extends keyof $.$NodeMap, T extends $.$NodeMap[K]>(tagname: K, ...args: ConstructorParameters<T>): InstanceType<T>;
|
|
44
|
+
/** Create {@link $HTMLElement} by tagname */
|
|
45
|
+
export function $<K extends keyof HTMLElementTagNameMap>(tagname: K): $HTMLElement<HTMLElementTagNameMap[K]>;
|
|
46
|
+
/** Create {@link $HTMLElement} by custom tagname */
|
|
47
|
+
export function $(tagname: string): $HTMLElement<HTMLElement>
|
|
48
|
+
/** Create multiple {@link $HTMLElement} objects by tagname */
|
|
49
|
+
export function $<N extends number, K extends keyof HTMLElementTagNameMap>(number: N, tagname: K): number extends N ? $HTMLElement<HTMLElementTagNameMap[K]>[] : Repeat<$HTMLElement<HTMLElementTagNameMap[K]>, N>;
|
|
50
|
+
/** Create multiple {@link $HTMLElement} objects by custom tagname */
|
|
51
|
+
export function $<N extends number>(number: N, tagname: string): number extends N ? $HTMLElement<HTMLElement>[] : Repeat<$HTMLElement<HTMLElement>, N>;
|
|
52
|
+
export function $(resolver: string | number | null | undefined | Element | HTMLElement | $Node | Function | TemplateStringsArray | Event | NodeListOf<Node | ChildNode> | EventTarget, ...args: any[]) {
|
|
40
53
|
if (isNull(resolver) || isUndefined(resolver)) return null;
|
|
41
54
|
if (_instanceof(resolver, $Node)) return resolver;
|
|
42
55
|
if (isString(resolver) && nodeNameMap[resolver]) return new nodeNameMap[resolver](...args);
|
|
@@ -60,6 +73,7 @@ export function $(resolver: string | number | null | undefined | Element | HTMLE
|
|
|
60
73
|
|
|
61
74
|
export namespace $ {
|
|
62
75
|
// css
|
|
76
|
+
const _stylesheet = new CSSStyleSheet();
|
|
63
77
|
export const stylesheet = _stylesheet;
|
|
64
78
|
_document.adoptedStyleSheets.push(_stylesheet);
|
|
65
79
|
export const style = _bind(_stylesheet.insertRule, _stylesheet);
|
|
@@ -76,8 +90,6 @@ export namespace $ {
|
|
|
76
90
|
forEach(resolver, ([nodeName, $node]) => nodeNameMap[nodeName] = $node);
|
|
77
91
|
return $;
|
|
78
92
|
}
|
|
79
|
-
|
|
80
|
-
export const span = (content: string) => $('span').content(content);
|
|
81
93
|
}
|
|
82
94
|
|
|
83
95
|
export type $ = typeof $;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { $EventTarget } from "#node/$EventTarget";
|
|
2
2
|
import { $Node } from "#node/$Node";
|
|
3
|
-
import { _instanceof, _null, _Object_defineProperty, _Object_entries, _Object_getOwnPropertyDescriptors, forEach, isUndefined } from "
|
|
3
|
+
import { _instanceof, _null, _Object_defineProperty, _Object_entries, _Object_getOwnPropertyDescriptors, forEach, isUndefined } from "@amateras/utils";
|
|
4
4
|
|
|
5
5
|
const assigner = (target: any, {set, get, fn}: {
|
|
6
6
|
set?: string[],
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { $Node } from "#node/$Node";
|
|
2
|
+
import { isUndefined } from "@amateras/utils";
|
|
3
|
+
|
|
4
|
+
export const chain: chain = <T, R, V>(_this: T, args: IArguments | null, get: (() => R) | null, value: V, set: (value: Exclude<V, undefined>) => any) => {
|
|
5
|
+
if (args && get && !args.length) return get();
|
|
6
|
+
if (isUndefined(value)) return _this;
|
|
7
|
+
for (const setter of $Node.setters) {
|
|
8
|
+
const result = setter(value, set);
|
|
9
|
+
if (!isUndefined(result)) return set(result), _this;
|
|
10
|
+
}
|
|
11
|
+
return set(value as any), _this;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface chain {
|
|
15
|
+
<T, V>(_this: T, args: null, get: null, value: V, set: (value: Exclude<V, undefined | $.$NodeParameterExtends<V>>) => any): T
|
|
16
|
+
<T, R, V>(_this: T, args: IArguments, get: (() => R), value: V, set: (value: Exclude<V, undefined | $.$NodeParameterExtends<V>>) => any): T | R
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { _Object_assign } from "@amateras/utils";
|
|
2
|
+
import "@amateras/dom/structure/NodeList";
|
|
3
|
+
import '@amateras/dom/structure/Node';
|
|
4
|
+
import '@amateras/dom/structure/Text';
|
|
5
|
+
import '@amateras/dom/structure/Document';
|
|
6
|
+
import '@amateras/dom/structure/Element';
|
|
7
|
+
import '@amateras/dom/structure/HTMLElement';
|
|
8
|
+
import '@amateras/dom/structure/CSSStyleSheet';
|
|
9
|
+
import '@amateras/dom/structure/CSS';
|
|
10
|
+
|
|
11
|
+
import '@amateras/dom/structure/html/HTMLAnchorElement';
|
|
12
|
+
|
|
13
|
+
import { Window } from "@amateras/dom/structure/Window";
|
|
14
|
+
|
|
15
|
+
const window = new Window();
|
|
16
|
+
|
|
17
|
+
_Object_assign(globalThis, {
|
|
18
|
+
window,
|
|
19
|
+
...window,
|
|
20
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _Array_from, _instanceof, _Object_assign, _Object_entries, _Object_fromEntries, isNull, isString, isUndefined } from "
|
|
2
|
-
import { _document } from "#
|
|
1
|
+
import { _Array_from, _instanceof, _Object_assign, _Object_entries, _Object_fromEntries, forEach, isNull, isNumber, isString, isUndefined } from "@amateras/utils";
|
|
2
|
+
import { _document } from "#env";
|
|
3
3
|
import { $Node } from "./$Node";
|
|
4
4
|
|
|
5
5
|
export class $Element<Ele extends Element = Element, EvMap = ElementEventMap> extends $Node<EvMap> {
|
|
@@ -12,14 +12,22 @@ export class $Element<Ele extends Element = Element, EvMap = ElementEventMap> ex
|
|
|
12
12
|
|
|
13
13
|
attr(): {[key: string]: string};
|
|
14
14
|
attr(key: string): string | null;
|
|
15
|
-
attr(obj: {[key: string]:
|
|
16
|
-
attr(resolver?: {[key: string]:
|
|
15
|
+
attr(obj: {[key: string]: $Parameter<any| null>}): this;
|
|
16
|
+
attr(resolver?: {[key: string]: $Parameter<any | null>} | string) {
|
|
17
17
|
if (!arguments.length) return _Object_fromEntries(_Array_from(this.attributes).map(attr => [attr.name, attr.value]));
|
|
18
18
|
if (isString(resolver)) return this.getAttribute(resolver);
|
|
19
|
-
if (resolver)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
if (resolver)
|
|
20
|
+
keyIterate: for (let [key, value] of _Object_entries(resolver)) {
|
|
21
|
+
const set = (value: string | number | boolean | null | undefined) => {
|
|
22
|
+
if (!isUndefined(value) && isNull(value)) this.removeAttribute(key);
|
|
23
|
+
else this.setAttribute(key, `${value}`);
|
|
24
|
+
}
|
|
25
|
+
for (const setter of $Node.setters) {
|
|
26
|
+
const result = setter(value, set);
|
|
27
|
+
if (!isUndefined(result)) { set(result); continue keyIterate; }
|
|
28
|
+
}
|
|
29
|
+
set(value as any);
|
|
30
|
+
}
|
|
23
31
|
return this;
|
|
24
32
|
}
|
|
25
33
|
|
|
@@ -40,6 +48,12 @@ export class $Element<Ele extends Element = Element, EvMap = ElementEventMap> ex
|
|
|
40
48
|
toString() {
|
|
41
49
|
return this.outerHTML();
|
|
42
50
|
}
|
|
51
|
+
|
|
52
|
+
animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions & { callback?: (animation: Animation) => void }) {
|
|
53
|
+
const animation = this.node.animate(keyframes, options);
|
|
54
|
+
if (!isNumber(options)) options?.callback?.(animation);
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
43
57
|
}
|
|
44
58
|
|
|
45
59
|
function createNode(nodeName: string) {
|
|
@@ -185,8 +199,6 @@ export interface $Element<Ele extends Element, EvMap = ElementEventMap> {
|
|
|
185
199
|
setPointerCapture(pointerId: number): this;
|
|
186
200
|
/** {@link Element.toggleAttribute} */
|
|
187
201
|
toggleAttribute(qualifiedName: string, force?: boolean): boolean;
|
|
188
|
-
/** {@link Element.animate} */
|
|
189
|
-
animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions): Animation;
|
|
190
202
|
/** {@link Element.getAnimations} */
|
|
191
203
|
getAnimations(options?: GetAnimationsOptions): Animation[];
|
|
192
204
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBoolean } from "
|
|
1
|
+
import { forEach, isBoolean, toArray } from "@amateras/utils";
|
|
2
2
|
|
|
3
3
|
export class $EventTarget<EvMap = {}> {
|
|
4
4
|
node: EventTarget;
|
|
@@ -7,16 +7,19 @@ export class $EventTarget<EvMap = {}> {
|
|
|
7
7
|
if (node !== window) (node as Mutable<EventTarget>).$ = this;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
on(type: string, listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | AddEventListenerOptions): this {
|
|
11
|
-
|
|
10
|
+
on(type: string | string[], listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | AddEventListenerOptions): this {
|
|
11
|
+
forEach(toArray(type), type => this.addEventListener(type, listener, options));
|
|
12
|
+
return this;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
off(type: string, listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | EventListenerOptions): this {
|
|
15
|
-
|
|
15
|
+
off(type: string | string[], listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | EventListenerOptions): this {
|
|
16
|
+
forEach(toArray(type), type => this.removeEventListener(type, listener, options));
|
|
17
|
+
return this
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
once(type: string, listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | AddEventListenerOptions): this {
|
|
19
|
-
|
|
20
|
+
once(type: string | string[], listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | AddEventListenerOptions): this {
|
|
21
|
+
forEach(toArray(type), type => this.on(type, listener, { once: true, ...(isBoolean(options) ? { capture: options } : options ?? {}) }));
|
|
22
|
+
return this
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
|
|
@@ -34,12 +37,12 @@ export interface $EventTarget<EvMap = {}> {
|
|
|
34
37
|
/** {@link EventTarget.dispatchEvent} */
|
|
35
38
|
dispatchEvent(event: Event): boolean;
|
|
36
39
|
|
|
37
|
-
on<K extends keyof EvMap, Ev extends EvMap[K]>(type: K, listener: $EventListener<this, Ev> | $EventListenerObject<this, Ev>, options?: boolean | AddEventListenerOptions): this;
|
|
40
|
+
on<K extends keyof EvMap, Ev extends EvMap[K]>(type: K | K[], listener: $EventListener<this, Ev> | $EventListenerObject<this, Ev>, options?: boolean | AddEventListenerOptions): this;
|
|
38
41
|
on(type: string, listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | AddEventListenerOptions): this;
|
|
39
42
|
|
|
40
|
-
off<K extends keyof EvMap, Ev extends EvMap[K]>(type: K, listener: $EventListener<this, Ev> | $EventListenerObject<this, Ev>, options?: boolean | EventListenerOptions): this;
|
|
43
|
+
off<K extends keyof EvMap, Ev extends EvMap[K]>(type: K | K[], listener: $EventListener<this, Ev> | $EventListenerObject<this, Ev>, options?: boolean | EventListenerOptions): this;
|
|
41
44
|
off(type: string, listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | EventListenerOptions): this;
|
|
42
45
|
|
|
43
|
-
once<K extends keyof EvMap, Ev extends EvMap[K]>(type: K, listener: $EventListener<this, Ev> | $EventListenerObject<this, Ev>, options?: boolean | AddEventListenerOptions): this;
|
|
46
|
+
once<K extends keyof EvMap, Ev extends EvMap[K]>(type: K | K[], listener: $EventListener<this, Ev> | $EventListenerObject<this, Ev>, options?: boolean | AddEventListenerOptions): this;
|
|
44
47
|
once(type: string, listener: $EventListener<this, Event> | $EventListenerObject<this, Event>, options?: boolean | AddEventListenerOptions): this;
|
|
45
48
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _Object_entries, forEach } from "
|
|
1
|
+
import { _Object_entries, forEach } from "@amateras/utils";
|
|
2
2
|
import { $Element } from "#node/$Element";
|
|
3
3
|
|
|
4
4
|
export class $HTMLElement<Ele extends HTMLElement = HTMLElement, EvMap = HTMLElementEventMap> extends $Element<Ele, EvMap> {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { _Array_from, _instanceof, _JSON_stringify, _null, _Promise, forEach, isFunction, isNull, isUndefined } from "#lib/native";
|
|
4
|
-
import { toArray } from "#lib/toArray";
|
|
1
|
+
import { _document } from "#env";
|
|
2
|
+
import { _Array_from, _instanceof, _JSON_stringify, _null, _Promise, forEach, isFunction, isNull, isUndefined, toArray } from "@amateras/utils";
|
|
5
3
|
import { $EventTarget } from "./$EventTarget";
|
|
6
4
|
|
|
7
5
|
export class $Node<EvMap = {}> extends $EventTarget<EvMap> {
|
|
@@ -13,10 +11,8 @@ export class $Node<EvMap = {}> extends $EventTarget<EvMap> {
|
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
content(children: $NodeContentResolver<this>) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.insert(children);
|
|
19
|
-
})
|
|
14
|
+
forEach(_Array_from(this.childNodes), node => node.remove());
|
|
15
|
+
return this.insert(children);
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
insert(resolver: $NodeContentResolver<this>, position = -1) {
|
|
@@ -64,7 +60,7 @@ export class $Node<EvMap = {}> extends $EventTarget<EvMap> {
|
|
|
64
60
|
static process<T extends $Node>($node: T, content: $NodeContentResolver<any>): Array<$Node | undefined | null> {
|
|
65
61
|
for (const processor of this.processors) {
|
|
66
62
|
const result = processor($node, content);
|
|
67
|
-
if (result)
|
|
63
|
+
if (result) content = result;
|
|
68
64
|
}
|
|
69
65
|
if (isUndefined(content) || isNull(content) || _instanceof(content, $Node)) return [content];
|
|
70
66
|
// is Promise
|
|
@@ -100,7 +96,7 @@ export class $Text extends $Node {
|
|
|
100
96
|
}
|
|
101
97
|
|
|
102
98
|
export type $NodeSetterHandler = (value: any, set: (value: any) => void) => any;
|
|
103
|
-
export type $NodeContentProcessor = <N extends $Node>($node: N, content: $NodeContentResolver<N>) =>
|
|
99
|
+
export type $NodeContentProcessor = <N extends $Node>($node: N, content: $NodeContentResolver<N>) => $NodeContentResolver<N>;
|
|
104
100
|
export type $NodeContentHandler<T extends $Node> = ($node: T) => OrPromise<$NodeContentResolver<T>>;
|
|
105
101
|
export type $NodeContentTypes = $Node | string | number | boolean | $.$NodeContentTypeExtends | null | undefined;
|
|
106
102
|
export type $NodeContentResolver<T extends $Node> = OrPromise<$NodeContentTypes | $NodeContentHandler<T> | $NodeContentResolver<T>[]>;
|
|
@@ -168,7 +164,7 @@ export interface $Node<EvMap = {}> extends $EventTarget<EvMap> {
|
|
|
168
164
|
/** {@link Node.replaceChild} */
|
|
169
165
|
replaceChild<T extends Node>(node: Node, child: T): T;
|
|
170
166
|
/** {@link Node.contains} */
|
|
171
|
-
contains(other: $EventTarget |
|
|
167
|
+
contains(other: $EventTarget | EventTarget | null | undefined): boolean;
|
|
172
168
|
|
|
173
169
|
/** {@link ChildNode.after} */
|
|
174
170
|
after(...nodes: ($EventTarget | Node | string)[]): this;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { chain } from "#lib/chain";
|
|
2
|
-
import { forEach, _Array_from, _instanceof, _null } from "
|
|
3
|
-
import { toArray } from "#lib/toArray";
|
|
2
|
+
import { forEach, _Array_from, _instanceof, _null, toArray } from "@amateras/utils";
|
|
4
3
|
import { $HTMLElement } from "#node/$HTMLElement";
|
|
5
4
|
import { $Node, type $NodeContentResolver } from "#node/$Node";
|
|
6
5
|
|
|
@@ -43,11 +42,12 @@ export class $Virtual<Ele extends HTMLElement = HTMLElement, EvMap = HTMLElement
|
|
|
43
42
|
render() {
|
|
44
43
|
// remove hidden node
|
|
45
44
|
forEach(this.childNodes, node => this.hiddenNodes.has($(node)) && node.remove());
|
|
45
|
+
// get array of visible node
|
|
46
|
+
const visibleNodes = _Array_from(this.nodes).filter($node => !this.hiddenNodes.has($node))
|
|
46
47
|
// add visible node with position
|
|
47
|
-
forEach(
|
|
48
|
+
forEach(visibleNodes, ($node, i) => {
|
|
48
49
|
if (
|
|
49
|
-
|
|
50
|
-
&& !$node.inDOM() // node is not in dom tree
|
|
50
|
+
!$node.inDOM() // node is not in dom tree
|
|
51
51
|
&& $(this.childNodes).at(i) !== $node // node not matched at position
|
|
52
52
|
) $Node.append(this, $node, i);
|
|
53
53
|
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amateras/css",
|
|
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
|
+
"./structure/*": "./src/structure/*.ts",
|
|
14
|
+
"./lib/*": "./src/lib/*.ts",
|
|
15
|
+
"./node/*": "./src/node/*.ts"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { colorAssign } from "
|
|
1
|
+
import { colorAssign } from "../../lib/colorAssign";
|
|
2
2
|
|
|
3
3
|
const _amber = {
|
|
4
4
|
50: '#fffbeb',
|
|
@@ -16,7 +16,7 @@ const _amber = {
|
|
|
16
16
|
|
|
17
17
|
colorAssign('amber', _amber);
|
|
18
18
|
|
|
19
|
-
declare module 'amateras/core' {
|
|
19
|
+
declare module '@amateras/core' {
|
|
20
20
|
export namespace $ {
|
|
21
21
|
export namespace color {
|
|
22
22
|
export const amber: typeof _amber;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { colorAssign } from "
|
|
1
|
+
import { colorAssign } from "../../lib/colorAssign";
|
|
2
2
|
|
|
3
3
|
colorAssign('black', '#000000');
|
|
4
4
|
colorAssign('white', '#ffffff');
|
|
5
5
|
|
|
6
|
-
declare module 'amateras/core' {
|
|
6
|
+
declare module '@amateras/core' {
|
|
7
7
|
export namespace $ {
|
|
8
8
|
export namespace color {
|
|
9
9
|
export const black: '#000000';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { colorAssign } from "
|
|
1
|
+
import { colorAssign } from "../../lib/colorAssign";
|
|
2
2
|
|
|
3
3
|
const _blue = {
|
|
4
4
|
50: '#eff6ff',
|
|
@@ -16,7 +16,7 @@ const _blue = {
|
|
|
16
16
|
|
|
17
17
|
colorAssign('blue', _blue);
|
|
18
18
|
|
|
19
|
-
declare module 'amateras/core' {
|
|
19
|
+
declare module '@amateras/core' {
|
|
20
20
|
export namespace $ {
|
|
21
21
|
export namespace color {
|
|
22
22
|
export const blue: typeof _blue;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { colorAssign } from "
|
|
1
|
+
import { colorAssign } from "../../lib/colorAssign";
|
|
2
2
|
|
|
3
3
|
const _cyan = {
|
|
4
4
|
50: '#ecfeff',
|
|
@@ -16,7 +16,7 @@ const _cyan = {
|
|
|
16
16
|
|
|
17
17
|
colorAssign('cyan', _cyan);
|
|
18
18
|
|
|
19
|
-
declare module 'amateras/core' {
|
|
19
|
+
declare module '@amateras/core' {
|
|
20
20
|
export namespace $ {
|
|
21
21
|
export namespace color {
|
|
22
22
|
export const cyan: typeof _cyan;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { colorAssign } from "
|
|
1
|
+
import { colorAssign } from "../../lib/colorAssign";
|
|
2
2
|
|
|
3
3
|
const _emerald = {
|
|
4
4
|
50: '#ecfdf5',
|
|
@@ -16,7 +16,7 @@ const _emerald = {
|
|
|
16
16
|
|
|
17
17
|
colorAssign('emerald', _emerald);
|
|
18
18
|
|
|
19
|
-
declare module 'amateras/core' {
|
|
19
|
+
declare module '@amateras/core' {
|
|
20
20
|
export namespace $ {
|
|
21
21
|
export namespace color {
|
|
22
22
|
export const emerald: typeof _emerald;
|