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
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
|
-
})
|
package/ext/ssr/package.json
DELETED
package/ext/ui/node/Waterfall.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { _Array_from, _instanceof, equal, forEach, isNumber } from "amateras/lib/native";
|
|
2
|
-
import { $HTMLElement } from "amateras/node/$HTMLElement";
|
|
3
|
-
import { $Element } from "amateras/node/$Element";
|
|
4
|
-
import { $Virtual } from "amateras/node/$Virtual";
|
|
5
|
-
|
|
6
|
-
const getRect = (el: $Element) => el.getBoundingClientRect();
|
|
7
|
-
const px = (value: number) => `${value}px`;
|
|
8
|
-
$.style(`waterfall { display: block; position: relative }`)
|
|
9
|
-
|
|
10
|
-
export class Waterfall extends $Virtual {
|
|
11
|
-
#column = 1;
|
|
12
|
-
#gap = 0;
|
|
13
|
-
#width = 0;
|
|
14
|
-
constructor() {
|
|
15
|
-
super('waterfall');
|
|
16
|
-
new ResizeObserver(_ => this.inDOM() && this.#width !== getRect(this).width && (this.dispatchEvent(new Event('resize', {cancelable: true})) && this.layout())).observe(this.node);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
column(): number;
|
|
20
|
-
column(column: $Parameter<number>): this;
|
|
21
|
-
column(column?: $Parameter<number>) {
|
|
22
|
-
if (!arguments.length) return this.#column;
|
|
23
|
-
if (isNumber(column)) this.#column = column;
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
gap(): number;
|
|
28
|
-
gap(gap: $Parameter<number>): this;
|
|
29
|
-
gap(gap?: $Parameter<number>) {
|
|
30
|
-
if (!arguments.length) return this.#gap;
|
|
31
|
-
if (isNumber(gap)) this.#gap = gap;
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
layout() {
|
|
36
|
-
const items = _Array_from(this.nodes).map(item => item);
|
|
37
|
-
const { width } = getRect(this);
|
|
38
|
-
this.#width = width;
|
|
39
|
-
const columnCount = this.#column;
|
|
40
|
-
const gap = this.#gap;
|
|
41
|
-
const columnWidth = ((width - ((columnCount - 1) * gap)) / columnCount);
|
|
42
|
-
const columns = _Array_from({length: columnCount}).map((_, i) => ({ i, h: 0, x: i * (columnWidth + gap) }))
|
|
43
|
-
const getColumnByHeight = (i: number) => columns.sort((a, b) => a.h - b.h ? a.h - b.h : a.i - b.i).at(i) as typeof columns[number];
|
|
44
|
-
forEach(items, item => {
|
|
45
|
-
if (!_instanceof(item, $HTMLElement)) return;
|
|
46
|
-
item.attr();
|
|
47
|
-
const { height, width } = item.attr();
|
|
48
|
-
const shortestSection = getColumnByHeight(0);
|
|
49
|
-
item.style({
|
|
50
|
-
position: 'absolute',
|
|
51
|
-
top: px(shortestSection.h),
|
|
52
|
-
left: px(shortestSection.x),
|
|
53
|
-
width: px(columnWidth),
|
|
54
|
-
});
|
|
55
|
-
if (width && height) {
|
|
56
|
-
// get ratio from attributes and calculate item's height
|
|
57
|
-
let itemHeight = columnWidth / (+width / +height);
|
|
58
|
-
item.style({ height: px(itemHeight) })
|
|
59
|
-
shortestSection.h += +itemHeight + gap;
|
|
60
|
-
} else {
|
|
61
|
-
item.style({ visibility: 'hidden', height: '' })
|
|
62
|
-
if (this.hiddenNodes.has(item)) this.show(item).render().hide(item);
|
|
63
|
-
let itemHeight = getRect(item).height;
|
|
64
|
-
item.style({visibility: '', height: px(itemHeight)})
|
|
65
|
-
shortestSection.h += +itemHeight + gap;
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
this.style({ height: px(getColumnByHeight(-1).h) });
|
|
69
|
-
this.dispatchEvent(new Event('layout'))
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
}
|
package/ext/ui/package.json
DELETED
package/src/index.ts
DELETED
package/src/lib/chain.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isUndefined } from "./native";
|
|
2
|
-
|
|
3
|
-
export const chain: chain = <T, R, V>(_this: T, args: IArguments | null, get: (() => R) | null, value: V, set: (value: Exclude<V, undefined>) => any) =>
|
|
4
|
-
args && get && !args.length
|
|
5
|
-
? get()
|
|
6
|
-
: isUndefined(value)
|
|
7
|
-
? _this
|
|
8
|
-
: (set(value as any), _this);
|
|
9
|
-
|
|
10
|
-
interface chain {
|
|
11
|
-
<T, V>(_this: T, args: null, get: null, value: V, set: (value: Exclude<V, undefined>) => any): T
|
|
12
|
-
<T, R, V>(_this: T, args: IArguments, get: (() => R), value: V, set: (value: Exclude<V, undefined>) => any): T | R
|
|
13
|
-
}
|
package/src/lib/debounce.ts
DELETED
package/src/lib/env.ts
DELETED
package/src/lib/randomId.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { _Array_from } from "./native";
|
|
2
|
-
|
|
3
|
-
const LOWER = 'abcdefghijklmnopqrstuvwxyz';
|
|
4
|
-
const UPPER = LOWER.toUpperCase();
|
|
5
|
-
export const randomId = (options?: {length?: number, lettercase?: 'any' | 'lower' | 'upper'}): string => {
|
|
6
|
-
options = {length: 5, lettercase: 'any', ...options};
|
|
7
|
-
const char = options.lettercase === 'any' ? LOWER + UPPER : options.lettercase === 'lower' ? LOWER : UPPER;
|
|
8
|
-
return _Array_from({length: options.length as number}, (_, i) => char[Math.round(Math.random() * char.length)]).join('');
|
|
9
|
-
}
|
package/src/lib/sleep.ts
DELETED
package/src/lib/toArray.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { _instanceof, _Object_assign } from "./native";
|
|
2
|
-
|
|
3
|
-
export const toArray = <T>(item: OrArray<T>): T[] => _instanceof(item, Array) ? item : [item];
|
|
4
|
-
|
|
5
|
-
declare module '#core' {
|
|
6
|
-
export namespace $ {
|
|
7
|
-
export function toArray<T>(item: OrArray<T>): T[];
|
|
8
|
-
}
|
|
9
|
-
}
|
package/src/lib/trycatch.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { _instanceof, _JSON_stringify, _null, _Object_assign } from "./native";
|
|
2
|
-
|
|
3
|
-
export const trycatch = <D>(callback: () => D): Result<D, Error> => {
|
|
4
|
-
try {
|
|
5
|
-
return [callback(), _null];
|
|
6
|
-
} catch (err) {
|
|
7
|
-
return [_null, _instanceof(err, Error) ? err : new Error(_JSON_stringify(err))];
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
_Object_assign($, {trycatch})
|
|
12
|
-
|
|
13
|
-
declare module '#core' {
|
|
14
|
-
export namespace $ {
|
|
15
|
-
export function trycatch <D>(callback: () => D): Result<D, Error>
|
|
16
|
-
}
|
|
17
|
-
}
|
package/src/lib/uppercase.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|