From 5d8d24ee89f245e96fefe3e43d8cb0bf51857928 Mon Sep 17 00:00:00 2001 From: * <8> Date: Tue, 25 Oct 2022 14:43:20 +0800 Subject: [PATCH 1/2] Match-id-7a9e111a1362e0c42f098a02691676c6e05fd91b --- .../src/horizonx/proxy/HooklessObserver.ts | 3 - .../proxy/handlers/CollectionProxyHandler.ts | 6 +- .../src/horizonx/store/StoreHandler.ts | 8 +-- libs/horizon/src/horizonx/types.d.ts | 63 ------------------- 4 files changed, 7 insertions(+), 73 deletions(-) diff --git a/libs/horizon/src/horizonx/proxy/HooklessObserver.ts b/libs/horizon/src/horizonx/proxy/HooklessObserver.ts index 42e7da21..6a5c6968 100644 --- a/libs/horizon/src/horizonx/proxy/HooklessObserver.ts +++ b/libs/horizon/src/horizonx/proxy/HooklessObserver.ts @@ -13,13 +13,10 @@ * See the Mulan PSL v2 for more details. */ -// TODO: implement vNode type - import {IObserver} from './Observer'; /** * 一个对象(对象、数组、集合)对应一个Observer - * */ export class HooklessObserver implements IObserver { 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 8c93e132..db79637c 100644 --- a/libs/horizon/src/horizonx/types.d.ts +++ b/libs/horizon/src/horizonx/types.d.ts @@ -31,66 +31,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 From 26f520cfc48aabcfed08226a5f41ed6deb90d06e Mon Sep 17 00:00:00 2001 From: * <8> Date: Tue, 25 Oct 2022 14:54:18 +0800 Subject: [PATCH 2/2] Match-id-33838147efb73c637b1314bd819ddeb781b0b680 --- CHANGELOG.md | 3 +++ libs/horizon/package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) 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",