@simpreact/simpreact 0.0.0-alpha.1f6ee65 → 0.0.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/core/createElement.d.ts +22 -15
- package/core/createElement.js +67 -23
- package/core/hostAdapter.d.ts +17 -7
- package/core/hostAdapter.js +4 -1
- package/core/index.d.ts +68 -3
- package/core/index.js +6 -3
- package/core/internal.d.ts +6 -3
- package/core/internal.js +6 -3
- package/core/lifecycleEventBus.d.ts +26 -0
- package/core/lifecycleEventBus.js +2 -0
- package/core/mounting.d.ts +9 -8
- package/core/mounting.js +87 -50
- package/core/patching.d.ts +6 -4
- package/core/patching.js +150 -162
- package/core/portal.d.ts +2 -0
- package/core/portal.js +9 -0
- package/core/ref.d.ts +17 -0
- package/core/ref.js +27 -0
- package/core/rerender.d.ts +11 -0
- package/core/rerender.js +61 -3
- package/core/unmounting.d.ts +2 -4
- package/core/unmounting.js +26 -27
- package/dom/attach-element-to-dom.d.ts +4 -0
- package/dom/attach-element-to-dom.js +9 -0
- package/dom/domAdapter.d.ts +3 -2
- package/dom/domAdapter.js +37 -113
- package/dom/events.d.ts +19 -0
- package/dom/events.js +129 -0
- package/dom/index.d.ts +1733 -1
- package/dom/index.js +2 -0
- package/dom/namespace.d.ts +2 -0
- package/dom/namespace.js +1 -0
- package/dom/props/controlled/index.d.ts +7 -0
- package/dom/props/controlled/index.js +51 -0
- package/dom/props/controlled/input.d.ts +7 -0
- package/dom/props/controlled/input.js +80 -0
- package/dom/props/controlled/select.d.ts +6 -0
- package/dom/props/controlled/select.js +76 -0
- package/dom/props/controlled/textarea.d.ts +6 -0
- package/dom/props/controlled/textarea.js +61 -0
- package/dom/props/dangerInnerHTML.d.ts +7 -0
- package/dom/props/dangerInnerHTML.js +24 -0
- package/dom/props/index.d.ts +1 -0
- package/dom/props/index.js +1 -0
- package/dom/props/props.d.ts +5 -0
- package/dom/props/props.js +197 -0
- package/dom/props/style.d.ts +1 -0
- package/dom/props/style.js +32 -0
- package/dom/render.d.ts +2 -2
- package/dom/render.js +31 -19
- package/hooks/index.d.ts +23 -12
- package/hooks/index.js +123 -29
- package/jsx-runtime/index.d.ts +247 -4
- package/jsx-runtime/index.js +2 -5
- package/package.json +22 -15
- package/shared/index.d.ts +19 -4
- package/shared/index.js +5 -4
- package/shared/lang.d.ts +3 -3
- package/shared/lang.js +3 -3
- package/shared/utils.d.ts +3 -2
- package/shared/utils.js +3 -6
- package/core/global.d.ts +0 -21
- package/core/global.js +0 -5
- package/shared/types.d.ts +0 -8
- package/shared/types.js +0 -1
package/hooks/index.d.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import type { SimpContext } from '../core';
|
|
2
|
-
|
|
3
|
-
type Cleanup =
|
|
4
|
-
type Effect = () => void | Cleanup;
|
|
5
|
-
type DependencyList = readonly unknown[];
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import type { RefObject, SimpContext } from '../core';
|
|
2
|
+
|
|
3
|
+
export type Cleanup = () => void;
|
|
4
|
+
export type Effect = () => void | Cleanup;
|
|
5
|
+
export type DependencyList = readonly unknown[];
|
|
6
|
+
|
|
7
|
+
declare function useRef<T>(initialValue: T): RefObject<T>;
|
|
8
|
+
declare function useRef<T>(initialValue: T | null): RefObject<T | null>;
|
|
9
|
+
declare function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
|
|
10
|
+
|
|
11
|
+
declare function useRerender(): () => void;
|
|
12
|
+
|
|
13
|
+
declare function useEffect(effect: Effect, deps?: DependencyList): void;
|
|
14
|
+
|
|
15
|
+
declare function useMounted(effect: Effect): void;
|
|
16
|
+
|
|
17
|
+
declare function useUnmounted(cleanup: Cleanup): void;
|
|
18
|
+
|
|
19
|
+
declare function useContext<T>(context: SimpContext<T>): T;
|
|
20
|
+
|
|
21
|
+
declare function useCatch(cb: (error: any) => void): void;
|
|
22
|
+
|
|
23
|
+
declare function areDepsEqual(nextDeps: DependencyList | undefined, prevDeps: DependencyList | undefined): boolean;
|
package/hooks/index.js
CHANGED
|
@@ -1,61 +1,136 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { lifecycleEventBus, rerender, syncRerenderLocker } from '../core/internal.js';
|
|
2
|
+
import { noop } from '../shared';
|
|
2
3
|
let currentIndex = 0;
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
// In runtime this is a nullable variable.
|
|
5
|
+
let currentElement;
|
|
6
|
+
lifecycleEventBus.subscribe(event => {
|
|
5
7
|
if (event.type === 'beforeRender') {
|
|
6
8
|
currentElement = event.element;
|
|
7
|
-
currentElement.store
|
|
8
|
-
|
|
9
|
+
if (currentElement.store?.catchHandlers) {
|
|
10
|
+
currentElement.store.catchHandlers = undefined;
|
|
11
|
+
}
|
|
9
12
|
}
|
|
10
|
-
if (event.type === 'afterRender') {
|
|
13
|
+
if (event.type === 'afterRender' || event.type === 'errored') {
|
|
11
14
|
currentElement = null;
|
|
12
15
|
currentIndex = 0;
|
|
13
16
|
}
|
|
14
17
|
if (event.type === 'mounted') {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const element = event.element;
|
|
19
|
+
if (element.store?.effectsHookStates) {
|
|
20
|
+
syncRerenderLocker.lock();
|
|
21
|
+
const effects = element.store.effectsHookStates;
|
|
22
|
+
element.store.effectsHookStates = undefined;
|
|
23
|
+
for (const state of effects) {
|
|
24
|
+
state.cleanup = state.effect() || undefined;
|
|
25
|
+
}
|
|
26
|
+
syncRerenderLocker.flush();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (event.type === 'updated') {
|
|
30
|
+
const element = event.element;
|
|
31
|
+
if (element.store?.effectsHookStates) {
|
|
32
|
+
syncRerenderLocker.lock();
|
|
33
|
+
const effects = element.store.effectsHookStates;
|
|
34
|
+
element.store.effectsHookStates = undefined;
|
|
35
|
+
for (const state of effects) {
|
|
36
|
+
if (typeof state.cleanup === 'function') {
|
|
37
|
+
state.cleanup();
|
|
38
|
+
}
|
|
39
|
+
state.cleanup = state.effect() || undefined;
|
|
18
40
|
}
|
|
19
|
-
|
|
41
|
+
syncRerenderLocker.flush();
|
|
20
42
|
}
|
|
21
43
|
}
|
|
22
44
|
if (event.type === 'unmounted') {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
45
|
+
const element = event.element;
|
|
46
|
+
if (element.store?.hookStates) {
|
|
47
|
+
for (const state of element.store.hookStates) {
|
|
48
|
+
if (state && 'cleanup' in state && typeof state.cleanup === 'function') {
|
|
49
|
+
state.cleanup();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (event.type === 'errored') {
|
|
55
|
+
const element = findElementWithCatchHandlers(event.element);
|
|
56
|
+
if (!element) {
|
|
57
|
+
throw new Error('Error occurred during rendering a component', { cause: event.error });
|
|
58
|
+
}
|
|
59
|
+
if (element.store.catchHandlers) {
|
|
60
|
+
syncRerenderLocker.lock();
|
|
61
|
+
for (const state of element.store.catchHandlers) {
|
|
62
|
+
state(event.error);
|
|
26
63
|
}
|
|
64
|
+
syncRerenderLocker.flush();
|
|
27
65
|
}
|
|
28
66
|
}
|
|
29
67
|
});
|
|
68
|
+
function findElementWithCatchHandlers(element) {
|
|
69
|
+
let temp = element;
|
|
70
|
+
while (temp != null) {
|
|
71
|
+
if (temp.store?.catchHandlers) {
|
|
72
|
+
return temp;
|
|
73
|
+
}
|
|
74
|
+
temp = temp.parent;
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
30
78
|
export function useRef(initialValue) {
|
|
31
|
-
|
|
79
|
+
const hookStates = getOrCreateHookStates(currentElement);
|
|
80
|
+
if (!hookStates[currentIndex]) {
|
|
81
|
+
hookStates[currentIndex] = { current: initialValue };
|
|
82
|
+
}
|
|
83
|
+
return hookStates[currentIndex++];
|
|
32
84
|
}
|
|
33
85
|
export function useRerender() {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
state.element = currentElement;
|
|
41
|
-
return state.fn;
|
|
86
|
+
const hookStates = getOrCreateHookStates(currentElement);
|
|
87
|
+
if (!hookStates[currentIndex]) {
|
|
88
|
+
const elementStore = currentElement.store;
|
|
89
|
+
hookStates[currentIndex] = () => rerender(elementStore.latestElement);
|
|
90
|
+
}
|
|
91
|
+
return hookStates[currentIndex++];
|
|
42
92
|
}
|
|
43
93
|
export function useEffect(effect, deps) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
94
|
+
const hookStates = getOrCreateHookStates(currentElement);
|
|
95
|
+
let state = hookStates[currentIndex];
|
|
96
|
+
if (!state) {
|
|
97
|
+
state = hookStates[currentIndex] = { effect };
|
|
98
|
+
}
|
|
49
99
|
if (!areDepsEqual(deps, state.deps)) {
|
|
50
100
|
state.effect = effect;
|
|
51
101
|
state.deps = deps;
|
|
52
|
-
currentElement.
|
|
102
|
+
getOrCreateEffectHookStates(currentElement).push(state);
|
|
53
103
|
}
|
|
104
|
+
currentIndex++;
|
|
105
|
+
}
|
|
106
|
+
export function useMounted(effect) {
|
|
107
|
+
const hookStates = getOrCreateHookStates(currentElement);
|
|
108
|
+
if (!hookStates[currentIndex]) {
|
|
109
|
+
hookStates[currentIndex] = { effect };
|
|
110
|
+
getOrCreateEffectHookStates(currentElement).push(hookStates[currentIndex]);
|
|
111
|
+
}
|
|
112
|
+
currentIndex++;
|
|
113
|
+
}
|
|
114
|
+
export function useUnmounted(cleanup) {
|
|
115
|
+
const hookStates = getOrCreateHookStates(currentElement);
|
|
116
|
+
if (!hookStates[currentIndex]) {
|
|
117
|
+
hookStates[currentIndex] = { cleanup, effect: noop };
|
|
118
|
+
}
|
|
119
|
+
currentIndex++;
|
|
54
120
|
}
|
|
55
121
|
export function useContext(context) {
|
|
56
122
|
return currentElement.contextMap?.get(context) ?? context.defaultValue;
|
|
57
123
|
}
|
|
58
|
-
function
|
|
124
|
+
export function useCatch(cb) {
|
|
125
|
+
if (!currentElement.store) {
|
|
126
|
+
currentElement.store = {};
|
|
127
|
+
}
|
|
128
|
+
if (!currentElement.store.catchHandlers) {
|
|
129
|
+
currentElement.store.catchHandlers = [];
|
|
130
|
+
}
|
|
131
|
+
currentElement.store.catchHandlers.push(cb);
|
|
132
|
+
}
|
|
133
|
+
export function areDepsEqual(nextDeps, prevDeps) {
|
|
59
134
|
if (nextDeps == null || prevDeps == null || nextDeps.length !== prevDeps.length) {
|
|
60
135
|
return false;
|
|
61
136
|
}
|
|
@@ -66,3 +141,22 @@ function areDepsEqual(nextDeps, prevDeps) {
|
|
|
66
141
|
}
|
|
67
142
|
return true;
|
|
68
143
|
}
|
|
144
|
+
function getOrCreateHookStates(element) {
|
|
145
|
+
if (!element.store) {
|
|
146
|
+
element.store = {};
|
|
147
|
+
}
|
|
148
|
+
if (!element.store.hookStates) {
|
|
149
|
+
element.store.hookStates = [];
|
|
150
|
+
}
|
|
151
|
+
return element.store.hookStates;
|
|
152
|
+
}
|
|
153
|
+
function getOrCreateEffectHookStates(element) {
|
|
154
|
+
if (!element.store) {
|
|
155
|
+
element.store = {};
|
|
156
|
+
}
|
|
157
|
+
if (!element.store.effectsHookStates) {
|
|
158
|
+
element.store.effectsHookStates = [];
|
|
159
|
+
}
|
|
160
|
+
return element.store.effectsHookStates;
|
|
161
|
+
}
|
|
162
|
+
export default { useRef, useRerender, useEffect, useMounted, useUnmounted, useContext, useCatch, areDepsEqual };
|
package/jsx-runtime/index.d.ts
CHANGED
|
@@ -1,7 +1,250 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { Fragment } from '../core';
|
|
1
|
+
import type { FC, Fragment as FragmentType, Key, SimpElement } from '../core';
|
|
3
2
|
import type { Maybe } from '../shared';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
3
|
+
import type {
|
|
4
|
+
AnchorHTMLAttributes,
|
|
5
|
+
AreaHTMLAttributes,
|
|
6
|
+
AudioHTMLAttributes,
|
|
7
|
+
BaseHTMLAttributes,
|
|
8
|
+
BlockquoteHTMLAttributes,
|
|
9
|
+
ButtonHTMLAttributes,
|
|
10
|
+
CanvasHTMLAttributes,
|
|
11
|
+
ColgroupHTMLAttributes,
|
|
12
|
+
ColHTMLAttributes,
|
|
13
|
+
DataHTMLAttributes,
|
|
14
|
+
DelHTMLAttributes,
|
|
15
|
+
DetailedHTMLProps,
|
|
16
|
+
DetailsHTMLAttributes,
|
|
17
|
+
DialogHTMLAttributes,
|
|
18
|
+
EmbedHTMLAttributes,
|
|
19
|
+
FieldsetHTMLAttributes,
|
|
20
|
+
FormHTMLAttributes,
|
|
21
|
+
HTMLAttributes,
|
|
22
|
+
HtmlHTMLAttributes,
|
|
23
|
+
IframeHTMLAttributes,
|
|
24
|
+
ImgHTMLAttributes,
|
|
25
|
+
InputHTMLAttributes,
|
|
26
|
+
InsHTMLAttributes,
|
|
27
|
+
KeygenHTMLAttributes,
|
|
28
|
+
LabelHTMLAttributes,
|
|
29
|
+
LiHTMLAttributes,
|
|
30
|
+
LinkHTMLAttributes,
|
|
31
|
+
MapHTMLAttributes,
|
|
32
|
+
MenuHTMLAttributes,
|
|
33
|
+
MetaHTMLAttributes,
|
|
34
|
+
MeterHTMLAttributes,
|
|
35
|
+
ObjectHTMLAttributes,
|
|
36
|
+
OlHTMLAttributes,
|
|
37
|
+
OptgroupHTMLAttributes,
|
|
38
|
+
OptionHTMLAttributes,
|
|
39
|
+
OutputHTMLAttributes,
|
|
40
|
+
ParamHTMLAttributes,
|
|
41
|
+
ProgressHTMLAttributes,
|
|
42
|
+
QuoteHTMLAttributes,
|
|
43
|
+
ScriptHTMLAttributes,
|
|
44
|
+
SelectHTMLAttributes,
|
|
45
|
+
SlotHTMLAttributes,
|
|
46
|
+
SourceHTMLAttributes,
|
|
47
|
+
StyleHTMLAttributes,
|
|
48
|
+
SVGProps,
|
|
49
|
+
TableHTMLAttributes,
|
|
50
|
+
TdHTMLAttributes,
|
|
51
|
+
TextareaHTMLAttributes,
|
|
52
|
+
ThHTMLAttributes,
|
|
53
|
+
TimeHTMLAttributes,
|
|
54
|
+
TrackHTMLAttributes,
|
|
55
|
+
VideoHTMLAttributes,
|
|
56
|
+
WebViewHTMLAttributes,
|
|
57
|
+
} from '../dom';
|
|
58
|
+
|
|
59
|
+
declare function jsx<P = {}>(type: string | FC<P>, props?: P, key?: Maybe<Key>): SimpElement<P>;
|
|
60
|
+
|
|
61
|
+
type Fragment = FragmentType;
|
|
62
|
+
|
|
6
63
|
export { jsx as jsxs, jsx as jsxDEV };
|
|
7
64
|
export { Fragment };
|
|
65
|
+
|
|
66
|
+
declare global {
|
|
67
|
+
namespace JSX {
|
|
68
|
+
interface IntrinsicElements {
|
|
69
|
+
// HTML
|
|
70
|
+
a: DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
71
|
+
abbr: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
72
|
+
address: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
73
|
+
area: DetailedHTMLProps<AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>;
|
|
74
|
+
article: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
75
|
+
aside: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
76
|
+
audio: DetailedHTMLProps<AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>;
|
|
77
|
+
b: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
78
|
+
base: DetailedHTMLProps<BaseHTMLAttributes<HTMLBaseElement>, HTMLBaseElement>;
|
|
79
|
+
bdi: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
80
|
+
bdo: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
81
|
+
big: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
82
|
+
blockquote: DetailedHTMLProps<BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
|
|
83
|
+
body: DetailedHTMLProps<HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>;
|
|
84
|
+
br: DetailedHTMLProps<HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
|
|
85
|
+
button: DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
|
|
86
|
+
canvas: DetailedHTMLProps<CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
|
|
87
|
+
caption: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
88
|
+
center: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
89
|
+
cite: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
90
|
+
code: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
91
|
+
col: DetailedHTMLProps<ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
|
|
92
|
+
colgroup: DetailedHTMLProps<ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
|
|
93
|
+
data: DetailedHTMLProps<DataHTMLAttributes<HTMLDataElement>, HTMLDataElement>;
|
|
94
|
+
datalist: DetailedHTMLProps<HTMLAttributes<HTMLDataListElement>, HTMLDataListElement>;
|
|
95
|
+
dd: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
96
|
+
del: DetailedHTMLProps<DelHTMLAttributes<HTMLModElement>, HTMLModElement>;
|
|
97
|
+
details: DetailedHTMLProps<DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>;
|
|
98
|
+
dfn: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
99
|
+
dialog: DetailedHTMLProps<DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>;
|
|
100
|
+
div: DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
101
|
+
dl: DetailedHTMLProps<HTMLAttributes<HTMLDListElement>, HTMLDListElement>;
|
|
102
|
+
dt: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
103
|
+
em: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
104
|
+
embed: DetailedHTMLProps<EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement>;
|
|
105
|
+
fieldset: DetailedHTMLProps<FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>;
|
|
106
|
+
figcaption: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
107
|
+
figure: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
108
|
+
footer: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
109
|
+
form: DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
|
|
110
|
+
h1: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
111
|
+
h2: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
112
|
+
h3: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
113
|
+
h4: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
114
|
+
h5: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
115
|
+
h6: DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
116
|
+
head: DetailedHTMLProps<HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>;
|
|
117
|
+
header: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
118
|
+
hgroup: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
119
|
+
hr: DetailedHTMLProps<HTMLAttributes<HTMLHRElement>, HTMLHRElement>;
|
|
120
|
+
html: DetailedHTMLProps<HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>;
|
|
121
|
+
i: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
122
|
+
iframe: DetailedHTMLProps<IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
|
|
123
|
+
img: DetailedHTMLProps<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
|
|
124
|
+
input: DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
125
|
+
ins: DetailedHTMLProps<InsHTMLAttributes<HTMLModElement>, HTMLModElement>;
|
|
126
|
+
kbd: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
127
|
+
keygen: DetailedHTMLProps<KeygenHTMLAttributes<HTMLElement>, HTMLElement>;
|
|
128
|
+
label: DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
|
|
129
|
+
legend: DetailedHTMLProps<HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>;
|
|
130
|
+
li: DetailedHTMLProps<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
|
|
131
|
+
link: DetailedHTMLProps<LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>;
|
|
132
|
+
main: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
133
|
+
map: DetailedHTMLProps<MapHTMLAttributes<HTMLMapElement>, HTMLMapElement>;
|
|
134
|
+
mark: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
135
|
+
menu: DetailedHTMLProps<MenuHTMLAttributes<HTMLElement>, HTMLElement>;
|
|
136
|
+
menuitem: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
137
|
+
meta: DetailedHTMLProps<MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
|
|
138
|
+
meter: DetailedHTMLProps<MeterHTMLAttributes<HTMLMeterElement>, HTMLMeterElement>;
|
|
139
|
+
nav: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
140
|
+
noindex: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
141
|
+
noscript: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
142
|
+
object: DetailedHTMLProps<ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>;
|
|
143
|
+
ol: DetailedHTMLProps<OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>;
|
|
144
|
+
optgroup: DetailedHTMLProps<OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
|
|
145
|
+
option: DetailedHTMLProps<OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
|
|
146
|
+
output: DetailedHTMLProps<OutputHTMLAttributes<HTMLOutputElement>, HTMLOutputElement>;
|
|
147
|
+
p: DetailedHTMLProps<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
|
|
148
|
+
param: DetailedHTMLProps<ParamHTMLAttributes<HTMLParamElement>, HTMLParamElement>;
|
|
149
|
+
picture: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
150
|
+
pre: DetailedHTMLProps<HTMLAttributes<HTMLPreElement>, HTMLPreElement>;
|
|
151
|
+
progress: DetailedHTMLProps<ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement>;
|
|
152
|
+
q: DetailedHTMLProps<QuoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
|
|
153
|
+
rp: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
154
|
+
rt: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
155
|
+
ruby: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
156
|
+
s: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
157
|
+
samp: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
158
|
+
search: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
159
|
+
slot: DetailedHTMLProps<SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement>;
|
|
160
|
+
script: DetailedHTMLProps<ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>;
|
|
161
|
+
section: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
162
|
+
select: DetailedHTMLProps<SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
|
|
163
|
+
small: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
164
|
+
source: DetailedHTMLProps<SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement>;
|
|
165
|
+
span: DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
|
|
166
|
+
strong: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
167
|
+
style: DetailedHTMLProps<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;
|
|
168
|
+
sub: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
169
|
+
summary: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
170
|
+
sup: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
171
|
+
table: DetailedHTMLProps<TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>;
|
|
172
|
+
template: DetailedHTMLProps<HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement>;
|
|
173
|
+
tbody: DetailedHTMLProps<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
|
|
174
|
+
td: DetailedHTMLProps<TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>;
|
|
175
|
+
textarea: DetailedHTMLProps<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
|
|
176
|
+
tfoot: DetailedHTMLProps<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
|
|
177
|
+
th: DetailedHTMLProps<ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>;
|
|
178
|
+
thead: DetailedHTMLProps<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
|
|
179
|
+
time: DetailedHTMLProps<TimeHTMLAttributes<HTMLTimeElement>, HTMLTimeElement>;
|
|
180
|
+
title: DetailedHTMLProps<HTMLAttributes<HTMLTitleElement>, HTMLTitleElement>;
|
|
181
|
+
tr: DetailedHTMLProps<HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
|
|
182
|
+
track: DetailedHTMLProps<TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement>;
|
|
183
|
+
u: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
184
|
+
ul: DetailedHTMLProps<HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
|
|
185
|
+
var: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
186
|
+
video: DetailedHTMLProps<VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
|
|
187
|
+
wbr: DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
188
|
+
webview: DetailedHTMLProps<WebViewHTMLAttributes<HTMLElement>, HTMLElement>;
|
|
189
|
+
|
|
190
|
+
// SVG
|
|
191
|
+
svg: SVGProps<SVGSVGElement>;
|
|
192
|
+
|
|
193
|
+
circle: SVGProps<SVGCircleElement>;
|
|
194
|
+
clipPath: SVGProps<SVGClipPathElement>;
|
|
195
|
+
defs: SVGProps<SVGDefsElement>;
|
|
196
|
+
desc: SVGProps<SVGDescElement>;
|
|
197
|
+
ellipse: SVGProps<SVGEllipseElement>;
|
|
198
|
+
feBlend: SVGProps<SVGFEBlendElement>;
|
|
199
|
+
feColorMatrix: SVGProps<SVGFEColorMatrixElement>;
|
|
200
|
+
feComponentTransfer: SVGProps<SVGFEComponentTransferElement>;
|
|
201
|
+
feComposite: SVGProps<SVGFECompositeElement>;
|
|
202
|
+
feConvolveMatrix: SVGProps<SVGFEConvolveMatrixElement>;
|
|
203
|
+
feDiffuseLighting: SVGProps<SVGFEDiffuseLightingElement>;
|
|
204
|
+
feDisplacementMap: SVGProps<SVGFEDisplacementMapElement>;
|
|
205
|
+
feDistantLight: SVGProps<SVGFEDistantLightElement>;
|
|
206
|
+
feDropShadow: SVGProps<SVGFEDropShadowElement>;
|
|
207
|
+
feFlood: SVGProps<SVGFEFloodElement>;
|
|
208
|
+
feFuncA: SVGProps<SVGFEFuncAElement>;
|
|
209
|
+
feFuncB: SVGProps<SVGFEFuncBElement>;
|
|
210
|
+
feFuncG: SVGProps<SVGFEFuncGElement>;
|
|
211
|
+
feFuncR: SVGProps<SVGFEFuncRElement>;
|
|
212
|
+
feGaussianBlur: SVGProps<SVGFEGaussianBlurElement>;
|
|
213
|
+
feImage: SVGProps<SVGFEImageElement>;
|
|
214
|
+
feMerge: SVGProps<SVGFEMergeElement>;
|
|
215
|
+
feMergeNode: SVGProps<SVGFEMergeNodeElement>;
|
|
216
|
+
feMorphology: SVGProps<SVGFEMorphologyElement>;
|
|
217
|
+
feOffset: SVGProps<SVGFEOffsetElement>;
|
|
218
|
+
fePointLight: SVGProps<SVGFEPointLightElement>;
|
|
219
|
+
feSpecularLighting: SVGProps<SVGFESpecularLightingElement>;
|
|
220
|
+
feSpotLight: SVGProps<SVGFESpotLightElement>;
|
|
221
|
+
feTile: SVGProps<SVGFETileElement>;
|
|
222
|
+
feTurbulence: SVGProps<SVGFETurbulenceElement>;
|
|
223
|
+
filter: SVGProps<SVGFilterElement>;
|
|
224
|
+
foreignObject: SVGProps<SVGForeignObjectElement>;
|
|
225
|
+
g: SVGProps<SVGGElement>;
|
|
226
|
+
image: SVGProps<SVGImageElement>;
|
|
227
|
+
line: SVGProps<SVGLineElement>;
|
|
228
|
+
linearGradient: SVGProps<SVGLinearGradientElement>;
|
|
229
|
+
marker: SVGProps<SVGMarkerElement>;
|
|
230
|
+
mask: SVGProps<SVGMaskElement>;
|
|
231
|
+
metadata: SVGProps<SVGMetadataElement>;
|
|
232
|
+
mpath: SVGProps<SVGElement>;
|
|
233
|
+
path: SVGProps<SVGPathElement>;
|
|
234
|
+
pattern: SVGProps<SVGPatternElement>;
|
|
235
|
+
polygon: SVGProps<SVGPolygonElement>;
|
|
236
|
+
polyline: SVGProps<SVGPolylineElement>;
|
|
237
|
+
radialGradient: SVGProps<SVGRadialGradientElement>;
|
|
238
|
+
rect: SVGProps<SVGRectElement>;
|
|
239
|
+
set: SVGProps<SVGSetElement>;
|
|
240
|
+
stop: SVGProps<SVGStopElement>;
|
|
241
|
+
switch: SVGProps<SVGSwitchElement>;
|
|
242
|
+
symbol: SVGProps<SVGSymbolElement>;
|
|
243
|
+
text: SVGProps<SVGTextElement>;
|
|
244
|
+
textPath: SVGProps<SVGTextPathElement>;
|
|
245
|
+
tspan: SVGProps<SVGTSpanElement>;
|
|
246
|
+
use: SVGProps<SVGUseElement>;
|
|
247
|
+
view: SVGProps<SVGViewElement>;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
package/jsx-runtime/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { createElement, Fragment } from '../core';
|
|
1
|
+
import { createElement, Fragment } from '../core/internal.js';
|
|
2
2
|
export function jsx(type, props, key) {
|
|
3
|
-
let _key;
|
|
4
|
-
if (key != null) {
|
|
5
|
-
_key = key;
|
|
6
|
-
}
|
|
3
|
+
let _key = key;
|
|
7
4
|
if (props && props.key != null) {
|
|
8
5
|
_key = props.key;
|
|
9
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpreact/simpreact",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://github.com/dPaskhin/simpreact#readme",
|
|
6
6
|
"main": "./core/index.js",
|
|
@@ -8,28 +8,32 @@
|
|
|
8
8
|
"types": "./core/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"import": "./core/index.js",
|
|
12
|
+
"types": "./core/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./internal": {
|
|
15
|
+
"import": "./core/internal.js",
|
|
16
|
+
"types": "./core/internal.d.ts"
|
|
13
17
|
},
|
|
14
18
|
"./jsx-runtime": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
19
|
+
"import": "./jsx-runtime/index.js",
|
|
20
|
+
"types": "./jsx-runtime/index.d.ts"
|
|
17
21
|
},
|
|
18
22
|
"./jsx-dev-runtime": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
23
|
+
"import": "./jsx-runtime/index.js",
|
|
24
|
+
"types": "./jsx-runtime/index.d.ts"
|
|
21
25
|
},
|
|
22
26
|
"./hooks": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
27
|
+
"import": "./hooks/index.js",
|
|
28
|
+
"types": "./hooks/index.d.ts"
|
|
25
29
|
},
|
|
26
30
|
"./dom": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
31
|
+
"import": "./dom/index.js",
|
|
32
|
+
"types": "./dom/index.d.ts"
|
|
29
33
|
},
|
|
30
34
|
"./shared": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
35
|
+
"import": "./shared/index.js",
|
|
36
|
+
"types": "./shared/index.d.ts"
|
|
33
37
|
}
|
|
34
38
|
},
|
|
35
39
|
"bugs": {
|
|
@@ -39,7 +43,10 @@
|
|
|
39
43
|
"type": "git",
|
|
40
44
|
"url": "git+https://github.com/dPaskhin/simpreact.git"
|
|
41
45
|
},
|
|
42
|
-
"
|
|
46
|
+
"sideEffects": false,
|
|
43
47
|
"license": "MIT",
|
|
44
|
-
"author": "Dmitrii Paskhin <d.pasxin@gmail.com>"
|
|
48
|
+
"author": "Dmitrii Paskhin <d.pasxin@gmail.com>",
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"csstype": "^3.1.3"
|
|
51
|
+
}
|
|
45
52
|
}
|
package/shared/index.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
1
|
+
export type Nullable<T> = T | null;
|
|
2
|
+
|
|
3
|
+
export type Maybe<T> = Nullable<T> | undefined;
|
|
4
|
+
|
|
5
|
+
export type Many<T> = T[] | T;
|
|
6
|
+
|
|
7
|
+
export type Dict<T = any> = Record<string, T>;
|
|
8
|
+
|
|
9
|
+
export type SimpText = string | number | bigint;
|
|
10
|
+
|
|
11
|
+
type Subscriber<Event> = (event: Event) => boolean | void;
|
|
12
|
+
|
|
13
|
+
declare class EventBus<Event = void> {
|
|
14
|
+
public publish(event: Event): void;
|
|
15
|
+
|
|
16
|
+
public subscribe(subscriber: Subscriber<Event>): () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare function isSimpText(value: unknown): value is SimpText;
|
package/shared/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
import { EventBus } from './EventBus';
|
|
2
|
+
import { emptyArray, emptyMap, emptyObject } from './lang';
|
|
3
|
+
import { isSimpText, noop } from './utils';
|
|
4
|
+
export { emptyObject, emptyMap, emptyArray, isSimpText, EventBus, noop };
|
|
5
|
+
export default { isSimpText, EMPTY_MAP: emptyMap, EMPTY_ARRAY: emptyArray, EMPTY_OBJECT: emptyObject, EventBus, noop };
|
package/shared/lang.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
1
|
+
export declare const emptyObject: Readonly<{}>;
|
|
2
|
+
export declare const emptyArray: readonly never[];
|
|
3
|
+
export declare const emptyMap: Map<any, any>;
|
package/shared/lang.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
1
|
+
export const emptyObject = Object.freeze({});
|
|
2
|
+
export const emptyArray = Object.freeze([]);
|
|
3
|
+
export const emptyMap = new Map();
|
package/shared/utils.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function
|
|
1
|
+
import type { SimpText } from './public';
|
|
2
|
+
export declare function isSimpText(value: unknown): value is SimpText;
|
|
3
|
+
export declare function noop(): void;
|
package/shared/utils.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export function
|
|
2
|
-
return
|
|
3
|
-
typeof value === 'string' ||
|
|
4
|
-
typeof value === 'number' ||
|
|
5
|
-
typeof value === 'bigint' ||
|
|
6
|
-
typeof value === 'boolean');
|
|
1
|
+
export function isSimpText(value) {
|
|
2
|
+
return typeof value === 'string' || typeof value === 'number' || typeof value === 'bigint';
|
|
7
3
|
}
|
|
4
|
+
export function noop() { }
|
package/core/global.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { HostAdapter } from './hostAdapter';
|
|
2
|
-
import type { SimpElement } from './createElement';
|
|
3
|
-
import { EventBus } from '../shared';
|
|
4
|
-
export type LifecycleEvent = {
|
|
5
|
-
type: 'beforeRender';
|
|
6
|
-
element: SimpElement;
|
|
7
|
-
} | {
|
|
8
|
-
type: 'afterRender';
|
|
9
|
-
} | {
|
|
10
|
-
type: 'mounted';
|
|
11
|
-
element: SimpElement;
|
|
12
|
-
} | {
|
|
13
|
-
type: 'unmounted';
|
|
14
|
-
element: SimpElement;
|
|
15
|
-
};
|
|
16
|
-
interface Global {
|
|
17
|
-
hostAdapter: HostAdapter;
|
|
18
|
-
eventBus: EventBus<LifecycleEvent>;
|
|
19
|
-
}
|
|
20
|
-
export declare const GLOBAL: Global;
|
|
21
|
-
export {};
|