diff --git a/app_define.json b/app_define.json index cd13e351..a674d06c 100644 --- a/app_define.json +++ b/app_define.json @@ -1 +1 @@ -{"fileVersion":"1","name":"Horizon","serviceId":"067e5bef6cd240ae9460229d107a99a6","description":"","version":"1.0.0","type":"microService","processes":{"Horizon":{"subscribes":[]}}} \ No newline at end of file +{"fileVersion":"1","name":"Inula","serviceId":"067e5bef6cd240ae9460229d107a99a6","description":"","version":"1.0.0","type":"microService","processes":{"Inula":{"subscribes":[]}}} diff --git a/babel.config.js b/babel.config.js index fa0e4b8c..522db7a3 100644 --- a/babel.config.js +++ b/babel.config.js @@ -20,8 +20,8 @@ module.exports = { [ '@babel/plugin-transform-react-jsx', { - pragma: 'Horizon.createElement', - pragmaFrag: 'Horizon.Fragment', + pragma: 'Inula.createElement', + pragmaFrag: 'Inula.Fragment', }, ], ['@babel/plugin-proposal-class-properties', { loose: true }], diff --git a/jest.config.js b/jest.config.js index 69f84f2b..5c55a50d 100644 --- a/jest.config.js +++ b/jest.config.js @@ -26,8 +26,8 @@ module.exports = { testEnvironment: 'jest-environment-jsdom-sixteen', testMatch: [ - // '/scripts/__tests__/HorizonXTest/edgeCases/deepVariableObserver.test.tsx', - // '/scripts/__tests__/HorizonXTest/StateManager/StateMap.test.tsx', + // '/scripts/__tests__/InulaXTest/edgeCases/deepVariableObserver.test.tsx', + // '/scripts/__tests__/InulaXTest/StateManager/StateMap.test.tsx', '/scripts/__tests__/**/*.test.js', '/scripts/__tests__/**/*.test.tsx', ], diff --git a/libs/horizon/README.md b/libs/horizon/README.md deleted file mode 100644 index c44e6d74..00000000 --- a/libs/horizon/README.md +++ /dev/null @@ -1 +0,0 @@ -# `horizon` diff --git a/libs/horizon/src/horizonx/devtools/constants.ts b/libs/horizon/src/horizonx/devtools/constants.ts deleted file mode 100644 index 3e105125..00000000 --- a/libs/horizon/src/horizonx/devtools/constants.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const INITIALIZED = 'horizonx store initialized'; -export const STATE_CHANGE = 'horizonx state change'; -export const SUBSCRIBED = 'horizonx subscribed'; -export const UNSUBSCRIBED = 'horizonx unsubscribed'; -export const ACTION = 'horizonx action'; -export const ACTION_QUEUED = 'horizonx action queued'; -export const QUEUE_PENDING = 'horizonx queue pending'; -export const QUEUE_FINISHED = 'horizonx queue finished'; -export const RENDER_TRIGGERED = 'horizonx render triggered'; -export const OBSERVED_COMPONENTS = 'horizonx observed components'; diff --git a/libs/inula/README.md b/libs/inula/README.md new file mode 100644 index 00000000..95818b1f --- /dev/null +++ b/libs/inula/README.md @@ -0,0 +1 @@ +# `inula` diff --git a/libs/horizon/global.d.ts b/libs/inula/global.d.ts similarity index 94% rename from libs/horizon/global.d.ts rename to libs/inula/global.d.ts index 76352c78..963ff285 100644 --- a/libs/horizon/global.d.ts +++ b/libs/inula/global.d.ts @@ -20,4 +20,4 @@ declare var isDev: boolean; declare var isTest: boolean; declare const __VERSION__: string; declare var setImmediate: Function; -declare var __HORIZON_DEV_HOOK__: any; +declare var __INULA_DEV_HOOK__: any; diff --git a/libs/horizon/index.ts b/libs/inula/index.ts similarity index 90% rename from libs/horizon/index.ts rename to libs/inula/index.ts index 20e47409..7668ddb2 100644 --- a/libs/horizon/index.ts +++ b/libs/inula/index.ts @@ -54,10 +54,10 @@ import { isLazy, isMemo, isPortal, -} from './src/external/HorizonIs'; -import { createStore, useStore, clearStore } from './src/horizonx/store/StoreHandler'; -import * as reduxAdapter from './src/horizonx/adapters/redux'; -import { watch } from './src/horizonx/proxy/watch'; +} from './src/external/InulaIs'; +import { createStore, useStore, clearStore } from './src/inulax/store/StoreHandler'; +import * as reduxAdapter from './src/inulax/adapters/redux'; +import { watch } from './src/inulax/proxy/watch'; import { act } from './src/external/TestUtil'; import { @@ -69,9 +69,9 @@ import { } from './src/dom/DOMExternal'; import { syncUpdates as flushSync } from './src/renderer/TreeBuilder'; -import { toRaw } from './src/horizonx/proxy/ProxyHandler'; +import { toRaw } from './src/inulax/proxy/ProxyHandler'; -const Horizon = { +const Inula = { Children, createRef, Component, @@ -152,7 +152,7 @@ export { unmountComponentAtNode, act, flushSync, - // 状态管理器HorizonX接口 + // 状态管理器InulaX接口 createStore, useStore, clearStore, @@ -177,4 +177,4 @@ export { Suspense, }; -export default Horizon; +export default Inula; diff --git a/libs/horizon/jsx-dev-runtime.ts b/libs/inula/jsx-dev-runtime.ts similarity index 100% rename from libs/horizon/jsx-dev-runtime.ts rename to libs/inula/jsx-dev-runtime.ts diff --git a/libs/horizon/jsx-runtime.ts b/libs/inula/jsx-runtime.ts similarity index 100% rename from libs/horizon/jsx-runtime.ts rename to libs/inula/jsx-runtime.ts diff --git a/libs/horizon/npm/index.js b/libs/inula/npm/index.js similarity index 83% rename from libs/horizon/npm/index.js rename to libs/inula/npm/index.js index b2c3033b..7cf8fa19 100644 --- a/libs/horizon/npm/index.js +++ b/libs/inula/npm/index.js @@ -16,7 +16,7 @@ 'use strict'; if (process.env.NODE_ENV === 'production') { - module.exports = require('./cjs/horizon.production.min.js'); + module.exports = require('./cjs/inula.production.min.js'); } else { - module.exports = require('./cjs/horizon.development.js'); + module.exports = require('./cjs/inula.development.js'); } diff --git a/libs/horizon/package.json b/libs/inula/package.json similarity index 66% rename from libs/horizon/package.json rename to libs/inula/package.json index f64cd277..0e57bbe8 100644 --- a/libs/horizon/package.json +++ b/libs/inula/package.json @@ -1,8 +1,8 @@ { - "name": "@cloudsop/horizon", - "description": "Horizon is a JavaScript framework library.", + "name": "inulajs", + "description": "InulaJS is a JavaScript framework library.", "keywords": [ - "horizon" + "inula" ], "version": "0.0.52", "homepage": "", diff --git a/libs/horizon/src/dom/DOMExternal.ts b/libs/inula/src/dom/DOMExternal.ts similarity index 100% rename from libs/horizon/src/dom/DOMExternal.ts rename to libs/inula/src/dom/DOMExternal.ts diff --git a/libs/horizon/src/dom/DOMInternalKeys.ts b/libs/inula/src/dom/DOMInternalKeys.ts similarity index 94% rename from libs/horizon/src/dom/DOMInternalKeys.ts rename to libs/inula/src/dom/DOMInternalKeys.ts index 3c356644..baa40fcc 100644 --- a/libs/horizon/src/dom/DOMInternalKeys.ts +++ b/libs/inula/src/dom/DOMInternalKeys.ts @@ -22,9 +22,9 @@ import type { Container, Props } from './DOMOperator'; import { DomComponent, DomText, TreeRoot } from '../renderer/vnode/VNodeTags'; -const INTERNAL_VNODE = '_horizon_VNode'; -const INTERNAL_PROPS = '_horizon_Props'; -const INTERNAL_NONDELEGATEEVENTS = '_horizon_NonDelegatedEvents'; +const INTERNAL_VNODE = '_inula_VNode'; +const INTERNAL_PROPS = '_inula_Props'; +const INTERNAL_NONDELEGATEEVENTS = '_inula_NonDelegatedEvents'; // 通过 VNode 实例获取 DOM 节点 export function getDom(vNode: VNode): Element | Text | null { diff --git a/libs/horizon/src/dom/DOMOperator.ts b/libs/inula/src/dom/DOMOperator.ts similarity index 97% rename from libs/horizon/src/dom/DOMOperator.ts rename to libs/inula/src/dom/DOMOperator.ts index ca952804..a4adebb4 100644 --- a/libs/horizon/src/dom/DOMOperator.ts +++ b/libs/inula/src/dom/DOMOperator.ts @@ -72,7 +72,7 @@ export function resetAfterSubmit(): void { // 创建 DOM 对象 export function newDom(tagName: string, props: Props, parentNamespace: string, vNode: VNode): Element { // document取值于treeRoot对应的DOM的ownerDocument。 - // 解决:在iframe中使用top的horizon时,horizon在创建DOM时用到的document并不是iframe的document,而是top中的document的问题。 + // 解决:在iframe中使用top的inula时,inula在创建DOM时用到的document并不是iframe的document,而是top中的document的问题。 const rootDom = getCurrentRoot().realNode; const doc = isDocument(rootDom) ? rootDom : rootDom.ownerDocument; diff --git a/libs/horizon/src/dom/DOMPropertiesHandler/DOMPropertiesHandler.ts b/libs/inula/src/dom/DOMPropertiesHandler/DOMPropertiesHandler.ts similarity index 96% rename from libs/horizon/src/dom/DOMPropertiesHandler/DOMPropertiesHandler.ts rename to libs/inula/src/dom/DOMPropertiesHandler/DOMPropertiesHandler.ts index f2657883..b3d83f8a 100644 --- a/libs/horizon/src/dom/DOMPropertiesHandler/DOMPropertiesHandler.ts +++ b/libs/inula/src/dom/DOMPropertiesHandler/DOMPropertiesHandler.ts @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import { allDelegatedHorizonEvents } from '../../event/EventHub'; +import { allDelegatedInulaEvents } from '../../event/EventHub'; import { updateCommonProp } from './UpdateCommonProp'; import { setStyles } from './StyleHandler'; import { lazyDelegateOnRoot, listenNonDelegatedEvent } from '../../event/EventBinding'; @@ -35,7 +35,7 @@ export function setDomProps(dom: Element, props: Object, isNativeTag: boolean, i } else if (isEventProp(propName)) { // 事件监听属性处理 const currentRoot = getCurrentRoot(); - if (!allDelegatedHorizonEvents.has(propName)) { + if (!allDelegatedInulaEvents.has(propName)) { listenNonDelegatedEvent(propName, dom, propVal); } else if (currentRoot && !currentRoot.delegatedEvents.has(propName)) { lazyDelegateOnRoot(currentRoot, propName); @@ -84,7 +84,7 @@ export function compareProps(oldProps: Object, newProps: Object): Object { } else if (propName === 'autoFocus' || propName === 'children' || propName === 'dangerouslySetInnerHTML') { continue; } else if (isEventProp(propName)) { - if (!allDelegatedHorizonEvents.has(propName)) { + if (!allDelegatedInulaEvents.has(propName)) { toUpdateProps[propName] = null; } } else { @@ -155,7 +155,7 @@ export function compareProps(oldProps: Object, newProps: Object): Object { } } else if (isEventProp(propName)) { const currentRoot = getCurrentRoot(); - if (!allDelegatedHorizonEvents.has(propName)) { + if (!allDelegatedInulaEvents.has(propName)) { toUpdateProps[propName] = newPropValue; } else if (currentRoot && !currentRoot.delegatedEvents.has(propName)) { lazyDelegateOnRoot(currentRoot, propName); diff --git a/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts b/libs/inula/src/dom/DOMPropertiesHandler/StyleHandler.ts similarity index 100% rename from libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts rename to libs/inula/src/dom/DOMPropertiesHandler/StyleHandler.ts diff --git a/libs/horizon/src/dom/DOMPropertiesHandler/UpdateCommonProp.ts b/libs/inula/src/dom/DOMPropertiesHandler/UpdateCommonProp.ts similarity index 100% rename from libs/horizon/src/dom/DOMPropertiesHandler/UpdateCommonProp.ts rename to libs/inula/src/dom/DOMPropertiesHandler/UpdateCommonProp.ts diff --git a/libs/horizon/src/dom/SelectionRangeHandler.ts b/libs/inula/src/dom/SelectionRangeHandler.ts similarity index 100% rename from libs/horizon/src/dom/SelectionRangeHandler.ts rename to libs/inula/src/dom/SelectionRangeHandler.ts diff --git a/libs/horizon/src/dom/utils/Common.ts b/libs/inula/src/dom/utils/Common.ts similarity index 96% rename from libs/horizon/src/dom/utils/Common.ts rename to libs/inula/src/dom/utils/Common.ts index 7b2af2b5..50dc845f 100644 --- a/libs/horizon/src/dom/utils/Common.ts +++ b/libs/inula/src/dom/utils/Common.ts @@ -13,14 +13,14 @@ * See the Mulan PSL v2 for more details. */ -import { HorizonDom } from './Interface'; +import { InulaDom } from './Interface'; import { Props } from '../DOMOperator'; /** * 获取当前聚焦的 input 或者 textarea 元素 * @param doc 指定 document */ -export function getFocusedDom(doc?: Document): HorizonDom | null { +export function getFocusedDom(doc?: Document): InulaDom | null { const currentDocument = doc ?? document; return currentDocument.activeElement ?? currentDocument.body; diff --git a/libs/horizon/src/dom/utils/DomCreator.ts b/libs/inula/src/dom/utils/DomCreator.ts similarity index 100% rename from libs/horizon/src/dom/utils/DomCreator.ts rename to libs/inula/src/dom/utils/DomCreator.ts diff --git a/libs/horizon/src/dom/utils/Interface.ts b/libs/inula/src/dom/utils/Interface.ts similarity index 80% rename from libs/horizon/src/dom/utils/Interface.ts rename to libs/inula/src/dom/utils/Interface.ts index 367bcebf..9cbc2536 100644 --- a/libs/horizon/src/dom/utils/Interface.ts +++ b/libs/inula/src/dom/utils/Interface.ts @@ -17,8 +17,8 @@ export interface Props { [propName: string]: any; } -export interface HorizonSelect extends HTMLSelectElement { +export interface InulaSelect extends HTMLSelectElement { _multiple?: boolean; } -export type HorizonDom = Element | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement; +export type InulaDom = Element | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement; diff --git a/libs/horizon/src/dom/validators/PropertiesData.ts b/libs/inula/src/dom/validators/PropertiesData.ts similarity index 100% rename from libs/horizon/src/dom/validators/PropertiesData.ts rename to libs/inula/src/dom/validators/PropertiesData.ts diff --git a/libs/horizon/src/dom/validators/ValidateProps.ts b/libs/inula/src/dom/validators/ValidateProps.ts similarity index 100% rename from libs/horizon/src/dom/validators/ValidateProps.ts rename to libs/inula/src/dom/validators/ValidateProps.ts diff --git a/libs/horizon/src/dom/valueHandler/InputValueHandler.ts b/libs/inula/src/dom/valueHandler/InputValueHandler.ts similarity index 100% rename from libs/horizon/src/dom/valueHandler/InputValueHandler.ts rename to libs/inula/src/dom/valueHandler/InputValueHandler.ts diff --git a/libs/horizon/src/dom/valueHandler/OptionValueHandler.ts b/libs/inula/src/dom/valueHandler/OptionValueHandler.ts similarity index 100% rename from libs/horizon/src/dom/valueHandler/OptionValueHandler.ts rename to libs/inula/src/dom/valueHandler/OptionValueHandler.ts diff --git a/libs/horizon/src/dom/valueHandler/SelectValueHandler.ts b/libs/inula/src/dom/valueHandler/SelectValueHandler.ts similarity index 91% rename from libs/horizon/src/dom/valueHandler/SelectValueHandler.ts rename to libs/inula/src/dom/valueHandler/SelectValueHandler.ts index ecb767a6..083fed75 100644 --- a/libs/horizon/src/dom/valueHandler/SelectValueHandler.ts +++ b/libs/inula/src/dom/valueHandler/SelectValueHandler.ts @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import { HorizonSelect, Props } from '../utils/Interface'; +import { InulaSelect, Props } from '../utils/Interface'; function updateMultipleValue(options, newValues) { const newValueSet = new Set(); @@ -54,14 +54,14 @@ function updateValue(options, newValues: any, isMultiple: boolean) { } } -export function getSelectPropsWithoutValue(dom: HorizonSelect, properties: Object) { +export function getSelectPropsWithoutValue(dom: InulaSelect, properties: Object) { return { ...properties, value: undefined, }; } -export function updateSelectValue(dom: HorizonSelect, props: Props, isInit = false) { +export function updateSelectValue(dom: InulaSelect, props: Props, isInit = false) { const { value, defaultValue, multiple } = props; const oldMultiple = dom._multiple !== undefined ? dom._multiple : dom.multiple; diff --git a/libs/horizon/src/dom/valueHandler/TextareaValueHandler.ts b/libs/inula/src/dom/valueHandler/TextareaValueHandler.ts similarity index 100% rename from libs/horizon/src/dom/valueHandler/TextareaValueHandler.ts rename to libs/inula/src/dom/valueHandler/TextareaValueHandler.ts diff --git a/libs/horizon/src/dom/valueHandler/ValueChangeHandler.ts b/libs/inula/src/dom/valueHandler/ValueChangeHandler.ts similarity index 96% rename from libs/horizon/src/dom/valueHandler/ValueChangeHandler.ts rename to libs/inula/src/dom/valueHandler/ValueChangeHandler.ts index 0d390902..99968321 100644 --- a/libs/horizon/src/dom/valueHandler/ValueChangeHandler.ts +++ b/libs/inula/src/dom/valueHandler/ValueChangeHandler.ts @@ -14,7 +14,7 @@ */ /** - * Horizon的输入框和文本框的change事件在原生的change事件上做了一层处理 + * Inula的输入框和文本框的change事件在原生的change事件上做了一层处理 * 只有值发生变化时才会触发change事件。 */ diff --git a/libs/horizon/src/dom/valueHandler/index.ts b/libs/inula/src/dom/valueHandler/index.ts similarity index 81% rename from libs/horizon/src/dom/valueHandler/index.ts rename to libs/inula/src/dom/valueHandler/index.ts index b432b658..6a9ad5a3 100644 --- a/libs/horizon/src/dom/valueHandler/index.ts +++ b/libs/inula/src/dom/valueHandler/index.ts @@ -18,21 +18,21 @@ * 处理组件被代理和不被代理情况下的不同逻辑 */ -import { HorizonDom, HorizonSelect, Props } from '../utils/Interface'; +import { InulaDom, InulaSelect, Props } from '../utils/Interface'; import { getInputPropsWithoutValue, setInitInputValue, updateInputValue } from './InputValueHandler'; import { getOptionPropsWithoutValue } from './OptionValueHandler'; import { getSelectPropsWithoutValue, updateSelectValue } from './SelectValueHandler'; import { getTextareaPropsWithoutValue, updateTextareaValue } from './TextareaValueHandler'; // 获取元素除了被代理的值以外的属性 -function getPropsWithoutValue(type: string, dom: HorizonDom, props: Props) { +function getPropsWithoutValue(type: string, dom: InulaDom, props: Props) { switch (type) { case 'input': return getInputPropsWithoutValue(dom, props); case 'option': return getOptionPropsWithoutValue(dom, props); case 'select': - return getSelectPropsWithoutValue(dom, props); + return getSelectPropsWithoutValue(dom, props); case 'textarea': return getTextareaPropsWithoutValue(dom, props); default: @@ -41,13 +41,13 @@ function getPropsWithoutValue(type: string, dom: HorizonDom, props: Props) { } // 其它属性挂载完成后处理被代理值相关的属性 -function setInitValue(type: string, dom: HorizonDom, props: Props) { +function setInitValue(type: string, dom: InulaDom, props: Props) { switch (type) { case 'input': setInitInputValue(dom, props); break; case 'select': - updateSelectValue(dom, props, true); + updateSelectValue(dom, props, true); break; case 'textarea': updateTextareaValue(dom, props, true); @@ -58,13 +58,13 @@ function setInitValue(type: string, dom: HorizonDom, props: Props) { } // 更新需要适配的属性 -function updateValue(type: string, dom: HorizonDom, props: Props) { +function updateValue(type: string, dom: InulaDom, props: Props) { switch (type) { case 'input': updateInputValue(dom, props); break; case 'select': - updateSelectValue(dom, props); + updateSelectValue(dom, props); break; case 'textarea': updateTextareaValue(dom, props); diff --git a/libs/horizon/src/event/EventBinding.ts b/libs/inula/src/event/EventBinding.ts similarity index 74% rename from libs/horizon/src/event/EventBinding.ts rename to libs/inula/src/event/EventBinding.ts index 8c81d763..aefcf1b4 100644 --- a/libs/horizon/src/event/EventBinding.ts +++ b/libs/inula/src/event/EventBinding.ts @@ -16,11 +16,11 @@ /** * 事件绑定实现,分为绑定委托事件和非委托事件 */ -import { allDelegatedHorizonEvents, simulatedDelegatedEvents } from './EventHub'; +import { allDelegatedInulaEvents, simulatedDelegatedEvents } from './EventHub'; import { isDocument } from '../dom/utils/Common'; import { getNearestVNode, getNonDelegatedListenerMap } from '../dom/DOMInternalKeys'; import { asyncUpdates, runDiscreteUpdates } from '../renderer/TreeBuilder'; -import { handleEventMain } from './HorizonEventMain'; +import { handleEventMain } from './InulaEventMain'; import { decorateNativeEvent } from './EventWrapper'; import { VNode } from '../renderer/vnode/VNode'; @@ -55,11 +55,11 @@ function listenToNativeEvent(nativeEvtName: string, delegatedElement: Element, i } // 是否捕获事件 -function isCaptureEvent(horizonEventName) { - if (horizonEventName === 'onLostPointerCapture' || horizonEventName === 'onGotPointerCapture') { +function isCaptureEvent(inulaEventName) { + if (inulaEventName === 'onLostPointerCapture' || inulaEventName === 'onGotPointerCapture') { return false; } - return horizonEventName.slice(-7) === 'Capture'; + return inulaEventName.slice(-7) === 'Capture'; } // 事件懒委托,当用户定义事件后,再进行委托到根节点 @@ -67,7 +67,7 @@ export function lazyDelegateOnRoot(currentRoot: VNode, eventName: string) { currentRoot.delegatedEvents.add(eventName); const isCapture = isCaptureEvent(eventName); - const nativeEvents = allDelegatedHorizonEvents.get(eventName); + const nativeEvents = allDelegatedInulaEvents.get(eventName); nativeEvents.forEach(nativeEvent => { const nativeFullName = isCapture ? nativeEvent + 'capture' : nativeEvent; @@ -89,13 +89,13 @@ export function listenSimulatedDelegatedEvents(root: VNode) { } } -// 通过horizon事件名获取到native事件名 -function getNativeEvtName(horizonEventName, capture) { +// 通过inula事件名获取到native事件名 +function getNativeEvtName(inulaEventName, capture) { let nativeName; if (capture) { - nativeName = horizonEventName.slice(2, -7); + nativeName = inulaEventName.slice(2, -7); } else { - nativeName = horizonEventName.slice(2); + nativeName = inulaEventName.slice(2); } if (!nativeName) { return ''; @@ -104,9 +104,9 @@ function getNativeEvtName(horizonEventName, capture) { } // 封装监听函数 -function getWrapperListener(horizonEventName, nativeEvtName, targetElement, listener) { +function getWrapperListener(inulaEventName, nativeEvtName, targetElement, listener) { return event => { - const customEvent = decorateNativeEvent(horizonEventName, nativeEvtName, event); + const customEvent = decorateNativeEvent(inulaEventName, nativeEvtName, event); asyncUpdates(() => { listener(customEvent); }); @@ -114,16 +114,16 @@ function getWrapperListener(horizonEventName, nativeEvtName, targetElement, list } // 非委托事件单独监听到各自dom节点 -export function listenNonDelegatedEvent(horizonEventName: string, domElement: Element, listener): void { - const isCapture = isCaptureEvent(horizonEventName); - const nativeEvtName = getNativeEvtName(horizonEventName, isCapture); +export function listenNonDelegatedEvent(inulaEventName: string, domElement: Element, listener): void { + const isCapture = isCaptureEvent(inulaEventName); + const nativeEvtName = getNativeEvtName(inulaEventName, isCapture); // 先判断是否存在老的监听事件,若存在则移除 const nonDelegatedListenerMap = getNonDelegatedListenerMap(domElement); - const currentListener = nonDelegatedListenerMap.get(horizonEventName); + const currentListener = nonDelegatedListenerMap.get(inulaEventName); if (currentListener) { domElement.removeEventListener(nativeEvtName, currentListener); - nonDelegatedListenerMap.delete(horizonEventName); + nonDelegatedListenerMap.delete(inulaEventName); } if (typeof listener !== 'function') { @@ -131,8 +131,8 @@ export function listenNonDelegatedEvent(horizonEventName: string, domElement: El } // 为了和委托事件对外行为一致,将事件对象封装成CustomBaseEvent - const wrapperListener = getWrapperListener(horizonEventName, nativeEvtName, domElement, listener); + const wrapperListener = getWrapperListener(inulaEventName, nativeEvtName, domElement, listener); // 添加新的监听 - nonDelegatedListenerMap.set(horizonEventName, wrapperListener); + nonDelegatedListenerMap.set(inulaEventName, wrapperListener); domElement.addEventListener(nativeEvtName, wrapperListener, isCapture); } diff --git a/libs/horizon/src/event/EventHub.ts b/libs/inula/src/event/EventHub.ts similarity index 85% rename from libs/horizon/src/event/EventHub.ts rename to libs/inula/src/event/EventHub.ts index 992f1457..d813b247 100644 --- a/libs/horizon/src/event/EventHub.ts +++ b/libs/inula/src/event/EventHub.ts @@ -13,16 +13,16 @@ * See the Mulan PSL v2 for more details. */ -// 需要委托的horizon事件和原生事件对应关系 -export const allDelegatedHorizonEvents = new Map(); +// 需要委托的inula事件和原生事件对应关系 +export const allDelegatedInulaEvents = new Map(); // 模拟委托事件,不冒泡事件需要利用其他事件来触发冒泡过程 export const simulatedDelegatedEvents = ['onMouseEnter', 'onMouseLeave']; // 所有委托的原生事件集合 export const allDelegatedNativeEvents = new Set(); -// Horizon事件和原生事件对应关系 -export const horizonEventToNativeMap = new Map([ +// Inula事件和原生事件对应关系 +export const inulaEventToNativeMap = new Map([ ['onKeyPress', ['keypress']], ['onTextInput', ['textInput']], ['onClick', ['click']], @@ -60,7 +60,7 @@ export const horizonEventToNativeMap = new Map([ ['onAnimationStart', ['animationstart']], ['onTransitionEnd', ['transitionend']], ]); -export const NativeEventToHorizonMap = { +export const NativeEventToInulaMap = { click: 'click', wheel: 'wheel', dblclick: 'doubleClick', @@ -99,17 +99,17 @@ export const EVENT_TYPE_BUBBLE = 'Bubble'; export const EVENT_TYPE_CAPTURE = 'Capture'; export const EVENT_TYPE_ALL = 'All'; -horizonEventToNativeMap.forEach((dependencies, horizonEvent) => { - allDelegatedHorizonEvents.set(horizonEvent, dependencies); - allDelegatedHorizonEvents.set(horizonEvent + 'Capture', dependencies); +inulaEventToNativeMap.forEach((dependencies, inulaEvent) => { + allDelegatedInulaEvents.set(inulaEvent, dependencies); + allDelegatedInulaEvents.set(inulaEvent + 'Capture', dependencies); dependencies.forEach(d => { allDelegatedNativeEvents.add(d); }); }); -export function transformToHorizonEvent(nativeEvtName: string) { - const name = NativeEventToHorizonMap[nativeEvtName]; +export function transformToInulaEvent(nativeEvtName: string) { + const name = NativeEventToInulaMap[nativeEvtName]; // 例:dragEnd -> onDragEnd return !name ? '' : `on${name[0].toUpperCase()}${name.slice(1)}`; } diff --git a/libs/horizon/src/event/EventWrapper.ts b/libs/inula/src/event/EventWrapper.ts similarity index 100% rename from libs/horizon/src/event/EventWrapper.ts rename to libs/inula/src/event/EventWrapper.ts diff --git a/libs/horizon/src/event/FormValueController.ts b/libs/inula/src/event/FormValueController.ts similarity index 100% rename from libs/horizon/src/event/FormValueController.ts rename to libs/inula/src/event/FormValueController.ts diff --git a/libs/horizon/src/event/HorizonEventMain.ts b/libs/inula/src/event/InulaEventMain.ts similarity index 87% rename from libs/horizon/src/event/HorizonEventMain.ts rename to libs/inula/src/event/InulaEventMain.ts index 9330af30..08e5f892 100644 --- a/libs/horizon/src/event/HorizonEventMain.ts +++ b/libs/inula/src/event/InulaEventMain.ts @@ -24,8 +24,8 @@ import { EVENT_TYPE_ALL, EVENT_TYPE_BUBBLE, EVENT_TYPE_CAPTURE, - horizonEventToNativeMap, - transformToHorizonEvent, + inulaEventToNativeMap, + transformToInulaEvent, } from './EventHub'; import { getDomTag } from '../dom/utils/Common'; import { updateInputHandlerIfChanged } from '../dom/valueHandler/ValueChangeHandler'; @@ -94,9 +94,9 @@ function getCommonListeners( target: null | EventTarget, isCapture: boolean ): ListenerUnitList { - const horizonEvtName = transformToHorizonEvent(nativeEvtName); + const inulaEvtName = transformToInulaEvent(nativeEvtName); - if (!horizonEvtName) { + if (!inulaEvtName) { return []; } @@ -113,8 +113,8 @@ function getCommonListeners( nativeEvtName = 'blur'; } - const horizonEvent = decorateNativeEvent(horizonEvtName, nativeEvtName, nativeEvent); - return getListenersFromTree(vNode, horizonEvtName, horizonEvent, isCapture ? EVENT_TYPE_CAPTURE : EVENT_TYPE_BUBBLE); + const inulaEvent = decorateNativeEvent(inulaEvtName, nativeEvtName, nativeEvent); + return getListenersFromTree(vNode, inulaEvtName, inulaEvent, isCapture ? EVENT_TYPE_CAPTURE : EVENT_TYPE_BUBBLE); } // 按顺序执行事件队列 @@ -132,8 +132,8 @@ function processListeners(listenerList: ListenerUnitList): void { }); } -// 触发可以被执行的horizon事件监听 -function triggerHorizonEvents( +// 触发可以被执行的inula事件监听 +function triggerInulaEvents( nativeEvtName: string, isCapture: boolean, nativeEvent: AnyNativeEvent, @@ -145,7 +145,7 @@ function triggerHorizonEvents( const listenerList: ListenerUnitList = getCommonListeners(nativeEvtName, vNode, nativeEvent, target, isCapture); let mouseEnterListeners: ListenerUnitList = []; - if (horizonEventToNativeMap.get('onMouseEnter')!.includes(nativeEvtName)) { + if (inulaEventToNativeMap.get('onMouseEnter')!.includes(nativeEvtName)) { mouseEnterListeners = getMouseEnterListeners( nativeEvtName, vNode, @@ -156,7 +156,7 @@ function triggerHorizonEvents( let changeEvents: ListenerUnitList = []; // 触发特殊handler委托事件 - if (!isCapture && horizonEventToNativeMap.get('onChange')!.includes(nativeEvtName)) { + if (!isCapture && inulaEventToNativeMap.get('onChange')!.includes(nativeEvtName)) { changeEvents = getChangeListeners(nativeEvtName, nativeEvent, vNode, target); } @@ -185,14 +185,14 @@ export function handleEventMain( // 有事件正在执行,同步执行事件 if (isInEventsExecution) { - triggerHorizonEvents(nativeEvtName, isCapture, nativeEvent, startVNode); + triggerInulaEvents(nativeEvtName, isCapture, nativeEvent, startVNode); return; } // 没有事件在执行,经过调度再执行事件 isInEventsExecution = true; try { - asyncUpdates(() => triggerHorizonEvents(nativeEvtName, isCapture, nativeEvent, startVNode)); + asyncUpdates(() => triggerInulaEvents(nativeEvtName, isCapture, nativeEvent, startVNode)); } finally { isInEventsExecution = false; if (shouldControlValue()) { diff --git a/libs/horizon/src/event/ListenerGetter.ts b/libs/inula/src/event/ListenerGetter.ts similarity index 96% rename from libs/horizon/src/event/ListenerGetter.ts rename to libs/inula/src/event/ListenerGetter.ts index c6562d3c..2a387771 100644 --- a/libs/horizon/src/event/ListenerGetter.ts +++ b/libs/inula/src/event/ListenerGetter.ts @@ -40,11 +40,11 @@ function getListenerFromVNode(vNode: VNode, eventName: string): Function | null // 获取监听事件 export function getListenersFromTree( targetVNode: VNode | null, - horizonEvtName: string | null, + inulaEvtName: string | null, nativeEvent: WrappedEvent, eventType: string ): ListenerUnitList { - if (!horizonEvtName) { + if (!inulaEvtName) { return []; } @@ -57,7 +57,7 @@ export function getListenersFromTree( const { realNode, tag } = vNode; if (tag === DomComponent && realNode !== null) { if (eventType === EVENT_TYPE_ALL || eventType === EVENT_TYPE_CAPTURE) { - const captureName = horizonEvtName + EVENT_TYPE_CAPTURE; + const captureName = inulaEvtName + EVENT_TYPE_CAPTURE; const captureListener = getListenerFromVNode(vNode, captureName); if (captureListener) { listeners.unshift({ @@ -70,7 +70,7 @@ export function getListenersFromTree( } if (eventType === EVENT_TYPE_ALL || eventType === EVENT_TYPE_BUBBLE) { - const bubbleListener = getListenerFromVNode(vNode, horizonEvtName); + const bubbleListener = getListenerFromVNode(vNode, inulaEvtName); if (bubbleListener) { listeners.push({ vNode, diff --git a/libs/horizon/src/event/MouseEvent.ts b/libs/inula/src/event/MouseEvent.ts similarity index 100% rename from libs/horizon/src/event/MouseEvent.ts rename to libs/inula/src/event/MouseEvent.ts diff --git a/libs/horizon/src/event/Types.ts b/libs/inula/src/event/Types.ts similarity index 92% rename from libs/horizon/src/event/Types.ts rename to libs/inula/src/event/Types.ts index e4f839aa..4ef5125a 100644 --- a/libs/horizon/src/event/Types.ts +++ b/libs/inula/src/event/Types.ts @@ -18,13 +18,13 @@ import { WrappedEvent } from './EventWrapper'; export type AnyNativeEvent = KeyboardEvent | MouseEvent | TouchEvent | UIEvent | Event; -export interface HorizonEventListener { +export interface InulaEventListener { (event: WrappedEvent): void; } export type ListenerUnit = { vNode: null | VNode; - listener: HorizonEventListener; + listener: InulaEventListener; currentTarget: EventTarget; event: WrappedEvent; }; diff --git a/libs/horizon/src/event/utils.ts b/libs/inula/src/event/utils.ts similarity index 100% rename from libs/horizon/src/event/utils.ts rename to libs/inula/src/event/utils.ts diff --git a/libs/horizon/src/external/ChildrenUtil.ts b/libs/inula/src/external/ChildrenUtil.ts similarity index 96% rename from libs/horizon/src/external/ChildrenUtil.ts rename to libs/inula/src/external/ChildrenUtil.ts index 96e41bdc..64d56f28 100644 --- a/libs/horizon/src/external/ChildrenUtil.ts +++ b/libs/inula/src/external/ChildrenUtil.ts @@ -88,7 +88,7 @@ function mapChildrenToArray(children: any, arr: Array, prefix: string, call processArrayChildren(children, arr, prefix, callback); return; } - throw new Error('Object is invalid as a Horizon child. '); + throw new Error('Object is invalid as a Inula child. '); // No Default } } @@ -119,7 +119,7 @@ const Children = { return n; }, only: children => { - throwIfTrue(!isValidElement(children), 'Horizon.Children.only function received invalid element.'); + throwIfTrue(!isValidElement(children), 'Inula.Children.only function received invalid element.'); return children; }, toArray: children => { diff --git a/libs/horizon/src/external/HorizonIs.ts b/libs/inula/src/external/InulaIs.ts similarity index 100% rename from libs/horizon/src/external/HorizonIs.ts rename to libs/inula/src/external/InulaIs.ts diff --git a/libs/horizon/src/external/JSXElement.ts b/libs/inula/src/external/JSXElement.ts similarity index 100% rename from libs/horizon/src/external/JSXElement.ts rename to libs/inula/src/external/JSXElement.ts diff --git a/libs/horizon/src/external/JSXElementType.ts b/libs/inula/src/external/JSXElementType.ts similarity index 100% rename from libs/horizon/src/external/JSXElementType.ts rename to libs/inula/src/external/JSXElementType.ts diff --git a/libs/horizon/src/external/TestUtil.ts b/libs/inula/src/external/TestUtil.ts similarity index 100% rename from libs/horizon/src/external/TestUtil.ts rename to libs/inula/src/external/TestUtil.ts diff --git a/libs/horizon/src/external/devtools.ts b/libs/inula/src/external/devtools.ts similarity index 99% rename from libs/horizon/src/external/devtools.ts rename to libs/inula/src/external/devtools.ts index b1802cc7..21648f4b 100644 --- a/libs/horizon/src/external/devtools.ts +++ b/libs/inula/src/external/devtools.ts @@ -128,7 +128,7 @@ export const helper = { }; export function injectUpdater() { - const hook = window.__HORIZON_DEV_HOOK__; + const hook = window.__INULA_DEV_HOOK__; if (hook) { hook.init(helper); } diff --git a/libs/horizon/src/horizonx/CommonUtils.ts b/libs/inula/src/inulax/CommonUtils.ts similarity index 99% rename from libs/horizon/src/horizonx/CommonUtils.ts rename to libs/inula/src/inulax/CommonUtils.ts index 46f82ba5..c4330834 100644 --- a/libs/horizon/src/horizonx/CommonUtils.ts +++ b/libs/inula/src/inulax/CommonUtils.ts @@ -138,7 +138,7 @@ export function resolveMutation(from, to) { } } - let keys = Object.keys({ ...from, ...to }).filter(key => key !== '_horizonObserver'); + let keys = Object.keys({ ...from, ...to }).filter(key => key !== '_inulaObserver'); const res = {}; let found = false; keys.forEach(key => { diff --git a/libs/horizon/src/horizonx/Constants.ts b/libs/inula/src/inulax/Constants.ts similarity index 93% rename from libs/horizon/src/horizonx/Constants.ts rename to libs/inula/src/inulax/Constants.ts index c18ce664..1e841db7 100644 --- a/libs/horizon/src/horizonx/Constants.ts +++ b/libs/inula/src/inulax/Constants.ts @@ -13,6 +13,6 @@ * See the Mulan PSL v2 for more details. */ -export const OBSERVER_KEY = typeof Symbol === 'function' ? Symbol('_horizonObserver') : '_horizonObserver'; +export const OBSERVER_KEY = typeof Symbol === 'function' ? Symbol('_inulaObserver') : '_inulaObserver'; export const RAW_VALUE = '_rawValue'; diff --git a/libs/horizon/src/horizonx/adapters/redux.ts b/libs/inula/src/inulax/adapters/redux.ts similarity index 97% rename from libs/horizon/src/horizonx/adapters/redux.ts rename to libs/inula/src/inulax/adapters/redux.ts index 6930ecd9..a196a486 100644 --- a/libs/horizon/src/horizonx/adapters/redux.ts +++ b/libs/inula/src/inulax/adapters/redux.ts @@ -126,13 +126,13 @@ export function createStore(reducer: Reducer, preloadedState?: any, enhancers?): replaceReducer: newReducer => { reducer = newReducer; }, - _horizonXstore: store, + _inulaXstore: store, dispatch: store.$a.dispatch, }; enhancers && enhancers(result); - result.dispatch({ type: 'HorizonX' }); + result.dispatch({ type: 'InulaX' }); store.reduxHandler = result; @@ -197,7 +197,7 @@ export function compose(...middlewares: ReduxMiddleware[]) { }; } -// HorizonX batches updates by default, this function is only for backwards compatibility +// InulaX batches updates by default, this function is only for backwards compatibility export function batch(fn: () => void) { fn(); } diff --git a/libs/horizon/src/horizonx/adapters/reduxReact.ts b/libs/inula/src/inulax/adapters/reduxReact.ts similarity index 98% rename from libs/horizon/src/horizonx/adapters/reduxReact.ts rename to libs/inula/src/inulax/adapters/reduxReact.ts index 31468796..d4dddbd3 100644 --- a/libs/horizon/src/horizonx/adapters/reduxReact.ts +++ b/libs/inula/src/inulax/adapters/reduxReact.ts @@ -30,7 +30,7 @@ export function Provider({ context: Context; children?: any[]; }) { - const Context = context; // NOTE: bind redux API to horizon API requires this renaming; + const Context = context; // NOTE: bind redux API to inula API requires this renaming; return createElement(Context.Provider, { value: store }, children); } diff --git a/libs/horizon/src/horizonx/adapters/reduxThunk.ts b/libs/inula/src/inulax/adapters/reduxThunk.ts similarity index 100% rename from libs/horizon/src/horizonx/adapters/reduxThunk.ts rename to libs/inula/src/inulax/adapters/reduxThunk.ts diff --git a/libs/inula/src/inulax/devtools/constants.ts b/libs/inula/src/inulax/devtools/constants.ts new file mode 100644 index 00000000..f6478862 --- /dev/null +++ b/libs/inula/src/inulax/devtools/constants.ts @@ -0,0 +1,10 @@ +export const INITIALIZED = 'inulax store initialized'; +export const STATE_CHANGE = 'inulax state change'; +export const SUBSCRIBED = 'inulax subscribed'; +export const UNSUBSCRIBED = 'inulax unsubscribed'; +export const ACTION = 'inulax action'; +export const ACTION_QUEUED = 'inulax action queued'; +export const QUEUE_PENDING = 'inulax queue pending'; +export const QUEUE_FINISHED = 'inulax queue finished'; +export const RENDER_TRIGGERED = 'inulax render triggered'; +export const OBSERVED_COMPONENTS = 'inulax observed components'; diff --git a/libs/horizon/src/horizonx/devtools/index.ts b/libs/inula/src/inulax/devtools/index.ts similarity index 84% rename from libs/horizon/src/horizonx/devtools/index.ts rename to libs/inula/src/inulax/devtools/index.ts index 711c0d62..e7b51b78 100644 --- a/libs/horizon/src/horizonx/devtools/index.ts +++ b/libs/inula/src/inulax/devtools/index.ts @@ -7,7 +7,7 @@ const sessionId = Date.now(); // this function is used to detect devtool connection export function isPanelActive() { - return window['__HORIZON_DEV_HOOK__']; + return window['__INULA_DEV_HOOK__']; } // safely serializes variables containing values wrapped in Proxy object @@ -44,7 +44,7 @@ function makeProxySnapshot(obj, visited: any[] = []) { if (type === 'vnode') { return { _type: 'VNode', - id: window['__HORIZON_DEV_HOOK__'].getVnodeId(obj), + id: window['__INULA_DEV_HOOK__'].getVnodeId(obj), tag: obj.tag, }; } @@ -114,39 +114,39 @@ function makeStoreSnapshot({ type, data }) { } export const devtools = { - // returns vNode id from horizon devtools + // returns vNode id from inula devtools getVNodeId: vNode => { if (!isPanelActive()) { return null; } - window['__HORIZON_DEV_HOOK__'].send(); // update list first - return window['__HORIZON_DEV_HOOK__'].getVnodeId(vNode); + window['__INULA_DEV_HOOK__'].send(); // update list first + return window['__INULA_DEV_HOOK__'].getVnodeId(vNode); }, - // sends horizonx devtool message to extension + // sends inulax devtool message to extension emit: (type, data) => { if (!isPanelActive()) { return; } window.postMessage({ - type: 'HORIZON_DEV_TOOLS', + type: 'INULA_DEV_TOOLS', payload: makeStoreSnapshot({ type, data }), from: 'dev tool hook', }, ''); }, }; -// collects components that are dependant on horizonx store and their ids +// collects components that are dependant on inulax store and their ids function getAffectedComponents() { const allStores = getAllStores(); const keys = Object.keys(allStores); const res = {}; keys.forEach(key => { - if (!allStores[key].$config.state._horizonObserver.keyVNodes) { + if (!allStores[key].$config.state._inulaObserver.keyVNodes) { res[key] = []; return; } const subRes = new Set(); - const process = Array.from(allStores[key].$config.state._horizonObserver.keyVNodes.values()); + const process = Array.from(allStores[key].$config.state._inulaObserver.keyVNodes.values()); while (process.length) { const pivot = process.shift() as { tag: 'string' }; if (pivot.tag) subRes.add(pivot); @@ -158,7 +158,7 @@ function getAffectedComponents() { .toString() .replace(/\{.*\}/, '{...}') .replace('function ', ''), - nodeId: window.__HORIZON_DEV_HOOK__.getVnodeId(vNode), + nodeId: window.__INULA_DEV_HOOK__.getVnodeId(vNode), }; }); }); @@ -168,11 +168,11 @@ function getAffectedComponents() { // listens to messages from background window.addEventListener('message', (messageEvent?) => { - if (messageEvent?.data?.payload?.type === 'horizonx request observed components') { + if (messageEvent?.data?.payload?.type === 'inulax request observed components') { // get observed components setTimeout(() => { window.postMessage({ - type: 'HORIZON_DEV_TOOLS', + type: 'INULA_DEV_TOOLS', payload: { type: OBSERVED_COMPONENTS, data: getAffectedComponents() }, from: 'dev tool hook', }, ''); @@ -180,7 +180,7 @@ window.addEventListener('message', (messageEvent?) => { } // executes store action - if (messageEvent.data?.payload?.type === 'horizonx executue action') { + if (messageEvent.data?.payload?.type === 'inulax executue action') { const data = messageEvent.data.payload.data; const store = getStore(data.storeId); if (!store?.[data.action]) return; @@ -191,7 +191,7 @@ window.addEventListener('message', (messageEvent?) => { } // queues store action - if (messageEvent?.data?.payload?.type === 'horizonx queue action') { + if (messageEvent?.data?.payload?.type === 'inulax queue action') { const data = messageEvent.data.payload.data; const store = getStore(data.storeId); if (!store?.[data.action]) return; @@ -202,7 +202,7 @@ window.addEventListener('message', (messageEvent?) => { } // queues change store state - if (messageEvent?.data?.payload?.type === 'horizonx change state') { + if (messageEvent?.data?.payload?.type === 'inulax change state') { const data = messageEvent.data.payload; const store = getStore(data.storeId); if (!store) return; diff --git a/libs/horizon/src/horizonx/proxy/HooklessObserver.ts b/libs/inula/src/inulax/proxy/HooklessObserver.ts similarity index 100% rename from libs/horizon/src/horizonx/proxy/HooklessObserver.ts rename to libs/inula/src/inulax/proxy/HooklessObserver.ts diff --git a/libs/horizon/src/horizonx/proxy/Observer.ts b/libs/inula/src/inulax/proxy/Observer.ts similarity index 100% rename from libs/horizon/src/horizonx/proxy/Observer.ts rename to libs/inula/src/inulax/proxy/Observer.ts diff --git a/libs/horizon/src/horizonx/proxy/ProxyHandler.ts b/libs/inula/src/inulax/proxy/ProxyHandler.ts similarity index 100% rename from libs/horizon/src/horizonx/proxy/ProxyHandler.ts rename to libs/inula/src/inulax/proxy/ProxyHandler.ts diff --git a/libs/horizon/src/horizonx/proxy/handlers/ArrayProxyHandler.ts b/libs/inula/src/inulax/proxy/handlers/ArrayProxyHandler.ts similarity index 97% rename from libs/horizon/src/horizonx/proxy/handlers/ArrayProxyHandler.ts rename to libs/inula/src/inulax/proxy/handlers/ArrayProxyHandler.ts index ce6c73c3..0907f33b 100644 --- a/libs/horizon/src/horizonx/proxy/handlers/ArrayProxyHandler.ts +++ b/libs/inula/src/inulax/proxy/handlers/ArrayProxyHandler.ts @@ -57,7 +57,7 @@ export function createArrayProxy(rawObj: any[], listener: { current: (...args) = let listeners = [] as ((...args) => void)[]; function objectGet(rawObj: object, key: string | symbol, receiver: any, singleLevel = false): any { - // The observer object of symbol ('_horizonObserver') cannot be accessed from Proxy to prevent errors caused by clonedeep. + // The observer object of symbol ('_inulaObserver') cannot be accessed from Proxy to prevent errors caused by clonedeep. if (key === OBSERVER_KEY) { return undefined; } diff --git a/libs/horizon/src/horizonx/proxy/handlers/CollectionProxyHandler.ts b/libs/inula/src/inulax/proxy/handlers/CollectionProxyHandler.ts similarity index 100% rename from libs/horizon/src/horizonx/proxy/handlers/CollectionProxyHandler.ts rename to libs/inula/src/inulax/proxy/handlers/CollectionProxyHandler.ts diff --git a/libs/horizon/src/horizonx/proxy/handlers/MapProxy.ts b/libs/inula/src/inulax/proxy/handlers/MapProxy.ts similarity index 100% rename from libs/horizon/src/horizonx/proxy/handlers/MapProxy.ts rename to libs/inula/src/inulax/proxy/handlers/MapProxy.ts diff --git a/libs/horizon/src/horizonx/proxy/handlers/ObjectProxyHandler.ts b/libs/inula/src/inulax/proxy/handlers/ObjectProxyHandler.ts similarity index 96% rename from libs/horizon/src/horizonx/proxy/handlers/ObjectProxyHandler.ts rename to libs/inula/src/inulax/proxy/handlers/ObjectProxyHandler.ts index 88a0c93b..c9e5521d 100644 --- a/libs/horizon/src/horizonx/proxy/handlers/ObjectProxyHandler.ts +++ b/libs/inula/src/inulax/proxy/handlers/ObjectProxyHandler.ts @@ -47,7 +47,7 @@ export function createObjectProxy( let listeners = [] as ((...args) => void)[]; function get(rawObj: object, key: string | symbol, receiver: any): any { - // The observer object of symbol ('_horizonObserver') cannot be accessed from Proxy to prevent errors caused by clonedeep. + // The observer object of symbol ('_inulaObserver') cannot be accessed from Proxy to prevent errors caused by clonedeep. if (key === OBSERVER_KEY) { return undefined; } diff --git a/libs/horizon/src/horizonx/proxy/handlers/SetProxy.ts b/libs/inula/src/inulax/proxy/handlers/SetProxy.ts similarity index 100% rename from libs/horizon/src/horizonx/proxy/handlers/SetProxy.ts rename to libs/inula/src/inulax/proxy/handlers/SetProxy.ts diff --git a/libs/horizon/src/horizonx/proxy/handlers/WeakMapProxy.ts b/libs/inula/src/inulax/proxy/handlers/WeakMapProxy.ts similarity index 100% rename from libs/horizon/src/horizonx/proxy/handlers/WeakMapProxy.ts rename to libs/inula/src/inulax/proxy/handlers/WeakMapProxy.ts diff --git a/libs/horizon/src/horizonx/proxy/handlers/WeakSetProxy.ts b/libs/inula/src/inulax/proxy/handlers/WeakSetProxy.ts similarity index 100% rename from libs/horizon/src/horizonx/proxy/handlers/WeakSetProxy.ts rename to libs/inula/src/inulax/proxy/handlers/WeakSetProxy.ts diff --git a/libs/horizon/src/horizonx/proxy/readonlyProxy.ts b/libs/inula/src/inulax/proxy/readonlyProxy.ts similarity index 100% rename from libs/horizon/src/horizonx/proxy/readonlyProxy.ts rename to libs/inula/src/inulax/proxy/readonlyProxy.ts diff --git a/libs/horizon/src/horizonx/proxy/watch.ts b/libs/inula/src/inulax/proxy/watch.ts similarity index 100% rename from libs/horizon/src/horizonx/proxy/watch.ts rename to libs/inula/src/inulax/proxy/watch.ts diff --git a/libs/horizon/src/horizonx/store/StoreHandler.ts b/libs/inula/src/inulax/store/StoreHandler.ts similarity index 100% rename from libs/horizon/src/horizonx/store/StoreHandler.ts rename to libs/inula/src/inulax/store/StoreHandler.ts diff --git a/libs/horizon/src/horizonx/types.d.ts b/libs/inula/src/inulax/types.d.ts similarity index 100% rename from libs/horizon/src/horizonx/types.d.ts rename to libs/inula/src/inulax/types.d.ts diff --git a/libs/horizon/src/renderer/ContextSaver.ts b/libs/inula/src/renderer/ContextSaver.ts similarity index 100% rename from libs/horizon/src/renderer/ContextSaver.ts rename to libs/inula/src/renderer/ContextSaver.ts diff --git a/libs/horizon/src/renderer/ErrorHandler.ts b/libs/inula/src/renderer/ErrorHandler.ts similarity index 100% rename from libs/horizon/src/renderer/ErrorHandler.ts rename to libs/inula/src/renderer/ErrorHandler.ts diff --git a/libs/horizon/src/renderer/ExecuteMode.ts b/libs/inula/src/renderer/ExecuteMode.ts similarity index 100% rename from libs/horizon/src/renderer/ExecuteMode.ts rename to libs/inula/src/renderer/ExecuteMode.ts diff --git a/libs/horizon/src/renderer/GlobalVar.ts b/libs/inula/src/renderer/GlobalVar.ts similarity index 100% rename from libs/horizon/src/renderer/GlobalVar.ts rename to libs/inula/src/renderer/GlobalVar.ts diff --git a/libs/horizon/src/renderer/Renderer.ts b/libs/inula/src/renderer/Renderer.ts similarity index 100% rename from libs/horizon/src/renderer/Renderer.ts rename to libs/inula/src/renderer/Renderer.ts diff --git a/libs/horizon/src/renderer/RootStack.ts b/libs/inula/src/renderer/RootStack.ts similarity index 100% rename from libs/horizon/src/renderer/RootStack.ts rename to libs/inula/src/renderer/RootStack.ts diff --git a/libs/horizon/src/renderer/TreeBuilder.ts b/libs/inula/src/renderer/TreeBuilder.ts similarity index 96% rename from libs/horizon/src/renderer/TreeBuilder.ts rename to libs/inula/src/renderer/TreeBuilder.ts index 1c3f4202..f079b896 100644 --- a/libs/horizon/src/renderer/TreeBuilder.ts +++ b/libs/inula/src/renderer/TreeBuilder.ts @@ -355,10 +355,10 @@ function renderFromRoot(treeRoot) { submitToRender(treeRoot); popCurrentRoot(); - if (window.__HORIZON_DEV_HOOK__) { - const hook = window.__HORIZON_DEV_HOOK__; - // injector.js 可能在 Horizon 代码之后加载,此时无 __HORIZON_DEV_HOOK__ 全局变量 - // Horizon 代码初次加载时不会初始化 helper + if (window.__INULA_DEV_HOOK__) { + const hook = window.__INULA_DEV_HOOK__; + // injector.js 可能在 Inula 代码之后加载,此时无 __INULA_DEV_HOOK__ 全局变量 + // Inula 代码初次加载时不会初始化 helper if (!hook.isInit) { injectUpdater(); } @@ -398,7 +398,7 @@ export function launchUpdateFromVNode(vNode: VNode) { ) { // 不是渲染阶段触发 - // 业务直接调用Horizon.render的时候会进入这个分支,同步渲染。 + // 业务直接调用Inula.render的时候会进入这个分支,同步渲染。 // 不能改成下面的异步,否则会有时序问题,因为业务可能会依赖这个渲染的完成。 renderFromRoot(treeRoot); } else { @@ -411,7 +411,7 @@ export function launchUpdateFromVNode(vNode: VNode) { } } -// ============================== HorizonDOM使用 ============================== +// ============================== InulaDOM使用 ============================== export function runDiscreteUpdates() { if (checkMode(ByAsync) || checkMode(InRender)) { // 已经渲染,不能再同步执行待工作的任务,有可能是被生命周期或effect触发的事件导致的,如el.focus() diff --git a/libs/horizon/src/renderer/Types.ts b/libs/inula/src/renderer/Types.ts similarity index 100% rename from libs/horizon/src/renderer/Types.ts rename to libs/inula/src/renderer/Types.ts diff --git a/libs/horizon/src/renderer/UpdateHandler.ts b/libs/inula/src/renderer/UpdateHandler.ts similarity index 95% rename from libs/horizon/src/renderer/UpdateHandler.ts rename to libs/inula/src/renderer/UpdateHandler.ts index 7febd61e..21f40299 100644 --- a/libs/horizon/src/renderer/UpdateHandler.ts +++ b/libs/inula/src/renderer/UpdateHandler.ts @@ -35,8 +35,8 @@ export enum UpdateState { export function newUpdate(): Update { return { type: UpdateState.Update, // 更新的类型 - content: null, // ClassComponent的content是setState第一个参数,TreeRoot的content是HorizonDOM.render的第一个参数 - callback: null, // setState的第二个参数,HorizonDOM.render的第三个参数 + content: null, // ClassComponent的content是setState第一个参数,TreeRoot的content是InulaDOM.render的第一个参数 + callback: null, // setState的第二个参数,InulaDOM.render的第三个参数 }; } diff --git a/libs/horizon/src/renderer/components/BaseClassComponent.ts b/libs/inula/src/renderer/components/BaseClassComponent.ts similarity index 100% rename from libs/horizon/src/renderer/components/BaseClassComponent.ts rename to libs/inula/src/renderer/components/BaseClassComponent.ts diff --git a/libs/horizon/src/renderer/components/CreatePortal.ts b/libs/inula/src/renderer/components/CreatePortal.ts similarity index 100% rename from libs/horizon/src/renderer/components/CreatePortal.ts rename to libs/inula/src/renderer/components/CreatePortal.ts diff --git a/libs/horizon/src/renderer/components/CreateRef.ts b/libs/inula/src/renderer/components/CreateRef.ts similarity index 100% rename from libs/horizon/src/renderer/components/CreateRef.ts rename to libs/inula/src/renderer/components/CreateRef.ts diff --git a/libs/horizon/src/renderer/components/ForwardRef.ts b/libs/inula/src/renderer/components/ForwardRef.ts similarity index 100% rename from libs/horizon/src/renderer/components/ForwardRef.ts rename to libs/inula/src/renderer/components/ForwardRef.ts diff --git a/libs/horizon/src/renderer/components/Lazy.ts b/libs/inula/src/renderer/components/Lazy.ts similarity index 100% rename from libs/horizon/src/renderer/components/Lazy.ts rename to libs/inula/src/renderer/components/Lazy.ts diff --git a/libs/horizon/src/renderer/components/Memo.ts b/libs/inula/src/renderer/components/Memo.ts similarity index 100% rename from libs/horizon/src/renderer/components/Memo.ts rename to libs/inula/src/renderer/components/Memo.ts diff --git a/libs/horizon/src/renderer/components/context/Context.ts b/libs/inula/src/renderer/components/context/Context.ts similarity index 100% rename from libs/horizon/src/renderer/components/context/Context.ts rename to libs/inula/src/renderer/components/context/Context.ts diff --git a/libs/horizon/src/renderer/components/context/CreateContext.ts b/libs/inula/src/renderer/components/context/CreateContext.ts similarity index 100% rename from libs/horizon/src/renderer/components/context/CreateContext.ts rename to libs/inula/src/renderer/components/context/CreateContext.ts diff --git a/libs/horizon/src/renderer/diff/DiffTools.ts b/libs/inula/src/renderer/diff/DiffTools.ts similarity index 100% rename from libs/horizon/src/renderer/diff/DiffTools.ts rename to libs/inula/src/renderer/diff/DiffTools.ts diff --git a/libs/horizon/src/renderer/diff/nodeDiffComparator.ts b/libs/inula/src/renderer/diff/nodeDiffComparator.ts similarity index 100% rename from libs/horizon/src/renderer/diff/nodeDiffComparator.ts rename to libs/inula/src/renderer/diff/nodeDiffComparator.ts diff --git a/libs/horizon/src/renderer/hooks/BaseHook.ts b/libs/inula/src/renderer/hooks/BaseHook.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/BaseHook.ts rename to libs/inula/src/renderer/hooks/BaseHook.ts diff --git a/libs/horizon/src/renderer/hooks/EffectConstant.js b/libs/inula/src/renderer/hooks/EffectConstant.js similarity index 100% rename from libs/horizon/src/renderer/hooks/EffectConstant.js rename to libs/inula/src/renderer/hooks/EffectConstant.js diff --git a/libs/horizon/src/renderer/hooks/HookExternal.ts b/libs/inula/src/renderer/hooks/HookExternal.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/HookExternal.ts rename to libs/inula/src/renderer/hooks/HookExternal.ts diff --git a/libs/horizon/src/renderer/hooks/HookMain.ts b/libs/inula/src/renderer/hooks/HookMain.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/HookMain.ts rename to libs/inula/src/renderer/hooks/HookMain.ts diff --git a/libs/horizon/src/renderer/hooks/HookStage.ts b/libs/inula/src/renderer/hooks/HookStage.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/HookStage.ts rename to libs/inula/src/renderer/hooks/HookStage.ts diff --git a/libs/horizon/src/renderer/hooks/HookType.ts b/libs/inula/src/renderer/hooks/HookType.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/HookType.ts rename to libs/inula/src/renderer/hooks/HookType.ts diff --git a/libs/horizon/src/renderer/hooks/UseCallbackHook.ts b/libs/inula/src/renderer/hooks/UseCallbackHook.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/UseCallbackHook.ts rename to libs/inula/src/renderer/hooks/UseCallbackHook.ts diff --git a/libs/horizon/src/renderer/hooks/UseEffectHook.ts b/libs/inula/src/renderer/hooks/UseEffectHook.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/UseEffectHook.ts rename to libs/inula/src/renderer/hooks/UseEffectHook.ts diff --git a/libs/horizon/src/renderer/hooks/UseImperativeHook.ts b/libs/inula/src/renderer/hooks/UseImperativeHook.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/UseImperativeHook.ts rename to libs/inula/src/renderer/hooks/UseImperativeHook.ts diff --git a/libs/horizon/src/renderer/hooks/UseMemoHook.ts b/libs/inula/src/renderer/hooks/UseMemoHook.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/UseMemoHook.ts rename to libs/inula/src/renderer/hooks/UseMemoHook.ts diff --git a/libs/horizon/src/renderer/hooks/UseReducerHook.ts b/libs/inula/src/renderer/hooks/UseReducerHook.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/UseReducerHook.ts rename to libs/inula/src/renderer/hooks/UseReducerHook.ts diff --git a/libs/horizon/src/renderer/hooks/UseRefHook.ts b/libs/inula/src/renderer/hooks/UseRefHook.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/UseRefHook.ts rename to libs/inula/src/renderer/hooks/UseRefHook.ts diff --git a/libs/horizon/src/renderer/hooks/UseStateHook.ts b/libs/inula/src/renderer/hooks/UseStateHook.ts similarity index 100% rename from libs/horizon/src/renderer/hooks/UseStateHook.ts rename to libs/inula/src/renderer/hooks/UseStateHook.ts diff --git a/libs/horizon/src/renderer/render/BaseComponent.ts b/libs/inula/src/renderer/render/BaseComponent.ts similarity index 97% rename from libs/horizon/src/renderer/render/BaseComponent.ts rename to libs/inula/src/renderer/render/BaseComponent.ts index 7c86a0ca..e3b08455 100644 --- a/libs/horizon/src/renderer/render/BaseComponent.ts +++ b/libs/inula/src/renderer/render/BaseComponent.ts @@ -21,7 +21,7 @@ import { FlagUtils } from '../vnode/VNodeFlags'; import { onlyUpdateChildVNodes } from '../vnode/VNodeCreator'; import componentRenders from './index'; import { setProcessingVNode } from '../GlobalVar'; -import { clearVNodeObservers } from '../../horizonx/store/StoreHandler'; +import { clearVNodeObservers } from '../../inulax/store/StoreHandler'; import { pushCurrentRoot } from '../RootStack'; // 复用vNode时,也需对树的上下文值处理,如context,portal, namespaceContext diff --git a/libs/horizon/src/renderer/render/ClassComponent.ts b/libs/inula/src/renderer/render/ClassComponent.ts similarity index 100% rename from libs/horizon/src/renderer/render/ClassComponent.ts rename to libs/inula/src/renderer/render/ClassComponent.ts diff --git a/libs/horizon/src/renderer/render/ContextConsumer.ts b/libs/inula/src/renderer/render/ContextConsumer.ts similarity index 100% rename from libs/horizon/src/renderer/render/ContextConsumer.ts rename to libs/inula/src/renderer/render/ContextConsumer.ts diff --git a/libs/horizon/src/renderer/render/ContextProvider.ts b/libs/inula/src/renderer/render/ContextProvider.ts similarity index 100% rename from libs/horizon/src/renderer/render/ContextProvider.ts rename to libs/inula/src/renderer/render/ContextProvider.ts diff --git a/libs/horizon/src/renderer/render/DomComponent.ts b/libs/inula/src/renderer/render/DomComponent.ts similarity index 100% rename from libs/horizon/src/renderer/render/DomComponent.ts rename to libs/inula/src/renderer/render/DomComponent.ts diff --git a/libs/horizon/src/renderer/render/DomPortal.ts b/libs/inula/src/renderer/render/DomPortal.ts similarity index 100% rename from libs/horizon/src/renderer/render/DomPortal.ts rename to libs/inula/src/renderer/render/DomPortal.ts diff --git a/libs/horizon/src/renderer/render/DomText.ts b/libs/inula/src/renderer/render/DomText.ts similarity index 96% rename from libs/horizon/src/renderer/render/DomText.ts rename to libs/inula/src/renderer/render/DomText.ts index 213f9f8b..8e90e88b 100644 --- a/libs/horizon/src/renderer/render/DomText.ts +++ b/libs/inula/src/renderer/render/DomText.ts @@ -41,7 +41,7 @@ export function bubbleRender(processing: VNode) { throwIfTrue( processing.realNode === null, 'We must have new text for new mounted node. This error is likely ' + - 'caused by a bug in Horizon. Please file an issue.' + 'caused by a bug in Inula. Please file an issue.' ); } // 获得对应节点 diff --git a/libs/horizon/src/renderer/render/ForwardRef.ts b/libs/inula/src/renderer/render/ForwardRef.ts similarity index 100% rename from libs/horizon/src/renderer/render/ForwardRef.ts rename to libs/inula/src/renderer/render/ForwardRef.ts diff --git a/libs/horizon/src/renderer/render/Fragment.ts b/libs/inula/src/renderer/render/Fragment.ts similarity index 100% rename from libs/horizon/src/renderer/render/Fragment.ts rename to libs/inula/src/renderer/render/Fragment.ts diff --git a/libs/horizon/src/renderer/render/FunctionComponent.ts b/libs/inula/src/renderer/render/FunctionComponent.ts similarity index 100% rename from libs/horizon/src/renderer/render/FunctionComponent.ts rename to libs/inula/src/renderer/render/FunctionComponent.ts diff --git a/libs/horizon/src/renderer/render/LazyComponent.ts b/libs/inula/src/renderer/render/LazyComponent.ts similarity index 100% rename from libs/horizon/src/renderer/render/LazyComponent.ts rename to libs/inula/src/renderer/render/LazyComponent.ts diff --git a/libs/horizon/src/renderer/render/MemoComponent.ts b/libs/inula/src/renderer/render/MemoComponent.ts similarity index 97% rename from libs/horizon/src/renderer/render/MemoComponent.ts rename to libs/inula/src/renderer/render/MemoComponent.ts index 95ebb64c..a229093c 100644 --- a/libs/horizon/src/renderer/render/MemoComponent.ts +++ b/libs/inula/src/renderer/render/MemoComponent.ts @@ -32,7 +32,7 @@ export function captureMemoComponent(processing: VNode, shouldUpdate: boolean): const Component = processing.type; // 合并 函数组件或类组件 的defaultProps let newProps = mergeDefaultProps(Component, processing.props); - // 解决Horizon.memo(Horizon.forwardRef(()=>{}))两层包装的场景 + // 解决Inula.memo(Inula.forwardRef(()=>{}))两层包装的场景 newProps = mergeDefaultProps(Component.type, newProps); if (processing.isCreated) { diff --git a/libs/horizon/src/renderer/render/SuspenseComponent.ts b/libs/inula/src/renderer/render/SuspenseComponent.ts similarity index 100% rename from libs/horizon/src/renderer/render/SuspenseComponent.ts rename to libs/inula/src/renderer/render/SuspenseComponent.ts diff --git a/libs/horizon/src/renderer/render/TreeRoot.ts b/libs/inula/src/renderer/render/TreeRoot.ts similarity index 100% rename from libs/horizon/src/renderer/render/TreeRoot.ts rename to libs/inula/src/renderer/render/TreeRoot.ts diff --git a/libs/horizon/src/renderer/render/class/ClassLifeCycleProcessor.ts b/libs/inula/src/renderer/render/class/ClassLifeCycleProcessor.ts similarity index 100% rename from libs/horizon/src/renderer/render/class/ClassLifeCycleProcessor.ts rename to libs/inula/src/renderer/render/class/ClassLifeCycleProcessor.ts diff --git a/libs/horizon/src/renderer/render/index.ts b/libs/inula/src/renderer/render/index.ts similarity index 100% rename from libs/horizon/src/renderer/render/index.ts rename to libs/inula/src/renderer/render/index.ts diff --git a/libs/horizon/src/renderer/submit/HookEffectHandler.ts b/libs/inula/src/renderer/submit/HookEffectHandler.ts similarity index 100% rename from libs/horizon/src/renderer/submit/HookEffectHandler.ts rename to libs/inula/src/renderer/submit/HookEffectHandler.ts diff --git a/libs/horizon/src/renderer/submit/LifeCycleHandler.ts b/libs/inula/src/renderer/submit/LifeCycleHandler.ts similarity index 98% rename from libs/horizon/src/renderer/submit/LifeCycleHandler.ts rename to libs/inula/src/renderer/submit/LifeCycleHandler.ts index d405b73e..35aaa7ba 100644 --- a/libs/horizon/src/renderer/submit/LifeCycleHandler.ts +++ b/libs/inula/src/renderer/submit/LifeCycleHandler.ts @@ -268,7 +268,7 @@ function unmountVNode(vNode: VNode): void { callComponentWillUnmount(vNode, instance); } - // HorizonX会在classComponentWillUnmount中清除对VNode的引入用 + // InulaX会在classComponentWillUnmount中清除对VNode的引入用 if (vNode.classComponentWillUnmount) { vNode.classComponentWillUnmount(vNode); vNode.classComponentWillUnmount = null; @@ -345,9 +345,9 @@ function submitAddition(vNode: VNode): void { function submitClear(vNode: VNode): void { const realNode = vNode.realNode; - const cloneDom = realNode.cloneNode(false); // 复制节点后horizon添加给dom的属性未能复制 + const cloneDom = realNode.cloneNode(false); // 复制节点后inula添加给dom的属性未能复制 // 真实 dom 获取的keys只包含新增的属性 - // 比如真实 dom 拿到的 keys 一般只有两个 horizon 自定义属性 + // 比如真实 dom 拿到的 keys 一般只有两个 inula 自定义属性 // 但考虑到用户可能自定义其他属性,所以采用遍历赋值的方式 const customizeKeys = Object.keys(realNode); const keyLength = customizeKeys.length; diff --git a/libs/horizon/src/renderer/submit/Submit.ts b/libs/inula/src/renderer/submit/Submit.ts similarity index 100% rename from libs/horizon/src/renderer/submit/Submit.ts rename to libs/inula/src/renderer/submit/Submit.ts diff --git a/libs/horizon/src/renderer/taskExecutor/BrowserAsync.ts b/libs/inula/src/renderer/taskExecutor/BrowserAsync.ts similarity index 100% rename from libs/horizon/src/renderer/taskExecutor/BrowserAsync.ts rename to libs/inula/src/renderer/taskExecutor/BrowserAsync.ts diff --git a/libs/horizon/src/renderer/taskExecutor/RenderQueue.ts b/libs/inula/src/renderer/taskExecutor/RenderQueue.ts similarity index 100% rename from libs/horizon/src/renderer/taskExecutor/RenderQueue.ts rename to libs/inula/src/renderer/taskExecutor/RenderQueue.ts diff --git a/libs/horizon/src/renderer/taskExecutor/TaskExecutor.ts b/libs/inula/src/renderer/taskExecutor/TaskExecutor.ts similarity index 100% rename from libs/horizon/src/renderer/taskExecutor/TaskExecutor.ts rename to libs/inula/src/renderer/taskExecutor/TaskExecutor.ts diff --git a/libs/horizon/src/renderer/taskExecutor/TaskQueue.ts b/libs/inula/src/renderer/taskExecutor/TaskQueue.ts similarity index 100% rename from libs/horizon/src/renderer/taskExecutor/TaskQueue.ts rename to libs/inula/src/renderer/taskExecutor/TaskQueue.ts diff --git a/libs/horizon/src/renderer/utils/compare.ts b/libs/inula/src/renderer/utils/compare.ts similarity index 100% rename from libs/horizon/src/renderer/utils/compare.ts rename to libs/inula/src/renderer/utils/compare.ts diff --git a/libs/horizon/src/renderer/utils/throwIfTrue.ts b/libs/inula/src/renderer/utils/throwIfTrue.ts similarity index 100% rename from libs/horizon/src/renderer/utils/throwIfTrue.ts rename to libs/inula/src/renderer/utils/throwIfTrue.ts diff --git a/libs/horizon/src/renderer/utils/vNodePath.ts b/libs/inula/src/renderer/utils/vNodePath.ts similarity index 100% rename from libs/horizon/src/renderer/utils/vNodePath.ts rename to libs/inula/src/renderer/utils/vNodePath.ts diff --git a/libs/horizon/src/renderer/vnode/VNode.ts b/libs/inula/src/renderer/vnode/VNode.ts similarity index 94% rename from libs/horizon/src/renderer/vnode/VNode.ts rename to libs/inula/src/renderer/vnode/VNode.ts index b383e62a..da1b59aa 100644 --- a/libs/horizon/src/renderer/vnode/VNode.ts +++ b/libs/inula/src/renderer/vnode/VNode.ts @@ -36,7 +36,7 @@ import type { VNodeTag } from './VNodeTags'; import type { RefType, ContextType, SuspenseState, Source } from '../Types'; import type { Hook } from '../hooks/HookType'; import { InitFlag } from './VNodeFlags'; -import { Observer } from '../../horizonx/proxy/Observer'; +import { Observer } from '../../inulax/proxy/Observer'; export const BELONG_CLASS_VNODE_KEY = typeof Symbol === 'function' ? Symbol('belongClassVNode') : 'belongClassVNode'; @@ -52,7 +52,7 @@ export class VNode { child: VNode | null = null; // 子节点 next: VNode | null = null; // 兄弟节点 cIndex = 0; // 节点在children数组中的位置 - eIndex = 0; // HorizonElement在jsx中的位置,例如:jsx中的null不会生成vNode,所以eIndex和cIndex不一致 + eIndex = 0; // InulaElement在jsx中的位置,例如:jsx中的null不会生成vNode,所以eIndex和cIndex不一致 ref: RefType | ((handle: any) => void) | null = null; // 包裹一个函数,submit阶段使用,比如将外部useRef生成的对象赋值到ref上 oldProps: any = null; @@ -62,7 +62,7 @@ export class VNode { changeList: any; // DOM的变更列表 effectList: any[] | null; // useEffect 的更新数组 updates: any[] | null; // TreeRoot和ClassComponent使用的更新数组 - stateCallbacks: any[] | null; // 存放存在setState的第二个参数和HorizonDOM.render的第三个参数所在的node数组 + stateCallbacks: any[] | null; // 存放存在setState的第二个参数和InulaDOM.render的第三个参数所在的node数组 isForceUpdate: boolean; // 是否使用强制更新 isSuspended = false; // 是否被suspense打断更新 state: any; // ClassComponent和TreeRoot的状态 @@ -101,10 +101,10 @@ export class VNode { [BELONG_CLASS_VNODE_KEY]: VNode | null = null; // 记录JSXElement所属class vNode,处理ref的时候使用 - // 状态管理器HorizonX使用 + // 状态管理器InulaX使用 isStoreChange: boolean; observers: Set | null = null; // 记录这个函数组件/类组件依赖哪些Observer - classComponentWillUnmount: ((vNode: VNode) => any) | null; // HorizonX会在classComponentWillUnmount中清除对VNode的引入用 + classComponentWillUnmount: ((vNode: VNode) => any) | null; // InulaX会在classComponentWillUnmount中清除对VNode的引入用 src: Source | null; // 节点所在代码位置 constructor(tag: VNodeTag, props: any, key: null | string, realNode) { diff --git a/libs/horizon/src/renderer/vnode/VNodeCreator.ts b/libs/inula/src/renderer/vnode/VNodeCreator.ts similarity index 99% rename from libs/horizon/src/renderer/vnode/VNodeCreator.ts rename to libs/inula/src/renderer/vnode/VNodeCreator.ts index 5b3db8ae..31cf3d19 100644 --- a/libs/horizon/src/renderer/vnode/VNodeCreator.ts +++ b/libs/inula/src/renderer/vnode/VNodeCreator.ts @@ -74,7 +74,7 @@ export function getLazyVNodeTag(lazyComp: any): string { } else if (lazyComp !== undefined && lazyComp !== null && typeLazyMap[lazyComp.vtype]) { return typeLazyMap[lazyComp.vtype]; } - throw Error("Horizon can't resolve the content of lazy"); + throw Error("Inula can't resolve the content of lazy"); } // 创建processing diff --git a/libs/horizon/src/renderer/vnode/VNodeFlags.ts b/libs/inula/src/renderer/vnode/VNodeFlags.ts similarity index 100% rename from libs/horizon/src/renderer/vnode/VNodeFlags.ts rename to libs/inula/src/renderer/vnode/VNodeFlags.ts diff --git a/libs/horizon/src/renderer/vnode/VNodeShouldUpdate.ts b/libs/inula/src/renderer/vnode/VNodeShouldUpdate.ts similarity index 100% rename from libs/horizon/src/renderer/vnode/VNodeShouldUpdate.ts rename to libs/inula/src/renderer/vnode/VNodeShouldUpdate.ts diff --git a/libs/horizon/src/renderer/vnode/VNodeTags.ts b/libs/inula/src/renderer/vnode/VNodeTags.ts similarity index 100% rename from libs/horizon/src/renderer/vnode/VNodeTags.ts rename to libs/inula/src/renderer/vnode/VNodeTags.ts diff --git a/libs/horizon/src/renderer/vnode/VNodeUtils.ts b/libs/inula/src/renderer/vnode/VNodeUtils.ts similarity index 98% rename from libs/horizon/src/renderer/vnode/VNodeUtils.ts rename to libs/inula/src/renderer/vnode/VNodeUtils.ts index 952b9541..7f960098 100644 --- a/libs/horizon/src/renderer/vnode/VNodeUtils.ts +++ b/libs/inula/src/renderer/vnode/VNodeUtils.ts @@ -125,8 +125,8 @@ export function clearVNode(vNode: VNode) { vNode.toUpdateNodes = null; vNode[BELONG_CLASS_VNODE_KEY] = null; - if (window.__HORIZON_DEV_HOOK__) { - const hook = window.__HORIZON_DEV_HOOK__; + if (window.__INULA_DEV_HOOK__) { + const hook = window.__INULA_DEV_HOOK__; hook.deleteVNode(vNode); } } diff --git a/package.json b/package.json index 22d01c6d..d2c20795 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "horizon-core", - "description": "Horizon is a JavaScript framework library.", + "name": "inulajs", + "description": "InulaJS is a JavaScript framework library.", "version": "0.0.52", "private": true, "workspaces": [ @@ -11,8 +11,8 @@ "prettier": "prettier -w libs/**/*.ts", "build": "rollup --config ./scripts/rollup/rollup.config.js", "build:watch": "rollup --watch --config ./scripts/rollup/rollup.config.js", - "build:horizon3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js build:horizon3rdLib-dev", - "build-types": "tsc -p ./libs/horizon/index.ts --emitDeclarationOnly --declaration --declarationDir ./build/horizon/@types --skipLibCheck || echo \"WARNING: TSC exited with status $?\"", + "build:inula3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js build:inula3rdLib-dev", + "build-types": "tsc -p libs/inula/index.ts --emitDeclarationOnly --declaration --declarationDir ./build/inula/@types --skipLibCheck || echo \\\"WARNING: TSC exited with status $?\\\"", "debug-test": "yarn test --debug", "test": "jest --config=jest.config.js", "watch-test": "yarn test --watch --dev" diff --git a/scripts/__tests__/ActTest/act.test.js b/scripts/__tests__/ActTest/act.test.js index 00f719ca..e0768094 100644 --- a/scripts/__tests__/ActTest/act.test.js +++ b/scripts/__tests__/ActTest/act.test.js @@ -13,9 +13,9 @@ * See the Mulan PSL v2 for more details. */ -import Horizon, { render, useState, act, useEffect } from '@cloudsop/horizon/index.ts'; +import Inula, { render, useState, act, useEffect } from '../../../libs/inula/index'; -describe('Horizon.act function Test', () => { +describe('Inula.act function Test', () => { it('The act can wait for the useEffect update to complete.', function () { const Parent = props => { const [buttonOptions, setBtn] = useState([]); diff --git a/scripts/__tests__/ComponentTest/ClassRefs.test.js b/scripts/__tests__/ComponentTest/ClassRefs.test.js index d5e91d29..c898e069 100644 --- a/scripts/__tests__/ComponentTest/ClassRefs.test.js +++ b/scripts/__tests__/ComponentTest/ClassRefs.test.js @@ -13,13 +13,13 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; describe('Class refs Test', () => { it('Parent can get Child instance by refs', function () { let pInst; - class Parent extends Horizon.Component { + class Parent extends Inula.Component { componentDidMount() { pInst = this; } @@ -35,7 +35,7 @@ describe('Class refs Test', () => { } } - class Child extends Horizon.Component { + class Child extends Inula.Component { state = { y: 0 }; render() { @@ -43,7 +43,7 @@ describe('Class refs Test', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(pInst.refs['child'].state.y).toEqual(0); expect(pInst.refs['childDiv'].innerHTML).toEqual('childDiv'); diff --git a/scripts/__tests__/ComponentTest/ComponentError.test.js b/scripts/__tests__/ComponentTest/ComponentError.test.js index aa25bcf0..3a16c00b 100755 --- a/scripts/__tests__/ComponentTest/ComponentError.test.js +++ b/scripts/__tests__/ComponentTest/ComponentError.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { getLogUtils } from '../jest/testUtils'; describe('Component Error Test', () => { @@ -24,11 +24,11 @@ describe('Component Error Test', () => { jest.spyOn(console, 'error').mockImplementation(); expect(() => { - Horizon.render(, document.createElement('div')); + Inula.render(, document.createElement('div')); }).toThrow('Component type is invalid, got: null'); expect(() => { - Horizon.render(, document.createElement('div')); + Inula.render(, document.createElement('div')); }).toThrow('Component type is invalid, got: undefined'); const App = () => { @@ -42,7 +42,7 @@ describe('Component Error Test', () => { }; expect(() => { - Horizon.render(, document.createElement('div')); + Inula.render(, document.createElement('div')); }).toThrow('Component type is invalid, got: null'); AppChild = () => { @@ -52,7 +52,7 @@ describe('Component Error Test', () => { }; expect(() => { - Horizon.render(, document.createElement('div')); + Inula.render(, document.createElement('div')); }).toThrow('Component type is invalid, got: undefined'); }); }); diff --git a/scripts/__tests__/ComponentTest/Context.test.js b/scripts/__tests__/ComponentTest/Context.test.js index a3e6c562..70cc7111 100644 --- a/scripts/__tests__/ComponentTest/Context.test.js +++ b/scripts/__tests__/ComponentTest/Context.test.js @@ -13,18 +13,18 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { getLogUtils } from '../jest/testUtils'; describe('Context Test', () => { const LogUtils = getLogUtils(); - it('Provider及其内部consumer组件都不受制于shouldComponentUpdate函数或者Horizon.memo()', () => { + it('Provider及其内部consumer组件都不受制于shouldComponentUpdate函数或者Inula.memo()', () => { const LanguageTypes = { JAVA: 'Java', JAVASCRIPT: 'JavaScript', }; const defaultValue = { type: LanguageTypes.JAVASCRIPT }; - const SystemLanguageContext = Horizon.createContext(defaultValue); + const SystemLanguageContext = Inula.createContext(defaultValue); const SystemLanguageConsumer = SystemLanguageContext.Consumer; const SystemLanguageProvider = (props) => { LogUtils.log('SystemLanguageProvider'); @@ -47,7 +47,7 @@ describe('Context Test', () => { ); }; - class Middle extends Horizon.Component { + class Middle extends Inula.Component { shouldComponentUpdate() { return false; } @@ -70,7 +70,7 @@ describe('Context Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('Java'); expect(LogUtils.getAndClear()).toEqual([ 'App', @@ -82,14 +82,14 @@ describe('Context Test', () => { ]); // 组件不变,Middle没有更新,消费者也不会执行 - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('Java'); expect(LogUtils.getAndClear()).toEqual([ 'App', 'SystemLanguageProvider' ]); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('JavaScript'); // 组件更新,但是Middle没有更新,会绕过Middle expect(LogUtils.getAndClear()).toEqual([ @@ -104,7 +104,7 @@ describe('Context Test', () => { ONE: 1, TWO: 2, }; - const NumberContext = Horizon.createContext(0); + const NumberContext = Inula.createContext(0); const NumberConsumer = NumberContext.Consumer; const NumberProvider = (props) => { LogUtils.log(`SystemLanguageProvider: ${props.type}`); @@ -127,7 +127,7 @@ describe('Context Test', () => { ); }; - class Middle extends Horizon.Component { + class Middle extends Inula.Component { shouldComponentUpdate() { return false; } @@ -151,7 +151,7 @@ describe('Context Test', () => { }; // Consumer决定于距离它最近的provider - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('2'); expect(LogUtils.getAndClear()).toEqual([ 'App', @@ -162,7 +162,7 @@ describe('Context Test', () => { 'Consumer DOM mutations' ]); // 更新 - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('3'); expect(LogUtils.getAndClear()).toEqual([ 'App', @@ -177,8 +177,8 @@ describe('Context Test', () => { ONE: 1, TWO: 2, }; - const NumberContext = Horizon.createContext(0); - const NewNumberContext = Horizon.createContext(1); + const NumberContext = Inula.createContext(0); + const NewNumberContext = Inula.createContext(1); const NumberConsumer = NumberContext.Consumer; const NumberProvider = props => { return ( @@ -195,7 +195,7 @@ describe('Context Test', () => { ); }; - class Middle extends Horizon.Component { + class Middle extends Inula.Component { shouldComponentUpdate() { return false; } @@ -234,18 +234,18 @@ describe('Context Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); // 没有匹配到Provider,会使用defaultValue expect(container.querySelector('p').innerHTML).toBe('0'); // 更新,设置value为undefined - Horizon.render(, container); + Inula.render(, container); // 设置value为undefined时,defaultValue不生效 expect(container.querySelector('p').innerHTML).toBe(''); }); it('不同provider下的多个consumer', () => { - const NumContext = Horizon.createContext(1); + const NumContext = Inula.createContext(1); const Consumer = NumContext.Consumer; function Provider(props) { @@ -260,7 +260,7 @@ describe('Context Test', () => { ); } - class Middle extends Horizon.Component { + class Middle extends Inula.Component { shouldComponentUpdate() { return false; } @@ -290,22 +290,22 @@ describe('Context Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('4'); expect(container.querySelector('#p').innerHTML).toBe('2'); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('6'); expect(container.querySelector('#p').innerHTML).toBe('3'); }); it('consumer里的child更新是不会重新渲染', () => { - const NumContext = Horizon.createContext(1); + const NumContext = Inula.createContext(1); const Consumer = NumContext.Consumer; let setNum; const ReturnDom = props => { - const [num, _setNum] = Horizon.useState(0); + const [num, _setNum] = Inula.useState(0); setNum = _setNum; LogUtils.log('ReturnDom'); return ( @@ -326,7 +326,7 @@ describe('Context Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('Context: 2, Num: 0'); expect(LogUtils.getAndClear()).toEqual([ 'Consumer', @@ -339,11 +339,11 @@ describe('Context Test', () => { it('consumer可以拿到其他context的值', () => { - const NumContext = Horizon.createContext(1); - const TypeContext = Horizon.createContext('typeA'); + const NumContext = Inula.createContext(1); + const TypeContext = Inula.createContext('typeA'); const NumAndType = () => { - const type = Horizon.useContext(TypeContext); + const type = Inula.useContext(TypeContext); return ( {value => { @@ -364,23 +364,23 @@ describe('Context Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('Num: 2, Type: typeB'); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('Num: 2, Type: typeR'); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('Num: 8, Type: typeR'); }); // antd menu 级连context场景,menu路径使用级联context实现 it('nested context', () => { - const NestedContext = Horizon.createContext([]); + const NestedContext = Inula.createContext([]); let updateContext; function App() { - const [state, useState] = Horizon.useState([]); + const [state, useState] = Inula.useState([]); updateContext = useState; return ( @@ -390,13 +390,13 @@ describe('Context Test', () => { ); } - const div1Ref = Horizon.createRef(); - const div2Ref = Horizon.createRef(); + const div1Ref = Inula.createRef(); + const div2Ref = Inula.createRef(); let updateSub1; function Sub1() { - const path = Horizon.useContext(NestedContext); - const [_, setState] = Horizon.useState({}); + const path = Inula.useContext(NestedContext); + const [_, setState] = Inula.useState({}); updateSub1 = () => setState({}); return ( @@ -406,7 +406,7 @@ describe('Context Test', () => { } function Sub2() { - const path = Horizon.useContext(NestedContext); + const path = Inula.useContext(NestedContext); return ( @@ -416,7 +416,7 @@ describe('Context Test', () => { } function Sub3() { - const path = Horizon.useContext(NestedContext); + const path = Inula.useContext(NestedContext); return ( @@ -426,7 +426,7 @@ describe('Context Test', () => { } function Son({ divRef }) { - const path = Horizon.useContext(NestedContext); + const path = Inula.useContext(NestedContext); return (
{path.join(',')}
@@ -434,7 +434,7 @@ describe('Context Test', () => { ); } - Horizon.render(, container); + Inula.render(, container); updateSub1(); expect(div1Ref.current.innerHTML).toEqual('1'); expect(div2Ref.current.innerHTML).toEqual('2,3'); diff --git a/scripts/__tests__/ComponentTest/DiffAlgorithm.test.js b/scripts/__tests__/ComponentTest/DiffAlgorithm.test.js index ccd501c3..c81f16b2 100644 --- a/scripts/__tests__/ComponentTest/DiffAlgorithm.test.js +++ b/scripts/__tests__/ComponentTest/DiffAlgorithm.test.js @@ -13,13 +13,13 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; describe('Diff Algorithm', () => { it('null should diff correctly', () => { const fn = jest.fn(); - class C extends Horizon.Component { + class C extends Inula.Component { constructor() { super(); fn(); @@ -33,7 +33,7 @@ describe('Diff Algorithm', () => { let update; function App() { - const [current, setCurrent] = Horizon.useState(1); + const [current, setCurrent] = Inula.useState(1); update = setCurrent; return ( <> @@ -44,7 +44,7 @@ describe('Diff Algorithm', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(fn).toHaveBeenCalledTimes(1); update(2); diff --git a/scripts/__tests__/ComponentTest/ForwardRef.test.js b/scripts/__tests__/ComponentTest/ForwardRef.test.js index 16f4cf5b..18261cc9 100644 --- a/scripts/__tests__/ComponentTest/ForwardRef.test.js +++ b/scripts/__tests__/ComponentTest/ForwardRef.test.js @@ -13,14 +13,14 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { getLogUtils } from '../jest/testUtils'; describe('ForwardRef', () => { const LogUtils = getLogUtils(); it('ForwardRef包裹的函数组件应该正常触发effect', () => { function App(props, ref) { - Horizon.useEffect(() => { + Inula.useEffect(() => { LogUtils.log('effect'); return () => { LogUtils.log('effect remove'); @@ -29,32 +29,32 @@ describe('ForwardRef', () => { return ; } - const Wrapper = Horizon.forwardRef(App); + const Wrapper = Inula.forwardRef(App); - Horizon.act(() => { - Horizon.render(, container); + Inula.act(() => { + Inula.render(, container); }); expect(LogUtils.getAndClear()).toEqual(['effect']); - Horizon.act(() => { - Horizon.render(, container); + Inula.act(() => { + Inula.render(, container); }); expect(LogUtils.getAndClear()).toEqual(['effect remove', 'effect']); }); it('memo组件包裹的类组件', () => { - class Component extends Horizon.Component { + class Component extends Inula.Component { render() { return ; } } - const Wrapper = Horizon.memo(Component); + const Wrapper = Inula.memo(Component); - Horizon.act(() => { - Horizon.render(, container); + Inula.act(() => { + Inula.render(, container); }); - Horizon.act(() => { - Horizon.render(, container); + Inula.act(() => { + Inula.render(, container); }); }); }); diff --git a/scripts/__tests__/ComponentTest/FragmentComponent.test.js b/scripts/__tests__/ComponentTest/FragmentComponent.test.js index c0b79fb1..ce8650ef 100755 --- a/scripts/__tests__/ComponentTest/FragmentComponent.test.js +++ b/scripts/__tests__/ComponentTest/FragmentComponent.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { Text } from '../jest/commonComponents'; import { getLogUtils } from '../jest/testUtils'; @@ -23,24 +23,24 @@ describe('Fragment', () => { useEffect, useRef, act, - } = Horizon; + } = Inula; it('可以渲染空元素', () => { const element = ( - + ); - Horizon.render(element, container); + Inula.render(element, container); expect(container.textContent).toBe(''); }); it('可以渲染单个元素', () => { const element = ( - + - + ); - Horizon.render(element, container); + Inula.render(element, container); expect(LogUtils.getAndClear()).toEqual(['Fragment']); expect(container.textContent).toBe('Fragment'); @@ -48,12 +48,12 @@ describe('Fragment', () => { it('可以渲染混合元素', () => { const element = ( - + Java and - + ); - Horizon.render(element, container); + Inula.render(element, container); expect(LogUtils.getAndClear()).toEqual(['JavaScript']); expect(container.textContent).toBe('Java and JavaScript'); @@ -67,7 +67,7 @@ describe('Fragment', () => { ); - Horizon.render(element, container); + Inula.render(element, container); expect(LogUtils.getAndClear()).toEqual(['Java', 'JavaScript']); expect(container.textContent).toBe('JavaJavaScript'); @@ -103,18 +103,18 @@ describe('Fragment', () => { }; act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); act(() => { - Horizon.render(, container); + Inula.render(, container); }); // 切换到不同层级Fragment时,副作用状态不会保留 expect(LogUtils.getNotClear()).toEqual([]); expect(container.textContent).toBe('2'); act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); expect(container.textContent).toBe('1'); @@ -145,18 +145,18 @@ describe('Fragment', () => { }; act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); act(() => { - Horizon.render(, container); + Inula.render(, container); }); // 状态会保留 expect(LogUtils.getNotClear()).toEqual(['useEffect']); expect(container.textContent).toBe('2'); act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual(['useEffect', 'useEffect']); expect(container.textContent).toBe('1'); @@ -188,18 +188,18 @@ describe('Fragment', () => { }; act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); act(() => { - Horizon.render(, container); + Inula.render(, container); }); // 状态不会保留 expect(LogUtils.getNotClear()).toEqual([]); expect(container.textContent).toBe('1232'); act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); expect(container.textContent).toBe('1'); @@ -234,18 +234,18 @@ describe('Fragment', () => { }; act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); act(() => { - Horizon.render(, container); + Inula.render(, container); }); // 状态不会保留 expect(LogUtils.getNotClear()).toEqual([]); expect(container.textContent).toBe('2'); act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); expect(container.textContent).toBe('1'); @@ -286,18 +286,18 @@ describe('Fragment', () => { }; act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); act(() => { - Horizon.render(, container); + Inula.render(, container); }); // 状态会保留 expect(LogUtils.getNotClear()).toEqual(['useEffect']); expect(container.textContent).toBe('2'); act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual(['useEffect', 'useEffect']); expect(container.textContent).toBe('1'); @@ -338,18 +338,18 @@ describe('Fragment', () => { }; act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); act(() => { - Horizon.render(, container); + Inula.render(, container); }); // 状态会保留 expect(LogUtils.getNotClear()).toEqual(['useEffect']); expect(container.textContent).toBe('2'); act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual(['useEffect', 'useEffect']); expect(container.textContent).toBe('1'); @@ -380,18 +380,18 @@ describe('Fragment', () => { }; act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); act(() => { - Horizon.render(, container); + Inula.render(, container); }); // 状态会保留 expect(LogUtils.getNotClear()).toEqual(['useEffect']); expect(container.textContent).toBe('2'); act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual(['useEffect', 'useEffect']); expect(container.textContent).toBe('1'); @@ -426,18 +426,18 @@ describe('Fragment', () => { }; act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); act(() => { - Horizon.render(, container); + Inula.render(, container); }); // 状态会保留 expect(LogUtils.getNotClear()).toEqual([]); expect(container.textContent).toBe('2'); act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); expect(container.textContent).toBe('[1]'); @@ -459,29 +459,29 @@ describe('Fragment', () => { const App = (props) => { return props.change ? ( - + - + ) : ( - + - + ); }; act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); act(() => { - Horizon.render(, container); + Inula.render(, container); }); // 状态不会保留 expect(LogUtils.getNotClear()).toEqual([]); expect(container.textContent).toBe('2'); act(() => { - Horizon.render(, container); + Inula.render(, container); }); expect(LogUtils.getNotClear()).toEqual([]); expect(container.textContent).toBe('1'); diff --git a/scripts/__tests__/ComponentTest/FunctionComponent.test.js b/scripts/__tests__/ComponentTest/FunctionComponent.test.js index bd02b9d5..81e10fe4 100644 --- a/scripts/__tests__/ComponentTest/FunctionComponent.test.js +++ b/scripts/__tests__/ComponentTest/FunctionComponent.test.js @@ -13,14 +13,14 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; describe('FunctionComponent Test', () => { it('渲染无状态组件', () => { const App = (props) => { return

{props.text}

; }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('app'); }); @@ -29,13 +29,13 @@ describe('FunctionComponent Test', () => { return

{props.text}

; }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('app'); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('ABC'); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('abc'); }); @@ -44,10 +44,10 @@ describe('FunctionComponent Test', () => { return

{props.text}

; }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('app'); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); expect(container.querySelector('p')).toBe(null); }); @@ -56,24 +56,24 @@ describe('FunctionComponent Test', () => { return
; }; - const realNode = Horizon.render(, container); + const realNode = Inula.render(, container); expect(realNode).toBe(null); }); - it('测试函数组件的defaultProps:Horizon.memo(Horizon.forwardRef(()=>{}))两层包装的场景后,defaultProps依然正常', () => { + it('测试函数组件的defaultProps:Inula.memo(Inula.forwardRef(()=>{}))两层包装的场景后,defaultProps依然正常', () => { const App = () => { return ; }; - const DefaultPropsComp = Horizon.forwardRef(props => { + const DefaultPropsComp = Inula.forwardRef(props => { return
{props.name}
; }); DefaultPropsComp.defaultProps = { name: 'Hello!', }; - const DefaultPropsCompMemo = Horizon.memo(DefaultPropsComp); + const DefaultPropsCompMemo = Inula.memo(DefaultPropsComp); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('div').innerHTML).toBe('Hello!'); }); @@ -86,7 +86,7 @@ describe('FunctionComponent Test', () => { return
{props.name}
; }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('div').style['_values']['--max-segment-num']).toBe(10); }); diff --git a/scripts/__tests__/ComponentTest/HookTest/UseCallback.test.js b/scripts/__tests__/ComponentTest/HookTest/UseCallback.test.js index 579f1d7d..cb599e32 100644 --- a/scripts/__tests__/ComponentTest/HookTest/UseCallback.test.js +++ b/scripts/__tests__/ComponentTest/HookTest/UseCallback.test.js @@ -13,10 +13,10 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; describe('useCallback Hook Test', () => { - const { useState, useCallback } = Horizon; + const { useState, useCallback } = Inula; it('测试useCallback', () => { const App = (props) => { @@ -31,7 +31,7 @@ describe('useCallback Hook Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('0'); // 点击按钮触发num加1 container.querySelector('button').click(); @@ -40,7 +40,7 @@ describe('useCallback Hook Test', () => { container.querySelector('button').click(); expect(container.querySelector('p').innerHTML).toBe('1'); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('1'); // 依赖项有变化,点击按钮num增加 container.querySelector('button').click(); diff --git a/scripts/__tests__/ComponentTest/HookTest/UseContext.test.js b/scripts/__tests__/ComponentTest/HookTest/UseContext.test.js index 4fc48f97..decc1a94 100644 --- a/scripts/__tests__/ComponentTest/HookTest/UseContext.test.js +++ b/scripts/__tests__/ComponentTest/HookTest/UseContext.test.js @@ -13,10 +13,10 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; describe('useContext Hook Test', () => { - const { useState, useContext, createContext, act, unmountComponentAtNode } = Horizon; + const { useState, useContext, createContext, act, unmountComponentAtNode } = Inula; it('简单使用useContext', () => { const LanguageTypes = { @@ -24,7 +24,7 @@ describe('useContext Hook Test', () => { JAVASCRIPT: 'JavaScript', }; const defaultValue = { type: LanguageTypes.JAVASCRIPT }; - const SystemLanguageContext = Horizon.createContext(defaultValue); + const SystemLanguageContext = Inula.createContext(defaultValue); const SystemLanguageProvider = ({ type, children }) => { return ( @@ -49,11 +49,11 @@ describe('useContext Hook Test', () => {
); }; - Horizon.render(, container); + Inula.render(, container); // 测试当Provider未提供时,获取到的默认值'JavaScript'。 expect(container.querySelector('p').innerHTML).toBe('JavaScript'); unmountComponentAtNode(container); - Horizon.render(, container); + Inula.render(, container); // 测试当Provider提供时,可以获取到Provider的值'Java'。 expect(container.querySelector('p').innerHTML).toBe('Java'); // 测试当Provider改变时,可以获取到最新Provider的值。 @@ -63,7 +63,7 @@ describe('useContext Hook Test', () => { it('更新后useContext仍能获取到context', () => { const Context = createContext({}); - const ref = Horizon.createRef(); + const ref = Inula.createRef(); function App() { return ( @@ -87,7 +87,7 @@ describe('useContext Hook Test', () => { return
{context.text}
; } - Horizon.render(, container); + Inula.render(, container); expect(ref.current.innerHTML).toBe('context'); update(); diff --git a/scripts/__tests__/ComponentTest/HookTest/UseEffect.test.js b/scripts/__tests__/ComponentTest/HookTest/UseEffect.test.js index 24799f55..a6da51ae 100644 --- a/scripts/__tests__/ComponentTest/HookTest/UseEffect.test.js +++ b/scripts/__tests__/ComponentTest/HookTest/UseEffect.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import { getLogUtils } from '../../jest/testUtils'; import { Text } from '../../jest/commonComponents'; @@ -25,7 +25,7 @@ describe('useEffect Hook Test', () => { memo, forwardRef, act, - } = Horizon; + } = Inula; const LogUtils = getLogUtils(); it('简单使用useEffect', () => { @@ -41,7 +41,7 @@ describe('useEffect Hook Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(document.getElementById('p').style.display).toBe('block'); // 点击按钮触发num加1 container.querySelector('button').click(); @@ -57,7 +57,7 @@ describe('useEffect Hook Test', () => { }; act(() => { - Horizon.render(, container, () => { + Inula.render(, container, () => { LogUtils.log('num effect'); }); // 第一次渲染为同步,所以同步执行的可以写在act里做判断 @@ -65,7 +65,7 @@ describe('useEffect Hook Test', () => { expect(container.textContent).toBe('op'); }); act(() => { - Horizon.render(null, container, () => { + Inula.render(null, container, () => { LogUtils.log('num effect89'); }); // 第二次渲染为异步,所以同步执行的不可以写在act里做判断,act里拿到的为空数组 @@ -87,7 +87,7 @@ describe('useEffect Hook Test', () => { }; const na = ; // 必须设置key值,否则在diff的时候na会被视为不同组件 - Horizon.render([, na], container); + Inula.render([, na], container); expect(LogUtils.getAndClear()).toEqual([ 'App', 'NewApp' @@ -95,7 +95,7 @@ describe('useEffect Hook Test', () => { expect(container.textContent).toBe('AppNewApp'); expect(LogUtils.getAndClear()).toEqual([]); // 在执行新的render前,会执行完上一次render的useEffect,所以LogUtils会加入'NewApp effect'。 - Horizon.render([na], container); + Inula.render([na], container); expect(LogUtils.getAndClear()).toEqual(['NewApp effect', 'NewApp']); expect(container.textContent).toBe('NewApp'); expect(LogUtils.getAndClear()).toEqual([]); @@ -119,7 +119,7 @@ describe('useEffect Hook Test', () => { return ; }; // 必须设置key值,否则在diff的时候na会被视为不同组件 - Horizon.render([, ], container); + Inula.render([, ], container); expect(LogUtils.getAndClear()).toEqual([ 'App', 'NewApp', @@ -137,7 +137,7 @@ describe('useEffect Hook Test', () => { const App = () => { useLayoutEffect(() => { LogUtils.log('App Layout effect'); - Horizon.render(, newContainer); + Inula.render(, newContainer); }); return ; }; @@ -148,7 +148,7 @@ describe('useEffect Hook Test', () => { return ; }; // 必须设置key值,否则在diff的时候na会被视为不同组件 - Horizon.render([, ], container); + Inula.render([, ], container); expect(LogUtils.getAndClear()).toEqual([ 'App', 'NewApp', @@ -168,13 +168,13 @@ describe('useEffect Hook Test', () => { return ; }; act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); expect(LogUtils.getAndClear()).toEqual(['num: 0', 'callback effect']); expect(container.textContent).toEqual('num: 0'); }); expect(LogUtils.getAndClear()).toEqual(['First effect [0]']); act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); }); // 此时异步执行,act执行完后会执行新render的useEffect @@ -197,13 +197,13 @@ describe('useEffect Hook Test', () => { return ; }; act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); expect(LogUtils.getAndClear()).toEqual(['num: 0', 'callback effect']); expect(container.textContent).toEqual('num: 0'); }); expect(LogUtils.getAndClear()).toEqual(['First effect [0]', 'Second effect [0]']); act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); }); // 第二次render时异步执行,act保证所有效果都已更新,所以先常规记录日志 // 然后记录useEffect的日志 @@ -246,7 +246,7 @@ describe('useEffect Hook Test', () => { }; act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); expect(LogUtils.getAndClear()).toEqual([ 'num: 0,word: App', 'num Layouteffect [0]', @@ -261,21 +261,21 @@ describe('useEffect Hook Test', () => { act(() => { // 此时word改变,num不变 - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual([ - 'num: 0,word: Horizon', + 'num: 0,word: Inula', 'word Layouteffect destroy', - 'word Layouteffect [Horizon]', + 'word Layouteffect [Inula]', 'callback effect', // 最后执行异步的 'word effect destroy', - 'word effect [Horizon]', + 'word effect [Inula]', ]); act(() => { // 此时num和word的所有effect都销毁 - Horizon.render(null, container, () => LogUtils.log('callback effect')); + Inula.render(null, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual([ 'num Layouteffect destroy', @@ -299,7 +299,7 @@ describe('useEffect Hook Test', () => { }; act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); expect(LogUtils.getAndClear()).toEqual([ 'num: 0', 'callback effect' @@ -311,7 +311,7 @@ describe('useEffect Hook Test', () => { ]); act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual([ 'num: 1', @@ -324,7 +324,7 @@ describe('useEffect Hook Test', () => { expect(LogUtils.getAndClear()).toEqual([]); act(() => { - Horizon.render(null, container, () => LogUtils.log('callback effect')); + Inula.render(null, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual([ 'callback effect', @@ -346,7 +346,7 @@ describe('useEffect Hook Test', () => { }; act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); expect(LogUtils.getAndClear()).toEqual([ 'num: 0', 'callback effect' @@ -358,7 +358,7 @@ describe('useEffect Hook Test', () => { ]); act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual([ 'num: 1', @@ -369,7 +369,7 @@ describe('useEffect Hook Test', () => { expect(LogUtils.getAndClear()).toEqual([]); act(() => { - Horizon.render(null, container, () => LogUtils.log('callback effect')); + Inula.render(null, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual([ 'callback effect', @@ -382,7 +382,7 @@ describe('useEffect Hook Test', () => { it('useEffect里使用useState(1', () => { let setNum; const App = () => { - const [num, _setNum] = Horizon.useState(0); + const [num, _setNum] = Inula.useState(0); useEffect(() => { LogUtils.log(`num effect [${num}]`); setNum = () => _setNum(1); @@ -397,7 +397,7 @@ describe('useEffect Hook Test', () => { }; act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); expect(LogUtils.getAndClear()).toEqual([ 'num: 0', 'num Layouteffect [0]', @@ -430,7 +430,7 @@ describe('useEffect Hook Test', () => { return ; }; - Horizon.render(, container, () => LogUtils.log('App callback effect')); + Inula.render(, container, () => LogUtils.log('App callback effect')); expect(LogUtils.getAndClear()).toEqual(['Num: 0', 'App callback effect']); expect(container.textContent).toEqual('Num: 0'); act(() => { @@ -460,7 +460,7 @@ describe('useEffect Hook Test', () => { return ; }); act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); expect(LogUtils.getAndClear()).toEqual([ 0, 'callback effect' @@ -471,7 +471,7 @@ describe('useEffect Hook Test', () => { // 不会重新渲染 act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual(['callback effect']); expect(container.textContent).toEqual('0'); @@ -490,7 +490,7 @@ describe('useEffect Hook Test', () => { expect(LogUtils.getAndClear()).toEqual([]); act(() => { - Horizon.render(null, container, () => LogUtils.log('callback effect')); + Inula.render(null, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual([ 'callback effect', @@ -512,7 +512,7 @@ describe('useEffect Hook Test', () => { return ; }, compare); act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); expect(LogUtils.getAndClear()).toEqual([ 0, 'callback effect' @@ -523,7 +523,7 @@ describe('useEffect Hook Test', () => { // 不会重新渲染 act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual(['callback effect']); expect(container.textContent).toEqual('0'); @@ -531,7 +531,7 @@ describe('useEffect Hook Test', () => { // 会重新渲染 act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual([ 1, @@ -544,7 +544,7 @@ describe('useEffect Hook Test', () => { expect(LogUtils.getAndClear()).toEqual([]); act(() => { - Horizon.render(null, container, () => LogUtils.log('callback effect')); + Inula.render(null, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual(['callback effect', 'num effect destroy 1']); expect(container.textContent).toEqual(''); @@ -565,7 +565,7 @@ describe('useEffect Hook Test', () => { return ; }; act(() => { - Horizon.render(, container, () => + Inula.render(, container, () => LogUtils.log('App callback effect'), ); expect(LogUtils.getAndClear()).toEqual(['Number: 0', 'App callback effect']); @@ -575,7 +575,7 @@ describe('useEffect Hook Test', () => { expect(LogUtils.getAndClear()).toEqual(['throw Error']); act(() => { - Horizon.render(null, container, () => + Inula.render(null, container, () => LogUtils.log('App callback effect'), ); }); @@ -607,14 +607,14 @@ describe('useEffect Hook Test', () => { }; act(() => { - Horizon.render(, container, () => LogUtils.log('num effect')); + Inula.render(, container, () => LogUtils.log('num effect')); expect(LogUtils.getAndClear()).toEqual(['Number: 0', 'num effect']); expect(container.textContent).toBe('Number: 0'); }); expect(LogUtils.getAndClear()).toEqual(['num effect [0]']); act(() => { - Horizon.render(null, container, () => LogUtils.log('num effect')); + Inula.render(null, container, () => LogUtils.log('num effect')); }); expect(LogUtils.getAndClear()).toEqual(['num effect', 'num effect destroy 0']); expect(container.textContent).toBe(''); @@ -633,7 +633,7 @@ describe('useEffect Hook Test', () => { return ; }; - Horizon.render(, container, () => LogUtils.log('num effect')); + Inula.render(, container, () => LogUtils.log('num effect')); expect(LogUtils.getAndClear()).toEqual(['Number: 0', 'num effect']); expect(container.textContent).toBe('Number: 0'); @@ -663,13 +663,13 @@ describe('useEffect Hook Test', () => { }; act(() => { - Horizon.render(, container, () => LogUtils.log('num effect')); + Inula.render(, container, () => LogUtils.log('num effect')); expect(LogUtils.getAndClear()).toEqual(['useEffect', 'num effect']); }); expect(LogUtils.getAndClear()).toEqual(['effect']); act(() => { - Horizon.render(null, container); + Inula.render(null, container); }); // 不会处理setNum(1) expect(LogUtils.getAndClear()).toEqual(['effect destroy']); @@ -678,7 +678,7 @@ describe('useEffect Hook Test', () => { it('当组件的更新方法在卸载函数中,组件的子组件更新不会告警', () => { const App = () => { LogUtils.log('App'); - const appRef = Horizon.createRef(null); + const appRef = Inula.createRef(null); useEffect(() => { LogUtils.log('App effect'); return () => { @@ -701,7 +701,7 @@ describe('useEffect Hook Test', () => { AppChild = forwardRef(AppChild); act(() => { - Horizon.render(, container, () => LogUtils.log('num effect')); + Inula.render(, container, () => LogUtils.log('num effect')); expect(LogUtils.getAndClear()).toEqual([ 'App', 'AppChild', @@ -711,7 +711,7 @@ describe('useEffect Hook Test', () => { expect(LogUtils.getAndClear()).toEqual(['Child effect', 'App effect']); act(() => { - Horizon.render(null, container); + Inula.render(null, container); }); // 销毁时执行appRef.current(1)不会报错 expect(LogUtils.getAndClear()).toEqual(['App effect destroy']); @@ -737,7 +737,7 @@ describe('useEffect Hook Test', () => { }; act(() => { - Horizon.render(, container, () => LogUtils.log('num effect')); + Inula.render(, container, () => LogUtils.log('num effect')); expect(LogUtils.getAndClear()).toEqual([ 'App', 'AppChild', @@ -747,7 +747,7 @@ describe('useEffect Hook Test', () => { expect(LogUtils.getAndClear()).toEqual(['Child effect']); act(() => { - Horizon.render(null, container); + Inula.render(null, container); }); // 销毁时执行 props.setNum(1);不会报错 expect(LogUtils.getAndClear()).toEqual(['Child effect destroy']); diff --git a/scripts/__tests__/ComponentTest/HookTest/UseImperativeHandle.test.js b/scripts/__tests__/ComponentTest/HookTest/UseImperativeHandle.test.js index a44c58b2..1de72341 100644 --- a/scripts/__tests__/ComponentTest/HookTest/UseImperativeHandle.test.js +++ b/scripts/__tests__/ComponentTest/HookTest/UseImperativeHandle.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import { Text } from '../../jest/commonComponents'; import { getLogUtils } from '../../jest/testUtils'; @@ -23,8 +23,8 @@ describe('useImperativeHandle Hook Test', () => { useImperativeHandle, forwardRef, act, - } = Horizon; - const { unmountComponentAtNode } = Horizon; + } = Inula; + const { unmountComponentAtNode } = Inula; const LogUtils = getLogUtils(); it('测试useImperativeHandle', () => { @@ -41,9 +41,9 @@ describe('useImperativeHandle Hook Test', () => { App = forwardRef(App); App1 = forwardRef(App1); - const counter = Horizon.createRef(null); - const counter1 = Horizon.createRef(null); - Horizon.render(, container); + const counter = Inula.createRef(null); + const counter1 = Inula.createRef(null); + Inula.render(, container); expect(counter.current.num).toBe(0); act(() => { counter.current.setNum(1); @@ -53,7 +53,7 @@ describe('useImperativeHandle Hook Test', () => { // 清空container unmountComponentAtNode(container); - Horizon.render(, container); + Inula.render(, container); expect(counter1.current.num1).toBe(0); act(() => { counter1.current.setNum1(1); @@ -76,9 +76,9 @@ describe('useImperativeHandle Hook Test', () => { App = forwardRef(App); App1 = forwardRef(App1); - const counter = Horizon.createRef(null); - const counter1 = Horizon.createRef(null); - Horizon.render(, container); + const counter = Inula.createRef(null); + const counter1 = Inula.createRef(null); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([0]); expect(counter.current.num).toBe(0); act(() => { @@ -90,7 +90,7 @@ describe('useImperativeHandle Hook Test', () => { // 清空container unmountComponentAtNode(container); - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([0]); expect(counter1.current.num1).toBe(0); act(() => { diff --git a/scripts/__tests__/ComponentTest/HookTest/UseLayoutEffect.test.js b/scripts/__tests__/ComponentTest/HookTest/UseLayoutEffect.test.js index 8cba787c..66bfbf4e 100644 --- a/scripts/__tests__/ComponentTest/HookTest/UseLayoutEffect.test.js +++ b/scripts/__tests__/ComponentTest/HookTest/UseLayoutEffect.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import { getLogUtils } from '../../jest/testUtils'; import { Text } from '../../jest/commonComponents'; @@ -23,7 +23,7 @@ describe('useLayoutEffect Hook Test', () => { useEffect, useLayoutEffect, act, - } = Horizon; + } = Inula; const LogUtils = getLogUtils(); it('简单使用useLayoutEffect', () => { const App = () => { @@ -38,7 +38,7 @@ describe('useLayoutEffect Hook Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(document.getElementById('p').style.display).toBe('none'); container.querySelector('button').click(); expect(container.querySelector('p').style.display).toBe('inline'); @@ -51,7 +51,7 @@ describe('useLayoutEffect Hook Test', () => { }); return ; }; - Horizon.render(, container, () => LogUtils.log('Sync effect')); + Inula.render(, container, () => LogUtils.log('Sync effect')); expect(LogUtils.getAndClear()).toEqual([ 1, // 同步在渲染之后 @@ -60,7 +60,7 @@ describe('useLayoutEffect Hook Test', () => { ]); expect(container.querySelector('p').innerHTML).toBe('1'); // 更新 - Horizon.render(, container, () => LogUtils.log('Sync effect')); + Inula.render(, container, () => LogUtils.log('Sync effect')); expect(LogUtils.getAndClear()).toEqual([ 2, 'LayoutEffect', @@ -87,7 +87,7 @@ describe('useLayoutEffect Hook Test', () => { }; act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); expect(LogUtils.getAndClear()).toEqual([ 'num: 0', 'num Layouteffect [0]', @@ -98,7 +98,7 @@ describe('useLayoutEffect Hook Test', () => { // 更新 act(() => { - Horizon.render(, container, () => LogUtils.log('callback effect')); + Inula.render(, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual([ // 异步effect @@ -116,7 +116,7 @@ describe('useLayoutEffect Hook Test', () => { ]); act(() => { - Horizon.render(null, container, () => LogUtils.log('callback effect')); + Inula.render(null, container, () => LogUtils.log('callback effect')); }); expect(LogUtils.getAndClear()).toEqual([ // 同步Layouteffect销毁 diff --git a/scripts/__tests__/ComponentTest/HookTest/UseMemo.test.js b/scripts/__tests__/ComponentTest/HookTest/UseMemo.test.js index 59a25a09..fb1fe711 100644 --- a/scripts/__tests__/ComponentTest/HookTest/UseMemo.test.js +++ b/scripts/__tests__/ComponentTest/HookTest/UseMemo.test.js @@ -13,12 +13,12 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import { getLogUtils } from '../../jest/testUtils'; import { Text } from '../../jest/commonComponents'; describe('useMemo Hook Test', () => { - const { useMemo, useState } = Horizon; + const { useMemo, useState } = Inula; const LogUtils = getLogUtils(); it('测试useMemo', () => { @@ -38,7 +38,7 @@ describe('useMemo Hook Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('App'); expect(container.querySelector('#p').innerHTML).toBe('1'); // 修改useMemo的依赖项,num会加一,text会改变。 @@ -63,26 +63,26 @@ describe('useMemo Hook Test', () => { }, [props._num]); return ; }; - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([ 0, 1 ]); expect(container.textContent).toBe('1'); - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([ 1, 2 ]); expect(container.textContent).toBe('2'); - Horizon.render(, container); + Inula.render(, container); // 不会触发useMemo expect(LogUtils.getAndClear()).toEqual([2]); expect(container.textContent).toBe('2'); - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([ 2, 3 @@ -106,16 +106,16 @@ describe('useMemo Hook Test', () => { return 2; }; - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual(['num 1', 1]); - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual(['num 1', 1]); - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual(['num 1', 1]); - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual(['num 2', 2]); }); }); diff --git a/scripts/__tests__/ComponentTest/HookTest/UseReducer.test.js b/scripts/__tests__/ComponentTest/HookTest/UseReducer.test.js index 379d85ac..806e3662 100644 --- a/scripts/__tests__/ComponentTest/HookTest/UseReducer.test.js +++ b/scripts/__tests__/ComponentTest/HookTest/UseReducer.test.js @@ -13,10 +13,10 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; describe('useReducer Hook Test', () => { - const { useReducer } = Horizon; + const { useReducer } = Inula; it('简单使用useReducer', () => { const intlCar = { logo: '', price: 0 }; @@ -59,7 +59,7 @@ describe('useReducer Hook Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe(''); expect(container.querySelector('#senP').innerHTML).toBe('0'); // 触发bmw @@ -77,7 +77,7 @@ describe('useReducer Hook Test', () => { const reducer = () => { return { data: nextId++ }; }; - const btnRef = Horizon.createRef(); + const btnRef = Inula.createRef(); const Main = () => { const [{ data }, dispatch] = useReducer(reducer, { data: 0 }); const dispatchLogging = () => { @@ -95,8 +95,8 @@ describe('useReducer Hook Test', () => { ); }; - Horizon.render(
, container); - Horizon.act(() => { + Inula.render(
, container); + Inula.act(() => { btnRef.current.click(); }); expect(nextId).toBe(2); diff --git a/scripts/__tests__/ComponentTest/HookTest/UseRef.test.js b/scripts/__tests__/ComponentTest/HookTest/UseRef.test.js index 570f029b..ebefe6b8 100644 --- a/scripts/__tests__/ComponentTest/HookTest/UseRef.test.js +++ b/scripts/__tests__/ComponentTest/HookTest/UseRef.test.js @@ -13,12 +13,12 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import { getLogUtils } from '../../jest/testUtils'; import { Text } from '../../jest/commonComponents'; describe('useRef Hook Test', () => { - const { useState, useRef } = Horizon; + const { useState, useRef } = Inula; const LogUtils = getLogUtils(); it('测试useRef', () => { @@ -36,7 +36,7 @@ describe('useRef Hook Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('1'); expect(container.querySelector('#sp').innerHTML).toBe('1'); // 点击按钮触发num加1,ref不变 @@ -59,7 +59,7 @@ describe('useRef Hook Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([1]); expect(container.querySelector('p').innerHTML).toBe('1'); // 点击按钮触发ref.current加1 diff --git a/scripts/__tests__/ComponentTest/HookTest/UseState.test.js b/scripts/__tests__/ComponentTest/HookTest/UseState.test.js index b5e7409f..0c7e60ab 100644 --- a/scripts/__tests__/ComponentTest/HookTest/UseState.test.js +++ b/scripts/__tests__/ComponentTest/HookTest/UseState.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import { getLogUtils } from '../../jest/testUtils'; import { Text } from '../../jest/commonComponents'; @@ -24,7 +24,7 @@ describe('useState Hook Test', () => { useImperativeHandle, memo, act, - } = Horizon; + } = Inula; const LogUtils = getLogUtils(); it('简单使用useState', () => { @@ -37,7 +37,7 @@ describe('useState Hook Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('0'); // 点击按钮触发num加1 container.querySelector('button').click(); @@ -59,7 +59,7 @@ describe('useState Hook Test', () => {

); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('00'); container.querySelector('p').click(); expect(container.querySelector('p').innerHTML).toBe('12'); @@ -81,7 +81,7 @@ describe('useState Hook Test', () => {

); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('0'); container.querySelector('p').click(); expect(container.querySelector('p').innerHTML).toBe('2'); @@ -96,7 +96,7 @@ describe('useState Hook Test', () => { setNum = _setNum; return ; }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('0'); expect(LogUtils.getAndClear()).toEqual([0]); // useState修改state 时,设置相同的值,函数组件不会重新渲染 @@ -115,8 +115,8 @@ describe('useState Hook Test', () => { return

{num}

; }); - const ref = Horizon.createRef(null); - Horizon.render(, container); + const ref = Inula.createRef(null); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([1]); expect(container.querySelector('p').innerHTML).toBe('1'); // 设置num为3 @@ -133,11 +133,11 @@ describe('useState Hook Test', () => { setNum = _setNum; return ; }); - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([0]); expect(container.querySelector('p').innerHTML).toBe('0'); // 不会重新渲染 - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([]); expect(container.querySelector('p').innerHTML).toBe('0'); // 会重新渲染 @@ -166,7 +166,7 @@ describe('useState Hook Test', () => { return ; }; - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual(['Number: 0, Count: 0']); expect(container.textContent).toBe('Number: 0, Count: 0'); act(() => { @@ -178,7 +178,7 @@ describe('useState Hook Test', () => { jest.spyOn(console, 'error').mockImplementation(); expect(() => { - Horizon.render(, container); + Inula.render(, container); }).toThrow('Hooks are less than expected, please check whether the hook is written in the condition.'); }); }); diff --git a/scripts/__tests__/ComponentTest/JsxElement.test.js b/scripts/__tests__/ComponentTest/JsxElement.test.js index 8794fbbf..5f3e573a 100644 --- a/scripts/__tests__/ComponentTest/JsxElement.test.js +++ b/scripts/__tests__/ComponentTest/JsxElement.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; describe('JSX Element test', () => { it('symbol attribute prevent cloneDeep unlimited loop', function () { @@ -29,7 +29,7 @@ describe('JSX Element test', () => { }) return result; } - class Demo extends Horizon.Component { + class Demo extends Inula.Component { render() { return (
@@ -39,7 +39,7 @@ describe('JSX Element test', () => { } } - const ele = Horizon.createElement(Demo); + const ele = Inula.createElement(Demo); const copy = cloneDeep(ele); expect(copy.vtype).toEqual(ele.vtype); expect(Object.getOwnPropertySymbols(copy).length).toEqual(0); diff --git a/scripts/__tests__/ComponentTest/LazyComponent.test.js b/scripts/__tests__/ComponentTest/LazyComponent.test.js index c50fede6..9f23e68e 100755 --- a/scripts/__tests__/ComponentTest/LazyComponent.test.js +++ b/scripts/__tests__/ComponentTest/LazyComponent.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { Text } from '../jest/commonComponents'; import { getLogUtils } from '../jest/testUtils'; @@ -23,8 +23,8 @@ describe('LazyComponent Test', () => { return { default: component }; }); - it('Horizon.lazy()', async () => { - class LazyComponent extends Horizon.Component { + it('Inula.lazy()', async () => { + class LazyComponent extends Inula.Component { static defaultProps = { language: 'Java' }; render() { @@ -33,12 +33,12 @@ describe('LazyComponent Test', () => { } } - const Lazy = Horizon.lazy(() => mockImport(LazyComponent)); + const Lazy = Inula.lazy(() => mockImport(LazyComponent)); - Horizon.render( - }> + Inula.render( + }> - , + , container ); @@ -47,10 +47,10 @@ describe('LazyComponent Test', () => { expect(container.querySelector('span')).toBe(null); await Promise.resolve(); - Horizon.render( - }> + Inula.render( + }> - , + , container ); @@ -59,16 +59,16 @@ describe('LazyComponent Test', () => { }); it('同步解析', async () => { - const LazyApp = Horizon.lazy(() => ({ + const LazyApp = Inula.lazy(() => ({ then(cb) { cb({ default: Text }); }, })); - Horizon.render( - Loading...
}> + Inula.render( + Loading...}> - , + , container ); @@ -77,7 +77,7 @@ describe('LazyComponent Test', () => { }); it('异常捕获边界', async () => { - class ErrorBoundary extends Horizon.Component { + class ErrorBoundary extends Inula.Component { state = {}; static getDerivedStateFromError(error) { return { message: error.message }; @@ -90,7 +90,7 @@ describe('LazyComponent Test', () => { } const LazyComponent = () => { - const [num, setNum] = Horizon.useState(0); + const [num, setNum] = Inula.useState(0); if (num === 2) { throw new Error('num is 2'); } else { @@ -103,24 +103,24 @@ describe('LazyComponent Test', () => { } }; - const LazyApp = Horizon.lazy(() => mockImport(LazyComponent)); + const LazyApp = Inula.lazy(() => mockImport(LazyComponent)); - Horizon.render( + Inula.render( - Loading...}> + Loading...}> - + , container ); expect(container.textContent).toBe('Loading...'); await Promise.resolve(); - Horizon.render( + Inula.render( - }> + }> - + , container ); @@ -133,7 +133,7 @@ describe('LazyComponent Test', () => { }); it('componentDidCatch捕获异常', async () => { - class ErrorBoundary extends Horizon.Component { + class ErrorBoundary extends Inula.Component { state = { catchError: false, error: null, @@ -157,7 +157,7 @@ describe('LazyComponent Test', () => { } const LazyComponent = () => { - const [num, setNum] = Horizon.useState(0); + const [num, setNum] = Inula.useState(0); if (num === 2) { throw new Error('num is 2'); } else { @@ -170,24 +170,24 @@ describe('LazyComponent Test', () => { } }; - const LazyApp = Horizon.lazy(() => mockImport(LazyComponent)); + const LazyApp = Inula.lazy(() => mockImport(LazyComponent)); - Horizon.render( + Inula.render( - Loading...}> + Loading...}> - + , container ); expect(container.textContent).toBe('Loading...'); await Promise.resolve(); - Horizon.render( + Inula.render( - }> + }> - + , container ); @@ -202,25 +202,25 @@ describe('LazyComponent Test', () => { it('#24 配合memo', async () => { const fnComp = () => { - return

horizon

; + return

inula

; }; - const LazyApp = Horizon.lazy(() => ({ + const LazyApp = Inula.lazy(() => ({ then(cb) { - cb({ default: Horizon.memo(() => fnComp, false) }); + cb({ default: Inula.memo(() => fnComp, false) }); }, })); expect(() => { - Horizon.render( - Loading...}> + Inula.render( + Loading...}> - , + , container ); - Horizon.render( - Loading...}> + Inula.render( + Loading...}> - , + , container ); }).not.toThrow(); diff --git a/scripts/__tests__/ComponentTest/LifeCycle.test.js b/scripts/__tests__/ComponentTest/LifeCycle.test.js index 2ab719ef..8969e8a9 100644 --- a/scripts/__tests__/ComponentTest/LifeCycle.test.js +++ b/scripts/__tests__/ComponentTest/LifeCycle.test.js @@ -13,14 +13,14 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { getLogUtils } from '../jest/testUtils'; describe('LifeCycle Test', () => { const LogUtils = getLogUtils(); describe('LifeCycle function', () => { it('不能在componentWillMount里setState', () => { - class App extends Horizon.Component { + class App extends Inula.Component { state = {}; UNSAFE_componentWillMount() { @@ -34,13 +34,13 @@ describe('LifeCycle Test', () => { } } - const realNode = Horizon.render(, container); + const realNode = Inula.render(, container); // 不能在componentWillMount里setState expect(realNode.textContent).toBe(undefined); }); it('componentDidMount里调用setState()将触发额外渲染', () => { - class ChildApp extends Horizon.Component { + class ChildApp extends Inula.Component { constructor(props) { super(props); } @@ -54,7 +54,7 @@ describe('LifeCycle Test', () => { } } - class App extends Horizon.Component { + class App extends Inula.Component { constructor(props) { super(props); LogUtils.log('constructor'); @@ -75,7 +75,7 @@ describe('LifeCycle Test', () => { } } - const realNode = Horizon.render(, container); + const realNode = Inula.render(, container); // 确实触发了额外渲染 expect(LogUtils.getAndClear()).toEqual([ 'constructor', @@ -89,7 +89,7 @@ describe('LifeCycle Test', () => { }); it('调用 this.setState() 通常不会触发 UNSAFE_componentWillReceiveProps()', () => { - class App extends Horizon.Component { + class App extends Inula.Component { state = {}; update = () => { @@ -108,14 +108,14 @@ describe('LifeCycle Test', () => { } } - const realNode = Horizon.render(, container); + const realNode = Inula.render(, container); expect(realNode.textContent).toBe(undefined); realNode.update(); expect(LogUtils.getAndClear()).toEqual([]); }); it('不能在componentWillReceiveProps里setState', () => { - class ChildApp extends Horizon.Component { + class ChildApp extends Inula.Component { state = {}; UNSAFE_componentWillReceiveProps() { @@ -127,7 +127,7 @@ describe('LifeCycle Test', () => { return
{this.state.text}
; } } - class App extends Horizon.Component { + class App extends Inula.Component { state = {}; update = () => { @@ -139,7 +139,7 @@ describe('LifeCycle Test', () => { } } - const realNode = Horizon.render(, container); + const realNode = Inula.render(, container); expect(realNode.textContent).toBe(undefined); realNode.update(); expect(LogUtils.getAndClear()).toEqual([ @@ -151,7 +151,7 @@ describe('LifeCycle Test', () => { }); it('shouldComponentUpdate与getDerivedStateFromProps', () => { - class App extends Horizon.Component { + class App extends Inula.Component { constructor(props) { super(props); this.state = { @@ -175,24 +175,24 @@ describe('LifeCycle Test', () => { } } - Horizon.render(, container); + Inula.render(, container); // 初次渲染不会调用shouldComponentUpdate expect(LogUtils.getAndClear()).toEqual([]); expect(container.querySelector('p').innerHTML).toBe('1'); - Horizon.render(, container); + Inula.render(, container); // getDerivedStateFromProps判断state没有变化时,会调用shouldComponentUpdate expect(LogUtils.getAndClear()).toEqual(['shouldComponentUpdate']); expect(container.querySelector('p').innerHTML).toBe('1'); - Horizon.render(, container); + Inula.render(, container); // getDerivedStateFromProps判断state变化时,会调用shouldComponentUpdate expect(LogUtils.getAndClear()).toEqual(['shouldComponentUpdate']); expect(container.querySelector('p').innerHTML).toBe('2'); }); it('如果shouldComponentUpdate()返回值为false,则不会调用componentDidUpdate()', () => { - class App extends Horizon.Component { + class App extends Inula.Component { constructor(props) { super(props); this.state = { @@ -219,22 +219,22 @@ describe('LifeCycle Test', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('1'); - Horizon.render(, container); + Inula.render(, container); // 不会调用componentDidUpdate() expect(LogUtils.getAndClear()).toEqual([]); expect(container.querySelector('p').innerHTML).toBe('1'); - Horizon.render(, container); + Inula.render(, container); // 调用componentDidUpdate() expect(LogUtils.getAndClear()).toEqual(['componentDidUpdate']); expect(container.querySelector('p').innerHTML).toBe('2'); }); it('getSnapshotBeforeUpdate()的返回值会作为componentDidUpdate()的第三个参数', () => { - class App extends Horizon.Component { + class App extends Inula.Component { constructor(props) { super(props); this.state = { @@ -263,11 +263,11 @@ describe('LifeCycle Test', () => { return

{this.state.num}

; } } - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([]); expect(container.querySelector('p').innerHTML).toBe(''); - Horizon.render(, container); + Inula.render(, container); // Snapshot作为componentDidUpdate()的第三个参数 expect(LogUtils.getAndClear()).toEqual([ 'getSnapshotBeforeUpdate prevProps:undefined prevState:undefined', @@ -275,14 +275,14 @@ describe('LifeCycle Test', () => { ]); expect(container.querySelector('p').innerHTML).toBe('1'); - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([ 'getSnapshotBeforeUpdate prevProps:1 prevState:1', 'componentDidUpdate prevProps:1 prevState:1 snapshot:Snapshot', ]); expect(container.querySelector('p').innerHTML).toBe('1'); - Horizon.render(, container); + Inula.render(, container); expect(LogUtils.getAndClear()).toEqual([ 'getSnapshotBeforeUpdate prevProps:1 prevState:1', 'componentDidUpdate prevProps:1 prevState:1 snapshot:Snapshot', @@ -291,7 +291,7 @@ describe('LifeCycle Test', () => { }); it('无论什么原因触发了渲染,只要有渲染就会触发getDerivedStateFromProps', () => { - class App extends Horizon.Component { + class App extends Inula.Component { constructor(props) { super(props); this.state = { @@ -308,8 +308,8 @@ describe('LifeCycle Test', () => { return

{this.state.num}

; } } - let realNode = Horizon.render(, container); - realNode = Horizon.render(, container); + let realNode = Inula.render(, container); + realNode = Inula.render(, container); realNode.forceUpdate(); // 触发了3次渲染 expect(LogUtils.getAndClear()).toEqual([ @@ -321,7 +321,7 @@ describe('LifeCycle Test', () => { }); it('生命周期执行顺序', () => { - class ChildApp extends Horizon.Component { + class ChildApp extends Inula.Component { UNSAFE_componentWillMount() { LogUtils.log('Child componentWillMount'); } @@ -350,7 +350,7 @@ describe('LifeCycle Test', () => { } } - class App extends Horizon.Component { + class App extends Inula.Component { UNSAFE_componentWillMount() { LogUtils.log('componentWillMount'); } @@ -379,7 +379,7 @@ describe('LifeCycle Test', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container.textContent).toBe('1'); expect(LogUtils.getAndClear()).toEqual([ 'componentWillMount', @@ -387,7 +387,7 @@ describe('LifeCycle Test', () => { 'Child componentDidMount', 'componentDidMount' ]); - Horizon.render(, container); + Inula.render(, container); expect(container.textContent).toBe('2'); expect(LogUtils.getAndClear()).toEqual([ 'componentWillReceiveProps', @@ -399,7 +399,7 @@ describe('LifeCycle Test', () => { 'Child componentDidUpdate', 'componentDidUpdate' ]); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); expect(container.textContent).toBe(''); expect(LogUtils.getAndClear()).toEqual([ 'componentWillUnmount', @@ -408,7 +408,7 @@ describe('LifeCycle Test', () => { }); it('新生命周期执行顺序', () => { - class ChildApp extends Horizon.Component { + class ChildApp extends Inula.Component { static getDerivedStateFromProps(props, state) { LogUtils.log('Child getDerivedStateFromProps'); } @@ -434,7 +434,7 @@ describe('LifeCycle Test', () => { } } - class App extends Horizon.Component { + class App extends Inula.Component { static getDerivedStateFromProps(props, state) { LogUtils.log('getDerivedStateFromProps'); } @@ -460,7 +460,7 @@ describe('LifeCycle Test', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container.textContent).toBe('1'); expect(LogUtils.getAndClear()).toEqual([ 'getDerivedStateFromProps', @@ -468,7 +468,7 @@ describe('LifeCycle Test', () => { 'Child componentDidMount', 'componentDidMount' ]); - Horizon.render(, container); + Inula.render(, container); expect(container.textContent).toBe('2'); expect(LogUtils.getAndClear()).toEqual([ 'getDerivedStateFromProps', @@ -480,7 +480,7 @@ describe('LifeCycle Test', () => { 'Child componentDidUpdate', 'componentDidUpdate' ]); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); expect(container.textContent).toBe(''); expect(LogUtils.getAndClear()).toEqual([ 'componentWillUnmount', diff --git a/scripts/__tests__/ComponentTest/Memo.test.js b/scripts/__tests__/ComponentTest/Memo.test.js index 8ff8cd20..2af413b4 100644 --- a/scripts/__tests__/ComponentTest/Memo.test.js +++ b/scripts/__tests__/ComponentTest/Memo.test.js @@ -13,18 +13,18 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; describe('Memo Test', () => { it('Memo should not make the path wrong', function () { let updateApp; function Child() { - const [_, update] = Horizon.useState({}); + const [_, update] = Inula.useState({}); updateApp = () => update({}); return
; } - const MemoChild = Horizon.memo(Child); + const MemoChild = Inula.memo(Child); function App() { return ( @@ -33,14 +33,14 @@ describe('Memo Test', () => { ); } - const MemoApp = Horizon.memo(App); - Horizon.render( + const MemoApp = Inula.memo(App); + Inula.render(
, container ); - Horizon.render( + Inula.render(
diff --git a/scripts/__tests__/ComponentTest/PortalComponent.test.js b/scripts/__tests__/ComponentTest/PortalComponent.test.js index 808689f5..2fc35030 100755 --- a/scripts/__tests__/ComponentTest/PortalComponent.test.js +++ b/scripts/__tests__/ComponentTest/PortalComponent.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { getLogUtils } from '../jest/testUtils'; import dispatchChangeEvent from '../utils/dispatchChangeEvent'; @@ -23,23 +23,23 @@ describe('PortalComponent Test', () => { it('将子节点渲染到存在于父组件以外的 DOM 节点', () => { const portalRoot = document.createElement('div'); - class PortalApp extends Horizon.Component { + class PortalApp extends Inula.Component { constructor(props) { super(props); this.element = portalRoot; } render() { - return Horizon.createPortal(this.props.child, this.element); + return Inula.createPortal(this.props.child, this.element); } } - Horizon.render(PortalApp
} />, container); + Inula.render(PortalApp} />, container); expect(container.textContent).toBe(''); //
PortalApp
被渲染到了portalRoot而非container expect(portalRoot.textContent).toBe('PortalApp'); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); expect(container.textContent).toBe(''); expect(portalRoot.textContent).toBe(''); }); @@ -48,7 +48,7 @@ describe('PortalComponent Test', () => { const portalRoot1st = document.createElement('div'); const portalRoot2nd = document.createElement('div'); - class PortalApp extends Horizon.Component { + class PortalApp extends Inula.Component { constructor(props) { super(props); this.element = portalRoot1st; @@ -57,19 +57,19 @@ describe('PortalComponent Test', () => { render() { return [ - Horizon.createPortal(this.props.child, this.element), - Horizon.createPortal(this.props.child, this.newElement), + Inula.createPortal(this.props.child, this.element), + Inula.createPortal(this.props.child, this.newElement), ]; } } - Horizon.render(PortalApp} />, container); + Inula.render(PortalApp} />, container); expect(container.textContent).toBe(''); //
PortalApp
被渲染到了portalRoot而非container expect(portalRoot1st.textContent).toBe('PortalApp'); expect(portalRoot2nd.textContent).toBe('PortalApp'); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); expect(container.textContent).toBe(''); expect(portalRoot1st.textContent).toBe(''); expect(portalRoot2nd.textContent).toBe(''); @@ -80,7 +80,7 @@ describe('PortalComponent Test', () => { const portalRoot2nd = document.createElement('div'); const portalRoot3rd = document.createElement('div'); - class PortalApp extends Horizon.Component { + class PortalApp extends Inula.Component { constructor(props) { super(props); this.element = portalRoot1st; @@ -91,24 +91,24 @@ describe('PortalComponent Test', () => { render() { return [
PortalApp1st
, - Horizon.createPortal( - [
PortalApp4
, Horizon.createPortal(this.props.child, this.element3rd)], + Inula.createPortal( + [
PortalApp4
, Inula.createPortal(this.props.child, this.element3rd)], this.element ),
PortalApp2nd
, - Horizon.createPortal(this.props.child, this.newElement), + Inula.createPortal(this.props.child, this.newElement), ]; } } - Horizon.render(PortalApp} />, container); + Inula.render(PortalApp} />, container); expect(container.textContent).toBe('PortalApp1stPortalApp2nd'); //
PortalApp4
会挂载在this.element上 expect(portalRoot1st.textContent).toBe('PortalApp4'); expect(portalRoot2nd.textContent).toBe('PortalApp'); expect(portalRoot3rd.textContent).toBe('PortalApp'); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); expect(container.textContent).toBe(''); expect(portalRoot1st.textContent).toBe(''); expect(portalRoot2nd.textContent).toBe(''); @@ -117,50 +117,50 @@ describe('PortalComponent Test', () => { it('改变Portal的参数', () => { const portalRoot = document.createElement('div'); - class PortalApp extends Horizon.Component { + class PortalApp extends Inula.Component { constructor(props) { super(props); this.element = portalRoot; } render() { - return Horizon.createPortal(this.props.child, this.element); + return Inula.createPortal(this.props.child, this.element); } } - Horizon.render(PortalApp} />, container); + Inula.render(PortalApp} />, container); expect(container.textContent).toBe(''); expect(portalRoot.textContent).toBe('PortalApp'); - Horizon.render(AppPortal} />, container); + Inula.render(AppPortal} />, container); expect(container.textContent).toBe(''); expect(portalRoot.textContent).toBe('AppPortal'); - Horizon.render(, container); + Inula.render(, container); expect(container.textContent).toBe(''); expect(portalRoot.textContent).toBe('portal'); - Horizon.render(, container); + Inula.render(, container); expect(container.textContent).toBe(''); expect(portalRoot.textContent).toBe(''); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); expect(container.textContent).toBe(''); expect(portalRoot.textContent).toBe(''); }); it('通过Portal进行事件冒泡', () => { const portalRoot = document.createElement('div'); - const buttonRef = Horizon.createRef(); + const buttonRef = Inula.createRef(); - class PortalApp extends Horizon.Component { + class PortalApp extends Inula.Component { constructor(props) { super(props); this.element = portalRoot; } render() { - return Horizon.createPortal(this.props.child, this.element); + return Inula.createPortal(this.props.child, this.element); } } @@ -187,7 +187,7 @@ describe('PortalComponent Test', () => { ); }; - Horizon.render(, container); + Inula.render(, container); const event = document.createEvent('Event'); event.initEvent('click', true, true); buttonRef.current.dispatchEvent(event); @@ -200,21 +200,21 @@ describe('PortalComponent Test', () => { }); it('Create portal at app root should not add event listener multiple times', () => { - const btnRef = Horizon.createRef(); + const btnRef = Inula.createRef(); - class PortalApp extends Horizon.Component { + class PortalApp extends Inula.Component { constructor(props) { super(props); } render() { - return Horizon.createPortal(this.props.child, container); + return Inula.createPortal(this.props.child, container); } } const onClick = jest.fn(); - class App extends Horizon.Component { + class App extends Inula.Component { constructor(props) { super(props); } @@ -229,13 +229,13 @@ describe('PortalComponent Test', () => { } } - Horizon.render(, container); + Inula.render(, container); btnRef.current.click(); expect(onClick).toHaveBeenCalledTimes(1); }); it('#76 Portal onChange should activate', () => { - class Dialog extends Horizon.Component { + class Dialog extends Inula.Component { node; constructor(props) { @@ -245,20 +245,20 @@ describe('PortalComponent Test', () => { } render() { - return Horizon.createPortal(this.props.children, this.node); + return Inula.createPortal(this.props.children, this.node); } } let showPortalInput; const fn = jest.fn(); - const inputRef = Horizon.createRef(); + const inputRef = Inula.createRef(); function App() { const Input = () => { - const [show, setShow] = Horizon.useState(false); + const [show, setShow] = Inula.useState(false); showPortalInput = setShow; - Horizon.useEffect(() => { + Inula.useEffect(() => { setTimeout(() => { setShow(true); }, 0); @@ -280,7 +280,7 @@ describe('PortalComponent Test', () => { ); } - Horizon.render(, container); + Inula.render(, container); showPortalInput(true); jest.advanceTimersToNextTimer(); dispatchChangeEvent(inputRef.current, 'test'); diff --git a/scripts/__tests__/ComponentTest/SuspenseComponent.test.js b/scripts/__tests__/ComponentTest/SuspenseComponent.test.js index 753373bc..37279de8 100755 --- a/scripts/__tests__/ComponentTest/SuspenseComponent.test.js +++ b/scripts/__tests__/ComponentTest/SuspenseComponent.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { Text } from '../jest/commonComponents'; import { getLogUtils } from '../jest/testUtils'; @@ -42,18 +42,18 @@ describe('SuspenseComponent Test', () => { it('挂载lazy组件', async () => { // 用同步的代码来实现异步操作 - class LazyComponent extends Horizon.Component { + class LazyComponent extends Inula.Component { render() { return ; } } - const Lazy = Horizon.lazy(() => mockImport(LazyComponent)); + const Lazy = Inula.lazy(() => mockImport(LazyComponent)); - Horizon.render( - }> + Inula.render( + }> - , + , container ); @@ -61,10 +61,10 @@ describe('SuspenseComponent Test', () => { expect(container.textContent).toBe('Loading...'); await Promise.resolve(); - Horizon.render( - }> + Inula.render( + }> - , + , container ); expect(LogUtils.getAndClear()).toEqual([5]); diff --git a/scripts/__tests__/DomTest/Attribute.test.js b/scripts/__tests__/DomTest/Attribute.test.js index 06706ede..bf560e0e 100755 --- a/scripts/__tests__/DomTest/Attribute.test.js +++ b/scripts/__tests__/DomTest/Attribute.test.js @@ -13,48 +13,48 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; describe('Dom Attribute', () => { it('属性值为null或undefined时,不会设置此属性', () => { - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').getAttribute('id')).toBe('div'); - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').hasAttribute('id')).toBe(false); - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').hasAttribute('id')).toBe(false); }); it('可以设置未知的属性', () => { - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').hasAttribute('abcd')).toBe(true); expect(container.querySelector('div').getAttribute('abcd')).toBe('abcd'); }); it('未知属性的值为null或undefined时,不会设置此属性', () => { - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').hasAttribute('abcd')).toBe(false); - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').hasAttribute('abcd')).toBe(false); }); it('未知属性的值为数字时,属性值会转为字符串', () => { - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').getAttribute('abcd')).toBe('0'); - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').getAttribute('abcd')).toBe('-3'); - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').getAttribute('abcd')).toBe('123.45'); }); it('访问节点的标准属性时可以拿到属性值,访问节点的非标准属性时会得到undefined', () => { - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').id).toBe('div'); expect(container.querySelector('div').abcd).toBe(undefined); }); it('特性方法', () => { - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').hasAttribute('abcd')).toBe(true); expect(container.querySelector('div').getAttribute('abcd')).toBe('0'); container.querySelector('div').setAttribute('abcd', 4); @@ -64,7 +64,7 @@ describe('Dom Attribute', () => { }); it('特性大小写不敏感', () => { - Horizon.render(
, container); + Inula.render(
, container); expect(container.querySelector('div').hasAttribute('abcd')).toBe(true); expect(container.querySelector('div').hasAttribute('ABCD')).toBe(true); expect(container.querySelector('div').getAttribute('abcd')).toBe('0'); @@ -72,19 +72,19 @@ describe('Dom Attribute', () => { }); it('使用 data- 开头的特性时,会映射到DOM的dataset属性且中划线格式会变成驼峰格式', () => { - Horizon.render(
, container); + Inula.render(
, container); container.querySelector('div').setAttribute('data-first-name', 'Tom'); expect(container.querySelector('div').dataset.firstName).toBe('Tom'); }); it('style 自动加px', () => { - const div = Horizon.render(
, container); + const div = Inula.render(
, container); expect(window.getComputedStyle(div).getPropertyValue('width')).toBe('10px'); expect(window.getComputedStyle(div).getPropertyValue('height')).toBe('20px'); }); it('WebkitLineClamp和lineClamp样式不会把数字转换成字符串或者追加"px"', () => { - Horizon.render(
, container); + Inula.render(
, container); // 浏览器可以将WebkitLineClamp识别为-webkit-line-clamp,测试框架不可以 expect(container.querySelector('div').style.WebkitLineClamp).toBe(2); }); @@ -92,7 +92,7 @@ describe('Dom Attribute', () => { it('空字符串做属性名', () => { const emptyStringProps = { '': '' }; expect(() => { - Horizon.render(
, container); + Inula.render(
, container); }).not.toThrow(); }); }); diff --git a/scripts/__tests__/DomTest/DomInput.test.js b/scripts/__tests__/DomTest/DomInput.test.js index ef9964d2..98b79119 100755 --- a/scripts/__tests__/DomTest/DomInput.test.js +++ b/scripts/__tests__/DomTest/DomInput.test.js @@ -14,37 +14,37 @@ */ /* eslint-disable @typescript-eslint/no-empty-function */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { getLogUtils } from '../jest/testUtils'; describe('Dom Input', () => { - const { act } = Horizon; + const { act } = Inula; const LogUtils = getLogUtils(); describe('type checkbox', () => { it('没有设置checked属性时,控制台不会报错', () => { expect(() => - Horizon.render(, container), + Inula.render(, container), ).not.toThrow(); }); it('checked属性为undefined或null时且没有onChange属性或没有readOnly={true},控制台不会报错', () => { expect(() => - Horizon.render(, container), + Inula.render(, container), ).not.toThrow(); expect(() => - Horizon.render(, container), + Inula.render(, container), ).not.toThrow(); }); it('复选框的value属性值可以改变', () => { - Horizon.render( + Inula.render( { LogUtils.log('checkbox click'); }} />, container, ); - Horizon.render( + Inula.render( { LogUtils.log('checkbox click'); }} />, @@ -56,7 +56,7 @@ describe('Dom Input', () => { }); it('复选框不设置value属性值时会设置value为"on"', () => { - Horizon.render( + Inula.render( , container, ); @@ -65,21 +65,21 @@ describe('Dom Input', () => { }); it('测试defaultChecked与更改defaultChecked', () => { - Horizon.render( + Inula.render( , container, ); expect(container.querySelector('input').value).toBe('on'); expect(container.querySelector('input').checked).toBe(false); - Horizon.render( + Inula.render( , container, ); expect(container.querySelector('input').value).toBe('on'); expect(container.querySelector('input').checked).toBe(true); - Horizon.render( + Inula.render( , container, ); @@ -91,86 +91,86 @@ describe('Dom Input', () => { describe('type text', () => { it('value属性为undefined或null时且没有onChange属性或没有readOnly={true},控制台不会报错', () => { expect(() => - Horizon.render(, container), + Inula.render(, container), ).not.toThrow(); expect(() => - Horizon.render(, container), + Inula.render(, container), ).not.toThrow(); expect(() => - Horizon.render(, container), + Inula.render(, container), ).not.toThrow(); }); it('value值会转为字符串', () => { - const realNode = Horizon.render(, container); + const realNode = Inula.render(, container); expect(realNode.value).toBe('1'); }); it('value值可以被设置为true/false', () => { - let realNode = Horizon.render(, container); + let realNode = Inula.render(, container); expect(realNode.value).toBe('1'); - realNode = Horizon.render(, container); + realNode = Inula.render(, container); expect(realNode.value).toBe('true'); - realNode = Horizon.render(, container); + realNode = Inula.render(, container); expect(realNode.value).toBe('false'); }); it('value值可以被设置为object', () => { - let realNode = Horizon.render(, container); + let realNode = Inula.render(, container); expect(realNode.value).toBe('1'); const value = { toString: () => { return 'value'; } }; - realNode = Horizon.render(, container); + realNode = Inula.render(, container); expect(realNode.value).toBe('value'); }); it('设置defaultValue', () => { - let realNode = Horizon.render(, container); + let realNode = Inula.render(, container); expect(realNode.value).toBe('1'); expect(realNode.getAttribute('value')).toBe('1'); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); // 测试defaultValue为boolean类型 - realNode = Horizon.render(, container); + realNode = Inula.render(, container); expect(realNode.value).toBe('true'); expect(realNode.getAttribute('value')).toBe('true'); - Horizon.unmountComponentAtNode(container); - realNode = Horizon.render(, container); + Inula.unmountComponentAtNode(container); + realNode = Inula.render(, container); expect(realNode.value).toBe('false'); expect(realNode.getAttribute('value')).toBe('false'); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); const value = { toString: () => { return 'default'; } }; - realNode = Horizon.render(, container); + realNode = Inula.render(, container); expect(realNode.value).toBe('default'); expect(realNode.getAttribute('value')).toBe('default'); }); it('value为0、defaultValue为1,input 的value应该为0', () => { - const input = Horizon.render(, container); + const input = Inula.render(, container); expect(input.getAttribute('value')).toBe('0'); }); it('name属性', () => { - let realNode = Horizon.render(, container); + let realNode = Inula.render(, container); expect(realNode.name).toBe('name'); expect(realNode.getAttribute('name')).toBe('name'); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); // 没有设置name属性 - realNode = Horizon.render(, container); + realNode = Inula.render(, container); expect(realNode.name).toBe(''); expect(realNode.getAttribute('name')).toBe(null); }); it('受控input可以触发onChange', () => { - let realNode = Horizon.render(, container); + let realNode = Inula.render(, container); Object.getOwnPropertyDescriptor( HTMLInputElement.prototype, 'value', @@ -189,19 +189,19 @@ describe('Dom Input', () => { describe('type radio', () => { it('radio的value可以更新', () => { - let realNode = Horizon.render(, container); + let realNode = Inula.render(, container); expect(realNode.value).toBe(''); expect(realNode.getAttribute('value')).toBe(''); - realNode = Horizon.render(, container); + realNode = Inula.render(, container); expect(realNode.value).toBe('false'); expect(realNode.getAttribute('value')).toBe('false'); - realNode = Horizon.render(, container); + realNode = Inula.render(, container); expect(realNode.value).toBe('true'); expect(realNode.getAttribute('value')).toBe('true'); }); it('相同name且在同一表单的radio互斥', () => { - Horizon.render( + Inula.render( <> @@ -231,9 +231,9 @@ describe('Dom Input', () => { }); it('name改变不影响相同name的radio', () => { - const inputRef = Horizon.createRef(); + const inputRef = Inula.createRef(); const App = () => { - const [isNum, setNum] = Horizon.useState(false); + const [isNum, setNum] = Inula.useState(false); const inputName = isNum ? 'secondName' : 'firstName'; const buttonClick = () => { @@ -259,7 +259,7 @@ describe('Dom Input', () => {
); }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').checked).toBe(false); expect(inputRef.current.checked).toBe(true); // 点击button,触发setNum @@ -271,15 +271,15 @@ describe('Dom Input', () => { describe('type submit', () => { it('type submit value', () => { - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(false); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(true); expect(container.querySelector('input').getAttribute('value')).toBe(''); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(true); expect(container.querySelector('input').getAttribute('value')).toBe('submit'); }); @@ -287,15 +287,15 @@ describe('Dom Input', () => { describe('type reset', () => { it('type reset value', () => { - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(false); - Horizon.unmountComponentAtNode(container); + Inula.unmountComponentAtNode(container); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(true); expect(container.querySelector('input').getAttribute('value')).toBe(''); - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(true); expect(container.querySelector('input').getAttribute('value')).toBe('reset'); }); @@ -303,13 +303,13 @@ describe('Dom Input', () => { describe('type number', () => { it('value值会把number类型转为字符串,且.xx转为0.xx', () => { - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(true); expect(container.querySelector('input').getAttribute('value')).toBe('0.12'); }); it('value值会把number类型转为字符串,且.xx转为0.xx', () => { - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(true); expect(container.querySelector('input').getAttribute('value')).toBe('0.12'); }); @@ -317,11 +317,11 @@ describe('Dom Input', () => { it('改变node.value值', () => { let setNum; const App = () => { - const [num, _setNum] = Horizon.useState(''); + const [num, _setNum] = Inula.useState(''); setNum = _setNum; return ; }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(true); expect(container.querySelector('input').getAttribute('value')).toBe(''); act(() => { @@ -333,11 +333,11 @@ describe('Dom Input', () => { it('node.value精度', () => { let setNum; const App = () => { - const [num, _setNum] = Horizon.useState(0.0000); + const [num, _setNum] = Inula.useState(0.0000); setNum = _setNum; return ; }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').getAttribute('value')).toBe('0'); act(() => { setNum(1.0000); @@ -350,7 +350,7 @@ describe('Dom Input', () => { const App = () => { return ; }; - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').getAttribute('value')).toBe('1'); expect(container.querySelector('input').value).toBe('1'); @@ -374,17 +374,17 @@ describe('Dom Input', () => { describe('type reset', () => { it('type reset的value值', () => { - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(true); expect(container.querySelector('input').getAttribute('value')).toBe('0.12'); - Horizon.unmountComponentAtNode(container); - Horizon.render(, container); + Inula.unmountComponentAtNode(container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(true); expect(container.querySelector('input').getAttribute('value')).toBe(''); - Horizon.unmountComponentAtNode(container); - Horizon.render(, container); + Inula.unmountComponentAtNode(container); + Inula.render(, container); expect(container.querySelector('input').hasAttribute('value')).toBe(false); }); }); diff --git a/scripts/__tests__/DomTest/DomSelect.test.js b/scripts/__tests__/DomTest/DomSelect.test.js index a126ab4c..4a718601 100755 --- a/scripts/__tests__/DomTest/DomSelect.test.js +++ b/scripts/__tests__/DomTest/DomSelect.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; describe('Dom Select', () => { it('设置value', () => { @@ -24,12 +24,12 @@ describe('Dom Select', () => { ); - const realNode = Horizon.render(selectNode, container); + const realNode = Inula.render(selectNode, container); expect(realNode.value).toBe('Vue'); expect(realNode.options[1].selected).toBe(true); realNode.value = 'React'; // 改变value会影响select的状态 - Horizon.render(selectNode, container); + Inula.render(selectNode, container); expect(realNode.options[0].selected).toBe(true); expect(realNode.value).toBe('React'); }); @@ -47,7 +47,7 @@ describe('Dom Select', () => { ); - const realNode = Horizon.render(selectNode, container); + const realNode = Inula.render(selectNode, container); expect(realNode.value).toBe('Vue'); expect(realNode.options[1].selected).toBe(true); selectValue = { @@ -63,7 +63,7 @@ describe('Dom Select', () => { ); // 改变value会影响select的状态 - Horizon.render(newSelectNode, container); + Inula.render(newSelectNode, container); expect(realNode.options[0].selected).toBe(true); expect(realNode.value).toBe('React'); }); @@ -76,7 +76,7 @@ describe('Dom Select', () => { ); - const realNode = Horizon.render(selectNode, container); + const realNode = Inula.render(selectNode, container); expect(realNode.value).toBe('Vue'); expect(realNode.options[1].selected).toBe(true); const newSelectNode = ( @@ -86,7 +86,7 @@ describe('Dom Select', () => { ); - Horizon.render(newSelectNode, container); + Inula.render(newSelectNode, container); // selected不变 expect(realNode.options[0].selected).toBe(false); expect(realNode.options[1].selected).toBe(true); @@ -102,13 +102,13 @@ describe('Dom Select', () => { ); - let realNode = Horizon.render(selectNode, container); + let realNode = Inula.render(selectNode, container); expect(realNode.value).toBe('Vue'); expect(realNode.options[1].selected).toBe(true); defaultVal = 'React'; // 改变defaultValue没有影响 - realNode = Horizon.render(selectNode, container); + realNode = Inula.render(selectNode, container); expect(realNode.value).toBe('Vue'); expect(realNode.options[0].selected).toBe(false); expect(realNode.options[1].selected).toBe(true); @@ -122,7 +122,7 @@ describe('Dom Select', () => { ); - let realNode = Horizon.render(selectNode, container); + let realNode = Inula.render(selectNode, container); expect(realNode.value).toBe('Vue'); expect(realNode.options[1].selected).toBe(true); @@ -139,7 +139,7 @@ describe('Dom Select', () => { }), ); // 鼠标改变受控select生效,select不受控 - Horizon.render(selectNode, container); + Inula.render(selectNode, container); // 'React'项没被选中 expect(realNode.options[0].selected).toBe(true); expect(realNode.options[1].selected).toBe(false); @@ -156,7 +156,7 @@ describe('Dom Select', () => { ); expect( - () => Horizon.render(selectNode, container) + () => Inula.render(selectNode, container) ).toThrowError('newValues.forEach is not a function'); }); @@ -169,7 +169,7 @@ describe('Dom Select', () => { ); expect( - () => Horizon.render(selectNode, container) + () => Inula.render(selectNode, container) ).not.toThrow(); expect(document.getElementById('se').options[0].selected).toBe(false); expect(document.getElementById('se').options[1].selected).toBe(true); @@ -183,7 +183,7 @@ describe('Dom Select', () => { ); - Horizon.render(selectNode, container); + Inula.render(selectNode, container); expect(document.getElementById('se').options[0].selected).toBe(false); expect(document.getElementById('se').options[1].selected).toBe(true); expect(document.getElementById('se').options[2].selected).toBe(true); @@ -198,7 +198,7 @@ describe('Dom Select', () => { ); expect( - () => Horizon.render(selectNode, container) + () => Inula.render(selectNode, container) ).not.toThrow(); expect(document.getElementById('se').options[0].selected).toBe(false); expect(document.getElementById('se').options[1].selected).toBe(true); @@ -212,7 +212,7 @@ describe('Dom Select', () => { ); - Horizon.render(selectNode, container); + Inula.render(selectNode, container); expect(document.getElementById('se').options[0].selected).toBe(true); expect(document.getElementById('se').options[1].selected).toBe(false); expect(document.getElementById('se').options[2].selected).toBe(false); @@ -226,7 +226,7 @@ describe('Dom Select', () => { ); - Horizon.render(selectNode, container); + Inula.render(selectNode, container); expect(document.getElementById('se').options[0].selected).toBe(false); expect(document.getElementById('se').options[1].selected).toBe(true); expect(document.getElementById('se').options[2].selected).toBe(true); @@ -239,7 +239,7 @@ describe('Dom Select', () => { ); - Horizon.render(selectNode, container); + Inula.render(selectNode, container); expect(document.getElementById('se').options[0].selected).toBe(true); expect(document.getElementById('se').options[1].selected).toBe(false); expect(document.getElementById('se').options[2].selected).toBe(false); @@ -253,7 +253,7 @@ describe('Dom Select', () => { ); - Horizon.render(selectNode, container); + Inula.render(selectNode, container); expect(document.getElementById('se').options[0].selected).toBe(true); expect(document.getElementById('se').options[1].selected).toBe(false); expect(document.getElementById('se').options[2].selected).toBe(false); @@ -266,7 +266,7 @@ describe('Dom Select', () => { ); - Horizon.render(selectNode, container); + Inula.render(selectNode, container); expect(document.getElementById('se').options[0].selected).toBe(false); expect(document.getElementById('se').options[1].selected).toBe(true); expect(document.getElementById('se').options[2].selected).toBe(true); @@ -280,7 +280,7 @@ describe('Dom Select', () => { ); - const realNode = Horizon.render(selectNode, container); + const realNode = Inula.render(selectNode, container); expect(realNode.options[0].selected).toBe(false); expect(realNode.options[1].selected).toBe(true); expect(realNode.options[2].selected).toBe(false); @@ -294,7 +294,7 @@ describe('Dom Select', () => { ); - const realNode = Horizon.render(selectNode, container); + const realNode = Inula.render(selectNode, container); expect(realNode.options[0].selected).toBe(false); expect(realNode.options[1].selected).toBe(true); expect(realNode.options[2].selected).toBe(false); @@ -305,7 +305,7 @@ describe('Dom Select', () => { ); - Horizon.render(newNode, container); + Inula.render(newNode, container); expect(realNode.options[0].selected).toBe(false); expect(realNode.options[1].selected).toBe(false); @@ -317,7 +317,7 @@ describe('Dom Select', () => { ); // 重新添加不会影响 - Horizon.render(newSelectNode, container); + Inula.render(newSelectNode, container); expect(realNode.options[0].selected).toBe(false); expect(realNode.options[1].selected).toBe(false); expect(realNode.options[2].selected).toBe(false); diff --git a/scripts/__tests__/DomTest/DomTextarea.test.js b/scripts/__tests__/DomTest/DomTextarea.test.js index 5944a92a..000e9644 100644 --- a/scripts/__tests__/DomTest/DomTextarea.test.js +++ b/scripts/__tests__/DomTest/DomTextarea.test.js @@ -13,20 +13,20 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; describe('Dom Textarea', () => { it('设置value', () => { - let realNode = Horizon.render(, container); + Inula.render(, container); expect(realNode.value).toBe('false'); }); @@ -92,14 +92,14 @@ describe('Dom Textarea', () => { const textareaNode = ( , container); + let realNode = Inula.render(, container); expect(realNode.value).toBe('1234'); - realNode = Horizon.render(, container); + realNode = Inula.render(, container); // realNode.value依旧为1234 expect(realNode.value).toBe('1234'); }); diff --git a/scripts/__tests__/EventTest/EventMain.test.js b/scripts/__tests__/EventTest/EventMain.test.js index e0341d72..c189f7de 100644 --- a/scripts/__tests__/EventTest/EventMain.test.js +++ b/scripts/__tests__/EventTest/EventMain.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import * as TestUtils from '../jest/testUtils'; function dispatchChangeEvent(input) { @@ -38,7 +38,7 @@ describe('事件', () => { ); }; - Horizon.render(, container); + Inula.render(, container); const a = container.querySelector('button'); a.click(); expect(LogUtils.getAndClear()).toEqual([ @@ -54,7 +54,7 @@ describe('事件', () => { it('returns 0', () => { let keyCode = null; - const node = Horizon.render( + const node = Inula.render( { keyCode = e.keyCode; @@ -87,7 +87,7 @@ describe('事件', () => { ); }; - Horizon.render(, container); + Inula.render(, container); container.querySelector('button').click(); expect(LogUtils.getAndClear()).toEqual([ @@ -114,7 +114,7 @@ describe('事件', () => { ); }; - Horizon.render(, container); + Inula.render(, container); container.querySelector('button').click(); expect(LogUtils.getAndClear()).toEqual([ @@ -133,7 +133,7 @@ describe('事件', () => {
); }; - Horizon.render(, container); + Inula.render(, container); container.querySelector('div').addEventListener( 'click', () => { @@ -162,15 +162,15 @@ describe('事件', () => { it('动态增加事件', () => { let update; - let inputRef = Horizon.createRef(); + let inputRef = Inula.createRef(); function Test() { - const [inputProps, setProps] = Horizon.useState({}); + const [inputProps, setProps] = Inula.useState({}); update = setProps; return ; } - Horizon.render(, container); + Inula.render(, container); update({ onChange: () => { LogUtils.log('change'); @@ -193,10 +193,10 @@ describe('事件', () => { radio2Called++; } - const radio1Ref = Horizon.createRef(); - const radio2Ref = Horizon.createRef(); + const radio1Ref = Inula.createRef(); + const radio2Ref = Inula.createRef(); - Horizon.render( + Inula.render( <> @@ -228,7 +228,7 @@ describe('事件', () => { let input1, input2, update1, update2; function App1() { - const [props, setProps] = Horizon.useState({}); + const [props, setProps] = Inula.useState({}); update1 = setProps; return ( { } function App2() { - const [props, setProps] = Horizon.useState({}); + const [props, setProps] = Inula.useState({}); update2 = setProps; return ( @@ -257,8 +257,8 @@ describe('事件', () => { } // 多根mount阶段挂载onChange事件 - Horizon.render(, root1); - Horizon.render(, root2); + Inula.render(, root1); + Inula.render(, root2); dispatchChangeEvent(input1); expect(LogUtils.getAndClear()).toEqual(['input1 changed']); diff --git a/scripts/__tests__/EventTest/FocusEvent.test.js b/scripts/__tests__/EventTest/FocusEvent.test.js index 10978d2d..b0f2954c 100644 --- a/scripts/__tests__/EventTest/FocusEvent.test.js +++ b/scripts/__tests__/EventTest/FocusEvent.test.js @@ -13,14 +13,14 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { getLogUtils } from '../jest/testUtils'; describe('合成焦点事件', () => { const LogUtils = getLogUtils(); it('onFocus', () => { - const realNode = Horizon.render( + const realNode = Inula.render( LogUtils.log(`onFocus: ${event.type}`)} onFocusCapture={event => LogUtils.log(`onFocusCapture: ${event.type}`)} @@ -40,7 +40,7 @@ describe('合成焦点事件', () => { }); it('onBlur', () => { - const realNode = Horizon.render( + const realNode = Inula.render( LogUtils.log(`onBlur: ${event.type}`)} onBlurCapture={event => LogUtils.log(`onBlurCapture: ${event.type}`)} diff --git a/scripts/__tests__/EventTest/KeyboardEvent.test.js b/scripts/__tests__/EventTest/KeyboardEvent.test.js index 675ef450..e6077aca 100644 --- a/scripts/__tests__/EventTest/KeyboardEvent.test.js +++ b/scripts/__tests__/EventTest/KeyboardEvent.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import {getLogUtils} from '../jest/testUtils'; describe('Keyboard Event', () => { @@ -29,7 +29,7 @@ describe('Keyboard Event', () => { }; it('keydown,keypress,keyup的keycode,charcode', () => { - const node = Horizon.render( + const node = Inula.render( { LogUtils.log('onKeyUp: keycode: ' + e.keyCode + ',charcode: ' + e.charCode); @@ -50,7 +50,7 @@ describe('Keyboard Event', () => { }); it('keypress的keycode,charcode', () => { - const node = Horizon.render( + const node = Inula.render( { LogUtils.log('onKeyPress: keycode: ' + e.keyCode + ',charcode: ' + e.charCode); @@ -66,7 +66,7 @@ describe('Keyboard Event', () => { }); it('当charcode为13,且不设置keycode的时候', () => { - const node = Horizon.render( + const node = Inula.render( { LogUtils.log('onKeyPress: keycode: ' + e.keyCode + ',charcode: ' + e.charCode); @@ -81,7 +81,7 @@ describe('Keyboard Event', () => { }); it('keydown,keypress,keyup的code', () => { - const node = Horizon.render( + const node = Inula.render( { LogUtils.log('onKeyUp: code: ' + e.code); @@ -124,7 +124,7 @@ describe('Keyboard Event', () => { expect(e.isPropagationStopped()).toBe(true); LogUtils.log(e.type + ' handle'); }; - const div = Horizon.render( + const div = Inula.render(
{ let container; @@ -39,7 +39,7 @@ describe('mouseenter和mouseleave事件测试', () => { iframeDocument.close(); const leaveEvents = []; - const node = Horizon.render( + const node = Inula.render(
{ e.persist(); @@ -72,7 +72,7 @@ describe('mouseenter和mouseleave事件测试', () => { iframeDocument.close(); const enterEvents = []; - const node = Horizon.render( + const node = Inula.render(
{ e.persist(); @@ -100,7 +100,7 @@ describe('mouseenter和mouseleave事件测试', () => { let childEnterCalls = 0; let parent = null; - class Parent extends Horizon.Component { + class Parent extends Inula.Component { render() { return (
{ } } - Horizon.render(, container); - Horizon.render(, container); + Inula.render(, container); + Inula.render(, container); parent.dispatchEvent( new MouseEvent('mouseout', { @@ -133,14 +133,14 @@ describe('mouseenter和mouseleave事件测试', () => { const mockFn2 = jest.fn(); const mockFn3 = jest.fn(); - class Parent extends Horizon.Component { + class Parent extends Inula.Component { constructor(props) { super(props); - this.parentEl = Horizon.createRef(); + this.parentEl = Inula.createRef(); } componentDidMount() { - Horizon.render(, this.parentEl.current); + Inula.render(, this.parentEl.current); } render() { @@ -148,11 +148,11 @@ describe('mouseenter和mouseleave事件测试', () => { } } - class MouseEnterDetect extends Horizon.Component { + class MouseEnterDetect extends Inula.Component { constructor(props) { super(props); - this.firstEl = Horizon.createRef(); - this.siblingEl = Horizon.createRef(); + this.firstEl = Inula.createRef(); + this.siblingEl = Inula.createRef(); } componentDidMount() { @@ -171,28 +171,28 @@ describe('mouseenter和mouseleave事件测试', () => { render() { return ( - +
- + ); } } - Horizon.render(, container); + Inula.render(, container); }); - it('未被horizon管理的节点触发mouseout事件,mouseenter事件也能正常触发', done => { + it('未被inula管理的节点触发mouseout事件,mouseenter事件也能正常触发', done => { const mockFn = jest.fn(); - class Parent extends Horizon.Component { + class Parent extends Inula.Component { constructor(props) { super(props); - this.parentEl = Horizon.createRef(); + this.parentEl = Inula.createRef(); } componentDidMount() { - Horizon.render(, this.parentEl.current); + Inula.render(, this.parentEl.current); } render() { @@ -200,11 +200,11 @@ describe('mouseenter和mouseleave事件测试', () => { } } - class MouseEnterDetect extends Horizon.Component { + class MouseEnterDetect extends Inula.Component { constructor(props) { super(props); - this.divRef = Horizon.createRef(); - this.siblingEl = Horizon.createRef(); + this.divRef = Inula.createRef(); + this.siblingEl = Inula.createRef(); } componentDidMount() { @@ -230,22 +230,22 @@ describe('mouseenter和mouseleave事件测试', () => { } } - Horizon.render(, container); + Inula.render(, container); }); it('外部portal节点触发的mouseout事件,根节点的mouseleave事件也能响应', () => { - const divRef = Horizon.createRef(); + const divRef = Inula.createRef(); const onMouseLeave = jest.fn(); function Component() { return (
- {Horizon.createPortal(
, document.body)} + {Inula.createPortal(
, document.body)}
); } - Horizon.render(, container); + Inula.render(, container); divRef.current.dispatchEvent( new MouseEvent('mouseout', { @@ -259,14 +259,14 @@ describe('mouseenter和mouseleave事件测试', () => { }); it('外部portal节点触发的mouseout事件,根节点的mouseEnter事件也能响应', () => { - const divRef = Horizon.createRef(); - const otherDivRef = Horizon.createRef(); + const divRef = Inula.createRef(); + const otherDivRef = Inula.createRef(); const onMouseEnter = jest.fn(); function Component() { return (
- {Horizon.createPortal( + {Inula.createPortal(
, document.body, )} @@ -274,7 +274,7 @@ describe('mouseenter和mouseleave事件测试', () => { ); } - Horizon.render(, container); + Inula.render(, container); divRef.current.dispatchEvent( new MouseEvent('mouseout', { diff --git a/scripts/__tests__/EventTest/MouseEvent.test.js b/scripts/__tests__/EventTest/MouseEvent.test.js index 62abb34c..46cc6522 100644 --- a/scripts/__tests__/EventTest/MouseEvent.test.js +++ b/scripts/__tests__/EventTest/MouseEvent.test.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { getLogUtils } from '../jest/testUtils'; describe('MouseEvent Test', () => { @@ -21,7 +21,7 @@ describe('MouseEvent Test', () => { describe('onClick Test', () => { it('绑定this', () => { - class App extends Horizon.Component { + class App extends Inula.Component { constructor(props) { super(props); this.state = { @@ -52,7 +52,7 @@ describe('MouseEvent Test', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container.querySelector('p').innerHTML).toBe('0'); expect(container.querySelector('#p').innerHTML).toBe('100'); // 点击按钮触发num加1 @@ -65,7 +65,7 @@ describe('MouseEvent Test', () => { it('点击触发', () => { const handleClick = jest.fn(); - Horizon.render(, container); + Inula.render(, container); container.querySelector('button').click(); expect(handleClick).toHaveBeenCalledTimes(1); for (let i = 0; i < 5; i++) { @@ -76,8 +76,8 @@ describe('MouseEvent Test', () => { it('disable不触发click', () => { const handleClick = jest.fn(); - const spanRef = Horizon.createRef(); - Horizon.render( + const spanRef = Inula.createRef(); + Inula.render( , @@ -90,7 +90,7 @@ describe('MouseEvent Test', () => { }); const test = (name, config) => { - const node = Horizon.render(config, container); + const node = Inula.render(config, container); let event = new MouseEvent(name, { relatedTarget: null, bubbles: true, @@ -163,7 +163,7 @@ describe('MouseEvent Test', () => { }); it('KeyboardEvent.getModifierState should not fail', () => { - const input = Horizon.render( { e.getModifierState('CapsLock'); }} diff --git a/scripts/__tests__/EventTest/WheelEvent.test.js b/scripts/__tests__/EventTest/WheelEvent.test.js index e563d94c..13f8bada 100644 --- a/scripts/__tests__/EventTest/WheelEvent.test.js +++ b/scripts/__tests__/EventTest/WheelEvent.test.js @@ -13,14 +13,14 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { getLogUtils } from '../jest/testUtils'; describe('合成滚轮事件', () => { const LogUtils = getLogUtils(); it('onWheel', () => { - const realNode = Horizon.render( + const realNode = Inula.render(
LogUtils.log(`onWheel: ${event.type}`)} onWheelCapture={event => LogUtils.log(`onWheelCapture: ${event.type}`)} @@ -50,7 +50,7 @@ describe('合成滚轮事件', () => { expect(e.isPropagationStopped()).toBe(true); LogUtils.log(e.type + ' handle'); }; - const realNode = Horizon.render( + const realNode = Inula.render(
, container ); diff --git a/scripts/__tests__/HorizonIsTest/index.test.js b/scripts/__tests__/HorizonIsTest/index.test.js deleted file mode 100644 index ff33477d..00000000 --- a/scripts/__tests__/HorizonIsTest/index.test.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2020 Huawei Technologies Co.,Ltd. - * - * InulaJS is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import * as Horizon from '@cloudsop/horizon/index.ts'; - -function App() { - return <>; -} - -describe('HorizonIs', () => { - it('should identify horizon elements', () => { - expect(Horizon.isElement(
)).toBe(true); - expect(Horizon.isElement('span')).toBe(false); - expect(Horizon.isElement(111)).toBe(false); - expect(Horizon.isElement(false)).toBe(false); - expect(Horizon.isElement(null)).toBe(false); - expect(Horizon.isElement([])).toBe(false); - expect(Horizon.isElement({})).toBe(false); - expect(Horizon.isElement(undefined)).toBe(false); - - const TestContext = Horizon.createContext(false); - expect(Horizon.isElement()).toBe(true); - expect(Horizon.isElement()).toBe(true); - expect(Horizon.isElement(<>)).toBe(true); - expect(Horizon.isElement()).toBe(true); - }); - - it('should identify Fragment', () => { - expect(Horizon.isFragment(<>)).toBe(true); - }); - - it('should identify memo component', () => { - const MemoComp = Horizon.memo(App); - expect(Horizon.isMemo()).toBe(true); - }); - - it('should identify forwardRef', () => { - const ForwardRefComp = Horizon.forwardRef(App); - expect(Horizon.isForwardRef()).toBe(true); - }); - - it('should identify lazy', () => { - const LazyComp = Horizon.lazy(() => App); - expect(Horizon.isLazy()).toBe(true); - }); - - it('should identify portal', () => { - const portal = Horizon.createPortal(
, container); - expect(Horizon.isPortal(portal)).toBe(true); - }); - - it('should identify ContextProvider', () => { - const TestContext = Horizon.createContext(false); - expect(Horizon.isContextProvider()).toBe(true); - expect(Horizon.isContextProvider()).toBe(false); - expect(Horizon.isContextConsumer()).toBe(false); - expect(Horizon.isContextConsumer()).toBe(true); - }); -}); diff --git a/scripts/__tests__/HorizonXTest/StateManager/StateArray.test.tsx b/scripts/__tests__/HorizonXTest/StateManager/StateArray.test.tsx index 9ffad653..ca4a9e08 100644 --- a/scripts/__tests__/HorizonXTest/StateManager/StateArray.test.tsx +++ b/scripts/__tests__/HorizonXTest/StateManager/StateArray.test.tsx @@ -14,9 +14,9 @@ */ //@ts-ignore -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import * as LogUtils from '../../jest/logUtils'; -import { clearStore, createStore, useStore } from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import { clearStore, createStore, useStore } from '../../../../libs/inula/src/inulax/store/StoreHandler'; import { App, Text, triggerClickEvent } from '../../jest/commonComponents'; import { describe, beforeEach, afterEach, it, expect } from '@jest/globals'; @@ -49,7 +49,7 @@ const useUserStore = createStore({ }); describe('测试store中的Array', () => { - const { unmountComponentAtNode } = Horizon; + const { unmountComponentAtNode } = Inula; let container: HTMLElement | null = null; beforeEach(() => { // 创建一个 DOM 元素作为渲染目标 @@ -102,17 +102,17 @@ describe('测试store中的Array', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: 2'); // 在Array中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: 3'); // 在Array中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: 2'); @@ -138,7 +138,7 @@ describe('测试store中的Array', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // push @@ -188,7 +188,7 @@ describe('测试store中的Array', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // push diff --git a/scripts/__tests__/HorizonXTest/StateManager/StateMap.test.tsx b/scripts/__tests__/HorizonXTest/StateManager/StateMap.test.tsx index e91e0e13..ddbf7589 100644 --- a/scripts/__tests__/HorizonXTest/StateManager/StateMap.test.tsx +++ b/scripts/__tests__/HorizonXTest/StateManager/StateMap.test.tsx @@ -14,9 +14,9 @@ */ //@ts-ignore -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import * as LogUtils from '../../jest/logUtils'; -import { clearStore, createStore, useStore } from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import { clearStore, createStore, useStore } from '../../../../libs/inula/src/inulax/store/StoreHandler'; import { App, Text, triggerClickEvent } from '../../jest/commonComponents'; import { describe, beforeEach, afterEach, it, expect } from '@jest/globals'; @@ -49,7 +49,7 @@ const useUserStore = createStore({ }); describe('测试store中的Map', () => { - const { unmountComponentAtNode } = Horizon; + const { unmountComponentAtNode } = Inula; let container: HTMLElement | null = null; beforeEach(() => { // 创建一个 DOM 元素作为渲染目标 @@ -110,23 +110,23 @@ describe('测试store中的Map', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 0'); @@ -149,23 +149,23 @@ describe('测试store中的Map', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); @@ -188,23 +188,23 @@ describe('测试store中的Map', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#ageList')?.innerHTML).toBe('age list: 1 2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#ageList')?.innerHTML).toBe('age list: 1 2 3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#ageList')?.innerHTML).toBe('age list: 1 2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#ageList')?.innerHTML).toBe('age list: '); @@ -227,23 +227,23 @@ describe('测试store中的Map', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); @@ -265,23 +265,23 @@ describe('测试store中的Map', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); @@ -298,11 +298,11 @@ describe('测试store中的Map', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: false'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: true'); @@ -324,23 +324,23 @@ describe('测试store中的Map', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); diff --git a/scripts/__tests__/HorizonXTest/StateManager/StateMixType.test.tsx b/scripts/__tests__/HorizonXTest/StateManager/StateMixType.test.tsx index 2bb360af..52e9b610 100644 --- a/scripts/__tests__/HorizonXTest/StateManager/StateMixType.test.tsx +++ b/scripts/__tests__/HorizonXTest/StateManager/StateMixType.test.tsx @@ -14,13 +14,13 @@ */ //@ts-ignore -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import * as LogUtils from '../../jest/logUtils'; -import { clearStore, createStore, useStore } from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import { clearStore, createStore, useStore } from '../../../../libs/inula/src/inulax/store/StoreHandler'; import { App, Text, triggerClickEvent } from '../../jest/commonComponents'; describe('测试store中的混合类型变化', () => { - const { unmountComponentAtNode } = Horizon; + const { unmountComponentAtNode } = Inula; let container: HTMLElement | null = null; beforeEach(() => { // 创建一个 DOM 元素作为渲染目标 @@ -98,10 +98,10 @@ describe('测试store中的混合类型变化', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#dayList')?.innerHTML).toBe('love: 1 3 5'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#dayList')?.innerHTML).toBe('love: 1 3 5 7'); @@ -168,7 +168,7 @@ describe('测试store中的混合类型变化', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('p1 p2'); diff --git a/scripts/__tests__/HorizonXTest/StateManager/StateSet.test.tsx b/scripts/__tests__/HorizonXTest/StateManager/StateSet.test.tsx index 7c1c8656..84213b7d 100644 --- a/scripts/__tests__/HorizonXTest/StateManager/StateSet.test.tsx +++ b/scripts/__tests__/HorizonXTest/StateManager/StateSet.test.tsx @@ -14,9 +14,9 @@ */ //@ts-ignore -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import * as LogUtils from '../../jest/logUtils'; -import { clearStore, createStore, useStore } from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import { clearStore, createStore, useStore } from '../../../../libs/inula/src/inulax/store/StoreHandler'; import { App, Text, triggerClickEvent } from '../../jest/commonComponents'; import { describe, beforeEach, afterEach, it, expect } from '@jest/globals'; @@ -49,7 +49,7 @@ const useUserStore = createStore({ }); describe('测试store中的Set', () => { - const { unmountComponentAtNode } = Horizon; + const { unmountComponentAtNode } = Inula; let container: HTMLElement | null = null; beforeEach(() => { // 创建一个 DOM 元素作为渲染目标 @@ -116,24 +116,24 @@ describe('测试store中的Set', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 2'); expect(container?.querySelector('#lastAge')?.innerHTML).toBe('last person age: 2'); // 在set中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 3'); // 在set中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 2'); // clear set - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 0'); @@ -158,23 +158,23 @@ describe('测试store中的Set', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在set中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在set中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear set - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); @@ -197,23 +197,23 @@ describe('测试store中的Set', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在set中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在set中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear set - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); @@ -235,23 +235,23 @@ describe('测试store中的Set', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在set中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在set中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear set - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); @@ -268,11 +268,11 @@ describe('测试store中的Set', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: false'); // 在set中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: true'); @@ -294,23 +294,23 @@ describe('测试store中的Set', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在set中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在set中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear set - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); diff --git a/scripts/__tests__/HorizonXTest/StateManager/StateWeakMap.test.tsx b/scripts/__tests__/HorizonXTest/StateManager/StateWeakMap.test.tsx index c6e2fc09..9e847d18 100644 --- a/scripts/__tests__/HorizonXTest/StateManager/StateWeakMap.test.tsx +++ b/scripts/__tests__/HorizonXTest/StateManager/StateWeakMap.test.tsx @@ -14,9 +14,9 @@ */ //@ts-ignore -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import * as LogUtils from '../../jest/logUtils'; -import { clearStore, createStore, useStore } from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import { clearStore, createStore, useStore } from '../../../../libs/inula/src/inulax/store/StoreHandler'; import { App, Text, triggerClickEvent } from '../../jest/commonComponents'; import { describe, beforeEach, afterEach, it, expect } from '@jest/globals'; @@ -49,7 +49,7 @@ const useUserStore = createStore({ }); describe('测试store中的WeakMap', () => { - const { unmountComponentAtNode } = Horizon; + const { unmountComponentAtNode } = Inula; let container: HTMLElement | null = null; beforeEach(() => { // 创建一个 DOM 元素作为渲染目标 @@ -110,17 +110,17 @@ describe('测试store中的WeakMap', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: false'); // 在WeakMap中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: true'); // 在WeakMap中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: false'); @@ -137,11 +137,11 @@ describe('测试store中的WeakMap', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: undefined'); // 在WeakMap中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: 3'); diff --git a/scripts/__tests__/HorizonXTest/StateManager/StateWeakSet.test.tsx b/scripts/__tests__/HorizonXTest/StateManager/StateWeakSet.test.tsx index 962e73c3..9986b941 100644 --- a/scripts/__tests__/HorizonXTest/StateManager/StateWeakSet.test.tsx +++ b/scripts/__tests__/HorizonXTest/StateManager/StateWeakSet.test.tsx @@ -14,9 +14,9 @@ */ //@ts-ignore -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import * as LogUtils from '../../jest/logUtils'; -import { clearStore, createStore, useStore } from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import { clearStore, createStore, useStore } from '../../../../libs/inula/src/inulax/store/StoreHandler'; import { App, Text, triggerClickEvent } from '../../jest/commonComponents'; import { describe, beforeEach, afterEach, it, expect } from '@jest/globals'; @@ -49,7 +49,7 @@ const useUserStore = createStore({ }); describe('测试store中的WeakSet', () => { - const { unmountComponentAtNode } = Horizon; + const { unmountComponentAtNode } = Inula; let container: HTMLElement | null = null; beforeEach(() => { // 创建一个 DOM 元素作为渲染目标 @@ -102,17 +102,17 @@ describe('测试store中的WeakSet', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: false'); // 在WeakSet中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: true'); // 在WeakSet中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: false'); diff --git a/scripts/__tests__/HorizonXTest/StoreFunctionality/async.test.tsx b/scripts/__tests__/HorizonXTest/StoreFunctionality/async.test.tsx index a215e3be..da9e1ca6 100644 --- a/scripts/__tests__/HorizonXTest/StoreFunctionality/async.test.tsx +++ b/scripts/__tests__/HorizonXTest/StoreFunctionality/async.test.tsx @@ -14,12 +14,12 @@ */ //@ts-ignore -import * as Horizon from '../../../../libs/horizon'; -import { createStore } from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import * as Inula from '../../../../libs/inula/index'; +import { createStore } from '../../../../libs/inula/src/inulax/store/StoreHandler'; import { triggerClickEvent } from '../../jest/commonComponents'; import { describe, beforeEach, afterEach, it, expect } from '@jest/globals'; -const { unmountComponentAtNode } = Horizon; +const { unmountComponentAtNode } = Inula; function postpone(timer, func) { return new Promise(resolve => { diff --git a/scripts/__tests__/HorizonXTest/StoreFunctionality/basicAccess.test.tsx b/scripts/__tests__/HorizonXTest/StoreFunctionality/basicAccess.test.tsx index a626551b..277a5bad 100644 --- a/scripts/__tests__/HorizonXTest/StoreFunctionality/basicAccess.test.tsx +++ b/scripts/__tests__/HorizonXTest/StoreFunctionality/basicAccess.test.tsx @@ -14,13 +14,13 @@ */ //@ts-ignore -import Horizon from '@cloudsop/horizon/index.ts'; +import Inula from '../../../../libs/inula/index'; import { triggerClickEvent } from '../../jest/commonComponents'; import { useLogStore } from './store'; import { describe, beforeEach, afterEach, it, expect } from '@jest/globals'; -import { createStore } from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import { createStore } from '../../../../libs/inula/src/inulax/store/StoreHandler'; -const { unmountComponentAtNode } = Horizon; +const { unmountComponentAtNode } = Inula; describe('Basic store manipulation', () => { let container: HTMLElement | null = null; @@ -46,7 +46,7 @@ describe('Basic store manipulation', () => { return
{logStore.length}
; } - Horizon.render(, container); + Inula.render(, container); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('1'); }); @@ -70,9 +70,9 @@ describe('Basic store manipulation', () => { ); } - Horizon.render(, container); + Inula.render(, container); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); @@ -98,9 +98,9 @@ describe('Basic store manipulation', () => { ); } - Horizon.render(, container); + Inula.render(, container); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); @@ -142,9 +142,9 @@ describe('Basic store manipulation', () => { ); } - Horizon.render(, container); + Inula.render(, container); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); @@ -187,9 +187,9 @@ describe('Basic store manipulation', () => { ); } - Horizon.render(, container); + Inula.render(, container); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); diff --git a/scripts/__tests__/HorizonXTest/StoreFunctionality/cloneDeep.test.js b/scripts/__tests__/HorizonXTest/StoreFunctionality/cloneDeep.test.js index d2b159d8..e1c0231d 100644 --- a/scripts/__tests__/HorizonXTest/StoreFunctionality/cloneDeep.test.js +++ b/scripts/__tests__/HorizonXTest/StoreFunctionality/cloneDeep.test.js @@ -13,13 +13,13 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; -import { clearStore, createStore, useStore } from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; -import { OBSERVER_KEY } from '../../../../libs/horizon/src/horizonx/Constants'; +import * as Inula from '../../../../libs/inula/index'; +import { clearStore, createStore, useStore } from '../../../../libs/inula/src/inulax/store/StoreHandler'; +import { OBSERVER_KEY } from '../../../../libs/inula/src/inulax/Constants'; import { App, Text, triggerClickEvent } from '../../jest/commonComponents'; describe('测试对store.state对象进行深度克隆', () => { - const { unmountComponentAtNode } = Horizon; + const { unmountComponentAtNode } = Inula; let container = null; beforeEach(() => { // 创建一个 DOM 元素作为渲染目标 @@ -81,7 +81,7 @@ describe('测试对store.state对象进行深度克隆', () => { ); } - it('The observer object of symbol (\'_horizonObserver\') cannot be accessed to from Proxy', () => { + it('The observer object of symbol (\'_inulaObserver\') cannot be accessed to from Proxy', () => { let userStore = null; function Child(props) { userStore = useStore('user'); @@ -93,13 +93,13 @@ describe('测试对store.state对象进行深度克隆', () => { ); } - Horizon.render(, container); + Inula.render(, container); - // The observer object of symbol ('_horizonObserver') cannot be accessed to from Proxy prevent errors caused by clonedeep. + // The observer object of symbol ('_inulaObserver') cannot be accessed to from Proxy prevent errors caused by clonedeep. expect(userStore.persons[0][OBSERVER_KEY]).toBe(undefined); }); - it('The observer object of symbol (\'_horizonObserver\') cannot be accessed to from Proxy', () => { + it('The observer object of symbol (\'_inulaObserver\') cannot be accessed to from Proxy', () => { let userStore = null; function Child(props) { userStore = useStore('user'); @@ -111,7 +111,7 @@ describe('测试对store.state对象进行深度克隆', () => { ); } - Horizon.render(, container); + Inula.render(, container); // NO throw this Exception, TypeError: 'get' on proxy: property 'prototype' is a read-only and non-configurable data property on the proxy target but the proxy did not return its actual value const proxyObj = userStore.persons[0].constructor; diff --git a/scripts/__tests__/HorizonXTest/StoreFunctionality/dollarAccess.test.tsx b/scripts/__tests__/HorizonXTest/StoreFunctionality/dollarAccess.test.tsx index 0ecd9fca..54c211f5 100644 --- a/scripts/__tests__/HorizonXTest/StoreFunctionality/dollarAccess.test.tsx +++ b/scripts/__tests__/HorizonXTest/StoreFunctionality/dollarAccess.test.tsx @@ -14,12 +14,12 @@ */ //@ts-ignore -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import { triggerClickEvent } from '../../jest/commonComponents'; import { useLogStore } from './store'; import { describe, beforeEach, afterEach, it, expect } from '@jest/globals'; -const { unmountComponentAtNode } = Horizon; +const { unmountComponentAtNode } = Inula; describe('Dollar store access', () => { let container: HTMLElement | null = null; @@ -45,7 +45,7 @@ describe('Dollar store access', () => { return
{logStore.$c.length()}
; } - Horizon.render(, container); + Inula.render(, container); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('1'); }); @@ -69,9 +69,9 @@ describe('Dollar store access', () => { ); } - Horizon.render(, container); + Inula.render(, container); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); diff --git a/scripts/__tests__/HorizonXTest/StoreFunctionality/otherCases.test.tsx b/scripts/__tests__/HorizonXTest/StoreFunctionality/otherCases.test.tsx index 46f5198b..8d473e8b 100644 --- a/scripts/__tests__/HorizonXTest/StoreFunctionality/otherCases.test.tsx +++ b/scripts/__tests__/HorizonXTest/StoreFunctionality/otherCases.test.tsx @@ -14,12 +14,12 @@ */ //@ts-ignore -import * as Horizon from '@cloudsop/horizon/index.ts'; -import { createStore } from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import * as Inula from '../../../../libs/inula/index'; +import { createStore } from '../../../../libs/inula/src/inulax/store/StoreHandler'; import { triggerClickEvent } from '../../jest/commonComponents'; import { describe, beforeEach, afterEach, it, expect } from '@jest/globals'; -const { unmountComponentAtNode } = Horizon; +const { unmountComponentAtNode } = Inula; describe('Self referencing', () => { let container: HTMLElement | null = null; @@ -69,17 +69,17 @@ describe('Self referencing', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('4'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('6'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); @@ -110,11 +110,11 @@ describe('Self referencing', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('5'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); @@ -154,10 +154,10 @@ describe('Self referencing', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('abc'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('def'); diff --git a/scripts/__tests__/HorizonXTest/StoreFunctionality/reset.js b/scripts/__tests__/HorizonXTest/StoreFunctionality/reset.js index 6fa0a639..4df7add5 100644 --- a/scripts/__tests__/HorizonXTest/StoreFunctionality/reset.js +++ b/scripts/__tests__/HorizonXTest/StoreFunctionality/reset.js @@ -13,11 +13,11 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; -import {createStore} from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import * as Inula from '../../../../libs/inula/index'; +import {createStore} from '../../../../libs/inula/src/inulax/store/StoreHandler'; import {triggerClickEvent} from '../../jest/commonComponents'; -const {unmountComponentAtNode} = Horizon; +const {unmountComponentAtNode} = Inula; describe('Reset', () => { it('RESET NOT IMPLEMENTED', async () => { @@ -69,25 +69,25 @@ describe('Reset', () => {
} - Horizon.render(, container); + Inula.render(, container); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); expect(document.getElementById(RESULT_ID).innerHTML).toBe('2'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, RESET_ID); }); expect(document.getElementById(RESULT_ID).innerHTML).toBe('0'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); diff --git a/scripts/__tests__/HorizonXTest/StoreFunctionality/store.ts b/scripts/__tests__/HorizonXTest/StoreFunctionality/store.ts index 4831afd3..f37d4547 100644 --- a/scripts/__tests__/HorizonXTest/StoreFunctionality/store.ts +++ b/scripts/__tests__/HorizonXTest/StoreFunctionality/store.ts @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import { createStore } from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import { createStore } from '../../../../libs/inula/src/inulax/store/StoreHandler'; export const useLogStore = createStore({ id: 'logStore', // you do not need to specify ID for local store diff --git a/scripts/__tests__/HorizonXTest/StoreFunctionality/utils.test.js b/scripts/__tests__/HorizonXTest/StoreFunctionality/utils.test.js index be07b4c4..ff9f0629 100644 --- a/scripts/__tests__/HorizonXTest/StoreFunctionality/utils.test.js +++ b/scripts/__tests__/HorizonXTest/StoreFunctionality/utils.test.js @@ -1,4 +1,4 @@ -import { resolveMutation } from '../../../../libs/horizon/src/horizonx/CommonUtils'; +import { resolveMutation } from '../../../../libs/inula/src/inulax/CommonUtils'; describe('Mutation resolve', () => { it('should resolve mutation different types', () => { diff --git a/scripts/__tests__/HorizonXTest/StoreFunctionality/watch.test.tsx b/scripts/__tests__/HorizonXTest/StoreFunctionality/watch.test.tsx index b6e44453..5d51aa76 100644 --- a/scripts/__tests__/HorizonXTest/StoreFunctionality/watch.test.tsx +++ b/scripts/__tests__/HorizonXTest/StoreFunctionality/watch.test.tsx @@ -13,8 +13,8 @@ * See the Mulan PSL v2 for more details. */ -import { createStore } from '@cloudsop/horizon/src/horizonx/store/StoreHandler'; -import { watch } from '@cloudsop/horizon/src/horizonx/proxy/watch'; +import { createStore } from '../../../../libs/inula'; +import { watch } from '../../../../libs/inula'; describe('watch', () => { it('shouhld watch primitive state variable', async () => { diff --git a/scripts/__tests__/HorizonXTest/adapters/ReduxAdapter.test.tsx b/scripts/__tests__/HorizonXTest/adapters/ReduxAdapter.test.tsx index 16e5bbe7..431719f5 100644 --- a/scripts/__tests__/HorizonXTest/adapters/ReduxAdapter.test.tsx +++ b/scripts/__tests__/HorizonXTest/adapters/ReduxAdapter.test.tsx @@ -14,13 +14,13 @@ */ //@ts-ignore -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import { createStore, applyMiddleware, combineReducers, bindActionCreators, -} from '../../../../libs/horizon/src/horizonx/adapters/redux'; +} from '../../../../libs/inula/src/inulax/adapters/redux'; import { describe, it, expect } from '@jest/globals'; describe('Redux adapter', () => { diff --git a/scripts/__tests__/HorizonXTest/adapters/ReduxAdapterThunk.test.tsx b/scripts/__tests__/HorizonXTest/adapters/ReduxAdapterThunk.test.tsx index c7ccf8b2..2507f28a 100644 --- a/scripts/__tests__/HorizonXTest/adapters/ReduxAdapterThunk.test.tsx +++ b/scripts/__tests__/HorizonXTest/adapters/ReduxAdapterThunk.test.tsx @@ -13,8 +13,8 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; -import { createStore, applyMiddleware, thunk } from '../../../../libs/horizon/src/horizonx/adapters/redux'; +import * as Inula from '../../../../libs/inula/index'; +import { createStore, applyMiddleware, thunk } from '../../../../libs/inula/src/inulax/adapters/redux'; import {describe, it, expect} from '@jest/globals'; describe('Redux thunk', () => { diff --git a/scripts/__tests__/HorizonXTest/adapters/ReduxReactAdapter.test.tsx b/scripts/__tests__/HorizonXTest/adapters/ReduxReactAdapter.test.tsx index bf31c13a..b2402c90 100644 --- a/scripts/__tests__/HorizonXTest/adapters/ReduxReactAdapter.test.tsx +++ b/scripts/__tests__/HorizonXTest/adapters/ReduxReactAdapter.test.tsx @@ -14,7 +14,7 @@ */ //@ts-ignore -import horizon, * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import { batch, connect, @@ -25,10 +25,10 @@ import { useStore, createSelectorHook, createDispatchHook -} from '../../../../libs/horizon/src/horizonx/adapters/redux'; +} from '../../../../libs/inula/src/inulax/adapters/redux'; import {triggerClickEvent} from '../../jest/commonComponents'; import {describe, it, beforeEach, afterEach, expect} from '@jest/globals'; -import { ReduxStoreHandler } from '@cloudsop/horizon/src/horizonx/types'; +import { ReduxStoreHandler } from '../../../../libs/inula/src/inulax/adapters/redux'; const BUTTON = 'button'; const BUTTON2 = 'button2'; @@ -64,7 +64,7 @@ describe('Redux/React binding adapter', () => { ; }; - Horizon.render(, getE(CONTAINER)); + Inula.render(, getE(CONTAINER)); expect(getE(RESULT).innerHTML).toBe('state'); }); @@ -92,11 +92,11 @@ describe('Redux/React binding adapter', () => { ; }; - Horizon.render(, getE(CONTAINER)); + Inula.render(, getE(CONTAINER)); expect(reduxStore.getState()).toBe(0); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(getE(CONTAINER), BUTTON); }); @@ -127,11 +127,11 @@ describe('Redux/React binding adapter', () => { ; }; - Horizon.render(, getE(CONTAINER)); + Inula.render(, getE(CONTAINER)); expect(getE(RESULT).innerHTML).toBe('0'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(getE(CONTAINER), BUTTON); triggerClickEvent(getE(CONTAINER), BUTTON); }); @@ -181,7 +181,7 @@ describe('Redux/React binding adapter', () => { const Wrapper = () => { //@ts-ignore - const [amount, setAmount] = Horizon.useState(5); + const [amount, setAmount] = Inula.useState(5); return
; } - Horizon.render(, getE(CONTAINER)); + Inula.render(, getE(CONTAINER)); expect(getE(RESULT).innerHTML).toBe('0'); expect(renderCounter).toBe(1); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(getE(CONTAINER), BUTTON); }); @@ -262,8 +262,8 @@ describe('Redux/React binding adapter', () => { return state; }); - const counterContext = horizon.createContext(); - const toggleContext = horizon.createContext(); + const counterContext = Inula.createContext(); + const toggleContext = Inula.createContext(); function Counter() { const count = createSelectorHook(counterContext)(); @@ -295,12 +295,12 @@ describe('Redux/React binding adapter', () => {
; } - Horizon.render(, getE(CONTAINER)); + Inula.render(, getE(CONTAINER)); expect(getE(BUTTON).innerHTML).toBe('0'); expect(getE(BUTTON2).innerHTML).toBe('false'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(getE(CONTAINER), BUTTON); triggerClickEvent(getE(CONTAINER), BUTTON2); }); diff --git a/scripts/__tests__/HorizonXTest/adapters/connectTest.tsx b/scripts/__tests__/HorizonXTest/adapters/connectTest.tsx index a11b8249..59e42396 100644 --- a/scripts/__tests__/HorizonXTest/adapters/connectTest.tsx +++ b/scripts/__tests__/HorizonXTest/adapters/connectTest.tsx @@ -1,7 +1,7 @@ -import { createElement } from '../../../../libs/horizon/src/external/JSXElement'; -import { createDomTextVNode } from '../../../../libs/horizon/src/renderer/vnode/VNodeCreator'; -import { createStore } from '../../../../libs/horizon/src/horizonx/adapters/redux'; -import { connect } from '../../../../libs/horizon/src/horizonx/adapters/reduxReact'; +import { createElement } from '../../../../libs/inula/src/external/JSXElement'; +import { createDomTextVNode } from '../../../../libs/inula/src/renderer/vnode/VNodeCreator'; +import { createStore } from '../../../../libs/inula/src/inulax/adapters/redux'; +import { connect } from '../../../../libs/inula/src/inulax/adapters/reduxReact'; createStore((state: number = 0, action): number => { if (action.type === 'add') return state + 1; diff --git a/scripts/__tests__/HorizonXTest/class/ClassException.test.tsx b/scripts/__tests__/HorizonXTest/class/ClassException.test.tsx index 4feb4635..1a9aed46 100644 --- a/scripts/__tests__/HorizonXTest/class/ClassException.test.tsx +++ b/scripts/__tests__/HorizonXTest/class/ClassException.test.tsx @@ -13,15 +13,15 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import * as LogUtils from '../../jest/logUtils'; -import {clearStore, createStore, useStore} from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import {clearStore, createStore, useStore} from '../../../../libs/inula/src/inulax/store/StoreHandler'; import {Text, triggerClickEvent} from '../../jest/commonComponents'; -import {getObserver} from '../../../../libs/horizon/src/horizonx/proxy/ProxyHandler'; +import {getObserver} from '../../../../libs/inula/src/inulax/proxy/ProxyHandler'; import {describe, beforeEach, afterEach, it, expect} from '@jest/globals'; describe('测试 Class VNode 清除时,对引用清除', () => { - const {unmountComponentAtNode} = Horizon; + const {unmountComponentAtNode} = Inula; let container:HTMLElement|null = null; let globalState = { name: 'bing dun dun', @@ -62,7 +62,7 @@ describe('测试 Class VNode 清除时,对引用清除', () => { }); it('test observer.clearByNode', () => { - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useStore('user'); render() { @@ -78,7 +78,7 @@ describe('测试 Class VNode 清除时,对引用清除', () => { } expect(() => { - Horizon.render(, container); + Inula.render(, container); }).toThrow('The number of updates exceeds the upper limit 50.\n' + ' A component maybe repeatedly invokes setState on componentWillUpdate or componentDidUpdate.'); diff --git a/scripts/__tests__/HorizonXTest/class/ClassStateArray.test.tsx b/scripts/__tests__/HorizonXTest/class/ClassStateArray.test.tsx index fccc922f..c1dd15a3 100644 --- a/scripts/__tests__/HorizonXTest/class/ClassStateArray.test.tsx +++ b/scripts/__tests__/HorizonXTest/class/ClassStateArray.test.tsx @@ -13,9 +13,9 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import * as LogUtils from '../../jest/logUtils'; -import {clearStore, createStore, useStore} from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import {clearStore, createStore, useStore} from '../../../../libs/inula/src/inulax/store/StoreHandler'; import {App, Text, triggerClickEvent} from '../../jest/commonComponents'; import {describe, beforeEach, afterEach, it, expect} from '@jest/globals'; @@ -42,7 +42,7 @@ let useUserStore = createStore({ }); describe('在Class组件中,测试store中的Array', () => { - const { unmountComponentAtNode } = Horizon; + const { unmountComponentAtNode } = Inula; let container:HTMLElement|null = null; beforeEach(() => { // 创建一个 DOM 元素作为渲染目标 @@ -61,7 +61,7 @@ describe('在Class组件中,测试store中的Array', () => { }); const newPerson = { name: 'p3', age: 3 }; - class Parent extends Horizon.Component { + class Parent extends Inula.Component { userStore = useUserStore(); props:{ children:any[] @@ -96,7 +96,7 @@ describe('在Class组件中,测试store中的Array', () => { } it('测试Array方法: push()、pop()', () => { - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useUserStore(); render() { @@ -108,17 +108,17 @@ describe('在Class组件中,测试store中的Array', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: 2'); // 在Array中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: 3'); // 在Array中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: 2'); @@ -127,7 +127,7 @@ describe('在Class组件中,测试store中的Array', () => { it('测试Array方法: entries()、push()、shift()、unshift、直接赋值', () => { let globalStore = useUserStore(); - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useUserStore(); constructor(props) { @@ -152,7 +152,7 @@ describe('在Class组件中,测试store中的Array', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // push @@ -188,7 +188,7 @@ describe('在Class组件中,测试store中的Array', () => { it('测试Array方法: forEach()', () => { let globalStore = useUserStore(); globalStore.$s.persons.push({ name: 'p2', age: 2 }); - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useUserStore(); constructor(props) { @@ -210,7 +210,7 @@ describe('在Class组件中,测试store中的Array', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // push diff --git a/scripts/__tests__/HorizonXTest/class/ClassStateMap.test.tsx b/scripts/__tests__/HorizonXTest/class/ClassStateMap.test.tsx index 50504d38..1ba27076 100644 --- a/scripts/__tests__/HorizonXTest/class/ClassStateMap.test.tsx +++ b/scripts/__tests__/HorizonXTest/class/ClassStateMap.test.tsx @@ -13,9 +13,9 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import * as LogUtils from '../../jest/logUtils'; -import {clearStore, createStore, useStore} from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import {clearStore, createStore, useStore} from '../../../../libs/inula/src/inulax/store/StoreHandler'; import {App, Text, triggerClickEvent} from '../../jest/commonComponents'; import {describe, beforeEach, afterEach, it, expect} from '@jest/globals'; @@ -42,7 +42,7 @@ const useUserStore = createStore({ }); describe('在Class组件中,测试store中的Map', () => { - const { unmountComponentAtNode } = Horizon; + const { unmountComponentAtNode } = Inula; let container:HTMLElement|null = null; beforeEach(() => { // 创建一个 DOM 元素作为渲染目标 @@ -64,7 +64,7 @@ describe('在Class组件中,测试store中的Map', () => { const newPerson = { name: 'p3', age: 3 }; - class Parent extends Horizon.Component { + class Parent extends Inula.Component { userStore = useUserStore(); props = {children:[]} @@ -104,7 +104,7 @@ describe('在Class组件中,测试store中的Map', () => { } it('测试Map方法: set()、delete()、clear()', () => { - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useUserStore(); render() { @@ -116,30 +116,30 @@ describe('在Class组件中,测试store中的Map', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#size')?.innerHTML).toBe('persons number: 0'); }); it('测试Map方法: keys()', () => { - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useUserStore(); render() { @@ -157,30 +157,30 @@ describe('在Class组件中,测试store中的Map', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); }); it('测试Map方法: values()', () => { - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useUserStore(); render() { @@ -198,30 +198,30 @@ describe('在Class组件中,测试store中的Map', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#ageList')?.innerHTML).toBe('age list: 1 2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#ageList')?.innerHTML).toBe('age list: 1 2 3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#ageList')?.innerHTML).toBe('age list: 1 2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#ageList')?.innerHTML).toBe('age list: '); }); it('测试Map方法: entries()', () => { - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useUserStore(); render() { @@ -239,30 +239,30 @@ describe('在Class组件中,测试store中的Map', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); }); it('测试Map方法: forEach()', () => { - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useUserStore(); render() { @@ -279,30 +279,30 @@ describe('在Class组件中,测试store中的Map', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); }); it('测试Map方法: has()', () => { - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useUserStore(); render() { @@ -314,18 +314,18 @@ describe('在Class组件中,测试store中的Map', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: false'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#hasPerson')?.innerHTML).toBe('has new person: true'); }); it('测试Map方法: for of()', () => { - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useUserStore(); render() { @@ -342,23 +342,23 @@ describe('在Class组件中,测试store中的Map', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // 在Map中增加一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'addBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2 p3'); // 在Map中删除一个对象 - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'delBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: p1 p2'); // clear Map - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'clearBtn'); }); expect(container?.querySelector('#nameList')?.innerHTML).toBe('name list: '); diff --git a/scripts/__tests__/HorizonXTest/clear/ClassVNodeClear.test.tsx b/scripts/__tests__/HorizonXTest/clear/ClassVNodeClear.test.tsx index f87560c6..6de95373 100644 --- a/scripts/__tests__/HorizonXTest/clear/ClassVNodeClear.test.tsx +++ b/scripts/__tests__/HorizonXTest/clear/ClassVNodeClear.test.tsx @@ -13,15 +13,15 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import * as LogUtils from '../../jest/logUtils'; -import {clearStore, createStore, useStore} from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import {clearStore, createStore, useStore} from '../../../../libs/inula/src/inulax/store/StoreHandler'; import {Text, triggerClickEvent} from '../../jest/commonComponents'; -import {getObserver} from '../../../../libs/horizon/src/horizonx/proxy/ProxyHandler'; +import {getObserver} from '../../../../libs/inula/src/inulax/proxy/ProxyHandler'; import {describe, it, beforeEach, afterEach, expect} from '@jest/globals'; describe('测试 Class VNode 清除时,对引用清除', () => { - const {unmountComponentAtNode} = Horizon; + const {unmountComponentAtNode} = Inula; let container:HTMLElement|null = null; let globalState = { name: 'bing dun dun', @@ -62,7 +62,7 @@ describe('测试 Class VNode 清除时,对引用清除', () => { }); it('test observer.clearByNode', () => { - class App extends Horizon.Component { + class App extends Inula.Component { userStore = useStore('user'); render() { @@ -75,7 +75,7 @@ describe('测试 Class VNode 清除时,对引用清除', () => { } } - class Parent extends Horizon.Component { + class Parent extends Inula.Component { userStore = useStore('user'); setWin = () => { @@ -92,7 +92,7 @@ describe('测试 Class VNode 清除时,对引用清除', () => { } } - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useStore('user'); render() { @@ -105,24 +105,24 @@ describe('测试 Class VNode 清除时,对引用清除', () => { } } - Horizon.render(, container); + Inula.render(, container); // Parent and Child hold the isWin key expect(getObserver(globalState).keyVNodes.get('isWin').size).toBe(2); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'toggleBtn'); }); // Parent hold the isWin key expect(getObserver(globalState).keyVNodes.get('isWin').size).toBe(1); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'toggleBtn'); }); // Parent and Child hold the isWin key expect(getObserver(globalState).keyVNodes.get('isWin').size).toBe(2); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'hideBtn'); }); // no component hold the isWin key diff --git a/scripts/__tests__/HorizonXTest/clear/FunctionVNodeClear.test.tsx b/scripts/__tests__/HorizonXTest/clear/FunctionVNodeClear.test.tsx index d00752e6..37cdd2d0 100644 --- a/scripts/__tests__/HorizonXTest/clear/FunctionVNodeClear.test.tsx +++ b/scripts/__tests__/HorizonXTest/clear/FunctionVNodeClear.test.tsx @@ -13,15 +13,15 @@ * See the Mulan PSL v2 for more details. */ -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../../libs/inula/index'; import * as LogUtils from '../../jest/logUtils'; -import {clearStore, createStore, useStore} from '../../../../libs/horizon/src/horizonx/store/StoreHandler'; +import {clearStore, createStore, useStore} from '../../../../libs/inula/src/inulax/store/StoreHandler'; import {Text, triggerClickEvent} from '../../jest/commonComponents'; -import {getObserver} from '../../../../libs/horizon/src/horizonx/proxy/ProxyHandler'; +import {getObserver} from '../../../../libs/inula/src/inulax/proxy/ProxyHandler'; import {describe, it, beforeEach, afterEach, expect} from '@jest/globals'; describe('测试VNode清除时,对引用清除', () => { - const {unmountComponentAtNode} = Horizon; + const {unmountComponentAtNode} = Inula; let container:HTMLElement|null = null; let globalState = { name: 'bing dun dun', @@ -59,7 +59,7 @@ describe('测试VNode清除时,对引用清除', () => { }); it('test observer.clearByNode', () => { - class App extends Horizon.Component { + class App extends Inula.Component { userStore = useStore('user'); render() { @@ -72,7 +72,7 @@ describe('测试VNode清除时,对引用清除', () => { } } - class Parent extends Horizon.Component { + class Parent extends Inula.Component { userStore = useStore('user'); setWin = () => { @@ -89,7 +89,7 @@ describe('测试VNode清除时,对引用清除', () => { } } - class Child extends Horizon.Component { + class Child extends Inula.Component { userStore = useStore('user'); render() { @@ -100,24 +100,24 @@ describe('测试VNode清除时,对引用清除', () => { } } - Horizon.render(, container); + Inula.render(, container); // Parent and Child hold the isWin key expect(getObserver(globalState).keyVNodes.get('isWin').size).toBe(2); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'toggleBtn'); }); // Parent hold the isWin key expect(getObserver(globalState).keyVNodes.get('isWin').size).toBe(1); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'toggleBtn'); }); // Parent and Child hold the isWin key expect(getObserver(globalState).keyVNodes.get('isWin').size).toBe(2); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, 'hideBtn'); }); // no component hold the isWin key diff --git a/scripts/__tests__/HorizonXTest/edgeCases/deepVariableObserver.test.tsx b/scripts/__tests__/HorizonXTest/edgeCases/deepVariableObserver.test.tsx index 6fff3531..6e7495a1 100644 --- a/scripts/__tests__/HorizonXTest/edgeCases/deepVariableObserver.test.tsx +++ b/scripts/__tests__/HorizonXTest/edgeCases/deepVariableObserver.test.tsx @@ -1,4 +1,4 @@ -import { createStore, useStore } from '@cloudsop/horizon/src/horizonx/store/StoreHandler'; +import { createStore, useStore } from '../../../../libs/inula'; import { describe, beforeEach, afterEach, it, expect } from '@jest/globals'; describe('Using deep variables', () => { diff --git a/scripts/__tests__/HorizonXTest/edgeCases/multipleStores.test.tsx b/scripts/__tests__/HorizonXTest/edgeCases/multipleStores.test.tsx index 12599ba8..9373861d 100644 --- a/scripts/__tests__/HorizonXTest/edgeCases/multipleStores.test.tsx +++ b/scripts/__tests__/HorizonXTest/edgeCases/multipleStores.test.tsx @@ -14,11 +14,11 @@ */ //@ts-ignore -import Horizon, { createStore } from '@cloudsop/horizon/index.ts'; +import Inula, { createStore } from '../../../../libs/inula/index'; import { triggerClickEvent } from '../../jest/commonComponents'; import { describe, beforeEach, afterEach, it, expect } from '@jest/globals'; -const { unmountComponentAtNode } = Horizon; +const { unmountComponentAtNode } = Inula; const useStore1 = createStore({ state: { counter: 1 }, @@ -57,7 +57,7 @@ describe('Using multiple stores', () => { }); it('Should use multiple stores in class component', () => { - class App extends Horizon.Component { + class App extends Inula.Component { render() { const { counter, add } = useStore1(); const { counter2, add2 } = useStore2(); @@ -88,15 +88,15 @@ describe('Using multiple stores', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('1 1'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('2 1'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID2); }); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('2 2'); @@ -107,7 +107,7 @@ describe('Using multiple stores', () => { store: any; store2: any; } - class App extends Horizon.Component { + class App extends Inula.Component { constructor() { super(); this.store = useStore1(); @@ -151,15 +151,15 @@ describe('Using multiple stores', () => { } } - Horizon.render(, container); + Inula.render(, container); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('1 1'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('2 1'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID2); }); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('2 2'); @@ -196,15 +196,15 @@ describe('Using multiple stores', () => { ); } - Horizon.render(, container); + Inula.render(, container); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('1 1'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID); }); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('2 1'); - Horizon.act(() => { + Inula.act(() => { triggerClickEvent(container, BUTTON_ID2); }); expect(document.getElementById(RESULT_ID)?.innerHTML).toBe('2 2'); diff --git a/scripts/__tests__/HorizonXTest/edgeCases/proxy.test.tsx b/scripts/__tests__/HorizonXTest/edgeCases/proxy.test.tsx index e02f5967..ca3d8fa6 100644 --- a/scripts/__tests__/HorizonXTest/edgeCases/proxy.test.tsx +++ b/scripts/__tests__/HorizonXTest/edgeCases/proxy.test.tsx @@ -13,8 +13,8 @@ * See the Mulan PSL v2 for more details. */ -import {createProxy} from '../../../../libs/horizon/src/horizonx/proxy/ProxyHandler'; -import {readonlyProxy} from '../../../../libs/horizon/src/horizonx/proxy/readonlyProxy'; +import {createProxy} from '../../../../libs/inula/src/inulax/proxy/ProxyHandler'; +import {readonlyProxy} from '../../../../libs/inula/src/inulax/proxy/readonlyProxy'; import {describe, beforeEach, afterEach, it, expect} from '@jest/globals'; describe('Proxy', () => { diff --git a/scripts/__tests__/InulaIsTest/index.test.js b/scripts/__tests__/InulaIsTest/index.test.js new file mode 100644 index 00000000..5afbcc7c --- /dev/null +++ b/scripts/__tests__/InulaIsTest/index.test.js @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2020 Huawei Technologies Co.,Ltd. + * + * InulaJS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +import * as Inula from '../../../libs/inula/index'; + +function App() { + return <>; +} + +describe('InulaIs', () => { + it('should identify inula elements', () => { + expect(Inula.isElement(
)).toBe(true); + expect(Inula.isElement('span')).toBe(false); + expect(Inula.isElement(111)).toBe(false); + expect(Inula.isElement(false)).toBe(false); + expect(Inula.isElement(null)).toBe(false); + expect(Inula.isElement([])).toBe(false); + expect(Inula.isElement({})).toBe(false); + expect(Inula.isElement(undefined)).toBe(false); + + const TestContext = Inula.createContext(false); + expect(Inula.isElement()).toBe(true); + expect(Inula.isElement()).toBe(true); + expect(Inula.isElement(<>)).toBe(true); + expect(Inula.isElement()).toBe(true); + }); + + it('should identify Fragment', () => { + expect(Inula.isFragment(<>)).toBe(true); + }); + + it('should identify memo component', () => { + const MemoComp = Inula.memo(App); + expect(Inula.isMemo()).toBe(true); + }); + + it('should identify forwardRef', () => { + const ForwardRefComp = Inula.forwardRef(App); + expect(Inula.isForwardRef()).toBe(true); + }); + + it('should identify lazy', () => { + const LazyComp = Inula.lazy(() => App); + expect(Inula.isLazy()).toBe(true); + }); + + it('should identify portal', () => { + const portal = Inula.createPortal(
, container); + expect(Inula.isPortal(portal)).toBe(true); + }); + + it('should identify ContextProvider', () => { + const TestContext = Inula.createContext(false); + expect(Inula.isContextProvider()).toBe(true); + expect(Inula.isContextProvider()).toBe(false); + expect(Inula.isContextConsumer()).toBe(false); + expect(Inula.isContextConsumer()).toBe(true); + }); +}); diff --git a/scripts/__tests__/jest/commonComponents.js b/scripts/__tests__/jest/commonComponents.js index 99832e5b..f9af6745 100644 --- a/scripts/__tests__/jest/commonComponents.js +++ b/scripts/__tests__/jest/commonComponents.js @@ -14,7 +14,7 @@ */ // eslint-disable-next-line @typescript-eslint/no-unused-vars -import * as Horizon from '@cloudsop/horizon/index.ts'; +import * as Inula from '../../../libs/inula/index'; import { getLogUtils } from './testUtils'; export const App = props => { diff --git a/scripts/__tests__/jest/jestEnvironment.js b/scripts/__tests__/jest/jestEnvironment.js index 92d696b2..f4ed610c 100644 --- a/scripts/__tests__/jest/jestEnvironment.js +++ b/scripts/__tests__/jest/jestEnvironment.js @@ -20,4 +20,4 @@ global.MessageChannel = function MessageChannel() { postMessage() { } }; }; -global.__VERSION__ = require('../../../libs/horizon/package.json').version; +global.__VERSION__ = require('../../../libs/inula/package.json').version; diff --git a/scripts/__tests__/jest/jestSetting.js b/scripts/__tests__/jest/jestSetting.js index 8af40471..94f4ab6c 100644 --- a/scripts/__tests__/jest/jestSetting.js +++ b/scripts/__tests__/jest/jestSetting.js @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ -import { unmountComponentAtNode } from '../../../libs/horizon/src/dom/DOMExternal'; +import { unmountComponentAtNode } from '../../../libs/inula/src/dom/DOMExternal'; import { getLogUtils } from './testUtils'; const LogUtils = getLogUtils(); diff --git a/scripts/gen3rdLib.js b/scripts/gen3rdLib.js index 1f3c51d0..10ce63cd 100644 --- a/scripts/gen3rdLib.js +++ b/scripts/gen3rdLib.js @@ -18,16 +18,16 @@ const path = require('path'); const fs = require('fs'); const childProcess = require('child_process'); -const horizonEcoPath = path.resolve(__dirname, '../../horizon-ecosystem'); -if (!fs.existsSync(horizonEcoPath)) { - throw Error('horizon-ecosystem not found, put horizon-core and horizon-ecosystem in same folder plz!'); +const inulaEcoPath = path.resolve(__dirname, '../../inula-ecosystem'); +if (!fs.existsSync(inulaEcoPath)) { + throw Error('inula-ecosystem not found, put inula-core and inula-ecosystem in same folder plz!'); } const cmd = process.argv[2]; childProcess.exec( `npm run ${cmd}`, { - cwd: horizonEcoPath, + cwd: inulaEcoPath, }, function (error, stdout) { if (error) { diff --git a/scripts/rollup/rollup.config.js b/scripts/rollup/rollup.config.js index 33ca0c34..f9e41654 100644 --- a/scripts/rollup/rollup.config.js +++ b/scripts/rollup/rollup.config.js @@ -21,13 +21,13 @@ import replace from '@rollup/plugin-replace'; import copy from './copy-plugin'; import execute from 'rollup-plugin-execute'; import {terser} from 'rollup-plugin-terser'; -import {version as horizonVersion} from '@cloudsop/horizon/package.json'; +import {version as inulaVersion} from '../../package.json'; const extensions = ['.js', '.ts']; -const libDir = path.join(__dirname, '../../libs/horizon'); +const libDir = path.join(__dirname, '../../libs/inula'); const rootDir = path.join(__dirname, '../..'); -const outDir = path.join(rootDir, 'build', 'horizon'); +const outDir = path.join(rootDir, 'build', 'inula'); if (!fs.existsSync(path.join(rootDir, 'build'))) { fs.mkdirSync(path.join(rootDir, 'build')); @@ -59,7 +59,7 @@ const getBasicPlugins = (mode) => { 'process.env.NODE_ENV': `"${mode}"`, isDev: isDev(mode).toString(), isTest: false, - __VERSION__: `"${horizonVersion}"`, + __VERSION__: `"${inulaVersion}"`, }, preventAssignment: true, }), @@ -68,7 +68,7 @@ const getBasicPlugins = (mode) => { function getOutputName(mode) { - return mode === 'production' ? `horizon.${mode}.min.js` : `horizon.${mode}.js`; + return mode === 'production' ? `inula.${mode}.min.js` : `inula.${mode}.js`; } function genConfig(mode) { @@ -84,7 +84,7 @@ function genConfig(mode) { { file: outputResolve('umd', getOutputName(mode)), sourcemap, - name: 'Horizon', + name: 'Inula', format: 'umd', }, ], diff --git a/tsconfig.json b/tsconfig.json index dbd77f67..4c6fbd07 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -35,7 +35,7 @@ "include": [ "./libs/**/src/**/*.ts", "./libs/**/*.ts", - "./libs/horizon/global.d.ts" + "./libs/inula/global.d.ts" ], "exclude": ["node_modules", "**/*.spec.ts", "dev"], "types": ["node"]