Merge pull request #99 from webzard-io/runtime

add preview deploy
This commit is contained in:
yz-yu 2021-10-31 16:41:06 +08:00 committed by GitHub
commit c1acdfff34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 660 additions and 240 deletions

View File

@ -15,15 +15,15 @@
"main": "dist/index.js",
"module": "dist/esm/index.js",
"unpkg": "dist/iife/index.js",
"types": "typings/index.d.ts",
"types": "lib/index.d.ts",
"files": [
"dist",
"typings"
"lib"
],
"scripts": {
"build": "tsup src/index.ts --format cjs,esm,iife --legacy-output",
"dev": "npm run build -- --watch",
"typings": "tsc --emitDeclarationOnly --declarationDir typings",
"typings": "tsc --emitDeclarationOnly",
"test": "jest",
"lint": "eslint src --ext .ts",
"prepublish": "npm run build && npm run typings"
@ -33,6 +33,7 @@
},
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/lodash-es": "^4.17.5",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"eslint": "^7.29.0",
@ -43,6 +44,7 @@
"typescript": "^4.3.5"
},
"dependencies": {
"@types/json-schema": "^7.0.7"
"@types/json-schema": "^7.0.7",
"lodash-es": "^4.17.21"
}
}

View File

@ -8,6 +8,7 @@
"main": "src/main.tsx",
"scripts": {
"dev": "vite",
"build": "vite build",
"test": "jest"
},
"publishConfig": {
@ -31,13 +32,14 @@
"formik": "^2.2.9",
"framer-motion": "^4",
"immer": "^9.0.6",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@babel/preset-react": "^7.14.5",
"@types/codemirror": "^5.60.5",
"@types/lodash-es": "^4.17.5",
"@vitejs/plugin-react": "^1.0.1",
"@vitejs/plugin-react-refresh": "^1.3.6",
"babel-jest": "^27.2.1",

View File

@ -1,5 +1,5 @@
import React from 'react';
import _ from 'lodash';
import { flatten } from 'lodash-es';
import { FormControl, FormLabel, Input, VStack } from '@chakra-ui/react';
import { EmotionJSX } from '@emotion/react/types/jsx-namespace';
import { TSchema } from '@sinclair/typebox';
@ -41,7 +41,7 @@ export const renderField = (properties: {
</FormControl>
);
} else {
const fieldArray: EmotionJSX.Element[] = _.flatten(
const fieldArray: EmotionJSX.Element[] = flatten(
Object.keys(value || []).map(childKey => {
const childValue = (value as any)[childKey];
return renderField({

View File

@ -1,7 +1,7 @@
import { CloseIcon } from '@chakra-ui/icons';
import { Button, HStack, IconButton, Input, VStack } from '@chakra-ui/react';
import produce from 'immer';
import { fromPairs, toPairs } from 'lodash';
import { fromPairs, toPairs } from 'lodash-es';
import React, { useState } from 'react';
type Props = {

View File

@ -15,7 +15,7 @@ import {
import { produce } from 'immer';
import { registry } from '../metaUI';
import { eventBus } from '../eventBus';
import _ from 'lodash';
import { set, isEqual } from 'lodash-es';
function genSlotTrait(parentId: string, slot: string): ComponentTrait {
return {
@ -120,7 +120,7 @@ export class AppModelManager {
newApp = produce(this.app, draft => {
return draft.spec.components.forEach(c => {
if (c.id === mo.componentId) {
_.set(c.properties, mo.propertyKey, mo.propertyValue);
set(c.properties, mo.propertyKey, mo.propertyValue);
}
});
});
@ -161,7 +161,7 @@ export class AppModelManager {
c.traits.forEach(t => {
if (t.type === mto.traitType) {
oldValue = t.properties[mto.propertyKey];
_.set(t.properties, mto.propertyKey, mto.propertyValue);
set(t.properties, mto.propertyKey, mto.propertyValue);
}
});
}
@ -228,6 +228,7 @@ export class AppModelManager {
c.traits.splice(rto.traitIndex, 1);
}
});
});
break;
case 'sortComponent':
const sortO = o as SortComponentOperation;
@ -237,19 +238,25 @@ export class AppModelManager {
const iSlotTrait = iComponent.traits.find(t => t.type === 'core/v1/slot');
if (!iSlotTrait) return;
const findArray = sortO.direction === 'up' ? this.app.spec.components.slice(0, iIndex).reverse() : this.app.spec.components.slice(iIndex + 1);
const findArray =
sortO.direction === 'up'
? this.app.spec.components.slice(0, iIndex).reverse()
: this.app.spec.components.slice(iIndex + 1);
const jComponent = findArray.find(c => {
const jSlotTrait = c.traits.find(t => t.type === 'core/v1/slot');
if (jSlotTrait){
return _.isEqual(jSlotTrait, iSlotTrait);
if (jSlotTrait) {
return isEqual(jSlotTrait, iSlotTrait);
}
});
if (!jComponent) return;
const jIndex = this.app.spec.components.findIndex(c => c.id === jComponent.id);
if (jIndex > -1) {
[draft.spec.components[iIndex],draft.spec.components[jIndex]] = [draft.spec.components[jIndex],draft.spec.components[iIndex]];
[draft.spec.components[iIndex], draft.spec.components[jIndex]] = [
draft.spec.components[jIndex],
draft.spec.components[iIndex],
];
}
});
break;

View File

@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react';
// https://vitejs.dev/config/
export default defineConfig({
base: './',
plugins: [
react({
babel: {
@ -14,6 +15,7 @@ export default defineConfig({
runtime: 'automatic',
importSource: '@emotion/react',
},
'emotion-react',
],
],
},

View File

@ -15,16 +15,16 @@
"main": "dist/index.js",
"module": "dist/esm/index.js",
"unpkg": "dist/iife/index.js",
"types": "typings/index.d.ts",
"types": "lib/index.d.ts",
"files": [
"dist",
"typings"
"lib"
],
"scripts": {
"dev": "vite",
"test": "jest",
"build": "tsup src/index.ts --format cjs,esm,iife --legacy-output --inject ./react-import.js --clean --no-splitting --sourcemap",
"typings": "tsc --emitDeclarationOnly --declarationDir typings",
"typings": "tsc --emitDeclarationOnly",
"lint": "eslint src --ext .ts",
"prepublish": "npm run build && npm run typings"
},
@ -40,14 +40,14 @@
"copy-to-clipboard": "^3.3.1",
"dayjs": "^1.10.6",
"framer-motion": "^4",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"mitt": "^3.0.0",
"nanoid": "^3.1.23",
"path-to-regexp": "^6.2.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react-grid-layout": "^1.3.0",
"react-markdown": "^6.0.2",
"react-markdown": "^7.1.0",
"react-resize-detector": "^6.7.6",
"react-simple-code-editor": "^0.11.0",
"wouter": "^2.7.4"
@ -59,6 +59,7 @@
"@babel/preset-typescript": "^7.15.0",
"@testing-library/react": "^12.1.0",
"@types/lodash": "^4.14.170",
"@types/lodash-es": "^4.17.5",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/react-grid-layout": "^1.1.2",

View File

@ -3,7 +3,7 @@ import { Static, Type } from '@sinclair/typebox';
import { Box as BaseBox } from '@chakra-ui/react';
import { ComponentImplementation } from '../../services/registry';
import Slot from '../_internal/Slot';
import { pick } from 'lodash';
import { pick } from 'lodash-es';
import { GRID_HEIGHT } from '../../constants';
const CssGlobals = Type.KeyOf(

View File

@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from 'react';
import _ from 'lodash';
import { first } from 'lodash-es';
import { createComponent } from '@meta-ui/core';
import { Static, Type } from '@sinclair/typebox';
import {
@ -29,7 +29,7 @@ const FormControlImpl: ComponentImplementation<{
const [inputValue, setInputValue] = useState('');
// don't show Invalid state on component mount
const [hideInvalid, setHideInvalid] = useState(true);
const inputId = useMemo(() => _.first(slotsMap?.get('content'))?.id || '', []);
const inputId = useMemo(() => first(slotsMap?.get('content'))?.id || '', []);
const [validResult, setValidResult] = useState({
isInvalid: false,
errorMsg: '',

View File

@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from 'react';
import { sortBy } from 'lodash';
import { sortBy } from 'lodash-es';
import {
Table as BaseTable,
Thead,

View File

@ -3,7 +3,7 @@ import { ComponentImplementation } from '../../services/registry';
import { createComponent } from '@meta-ui/core';
import { getSlots } from '../_internal/Slot';
import { Static, Type } from '@sinclair/typebox';
import { partial } from 'lodash';
import { partial } from 'lodash-es';
const BaseGridLayout = React.lazy(() => import('../_internal/GridLayout'));

View File

@ -1,6 +1,6 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { watch } from '../utils/watchReactivity';
import { merge } from 'lodash';
import { merge } from 'lodash-es';
import {
RuntimeApplicationComponent,
ImplWrapperProps,

View File

@ -1,4 +1,4 @@
import _ from 'lodash';
import { toNumber, mapValues, isArray, isPlainObject, set } from 'lodash-es';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import { reactive } from '@vue/reactivity';
@ -82,7 +82,7 @@ export class StateManager {
maskedEval(raw: string, evalListItem = false, scopeObject = {}) {
if (isNumeric(raw)) {
return _.toNumber(raw);
return toNumber(raw);
}
if (raw === 'true') {
return true;
@ -122,14 +122,14 @@ export class StateManager {
}) => void,
path: Array<string | number> = []
): any {
return _.mapValues(obj, (val, key) => {
return _.isArray(val)
return mapValues(obj, (val, key) => {
return isArray(val)
? val.map((innerVal, idx) => {
return _.isPlainObject(innerVal)
return isPlainObject(innerVal)
? this.mapValuesDeep(innerVal, fn, path.concat(key, idx))
: fn({ value: innerVal, key, obj, path: path.concat(key, idx) });
})
: _.isPlainObject(val)
: isPlainObject(val)
? this.mapValuesDeep(val, fn, path.concat(key))
: fn({ value: val, key, obj, path: path.concat(key) });
});
@ -150,7 +150,7 @@ export class StateManager {
return this.maskedEval(v);
},
newV => {
_.set(evaluated, path, newV);
set(evaluated, path, newV);
watcher({ result: evaluated });
}
);

View File

@ -1,6 +1,6 @@
import { createTrait } from '@meta-ui/core';
import { Static, Type } from '@sinclair/typebox';
import { debounce, throttle, delay } from 'lodash';
import { debounce, throttle, delay } from 'lodash-es';
import { CallbackMap, TraitImplementation } from 'src/types/RuntimeSchema';
import { EventHandlerSchema } from '../../types/TraitPropertiesSchema';
@ -37,10 +37,10 @@ const useEventTrait: TraitImplementation<Static<typeof PropsSchema>> = ({
handler.wait.type === 'debounce'
? debounce(cb, handler.wait.time)
: handler.wait.type === 'throttle'
? throttle(cb, handler.wait.time)
: handler.wait.type === 'delay'
? () => delay(cb, handler.wait!.time)
: cb
? throttle(cb, handler.wait.time)
: handler.wait.type === 'delay'
? () => delay(cb, handler.wait!.time)
: cb
);
}
}

View File

@ -1,6 +1,6 @@
import { createTrait } from '@meta-ui/core';
import { Static, Type } from '@sinclair/typebox';
import { isEqual } from 'lodash';
import { isEqual } from 'lodash-es';
import { TraitImplementation } from 'src/types/RuntimeSchema';
import { ValidResultSchema } from '../../types/ValidResultSchema';

View File

@ -21,7 +21,8 @@
"types": ["@emotion/react/types/css-prop"],
"baseUrl": "./",
"jsx": "react-jsx",
"jsxImportSource": "@emotion/react"
"jsxImportSource": "@emotion/react",
"rootDir": "src"
},
"include": ["./src"]
}

805
yarn.lock

File diff suppressed because it is too large Load Diff