Match-id-576054d072d98d7dc612751b57b20a3f6e9ae57c

This commit is contained in:
* 2023-07-26 14:50:55 +08:00
parent b0094298dc
commit 37e36700f9
199 changed files with 1050 additions and 1050 deletions

View File

@ -1 +1 @@
{"fileVersion":"1","name":"Horizon","serviceId":"067e5bef6cd240ae9460229d107a99a6","description":"","version":"1.0.0","type":"microService","processes":{"Horizon":{"subscribes":[]}}} {"fileVersion":"1","name":"Inula","serviceId":"067e5bef6cd240ae9460229d107a99a6","description":"","version":"1.0.0","type":"microService","processes":{"Inula":{"subscribes":[]}}}

View File

@ -20,8 +20,8 @@ module.exports = {
[ [
'@babel/plugin-transform-react-jsx', '@babel/plugin-transform-react-jsx',
{ {
pragma: 'Horizon.createElement', pragma: 'Inula.createElement',
pragmaFrag: 'Horizon.Fragment', pragmaFrag: 'Inula.Fragment',
}, },
], ],
['@babel/plugin-proposal-class-properties', { loose: true }], ['@babel/plugin-proposal-class-properties', { loose: true }],

View File

@ -26,8 +26,8 @@ module.exports = {
testEnvironment: 'jest-environment-jsdom-sixteen', testEnvironment: 'jest-environment-jsdom-sixteen',
testMatch: [ testMatch: [
// '<rootDir>/scripts/__tests__/HorizonXTest/edgeCases/deepVariableObserver.test.tsx', // '<rootDir>/scripts/__tests__/InulaXTest/edgeCases/deepVariableObserver.test.tsx',
// '<rootDir>/scripts/__tests__/HorizonXTest/StateManager/StateMap.test.tsx', // '<rootDir>/scripts/__tests__/InulaXTest/StateManager/StateMap.test.tsx',
'<rootDir>/scripts/__tests__/**/*.test.js', '<rootDir>/scripts/__tests__/**/*.test.js',
'<rootDir>/scripts/__tests__/**/*.test.tsx', '<rootDir>/scripts/__tests__/**/*.test.tsx',
], ],

View File

@ -1 +0,0 @@
# `horizon`

View File

@ -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';

1
libs/inula/README.md Normal file
View File

@ -0,0 +1 @@
# `inula`

View File

@ -20,4 +20,4 @@ declare var isDev: boolean;
declare var isTest: boolean; declare var isTest: boolean;
declare const __VERSION__: string; declare const __VERSION__: string;
declare var setImmediate: Function; declare var setImmediate: Function;
declare var __HORIZON_DEV_HOOK__: any; declare var __INULA_DEV_HOOK__: any;

View File

@ -54,10 +54,10 @@ import {
isLazy, isLazy,
isMemo, isMemo,
isPortal, isPortal,
} from './src/external/HorizonIs'; } from './src/external/InulaIs';
import { createStore, useStore, clearStore } from './src/horizonx/store/StoreHandler'; import { createStore, useStore, clearStore } from './src/inulax/store/StoreHandler';
import * as reduxAdapter from './src/horizonx/adapters/redux'; import * as reduxAdapter from './src/inulax/adapters/redux';
import { watch } from './src/horizonx/proxy/watch'; import { watch } from './src/inulax/proxy/watch';
import { act } from './src/external/TestUtil'; import { act } from './src/external/TestUtil';
import { import {
@ -69,9 +69,9 @@ import {
} from './src/dom/DOMExternal'; } from './src/dom/DOMExternal';
import { syncUpdates as flushSync } from './src/renderer/TreeBuilder'; 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, Children,
createRef, createRef,
Component, Component,
@ -152,7 +152,7 @@ export {
unmountComponentAtNode, unmountComponentAtNode,
act, act,
flushSync, flushSync,
// 状态管理器HorizonX接口 // 状态管理器InulaX接口
createStore, createStore,
useStore, useStore,
clearStore, clearStore,
@ -177,4 +177,4 @@ export {
Suspense, Suspense,
}; };
export default Horizon; export default Inula;

View File

@ -16,7 +16,7 @@
'use strict'; 'use strict';
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/horizon.production.min.js'); module.exports = require('./cjs/inula.production.min.js');
} else { } else {
module.exports = require('./cjs/horizon.development.js'); module.exports = require('./cjs/inula.development.js');
} }

View File

