Match-id-09c02e5b35a7c00c3c718483e5ad0a413a7e44f6

This commit is contained in:
* 2022-10-26 10:08:56 +08:00 committed by *
commit c12ae6fa12
6 changed files with 11 additions and 73 deletions

View File

@ -1,3 +1,6 @@
## 0.0.24 (2022-10-25)
- **core**: fix 修改IE上报Symbol错误的问题
## 0.0.23 (2022-09-23)
- **core**: #86 兼容ReactIs API
-

View File

@ -4,7 +4,7 @@
"keywords": [
"horizon"
],
"version": "0.0.23",
"version": "0.0.24",
"homepage": "",
"bugs": "",
"main": "index.js",

View File

@ -13,8 +13,6 @@
* See the Mulan PSL v2 for more details.
*/
// TODO: implement vNode type
import { IObserver } from './Observer';
/**

View File

@ -28,7 +28,8 @@ const handler = {
forEach,
keys,
values,
[Symbol.iterator]: forOf,
// 判断Symbol类型兼容IE
[typeof Symbol === 'function' ? Symbol.iterator : '@@iterator']: forOf,
};
export function createCollectionProxy(rawObj: Object, hookObserver = true): Object {
@ -214,7 +215,8 @@ function wrapIterator(rawObj: Object, rawIt: { next: () => { value: any; done: b
return { value: newVal, done };
},
[Symbol.iterator]() {
// 判断Symbol类型兼容IE
[typeof Symbol === 'function' ? Symbol.iterator : '@@iterator']() {
return this;
},
};

View File

@ -19,7 +19,7 @@ import { getProcessingVNode } from '../../renderer/GlobalVar';
import { createProxy } from '../proxy/ProxyHandler';
import readonlyProxy from '../proxy/readonlyProxy';
import { Observer } from '../proxy/Observer';
import { FunctionComponent, ClassComponent } from '../Constants';
import { FunctionComponent, ClassComponent } from '../../renderer/vnode/VNodeTags';
import { VNode } from '../../renderer/Types';
const storeMap = new Map<string, StoreHandler<any, any, any>>();
@ -80,8 +80,6 @@ type AsyncAction<T extends ActionFunction<any>, S extends object> = (
type StoreActions<S extends object, A extends UserActions<S>> = { [K in keyof A]: Action<A[K], S> };
type QueuedStoreActions<S extends object, A extends UserActions<S>> = { [K in keyof A]: AsyncAction<A[K], S> };
type ComputedValues<S extends object, C extends UserComputedValues<S>> = { [K in keyof C]: ReturnType<C[K]> };
type PostponedAction = (state: object, ...args: any[]) => Promise<any>;
type PostponedActions = { [key: string]: PostponedAction };
export function createStore<S extends object, A extends UserActions<S>, C extends UserComputedValues<S>>(
config: StoreConfig<S, A, C>

View File

@ -30,66 +30,3 @@ export interface IObserver {
clearByVNode: (vNode: any) => void;
}
type RemoveFirstFromTuple<T extends any[]> = T['length'] extends 0
? []
: ((...b: T) => void) extends (a, ...b: infer I) => void
? I
: [];
type UserActions<S extends object> = { [K: string]: ActionFunction<S> };
type UserComputedValues<S extends object> = { [K: string]: ComputedFunction<S> };
type ActionFunction<S extends object> = (state: S, ...args: any[]) => any;
type ComputedFunction<S extends object> = (state: S) => any;
type Action<T extends UserActions<?>> = (...args: RemoveFirstFromTuple<Parameters<T>>) => ReturnType<T>;
type AsyncAction<T extends UserActions<?>> = (...args: RemoveFirstFromTuple<Parameters<T>>) => Promise<ReturnType<T>>;
type StoreActions<S extends object, A extends UserActions<S>> = { [K in keyof A]: Action<A[K]> };
type QueuedStoreActions<S extends object, A extends UserActions<S>> = { [K in keyof A]: AsyncAction<A[K]> };
type ComputedValues<S extends object, C extends UserComputedValues<S>> = { [K in keyof C]: ReturnType<C[K]> };
type PostponedAction = (state: object, ...args: any[]) => Promise<any>;
type PostponedActions = { [key: string]: PostponedAction };
export type StoreHandler<S extends object, A extends UserActions<S>, C extends UserComputedValues<S>> = {
$subscribe: (listener: () => void) => void;
$unsubscribe: (listener: () => void) => void;
$state: S;
$config: StoreConfig<S, A, C>;
$queue: QueuedStoreActions<S, A>;
$actions: StoreActions<S, A>;
$computed: ComputedValues<S, C>;
reduxHandler?: ReduxStoreHandler;
} & { [K in keyof S]: S[K] } & { [K in keyof A]: Action<A[K]> } & { [K in keyof C]: ReturnType<C[K]> };
export type StoreConfig<S extends object, A extends UserActions<S>, C extends UserComputedValues<S>> = {
state?: S;
options?: { suppressHooks?: boolean };
actions?: A;
id?: string;
computed?: C;
};
type ReduxStoreHandler = {
reducer: (state: any, action: { type: string }) => any;
dispatch: (action: { type: string }) => void;
getState: () => any;
subscribe: (listener: () => void) => (listener: () => void) => void;
replaceReducer: (reducer: (state: any, action: { type: string }) => any) => void;
_horizonXstore: StoreHandler;
};
type ReduxAction = {
type: string;
};
type ReduxMiddleware = (
store: ReduxStoreHandler,
extraArgument?: any
) => (
next: (action: ReduxAction) => any
) => (
action:
| ReduxAction
| ((dispatch: (action: ReduxAction) => void, store: ReduxStoreHandler, extraArgument?: any) => any)
) => ReduxStoreHandler;