solarite 0.5.2 → 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/LICENSE +21 -0
- package/dist/Solarite-debug.js +2823 -1856
- package/dist/Solarite.js +2779 -1824
- package/dist/Solarite.min.js +2 -4
- package/package.json +16 -3
- package/readme.md +58 -11
- package/src/Globals.js +54 -72
- package/src/HtmlParser.js +90 -90
- package/src/MultiValueMap.js +57 -105
- package/src/NodeGroup.js +624 -470
- package/src/Path.js +224 -211
- package/src/PathToAttribValue.js +401 -261
- package/src/PathToAttribs.js +113 -80
- package/src/PathToComment.js +7 -7
- package/src/PathToComponent.js +183 -188
- package/src/PathToEvent.js +76 -64
- package/src/PathToKey.js +19 -0
- package/src/PathToNodes.js +1053 -566
- package/src/RootNodeGroup.js +120 -8
- package/src/Shell.js +570 -348
- package/src/Solarite.d.ts +134 -113
- package/src/Solarite.js +243 -286
- package/src/Template.js +195 -274
- package/src/Util.js +353 -351
- package/src/assert.js +10 -10
- package/src/assignAttributes.js +63 -0
- package/src/delve.js +55 -43
- package/src/h.js +220 -138
- package/src/jsx-dev-runtime.d.ts +1 -0
- package/src/jsx-dev-runtime.js +5 -0
- package/src/jsx-runtime.d.ts +21 -0
- package/src/jsx-runtime.js +84 -0
- package/src/jsx.js +194 -0
- package/src/toEl.js +77 -82
- package/dist/udomdiff-license.txt +0 -18
- package/src/getArg.js +0 -137
- package/src/hash.js +0 -89
- package/src/udomdiff.js +0 -176
- package/src/unused/FastLookupArray.js +0 -54
- package/src/unused/Hashes.js +0 -339
- package/src/unused/InUse.test.js +0 -92
- package/src/unused/InUseMap.js +0 -98
- package/src/unused/LinkedList.js +0 -117
- package/src/unused/LinkedList.test.js +0 -115
- package/src/unused/Misc.js +0 -13
- package/src/unused/Perf.js +0 -47
- package/src/unused/TrackedArray.js +0 -54
- package/src/unused/WeakArray.js +0 -33
- package/src/watch.js +0 -543
package/src/Solarite.d.ts
CHANGED
|
@@ -1,113 +1,134 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Solarite JavaScript UI library.
|
|
3
|
-
* MIT License
|
|
4
|
-
* https://vorticode.github.io/solarite/
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export interface RenderOptions {
|
|
8
|
-
styles?: boolean;
|
|
9
|
-
scripts?: boolean;
|
|
10
|
-
ids?: boolean;
|
|
11
|
-
render?: boolean;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Solarite JavaScript UI library.
|
|
3
|
+
* MIT License
|
|
4
|
+
* https://vorticode.github.io/solarite/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface RenderOptions {
|
|
8
|
+
styles?: boolean;
|
|
9
|
+
scripts?: boolean;
|
|
10
|
+
ids?: boolean;
|
|
11
|
+
render?: boolean;
|
|
12
|
+
|
|
13
|
+
/** Defaults to true: bubbling events (click, input, etc.) dispatch from one document-level
|
|
14
|
+
* listener instead of addEventListener per element - much faster creation and teardown
|
|
15
|
+
* of large lists. Pass false to bind every event directly, or an array to delegate only
|
|
16
|
+
* the listed event names. Non-bubbling events always bind directly. Note: delegated
|
|
17
|
+
* handlers run when the event reaches the document, so manual stopPropagation() on an
|
|
18
|
+
* ancestor suppresses them, and manually added ancestor listeners fire first. A
|
|
19
|
+
* programmatically dispatched non-bubbling event won't reach delegated handlers. */
|
|
20
|
+
eventDelegation?: boolean | string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Tagged template literal or function for creating Templates and rendering to the DOM.
|
|
25
|
+
*
|
|
26
|
+
* The key attribute is reserved for keyed lists: `h`<tr key=${row.id}>...``
|
|
27
|
+
* It must be a single whole-value expression on a top-level element; DOM node identity
|
|
28
|
+
* then follows the key across re-renders (state preservation, minimal moves).
|
|
29
|
+
* Static or mixed key values throw, and components never receive key as an arg. */
|
|
30
|
+
declare function h(htmlStrings: TemplateStringsArray, ...exprs: any[]): Template;
|
|
31
|
+
declare function h(htmlStrings: string | string[], ...exprs: any[]): Template;
|
|
32
|
+
declare function h(el: HTMLElement | DocumentFragment, options?: RenderOptions): (htmlStrings: TemplateStringsArray, ...exprs: any[]) => HTMLElement | DocumentFragment;
|
|
33
|
+
declare function h(el: HTMLElement | DocumentFragment, template: Template, options?: RenderOptions): void;
|
|
34
|
+
declare function h(tag: string | Function | symbol, props: object | null, ...children: any[]): Template; // JSX classic factory
|
|
35
|
+
declare function h(obj: {render: Function}): (htmlStrings: TemplateStringsArray, ...exprs: any[]) => void; // Rebound render
|
|
36
|
+
declare function h(): (htmlStrings: TemplateStringsArray, ...exprs: any[]) => Node|DocumentFragment;
|
|
37
|
+
|
|
38
|
+
declare namespace h {
|
|
39
|
+
/** Render a list, reusing each item's DOM while the item is the SAME object; replace an item
|
|
40
|
+
* (don't mutate it) to re-render it. fn runs only for new items. No deps: identity is the dep. */
|
|
41
|
+
function map<T>(items:T[], fn:(item:T) => Template): Template[];
|
|
42
|
+
|
|
43
|
+
/** Alias of h.map with a name that flags the immutability contract at the call site. */
|
|
44
|
+
function immutableMap<T>(items:T[], fn:(item:T) => Template): Template[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Tagged template literal for SVG markup and SVG child fragments. */
|
|
48
|
+
declare function svg(htmlStrings: TemplateStringsArray, ...exprs: any[]): Template;
|
|
49
|
+
declare function svg(htmlStrings: string | string[], ...exprs: any[]): Template;
|
|
50
|
+
|
|
51
|
+
export default h;
|
|
52
|
+
export {h, svg};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Solarite provides more features if your web component extends Solarite instead of HTMLElement. */
|
|
56
|
+
export class Solarite extends HTMLElement {
|
|
57
|
+
constructor(attribs?: Record<string, any> | null);
|
|
58
|
+
render(attribs?: Record<string, any>, changed?:boolean): void;
|
|
59
|
+
renderFirstTime(): void;
|
|
60
|
+
connectedCallback(): void;
|
|
61
|
+
static define(tagName?: string | null): void;
|
|
62
|
+
static getAttribs(el: HTMLElement): Record<string, any>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Convert a template, string, or object into a DOM Node or Element. */
|
|
68
|
+
export function toEl(arg: string | Template | {render: () => void}): Node | HTMLElement | DocumentFragment;
|
|
69
|
+
|
|
70
|
+
/** An event binding registered by a two-way or event attribute, dispatchable via handleEvent(). */
|
|
71
|
+
export interface EventBinding {
|
|
72
|
+
handleEvent(event: Event): any;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Get the EventBinding registered for a node+key, or undefined. */
|
|
76
|
+
export function getEventBinding(node: Node, key: string): EventBinding | undefined;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Read an element's html attributes onto fields that already exist on the element, to
|
|
80
|
+
* support plain-html instantiation like `<my-timer duration="7" auto-start>`.
|
|
81
|
+
*
|
|
82
|
+
* Attribute names convert from kebab-case to camelCase. A `${...}` attribute is JSON-parsed
|
|
83
|
+
* back to its original type. Every other attribute value is a string: if its field is named
|
|
84
|
+
* in `types`, the string is cast with that converter, otherwise it's assigned as a string.
|
|
85
|
+
*
|
|
86
|
+
* `types` maps a field name to a converter: Number, Boolean, String, Date, or any function
|
|
87
|
+
* taking the string and returning a value. Boolean is true for any string except 'false'
|
|
88
|
+
* and '0', so a bare attribute reads as true. Field names in `ignore` are skipped. */
|
|
89
|
+
export function assignAttributes(dest: HTMLElement, types?: Record<string, Function>, ignore?: string[]): void;
|
|
90
|
+
|
|
91
|
+
export class Template {
|
|
92
|
+
exprs: any[];
|
|
93
|
+
html: string[];
|
|
94
|
+
/** List key for keyed diffing, set by the JSX runtime from a `key` prop. */
|
|
95
|
+
key?: any;
|
|
96
|
+
constructor(htmlStrings: string[], exprs: any[]);
|
|
97
|
+
render(el?: HTMLElement | null, options?: RenderOptions): HTMLElement | DocumentFragment;
|
|
98
|
+
getCloseKey(): string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** JSX fragment marker for the classic/automatic factories: `<>...</>`. */
|
|
102
|
+
export const Fragment: unique symbol;
|
|
103
|
+
|
|
104
|
+
export function delve(obj: object, path: string[], createVal?: any): any;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Internal utilities and state. */
|
|
108
|
+
export const Globals: {
|
|
109
|
+
connected: WeakSet<HTMLElement>;
|
|
110
|
+
currentSlotChildren: any[] | null;
|
|
111
|
+
div: HTMLDivElement;
|
|
112
|
+
doc: Document;
|
|
113
|
+
elementClasses: {[key: string]: typeof Node};
|
|
114
|
+
htmlProps: {[key: string]: boolean};
|
|
115
|
+
rootNodeGroups: WeakMap<HTMLElement, any>;
|
|
116
|
+
objToEl: WeakMap<any, any>;
|
|
117
|
+
rendered: WeakSet<HTMLElement>;
|
|
118
|
+
shells: WeakMap<string[], any>;
|
|
119
|
+
reset: Function;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const SolariteUtil: {
|
|
123
|
+
arraySame(a: any[], b: any[]): boolean;
|
|
124
|
+
attribsToObject(el: HTMLElement, ignore?: string | null): Record<string, any>;
|
|
125
|
+
bindId(root: any, el: HTMLElement): void;
|
|
126
|
+
bindStyles(style: HTMLStyleElement, root: HTMLElement): void;
|
|
127
|
+
camelToDashes(str: string): string;
|
|
128
|
+
dashesToCamel(str: string): string;
|
|
129
|
+
defineClass(Class: typeof HTMLElement, tagName?: string | null): void;
|
|
130
|
+
isIterable(obj: any): boolean;
|
|
131
|
+
trimEmptyNodes(nodes: NodeList | Node[]): Node[];
|
|
132
|
+
[key: string]: any;
|
|
133
|
+
};
|
|
134
|
+
|