mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-01-18 16:54:00 +08:00
refactor runtime variables to sunmao
This commit is contained in:
parent
09211db07b
commit
bfabfdeea0
@ -1,5 +1,5 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { GridCallbacks, DIALOG_CONTAINER_ID, initMetaUI } from '@sunmao-ui/runtime';
|
||||
import { GridCallbacks, DIALOG_CONTAINER_ID, initSunmaoUI } from '@sunmao-ui/runtime';
|
||||
import produce from 'immer';
|
||||
import { Box, Tabs, TabList, Tab, TabPanels, TabPanel, Flex } from '@chakra-ui/react';
|
||||
import { StructureTree } from './StructureTree';
|
||||
@ -19,7 +19,7 @@ import { ComponentWrapper } from './ComponentWrapper';
|
||||
import { StateEditor, SchemaEditor } from './CodeEditor';
|
||||
import { AppModelManager } from '../operations/AppModelManager';
|
||||
|
||||
type ReturnOfInit = ReturnType<typeof initMetaUI>;
|
||||
type ReturnOfInit = ReturnType<typeof initSunmaoUI>;
|
||||
|
||||
type Props = {
|
||||
App: ReturnOfInit['App'];
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ChakraProvider } from '@chakra-ui/react';
|
||||
import { Application } from '@sunmao-ui/core';
|
||||
import { initMetaUI } from '@sunmao-ui/runtime';
|
||||
import { initSunmaoUI } from '@sunmao-ui/runtime';
|
||||
import { Registry } from '@sunmao-ui/runtime/lib/services/registry';
|
||||
import { StrictMode } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
@ -21,12 +21,12 @@ export default function renderApp(
|
||||
app: Application = DefaultAppSchema,
|
||||
options: Options = {}
|
||||
) {
|
||||
const metaUI = initMetaUI();
|
||||
const ui = initSunmaoUI();
|
||||
|
||||
const App = metaUI.App;
|
||||
const registry = metaUI.registry;
|
||||
const apiService = metaUI.apiService;
|
||||
const stateStore = metaUI.stateManager.store;
|
||||
const App = ui.App;
|
||||
const registry = ui.registry;
|
||||
const apiService = ui.apiService;
|
||||
const stateStore = ui.stateManager.store;
|
||||
const appModelManager = new AppModelManager(app, registry);
|
||||
|
||||
const { components = [], traits = [], modules = [] } = options;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Flex, Box, ChakraProvider, Button } from '@chakra-ui/react';
|
||||
import { Application } from '@sunmao-ui/core';
|
||||
import { initMetaUI } from '@sunmao-ui/runtime';
|
||||
import { initSunmaoUI } from '@sunmao-ui/runtime';
|
||||
import { Registry } from '@sunmao-ui/runtime/lib/services/registry';
|
||||
import { StrictMode, useMemo, useState } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
@ -25,11 +25,11 @@ const Playground: React.FC<{ examples: Example[] }> = ({ examples }) => {
|
||||
if (!example) {
|
||||
return {};
|
||||
}
|
||||
const metaUI = initMetaUI();
|
||||
const App = metaUI.App;
|
||||
const registry = metaUI.registry;
|
||||
const apiService = metaUI.apiService;
|
||||
const stateStore = metaUI.stateManager.store;
|
||||
const ui = initSunmaoUI();
|
||||
const App = ui.App;
|
||||
const registry = ui.registry;
|
||||
const apiService = ui.apiService;
|
||||
const stateStore = ui.stateManager.store;
|
||||
|
||||
const { app, modules = [] } = example.value;
|
||||
modules.forEach(m => {
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script type="module">
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { initMetaUI } from './src';
|
||||
import { initSunmaoUI } from './src';
|
||||
import { ChakraProvider } from '@chakra-ui/react';
|
||||
import examples from '@example.json';
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
const rootEl = document.querySelector('#root');
|
||||
const render = example => {
|
||||
ReactDOM.unmountComponentAtNode(rootEl);
|
||||
const { App, registry } = initMetaUI();
|
||||
const { App, registry } = initSunmaoUI();
|
||||
const { app, modules = [] } = example.value;
|
||||
modules.forEach(m => {
|
||||
registry.registerModule(m);
|
||||
|
@ -3,11 +3,11 @@ import { createApplication } from '@sunmao-ui/core';
|
||||
import { initStateAndMethod } from './utils/initStateAndMethod';
|
||||
import { ImplWrapper } from './services/ImplWrapper';
|
||||
import { resolveAppComponents } from './services/resolveAppComponents';
|
||||
import { AppProps, MetaUIServices } from './types/RuntimeSchema';
|
||||
import { AppProps, UIServices } from './types/RuntimeSchema';
|
||||
import { DebugEvent, DebugStore } from './services/DebugComponents';
|
||||
|
||||
// inject modules to App
|
||||
export function genApp(services: MetaUIServices) {
|
||||
export function genApp(services: UIServices) {
|
||||
return (props: Omit<AppProps, 'services'>) => {
|
||||
return <App {...props} services={services} />;
|
||||
};
|
||||
|
@ -3,7 +3,7 @@ import React, { useEffect, useMemo } from 'react';
|
||||
import { get } from 'lodash-es';
|
||||
import { useDeepCompareMemo } from 'use-deep-compare';
|
||||
import { RuntimeApplication } from '@sunmao-ui/core';
|
||||
import { MetaUIServices, RuntimeModuleSchema } from '../../types/RuntimeSchema';
|
||||
import { UIServices, RuntimeModuleSchema } from '../../types/RuntimeSchema';
|
||||
import { EventHandlerSchema } from '../../types/TraitPropertiesSchema';
|
||||
import { resolveAppComponents } from '../../services/resolveAppComponents';
|
||||
import { ImplWrapper } from '../../services/ImplWrapper';
|
||||
@ -12,7 +12,7 @@ import { parseTypeComponents } from '../../utils/parseType';
|
||||
|
||||
type Props = Static<typeof RuntimeModuleSchema> & {
|
||||
evalScope?: Record<string, any>;
|
||||
services: MetaUIServices;
|
||||
services: UIServices;
|
||||
app?: RuntimeApplication;
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { Static } from '@sinclair/typebox';
|
||||
import { ColumnSchema } from './TableTypes';
|
||||
import { Button, Link, Td, Text } from '@chakra-ui/react';
|
||||
import { LIST_ITEM_EXP, LIST_ITEM_INDEX_EXP } from '../../../constants';
|
||||
import { MetaUIServices } from 'src/types/RuntimeSchema';
|
||||
import { UIServices } from 'src/types/RuntimeSchema';
|
||||
import { ModuleRenderer } from '../../_internal/ModuleRenderer';
|
||||
|
||||
export const TableTd: React.FC<{
|
||||
@ -11,7 +11,7 @@ export const TableTd: React.FC<{
|
||||
item: any;
|
||||
column: Static<typeof ColumnSchema>;
|
||||
onClickItem: () => void;
|
||||
services: MetaUIServices;
|
||||
services: UIServices;
|
||||
app?: RuntimeApplication;
|
||||
}> = props => {
|
||||
const { item, index, column, onClickItem, services, app } = props;
|
||||
|
@ -1,5 +1,5 @@
|
||||
export const LIST_ITEM_EXP = '$listItem';
|
||||
export const LIST_ITEM_INDEX_EXP = '$i';
|
||||
export const GRID_HEIGHT = 40;
|
||||
export const DIALOG_CONTAINER_ID = 'meta-ui-dialog-container';
|
||||
export const DIALOG_CONTAINER_ID = 'sunmao-ui-dialog-container';
|
||||
export const DROP_EXAMPLE_SIZE_PREFIX = 'exampleSize: ';
|
||||
|
@ -5,7 +5,7 @@ import { initApiService } from './services/apiService';
|
||||
import { mountUtilMethods } from './services/util-methods';
|
||||
import { initGlobalHandlerMap } from './services/handler';
|
||||
|
||||
export function initMetaUI() {
|
||||
export function initSunmaoUI() {
|
||||
const registry = initRegistry();
|
||||
const stateManager = initStateManager();
|
||||
const globalHandlerMap = initGlobalHandlerMap();
|
||||
|
@ -1,10 +1,10 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { Application } from '@sunmao-ui/core';
|
||||
import { initMetaUI } from './index';
|
||||
import { initSunmaoUI } from './index';
|
||||
import { ChakraProvider } from '@chakra-ui/react';
|
||||
|
||||
const { App, registry: _registry } = initMetaUI();
|
||||
const { App, registry: _registry } = initSunmaoUI();
|
||||
|
||||
export default function renderApp(options: Application) {
|
||||
ReactDOM.render(
|
||||
|
@ -199,7 +199,7 @@ export const ImplWrapper = React.forwardRef<HTMLDivElement, ImplWrapperProps>(
|
||||
} = props;
|
||||
/* eslint-enable */
|
||||
result = (
|
||||
<div key={c.id} data-meta-ui-id={c.id} ref={ref} {...restProps}>
|
||||
<div key={c.id} data-sunmao-ui-id={c.id} ref={ref} {...restProps}>
|
||||
{result}
|
||||
</div>
|
||||
);
|
||||
|
@ -4,7 +4,7 @@ import { ContainerPropertySchema } from '../traits/core/slot';
|
||||
import { Static } from '@sinclair/typebox';
|
||||
import {
|
||||
ComponentParamsFromApp,
|
||||
MetaUIServices,
|
||||
UIServices,
|
||||
SlotComponentMap,
|
||||
} from 'src/types/RuntimeSchema';
|
||||
import { ImplWrapper } from './ImplWrapper';
|
||||
@ -12,7 +12,7 @@ import { ImplWrapper } from './ImplWrapper';
|
||||
export function resolveAppComponents(
|
||||
components: RuntimeApplication['spec']['components'],
|
||||
params: {
|
||||
services: MetaUIServices;
|
||||
services: UIServices;
|
||||
app?: RuntimeApplication;
|
||||
} & ComponentParamsFromApp
|
||||
): {
|
||||
|
@ -9,7 +9,7 @@ import { Type } from '@sinclair/typebox';
|
||||
|
||||
export type RuntimeApplicationComponent = RuntimeApplication['spec']['components'][0];
|
||||
|
||||
export type MetaUIServices = {
|
||||
export type UIServices = {
|
||||
registry: Registry;
|
||||
stateManager: StateManager;
|
||||
globalHandlerMap: GlobalHandlerMap;
|
||||
@ -35,7 +35,7 @@ export type ComponentParamsFromApp = {
|
||||
|
||||
export type AppProps = {
|
||||
options: Application;
|
||||
services: MetaUIServices;
|
||||
services: UIServices;
|
||||
debugStore?: boolean;
|
||||
debugEvent?: boolean;
|
||||
} & ComponentParamsFromApp;
|
||||
@ -44,7 +44,7 @@ export type ImplWrapperProps = {
|
||||
component: RuntimeApplicationComponent;
|
||||
slotsMap: SlotsMap | undefined;
|
||||
targetSlot: { id: string; slot: string } | null;
|
||||
services: MetaUIServices;
|
||||
services: UIServices;
|
||||
app?: RuntimeApplication;
|
||||
} & ComponentParamsFromApp;
|
||||
|
||||
@ -86,7 +86,7 @@ export type TraitImplementation<T = any> = (
|
||||
props: T &
|
||||
RuntimeFunctions & {
|
||||
componentId: string;
|
||||
services: MetaUIServices;
|
||||
services: UIServices;
|
||||
}
|
||||
) => TraitResult;
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
# Meta UI
|
||||
# Sunmao UI
|
||||
|
||||
## 版本
|
||||
|
||||
当前 Meta UI **规范**版本为 **v0.1.0**。
|
||||
当前 Sunmao UI **规范**版本为 **v0.1.0**。
|
||||
|
||||
## 目标
|
||||
|
||||
Meta UI 的目标是通过提供一种元数据格式用于描述 UI,将开发过程抽象为一个通用平台,从而以更高效的方式开发更高质量的 UI。
|
||||
Sunmao UI 的目标是通过提供一种元数据格式用于描述 UI,将开发过程抽象为一个通用平台,从而以更高效的方式开发更高质量的 UI。
|
||||
|
||||
为此衍生出两种角色:
|
||||
|
||||
@ -15,7 +15,7 @@ Meta UI 的目标是通过提供一种元数据格式用于描述 UI,将开发
|
||||
|
||||
平台搭建者为平台增添更多的能力,因此他们关心平台的**扩展性**;平台使用者基于平台提供的能力开发 UI,因此他们关心平台的**易用性**。
|
||||
|
||||
Meta UI 的规范则是平台搭建者与使用者之间沟通的桥梁。
|
||||
Sunmao UI 的规范则是平台搭建者与使用者之间沟通的桥梁。
|
||||
|
||||
## 概述与术语
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user