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',
{
pragma: 'Horizon.createElement',
pragmaFrag: 'Horizon.Fragment',
pragma: 'Inula.createElement',
pragmaFrag: 'Inula.Fragment',
},
],
['@babel/plugin-proposal-class-properties', { loose: true }],

View File

@ -26,8 +26,8 @@ module.exports = {
testEnvironment: 'jest-environment-jsdom-sixteen',
testMatch: [
// '<rootDir>/scripts/__tests__/HorizonXTest/edgeCases/deepVariableObserver.test.tsx',
// '<rootDir>/scripts/__tests__/HorizonXTest/StateManager/StateMap.test.tsx',
// '<rootDir>/scripts/__tests__/InulaXTest/edgeCases/deepVariableObserver.test.tsx',
// '<rootDir>/scripts/__tests__/InulaXTest/StateManager/StateMap.test.tsx',
'<rootDir>/scripts/__tests__/**/*.test.js',
'<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 const __VERSION__: string;
declare var setImmediate: Function;
declare var __HORIZON_DEV_HOOK__: any;
declare var __INULA_DEV_HOOK__: any;

View File

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

View File

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

View File

@ -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": "",

View File

@ -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 {

View File

@ -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的inulainula在创建DOM时用到的document并不是iframe的document而是top中的document的问题。
const rootDom = getCurrentRoot().realNode;
const doc = isDocument(rootDom) ? rootDom : rootDom.ownerDocument;

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@
*/
/**
* Horizon的输入框和文本框的change事件在原生的change事件上做了一层处理
* Inula的输入框和文本框的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 { 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(<HTMLInputElement>dom, props);
case 'option':
return getOptionPropsWithoutValue(dom, props);
case 'select':
return getSelectPropsWithoutValue(<HorizonSelect>dom, props);
return getSelectPropsWithoutValue(<InulaSelect>dom, props);
case 'textarea':
return getTextareaPropsWithoutValue(<HTMLTextAreaElement>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(<HTMLInputElement>dom, props);
break;
case 'select':
updateSelectValue(<HorizonSelect>dom, props, true);
updateSelectValue(<InulaSelect>dom, props, true);
break;
case 'textarea':
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) {
case 'input':
updateInputValue(<HTMLInputElement>dom, props);
break;
case 'select':
updateSelectValue(<HorizonSelect>dom, props);
updateSelectValue(<InulaSelect>dom, props);
break;
case 'textarea':
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 { 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);
}

View File

@ -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)}`;
}

View File

@ -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()) {

View File

@ -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,

View File

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

View File

@ -88,7 +88,7 @@ function mapChildrenToArray(children: any, arr: Array<any>, 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 => {

View File

@ -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);
}

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

View File

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

View File

@ -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();
}

View File

@ -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);
}

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

View File

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

View File

@ -47,7 +47,7 @@ export function createObjectProxy<T extends object>(
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;
}

View File

@ -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()

View File

@ -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的第三个参数
};
}

View File

@ -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时也需对树的上下文值处理如contextportal, namespaceContext

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