@ -1,8 +1,8 @@
{ {
"name": "@cloudsop/horizon", "name": "inulajs",
"description": "Horizon is a JavaScript framework library.", "description": "InulaJS is a JavaScript framework library.",
"keywords": [ "keywords": [
"horizon" "inula"
], ],
"version": "0.0.52", "version": "0.0.52",
"homepage": "", "homepage": "",

View File

@ -22,9 +22,9 @@ import type { Container, Props } from './DOMOperator';
import { DomComponent, DomText, TreeRoot } from '../renderer/vnode/VNodeTags'; import { DomComponent, DomText, TreeRoot } from '../renderer/vnode/VNodeTags';
const INTERNAL_VNODE = '_horizon_VNode'; const INTERNAL_VNODE = '_inula_VNode';
const INTERNAL_PROPS = '_horizon_Props'; const INTERNAL_PROPS = '_inula_Props';
const INTERNAL_NONDELEGATEEVENTS = '_horizon_NonDelegatedEvents'; const INTERNAL_NONDELEGATEEVENTS = '_inula_NonDelegatedEvents';
// 通过 VNode 实例获取 DOM 节点 // 通过 VNode 实例获取 DOM 节点
export function getDom(vNode: VNode): Element | Text | null { export function getDom(vNode: VNode): Element | Text | null {

View File

@ -72,7 +72,7 @@ export function resetAfterSubmit(): void {
// 创建 DOM 对象 // 创建 DOM 对象
export function newDom(tagName: string, props: Props, parentNamespace: string, vNode: VNode): Element { export function newDom(tagName: string, props: Props, parentNamespace: string, vNode: VNode): Element {
// document取值于treeRoot对应的DOM的ownerDocument。 // document取值于treeRoot对应的DOM的ownerDocument。
// 解决在iframe中使用top的horizon时horizon在创建DOM时用到的document并不是iframe的document而是top中的document的问题。 // 解决在iframe中使用top的inulainula在创建DOM时用到的document并不是iframe的document而是top中的document的问题。
const rootDom = getCurrentRoot().realNode; const rootDom = getCurrentRoot().realNode;
const doc = isDocument(rootDom) ? rootDom : rootDom.ownerDocument; const doc = isDocument(rootDom) ? rootDom : rootDom.ownerDocument;

View File

@ -13,7 +13,7 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
import { allDelegatedHorizonEvents } from '../../event/EventHub'; import { allDelegatedInulaEvents } from '../../event/EventHub';
import { updateCommonProp } from './UpdateCommonProp'; import { updateCommonProp } from './UpdateCommonProp';
import { setStyles } from './StyleHandler'; import { setStyles } from './StyleHandler';
import { lazyDelegateOnRoot, listenNonDelegatedEvent } from '../../event/EventBinding'; import { lazyDelegateOnRoot, listenNonDelegatedEvent } from '../../event/EventBinding';
@ -35,7 +35,7 @@ export function setDomProps(dom: Element, props: Object, isNativeTag: boolean, i
} else if (isEventProp(propName)) { } else if (isEventProp(propName)) {
// 事件监听属性处理 // 事件监听属性处理
const currentRoot = getCurrentRoot(); const currentRoot = getCurrentRoot();
if (!allDelegatedHorizonEvents.has(propName)) { if (!allDelegatedInulaEvents.has(propName)) {
listenNonDelegatedEvent(propName, dom, propVal); listenNonDelegatedEvent(propName, dom, propVal);
} else if (currentRoot && !currentRoot.delegatedEvents.has(propName)) { } else if (currentRoot && !currentRoot.delegatedEvents.has(propName)) {
lazyDelegateOnRoot(currentRoot, propName); lazyDelegateOnRoot(currentRoot, propName);
@ -84,7 +84,7 @@ export function compareProps(oldProps: Object, newProps: Object): Object {
} else if (propName === 'autoFocus' || propName === 'children' || propName === 'dangerouslySetInnerHTML') { } else if (propName === 'autoFocus' || propName === 'children' || propName === 'dangerouslySetInnerHTML') {
continue; continue;
} else if (isEventProp(propName)) { } else if (isEventProp(propName)) {
if (!allDelegatedHorizonEvents.has(propName)) { if (!allDelegatedInulaEvents.has(propName)) {
toUpdateProps[propName] = null; toUpdateProps[propName] = null;
} }
} else { } else {
@ -155,7 +155,7 @@ export function compareProps(oldProps: Object, newProps: Object): Object {
} }
} else if (isEventProp(propName)) { } else if (isEventProp(propName)) {
const currentRoot = getCurrentRoot(); const currentRoot = getCurrentRoot();
if (!allDelegatedHorizonEvents.has(propName)) { if (!allDelegatedInulaEvents.has(propName)) {
toUpdateProps[propName] = newPropValue; toUpdateProps[propName] = newPropValue;
} else if (currentRoot && !currentRoot.delegatedEvents.has(propName)) { } else if (currentRoot && !currentRoot.delegatedEvents.has(propName)) {
lazyDelegateOnRoot(currentRoot, propName); lazyDelegateOnRoot(currentRoot, propName);

View File

@ -13,14 +13,14 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
import { HorizonDom } from './Interface'; import { InulaDom } from './Interface';
import { Props } from '../DOMOperator'; import { Props } from '../DOMOperator';
/** /**
* input textarea * input textarea
* @param doc document * @param doc document
*/ */
export function getFocusedDom(doc?: Document): HorizonDom | null { export function getFocusedDom(doc?: Document): InulaDom | null {
const currentDocument = doc ?? document; const currentDocument = doc ?? document;
return currentDocument.activeElement ?? currentDocument.body; return currentDocument.activeElement ?? currentDocument.body;

View File

@ -17,8 +17,8 @@ export interface Props {
[propName: string]: any; [propName: string]: any;
} }
export interface HorizonSelect extends HTMLSelectElement { export interface InulaSelect extends HTMLSelectElement {
_multiple?: boolean; _multiple?: boolean;
} }
export type HorizonDom = Element | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement; export type InulaDom = Element | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;

View File

@ -13,7 +13,7 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
import { HorizonSelect, Props } from '../utils/Interface'; import { InulaSelect, Props } from '../utils/Interface';
function updateMultipleValue(options, newValues) { function updateMultipleValue(options, newValues) {
const newValueSet = new Set(); 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 { return {
...properties, ...properties,
value: undefined, 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 { value, defaultValue, multiple } = props;
const oldMultiple = dom._multiple !== undefined ? dom._multiple : dom.multiple; const oldMultiple = dom._multiple !== undefined ? dom._multiple : dom.multiple;

View File

@ -14,7 +14,7 @@
*/ */
/** /**
* Horizon的输入框和文本框的change事件在原生的change事件上做了一层处理 * Inula的输入框和文本框的change事件在原生的change事件上做了一层处理
* change事件 * change事件
*/ */

View File

@ -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 { getInputPropsWithoutValue, setInitInputValue, updateInputValue } from './InputValueHandler';
import { getOptionPropsWithoutValue } from './OptionValueHandler'; import { getOptionPropsWithoutValue } from './OptionValueHandler';
import { getSelectPropsWithoutValue, updateSelectValue } from './SelectValueHandler'; import { getSelectPropsWithoutValue, updateSelectValue } from './SelectValueHandler';
import { getTextareaPropsWithoutValue, updateTextareaValue } from './TextareaValueHandler'; import { getTextareaPropsWithoutValue, updateTextareaValue } from './TextareaValueHandler';
// 获取元素除了被代理的值以外的属性 // 获取元素除了被代理的值以外的属性
function getPropsWithoutValue(type: string, dom: HorizonDom, props: Props) { function getPropsWithoutValue(type: string, dom: InulaDom, props: Props) {
switch (type) { switch (type) {
case 'input': case 'input':
return getInputPropsWithoutValue(<HTMLInputElement>dom, props); return getInputPropsWithoutValue(<HTMLInputElement>dom, props);
case 'option': case 'option':
return getOptionPropsWithoutValue(dom, props); return getOptionPropsWithoutValue(dom, props);
case 'select': case 'select':
return getSelectPropsWithoutValue(<HorizonSelect>dom, props); return getSelectPropsWithoutValue(<InulaSelect>dom, props);
case 'textarea': case 'textarea':
return getTextareaPropsWithoutValue(<HTMLTextAreaElement>dom, props); return getTextareaPropsWithoutValue(<HTMLTextAreaElement>dom, props);
default: 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) { switch (type) {
case 'input': case 'input':
setInitInputValue(<HTMLInputElement>dom, props); setInitInputValue(<HTMLInputElement>dom, props);
break; break;
case 'select': case 'select':
updateSelectValue(<HorizonSelect>dom, props, true); updateSelectValue(<InulaSelect>dom, props, true);
break; break;
case 'textarea': case 'textarea':
updateTextareaValue(<HTMLTextAreaElement>dom, props, true); updateTextareaValue(<HTMLTextAreaElement>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) { switch (type) {
case 'input': case 'input':
updateInputValue(<HTMLInputElement>dom, props); updateInputValue(<HTMLInputElement>dom, props);
break; break;
case 'select': case 'select':
updateSelectValue(<HorizonSelect>dom, props); updateSelectValue(<InulaSelect>dom, props);
break; break;
case 'textarea': case 'textarea':
updateTextareaValue(<HTMLTextAreaElement>dom, props); updateTextareaValue(<HTMLTextAreaElement>dom, props);

View File

@ -16,11 +16,11 @@
/** /**
* *
*/ */
import { allDelegatedHorizonEvents, simulatedDelegatedEvents } from './EventHub'; import { allDelegatedInulaEvents, simulatedDelegatedEvents } from './EventHub';
import { isDocument } from '../dom/utils/Common'; import { isDocument } from '../dom/utils/Common';
import { getNearestVNode, getNonDelegatedListenerMap } from '../dom/DOMInternalKeys'; import { getNearestVNode, getNonDelegatedListenerMap } from '../dom/DOMInternalKeys';
import { asyncUpdates, runDiscreteUpdates } from '../renderer/TreeBuilder'; import { asyncUpdates, runDiscreteUpdates } from '../renderer/TreeBuilder';
import { handleEventMain } from './HorizonEventMain'; import { handleEventMain } from './InulaEventMain';
import { decorateNativeEvent } from './EventWrapper'; import { decorateNativeEvent } from './EventWrapper';
import { VNode } from '../renderer/vnode/VNode'; import { VNode } from '../renderer/vnode/VNode';
@ -55,11 +55,11 @@ function listenToNativeEvent(nativeEvtName: string, delegatedElement: Element, i
} }
// 是否捕获事件 // 是否捕获事件
function isCaptureEvent(horizonEventName) { function isCaptureEvent(inulaEventName) {
if (horizonEventName === 'onLostPointerCapture' || horizonEventName === 'onGotPointerCapture') { if (inulaEventName === 'onLostPointerCapture' || inulaEventName === 'onGotPointerCapture') {
return false; 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); currentRoot.delegatedEvents.add(eventName);
const isCapture = isCaptureEvent(eventName); const isCapture = isCaptureEvent(eventName);
const nativeEvents = allDelegatedHorizonEvents.get(eventName); const nativeEvents = allDelegatedInulaEvents.get(eventName);
nativeEvents.forEach(nativeEvent => { nativeEvents.forEach(nativeEvent => {
const nativeFullName = isCapture ? nativeEvent + 'capture' : nativeEvent; const nativeFullName = isCapture ? nativeEvent + 'capture' : nativeEvent;
@ -89,13 +89,13 @@ export function listenSimulatedDelegatedEvents(root: VNode) {
} }
} }
// 通过horizon事件名获取到native事件名 // 通过inula事件名获取到native事件名
function getNativeEvtName(horizonEventName, capture) { function getNativeEvtName(inulaEventName, capture) {
let nativeName; let nativeName;
if (capture) { if (capture) {
nativeName = horizonEventName.slice(2, -7); nativeName = inulaEventName.slice(2, -7);
} else { } else {
nativeName = horizonEventName.slice(2); nativeName = inulaEventName.slice(2);
} }
if (!nativeName) { if (!nativeName) {
return ''; return '';
@ -104,9 +104,9 @@ function getNativeEvtName(horizonEventName, capture) {
} }
// 封装监听函数 // 封装监听函数
function getWrapperListener(horizonEventName, nativeEvtName, targetElement, listener) { function getWrapperListener(inulaEventName, nativeEvtName, targetElement, listener) {
return event => { return event => {
const customEvent = decorateNativeEvent(horizonEventName, nativeEvtName, event); const customEvent = decorateNativeEvent(inulaEventName, nativeEvtName, event);
asyncUpdates(() => { asyncUpdates(() => {
listener(customEvent); listener(customEvent);
}); });
@ -114,16 +114,16 @@ function getWrapperListener(horizonEventName, nativeEvtName, targetElement, list
} }
// 非委托事件单独监听到各自dom节点 // 非委托事件单独监听到各自dom节点
export function listenNonDelegatedEvent(horizonEventName: string, domElement: Element, listener): void { export function listenNonDelegatedEvent(inulaEventName: string, domElement: Element, listener): void {
const isCapture = isCaptureEvent(horizonEventName); const isCapture = isCaptureEvent(inulaEventName);
const nativeEvtName = getNativeEvtName(horizonEventName, isCapture); const nativeEvtName = getNativeEvtName(inulaEventName, isCapture);
// 先判断是否存在老的监听事件,若存在则移除 // 先判断是否存在老的监听事件,若存在则移除
const nonDelegatedListenerMap = getNonDelegatedListenerMap(domElement); const nonDelegatedListenerMap = getNonDelegatedListenerMap(domElement);
const currentListener = nonDelegatedListenerMap.get(horizonEventName); const currentListener = nonDelegatedListenerMap.get(inulaEventName);
if (currentListener) { if (currentListener) {
domElement.removeEventListener(nativeEvtName, currentListener); domElement.removeEventListener(nativeEvtName, currentListener);
nonDelegatedListenerMap.delete(horizonEventName); nonDelegatedListenerMap.delete(inulaEventName);
} }
if (typeof listener !== 'function') { if (typeof listener !== 'function') {
@ -131,8 +131,8 @@ export function listenNonDelegatedEvent(horizonEventName: string, domElement: El
} }
// 为了和委托事件对外行为一致将事件对象封装成CustomBaseEvent // 为了和委托事件对外行为一致将事件对象封装成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); domElement.addEventListener(nativeEvtName, wrapperListener, isCapture);
} }

View File

@ -13,16 +13,16 @@
* See the Mulan PSL v2 for more details. * See the Mulan PSL v2 for more details.
*/ */
// 需要委托的horizon事件和原生事件对应关系 // 需要委托的inula事件和原生事件对应关系
export const allDelegatedHorizonEvents = new Map(); export const allDelegatedInulaEvents = new Map();
// 模拟委托事件,不冒泡事件需要利用其他事件来触发冒泡过程 // 模拟委托事件,不冒泡事件需要利用其他事件来触发冒泡过程
export const simulatedDelegatedEvents = ['onMouseEnter', 'onMouseLeave']; export const simulatedDelegatedEvents = ['onMouseEnter', 'onMouseLeave'];
// 所有委托的原生事件集合 // 所有委托的原生事件集合
export const allDelegatedNativeEvents = new Set(); export const allDelegatedNativeEvents = new Set();
// Horizon事件和原生事件对应关系 // Inula事件和原生事件对应关系
export const horizonEventToNativeMap = new Map([ export const inulaEventToNativeMap = new Map([
['onKeyPress', ['keypress']], ['onKeyPress', ['keypress']],
['onTextInput', ['textInput']], ['onTextInput', ['textInput']],
['onClick', ['click']], ['onClick', ['click']],
@ -60,7 +60,7 @@ export const horizonEventToNativeMap = new Map([
['onAnimationStart', ['animationstart']], ['onAnimationStart', ['animationstart']],
['onTransitionEnd', ['transitionend']], ['onTransitionEnd', ['transitionend']],
]); ]);
export const NativeEventToHorizonMap = { export const NativeEventToInulaMap = {
click: 'click', click: 'click',
wheel: 'wheel', wheel: 'wheel',
dblclick: 'doubleClick', dblclick: 'doubleClick',
@ -99,17 +99,17 @@ export const EVENT_TYPE_BUBBLE = 'Bubble';
export const EVENT_TYPE_CAPTURE = 'Capture'; export const EVENT_TYPE_CAPTURE = 'Capture';
export const EVENT_TYPE_ALL = 'All'; export const EVENT_TYPE_ALL = 'All';
horizonEventToNativeMap.forEach((dependencies, horizonEvent) => { inulaEventToNativeMap.forEach((dependencies, inulaEvent) => {
allDelegatedHorizonEvents.set(horizonEvent, dependencies); allDelegatedInulaEvents.set(inulaEvent, dependencies);
allDelegatedHorizonEvents.set(horizonEvent + 'Capture', dependencies); allDelegatedInulaEvents.set(inulaEvent + 'Capture', dependencies);
dependencies.forEach(d => { dependencies.forEach(d => {
allDelegatedNativeEvents.add(d); allDelegatedNativeEvents.add(d);
}); });
}); });
export function transformToHorizonEvent(nativeEvtName: string) { export function transformToInulaEvent(nativeEvtName: string) {
const name = NativeEventToHorizonMap[nativeEvtName]; const name = NativeEventToInulaMap[nativeEvtName];
// 例dragEnd -> onDragEnd // 例dragEnd -> onDragEnd
return !name ? '' : `on${name[0].toUpperCase()}${name.slice(1)}`; return !name ? '' : `on${name[0].toUpperCase()}${name.slice(1)}`;
} }

View File

@ -24,8 +24,8 @@ import {
EVENT_TYPE_ALL, EVENT_TYPE_ALL,
EVENT_TYPE_BUBBLE, EVENT_TYPE_BUBBLE,
EVENT_TYPE_CAPTURE, EVENT_TYPE_CAPTURE,
horizonEventToNativeMap, inulaEventToNativeMap,
transformToHorizonEvent, transformToInulaEvent,
} from './EventHub'; } from './EventHub';
import { getDomTag } from '../dom/utils/Common'; import { getDomTag } from '../dom/utils/Common';
import { updateInputHandlerIfChanged } from '../dom/valueHandler/ValueChangeHandler'; import { updateInputHandlerIfChanged } from '../dom/valueHandler/ValueChangeHandler';
@ -94,9 +94,9 @@ function getCommonListeners(
target: null | EventTarget, target: null | EventTarget,
isCapture: boolean isCapture: boolean
): ListenerUnitList { ): ListenerUnitList {
const horizonEvtName = transformToHorizonEvent(nativeEvtName); const inulaEvtName = transformToInulaEvent(nativeEvtName);
if (!horizonEvtName) { if (!inulaEvtName) {
return []; return [];
} }
@ -113,8 +113,8 @@ function getCommonListeners(
nativeEvtName = 'blur'; nativeEvtName = 'blur';
} }
const horizonEvent = decorateNativeEvent(horizonEvtName, nativeEvtName, nativeEvent); const inulaEvent = decorateNativeEvent(inulaEvtName, nativeEvtName, nativeEvent);
return getListenersFromTree(vNode, horizonEvtName, horizonEvent, isCapture ? EVENT_TYPE_CAPTURE : EVENT_TYPE_BUBBLE); return getListenersFromTree(vNode, inulaEvtName, inulaEvent, isCapture ? EVENT_TYPE_CAPTURE : EVENT_TYPE_BUBBLE);
} }
// 按顺序执行事件队列 // 按顺序执行事件队列
@ -132,8 +132,8 @@ function processListeners(listenerList: ListenerUnitList): void {
}); });
} }
// 触发可以被执行的horizon事件监听 // 触发可以被执行的inula事件监听
function triggerHorizonEvents( function triggerInulaEvents(
nativeEvtName: string, nativeEvtName: string,
isCapture: boolean, isCapture: boolean,
nativeEvent: AnyNativeEvent, nativeEvent: AnyNativeEvent,
@ -145,7 +145,7 @@ function triggerHorizonEvents(
const listenerList: ListenerUnitList = getCommonListeners(nativeEvtName, vNode, nativeEvent, target, isCapture); const listenerList: ListenerUnitList = getCommonListeners(nativeEvtName, vNode, nativeEvent, target, isCapture);
let mouseEnterListeners: ListenerUnitList = []; let mouseEnterListeners: ListenerUnitList = [];
if (horizonEventToNativeMap.get('onMouseEnter')!.includes(nativeEvtName)) { if (inulaEventToNativeMap.get('onMouseEnter')!.includes(nativeEvtName)) {
mouseEnterListeners = getMouseEnterListeners( mouseEnterListeners = getMouseEnterListeners(
nativeEvtName, nativeEvtName,
vNode, vNode,
@ -156,7 +156,7 @@ function triggerHorizonEvents(
let changeEvents: ListenerUnitList = []; let changeEvents: ListenerUnitList = [];
// 触发特殊handler委托事件 // 触发特殊handler委托事件
if (!isCapture && horizonEventToNativeMap.get('onChange')!.includes(nativeEvtName)) { if (!isCapture && inulaEventToNativeMap.get('onChange')!.includes(nativeEvtName)) {
changeEvents = getChangeListeners(nativeEvtName, nativeEvent, vNode, target); changeEvents = getChangeListeners(nativeEvtName, nativeEvent, vNode, target);
} }
@ -185,14 +185,14 @@ export function handleEventMain(
// 有事件正在执行,同步执行事件 // 有事件正在执行,同步执行事件
if (isInEventsExecution) { if (isInEventsExecution) {
triggerHorizonEvents(nativeEvtName, isCapture, nativeEvent, startVNode); triggerInulaEvents(nativeEvtName, isCapture, nativeEvent, startVNode);
return; return;
} }
// 没有事件在执行,经过调度再执行事件 // 没有事件在执行,经过调度再执行事件
isInEventsExecution = true; isInEventsExecution = true;
try { try {
asyncUpdates(() => triggerHorizonEvents(nativeEvtName, isCapture, nativeEvent, startVNode)); asyncUpdates(() => triggerInulaEvents(nativeEvtName, isCapture, nativeEvent, startVNode));
} finally { } finally {
isInEventsExecution = false; isInEventsExecution = false;
if (shouldControlValue()) { if (shouldControlValue()) {

View File

@ -40,11 +40,11 @@ function getListenerFromVNode(vNode: VNode, eventName: string): Function | null
// 获取监听事件 // 获取监听事件
export function getListenersFromTree( export function getListenersFromTree(
targetVNode: VNode | null, targetVNode: VNode | null,
horizonEvtName: string | null, inulaEvtName: string | null,
nativeEvent: WrappedEvent, nativeEvent: WrappedEvent,
eventType: string eventType: string
): ListenerUnitList { ): ListenerUnitList {
if (!horizonEvtName) { if (!inulaEvtName) {
return []; return [];
} }
@ -57,7 +57,7 @@ export function getListenersFromTree(
const { realNode, tag } = vNode; const { realNode, tag } = vNode;
if (tag === DomComponent && realNode !== null) { if (tag === DomComponent && realNode !== null) {
if (eventType === EVENT_TYPE_ALL || eventType === EVENT_TYPE_CAPTURE) { 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); const captureListener = getListenerFromVNode(vNode, captureName);
if (captureListener) { if (captureListener) {
listeners.unshift({ listeners.unshift({
@ -70,7 +70,7 @@ export function getListenersFromTree(
} }
if (eventType === EVENT_TYPE_ALL || eventType === EVENT_TYPE_BUBBLE) { if (eventType === EVENT_TYPE_ALL || eventType === EVENT_TYPE_BUBBLE) {
const bubbleListener = getListenerFromVNode(vNode, horizonEvtName); const bubbleListener = getListenerFromVNode(vNode, inulaEvtName);
if (bubbleListener) { if (bubbleListener) {
listeners.push({ listeners.push({
vNode, vNode,

View File

@ -18,13 +18,13 @@ import { WrappedEvent } from './EventWrapper';
export type AnyNativeEvent = KeyboardEvent | MouseEvent | TouchEvent | UIEvent | Event; export type AnyNativeEvent = KeyboardEvent | MouseEvent | TouchEvent | UIEvent | Event;
export interface HorizonEventListener { export interface InulaEventListener {
(event: WrappedEvent): void; (event: WrappedEvent): void;
} }
export type ListenerUnit = { export type ListenerUnit = {
vNode: null | VNode; vNode: null | VNode;
listener: HorizonEventListener; listener: InulaEventListener;
currentTarget: EventTarget; currentTarget: EventTarget;
event: WrappedEvent; event: WrappedEvent;
}; };

View File

@ -88,7 +88,7 @@ function mapChildrenToArray(children: any, arr: Array<any>, prefix: string, call
processArrayChildren(children, arr, prefix, callback); processArrayChildren(children, arr, prefix, callback);
return; return;
} }
throw new Error('Object is invalid as a Horizon child. '); throw new Error('Object is invalid as a Inula child. ');
// No Default // No Default
} }
} }
@ -119,7 +119,7 @@ const Children = {
return n; return n;
}, },
only: children => { only: children => {
throwIfTrue(!isValidElement(children), 'Horizon.Children.only function received invalid element.'); throwIfTrue(!isValidElement(children), 'Inula.Children.only function received invalid element.');
return children; return children;
}, },
toArray: children => { toArray: children => {

View File

@ -128,7 +128,7 @@ export const helper = {
}; };
export function injectUpdater() { export function injectUpdater() {
const hook = window.__HORIZON_DEV_HOOK__; const hook = window.__INULA_DEV_HOOK__;
if (hook) { if (hook) {
hook.init(helper); hook.init(helper);
} }

View File

@ -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 = {}; const res = {};
let found = false; let found = false;
keys.forEach(key => { keys.forEach(key => {

View File

@ -13,6 +13,6 @@
* See the Mulan PSL v2 for more details. * 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'; export const RAW_VALUE = '_rawValue';

View File

@ -126,13 +126,13 @@ export function createStore(reducer: Reducer, preloadedState?: any, enhancers?):
replaceReducer: newReducer => { replaceReducer: newReducer => {
reducer = newReducer; reducer = newReducer;
}, },
_horizonXstore: store, _inulaXstore: store,
dispatch: store.$a.dispatch, dispatch: store.$a.dispatch,
}; };
enhancers && enhancers(result); enhancers && enhancers(result);
result.dispatch({ type: 'HorizonX' }); result.dispatch({ type: 'InulaX' });
store.reduxHandler = result; 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) { export function batch(fn: () => void) {
fn(); fn();
} }

View File

@ -30,7 +30,7 @@ export function Provider({
context: Context; context: Context;
children?: any[]; 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); return createElement(Context.Provider, { value: store }, children);
} }

View File

@ -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';

View File

@ -7,7 +7,7 @@ const sessionId = Date.now();
// this function is used to detect devtool connection // this function is used to detect devtool connection
export function isPanelActive() { export function isPanelActive() {
return window['__HORIZON_DEV_HOOK__']; return window['__INULA_DEV_HOOK__'];
} }
// safely serializes variables containing values wrapped in Proxy object // safely serializes variables containing values wrapped in Proxy object
@ -44,7 +44,7 @@ function makeProxySnapshot(obj, visited: any[] = []) {
if (type === 'vnode') { if (type === 'vnode') {
return { return {
_type: 'VNode', _type: 'VNode',
id: window['__HORIZON_DEV_HOOK__'].getVnodeId(obj), id: window['__INULA_DEV_HOOK__'].getVnodeId(obj),
tag: obj.tag, tag: obj.tag,
}; };
} }
@ -114,39 +114,39 @@ function makeStoreSnapshot({ type, data }) {
} }
export const devtools = { export const devtools = {
// returns vNode id from horizon devtools // returns vNode id from inula devtools
getVNodeId: vNode => { getVNodeId: vNode => {
if (!isPanelActive()) { if (!isPanelActive()) {
return null; return null;
} }
window['__HORIZON_DEV_HOOK__'].send(); // update list first window['__INULA_DEV_HOOK__'].send(); // update list first
return window['__HORIZON_DEV_HOOK__'].getVnodeId(vNode); return window['__INULA_DEV_HOOK__'].getVnodeId(vNode);
}, },
// sends horizonx devtool message to extension // sends inulax devtool message to extension
emit: (type, data) => { emit: (type, data) => {
if (!isPanelActive()) { if (!isPanelActive()) {
return; return;
} }
window.postMessage({ window.postMessage({
type: 'HORIZON_DEV_TOOLS', type: 'INULA_DEV_TOOLS',
payload: makeStoreSnapshot({ type, data }), payload: makeStoreSnapshot({ type, data }),
from: 'dev tool hook', 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() { function getAffectedComponents() {
const allStores = getAllStores(); const allStores = getAllStores();
const keys = Object.keys(allStores); const keys = Object.keys(allStores);
const res = {}; const res = {};
keys.forEach(key => { keys.forEach(key => {
if (!allStores[key].$config.state._horizonObserver.keyVNodes) { if (!allStores[key].$config.state._inulaObserver.keyVNodes) {
res[key] = []; res[key] = [];
return; return;
} }
const subRes = new Set(); 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) { while (process.length) {
const pivot = process.shift() as { tag: 'string' }; const pivot = process.shift() as { tag: 'string' };
if (pivot.tag) subRes.add(pivot); if (pivot.tag) subRes.add(pivot);
@ -158,7 +158,7 @@ function getAffectedComponents() {
.toString() .toString()
.replace(/\{.*\}/, '{...}') .replace(/\{.*\}/, '{...}')
.replace('function ', ''), .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 // listens to messages from background
window.addEventListener('message', (messageEvent?) => { 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 // get observed components
setTimeout(() => { setTimeout(() => {
window.postMessage({ window.postMessage({
type: 'HORIZON_DEV_TOOLS', type: 'INULA_DEV_TOOLS',
payload: { type: OBSERVED_COMPONENTS, data: getAffectedComponents() }, payload: { type: OBSERVED_COMPONENTS, data: getAffectedComponents() },
from: 'dev tool hook', from: 'dev tool hook',
}, ''); }, '');
@ -180,7 +180,7 @@ window.addEventListener('message', (messageEvent?) => {
} }
// executes store action // 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 data = messageEvent.data.payload.data;
const store = getStore(data.storeId); const store = getStore(data.storeId);
if (!store?.[data.action]) return; if (!store?.[data.action]) return;
@ -191,7 +191,7 @@ window.addEventListener('message', (messageEvent?) => {
} }
// queues store action // 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 data = messageEvent.data.payload.data;
const store = getStore(data.storeId); const store = getStore(data.storeId);
if (!store?.[data.action]) return; if (!store?.[data.action]) return;
@ -202,7 +202,7 @@ window.addEventListener('message', (messageEvent?) => {
} }
// queues change store state // 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 data = messageEvent.data.payload;
const store = getStore(data.storeId); const store = getStore(data.storeId);
if (!store) return; if (!store) return;

View File

@ -57,7 +57,7 @@ export function createArrayProxy(rawObj: any[], listener: { current: (...args) =
let listeners = [] as ((...args) => void)[]; let listeners = [] as ((...args) => void)[];
function objectGet(rawObj: object, key: string | symbol, receiver: any, singleLevel = false): any { 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) { if (key === OBSERVER_KEY) {
return undefined; return undefined;
} }

View File

@ -47,7 +47,7 @@ export function createObjectProxy<T extends object>(
let listeners = [] as ((...args) => void)[]; let listeners = [] as ((...args) => void)[];
function get(rawObj: object, key: string | symbol, receiver: any): any { 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) { if (key === OBSERVER_KEY) {
return undefined; return undefined;
} }

View File

@ -355,10 +355,10 @@ function renderFromRoot(treeRoot) {
submitToRender(treeRoot); submitToRender(treeRoot);
popCurrentRoot(); popCurrentRoot();
if (window.__HORIZON_DEV_HOOK__) { if (window.__INULA_DEV_HOOK__) {
const hook = window.__HORIZON_DEV_HOOK__; const hook = window.__INULA_DEV_HOOK__;
// injector.js 可能在 Horizon 代码之后加载,此时无 __HORIZON_DEV_HOOK__ 全局变量 // injector.js 可能在 Inula 代码之后加载,此时无 __INULA_DEV_HOOK__ 全局变量
// Horizon 代码初次加载时不会初始化 helper // Inula 代码初次加载时不会初始化 helper
if (!hook.isInit) { if (!hook.isInit) {
injectUpdater(); injectUpdater();
} }
@ -398,7 +398,7 @@ export function launchUpdateFromVNode(vNode: VNode) {
) { ) {
// 不是渲染阶段触发 // 不是渲染阶段触发
// 业务直接调用Horizon.render的时候会进入这个分支同步渲染。 // 业务直接调用Inula.render的时候会进入这个分支同步渲染。
// 不能改成下面的异步,否则会有时序问题,因为业务可能会依赖这个渲染的完成。 // 不能改成下面的异步,否则会有时序问题,因为业务可能会依赖这个渲染的完成。
renderFromRoot(treeRoot); renderFromRoot(treeRoot);
} else { } else {
@ -411,7 +411,7 @@ export function launchUpdateFromVNode(vNode: VNode) {
} }
} }
// ============================== HorizonDOM使用 ============================== // ============================== InulaDOM使用 ==============================
export function runDiscreteUpdates() { export function runDiscreteUpdates() {
if (checkMode(ByAsync) || checkMode(InRender)) { if (checkMode(ByAsync) || checkMode(InRender)) {
// 已经渲染不能再同步执行待工作的任务有可能是被生命周期或effect触发的事件导致的如el.focus() // 已经渲染不能再同步执行待工作的任务有可能是被生命周期或effect触发的事件导致的如el.focus()

View File

@ -35,8 +35,8 @@ export enum UpdateState {
export function newUpdate(): Update { export function newUpdate(): Update {
return { return {
type: UpdateState.Update, // 更新的类型 type: UpdateState.Update, // 更新的类型
content: null, // ClassComponent的content是setState第一个参数TreeRoot的content是HorizonDOM.render的第一个参数 content: null, // ClassComponent的content是setState第一个参数TreeRoot的content是InulaDOM.render的第一个参数
callback: null, // setState的第二个参数HorizonDOM.render的第三个参数 callback: null, // setState的第二个参数InulaDOM.render的第三个参数
}; };
} }

View File

@ -21,7 +21,7 @@ import { FlagUtils } from '../vnode/VNodeFlags';
import { onlyUpdateChildVNodes } from '../vnode/VNodeCreator'; import { onlyUpdateChildVNodes } from '../vnode/VNodeCreator';
import componentRenders from './index'; import componentRenders from './index';
import { setProcessingVNode } from '../GlobalVar'; import { setProcessingVNode } from '../GlobalVar';
import { clearVNodeObservers } from '../../horizonx/store/StoreHandler'; import { clearVNodeObservers } from '../../inulax/store/StoreHandler';
import { pushCurrentRoot } from '../RootStack'; import { pushCurrentRoot } from '../RootStack';
// 复用vNode时也需对树的上下文值处理如contextportal, namespaceContext // 复用vNode时也需对树的上下文值处理如contextportal, namespaceContext

Some files were not shown because too many files have changed in this diff Show More