@simpreact/simpreact 0.0.4 → 0.0.6
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.txt +1 -1
- package/compat/context.d.ts +4 -4
- package/compat/context.js +3 -2
- package/compat/core.d.ts +4 -0
- package/compat/core.js +14 -9
- package/compat/dom.d.ts +4 -5
- package/compat/dom.js +3 -2
- package/compat/hooks.d.ts +16 -13
- package/compat/hooks.js +19 -15
- package/compat/index.d.ts +10 -9
- package/compat/renderRuntime.d.ts +2 -0
- package/compat/renderRuntime.js +14 -0
- package/component/index.d.ts +16 -0
- package/component/index.js +164 -0
- package/context/index.d.ts +12 -5
- package/context/index.js +62 -57
- package/core/createElement.d.ts +29 -20
- package/core/createElement.js +159 -133
- package/core/hostAdapter.d.ts +8 -12
- package/core/hostAdapter.js +1 -4
- package/core/hostOperations.d.ts +5 -0
- package/core/hostOperations.js +15 -0
- package/core/index.d.ts +29 -6
- package/core/internal.d.ts +3 -0
- package/core/internal.js +3 -0
- package/core/lifecycleEventBus.d.ts +15 -6
- package/core/lifecycleEventBus.js +16 -2
- package/core/memo.d.ts +0 -2
- package/core/memo.js +1 -3
- package/core/mounting.d.ts +7 -9
- package/core/mounting.js +221 -82
- package/core/patching.d.ts +7 -8
- package/core/patching.js +235 -255
- package/core/patchingChildren.d.ts +6 -0
- package/core/patchingChildren.js +330 -0
- package/core/portal.d.ts +1 -1
- package/core/portal.js +17 -7
- package/core/processStack.d.ts +69 -0
- package/core/processStack.js +63 -0
- package/core/ref.d.ts +4 -3
- package/core/rerender.d.ts +4 -14
- package/core/rerender.js +67 -112
- package/core/runtime.d.ts +17 -0
- package/core/runtime.js +2 -0
- package/core/unmounting.d.ts +11 -6
- package/core/unmounting.js +81 -40
- package/core/utils.d.ts +10 -0
- package/core/utils.js +143 -0
- package/dom/attach-element-to-dom.d.ts +4 -3
- package/dom/attach-element-to-dom.js +12 -7
- package/dom/domAdapter.js +22 -25
- package/dom/events.d.ts +5 -5
- package/dom/events.js +33 -16
- package/dom/index.d.ts +16 -5
- package/dom/index.js +4 -3
- package/dom/props/controlled/index.d.ts +3 -3
- package/dom/props/controlled/index.js +8 -8
- package/dom/props/controlled/input.d.ts +3 -3
- package/dom/props/controlled/input.js +57 -34
- package/dom/props/controlled/select.d.ts +3 -3
- package/dom/props/controlled/select.js +39 -26
- package/dom/props/controlled/textarea.d.ts +3 -3
- package/dom/props/controlled/textarea.js +57 -34
- package/dom/props/dangerInnerHTML.d.ts +2 -2
- package/dom/props/dangerInnerHTML.js +3 -2
- package/dom/props/props.d.ts +4 -4
- package/dom/props/props.js +24 -21
- package/dom/render.d.ts +4 -5
- package/dom/render.js +38 -34
- package/hooks/index.d.ts +15 -13
- package/hooks/index.js +155 -159
- package/jsx-runtime/index.d.ts +2 -1
- package/package.json +9 -1
- package/shared/index.d.ts +10 -0
- package/shared/index.js +4 -7
- package/shared/utils.js +4 -4
- package/shared/EventBus.d.ts +0 -18
- package/shared/EventBus.js +0 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpreact/simpreact",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://github.com/dPaskhin/simpreact#readme",
|
|
6
6
|
"main": "./core/index.js",
|
|
@@ -17,6 +17,14 @@
|
|
|
17
17
|
"./compat/*": {
|
|
18
18
|
"import": "./compat/index.js"
|
|
19
19
|
},
|
|
20
|
+
"./component": {
|
|
21
|
+
"import": "./component/index.js",
|
|
22
|
+
"types": "./component/index.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./context/*": {
|
|
25
|
+
"import": "./context/index.js",
|
|
26
|
+
"types": "./context/index.d.ts"
|
|
27
|
+
},
|
|
20
28
|
"./internal": {
|
|
21
29
|
"import": "./core/internal.js",
|
|
22
30
|
"types": "./core/internal.d.ts"
|
package/shared/index.d.ts
CHANGED
|
@@ -16,6 +16,16 @@ declare class EventBus<Event = void> {
|
|
|
16
16
|
public subscribe(subscriber: Subscriber<Event>): () => void;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
export type Cleanup = () => void;
|
|
20
|
+
export type Effect = () => void | Cleanup;
|
|
21
|
+
export type DependencyList = readonly unknown[];
|
|
22
|
+
|
|
23
|
+
export interface EffectState {
|
|
24
|
+
effect: Effect;
|
|
25
|
+
cleanup: Nullable<Cleanup>;
|
|
26
|
+
deps: Nullable<DependencyList>;
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
declare function isSimpText(value: unknown): value is SimpText;
|
|
20
30
|
|
|
21
31
|
declare function noop(): void;
|
package/shared/index.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { EventBus } from './EventBus.js';
|
|
2
1
|
import { emptyArray, emptyMap, emptyObject } from './lang.js';
|
|
3
2
|
import { callOrGet, isSimpText, noop, shallowEqual } from './utils.js';
|
|
4
|
-
export { emptyObject, emptyMap, emptyArray, isSimpText,
|
|
3
|
+
export { emptyObject, emptyMap, emptyArray, isSimpText, noop, callOrGet, shallowEqual };
|
|
5
4
|
export default {
|
|
6
5
|
isSimpText,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
EventBus,
|
|
6
|
+
emptyMap,
|
|
7
|
+
emptyArray,
|
|
8
|
+
emptyObject,
|
|
11
9
|
noop,
|
|
12
10
|
callOrGet,
|
|
13
|
-
emptyObject,
|
|
14
11
|
};
|
package/shared/utils.js
CHANGED
|
@@ -22,17 +22,17 @@ export function shallowEqual(objA, objB) {
|
|
|
22
22
|
if (Object.is(objA, objB)) {
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
|
-
if (typeof objA !== 'object' || objA
|
|
25
|
+
if (typeof objA !== 'object' || objA == null || typeof objB !== 'object' || objB == null) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
|
-
const keysA =
|
|
29
|
-
const keysB =
|
|
28
|
+
const keysA = Reflect.ownKeys(objA);
|
|
29
|
+
const keysB = Reflect.ownKeys(objB);
|
|
30
30
|
if (keysA.length !== keysB.length) {
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
33
33
|
for (let i = 0; i < keysA.length; i++) {
|
|
34
34
|
const currentKey = keysA[i];
|
|
35
|
-
if (!Object.
|
|
35
|
+
if (!Object.hasOwn(objB, currentKey) || !Object.is(objA[currentKey], objB[currentKey])) {
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
38
|
}
|
package/shared/EventBus.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
type Subscriber<Event> = (event: Event) => boolean | void;
|
|
2
|
-
export declare class EventBus<Event = void> {
|
|
3
|
-
private _subscribers;
|
|
4
|
-
/**
|
|
5
|
-
* Synchronously invokes subscribers and passes the event.
|
|
6
|
-
*
|
|
7
|
-
* @param event The event to publish.
|
|
8
|
-
*/
|
|
9
|
-
publish(event: Event): void;
|
|
10
|
-
/**
|
|
11
|
-
* Adds a subscriber to the event bus. Subscriber would receive all events published via {@link EventBus.publish}.
|
|
12
|
-
*
|
|
13
|
-
* @param subscriber The subscriber callback.
|
|
14
|
-
* @returns The callback that unsubscribes the subscriber from the event bus.
|
|
15
|
-
*/
|
|
16
|
-
subscribe(subscriber: Subscriber<Event>): () => void;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
package/shared/EventBus.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export class EventBus {
|
|
2
|
-
_subscribers = [];
|
|
3
|
-
/**
|
|
4
|
-
* Synchronously invokes subscribers and passes the event.
|
|
5
|
-
*
|
|
6
|
-
* @param event The event to publish.
|
|
7
|
-
*/
|
|
8
|
-
publish(event) {
|
|
9
|
-
for (const subscriber of this._subscribers) {
|
|
10
|
-
subscriber(event);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Adds a subscriber to the event bus. Subscriber would receive all events published via {@link EventBus.publish}.
|
|
15
|
-
*
|
|
16
|
-
* @param subscriber The subscriber callback.
|
|
17
|
-
* @returns The callback that unsubscribes the subscriber from the event bus.
|
|
18
|
-
*/
|
|
19
|
-
subscribe(subscriber) {
|
|
20
|
-
const subscribers = this._subscribers;
|
|
21
|
-
if (subscribers.indexOf(subscriber) === -1) {
|
|
22
|
-
subscribers.push(subscriber);
|
|
23
|
-
}
|
|
24
|
-
return () => {
|
|
25
|
-
subscribers.splice(subscribers.indexOf(subscriber), 1);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|