diff --git a/CHANGELOG.md b/CHANGELOG.md index 10f970ab..7404c980 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.0.24 (2022-10-25) +- **core**: fix 修改IE上报Symbol错误的问题 + ## 0.0.23 (2022-09-23) - **core**: #86 兼容ReactIs API - diff --git a/libs/horizon/package.json b/libs/horizon/package.json index 8b0f2127..0f6ee886 100644 --- a/libs/horizon/package.json +++ b/libs/horizon/package.json @@ -4,7 +4,7 @@ "keywords": [ "horizon" ], - "version": "0.0.23", + "version": "0.0.24", "homepage": "", "bugs": "", "main": "index.js", diff --git a/libs/horizon/src/horizonx/proxy/HooklessObserver.ts b/libs/horizon/src/horizonx/proxy/HooklessObserver.ts index bc1dbda0..063fba9f 100644 --- a/libs/horizon/src/horizonx/proxy/HooklessObserver.ts +++ b/libs/horizon/src/horizonx/proxy/HooklessObserver.ts @@ -13,8 +13,6 @@ * See the Mulan PSL v2 for more details. */ -// TODO: implement vNode type - import { IObserver } from './Observer'; /** diff --git a/libs/horizon/src/horizonx/proxy/handlers/CollectionProxyHandler.ts b/libs/horizon/src/horizonx/proxy/handlers/CollectionProxyHandler.ts index cad085bc..dad28366 100644 --- a/libs/horizon/src/horizonx/proxy/handlers/CollectionProxyHandler.ts +++ b/libs/horizon/src/horizonx/proxy/handlers/CollectionProxyHandler.ts @@ -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; }, }; diff --git a/libs/horizon/src/horizonx/store/StoreHandler.ts b/libs/horizon/src/horizonx/store/StoreHandler.ts index 867e8cb4..6c1cac0a 100644 --- a/libs/horizon/src/horizonx/store/StoreHandler.ts +++ b/libs/horizon/src/horizonx/store/StoreHandler.ts @@ -13,13 +13,13 @@ * See the Mulan PSL v2 for more details. */ -//@ts-ignore +// @ts-ignore import { useEffect, useRef } from '../../renderer/hooks/HookExternal'; 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>(); @@ -80,13 +80,11 @@ type AsyncAction, S extends object> = ( type StoreActions> = { [K in keyof A]: Action }; type QueuedStoreActions> = { [K in keyof A]: AsyncAction }; type ComputedValues> = { [K in keyof C]: ReturnType }; -type PostponedAction = (state: object, ...args: any[]) => Promise; -type PostponedActions = { [key: string]: PostponedAction }; export function createStore, C extends UserComputedValues>( config: StoreConfig ): () => StoreHandler { - //create a local shalow copy to ensure consistency (if user would change the config object after store creation) + // create a local shalow copy to ensure consistency (if user would change the config object after store creation) config = { id: config.id, options: config.options, diff --git a/libs/horizon/src/horizonx/types.d.ts b/libs/horizon/src/horizonx/types.d.ts index 243d6f8a..e7868c35 100644 --- a/libs/horizon/src/horizonx/types.d.ts +++ b/libs/horizon/src/horizonx/types.d.ts @@ -30,66 +30,3 @@ export interface IObserver { clearByVNode: (vNode: any) => void; } - -type RemoveFirstFromTuple = T['length'] extends 0 - ? [] - : ((...b: T) => void) extends (a, ...b: infer I) => void - ? I - : []; - -type UserActions = { [K: string]: ActionFunction }; -type UserComputedValues = { [K: string]: ComputedFunction }; - -type ActionFunction = (state: S, ...args: any[]) => any; -type ComputedFunction = (state: S) => any; -type Action> = (...args: RemoveFirstFromTuple>) => ReturnType; -type AsyncAction> = (...args: RemoveFirstFromTuple>) => Promise>; - -type StoreActions> = { [K in keyof A]: Action }; -type QueuedStoreActions> = { [K in keyof A]: AsyncAction }; -type ComputedValues> = { [K in keyof C]: ReturnType }; -type PostponedAction = (state: object, ...args: any[]) => Promise; -type PostponedActions = { [key: string]: PostponedAction }; - -export type StoreHandler, C extends UserComputedValues> = { - $subscribe: (listener: () => void) => void; - $unsubscribe: (listener: () => void) => void; - $state: S; - $config: StoreConfig; - $queue: QueuedStoreActions; - $actions: StoreActions; - $computed: ComputedValues; - reduxHandler?: ReduxStoreHandler; -} & { [K in keyof S]: S[K] } & { [K in keyof A]: Action } & { [K in keyof C]: ReturnType }; - -export type StoreConfig, C extends UserComputedValues> = { - 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;