amateras 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -26
- package/index.ts +1 -0
- package/package.json +32 -27
- 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/packages/core/src/index.ts +96 -0
- package/packages/core/src/lib/assignNodeProperties.ts +11 -0
- package/packages/core/src/lib/assignProperties.ts +57 -0
- 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 +25 -47
- package/packages/core/src/node/$EventTarget.ts +48 -0
- package/{src → packages/core/src}/node/$HTMLElement.ts +1 -1
- package/{src → packages/core/src}/node/$Node.ts +64 -73
- package/packages/core/src/node/$Virtual.ts +65 -0
- 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 +4 -4
- package/packages/html/src/node/$Canvas.ts +38 -0
- package/{ext/html → packages/html/src}/node/$Dialog.ts +4 -4
- package/{ext/html → packages/html/src}/node/$Form.ts +4 -4
- package/{ext/html → packages/html/src}/node/$Image.ts +4 -4
- package/{ext/html → packages/html/src}/node/$Input.ts +4 -4
- package/{ext/html → packages/html/src}/node/$Label.ts +4 -4
- package/{ext/html → packages/html/src}/node/$Media.ts +4 -4
- package/{ext/html → packages/html/src}/node/$OptGroup.ts +4 -4
- package/{ext/html → packages/html/src}/node/$Option.ts +4 -4
- package/{ext/html → packages/html/src}/node/$Select.ts +4 -4
- package/{ext/html → packages/html/src}/node/$TextArea.ts +4 -4
- package/{ext → packages}/i18n/README.md +20 -0
- package/packages/i18n/package.json +19 -0
- package/packages/i18n/src/index.ts +140 -0
- package/{ext → packages}/i18n/src/structure/I18n.ts +12 -8
- package/{ext → packages}/i18n/src/structure/I18nDictionary.ts +1 -1
- package/packages/i18n/src/structure/I18nTranslation.ts +41 -0
- 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 +9 -10
- package/{ext → packages}/idb/src/structure/builder/$IDBStoreBuilder.ts +1 -1
- package/packages/markdown/README.md +53 -0
- package/packages/markdown/package.json +19 -0
- package/packages/markdown/src/index.ts +3 -0
- package/packages/markdown/src/lib/type.ts +26 -0
- package/packages/markdown/src/lib/util.ts +21 -0
- package/packages/markdown/src/structure/Markdown.ts +54 -0
- package/packages/markdown/src/structure/MarkdownLexer.ts +111 -0
- package/packages/markdown/src/structure/MarkdownParser.ts +34 -0
- package/packages/markdown/src/syntax/alert.ts +46 -0
- package/packages/markdown/src/syntax/blockquote.ts +35 -0
- package/packages/markdown/src/syntax/bold.ts +11 -0
- package/packages/markdown/src/syntax/code.ts +11 -0
- package/packages/markdown/src/syntax/codeblock.ts +44 -0
- package/packages/markdown/src/syntax/heading.ts +14 -0
- package/packages/markdown/src/syntax/horizontalRule.ts +11 -0
- package/packages/markdown/src/syntax/image.ts +23 -0
- package/packages/markdown/src/syntax/italic.ts +11 -0
- package/packages/markdown/src/syntax/link.ts +46 -0
- package/packages/markdown/src/syntax/list.ts +121 -0
- package/packages/markdown/src/syntax/table.ts +67 -0
- package/packages/markdown/src/syntax/text.ts +19 -0
- package/packages/router/README.md +175 -0
- package/packages/router/package.json +19 -0
- package/packages/router/src/index.ts +68 -0
- package/packages/router/src/node/Page.ts +38 -0
- package/packages/router/src/node/Router.ts +212 -0
- package/{ext/router → packages/router/src}/node/RouterAnchor.ts +13 -2
- package/packages/router/src/structure/PageBuilder.ts +24 -0
- package/packages/router/src/structure/Route.ts +105 -0
- package/packages/signal/README.md +93 -0
- package/packages/signal/package.json +18 -0
- package/packages/signal/src/index.ts +221 -0
- package/{src → packages/signal/src}/structure/Signal.ts +6 -10
- package/packages/ssr/package.json +19 -0
- package/packages/ssr/src/index.ts +38 -0
- package/packages/ui/lib/VirtualScroll.ts +25 -0
- package/packages/ui/node/Accordian.ts +97 -0
- package/packages/ui/node/Carousel.ts +20 -0
- package/packages/ui/node/Form.ts +54 -0
- package/packages/ui/node/Grid.ts +0 -0
- package/packages/ui/node/Modal.ts +45 -0
- package/packages/ui/node/Table.ts +43 -0
- package/packages/ui/node/Tabs.ts +129 -0
- package/packages/ui/node/Toast.ts +16 -0
- 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 +9 -15
- package/packages/utils/src/index.ts +90 -0
- 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/i18n/src/index.ts +0 -54
- package/ext/i18n/src/node/I18nText.ts +0 -35
- package/ext/idb/package.json +0 -13
- package/ext/markdown/index.ts +0 -121
- package/ext/markdown/package.json +0 -8
- package/ext/router/README.md +0 -81
- package/ext/router/index.ts +0 -73
- package/ext/router/node/Page.ts +0 -27
- package/ext/router/node/Route.ts +0 -54
- package/ext/router/node/Router.ts +0 -149
- package/ext/ssr/env.ts +0 -61
- package/ext/ssr/index.ts +0 -49
- package/ext/ssr/package.json +0 -10
- package/src/core.ts +0 -114
- package/src/index.ts +0 -3
- package/src/lib/assign.ts +0 -38
- package/src/lib/assignHelper.ts +0 -18
- package/src/lib/chain.ts +0 -13
- package/src/lib/debounce.ts +0 -7
- package/src/lib/env.ts +0 -2
- package/src/lib/native.ts +0 -40
- 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/node.ts +0 -10
- /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}/idb/README.md +0 -0
- /package/{ext → packages}/idb/src/core.ts +0 -0
package/src/core.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import './global';
|
|
2
|
-
import './node';
|
|
3
|
-
import { Signal } from "#structure/Signal";
|
|
4
|
-
import { $Element, type $Event } from "#node/$Element";
|
|
5
|
-
import { $Node, type $NodeContentResolver, type $NodeContentTypes } from '#node/$Node';
|
|
6
|
-
import { _instanceof, isString, isFunction, _Object_assign, isObject, isNull, _Object_entries, _Object_defineProperty, forEach, isNumber, _Array_from, isUndefined, _bind, _null } from '#lib/native';
|
|
7
|
-
import { $HTMLElement } from '#node/$HTMLElement';
|
|
8
|
-
import { _document } from '#lib/env';
|
|
9
|
-
import { toArray } from '#lib/toArray';
|
|
10
|
-
|
|
11
|
-
const nodeNameMap: {[key: string]: Constructor<$Node>} = {}
|
|
12
|
-
const _stylesheet = new CSSStyleSheet();
|
|
13
|
-
|
|
14
|
-
export function $<F extends (...args: any[]) => $NodeContentResolver<$Node>, N extends number>(number: N, fn: F, ...args: Parameters<F>): Repeat<ReturnType<F>, N>;
|
|
15
|
-
export function $<F extends (...args: any[]) => $NodeContentResolver<$Node>>(fn: F, ...args: Parameters<F>): ReturnType<F>;
|
|
16
|
-
export function $<T extends Constructor<$Node>, P extends ConstructorParameters<T>, N extends number>(number: N, construct: T, ...args: P): Repeat<InstanceType<T>, N>;
|
|
17
|
-
export function $<T extends Constructor<$Node>, P extends ConstructorParameters<T>>(construct: T, ...args: P): InstanceType<T>;
|
|
18
|
-
export function $(nodes: NodeListOf<Node | ChildNode>): $Node[];
|
|
19
|
-
export function $<N extends $Node>($node: N, ...args: any[]): N;
|
|
20
|
-
export function $<N extends $Node>($node: N | null | undefined, ...args: any[]): N | null | undefined;
|
|
21
|
-
export function $<H extends HTMLElement>(element: H, ...args: any[]): $HTMLElement<H>;
|
|
22
|
-
export function $<H extends HTMLElement>(element: H | null | undefined, ...args: any[]): $HTMLElement<H> | null | undefined;
|
|
23
|
-
export function $<E extends Element>(element: E, ...args: any[]): $Element<E>;
|
|
24
|
-
export function $<E extends Element>(element: E | null | undefined, ...args: any[]): $Element<E> | null | undefined;
|
|
25
|
-
export function $<N extends Node | EventTarget>(node: N, ...args: any[]): $Node;
|
|
26
|
-
export function $<N extends Node | EventTarget>(node: N | null | undefined, ...args: any[]): $Node | null | undefined;
|
|
27
|
-
export function $<K extends TemplateStringsArray>(string: K, ...values: any[]): $NodeContentTypes[];
|
|
28
|
-
export function $<K extends keyof HTMLElementTagNameMap, N extends number>(number: N, tagname: K): Repeat<$HTMLElement<HTMLElementTagNameMap[K]>, N>;
|
|
29
|
-
export function $<K extends keyof HTMLElementTagNameMap>(tagname: K): $HTMLElement<HTMLElementTagNameMap[K]>;
|
|
30
|
-
export function $<Ev extends $Event<$Element, Event>>(event: Ev): Ev['currentTarget']['$'];
|
|
31
|
-
export function $<N extends number>(number: N, tagname: string): Repeat<$HTMLElement<HTMLElement>, N>;
|
|
32
|
-
export function $(tagname: string): $HTMLElement<HTMLElement>
|
|
33
|
-
export function $(resolver: string | number | null | undefined | Element | HTMLElement | $Node | Function | TemplateStringsArray | Event | NodeListOf<Node | ChildNode>, ...args: any[]) {
|
|
34
|
-
if (isNull(resolver) || isUndefined(resolver)) return null;
|
|
35
|
-
if (_instanceof(resolver, $Node)) return resolver;
|
|
36
|
-
if (isString(resolver) && nodeNameMap[resolver]) return new nodeNameMap[resolver](...args);
|
|
37
|
-
if (isFunction(resolver))
|
|
38
|
-
if (resolver.prototype?.constructor) return new resolver.prototype.constructor(...args);
|
|
39
|
-
else return resolver(...args);
|
|
40
|
-
if (resolver instanceof Array) {
|
|
41
|
-
const iterate = args.values();
|
|
42
|
-
return resolver.map(str => [str ?? undefined, iterate.next().value]).flat().filter(item => item);
|
|
43
|
-
}
|
|
44
|
-
if (_instanceof(resolver, Node) && _instanceof(resolver.$, $Node)) return resolver.$;
|
|
45
|
-
if (_instanceof(resolver, Event)) return $(resolver.currentTarget as Element);
|
|
46
|
-
if (isNumber(resolver)) return _Array_from({length: resolver}).map(_ => $(args[0], ...args.slice(1)));
|
|
47
|
-
if (_instanceof(resolver, HTMLElement)) return new $HTMLElement(resolver);
|
|
48
|
-
if (_instanceof(resolver, Element)) return new $Element(resolver);
|
|
49
|
-
if (_instanceof(resolver, Node)) return new $Node(resolver as any);
|
|
50
|
-
if (_instanceof(resolver, NodeList)) return _Array_from(resolver).map($)
|
|
51
|
-
return new $HTMLElement(resolver);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export namespace $ {
|
|
55
|
-
export const stylesheet = _stylesheet;
|
|
56
|
-
_document.adoptedStyleSheets.push(_stylesheet);
|
|
57
|
-
export const style = _bind(_stylesheet.insertRule, _stylesheet);
|
|
58
|
-
type SignalProcess<T> = T extends Array<any> ? {} : T extends object ? { [key in keyof T as `${string & key}$`]: SignalFunction<T[key]> } : {};
|
|
59
|
-
export type SignalFunction<T> = {signal: Signal<T>, set: (newValue: T | ((oldValue: T) => T)) => SignalFunction<T>} & (() => T) & SignalProcess<T>;
|
|
60
|
-
export const signal = <T>(value: T): SignalFunction<T> => {
|
|
61
|
-
const signal = new Signal<T>(value);
|
|
62
|
-
const signalFn = function () { return signal.value(); }
|
|
63
|
-
_Object_assign(signalFn, {
|
|
64
|
-
signal,
|
|
65
|
-
set(newValue: T) { return signal.value(newValue), signalFn; }
|
|
66
|
-
})
|
|
67
|
-
if (isObject(value) && !isNull(value)) {
|
|
68
|
-
for (const [key, val] of _Object_entries(value)) {
|
|
69
|
-
const val$ = $.signal(val);
|
|
70
|
-
val$.signal.subscribe(newValue => { value[key as keyof typeof value] = newValue; signal.emit() });
|
|
71
|
-
_Object_defineProperty(signalFn, `${key}$`, {value: val$});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return signalFn as unknown as SignalFunction<T>
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export type ComputeFunction<T> = ({(): T}) & { signal: Signal<T> };
|
|
78
|
-
export const compute = <T>(process: () => T): ComputeFunction<T> => {
|
|
79
|
-
let subscribed = false;
|
|
80
|
-
const signalFn: SignalFunction<any> = signal(_null);
|
|
81
|
-
const computeFn = () => {
|
|
82
|
-
if (!subscribed) return signalFn.set(subscribe())();
|
|
83
|
-
else return signalFn.set(process())();
|
|
84
|
-
}
|
|
85
|
-
const subscribe = () => {
|
|
86
|
-
const signalHandler = (signal: Signal<any>) => {
|
|
87
|
-
signal.subscribe(() => signalFn.set(process()))
|
|
88
|
-
}
|
|
89
|
-
Signal.listeners.add(signalHandler);
|
|
90
|
-
const result = process();
|
|
91
|
-
Signal.listeners.delete(signalHandler);
|
|
92
|
-
subscribed = true;
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
_Object_assign(computeFn, { signal: signalFn.signal });
|
|
96
|
-
return computeFn as ComputeFunction<T>
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
type assign = {
|
|
100
|
-
(resolver: [nodeName: string, $node: Constructor<$Node>][]): $;
|
|
101
|
-
(nodeName: string, $node: Constructor<$Node>): $;
|
|
102
|
-
}
|
|
103
|
-
export const assign: assign = (resolver: string | [nodeName: string, $node: Constructor<$Node>][], $node?: Constructor<$Node>) => {
|
|
104
|
-
if (isString(resolver)) $node && (nodeNameMap[resolver] = $node);
|
|
105
|
-
else forEach(resolver, ([nodeName, $node]) => nodeNameMap[nodeName] = $node);
|
|
106
|
-
return $;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export const span = (content: string) => $('span').content(content);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export type $ = typeof $;
|
|
113
|
-
globalThis.$ = $;
|
|
114
|
-
_Object_assign($, {toArray})
|
package/src/index.ts
DELETED
package/src/lib/assign.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Signal } from "../structure/Signal";
|
|
2
|
-
import { _instanceof, _Object_defineProperty, forEach, isUndefined } from "./native";
|
|
3
|
-
|
|
4
|
-
export const assign = (target: any, {set, get, fn}: {
|
|
5
|
-
set?: string[],
|
|
6
|
-
get?: string[],
|
|
7
|
-
fn?: string[]
|
|
8
|
-
}) => {
|
|
9
|
-
const [GET, SET, FN] = ['get', 'set', 'fn'] as const;
|
|
10
|
-
const filterAndMap = (type: 'get' | 'set' | 'fn', arr: string[] | undefined) => arr?.map(prop => [type, prop]) ?? []
|
|
11
|
-
const list = [...filterAndMap(GET, get), ...filterAndMap(SET, set), ...filterAndMap(FN, fn)] as [string, string][];
|
|
12
|
-
forEach(list, ([type, prop]) =>
|
|
13
|
-
_Object_defineProperty(target.prototype, prop, {
|
|
14
|
-
...(type === GET ? {
|
|
15
|
-
get() { return this.node[prop as any] }
|
|
16
|
-
} : {
|
|
17
|
-
writable: true,
|
|
18
|
-
...(type === SET ? {
|
|
19
|
-
// set
|
|
20
|
-
value(this, args: any) {
|
|
21
|
-
if (!arguments.length) return this.node[prop];
|
|
22
|
-
let set = (value: any) => !isUndefined(value) && (this.node[prop] = value);
|
|
23
|
-
if (_instanceof(args, Signal)) args = args.subscribe(set).value();
|
|
24
|
-
set(args)
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
} : {
|
|
28
|
-
// fn
|
|
29
|
-
value(this, ...args : any[]) {
|
|
30
|
-
let result = this.node[prop](...args)
|
|
31
|
-
return isUndefined(result) ? this : result;
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}),
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
)
|
|
38
|
-
}
|
package/src/lib/assignHelper.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { $Node } from "#node/$Node";
|
|
2
|
-
import { assign } from "./assign";
|
|
3
|
-
import { _Object_entries, _Object_getOwnPropertyDescriptors, forEach } from "./native";
|
|
4
|
-
|
|
5
|
-
export const assignHelper = (object: Constructor<EventTarget>, target: Constructor<$Node>, tagname?: string) => {
|
|
6
|
-
const [set, get, fn] = [[], [], []] as [string[], string[], string[]]
|
|
7
|
-
// assign native object properties to target
|
|
8
|
-
forEach(_Object_entries(_Object_getOwnPropertyDescriptors(object.prototype)), ([prop, value]) => {
|
|
9
|
-
if (!(prop in target.prototype)) {
|
|
10
|
-
if (value.get && !value.set) get.push(prop);
|
|
11
|
-
else if (value.value) fn.push(prop);
|
|
12
|
-
else if (value.get && value.set) set.push(prop);
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
assign(target, {set, get, fn})
|
|
16
|
-
// register tagname
|
|
17
|
-
if (tagname) $.assign(tagname, target)
|
|
18
|
-
}
|
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/native.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Value
|
|
2
|
-
export const _null = null;
|
|
3
|
-
export const _undefined = undefined;
|
|
4
|
-
// Object
|
|
5
|
-
export const _Object_fromEntries = Object.fromEntries;
|
|
6
|
-
export const _Object_entries = Object.entries;
|
|
7
|
-
export const _Object_assign = Object.assign;
|
|
8
|
-
export const _Object_values = Object.values;
|
|
9
|
-
export const _Object_defineProperty = Object.defineProperty;
|
|
10
|
-
export const _Object_getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors;
|
|
11
|
-
// Array
|
|
12
|
-
export const _Array_from = Array.from;
|
|
13
|
-
export const forEach: forEach = <T>(arr: any, fn: any, thisArgs?: any) => arr.forEach(fn, thisArgs);
|
|
14
|
-
// type check
|
|
15
|
-
export const _typeof = (target: any, type: 'string' | 'number' | 'object' | 'boolean' | 'function' | 'bigint' | 'symbol' | 'undefined') => typeof target === type;
|
|
16
|
-
export const equal = <T, V extends T>(target: T, ...args: V[]): target is V => !!args.find(a => a === target);
|
|
17
|
-
export const isString = (target: any): target is string => _typeof(target, 'string');
|
|
18
|
-
export const isBoolean = (target: any): target is boolean => _typeof(target, 'boolean');
|
|
19
|
-
export const isNumber = (target: any): target is number => _typeof(target, 'number');
|
|
20
|
-
export const isObject = (target: any): target is object => _typeof(target, 'object');
|
|
21
|
-
export const isFunction = (target: any): target is Function => _typeof(target, 'function');
|
|
22
|
-
export const isUndefined = (target: any): target is undefined => target === undefined;
|
|
23
|
-
export const isNull = (target: any): target is null => target === _null;
|
|
24
|
-
export const isArray = Array.isArray;
|
|
25
|
-
export const _instanceof = <T extends (abstract new (...args: any[]) => any)[]>(target: any, ...instance: T): target is InstanceType<T[number]> => !!instance.find(i => target instanceof i);
|
|
26
|
-
// JSON
|
|
27
|
-
export const _JSON_stringify = JSON.stringify;
|
|
28
|
-
export const _JSON_parse = JSON.parse;
|
|
29
|
-
// String
|
|
30
|
-
export const startsWith = (target: string, ...str: string[]) => !!str.find(s => target.startsWith(s));
|
|
31
|
-
// Function
|
|
32
|
-
export const _bind = (target: Function, obj: Object) => target.bind(obj);
|
|
33
|
-
interface forEach {
|
|
34
|
-
<T>(arr: Array<T>, fn: (value: T, index: number, array: Array<T>) => any, thisArgs?: any): void;
|
|
35
|
-
<T>(set: Set<T>, fn: (value: T, index: number, set: Set<T>) => any, thisArgs?: any): void;
|
|
36
|
-
<K, V>(set: Map<K, V>, fn: (value: V, key: K, index: number, map: Map<K, V>) => any, thisArgs?: any): void;
|
|
37
|
-
<N extends Node>(set: NodeListOf<N>, fn: (value: N, index: number, parent: NodeListOf<N>) => any, thisArgs?: any): void;
|
|
38
|
-
}
|
|
39
|
-
// Promise
|
|
40
|
-
export const _Promise = Promise;
|
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/node.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { $HTMLElement } from '#node/$HTMLElement';
|
|
2
|
-
import { assignHelper } from '#lib/assignHelper';
|
|
3
|
-
import { $Element } from '#node/$Element';
|
|
4
|
-
import { $Node, $Text } from '#node/$Node';
|
|
5
|
-
|
|
6
|
-
assignHelper(EventTarget, $Node);
|
|
7
|
-
assignHelper(Node, $Node);
|
|
8
|
-
assignHelper(Text, $Text);
|
|
9
|
-
assignHelper(Element, $Element);
|
|
10
|
-
assignHelper(HTMLElement, $HTMLElement);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|