@simpreact/simpreact 0.0.0-alpha.1f6ee65
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 +21 -0
- package/README.md +1 -0
- package/core/context.d.ts +18 -0
- package/core/context.js +18 -0
- package/core/createElement.d.ts +26 -0
- package/core/createElement.js +166 -0
- package/core/fragment.d.ts +5 -0
- package/core/fragment.js +1 -0
- package/core/global.d.ts +21 -0
- package/core/global.js +5 -0
- package/core/hostAdapter.d.ts +17 -0
- package/core/hostAdapter.js +1 -0
- package/core/index.d.ts +3 -0
- package/core/index.js +3 -0
- package/core/internal.d.ts +8 -0
- package/core/internal.js +8 -0
- package/core/mounting.d.ts +12 -0
- package/core/mounting.js +95 -0
- package/core/patching.d.ts +8 -0
- package/core/patching.js +279 -0
- package/core/rerender.d.ts +2 -0
- package/core/rerender.js +5 -0
- package/core/unmounting.d.ts +8 -0
- package/core/unmounting.js +65 -0
- package/dom/domAdapter.d.ts +2 -0
- package/dom/domAdapter.js +159 -0
- package/dom/index.d.ts +1 -0
- package/dom/index.js +1 -0
- package/dom/render.d.ts +9 -0
- package/dom/render.js +29 -0
- package/hooks/index.d.ts +12 -0
- package/hooks/index.js +68 -0
- package/jsx-runtime/index.d.ts +7 -0
- package/jsx-runtime/index.js +16 -0
- package/package.json +45 -0
- package/shared/EventBus.d.ts +18 -0
- package/shared/EventBus.js +28 -0
- package/shared/index.d.ts +4 -0
- package/shared/index.js +4 -0
- package/shared/lang.d.ts +3 -0
- package/shared/lang.js +3 -0
- package/shared/types.d.ts +8 -0
- package/shared/types.js +1 -0
- package/shared/utils.d.ts +2 -0
- package/shared/utils.js +7 -0
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@simpreact/simpreact",
|
|
3
|
+
"version": "0.0.0-alpha.1f6ee65",
|
|
4
|
+
"description": "",
|
|
5
|
+
"homepage": "https://github.com/dPaskhin/simpreact#readme",
|
|
6
|
+
"main": "./core/index.js",
|
|
7
|
+
"module": "./core/index.js",
|
|
8
|
+
"types": "./core/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./core/index.d.ts",
|
|
12
|
+
"import": "./core/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./jsx-runtime": {
|
|
15
|
+
"types": "./jsx-runtime/index.d.ts",
|
|
16
|
+
"import": "./jsx-runtime/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./jsx-dev-runtime": {
|
|
19
|
+
"types": "./jsx-runtime/index.d.ts",
|
|
20
|
+
"import": "./jsx-runtime/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./hooks": {
|
|
23
|
+
"types": "./hooks/index.d.ts",
|
|
24
|
+
"import": "./hooks/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./dom": {
|
|
27
|
+
"types": "./dom/index.d.ts",
|
|
28
|
+
"import": "./dom/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./shared": {
|
|
31
|
+
"types": "./shared/index.d.ts",
|
|
32
|
+
"import": "./shared/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/dPaskhin/simpreact/issues"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/dPaskhin/simpreact.git"
|
|
41
|
+
},
|
|
42
|
+
"type": "module",
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"author": "Dmitrii Paskhin <d.pasxin@gmail.com>"
|
|
45
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
}
|
package/shared/index.js
ADDED
package/shared/lang.d.ts
ADDED
package/shared/lang.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type Nullable<T> = T | null;
|
|
2
|
+
export type Maybe<T> = Nullable<T> | undefined;
|
|
3
|
+
export type Many<T> = T[] | T;
|
|
4
|
+
export type Dict<T = any> = Record<string, T>;
|
|
5
|
+
export type Primitive = string | number | boolean | bigint | undefined | null;
|
|
6
|
+
export interface VoidFunction {
|
|
7
|
+
(): void;
|
|
8
|
+
}
|
package/shared/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|