├── .editorconfig ├── .eslintignore ├── .eslintrc.cjs ├── .gitignore ├── .npmrc ├── .prettierignore ├── .prettierrc.cjs ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── build.json ├── build.plugin.js ├── package.json ├── pnpm-lock.yaml ├── public ├── index.html ├── js │ ├── vue-renderer.d.ts │ ├── vue-renderer.js │ ├── vue-renderer.js.map │ ├── vue-simulator-renderer.css │ ├── vue-simulator-renderer.js │ ├── vue-simulator-renderer.js.map │ └── vue.runtime.global.js ├── mock │ └── info.json └── preview.html ├── src ├── assets │ ├── assets.json │ └── schema.json ├── components │ └── logo │ │ ├── logo.less │ │ └── logo.tsx ├── editor.less ├── editor.ts ├── plugins │ ├── actions.ts │ ├── init.ts │ └── registry.ts ├── setters │ ├── expression-setter │ │ └── index.tsx │ └── index.ts ├── utils │ ├── Logger.ts │ └── store.ts └── vue │ └── preview.ts └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # https://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 2 9 | end_of_line = lf 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | [*.md] 14 | insert_final_newline = false 15 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | .output 4 | .nuxt 5 | **/*.json 6 | public 7 | -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | process.env.ESLINT_TSCONFIG = 'tsconfig.json' 2 | 3 | module.exports = { 4 | extends: '@cdlab996/eslint-config-react', 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/node 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 3 | 4 | ### Node ### 5 | # Logs 6 | logs 7 | *.log 8 | *.log* 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .DS_Store 97 | .nitro 98 | .nuxt 99 | .output 100 | dist 101 | 102 | # Gatsby files 103 | .cache/ 104 | # Comment in the public line in if your project uses Gatsby and not Next.js 105 | # https://nextjs.org/blog/next-9-1#public-directory-support 106 | # public 107 | 108 | # vuepress build output 109 | .vuepress/dist 110 | 111 | # vuepress v2.x temp and cache directory 112 | .temp 113 | 114 | # Docusaurus cache and generated files 115 | .docusaurus 116 | 117 | # Serverless directories 118 | .serverless/ 119 | 120 | # FuseBox cache 121 | .fusebox/ 122 | 123 | # DynamoDB Local files 124 | .dynamodb/ 125 | 126 | # TernJS port file 127 | .tern-port 128 | 129 | # Stores VSCode versions used for testing VSCode extensions 130 | .vscode-test 131 | 132 | # yarn v2 133 | .yarn/cache 134 | .yarn/unplugged 135 | .yarn/build-state.yml 136 | .yarn/install-state.gz 137 | .pnp.* 138 | .idea 139 | 140 | ### Node Patch ### 141 | # Serverless Webpack directories 142 | .webpack/ 143 | 144 | # Optional stylelint cache 145 | 146 | # SvelteKit build / generate output 147 | .svelte-kit 148 | 149 | # End of https://www.toptal.com/developers/gitignore/api/node 150 | .user.ini -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | # registry=https://registry.npmmirror.com/ 2 | shamefully-hoist=true 3 | strict-peer-dependencies=false 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .nuxt 2 | .output 3 | .vscode 4 | dist 5 | node_modules 6 | **/*.yaml 7 | **/*.json 8 | public 9 | -------------------------------------------------------------------------------- /.prettierrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | ...require('@cdlab996/prettier-config'), 3 | // Add your custom configurations here 4 | } 5 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // Disable the default formatter, use eslint instead 3 | "editor.formatOnSave": false, 4 | "editor.defaultFormatter": "esbenp.prettier-vscode", 5 | "prettier.enable": true, 6 | "css.validate": false, 7 | "less.validate": false, 8 | "scss.validate": false, 9 | 10 | // Auto fix 11 | "editor.codeActionsOnSave": { 12 | "source.fixAll.eslint": "explicit", 13 | "source.fixAll.stylelint": "explicit", 14 | "source.organizeImports": "never" 15 | }, 16 | 17 | // Enable eslint for all supported languages 18 | "eslint.validate": [ 19 | "javascript", 20 | "javascriptreact", 21 | "typescript", 22 | "typescriptreact", 23 | "vue", 24 | "html", 25 | "markdown", 26 | "json", 27 | "jsonc", 28 | "yaml", 29 | "toml" 30 | ], 31 | "stylelint.validate": [ 32 | "javascript", 33 | "javascriptreact", 34 | "typescript", 35 | "typescriptreact", 36 | "vue", 37 | "html", 38 | "markdown", 39 | "json", 40 | "jsonc", 41 | "yaml", 42 | "toml" 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023-PRESENT cdLab996 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🚀 Lowcode Engine Vue Demo 2 | 3 | > This is a Lowcode Engine demo based on Vue. You can experience the following versions online: 4 | > 5 | > Note: As the Vue 2.7 version is currently not open-source, only URL access is provided. 6 | 7 | - Vue 3: [https://lowcode-engine-demo-vue.vercel.app/](https://lowcode-engine-demo-vue.vercel.app/) 8 | - Vue 2.7: [https://lowcode-engine-demo-vue2-7.vercel.app/](https://lowcode-engine-demo-vue2-7.vercel.app/) 9 | - Vue 2.7 Examples: [https://lowcode-engine-demo-vue2-7-examples.vercel.app/](https://lowcode-engine-demo-vue2-7-examples.vercel.app/) 10 | 11 | ## 🌱 Getting Started 12 | 13 | run the development server: 14 | 15 | Recommended versions: 16 | 17 | - node `^v16.14.0` 18 | - pnpm `^8.15.4` 19 | 20 | ```bash 21 | pnpm install 22 | 23 | pnpm run dev 24 | ``` 25 | 26 | Open [http://localhost:5577](http://localhost:5577) with your browser to see the result. 27 | 28 | ## 💡 Usage Considerations 29 | 30 | When using variables: 31 | 32 | - `this.props.xxx` -> `this.xxx` 33 | - `this.state.xxx` -> `this.xxx` 34 | 35 | At present, the vue code editor has not been adapted yet. You can directly edit the code using the react code editor. 36 | 37 | - The content within `state` will automatically convert to vue `data`. 38 | - Lifecycle events will automatically adapt to vue lifecycle. 39 | - `componentDidMount` -> `onMounted` 40 | - `componentDidCatch` -> `onErrorCaptured` 41 | - `shouldComponentUpdate` -> `onBeforeUpdate` 42 | - `componentWillUnmount` -> `onBeforeUnmount` 43 | - All other methods will automatically convert to vue `methods`. 44 | 45 | ## ⚡ Credits 46 | 47 | Code built with the help of these related projects: 48 | 49 | - [@alib/build-scripts](https://github.com/ice-lab/build-scripts) for development and build. 50 | - [@alilc/lowcode-plugin-components-pane](https://github.com/alibaba/lowcode-plugins/tree/main/packages/plugin-components-pane) Lowcode Plugin Component Panel 51 | - [@alilc/lowcode-plugin-datasource-pane](https://github.com/alibaba/lowcode-plugins/tree/main/packages/plugin-datasource-pane) Datasource Panel Plugin 52 | - [@alilc/lowcode-plugin-inject](https://github.com/alibaba/lowcode-tools/tree/main/packages/lowcode-plugin-inject) In-project Debugging Plugin 53 | - [@alilc/lowcode-plugin-schema](https://github.com/alibaba/lowcode-plugins/tree/main/packages/plugin-schema) View Lowcode Engine Schema 54 | - [@alilc/lowcode-plugin-set-ref-prop](https://github.com/alibaba/lowcode-plugins/tree/main/packages/plugin-set-ref-prop) Ability to Set ref-id in the Advanced Settings Panel 55 | - [@alilc/lowcode-plugin-simulator-select](https://github.com/alibaba/lowcode-plugins/tree/main/packages/plugin-simulator-size) Canvas Switching 56 | - [@alilc/lowcode-plugin-undo-redo](https://github.com/alibaba/lowcode-plugins/tree/main/packages/plugin-undo-redo) Lowcode Plugin Undo and Redo 57 | - [@alilc/lowcode-types](https://github.com/alibaba/lowcode-engine/tree/main/packages/types) Type Definitions 58 | - [@knxcloud/lowcode-plugin-vue-code-editor](https://github.com/KNXCloud/lowcode-engine-plugins/tree/main/packages/plugin-vue-code-editor) Vue Code Editor 59 | - [@knxcloud/lowcode-utils](https://github.com/KNXCloud/lowcode-engine-vue/tree/main/packages/utils) Utility Library for @knxcloud Packages 60 | - [@knxcloud/lowcode-vue-renderer](https://github.com/KNXCloud/lowcode-engine-vue/tree/main/packages/vue-renderer) Vue Renderer 61 | - [@knxcloud/lowcode-vue-simulator-renderer](https://github.com/KNXCloud/lowcode-engine-vue/tree/main/packages/vue-simulator-renderer) Vue Simulator Renderer 62 | - [@cdlab996/lowcode-plugin-manual](https://github.com/cdlab996/lowcode-plugin-manual) Lowcode Plugin Manual (Due to the official plugins not supporting URL configuration, it has been separated) 63 | - [@cdlab996/lowcode-engine-ext-vue](https://github.com/cdlab996/lowcode-engine-ext-vue) Adapting Vue Setters 64 | - [@cdlab996/plugin-directive-loading](https://github.com/cdlab996/plugin-directive-loading) Vue Custom Directive 65 | - [@cdlab996/lowcode-plugin-set-doc-url](https://github.com/cdLab996/lowcode-engine-plugins/tree/main/packages/plugin-set-doc-url) Lowcode Plugin Component material new documentation address 66 | - [@cdlab996/antd-lowcode-materials](https://github.com/cdLab996/lowcode-engine-materials-vue/tree/main/packages/ant-design-vue) Ant Design Vue Materials 67 | - [@cdlab996/element-plus-lowcode-materials](https://github.com/cdLab996/lowcode-engine-materials-vue/tree/main/packages/element-plus) Element Plus Materials 68 | - [@cdlab996/vant-lowcode-materials](https://github.com/cdLab996/lowcode-engine-materials-vue/tree/main/packages/vant) Vant Materials 69 | 70 | ## 📜 License 71 | 72 | [MIT](./LICENSE) License © 2023-PRESENT [cdLab996](https://github.com/cdLab996) 73 | -------------------------------------------------------------------------------- /build.json: -------------------------------------------------------------------------------- 1 | { 2 | "entry": { 3 | "preview": "./src/vue/preview.ts" 4 | }, 5 | "publicPath": "/", 6 | "externals": { 7 | "@alifd/next": "var window.Next", 8 | "@alilc/lowcode-engine": "var window.AliLowCodeEngine", 9 | "@cdlab996/lowcode-engine-ext-vue": "var window.AliLowCodeEngineExt", 10 | "@alilc/lowcode-editor-core": "var window.AliLowCodeEngine.common.editorCabin", 11 | "@alilc/lowcode-designer": "var window.AliLowCodeEngine.common.designerCabin", 12 | "@alilc/lowcode-editor-skeleton": "var window.AliLowCodeEngine.common.skeletonCabin", 13 | "@knxcloud/lowcode-vue-renderer": "var window.LCVueRenderer", 14 | "@knxcloud/lowcode-vue-simulator-renderer": "var window.LCVueSimulatorRenderer", 15 | "lodash": "var window._", 16 | "moment": "var window.moment", 17 | "prop-types": "var window.PropTypes", 18 | "react": "var window.React", 19 | "react-dom": "var window.ReactDOM", 20 | "vue": "var window.Vue", 21 | "naive-ui": "naive" 22 | }, 23 | "outputDir": "dist", 24 | "vendor": false, 25 | "plugins": ["build-plugin-react-app", "./build.plugin.js"] 26 | } 27 | -------------------------------------------------------------------------------- /build.plugin.js: -------------------------------------------------------------------------------- 1 | const HtmlWebpackPlugin = require('html-webpack-plugin') 2 | const path = require('node:path') 3 | 4 | module.exports = ({ onGetWebpackConfig }) => { 5 | onGetWebpackConfig((config) => { 6 | config.merge({ 7 | node: { 8 | fs: 'empty', 9 | }, 10 | }) 11 | 12 | config.module // fixes https://github.com/graphql/graphql-js/issues/1272 13 | .rule('mjs$') 14 | .test(/\.mjs$/) 15 | .include.add(/node_modules/) 16 | .end() 17 | .type('javascript/auto') 18 | 19 | config.merge({ 20 | entry: { 21 | editor: require.resolve('./src/editor.ts'), 22 | }, 23 | }) 24 | 25 | config.plugin('editor').use(HtmlWebpackPlugin, [ 26 | { 27 | inject: false, 28 | template: require.resolve('./public/index.html'), 29 | filename: 'index.html', 30 | }, 31 | ]) 32 | 33 | config.plugin('preview').use(HtmlWebpackPlugin, [ 34 | { 35 | inject: false, 36 | template: require.resolve('./public/preview.html'), 37 | filename: 'preview.html', 38 | }, 39 | ]) 40 | 41 | config.resolve.merge({ 42 | alias: { 43 | '@': path.resolve(__dirname, 'src'), 44 | }, 45 | }) 46 | }) 47 | } 48 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cdlab996/lowcode-engine-demo-vue", 3 | "version": "1.0.0", 4 | "private": true, 5 | "author": "wudi", 6 | "license": "MIT", 7 | "engines": { 8 | "node": "^16.0.0", 9 | "pnpm": "^8.0.0" 10 | }, 11 | "scripts": { 12 | "start": "build-scripts start --disable-reload --port 5577", 13 | "build": "build-scripts build", 14 | "lint": "eslint .", 15 | "lint:fix": "eslint . --fix", 16 | "format": "prettier --check --write .", 17 | "format:fail": "prettier --check ." 18 | }, 19 | "dependencies": { 20 | "@alilc/lowcode-plugin-components-pane": "^1.0.7", 21 | "@alilc/lowcode-plugin-datasource-pane": "^1.0.10", 22 | "@alilc/lowcode-plugin-inject": "^1.2.2", 23 | "@alilc/lowcode-plugin-schema": "^1.0.5", 24 | "@alilc/lowcode-plugin-set-ref-prop": "^1.0.1", 25 | "@alilc/lowcode-plugin-simulator-select": "^1.0.3", 26 | "@alilc/lowcode-plugin-undo-redo": "^1.0.0", 27 | "@alilc/lowcode-types": "^1.1.7", 28 | "@cdlab996/antd-lowcode-materials": "^0.0.1", 29 | "@cdlab996/element-plus-lowcode-materials": "^0.0.1", 30 | "@cdlab996/lowcode-plugin-manual": "^1.0.2", 31 | "@cdlab996/lowcode-plugin-set-doc-url": "^1.0.1", 32 | "@cdlab996/plugin-directive-loading": "^1.0.0", 33 | "@cdlab996/vant-lowcode-materials": "^0.0.1", 34 | "@knxcloud/lowcode-plugin-vue-code-editor": "0.1.2", 35 | "@knxcloud/lowcode-utils": "^1.6.0", 36 | "@knxcloud/lowcode-vue-renderer": "^1.6.0", 37 | "@knxcloud/lowcode-vue-simulator-renderer": "^1.6.1" 38 | }, 39 | "devDependencies": { 40 | "@alib/build-scripts": "^0.1.32", 41 | "@alilc/lowcode-engine": "^1.1.7", 42 | "@babel/core": "^7.21.0", 43 | "@cdlab996/eslint-config-react": "0.0.6-beta.4", 44 | "@cdlab996/lowcode-engine-ext-vue": "^1.0.6-beta.29", 45 | "@cdlab996/prettier-config": "^0.0.6-beta.4", 46 | "@types/node": "^17.0.45", 47 | "@types/prop-types": "^15.7.5", 48 | "@types/react": "^16.14.35", 49 | "@types/react-dom": "^16.9.18", 50 | "build-plugin-component": "^1.12.1", 51 | "build-plugin-moment-locales": "^0.1.3", 52 | "build-plugin-react-app": "^1.8.5", 53 | "eslint": "^8.57.0", 54 | "prettier": "^3.2.5", 55 | "typescript": "^5.4.3", 56 | "vue": "^3.4.21" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 低代码引擎 8 | 9 | 10 | 14 | 18 | 19 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /public/js/vue-renderer.d.ts: -------------------------------------------------------------------------------- 1 | import { AllowedComponentProps } from 'vue'; 2 | import { Component } from 'vue'; 3 | import { ComponentCustomProps } from 'vue'; 4 | import { ComponentOptionsMixin } from 'vue'; 5 | import { ComponentPublicInstance } from 'vue'; 6 | import { ComputedOptions } from 'vue'; 7 | import { ComputedRef } from 'vue'; 8 | import { DataSource } from '@knxcloud/lowcode-data-source'; 9 | import { DefineComponent } from 'vue'; 10 | import { DesignMode } from '@knxcloud/lowcode-hooks'; 11 | import type { ExtractDefaultPropTypes } from 'vue'; 12 | import { ExtractPropTypes } from 'vue'; 13 | import { Fragment } from 'vue'; 14 | import { INode } from '@knxcloud/lowcode-hooks'; 15 | import { IPublicTypeContainerSchema } from '@alilc/lowcode-types'; 16 | import type { IPublicTypeI18nData } from '@alilc/lowcode-types'; 17 | import type { IPublicTypeJSExpression } from '@alilc/lowcode-types'; 18 | import type { IPublicTypeJSFunction } from '@alilc/lowcode-types'; 19 | import type { IPublicTypeNodeData } from '@alilc/lowcode-types'; 20 | import type { IPublicTypeNodeSchema } from '@alilc/lowcode-types'; 21 | import { MethodOptions } from 'vue'; 22 | import { PropType } from 'vue'; 23 | import { Ref } from 'vue'; 24 | import { RendererElement } from 'vue'; 25 | import { RendererNode } from 'vue'; 26 | import type { RequestHandler } from '@alilc/lowcode-types'; 27 | import type { Router } from 'vue-router'; 28 | import { Slot } from 'vue'; 29 | import { Slots } from 'vue'; 30 | import { VNode } from 'vue'; 31 | import { VNodeChild } from 'vue'; 32 | import { VNodeProps } from 'vue'; 33 | 34 | export declare const baseRendererPropKeys: ("__scope" | "__locale" | ("__parser" | "__schema" | "__appHelper" | "__designMode" | "__components" | "__messages" | "__getNode" | "__triggerCompGetCtx" | "__thisRequiredInJSE" | "__requestHandlersMap" | "__props"))[]; 35 | 36 | export declare interface BlockScope { 37 | [x: string | symbol]: unknown; 38 | } 39 | 40 | export declare const cleanCacledModules: () => void; 41 | 42 | export declare class Config { 43 | private renderers; 44 | private configProvider; 45 | setConfigProvider(comp: any): void; 46 | getConfigProvider(): any; 47 | setRenderers(renderers: RendererModules): void; 48 | getRenderers(): RendererModules; 49 | } 50 | 51 | export declare const config: Config; 52 | 53 | export declare type ExtractPublicPropTypes = Omit, keyof ExtractDefaultPropTypes> & Partial>; 54 | 55 | export declare type I18nMessages = { 56 | [locale: string]: Record; 57 | }; 58 | 59 | export declare type LeafComponent = DefineComponent; 60 | 61 | export declare const leafPropKeys: ("__scope" | "__comp" | ("__schema" | "__vnodeProps" | "__isRootNode"))[]; 62 | 63 | export declare type LeafProps = ExtractPropTypes; 64 | 65 | export declare const leafProps: { 66 | readonly __comp: null; 67 | readonly __scope: null; 68 | readonly __schema: { 69 | readonly type: PropType; 70 | readonly default: () => {}; 71 | }; 72 | readonly __vnodeProps: { 73 | readonly type: PropType>; 74 | readonly default: () => {}; 75 | }; 76 | readonly __isRootNode: BooleanConstructor; 77 | }; 78 | 79 | export declare const LOWCODE_ROUTE_META: unique symbol; 80 | 81 | export declare type MaybeArray = T | T[]; 82 | 83 | export declare function mergeScope(scope: RuntimeScope, ...blockScope: MaybeArray[]): RuntimeScope; 84 | 85 | export declare function mergeScope(...blockScope: MaybeArray[]): BlockScope; 86 | 87 | declare type RenderComponent = (nodeSchema: IPublicTypeNodeData, scope: RuntimeScope, comp?: Component | typeof Fragment) => VNode | VNode[] | null; 88 | 89 | export declare type RendererComponent = DefineComponent; 90 | 91 | export declare type RendererModules = Record; 92 | 93 | export declare type RendererProps = ExtractPropTypes; 94 | 95 | export declare const rendererProps: { 96 | readonly __scope: { 97 | readonly type: PropType; 98 | readonly default: undefined; 99 | }; 100 | readonly __schema: { 101 | readonly type: PropType; 102 | readonly required: true; 103 | }; 104 | readonly __appHelper: { 105 | readonly type: PropType>; 106 | readonly default: () => {}; 107 | }; 108 | readonly __designMode: { 109 | readonly type: PropType<"live" | "design">; 110 | readonly default: "live"; 111 | }; 112 | readonly __components: { 113 | readonly type: PropType>>; 114 | readonly required: true; 115 | }; 116 | readonly __locale: { 117 | readonly type: StringConstructor; 118 | readonly default: undefined; 119 | }; 120 | readonly __messages: { 121 | readonly type: PropType; 122 | readonly default: () => {}; 123 | }; 124 | readonly __getNode: { 125 | readonly type: PropType<(id: string) => INode | null>; 126 | readonly required: true; 127 | }; 128 | readonly __triggerCompGetCtx: { 129 | readonly type: PropType<(schema: IPublicTypeNodeSchema, ref: ComponentPublicInstance) => void>; 130 | readonly required: true; 131 | }; 132 | readonly __thisRequiredInJSE: { 133 | readonly type: BooleanConstructor; 134 | readonly default: true; 135 | }; 136 | readonly __requestHandlersMap: { 137 | readonly type: PropType>>; 138 | readonly default: () => {}; 139 | }; 140 | readonly __props: { 141 | readonly type: ObjectConstructor; 142 | readonly default: () => {}; 143 | }; 144 | readonly __parser: { 145 | readonly type: PropType; 146 | readonly required: true; 147 | }; 148 | }; 149 | 150 | export declare interface RuntimeScope extends BlockScope, ComponentPublicInstance { 151 | i18n(key: string, values: any): string; 152 | currentLocale: string; 153 | dataSourceMap: Record; 154 | reloadDataSource(): Promise; 155 | __parser: SchemaParser; 156 | __thisRequired: boolean; 157 | __loopScope?: boolean; 158 | __loopRefIndex?: number; 159 | __loopRefOffset?: number; 160 | } 161 | 162 | export declare class SchemaParser { 163 | static cacheModules: Record; 164 | static cleanCachedModules(): void; 165 | private createFunction; 166 | private exports; 167 | constructor(options?: SchemaParserOptions); 168 | initModule(schema: IPublicTypeContainerSchema): this; 169 | parseSlotScope(args: unknown[], params: string[]): BlockScope; 170 | parseI18n(i18nInfo: IPublicTypeI18nData, scope?: RuntimeScope | boolean): string | undefined; 171 | parseSchema(schema: IPublicTypeI18nData, scope?: RuntimeScope | boolean): string | undefined; 172 | parseSchema(schema: IPublicTypeJSFunction, scope?: RuntimeScope | boolean): CallableFunction; 173 | parseSchema(schema: IPublicTypeJSExpression, scope?: RuntimeScope | boolean): unknown; 174 | parseSchema(schema: T, scope: RuntimeScope | boolean): { 175 | [K in keyof T]: T[K] extends IPublicTypeI18nData ? string : T[K] extends IPublicTypeJSFunction ? CallableFunction : T[K] extends IPublicTypeJSExpression ? unknown : T[K] extends IPublicTypeJSExpression | IPublicTypeJSFunction ? CallableFunction | unknown : T[K]; 176 | }; 177 | parseSchema(schema: unknown, scope?: RuntimeScope | boolean): T; 178 | parseOnlyJsValue(schema: unknown): T; 179 | parseOnlyJsValue(schema: unknown): unknown; 180 | parseExpression(str: IPublicTypeJSFunction, scope?: RuntimeScope | boolean): CallableFunction; 181 | parseExpression(str: IPublicTypeJSExpression, scope?: RuntimeScope | boolean): unknown; 182 | parseExpression(str: IPublicTypeJSExpression | IPublicTypeJSFunction, scope?: RuntimeScope | boolean): CallableFunction | unknown; 183 | } 184 | 185 | export declare interface SchemaParserOptions { 186 | thisRequired?: boolean; 187 | } 188 | 189 | export declare function setupLowCodeRouteGuard(router: Router, options?: SetupLowCodeRouteGuardOptions): (() => void) | undefined; 190 | 191 | export declare interface SetupLowCodeRouteGuardOptions extends SchemaParserOptions { 192 | /** 193 | * @default 'runtimeScope' 194 | */ 195 | scopePath?: string; 196 | /** 197 | * 等待异步 setup 以及 init dataSource 的超时时间,默认为 1 分钟 198 | * @default 60000 ms 199 | */ 200 | timeout?: number; 201 | } 202 | 203 | export declare type SlotSchemaMap = { 204 | [x: string]: unknown; 205 | }; 206 | 207 | export declare function useLeaf(leafProps: LeafProps, onChildShowChange?: (schema: IPublicTypeNodeSchema, show: boolean) => void): { 208 | node: INode | null; 209 | locked: Ref; 210 | isRootNode: boolean; 211 | getNode: (id: string) => INode | null; 212 | renderComp: RenderComponent; 213 | buildProps: (propsSchema: Record, scope: RuntimeScope, node?: INode | null, blockScope?: BlockScope | null, extraProps?: Record) => any; 214 | buildSlots: (slots: SlotSchemaMap, scope: RuntimeScope, node?: INode | null) => Slots; 215 | }; 216 | 217 | export declare function useRenderer(rendererProps: RendererProps, scope: RuntimeScope): { 218 | node: INode | null; 219 | locked: Ref; 220 | isRootNode: boolean; 221 | getNode: (id: string) => INode | null; 222 | renderComp: RenderComponent; 223 | buildProps: (propsSchema: Record, scope: RuntimeScope, node?: INode | null | undefined, blockScope?: BlockScope | null | undefined, extraProps?: Record | undefined) => any; 224 | buildSlots: (slots: SlotSchemaMap, scope: RuntimeScope, node?: INode | null | undefined) => Readonly<{ 225 | [name: string]: Slot | undefined; 226 | }>; 227 | scope: RuntimeScope; 228 | schemaRef: ComputedRef; 229 | designModeRef: ComputedRef<"live" | "design">; 230 | componentsRef: ComputedRef>>; 231 | }; 232 | 233 | export declare function useRootScope(rendererProps: RendererProps, setupConext: object): { 234 | scope: RuntimeScope; 235 | wrapRender: (render: () => VNodeChild | null) => (() => VNodeChild | null) | Promise<() => VNodeChild | null>; 236 | }; 237 | 238 | declare const VueRenderer: DefineComponent< { 239 | readonly scope: PropType; 240 | readonly schema: { 241 | readonly type: PropType; 242 | readonly required: true; 243 | }; 244 | readonly passProps: PropType>; 245 | readonly components: { 246 | readonly type: PropType>>; 247 | readonly required: true; 248 | }; 249 | /** 设计模式,可选值:live、design */ 250 | readonly designMode: { 251 | readonly type: PropType; 252 | readonly default: "live"; 253 | }; 254 | /** 设备信息 */ 255 | readonly device: StringConstructor; 256 | /** 语言 */ 257 | readonly locale: StringConstructor; 258 | readonly messages: { 259 | readonly type: PropType; 260 | readonly default: () => {}; 261 | }; 262 | readonly getNode: PropType<(id: string) => INode | null>; 263 | /** 组件获取 ref 时触发的钩子 */ 264 | readonly onCompGetCtx: PropType<(schema: IPublicTypeNodeSchema, ref: ComponentPublicInstance) => void>; 265 | readonly thisRequiredInJSE: { 266 | readonly type: BooleanConstructor; 267 | readonly default: true; 268 | }; 269 | readonly disableCompMock: { 270 | readonly type: PropType; 271 | readonly default: false; 272 | }; 273 | readonly appHelper: ObjectConstructor; 274 | readonly requestHandlersMap: ObjectConstructor; 275 | }, () => VNode | null, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly; 279 | readonly schema: { 280 | readonly type: PropType; 281 | readonly required: true; 282 | }; 283 | readonly passProps: PropType>; 284 | readonly components: { 285 | readonly type: PropType>>; 286 | readonly required: true; 287 | }; 288 | /** 设计模式,可选值:live、design */ 289 | readonly designMode: { 290 | readonly type: PropType; 291 | readonly default: "live"; 292 | }; 293 | /** 设备信息 */ 294 | readonly device: StringConstructor; 295 | /** 语言 */ 296 | readonly locale: StringConstructor; 297 | readonly messages: { 298 | readonly type: PropType; 299 | readonly default: () => {}; 300 | }; 301 | readonly getNode: PropType<(id: string) => INode | null>; 302 | /** 组件获取 ref 时触发的钩子 */ 303 | readonly onCompGetCtx: PropType<(schema: IPublicTypeNodeSchema, ref: ComponentPublicInstance) => void>; 304 | readonly thisRequiredInJSE: { 305 | readonly type: BooleanConstructor; 306 | readonly default: true; 307 | }; 308 | readonly disableCompMock: { 309 | readonly type: PropType; 310 | readonly default: false; 311 | }; 312 | readonly appHelper: ObjectConstructor; 313 | readonly requestHandlersMap: ObjectConstructor; 314 | }>>, { 315 | readonly designMode: DesignMode; 316 | readonly thisRequiredInJSE: boolean; 317 | readonly messages: I18nMessages; 318 | readonly disableCompMock: boolean | string[]; 319 | }>; 320 | export default VueRenderer; 321 | 322 | export declare type VueRendererProps = ExtractPublicPropTypes; 323 | 324 | export declare const vueRendererProps: { 325 | readonly scope: PropType; 326 | readonly schema: { 327 | readonly type: PropType; 328 | readonly required: true; 329 | }; 330 | readonly passProps: PropType>; 331 | readonly components: { 332 | readonly type: PropType>>; 333 | readonly required: true; 334 | }; 335 | /** 设计模式,可选值:live、design */ 336 | readonly designMode: { 337 | readonly type: PropType; 338 | readonly default: "live"; 339 | }; 340 | /** 设备信息 */ 341 | readonly device: StringConstructor; 342 | /** 语言 */ 343 | readonly locale: StringConstructor; 344 | readonly messages: { 345 | readonly type: PropType; 346 | readonly default: () => {}; 347 | }; 348 | readonly getNode: PropType<(id: string) => INode | null>; 349 | /** 组件获取 ref 时触发的钩子 */ 350 | readonly onCompGetCtx: PropType<(schema: IPublicTypeNodeSchema, ref: ComponentPublicInstance) => void>; 351 | readonly thisRequiredInJSE: { 352 | readonly type: BooleanConstructor; 353 | readonly default: true; 354 | }; 355 | readonly disableCompMock: { 356 | readonly type: PropType; 357 | readonly default: false; 358 | }; 359 | readonly appHelper: ObjectConstructor; 360 | readonly requestHandlersMap: ObjectConstructor; 361 | }; 362 | 363 | export { } 364 | -------------------------------------------------------------------------------- /public/js/vue-renderer.js: -------------------------------------------------------------------------------- 1 | (function(L,h){typeof exports=="object"&&typeof module!="undefined"?h(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],h):(L=typeof globalThis!="undefined"?globalThis:L||self,h(L.LCVueRenderer={},L.Vue))})(this,function(L,h){"use strict";var uo=Object.defineProperty;var ho=(L,h,X)=>h in L?uo(L,h,{enumerable:!0,configurable:!0,writable:!0,value:X}):L[h]=X;var re=(L,h,X)=>(ho(L,typeof h!="symbol"?h+"":h,X),X);const X={__scope:{type:Object,default:void 0},__schema:{type:Object,required:!0},__appHelper:{type:Object,default:()=>({})},__designMode:{type:String,default:"live"},__components:{type:Object,required:!0},__locale:{type:String,default:void 0},__messages:{type:Object,default:()=>({})},__getNode:{type:Function,required:!0},__triggerCompGetCtx:{type:Function,required:!0},__thisRequiredInJSE:{type:Boolean,default:!0},__requestHandlersMap:{type:Object,default:()=>({})},__props:{type:Object,default:()=>({})},__parser:{type:Object,required:!0}},rn=Object.keys(X),ae={__comp:null,__scope:null,__schema:{type:Object,default:()=>({})},__vnodeProps:{type:Object,default:()=>({})},__isRootNode:Boolean},et=Object.keys(ae);var Oe=function(e,t){return Oe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},Oe(e,t)};function ue(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Oe(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var I=function(){return I=Object.assign||function(t){for(var n,r=1,o=arguments.length;r0}),n=[],r=0,o=t;r1)throw new RangeError("integer-width stems only accept a single optional option");o.options[0].replace(pn,function(f,l,c,d,a,p){if(l)t.minimumIntegerDigits=c.length;else{if(d&&a)throw new Error("We currently do not support maximum integer digits");if(p)throw new Error("We currently do not support exact integer digits")}return""});continue}if(ft.test(o.stem)){t.minimumIntegerDigits=o.stem.length;continue}if(lt.test(o.stem)){if(o.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");o.stem.replace(lt,function(f,l,c,d,a,p){return c==="*"?t.minimumFractionDigits=l.length:d&&d[0]==="#"?t.maximumFractionDigits=d.length:a&&p?(t.minimumFractionDigits=a.length,t.maximumFractionDigits=a.length+p.length):(t.minimumFractionDigits=l.length,t.maximumFractionDigits=l.length),""});var i=o.options[0];i==="w"?t=I(I({},t),{trailingZeroDisplay:"stripIfInteger"}):i&&(t=I(I({},t),pt(i)));continue}if(ct.test(o.stem)){t=I(I({},t),pt(o.stem));continue}var s=dt(o.stem);s&&(t=I(I({},t),s));var u=dn(o.stem);u&&(t=I(I({},t),u))}return t}var he={"001":["H","h"],AC:["H","h","hb","hB"],AD:["H","hB"],AE:["h","hB","hb","H"],AF:["H","hb","hB","h"],AG:["h","hb","H","hB"],AI:["H","h","hb","hB"],AL:["h","H","hB"],AM:["H","hB"],AO:["H","hB"],AR:["H","h","hB","hb"],AS:["h","H"],AT:["H","hB"],AU:["h","hb","H","hB"],AW:["H","hB"],AX:["H"],AZ:["H","hB","h"],BA:["H","hB","h"],BB:["h","hb","H","hB"],BD:["h","hB","H"],BE:["H","hB"],BF:["H","hB"],BG:["H","hB","h"],BH:["h","hB","hb","H"],BJ:["H","hB"],BL:["H","hB"],BM:["h","hb","H","hB"],BN:["hb","hB","h","H"],BO:["H","hB","h","hb"],BQ:["H"],BR:["H","hB"],BS:["h","hb","H","hB"],BT:["h","H"],BW:["H","h","hb","hB"],BZ:["H","h","hb","hB"],CA:["h","hb","H","hB"],CC:["H","h","hb","hB"],CD:["hB","H"],CF:["H","h","hB"],CG:["H","hB"],CH:["H","hB","h"],CI:["H","hB"],CK:["H","h","hb","hB"],CL:["H","h","hB","hb"],CM:["H","h","hB"],CN:["H","hB","hb","h"],CO:["h","H","hB","hb"],CP:["H"],CR:["H","h","hB","hb"],CU:["H","h","hB","hb"],CV:["H","hB"],CX:["H","h","hb","hB"],CY:["h","H","hb","hB"],CZ:["H"],DE:["H","hB"],DG:["H","h","hb","hB"],DJ:["h","H"],DK:["H"],DM:["h","hb","H","hB"],DO:["h","H","hB","hb"],DZ:["h","hB","hb","H"],EA:["H","h","hB","hb"],EC:["H","hB","h","hb"],EE:["H","hB"],EG:["h","hB","hb","H"],EH:["h","hB","hb","H"],ER:["h","H"],ES:["H","hB","h","hb"],ET:["hB","hb","h","H"],FI:["H"],FJ:["h","hb","H","hB"],FK:["H","h","hb","hB"],FM:["h","hb","H","hB"],FR:["H","hB"],GA:["H","hB"],GB:["H","h","hb","hB"],GD:["h","hb","H","hB"],GE:["H","hB","h"],GF:["H","hB"],GG:["H","h","hb","hB"],GH:["h","H"],GI:["H","h","hb","hB"],GM:["h","hb","H","hB"],GN:["H","hB"],GP:["H","hB"],GQ:["H","hB","h","hb"],GR:["h","H","hb","hB"],GT:["H","h","hB","hb"],GU:["h","hb","H","hB"],GW:["H","hB"],GY:["h","hb","H","hB"],HK:["h","hB","hb","H"],HN:["H","h","hB","hb"],HR:["H","hB"],IC:["H","h","hB","hb"],ID:["H"],IE:["H","h","hb","hB"],IL:["H","hB"],IM:["H","h","hb","hB"],IN:["h","H"],IO:["H","h","hb","hB"],IQ:["h","hB","hb","H"],IR:["hB","H"],IS:["H"],IT:["H","hB"],JE:["H","h","hb","hB"],JM:["h","hb","H","hB"],JO:["h","hB","hb","H"],JP:["H","h","K"],KE:["hB","hb","H","h"],KG:["H","h","hB","hb"],KH:["hB","h","H","hb"],KI:["h","hb","H","hB"],KM:["H","h","hB","hb"],KN:["h","hb","H","hB"],KP:["h","H","hB","hb"],KR:["h","H","hB","hb"],KW:["h","hB","hb","H"],KY:["h","hb","H","hB"],KZ:["H","hB"],LA:["H","hb","hB","h"],LB:["h","hB","hb","H"],LC:["h","hb","H","hB"],LI:["H","hB","h"],LK:["H","h","hB","hb"],LR:["h","hb","H","hB"],LS:["h","H"],LT:["H","h","hb","hB"],LU:["H","h","hB"],LV:["H","hB","hb","h"],LY:["h","hB","hb","H"],MA:["H","h","hB","hb"],MC:["H","hB"],MD:["H","hB"],ME:["H","hB","h"],MF:["H","hB"],MH:["h","hb","H","hB"],MK:["H","h","hb","hB"],ML:["H"],MM:["hB","hb","H","h"],MN:["H","h","hb","hB"],MO:["h","hB","hb","H"],MP:["h","hb","H","hB"],MQ:["H","hB"],MR:["h","hB","hb","H"],MS:["H","h","hb","hB"],MW:["h","hb","H","hB"],MX:["H","h","hB","hb"],MY:["hb","hB","h","H"],MZ:["H","hB"],NA:["h","H","hB","hb"],NC:["H","hB"],NE:["H"],NF:["H","h","hb","hB"],NG:["H","h","hb","hB"],NI:["H","h","hB","hb"],NL:["H","hB"],NP:["H","h","hB"],NR:["H","h","hb","hB"],NU:["H","h","hb","hB"],NZ:["h","hb","H","hB"],OM:["h","hB","hb","H"],PA:["h","H","hB","hb"],PE:["H","hB","h","hb"],PF:["H","h","hB"],PG:["h","H"],PH:["h","hB","hb","H"],PK:["h","hB","H"],PM:["H","hB"],PN:["H","h","hb","hB"],PR:["h","H","hB","hb"],PS:["h","hB","hb","H"],PT:["H","hB"],PW:["h","H"],PY:["H","h","hB","hb"],QA:["h","hB","hb","H"],RE:["H","hB"],RO:["H","hB"],RS:["H","hB","h"],RU:["H"],SA:["h","hB","hb","H"],SB:["h","hb","H","hB"],SC:["H","h","hB"],SD:["h","hB","hb","H"],SE:["H"],SG:["h","hb","H","hB"],SH:["H","h","hb","hB"],SI:["H","hB"],SJ:["H"],SK:["H"],SL:["h","hb","H","hB"],SM:["H","h","hB"],SN:["H","h","hB"],SO:["h","H"],SR:["H","hB"],SS:["h","hb","H","hB"],ST:["H","hB"],SV:["H","h","hB","hb"],SX:["H","h","hb","hB"],SY:["h","hB","hb","H"],SZ:["h","hb","H","hB"],TA:["H","h","hb","hB"],TC:["h","hb","H","hB"],TD:["h","H","hB"],TF:["H","h","hB"],TG:["H","hB"],TL:["H","hB","hb","h"],TN:["h","hB","hb","H"],TO:["h","H"],TR:["H","hB"],TT:["h","hb","H","hB"],TW:["hB","hb","h","H"],TZ:["hB","hb","H","h"],UA:["H","hB","h"],UG:["hB","hb","H","h"],UM:["h","hb","H","hB"],US:["h","hb","H","hB"],UY:["H","h","hB","hb"],UZ:["H","hB","h"],VA:["H","h","hB"],VC:["h","hb","H","hB"],VE:["h","H","hB","hb"],VG:["h","hb","H","hB"],VI:["h","hb","H","hB"],VU:["h","H"],WF:["H","hB"],WS:["h","H"],XK:["H","hB","h"],YE:["h","hB","hb","H"],YT:["H","hB"],ZA:["H","h","hb","hB"],ZM:["h","hb","H","hB"],"af-ZA":["H","h","hB","hb"],"ar-001":["h","hB","hb","H"],"ca-ES":["H","h","hB"],"en-001":["h","hb","H","hB"],"es-BO":["H","h","hB","hb"],"es-BR":["H","h","hB","hb"],"es-EC":["H","h","hB","hb"],"es-ES":["H","h","hB","hb"],"es-GQ":["H","h","hB","hb"],"es-PE":["H","h","hB","hb"],"fr-CA":["H","h","hB"],"gl-ES":["H","h","hB"],"gu-IN":["hB","hb","h","H"],"hi-IN":["hB","h","H"],"it-CH":["H","h","hB"],"it-IT":["H","h","hB"],"kn-IN":["hB","h","H"],"ml-IN":["hB","h","H"],"mr-IN":["hB","hb","h","H"],"pa-IN":["hB","hb","h","H"],"ta-IN":["hB","h","hb","H"],"te-IN":["hB","h","H"],"zu-ZA":["H","hB","hb","h"]};function _n(e,t){for(var n="",r=0;r>1),f="a",l=bn(t);for((l=="H"||l=="k")&&(u=0);u-- >0;)n+=f;for(;s-- >0;)n=l+n}else o==="J"?n+="H":n+=o}return n}function bn(e){var t=e.hourCycle;if(t===void 0&&e.hourCycles&&e.hourCycles.length&&(t=e.hourCycles[0]),t)switch(t){case"h24":return"k";case"h23":return"H";case"h12":return"h";case"h11":return"K";default:throw new Error("Invalid hourCycle")}var n=e.language,r;n!=="root"&&(r=e.maximize().region);var o=he[r||""]||he[n||""]||he["".concat(n,"-001")]||he["001"];return o[0]}var ve,En=new RegExp("^".concat(ht.source,"*")),gn=new RegExp("".concat(ht.source,"*$"));function P(e,t){return{start:e,end:t}}var xn=!!String.prototype.startsWith,yn=!!String.fromCodePoint,Sn=!!Object.fromEntries,Cn=!!String.prototype.codePointAt,Tn=!!String.prototype.trimStart,On=!!String.prototype.trimEnd,Rn=!!Number.isSafeInteger,Hn=Rn?Number.isSafeInteger:function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991},Pe=!0;try{var vn=gt("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");Pe=((ve=vn.exec("a"))===null||ve===void 0?void 0:ve[0])==="a"}catch(e){Pe=!1}var _t=xn?function(t,n,r){return t.startsWith(n,r)}:function(t,n,r){return t.slice(r,r+n.length)===n},Be=yn?String.fromCodePoint:function(){for(var t=[],n=0;ni;){if(s=t[i++],s>1114111)throw RangeError(s+" is not a valid code point");r+=s<65536?String.fromCharCode(s):String.fromCharCode(((s-=65536)>>10)+55296,s%1024+56320)}return r},bt=Sn?Object.fromEntries:function(t){for(var n={},r=0,o=t;r=r)){var o=t.charCodeAt(n),i;return o<55296||o>56319||n+1===r||(i=t.charCodeAt(n+1))<56320||i>57343?o:(o-55296<<10)+(i-56320)+65536}},Pn=Tn?function(t){return t.trimStart()}:function(t){return t.replace(En,"")},Bn=On?function(t){return t.trimEnd()}:function(t){return t.replace(gn,"")};function gt(e,t){return new RegExp(e,t)}var Ne;if(Pe){var xt=gt("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");Ne=function(t,n){var r;xt.lastIndex=n;var o=xt.exec(t);return(r=o[1])!==null&&r!==void 0?r:""}}else Ne=function(t,n){for(var r=[];;){var o=Et(t,n);if(o===void 0||yt(o)||wn(o))break;r.push(o),n+=o>=65536?2:1}return Be.apply(void 0,r)};var Nn=function(){function e(t,n){n===void 0&&(n={}),this.message=t,this.position={offset:0,line:1,column:1},this.ignoreTag=!!n.ignoreTag,this.locale=n.locale,this.requiresOtherClause=!!n.requiresOtherClause,this.shouldParseSkeletons=!!n.shouldParseSkeletons}return e.prototype.parse=function(){if(this.offset()!==0)throw Error("parser can only be used once");return this.parseMessage(0,"",!1)},e.prototype.parseMessage=function(t,n,r){for(var o=[];!this.isEOF();){var i=this.char();if(i===123){var s=this.parseArgument(t,r);if(s.err)return s;o.push(s.val)}else{if(i===125&&t>0)break;if(i===35&&(n==="plural"||n==="selectordinal")){var u=this.clonePosition();this.bump(),o.push({type:U.pound,location:P(u,this.clonePosition())})}else if(i===60&&!this.ignoreTag&&this.peek()===47){if(r)break;return this.error(H.UNMATCHED_CLOSING_TAG,P(this.clonePosition(),this.clonePosition()))}else if(i===60&&!this.ignoreTag&&Ie(this.peek()||0)){var s=this.parseTag(t,n);if(s.err)return s;o.push(s.val)}else{var s=this.parseLiteral(t,n);if(s.err)return s;o.push(s.val)}}}return{val:o,err:null}},e.prototype.parseTag=function(t,n){var r=this.clonePosition();this.bump();var o=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:U.literal,value:"<".concat(o,"/>"),location:P(r,this.clonePosition())},err:null};if(this.bumpIf(">")){var i=this.parseMessage(t+1,n,!0);if(i.err)return i;var s=i.val,u=this.clonePosition();if(this.bumpIf("")?{val:{type:U.tag,value:o,children:s,location:P(r,this.clonePosition())},err:null}:this.error(H.INVALID_TAG,P(u,this.clonePosition())))}else return this.error(H.UNCLOSED_TAG,P(r,this.clonePosition()))}else return this.error(H.INVALID_TAG,P(r,this.clonePosition()))},e.prototype.parseTagName=function(){var t=this.offset();for(this.bump();!this.isEOF()&&An(this.char());)this.bump();return this.message.slice(t,this.offset())},e.prototype.parseLiteral=function(t,n){for(var r=this.clonePosition(),o="";;){var i=this.tryParseQuote(n);if(i){o+=i;continue}var s=this.tryParseUnquoted(t,n);if(s){o+=s;continue}var u=this.tryParseLeftAngleBracket();if(u){o+=u;continue}break}var f=P(r,this.clonePosition());return{val:{type:U.literal,value:o,location:f},err:null}},e.prototype.tryParseLeftAngleBracket=function(){return!this.isEOF()&&this.char()===60&&(this.ignoreTag||!In(this.peek()||0))?(this.bump(),"<"):null},e.prototype.tryParseQuote=function(t){if(this.isEOF()||this.char()!==39)return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if(t==="plural"||t==="selectordinal")break;return null;default:return null}this.bump();var n=[this.char()];for(this.bump();!this.isEOF();){var r=this.char();if(r===39)if(this.peek()===39)n.push(39),this.bump();else{this.bump();break}else n.push(r);this.bump()}return Be.apply(void 0,n)},e.prototype.tryParseUnquoted=function(t,n){if(this.isEOF())return null;var r=this.char();return r===60||r===123||r===35&&(n==="plural"||n==="selectordinal")||r===125&&t>0?null:(this.bump(),Be(r))},e.prototype.parseArgument=function(t,n){var r=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(H.EXPECT_ARGUMENT_CLOSING_BRACE,P(r,this.clonePosition()));if(this.char()===125)return this.bump(),this.error(H.EMPTY_ARGUMENT,P(r,this.clonePosition()));var o=this.parseIdentifierIfPossible().value;if(!o)return this.error(H.MALFORMED_ARGUMENT,P(r,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(H.EXPECT_ARGUMENT_CLOSING_BRACE,P(r,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:U.argument,value:o,location:P(r,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(H.EXPECT_ARGUMENT_CLOSING_BRACE,P(r,this.clonePosition())):this.parseArgumentOptions(t,n,o,r);default:return this.error(H.MALFORMED_ARGUMENT,P(r,this.clonePosition()))}},e.prototype.parseIdentifierIfPossible=function(){var t=this.clonePosition(),n=this.offset(),r=Ne(this.message,n),o=n+r.length;this.bumpTo(o);var i=this.clonePosition(),s=P(t,i);return{value:r,location:s}},e.prototype.parseArgumentOptions=function(t,n,r,o){var i,s=this.clonePosition(),u=this.parseIdentifierIfPossible().value,f=this.clonePosition();switch(u){case"":return this.error(H.EXPECT_ARGUMENT_TYPE,P(s,f));case"number":case"date":case"time":{this.bumpSpace();var l=null;if(this.bumpIf(",")){this.bumpSpace();var c=this.clonePosition(),d=this.parseSimpleArgStyleIfPossible();if(d.err)return d;var a=Bn(d.val);if(a.length===0)return this.error(H.EXPECT_ARGUMENT_STYLE,P(this.clonePosition(),this.clonePosition()));var p=P(c,this.clonePosition());l={style:a,styleLocation:p}}var _=this.tryParseArgumentClose(o);if(_.err)return _;var E=P(o,this.clonePosition());if(l&&_t(l==null?void 0:l.style,"::",0)){var y=Pn(l.style.slice(2));if(u==="number"){var d=this.parseNumberSkeletonFromString(y,l.styleLocation);return d.err?d:{val:{type:U.number,value:r,location:E,style:d.val},err:null}}else{if(y.length===0)return this.error(H.EXPECT_DATE_TIME_SKELETON,E);var B=y;this.locale&&(B=_n(y,this.locale));var a={type:Q.dateTime,pattern:B,location:l.styleLocation,parsedOptions:this.shouldParseSkeletons?hn(B):{}},R=u==="date"?U.date:U.time;return{val:{type:R,value:r,location:E,style:a},err:null}}}return{val:{type:u==="number"?U.number:u==="date"?U.date:U.time,value:r,location:E,style:(i=l==null?void 0:l.style)!==null&&i!==void 0?i:null},err:null}}case"plural":case"selectordinal":case"select":{var w=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(H.EXPECT_SELECT_ARGUMENT_OPTIONS,P(w,I({},w)));this.bumpSpace();var M=this.parseIdentifierIfPossible(),m=0;if(u!=="select"&&M.value==="offset"){if(!this.bumpIf(":"))return this.error(H.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,P(this.clonePosition(),this.clonePosition()));this.bumpSpace();var d=this.tryParseDecimalInteger(H.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,H.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);if(d.err)return d;this.bumpSpace(),M=this.parseIdentifierIfPossible(),m=d.val}var g=this.tryParsePluralOrSelectOptions(t,u,n,M);if(g.err)return g;var _=this.tryParseArgumentClose(o);if(_.err)return _;var S=P(o,this.clonePosition());return u==="select"?{val:{type:U.select,value:r,options:bt(g.val),location:S},err:null}:{val:{type:U.plural,value:r,options:bt(g.val),offset:m,pluralType:u==="plural"?"cardinal":"ordinal",location:S},err:null}}default:return this.error(H.INVALID_ARGUMENT_TYPE,P(s,f))}},e.prototype.tryParseArgumentClose=function(t){return this.isEOF()||this.char()!==125?this.error(H.EXPECT_ARGUMENT_CLOSING_BRACE,P(t,this.clonePosition())):(this.bump(),{val:!0,err:null})},e.prototype.parseSimpleArgStyleIfPossible=function(){for(var t=0,n=this.clonePosition();!this.isEOF();){var r=this.char();switch(r){case 39:{this.bump();var o=this.clonePosition();if(!this.bumpUntil("'"))return this.error(H.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE,P(o,this.clonePosition()));this.bump();break}case 123:{t+=1,this.bump();break}case 125:{if(t>0)t-=1;else return{val:this.message.slice(n.offset,this.offset()),err:null};break}default:this.bump();break}}return{val:this.message.slice(n.offset,this.offset()),err:null}},e.prototype.parseNumberSkeletonFromString=function(t,n){var r=[];try{r=cn(t)}catch(o){return this.error(H.INVALID_NUMBER_SKELETON,n)}return{val:{type:Q.number,tokens:r,location:n,parsedOptions:this.shouldParseSkeletons?mn(r):{}},err:null}},e.prototype.tryParsePluralOrSelectOptions=function(t,n,r,o){for(var i,s=!1,u=[],f=new Set,l=o.value,c=o.location;;){if(l.length===0){var d=this.clonePosition();if(n!=="select"&&this.bumpIf("=")){var a=this.tryParseDecimalInteger(H.EXPECT_PLURAL_ARGUMENT_SELECTOR,H.INVALID_PLURAL_ARGUMENT_SELECTOR);if(a.err)return a;c=P(d,this.clonePosition()),l=this.message.slice(d.offset,this.offset())}else break}if(f.has(l))return this.error(n==="select"?H.DUPLICATE_SELECT_ARGUMENT_SELECTOR:H.DUPLICATE_PLURAL_ARGUMENT_SELECTOR,c);l==="other"&&(s=!0),this.bumpSpace();var p=this.clonePosition();if(!this.bumpIf("{"))return this.error(n==="select"?H.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT:H.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT,P(this.clonePosition(),this.clonePosition()));var _=this.parseMessage(t+1,n,r);if(_.err)return _;var E=this.tryParseArgumentClose(p);if(E.err)return E;u.push([l,{value:_.val,location:P(p,this.clonePosition())}]),f.add(l),this.bumpSpace(),i=this.parseIdentifierIfPossible(),l=i.value,c=i.location}return u.length===0?this.error(n==="select"?H.EXPECT_SELECT_ARGUMENT_SELECTOR:H.EXPECT_PLURAL_ARGUMENT_SELECTOR,P(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!s?this.error(H.MISSING_OTHER_CLAUSE,P(this.clonePosition(),this.clonePosition())):{val:u,err:null}},e.prototype.tryParseDecimalInteger=function(t,n){var r=1,o=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(r=-1);for(var i=!1,s=0;!this.isEOF();){var u=this.char();if(u>=48&&u<=57)i=!0,s=s*10+(u-48),this.bump();else break}var f=P(o,this.clonePosition());return i?(s*=r,Hn(s)?{val:s,err:null}:this.error(n,f)):this.error(t,f)},e.prototype.offset=function(){return this.position.offset},e.prototype.isEOF=function(){return this.offset()===this.message.length},e.prototype.clonePosition=function(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}},e.prototype.char=function(){var t=this.position.offset;if(t>=this.message.length)throw Error("out of bound");var n=Et(this.message,t);if(n===void 0)throw Error("Offset ".concat(t," is at invalid UTF-16 code unit boundary"));return n},e.prototype.error=function(t,n){return{val:null,err:{kind:t,message:this.message,location:n}}},e.prototype.bump=function(){if(!this.isEOF()){var t=this.char();t===10?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=t<65536?1:2)}},e.prototype.bumpIf=function(t){if(_t(this.message,t,this.offset())){for(var n=0;n=0?(this.bumpTo(r),!0):(this.bumpTo(this.message.length),!1)},e.prototype.bumpTo=function(t){if(this.offset()>t)throw Error("targetOffset ".concat(t," must be greater than or equal to the current offset ").concat(this.offset()));for(t=Math.min(t,this.message.length);;){var n=this.offset();if(n===t)break;if(n>t)throw Error("targetOffset ".concat(t," is at invalid UTF-16 code unit boundary"));if(this.bump(),this.isEOF())break}},e.prototype.bumpSpace=function(){for(;!this.isEOF()&&yt(this.char());)this.bump()},e.prototype.peek=function(){if(this.isEOF())return null;var t=this.char(),n=this.offset(),r=this.message.charCodeAt(n+(t>=65536?2:1));return r!=null?r:null},e}();function Ie(e){return e>=97&&e<=122||e>=65&&e<=90}function In(e){return Ie(e)||e===47}function An(e){return e===45||e===46||e>=48&&e<=57||e===95||e>=97&&e<=122||e>=65&&e<=90||e==183||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}function yt(e){return e>=9&&e<=13||e===32||e===133||e>=8206&&e<=8207||e===8232||e===8233}function wn(e){return e>=33&&e<=35||e===36||e>=37&&e<=39||e===40||e===41||e===42||e===43||e===44||e===45||e>=46&&e<=47||e>=58&&e<=59||e>=60&&e<=62||e>=63&&e<=64||e===91||e===92||e===93||e===94||e===96||e===123||e===124||e===125||e===126||e===161||e>=162&&e<=165||e===166||e===167||e===169||e===171||e===172||e===174||e===176||e===177||e===182||e===187||e===191||e===215||e===247||e>=8208&&e<=8213||e>=8214&&e<=8215||e===8216||e===8217||e===8218||e>=8219&&e<=8220||e===8221||e===8222||e===8223||e>=8224&&e<=8231||e>=8240&&e<=8248||e===8249||e===8250||e>=8251&&e<=8254||e>=8257&&e<=8259||e===8260||e===8261||e===8262||e>=8263&&e<=8273||e===8274||e===8275||e>=8277&&e<=8286||e>=8592&&e<=8596||e>=8597&&e<=8601||e>=8602&&e<=8603||e>=8604&&e<=8607||e===8608||e>=8609&&e<=8610||e===8611||e>=8612&&e<=8613||e===8614||e>=8615&&e<=8621||e===8622||e>=8623&&e<=8653||e>=8654&&e<=8655||e>=8656&&e<=8657||e===8658||e===8659||e===8660||e>=8661&&e<=8691||e>=8692&&e<=8959||e>=8960&&e<=8967||e===8968||e===8969||e===8970||e===8971||e>=8972&&e<=8991||e>=8992&&e<=8993||e>=8994&&e<=9e3||e===9001||e===9002||e>=9003&&e<=9083||e===9084||e>=9085&&e<=9114||e>=9115&&e<=9139||e>=9140&&e<=9179||e>=9180&&e<=9185||e>=9186&&e<=9254||e>=9255&&e<=9279||e>=9280&&e<=9290||e>=9291&&e<=9311||e>=9472&&e<=9654||e===9655||e>=9656&&e<=9664||e===9665||e>=9666&&e<=9719||e>=9720&&e<=9727||e>=9728&&e<=9838||e===9839||e>=9840&&e<=10087||e===10088||e===10089||e===10090||e===10091||e===10092||e===10093||e===10094||e===10095||e===10096||e===10097||e===10098||e===10099||e===10100||e===10101||e>=10132&&e<=10175||e>=10176&&e<=10180||e===10181||e===10182||e>=10183&&e<=10213||e===10214||e===10215||e===10216||e===10217||e===10218||e===10219||e===10220||e===10221||e===10222||e===10223||e>=10224&&e<=10239||e>=10240&&e<=10495||e>=10496&&e<=10626||e===10627||e===10628||e===10629||e===10630||e===10631||e===10632||e===10633||e===10634||e===10635||e===10636||e===10637||e===10638||e===10639||e===10640||e===10641||e===10642||e===10643||e===10644||e===10645||e===10646||e===10647||e===10648||e>=10649&&e<=10711||e===10712||e===10713||e===10714||e===10715||e>=10716&&e<=10747||e===10748||e===10749||e>=10750&&e<=11007||e>=11008&&e<=11055||e>=11056&&e<=11076||e>=11077&&e<=11078||e>=11079&&e<=11084||e>=11085&&e<=11123||e>=11124&&e<=11125||e>=11126&&e<=11157||e===11158||e>=11159&&e<=11263||e>=11776&&e<=11777||e===11778||e===11779||e===11780||e===11781||e>=11782&&e<=11784||e===11785||e===11786||e===11787||e===11788||e===11789||e>=11790&&e<=11798||e===11799||e>=11800&&e<=11801||e===11802||e===11803||e===11804||e===11805||e>=11806&&e<=11807||e===11808||e===11809||e===11810||e===11811||e===11812||e===11813||e===11814||e===11815||e===11816||e===11817||e>=11818&&e<=11822||e===11823||e>=11824&&e<=11833||e>=11834&&e<=11835||e>=11836&&e<=11839||e===11840||e===11841||e===11842||e>=11843&&e<=11855||e>=11856&&e<=11857||e===11858||e>=11859&&e<=11903||e>=12289&&e<=12291||e===12296||e===12297||e===12298||e===12299||e===12300||e===12301||e===12302||e===12303||e===12304||e===12305||e>=12306&&e<=12307||e===12308||e===12309||e===12310||e===12311||e===12312||e===12313||e===12314||e===12315||e===12316||e===12317||e>=12318&&e<=12319||e===12320||e===12336||e===64830||e===64831||e>=65093&&e<=65094}function Ae(e){e.forEach(function(t){if(delete t.location,it(t)||st(t))for(var n in t.options)delete t.options[n].location,Ae(t.options[n].value);else nt(t)&&ut(t.style)||(rt(t)||ot(t))&&He(t.style)?delete t.style.location:at(t)&&Ae(t.children)})}function Ln(e,t){t===void 0&&(t={}),t=I({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new Nn(e,t).parse();if(n.err){var r=SyntaxError(H[n.err.kind]);throw r.location=n.err.location,r.originalMessage=n.err.message,r}return t!=null&&t.captureLocation||Ae(n.val),n.val}function we(e,t){var n=t&&t.cache?t.cache:jn,r=t&&t.serializer?t.serializer:Fn,o=t&&t.strategy?t.strategy:Un;return o(e,{cache:n,serializer:r})}function Mn(e){return e==null||typeof e=="number"||typeof e=="boolean"}function St(e,t,n,r){var o=Mn(r)?r:n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.call(this,r),t.set(o,i)),i}function Ct(e,t,n){var r=Array.prototype.slice.call(arguments,3),o=n(r),i=t.get(o);return typeof i=="undefined"&&(i=e.apply(this,r),t.set(o,i)),i}function Le(e,t,n,r,o){return n.bind(t,e,r,o)}function Un(e,t){var n=e.length===1?St:Ct;return Le(e,this,n,t.cache.create(),t.serializer)}function Dn(e,t){return Le(e,this,Ct,t.cache.create(),t.serializer)}function Gn(e,t){return Le(e,this,St,t.cache.create(),t.serializer)}var Fn=function(){return JSON.stringify(arguments)};function Me(){this.cache=Object.create(null)}Me.prototype.get=function(e){return this.cache[e]},Me.prototype.set=function(e,t){this.cache[e]=t};var jn={create:function(){return new Me}},Ue={variadic:Dn,monadic:Gn},ee;(function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"})(ee||(ee={}));var le=function(e){ue(t,e);function t(n,r,o){var i=e.call(this,n)||this;return i.code=r,i.originalMessage=o,i}return t.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},t}(Error),Tt=function(e){ue(t,e);function t(n,r,o,i){return e.call(this,'Invalid values for "'.concat(n,'": "').concat(r,'". Options are "').concat(Object.keys(o).join('", "'),'"'),ee.INVALID_VALUE,i)||this}return t}(le),Vn=function(e){ue(t,e);function t(n,r,o){return e.call(this,'Value for "'.concat(n,'" must be of type ').concat(r),ee.INVALID_VALUE,o)||this}return t}(le),kn=function(e){ue(t,e);function t(n,r){return e.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(r,'"'),ee.MISSING_VALUE,r)||this}return t}(le),k;(function(e){e[e.literal=0]="literal",e[e.object=1]="object"})(k||(k={}));function $n(e){return e.length<2?e:e.reduce(function(t,n){var r=t[t.length-1];return!r||r.type!==k.literal||n.type!==k.literal?t.push(n):r.value+=n.value,t},[])}function Xn(e){return typeof e=="function"}function ce(e,t,n,r,o,i,s){if(e.length===1&&tt(e[0]))return[{type:k.literal,value:e[0].value}];for(var u=[],f=0,l=e;f0?new Intl.Locale(n[0]):new Intl.Locale(typeof t=="string"?t:t[0])}},e.__parse=Ln,e.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},e}();function Zn(e,t={},n="zh-CN",r={}){return!r||!r[n]||!r[n][e]?"":new zn(r[n][e],n).format(t)}const Ot=()=>{};function Yn(e){const t={};for(const n of e)G(n)&&n.length>=2&&(t[n[0]]=n[1]);return t}function Rt(e,t){let n=null;return t?function(){n&&clearTimeout(n),n=setTimeout(()=>{n=null,e.apply(this)},t)}:function(){n||(n=setTimeout(()=>{n=null,e.apply(this)}))}}const Ge=e=>Object.prototype.toString.call(e);function Kn(e){return new Promise(t=>setTimeout(t,e))}const Fe=e=>{const t=new Set(q(e)?e.split(","):G(e)?e:[]),n=A(e)?e:r=>t.has(r);return r=>{const o=Object.keys(r);if(o.every(f=>!n(f)))return[{},r,0];let i=0;const s={},u={};for(const f of o)n(f)?(s[f]=r[f],i++):u[f]=r[f];return[s,u,i]}};function J(e){return e==null}function Ht(e){return e===void 0}function q(e){return typeof e=="string"}function D(e){return!J(e)&&typeof e=="object"}function vt(e){return typeof e=="boolean"}function G(e){return Array.isArray(e)}function A(e){return typeof e=="function"}function je(e){return D(e)&&A(e.then)&&A(e.catch)}function W(e){return!J(e)&&Ge(e)==="[object Object]"}function Qn(e){return e&&(Reflect.get(e,"__esModule")||Reflect.get(e,Symbol.toStringTag)==="Module")}function fe(e){return e?D(e)&&(e.type==="JSFunction"||e.extType==="function"):!1}function pe(e){return D(e)&&e.type==="JSSlot"}function oe(e){return D(e)&&e.type==="JSExpression"&&e.extType!=="function"}function Ve(e){return D(e)&&e.type==="i18n"}function de(e){return e&&e.componentName}function ke(e){return de(e)&&e.componentName==="Slot"}function er(e){return de(e)&&(e.componentName==="Block"||e.componentName==="Page"||e.componentName==="Component")}var te=function(e){return e[e.Environment=1]="Environment",e[e.Library=2]="Library",e[e.Theme=3]="Theme",e[e.Runtime=4]="Runtime",e[e.Components=5]="Components",e[e.App=6]="App",e}({});te.Environment,te.Library,te.Theme,te.Runtime,te.Components,te.App;function me(e){return e&&e.replace(/-[a-zA-Z]/g,t=>t.charAt(1).toLocaleUpperCase())}$e=void 0;var tr=function(e){return e.Render="render",e.Serilize="serilize",e.Save="save",e.Clone="clone",e.Init="init",e.Upgrade="upgrade",e}({}),$e=tr;function Xe(e){if(D(e)){if(A(e.export))return e.export($e.Render);if(A(e.exportSchema))return e.exportSchema($e.Render)}return null}function ne(e){console.warn("[vue-renderer]: "+e)}const Pt={};function nr(e){!Pt[e]&&(Pt[e]=!0)&&ne(e)}var F=(e=>(e[e.OTHER=0]="OTHER",e[e.SETUP=1]="SETUP",e[e.DATA=2]="DATA",e[e.PROPS=3]="PROPS",e[e.CONTEXT=4]="CONTEXT",e))(F||{});function Bt(e,t){switch(t){case 1:return e.$.setupState.__lcSetup?e.$.setupState:e.$.setupState=h.proxyRefs(Object.create(null,{__lcSetup:{get:()=>!0,enumerable:!1,configurable:!1}}));case 2:return h.isReactive(e.$.data)?e.$.data:e.$.data=h.reactive({});case 3:return e.$.props;default:return e.$.ctx}}function V(e,t,n,r,o=!0){const i=e.$,s=Bt(e,t);if(r){const u=Object.getOwnPropertyDescriptors(n);for(const f in u){if(f in s){ne("重复定义 key: "+f);continue}Object.defineProperty(s,f,u[f]),i.accessCache[f]=t}}else for(const u in n){if(u in s){ne("重复定义 key: "+u);continue}s[u]=Reflect.get(n,u),i.accessCache[u]=t}if(t===3&&Object.keys(n).length>0&&o){const{propsOptions:[u,f]}=i,l={},c=[];for(const d in n){if(u[d])continue;const a=Reflect.get(n,d);vt(a)?(l[d]={0:!0,1:!0,type:Boolean,default:a},c.push(d)):Ht(a)?l[d]={0:!1,1:!1,type:null}:(l[d]={0:!0,1:!1,type:null,default:a},c.push(d))}Object.keys(l).length>0&&(i.propsOptions=[{...u,...l},[...f,...c]])}}function Je(e){return"$"in e}function rr(e){return!e||!D(e)?!1:!!(Je(e)||Object.keys(e).length>0)}function ie(...e){const t=[];if(e.flat().forEach(o=>{rr(o)&&t.push(o)}),t.length<=1)return t[0];const[n,...r]=t;return r.reduce((o,i)=>{if(Je(i)){if(Je(o))return i;{const u=o;o=i,i=u}}const s=Object.getOwnPropertyDescriptors(i);return o=Object.create(o,s),h.isProxy(i)?h.reactive(o):o},n)}function z(e){return e?G(e)?e:[e]:[]}const or={JSEXPRESSION:"JSExpression",JSFUNCTION:"JSFunction",JSSLOT:"JSSlot",JSBLOCK:"JSBlock",I18N:"i18n"},Ke=class{constructor(t){re(this,"createFunction");re(this,"exports",{});this.createFunction=t&&!t.thisRequired?n=>new Function("__exports__","__scope__",`with(__exports__) { with(__scope__) { ${n} } }`):n=>new Function("__exports__",`with(__exports__) { ${n} }`)}static cleanCachedModules(){this.cacheModules={}}initModule(t){var o;const n=(o=t.lifeCycles)==null?void 0:o.initModule,r=n&&this.parseSchema(n,!1);return this.exports=A(r)?r(Ke.cacheModules,window):{},this}parseSlotScope(t,n){const r={};return z(n).forEach((o,i)=>{r[o]=t[i]}),r}parseI18n(t,n){return this.parseExpression({type:or.JSEXPRESSION,value:`this.$t(${JSON.stringify(t.key)})`},n)}parseSchema(t,n){if(oe(t)||fe(t))return this.parseExpression(t,n);if(Ve(t))return this.parseI18n(t,n);if(q(t))return t.trim();if(G(t))return t.map(r=>this.parseSchema(r,n));if(A(t))return t.bind(n);if(W(t)){if(!t)return t;const r={};return Object.keys(t).forEach(o=>{o.startsWith("__")||(r[o]=this.parseSchema(t[o],n))}),r}return t}parseOnlyJsValue(t){if(!(oe(t)||Ve(t))){{if(fe(t))return this.parseExpression(t,!1);if(G(t))return t.map(n=>this.parseOnlyJsValue(n));if(W(t))return Object.keys(t).reduce((n,r)=>(r.startsWith("__")||(n[r]=this.parseOnlyJsValue(t[r])),n),{})}return t}}parseExpression(t,n){try{const r=['"use strict";'];let o;return o=(t.value||"").trim(),n!==!1&&!o.match(/^\([^)]*\)\s*=>/)&&(o=o.replace(/this(\W|$)/g,(s,u)=>`__self${u}`),r.push("var __self = arguments[1];")),r.push("return "),o=r.join(` 4 | `)+o,this.createFunction(o)(this.exports,n||{})}catch(r){console.warn("parseExpression.error",r,t,self);return}}};let K=Ke;re(K,"cacheModules",{});function ir(){let e=window.__currentNode;return e||(e=Symbol("__currentNode"),window.__currentNode=e),e}function Nt(){let e=window.__rendererContext;return e||(e=Symbol("__rendererContext"),window.__rendererContext=e),e}function _e(){const e=Nt();return h.inject(e,()=>{var t,n;const r=(n=(t=h.getCurrentInstance())==null?void 0:t.props)!=null?n:{};return{rerender:()=>{},thisRequiredInJSE:!0,components:be(r,"components",{}),designMode:be(r,"designMode","live"),getNode:be(r,"getNode",()=>null),wrapLeafComp:(o,i,s)=>s,triggerCompGetCtx:be(r,"triggerCompGetCtx",()=>{})}},!0)}function be(e,t,n){return e[t]||e[`__${t}`]||n}const It=Symbol("hocNode"),sr=e=>{const{rerender:t}=_e(),n=h.inject(It,null),r=Rt(e);return h.provide(It,{rerenderSlots:r}),n?{rerender:r,rerenderRoot:t,rerenderParent:n.rerenderSlots}:{rerender:r,rerenderRoot:t,rerenderParent:t}},ar=h.defineComponent({name:"Hoc",inheritAttrs:!1,props:ae,setup(e,{slots:t,attrs:n}){const r=h.shallowRef(!0),o=h.shallowRef(e.__schema),i=h.shallowRef(),s=y=>{o.value=y,i.value=qt(y,a).slots},{rerender:u,rerenderRoot:f,rerenderParent:l}=sr(()=>{const y=a?Xe(a):null;y&&s(y)}),c={};h.onUnmounted(()=>Object.keys(c).forEach(y=>{c[y](),delete c[y]}));const{locked:d,node:a,buildSlots:p,getNode:_,isRootNode:E}=ze(e,(y,B)=>{const R=y.id;if(R){if(B&&c[R])c[R](),delete c[R];else if(!B&&!c[R]){const w=_(R);if(w){const M=w.onVisibleChange(()=>u()),m=w.onPropChange(()=>u());c[R]=()=>{M(),m()}}}}});if(a){const y=a.onChildrenChange(()=>{f()});y&&h.onUnmounted(y),h.onUnmounted(a.onPropChange(B=>{const{key:R,prop:w,newValue:M,oldValue:m}=B;w.path.length===1?R==="___isLocked___"?d.value=M:pe(M)||pe(m)?f():l():l()})),h.onUnmounted(a.onVisibleChange(B=>{E?r.value=B:l()})),s(Xe(a))}return h.watch(()=>e.__schema,y=>s(y)),()=>{var m;const y=h.toRaw(e.__comp),B=h.toRaw(e.__scope),R={...e.__vnodeProps},w=Zt(n)[1];if(E&&!r.value)return null;const M=i.value?p(i.value,B,a):t;return y?ge(y)?h.h(h.Fragment,(m=M.default)==null?void 0:m.call(M)):h.h(y,h.mergeProps(w,R),M):h.h("div","component not found")}}}),ur=h.defineComponent({inheritAttrs:!1,props:ae,setup:(e,{attrs:t,slots:n})=>()=>{const r=h.toRaw(e.__comp),o={...e.__vnodeProps},i=Zt(t)[1];return ge(r)?h.renderSlot(n,"default",t):r?h.h(r,h.mergeProps(i,o),n):null}});function At(e){const t=[];return Object.keys(e).forEach(n=>{const r=e[n];r==null||r===""||(typeof r=="object"?t.push(`${n}=${encodeURIComponent(JSON.stringify(r))}`):t.push(`${n}=${encodeURIComponent(String(r))}`))}),t.join("&")}function hr(e,t){if(!t)return e;const n=At(t);return n?e.indexOf("?")>0?`${e}&${n}`:`${e}?${n}`:e}function lr(e,t){for(const n in e)if(n.toLowerCase()===t)return[e[n],n];return[]}function cr(e){return q(e)&&["arrayBuffer","blob","formData","json","text"].includes(e)}function fr(e){const t=new FormData;for(const n in e){const r=e[n];r instanceof Blob?t.append(n,r):t.append(n,String(r))}return t}const wt={"application/json":e=>JSON.stringify(e),"multipart/form-data":e=>W(e)?fr(e):e,"application/x-www-form-urlencoded":e=>At(e)};function pr(e,t){const n=Object.keys(wt).find(r=>e.includes(r));return n?wt[n](t):t}class se extends Error{constructor(t,n,r){super(t),this.code=n,this.data=r}}class Lt{constructor(t,n){this.code=t,this.data=n}}async function Mt(e){const{uri:t,method:n,timeout:r,params:o={},headers:i={},isCors:s,responseType:u="json",...f}=e;let l;const c={Accept:"application/json",...i},d={method:n,headers:c,credentials:"include",...f};if(s&&(d.mode="cors"),n==="GET"||n==="DELETE"||n==="OPTIONS")l=hr(t,o);else{l=t;const[_,E]=lr(c,"content-type");d.body=pr(_!=null?_:"application/json",o),_==="multipart/form-data"&&E&&delete c[E]}if(r){const _=new AbortController;d.signal=_.signal,setTimeout(()=>_.abort(),r)}const a=await fetch(l,d),p=a.status;if(p>=200&&p<300)if(p===204){if(n==="DELETE")return new Lt(p,null);throw new se(a.statusText,p)}else{if(!cr(u))throw new se(`invalid response type: ${u}`,-1);return new Lt(p,await a[u]())}else if(p>=400)try{const _=await a.json();throw new se(a.statusText,p,_)}catch(_){throw new se(a.statusText,p)}throw new se(a.statusText,p)}function dr(e,{state:t,setState:n},r){const o=h.shallowRef(),i=h.shallowRef(),s=h.ref("init"),u=h.computed(()=>s.value==="loading"),f=h.computed(()=>e.isInit?Ee(e.isInit,t):!1),l=h.computed(()=>e.isSync?Ee(e.isSync,t):!1),{willFetch:c=mr,shouldFetch:d=_r,dataHandler:a=E=>E&&Reflect.get(E,"data"),errorHandler:p=br}=e,_=async(E,y={})=>{try{const{type:B,options:R,id:w}=e,M=Er(e,r);if(!M)throw new Error("unsupport fetch type: "+B);if(!d())throw new Error(`the ${w} request should not fetch, please check the condition`);const{inputHeaders:m={},assignToScope:g=!0,...S}=y;s.value="loading";const{params:T,headers:N,...b}=Ee(R,t),x=await c({...b,...S,params:W(T)&&W(E)?{...T,...E}:E!=null?E:T,headers:{...W(N)?N:{},...W(m)?m:{}}}),v=await M(x,{state:t,setState:n}),C=o.value=a(v);return!Ht(C)&&g&&n({[w]:C}),s.value="loading",C}catch(B){s.value="error",i.value=B,p(B)}};return h.reactive({data:o,error:i,loading:u,status:s,isInit:f,isSync:l,load:_})}const mr=e=>e,_r=()=>!0,br=e=>{throw e};function Ee(e,t){return A(e)?e.call(t,t):W(e)?Object.keys(e).reduce((n,r)=>(Reflect.set(n,r,Ee(e[r],t)),n),{}):e}function Er(e,t){var n,r;const{type:o,requestHandler:i}=e;return o?o==="custom"&&i?i:o==="fetch"?(n=t[o])!=null?n:Mt:(r=t[o])!=null?r:null:Mt}function gr(e,t,n={}){const r={},o={},{list:i,dataHandler:s}=e;for(const l of i){const c={dataHandler:s,...l},d=dr(c,t,n),a=(p,_)=>{const E={assignToScope:!1,..._};return d.load(p,E)};r[l.id]=a,o[l.id]=d}return{dataSource:r,dataSourceMap:o,reloadDataSource:(l,c,d)=>{if(l){const E=o[l];if(!E)throw new Error("dataSource not found, id: "+l);return E.load(c,d)}const a=[],p=[];Object.keys(o).map(E=>o[E]).filter(E=>E.isInit).forEach(E=>{E.isSync?a.push(E):p.push(E)});const _=[...p.map(E=>E.load()),a.reduce((E,y)=>E.then(()=>y.load()),Promise.resolve(null))];return Promise.all(_)},shouldInit:()=>Object.keys(o).some(l=>o[l].isInit)}}function xr(e,t,n){const r=t.__parser,o=r.parseSchema(e.dataHandler,t),i=e.list.map(({isInit:s=!1,isSync:u=!1,requestHandler:f,dataHandler:l,errorHandler:c,willFetch:d,shouldFetch:a,options:p,..._})=>({...r.parseSchema(_,t),isInit:Ut(s,r,t),isSync:Ut(u,r,t),requestHandler:r.parseSchema(f,t),dataHandler:r.parseSchema(l,t),errorHandler:r.parseSchema(c,t),willFetch:r.parseSchema(d,t),shouldFetch:r.parseSchema(a,t),options:()=>r.parseSchema(p,t)}));return gr({list:i,dataHandler:o},{state:t,setState(s){const u={};for(const f in s)f in t?t[f]=s[f]:u[f]=s[f];Object.keys(u).length>0&&(V(t,F.CONTEXT,u),t.$forceUpdate())},forceUpdate:()=>t.$forceUpdate()},n)}function Ut(e,t,n){return oe(e)?t.parseSchema({type:"JSFunction",value:`function () { return ${e.value} }`},n):fe(e)?t.parseSchema(e,n):e}function yr(e,t,n){const r=e.parseSchema(t,!1);if(!W(r))return;const o={};for(const i in r){const s=r[i],u=A(s)?s.bind(n):A(s.get)?s.get.bind(n):Ot,f=!A(s)&&A(s.set)?s.set.bind(n):Ot,l=h.computed({get:u,set:f});Object.defineProperty(o,i,{enumerable:!0,configurable:!0,get:()=>l.value,set:c=>l.value=c})}V(n,F.CONTEXT,o,!0)}function Dt(e){const t=e&&e.toString().match(/^\s*function (\w+)/);return t?t[1]:e===null?"null":""}function Gt(e,t){return Dt(e)===Dt(t)}function Ft(e,t){return G(t)?t.findIndex(n=>Gt(n,e)):A(t)&&Gt(t,e)?0:-1}function Sr(e,t,n){const r=e.parseSchema(t,!1);if(!r||!D(r)&&!G(r)||D(r)&&Object.keys(r).length===0||G(r)&&r.length===0)return;const o=n.$,{propsOptions:[i,s]}=o,u={},f=[];for(const l in r){const c=r[l];let d,a;if(q(c)?(d=me(c),a={}):(d=me(l),a=G(c)||A(c)?{type:c}:c),i[d]){ne("prop "+d+"声明重复");continue}const p=Ft(Boolean,a.type),_=Ft(String,a.type);u[d]={0:p>-1,1:_<0||p<_,...a},(p>-1||"default"in a)&&f.push(d)}if(Object.keys(u).length>0){o.propsOptions=[{...i,...u},[...s,...f]];const{props:l,attrs:c}=o,d=Object.keys(u).reduce((a,p)=>(a[p]=Cr(u,{...l,...a},p,c[p],o,f.includes(p)),a),{});Object.keys(d).length>0&&V(n,F.PROPS,d,!1,!1)}}function Cr(e,t,n,r,o,i){const s=e[n];if(s!=null){const u=Reflect.has(s,"default");if(u&&r===void 0){const f=s.default;if(s.type!==Function&&!s.skipFactory&&A(f)){const{propsDefaults:l}=o;n in l?r=l[n]:r=l[n]=h.withCtx(()=>f.call(null,t),o)()}else r=f}s[0]&&(i&&!u?r=!1:s[1]&&(r===""||r===Rr(n))&&(r=!0))}return r}const Tr=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},Or=/\B([A-Z])/g,Rr=Tr(e=>e.replace(Or,"-$1").toLowerCase());function Hr(e,t,n){const r=e.parseSchema(t,!1),o=G(r)?r.reduce((i,s)=>(i[s]=null,i),{}):D(r)?r:null;!o||Object.keys(o).length===0||(n.$.emitsOptions=Object.create(n.$.emitsOptions,Object.getOwnPropertyDescriptors(o)))}function vr(e,t,n){const r=e.parseSchema(t,!1),o=A(r)?r.call(n):D(r)?r:null;!o||Object.keys(o).length===0||V(n,F.DATA,o)}function Pr(e,t){const n=t.split(".");return()=>{let r=e;for(let o=0;on[r];if(q(e)){const i=t[e];A(i)?h.watch(o,i):h.warn(`Invalid watch handler specified by key "${e}"`,i)}else if(A(e))h.watch(o,e.bind(n));else if(D(e))if(G(e))e.forEach(i=>jt(i,t,n,r));else{const i=A(e.handler)?e.handler.bind(n):q(e.handler)?t[e.handler]:null;A(i)?h.watch(o,i,e):h.warn(`Invalid watch handler specified by key "${e.handler}"`,i)}else h.warn(`Invalid watch option: "${r}"`,e)}function Br(e,t,n){const r=e.parseSchema(t,!1);if(!r||!D(r)||Object.keys(r).length===0)return;const o=Bt(n,F.CONTEXT);for(const i in r)jt(r[i],o,n,i)}function Nr(e,t,n){const r=e.parseSchema(t,!1);let o;if(G(r))o=r.reduce((s,u)=>(s[u]=u,s),{});else if(D(r))o=r;else return;const i={};for(const s in o){const u=o[s];let f;if(D(u)){const l=u.from||s;"default"in u?f=h.inject(l,u.default,!0):f=h.inject(l)}else f=h.inject(u);h.isRef(f)?Object.defineProperty(i,s,{enumerable:!0,configurable:!0,get:()=>f.value,set:l=>f.value=l}):i[s]=f}V(n,F.CONTEXT,i,!0)}function Ir(e,t,n){const r=e.parseSchema(t,n),o=A(r)?r():r;D(o)&&Reflect.ownKeys(o).forEach(i=>{const s=Reflect.get(o,i);h.provide(i,s)})}function Ar(e,t,n,[r,o]){const i=e.parseSchema(t,!1);if(!A(i))return;const s=i.apply(void 0,[r,o]);if(je(s))return s.then(u=>Vt(u,n));Vt(s,n)}function Vt(e,t){if(!J(e)){if(!D(e)){ne("不支持的 setup 返回值类型, type: "+Ge(e));return}V(t,F.SETUP,h.toRaw(e))}}function wr(e,t,n){const r=e.parseSchema(t,!1);A(r)&&r.call(n)}function Lr(e,t,n){const r=e.parseSchema(t,!1);A(r)&&r.call(n)}const kt=Symbol(),$t=e=>void(e[kt]=!0),qe=e=>kt in e,Mr=e=>A(e),Ur=["beforeRouteEnter","beforeRouteUpdate","beforeRouteLeave"],Xt=Symbol("LOWCODE_ROUTE_META");function Dr(e){const t=e.split(".");return n=>{let r=n;for(let o=0;o0?Object.create(d,Object.getOwnPropertyDescriptors(_)):d}function s(c,d){return d.length<3?function(a,p){const _=o(this);return u(d.call(_,a,p))}:function(a,p,_){const E=o(this);return u(d.call(E,a,p,_))}}const u=c=>A(c)?async d=>{let a;const p=Date.now();for(;!(a=o(d));){if(Date.now()-p>=n)throw new Error("lowcode guard wait timeout");await Kn()}return c(a)}:je(c)?c.then(u):c;return e.beforeEach((c,d,a)=>{if(c.matched.every(p=>qe(p)))return a();Promise.all(c.matched.map(async p=>{var B;if(qe(p))return;const _=(B=p.components)!=null?B:{},E=_.default,y=p.meta[Xt];if(E&&er(y)){let R;Mr(E)?(R=await E(),Qn(R)&&(R=R.default)):R=E,_.default=i(p,R,y,r.initModule(y))}$t(p)})).then(()=>a())})}const Fr={setup:Ar,created:wr,beforeCreate:Lr,initInject:Nr,initProvide:Ir,initEmits:Hr,initProps:Sr,initData:vr,initWatch:Br,initComputed:yr};function jr(e,t,n){function r(o,i,s){var c;const f=((c=e.lifeCycles)!=null?c:{})[o],l=Fr[o];if(f&&l)return l(n,f,t,[i,s])}return r}const Vr=ir(),kr={beforeMount:h.onBeforeMount,mounted:h.onMounted,beforeUpdate:h.onBeforeUpdate,updated:h.onUpdated,activated:h.onActivated,deactivated:h.onDeactivated,beforeUnmount:h.onBeforeUnmount,renderTracked:h.onRenderTracked,renderTriggered:h.onRenderTriggered,unmounted:h.onUnmounted,errorCaptured:h.onErrorCaptured,serverPrefetch:h.onServerPrefetch},$r={componentDidMount:h.onMounted,componentDidCatch:h.onErrorCaptured,shouldComponentUpdate:h.onBeforeUpdate,componentWillUnmount:h.onBeforeUnmount},We={...kr,...$r};function ge(e){return e===h.Fragment}function Xr(e){return e in We}function Jr(e){const t={};if(D(e))for(const n in e)n in We&&(t[n]=e[n]);return t}const Jt=Symbol("IS_LOCKED"),xe=Symbol("IS_ROOT_NODE");function qr(e){const t=h.ref(e),n=h.inject(Jt,null),r=h.computed({get:()=>(n==null?void 0:n.value)||t.value,set:o=>t.value=o});return h.provide(Jt,r),r}function Wr(e){return e?h.provide(xe,!0):(e=h.inject(xe,null),e==null?h.provide(xe,e=!0):e&&h.provide(xe,!1)),e}function ze(e,t=()=>{}){const n=_e(),{getNode:r,wrapLeafComp:o,designMode:i,thisRequiredInJSE:s}=n,u=new K({thisRequired:s}),f=e.__schema.id?r(e.__schema.id):null,l=f?qr(f.isLocked):h.ref(!1),c=i==="design";h.provide(Vr,{mode:i,node:f,isDesignerEnv:c});const d=(m,g,S,T)=>{var Te;if(q(m))return h.createTextVNode(m);if(J(m))return null;if(!de(m)){const $=u.parseSchema(m,S);return h.createTextVNode(h.toDisplayString($))}const{show:N,scence:b}=M(m,S,c);if(!N)return h.createCommentVNode(`${b} ${N}`);const x=m.id?r(m.id):null,{componentName:v}=m;if(!T&&(T=n.components[v],!T)){if(v==="Slot")return z(m.children).flatMap($=>d($,g,S)).filter($=>!J($));if(c)return h.h("div",`component[${v}] not found`);T={setup($,{slots:Y}){return nr("组件未找到, 组件名:"+v),h.h("div",h.mergeProps($,{class:"lc-component-not-found"}),Y)}}}g=o(v,T,g);const C=$=>{n.triggerCompGetCtx(m,$)},{props:O,slots:j}=qt(m),{loop:Z,buildLoopScope:Ce}=w(m,S);if(!Z){const $=R(O,S,x,null,{ref:C}),[Y,Qe]=zt($);return h.h(g,{key:(Te=Y.key)!=null?Te:m.id,__comp:T,__scope:S,__schema:m,__vnodeProps:Y,...Qe},E(j,S,x))}return G(Z)?Z.map(($,Y,Qe)=>{var nn;const Qt=Ce($,Y,Qe.length),so=R(O,S,x,Qt,{ref:C}),[en,ao]=zt(so),tn=ie(S,Qt);return h.h(g,{key:(nn=en.key)!=null?nn:`${m.id}--${Y}`,__comp:T,__scope:tn,__schema:m,__vnodeProps:en,...ao},E(j,tn,x))}):(ne("循环对象必须是数组, type: "+Ge(Z)),null)},_=c?(m,g,S)=>{const T=d(m,ar,g,S);return de(m)&&h.isVNode(T)&&(T.type===h.Comment?t(m,!1):t(m,!0)),T}:(m,g,S)=>d(m,ur,g,S),E=(m,g,S)=>Object.keys(m).reduce((T,N)=>{let b=m[N];const x=N==="default";if(J(b)&&!x||x&&!(S!=null&&S.isContainerNode)&&(G(b)&&b.length===0||J(b)))return T;let v;return G(b)&&b.length===0&&(b=b[0]),G(b)?v=Ze(b,C=>()=>C.map(O=>_(O,g)).filter(O=>!J(O))):ke(b)?v=Ze(b,C=>(...O)=>{var Z;const j=_(C,ie(g,u.parseSlotScope(O,(Z=C.params)!=null?Z:[])));return z(j)}):v=Ze(b,C=>()=>z(_(C,g))),T[N]=x&&c&&(S!=null&&S.isContainerNode)?Zr(v,l):v,T},{}),y=(m,g,S,T,N)=>{var x,v;const b=T?N==null?void 0:N.getProp(T,!1):null;if(oe(m)||fe(m))return u.parseExpression(m,g);if(Ve(m))return u.parseI18n(m,g);if(pe(m)){let C,O;return b!=null&&b.slotNode?(O=b.slotNode.schema,C=ke(O)?(x=O.params)!=null?x:[]:[]):(O=z(m.value),C=(v=m.params)!=null?v:[]),(...j)=>{const Z=u.parseSlotScope(j,C),Ce=[];return z(O).forEach(Te=>{const $=_(Te,ie(g,S,Z));z($).forEach(Y=>Ce.push(Y))}),Ce}}else{if(G(m))return m.map((C,O)=>y(C,g,S,`${T}.${O}`,N));if(m&&D(m)){const C={};return Object.keys(m).forEach(O=>{if(O.startsWith("__"))return;const j=m[O];C[O]=y(j,g,S,`${T}.${O}`,N)}),C}}return m},B=(m,g,S,T,N)=>{if(q(m)){const b=m;let x=null;return v=>{let C=g.$.refs;if(Object.keys(C).length===0&&(C=g.$.refs={}),J(g.__loopRefIndex))C[b]=v,b in g&&(g[b]=v);else{let O=C[b];if(!G(O))O=C[b]=[],b in g&&(O=g[b]=O);else if(b in g){const j=g[b];!G(j)||h.toRaw(j)!==O?O=g[b]=O:O=j}if(J(v)){const j=O.indexOf(x);j>=0&&O.splice(j,1)}else O[g.__loopRefIndex]=v}x=v}}else{const b=y(m,g,S,T,N);return q(b)?B(b,g,S,T,N):b}},R=(m,g,S,T,N)=>{const b={};Object.keys(m).forEach(C=>{Wt(b,C,m[C])});const x={},v=T?ie(g,T):g;return Object.keys(b).forEach(C=>{const O=b[C];x[C]=C==="ref"?B(O,v,T,C,S):y(O,v,T,C,S)}),N&&Object.keys(N).forEach(C=>{Wt(x,C,N[C])}),x},w=(m,g)=>{let S=null;const T=["item","index"];return m.loop&&(S=m.loop),m.loopArgs&&m.loopArgs.forEach((N,b)=>{T[b]=N}),{loop:S?u.parseSchema(S,g):null,loopArgs:T,buildLoopScope(N,b,x){var j;const v=(j=g.__loopRefOffset)!=null?j:0,[C,O]=T;return{[C]:N,[O]:b,__loopScope:!0,__loopRefIndex:v+b,__loopRefOffset:x*b}}}},M=(m,g,S)=>{var b,x;const T=S&&(b=m.hidden)!=null?b:!1,N=(x=m.condition)!=null?x:!0;return T?{scence:"hidden",show:!1}:{scence:"condition",show:typeof N=="boolean"?N:!!u.parseSchema(N,g)}};return{node:f,locked:l,isRootNode:Wr(e.__isRootNode),getNode:r,renderComp:_,buildProps:R,buildSlots:E}}function ye(e,t){const n=h.computed(()=>e.__schema),r={__comp:null,__scope:t,__isRootNode:!0,__vnodeProps:{},__schema:e.__schema},o=h.computed(()=>{var s;return(s=e.__designMode)!=null?s:"live"}),i=h.computed(()=>e.__components);return{scope:t,schemaRef:n,designModeRef:o,componentsRef:i,...ze(r)}}function Se(e,t){var N;const{__schema:n,__scope:r,__parser:o,__appHelper:i,__requestHandlersMap:s}=e,{props:u,state:f,methods:l,lifeCycles:c}=n!=null?n:{},d=h.getCurrentInstance(),a=d.proxy,p=jr(n,a,o);if(p("initEmits"),p("beforeCreate"),p("initProps"),u){const b=o.parseOnlyJsValue(u);V(a,F.PROPS,b)}const _=p("setup",d.props,t);if(p("initInject"),l){const b=o.parseSchema(l,a);b&&V(a,F.CONTEXT,b)}if(p("initData"),f){const b=o.parseSchema(f);b&&V(a,F.DATA,b)}p("initComputed"),p("initWatch"),p("initProvide");const E=o.parseSchema(Jr(c),a);Object.keys(E).length>0&&Object.keys(E).forEach(b=>{if(Xr(b)){const x=E[b];A(x)&&We[b](x,d)}}),zr(n.css,n.id);const y=(b,x)=>{const{__locale:v,__messages:C}=e;return Zn(b,x,v,C)},B=h.computed(()=>e.__locale);V(a,F.CONTEXT,{i18n:y,$t:y}),V(a,F.DATA,{currentLocale:B});const{dataSource:R,dataSourceMap:w,reloadDataSource:M,shouldInit:m}=xr((N=n.dataSource)!=null?N:{list:[],dataHandler:void 0},a,s),g=Object.keys(w).filter(b=>!(b in a)).map(b=>[b,h.ref()]);V(a,F.CONTEXT,{dataSource:R,dataSourceMap:w,reloadDataSource:M}),V(a,F.SETUP,Yn(g)),r&&V(a,F.SETUP,r),p("created");const S=b=>{const x=[];return je(_)&&x.push(_),m()&&x.push(M()),x.length>0?Promise.all(x).then(()=>b):b};V(a,F.CONTEXT,{__loopScope:!1,__loopRefIndex:null,__loopRefOffset:0}),V(a,F.CONTEXT,Object.keys(i).reduce((b,x)=>{const v=x.startsWith("$")?x:"$"+x;return b[v]=i[x],b},{}));const T={_:!0,$:!0};return{scope:new Proxy({},{get(b,x){return x===Symbol.toStringTag?"[object RuntimeScope]":x===Symbol.unscopables?T:Reflect.get(a,x,a)},set(b,x,v){return Reflect.set(a,x,v,a)},has(b,x){return Reflect.has(a,x)},defineProperty(b,x,v){return Reflect.defineProperty(a,x,v)},ownKeys:()=>Array.from(new Set([...Reflect.ownKeys(a.$.props),...Reflect.ownKeys(a.$.data),...Reflect.ownKeys(a.$.setupState),...Reflect.ownKeys(a.$.ctx)]))}),wrapRender:S}}function zr(e,t){var r;let n=null;t&&(n=document.querySelector(`style[data-id="${t}"]`)),e?(n||(n=document.createElement("style"),t&&n.setAttribute("data-id",t),(document.head||document.getElementsByTagName("head")[0]).appendChild(n)),n.innerHTML!==e&&(n.innerHTML=e)):n&&((r=n.parentElement)==null||r.removeChild(n))}const qt=(e,t)=>{var i;const n={},r={};n.default=G(e.children)&&e.children.length===1?e.children[0]:e.children;const o=s=>s==="children"?"default":s;return Object.entries((i=e.props)!=null?i:{}).forEach(([s,u])=>{if(pe(u)){const f=t==null?void 0:t.getProp(s,!1);if(f&&f.slotNode){const l=f.slotNode.schema;ke(l)&&(n[o(s)]=l)}else u.value&&(n[o(s)]={componentName:"Slot",params:u.params,children:u.value})}else s==="className"?r.class=u:s==="children"?n.default=u:r[s]=u}),{props:r,slots:n}},Ze=(e,t)=>t(e),Wt=(e,t,n)=>{var r;if(t.startsWith("v-model")){const o=t.match(/v-model(?::(\w+))?$/);if(!o)return e;const i=me((r=o[1])!=null?r:"modelValue"),s=`onUpdate:${i}`;if(oe(n)){const u={type:"JSFunction",value:`function ($event) {${n.value} = $event}`};e[s]=s in e?z(e[s]).concat(u):u}e[i]=n}else if(!t.startsWith("v-"))if(t.match(/^on[A-Z]/)){const o=t.match(/onUpdate(?::?(\w+))$/);o&&(t=`onUpdate:${me(o[1])}`),e[t]=t in e?z(e[t]).concat(n):n}else if(t==="ref"&&"ref"in e){const o=n,i=e.ref;A(i)&&A(o)?e.ref=(...s)=>{o(...s),i(...s)}:e.ref=[i,o].filter(A).pop()}else e[t]=n},Zr=(e,t)=>(...n)=>{const r=e(...n).filter(Boolean);if(!r.length){const o=t.value,i={"lc-container-locked":o,"lc-container-placeholder":!0},s=o?"锁定元素及子元素无法编辑":"拖拽组件或模板到这里";r.push(h.h("div",{class:i},s))}return r},zt=Fe("key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Zt=Fe(et),Yr=h.defineComponent((e,{slots:t})=>()=>h.h("div",{class:"lc-page",style:{height:"100%"},...e},t)),Kr=h.defineComponent({name:"PageRenderer",props:X,__renderer__:!0,setup(e,t){const{scope:n,wrapRender:r}=Se(e,t),{renderComp:o,componentsRef:i,schemaRef:s}=ye(e,n);return r(()=>o(s.value,n,i.value.Page||Yr))}}),Qr=h.defineComponent({name:"BlockRenderer",props:X,__renderer__:!0,setup(e,t){const{scope:n,wrapRender:r}=Se(e,t),{triggerCompGetCtx:o}=_e(),{renderComp:i,schemaRef:s,componentsRef:u}=ye(e,n),f=u.value[s.value.componentName]||h.Fragment,l=h.getCurrentInstance();return ge(f)&&h.onMounted(()=>{l!=null&&l.proxy&&o(s.value,l.proxy)}),r(()=>i(s.value,n,u.value.Block||h.Fragment))}}),eo=h.defineComponent({name:"ComponentRenderer",props:X,__renderer__:!0,setup(e,t){const{scope:n,wrapRender:r}=Se(e,t),{triggerCompGetCtx:o}=_e(),{renderComp:i,schemaRef:s,componentsRef:u}=ye(e,n),f=u.value[s.value.componentName]||h.Fragment,l=h.getCurrentInstance();return ge(f)&&h.onMounted(()=>{l!=null&&l.proxy&&o(s.value,l.proxy)}),r(()=>i(s.value,n,f))}}),Yt={PageRenderer:Kr,BlockRenderer:Qr,ComponentRenderer:eo};class to{constructor(){re(this,"renderers",{...Yt});re(this,"configProvider",null)}setConfigProvider(t){this.configProvider=t}getConfigProvider(){return this.configProvider}setRenderers(t){this.renderers=t}getRenderers(){return this.renderers}}const Ye=new to,Kt={scope:Object,schema:{type:Object,required:!0},passProps:Object,components:{type:Object,required:!0},designMode:{type:String,default:"live"},device:String,locale:String,messages:{type:Object,default:()=>({})},getNode:Function,onCompGetCtx:Function,thisRequiredInJSE:{type:Boolean,default:!0},disableCompMock:{type:[Array,Boolean],default:!1},appHelper:Object,requestHandlersMap:Object},no=Fe(e=>!e.match(/^[a-z]+([A-Z][a-z]+)*$/)),ro=e=>e&&e.name==="AsyncComponentWrapper",oo=h.defineComponent({props:Kt,setup(e,{slots:t,expose:n}){const r=new K({thisRequired:e.thisRequiredInJSE}).initModule(e.schema),o=(a,p)=>{var _;p&&((_=e.onCompGetCtx)==null||_.call(e,a,p))},i=a=>{var p,_;return(_=(p=e.getNode)==null?void 0:p.call(e,a))!=null?_:null},s=h.shallowRef(e.schema);h.watch(()=>e.schema,()=>s.value=e.schema);let u=()=>!0;h.watchEffect(()=>{const a=e.disableCompMock;vt(a)?u=a?()=>!1:()=>!0:a&&(u=p=>!a.includes(p))});const f=new Map,l=h.reactive({designMode:h.computed(()=>e.designMode),components:h.computed(()=>({...Ye.getRenderers(),...e.components})),thisRequiredInJSE:h.computed(()=>e.thisRequiredInJSE),getNode:a=>{var p,_;return(_=(p=e.getNode)==null?void 0:p.call(e,a))!=null?_:null},triggerCompGetCtx:(a,p)=>{var _;(_=e.onCompGetCtx)==null||_.call(e,a,p)},rerender:Rt(()=>{const a=e.schema.id,p=a&&i(a);if(p){const _=Xe(p);_&&(s.value=_)}h.triggerRef(s)}),wrapLeafComp:(a,p,_)=>{let E=f.get(_);if(E){if(E.has(p))return E.get(p)}else E=new Map,f.set(_,E);if(u(a)&&!ro(p)){const[y,B,R]=no(p);R&&(_=Object.create(_,Object.getOwnPropertyDescriptors(y)))}return E.set(p,_),_}});h.provide(Nt(),l);const c=h.ref();n({runtimeScope:c});const d=()=>{const{components:a}=l,{scope:p,locale:_,messages:E,designMode:y,thisRequiredInJSE:B,requestHandlersMap:R,passProps:w,appHelper:M}=e,{value:m}=s;if(!m)return null;const{componentName:g}=m;let S=a[g]||a[`${g}Renderer`];return S&&!S.__renderer__&&(S=Yt[`${g}Renderer`]),S?h.h(S,{key:m.__ctx?`${m.__ctx.lceKey}_${m.__ctx.idx||"0"}`:m.id,...w,...r.parseOnlyJsValue(m.props),ref:c,__parser:r,__scope:p,__schema:m,__locale:_,__messages:E,__appHelper:M,__components:a,__designMode:y,__thisRequiredInJSE:B,__requestHandlersMap:R,__getNode:i,__triggerCompGetCtx:o},t):null};return()=>{const{device:a,locale:p}=e,_=Ye.getConfigProvider();return _?h.h(_,{device:a,locale:p},{default:d}):d()}}}),io=()=>{K.cleanCachedModules()};L.LOWCODE_ROUTE_META=Xt,L.SchemaParser=K,L.baseRendererPropKeys=rn,L.cleanCacledModules=io,L.config=Ye,L.default=oo,L.leafPropKeys=et,L.leafProps=ae,L.mergeScope=ie,L.rendererProps=X,L.setupLowCodeRouteGuard=Gr,L.useLeaf=ze,L.useRenderer=ye,L.useRootScope=Se,L.vueRendererProps=Kt,Object.defineProperties(L,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); 5 | //# sourceMappingURL=vue-renderer.js.map 6 | -------------------------------------------------------------------------------- /public/js/vue-simulator-renderer.css: -------------------------------------------------------------------------------- 1 | body,html{display:block;margin:0;padding:0;background:white}html.engine-design-mode{padding-bottom:0}html.engine-cursor-move,html.engine-cursor-move *{cursor:grabbing!important}html.engine-cursor-copy,html.engine-cursor-copy *{cursor:copy!important}html.engine-cursor-ew-resize,html.engine-cursor-ew-resize *{cursor:ew-resize!important}html.lc-cursor-dragging,html.lc-cursor-dragging *{cursor:move!important}html.lc-cursor-x-resizing,html.lc-cursor-x-resizing *{cursor:col-resize}html.lc-cursor-y-resizing,html.lc-cursor-y-resizing *{cursor:row-resize}html.lc-cursor-copy,html.lc-cursor-copy *{cursor:copy!important}::-webkit-scrollbar{width:5px;height:5px}::-webkit-scrollbar-thumb{background-color:#0000004d;border-radius:5px}.lc-container{height:100%}.lc-container:empty{display:flex;align-items:center;min-width:140px;height:66px;max-height:100%;overflow:hidden;color:#a7b1bd;text-align:center;background:#f2f3f5;outline:1px dashed rgba(31,56,88,.2);outline-offset:-1px!important}.lc-container:empty:before{z-index:1;width:100%;font-size:14px;white-space:nowrap;content:"拖拽组件或模板到这里"}.lc-container-placeholder{display:flex;align-items:center;justify-content:center;width:100%;height:100%;min-height:60px;color:#a7b1bd;font-size:14px;background-color:#f0f0f0;border:1px dotted}.lc-container-placeholder.lc-container-locked{background:#eccfcf}body.engine-document:after,body.engine-document:before{display:table;content:""}body.engine-document:after{clear:both}.engine-live-editing{outline:none;box-shadow:0 0 0 2px #66bc5c;cursor:text;user-select:text}#app{height:100vh} 2 | -------------------------------------------------------------------------------- /public/mock/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": "Hello AliLowCode!!11111111111", 3 | "user": { 4 | "username": "wudi", 5 | "password": "qwerty..." 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /public/preview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Lowcode Engine Preview 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/assets/assets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "packages": [ 4 | { 5 | "package": "@cdlab996/antd-lowcode-materials", 6 | "version": "0.0.1", 7 | "library": "Cdlab996AntdLowcodeMaterials", 8 | "urls": [ 9 | "https://unpkg.com/@cdlab996/antd-lowcode-materials@latest/dist/index.css", 10 | "https://unpkg.com/@cdlab996/antd-lowcode-materials@latest/dist/index.js" 11 | ] 12 | }, 13 | { 14 | "package": "@cdlab996/element-plus-lowcode-materials", 15 | "version": "0.0.1", 16 | "library": "Cdlab996ElementPlusLowcodeMaterials", 17 | "urls": [ 18 | "https://unpkg.com/@cdlab996/element-plus-lowcode-materials@latest/dist/index.css", 19 | "https://unpkg.com/@cdlab996/element-plus-lowcode-materials@latest/dist/index.js" 20 | ] 21 | }, 22 | { 23 | "package": "@cdlab996/vant-lowcode-materials", 24 | "version": "1.0.0", 25 | "library": "Cdlab996VantLowcodeMaterials", 26 | "urls": [ 27 | "https://unpkg.com/@cdlab996/vant-lowcode-materials@latest/dist/index.css", 28 | "https://unpkg.com/@cdlab996/vant-lowcode-materials@latest/dist/index.js" 29 | ] 30 | } 31 | ], 32 | "components": [ 33 | { 34 | "title": "区块", 35 | "group": "基础组件", 36 | "category": "原生组件", 37 | "priority": 902, 38 | "componentName": "div", 39 | "props": [], 40 | "configure": { 41 | "supports": { 42 | "style": true, 43 | "loop": true 44 | }, 45 | "component": { 46 | "isContainer": true 47 | } 48 | }, 49 | "snippets": [ 50 | { 51 | "screenshot": "https://helios-allpublic-1257616148.cos.ap-shanghai.myqcloud.com/img/card.png", 52 | "title": "区块", 53 | "schema": { 54 | "componentName": "div", 55 | "children": [] 56 | } 57 | } 58 | ] 59 | }, 60 | { 61 | "title": "正文", 62 | "group": "基础组件", 63 | "category": "原生组件", 64 | "priority": 901, 65 | "componentName": "span", 66 | "props": [ 67 | { 68 | "name": "children", 69 | "title": "内容", 70 | "propType": "string" 71 | } 72 | ], 73 | "configure": { 74 | "supports": { 75 | "style": true, 76 | "loop": false 77 | } 78 | }, 79 | "snippets": [ 80 | { 81 | "screenshot": "https://img.alicdn.com/imgextra/i3/O1CN01n5wpxc1bi862KuXFz_!!6000000003498-55-tps-50-50.svg", 82 | "title": "正文", 83 | "schema": { 84 | "componentName": "span", 85 | "props": { 86 | "children": "文本内容" 87 | } 88 | } 89 | } 90 | ] 91 | }, 92 | { 93 | "title": "图片", 94 | "group": "基础组件", 95 | "category": "原生组件", 96 | "priority": 900, 97 | "componentName": "img", 98 | "props": [ 99 | { 100 | "name": "src", 101 | "propType": "string", 102 | "description": "描述" 103 | }, 104 | { 105 | "name": "alt", 106 | "propType": "string", 107 | "description": "描述" 108 | } 109 | ], 110 | "configure": { 111 | "supports": { 112 | "style": true, 113 | "loop": true 114 | } 115 | }, 116 | "snippets": [ 117 | { 118 | "title": "图片", 119 | "screenshot": "https://img.alicdn.com/imgextra/i3/O1CN01tnhXhk1GUIFhsXwzA_!!6000000000625-55-tps-56-56.svg", 120 | "schema": { 121 | "componentName": "img", 122 | "props": { 123 | "src": "https://img.alicdn.com/imgextra/i2/O1CN01uv6vu822RBCSYLro2_!!6000000007116-55-tps-139-26.svg", 124 | "alt": "图片" 125 | } 126 | } 127 | } 128 | ] 129 | }, 130 | { 131 | "title": "页面", 132 | "componentName": "Page", 133 | "props": [ 134 | { 135 | "name": "style", 136 | "propType": "object", 137 | "defaultValue": { 138 | "padding": 12 139 | } 140 | } 141 | ], 142 | "configure": { 143 | "supports": { 144 | "style": true, 145 | "className": true 146 | }, 147 | "component": { 148 | "isContainer": true, 149 | "disableBehaviors": "*" 150 | } 151 | } 152 | }, 153 | { 154 | "title": "插槽", 155 | "componentName": "Slot", 156 | "configure": { 157 | "component": { 158 | "isContainer": true, 159 | "disableBehaviors": "*" 160 | } 161 | } 162 | }, 163 | { 164 | "exportName": "Cdlab996AntdLowcodeMaterialsMeta", 165 | "url": "https://unpkg.com/@cdlab996/antd-lowcode-materials@latest/dist/meta.js", 166 | "package": { 167 | "npm": "@cdlab996/antd-lowcode-materials" 168 | } 169 | }, 170 | { 171 | "exportName": "Cdlab996ElementPlusLowcodeMaterialsMeta", 172 | "url": "https://unpkg.com/@cdlab996/element-plus-lowcode-materials@latest/dist/meta.js", 173 | "package": { 174 | "npm": "@cdlab996/element-plus-lowcode-materials" 175 | } 176 | }, 177 | { 178 | "exportName": "Cdlab996VantLowcodeMaterialsMeta", 179 | "url": "https://unpkg.com/@cdlab996/vant-lowcode-materials@latest/dist/meta.js", 180 | "package": { 181 | "npm": "@cdlab996/vant-lowcode-materials" 182 | } 183 | } 184 | ], 185 | "sort": { 186 | "groupList": [], 187 | "categoryList": [] 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /src/assets/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "componentName": "Page", 3 | "id": "node_dockcviv8fo1", 4 | "props": {}, 5 | "docId": "doclupc274w", 6 | "fileName": "/", 7 | "state": { 8 | "text": "outer", 9 | "isShowDialog": false, 10 | "info": { "info": "", "user": { "username": "", "password": "" } } 11 | }, 12 | "dataSource": { "list": [] }, 13 | "css": "body {\n font-size: 12px;\n}\n\n.button {\n width: 100px;\n color: #ff00ff\n}", 14 | "lifeCycles": { 15 | "mounted": { 16 | "type": "JSFunction", 17 | "value": "function () {\n console.log('did mount');\n }" 18 | }, 19 | "beforeMount": { 20 | "type": "JSFunction", 21 | "value": "function () {\n console.log('will unmount');\n }" 22 | } 23 | }, 24 | "methods": { 25 | "testFunc": { 26 | "type": "JSFunction", 27 | "value": "function () {\n console.log('test func');\n }" 28 | } 29 | }, 30 | "originCode": "class LowcodeComponent extends Component {\n state = {\n \"text\": \"outer\",\n \"isShowDialog\": false,\n \"info\": {\n \"info\": \"\",\n \"user\": {\n \"username\": \"\",\n \"password\": \"\"\n }\n }\n }\n componentDidMount() {\n console.log('did mount');\n }\n componentWillUnmount() {\n console.log('will unmount');\n }\n testFunc() {\n console.log('test func');\n }\n onClick() {\n this.setState({\n isShowDialog: true\n })\n }\n closeDialog() {\n this.setState({\n isShowDialog: false\n })\n }\n\n\tonClick_new(){\n this.$message.success('hhhhhh')\n\t}\n\n\tonSubmit(ev){\n ev.preventDefault();\n this.dataSourceMap.submit.load()\n\t}\n}", 31 | "hidden": false, 32 | "title": "", 33 | "isLocked": false, 34 | "condition": true, 35 | "conditionGroup": "", 36 | "meta": { 37 | "originCode": "import { defineComponent } from 'vue';\n\nexport default defineComponent({\n data: () => ({\n text: \"outer\",\n isShowDialog: false,\n info: {\n \"info\": \"\",\n \"user\": {\n \"username\": \"\",\n \"password\": \"\"\n }\n },\n }),\n methods: {\n testFunc() {\n console.log('test func');\n },\n },\n mounted() {\n console.log('did mount');\n },\n beforeMount() {\n console.log('will unmount');\n },\n})\n" 38 | }, 39 | "children": [ 40 | { 41 | "componentName": "VanTabs", 42 | "id": "node_ocluqshvky1", 43 | "props": { 44 | "items": [ 45 | { "primaryKey": "2438", "title": "标签项0" }, 46 | { "primaryKey": "8925", "title": "标签项1" } 47 | ], 48 | "color": "#ee0a24", 49 | "background": "#fff", 50 | "duration": "0.3", 51 | "line-width": "40px", 52 | "line-height": "3px", 53 | "animated": false, 54 | "border": false, 55 | "ellipsis": false, 56 | "sticky": false, 57 | "swipeable": false, 58 | "lazy-render": true, 59 | "scrollspy": false, 60 | "offset-top": "0", 61 | "swipe-threshold": "5" 62 | }, 63 | "hidden": false, 64 | "title": "", 65 | "isLocked": false, 66 | "condition": true, 67 | "conditionGroup": "", 68 | "children": [ 69 | { 70 | "componentName": "VanTab", 71 | "id": "node_ocluqshvky2", 72 | "props": { "primaryKey": "2438", "title": "标签项0" }, 73 | "hidden": false, 74 | "title": "", 75 | "isLocked": false, 76 | "condition": true, 77 | "conditionGroup": "", 78 | "children": [ 79 | { 80 | "componentName": "AButton", 81 | "id": "node_ocluqp1per1", 82 | "props": { 83 | "type": "primary", 84 | "children": "主按钮", 85 | "htmlType": "button", 86 | "size": "middle", 87 | "shape": "default", 88 | "block": false, 89 | "danger": false, 90 | "ghost": false, 91 | "disabled": false 92 | }, 93 | "hidden": false, 94 | "title": "", 95 | "isLocked": false, 96 | "condition": true, 97 | "conditionGroup": "" 98 | }, 99 | { 100 | "componentName": "AButton", 101 | "id": "node_ocluqp1per2", 102 | "props": { 103 | "type": "default", 104 | "children": "次按钮", 105 | "htmlType": "button", 106 | "size": "middle", 107 | "shape": "default", 108 | "block": false, 109 | "danger": false, 110 | "ghost": false, 111 | "disabled": false 112 | }, 113 | "hidden": false, 114 | "title": "", 115 | "isLocked": false, 116 | "condition": true, 117 | "conditionGroup": "" 118 | } 119 | ] 120 | }, 121 | { 122 | "componentName": "VanTab", 123 | "id": "node_ocluqshvky3", 124 | "props": { "primaryKey": "8925", "title": "标签项1" }, 125 | "hidden": false, 126 | "title": "", 127 | "isLocked": false, 128 | "condition": true, 129 | "conditionGroup": "", 130 | "children": [ 131 | { 132 | "componentName": "VanImage", 133 | "id": "node_ocluqshvky4", 134 | "props": { 135 | "src": "https://img01.yzcdn.cn/vant/cat.jpeg", 136 | "fit": "fill", 137 | "radius": 0, 138 | "round": false, 139 | "lazy-load": false, 140 | "show-error": true, 141 | "show-loading": true, 142 | "error-icon": "photo-fail", 143 | "loading-icon": "photo", 144 | "alt": "", 145 | "width": "", 146 | "height": "", 147 | "icon-prefix": "" 148 | }, 149 | "hidden": false, 150 | "title": "", 151 | "isLocked": false, 152 | "condition": true, 153 | "conditionGroup": "" 154 | } 155 | ] 156 | } 157 | ] 158 | } 159 | ] 160 | } 161 | -------------------------------------------------------------------------------- /src/components/logo/logo.less: -------------------------------------------------------------------------------- 1 | .lowcode-plugin-logo { 2 | .logo { 3 | display: block; 4 | width: 139px; 5 | height: 26px; 6 | background-repeat: no-repeat; 7 | background-position: center; 8 | background-size: contain; 9 | cursor: pointer; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/components/logo/logo.tsx: -------------------------------------------------------------------------------- 1 | import type { FC, ReactElement } from 'react' 2 | import PropTypes from 'prop-types' 3 | import type { PluginProps } from '@alilc/lowcode-types' 4 | import './logo.less' 5 | 6 | export interface IProps { 7 | logo?: string 8 | href?: string 9 | } 10 | 11 | export const Logo: FC = (props): ReactElement => { 12 | return ( 13 |
14 | 20 |
21 | ) 22 | } 23 | 24 | Logo.propTypes = { 25 | logo: PropTypes.string, 26 | href: PropTypes.string, 27 | } 28 | -------------------------------------------------------------------------------- /src/editor.less: -------------------------------------------------------------------------------- 1 | html { 2 | min-width: 1024px; 3 | } 4 | 5 | body { 6 | font-size: 12px; 7 | font-family: PingFangSC-Regular, Roboto, 'Helvetica Neue', Helvetica, Tahoma, Arial, 8 | 'PingFang SC-Light', 'Microsoft YaHei'; 9 | 10 | * { 11 | box-sizing: border-box; 12 | } 13 | } 14 | 15 | #lce-container { 16 | position: fixed; 17 | top: 0; 18 | right: 0; 19 | bottom: 0; 20 | left: 0; 21 | box-sizing: border-box; 22 | width: 100%; 23 | height: 100%; 24 | margin: 0; 25 | padding: 0; 26 | overflow: hidden; 27 | text-rendering: optimizelegibility; 28 | -webkit-user-drag: none; 29 | -webkit-touch-callout: none; 30 | -webkit-font-smoothing: antialiased; 31 | 32 | .lc-code-control { 33 | position: relative; 34 | height: calc(100% - 24px); 35 | overflow: visible; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/editor.ts: -------------------------------------------------------------------------------- 1 | import { init, project } from '@alilc/lowcode-engine' 2 | import { setupHostEnvironment } from '@knxcloud/lowcode-utils' 3 | 4 | import registerPlugins from './plugins/registry' 5 | import './editor.less' 6 | 7 | const getUrlParam = (name: string): string | null => { 8 | if (!name) return null 9 | 10 | const searchParams = window.location.search 11 | if (!searchParams) return null 12 | 13 | const urlParams = new URLSearchParams(searchParams) 14 | return urlParams.get(name) 15 | } 16 | 17 | void (async () => { 18 | const preference = new Map() 19 | 20 | preference.set('DataSourcePane', { 21 | importPlugins: [], 22 | dataSourceTypes: [ 23 | { 24 | type: 'fetch', 25 | }, 26 | ], 27 | }) 28 | 29 | await registerPlugins() 30 | 31 | const client: string = getUrlParam('client') || 'h5' 32 | const client2deviceMap: Record = { 33 | h5: 'mobile', 34 | pc: 'default', 35 | } 36 | 37 | const device: string = client2deviceMap[client] || 'default' 38 | setupHostEnvironment(project, '/js/vue.runtime.global.js') 39 | 40 | const options = { 41 | enableCondition: true, 42 | enableCanvasLock: true, 43 | supportVariableGlobally: true, 44 | device, 45 | simulatorUrl: ['/js/vue-simulator-renderer.js', '/js/vue-simulator-renderer.css'], 46 | } 47 | 48 | await init(document.getElementById('lce-container')!, options, preference) 49 | })() 50 | -------------------------------------------------------------------------------- /src/plugins/actions.ts: -------------------------------------------------------------------------------- 1 | import { createElement as h } from 'react' 2 | import { Button, Message } from '@alifd/next' 3 | import type { IPublicModelPluginContext } from '@alilc/lowcode-types' 4 | 5 | import { saveSchema } from '@/utils/store' 6 | import Logger from '@/utils/Logger' 7 | 8 | const save = async () => { 9 | await saveSchema() 10 | Message.success('成功保存到本地') 11 | } 12 | 13 | const preview = async () => { 14 | await saveSchema() 15 | window.open('preview.html') 16 | } 17 | 18 | const savePlugin = (ctx: IPublicModelPluginContext) => { 19 | return { 20 | name: 'saveSample', 21 | init() { 22 | const { skeleton, hotkey } = ctx 23 | 24 | skeleton.add({ 25 | name: 'saveSample', 26 | area: 'topArea', 27 | type: 'Widget', 28 | props: { align: 'right' }, 29 | content: h( 30 | Button, 31 | { 32 | onClick: () => { 33 | save().catch((error) => Logger.error(error)) 34 | }, 35 | }, 36 | '保存到本地' 37 | ), 38 | }) 39 | 40 | skeleton.add({ 41 | name: 'previewSample', 42 | area: 'topArea', 43 | type: 'Widget', 44 | props: { align: 'right' }, 45 | content: h( 46 | Button, 47 | { 48 | onClick: () => { 49 | preview().catch((error) => Logger.error(error)) 50 | }, 51 | }, 52 | '预览' 53 | ), 54 | }) 55 | 56 | hotkey.bind('command+s', async (e) => { 57 | e.preventDefault() 58 | await save() 59 | }) 60 | }, 61 | } 62 | } 63 | 64 | savePlugin.pluginName = 'saveSample' 65 | 66 | export default savePlugin 67 | -------------------------------------------------------------------------------- /src/plugins/init.ts: -------------------------------------------------------------------------------- 1 | import { injectAssets } from '@alilc/lowcode-plugin-inject' 2 | import type { 3 | IPublicModelPluginContext, 4 | IPublicTypeAssetsJson, 5 | IPublicTypeRootSchema, 6 | } from '@alilc/lowcode-types' 7 | 8 | import { getProjectSchemaToLocalStorage } from '@/utils/store' 9 | // import Logger from '@/utils/Logger' 10 | 11 | import assets from '@/assets/assets.json' 12 | import originSchema from '@/assets/schema.json' 13 | 14 | const editorInit = (ctx: IPublicModelPluginContext) => { 15 | return { 16 | name: 'editor-init', 17 | async init() { 18 | const { material, project } = ctx 19 | 20 | // const assets = await fetch('http://127.0.0.1:9000/assets.json').then((res) => 21 | // res.json() 22 | // ); 23 | // Logger.log('🚀 ~ file: init.ts:16 ~ init ~ assets:', assets); 24 | // material.setAssets(assets); 25 | 26 | const loadedAssets = (await injectAssets(assets)) as IPublicTypeAssetsJson 27 | material.setAssets(loadedAssets) 28 | 29 | const projectSchema = getProjectSchemaToLocalStorage() 30 | const schema = projectSchema ? projectSchema.componentsTree.pop() : originSchema 31 | 32 | project.onSimulatorRendererReady(() => { 33 | project.openDocument(schema as IPublicTypeRootSchema) 34 | }) 35 | }, 36 | } 37 | } 38 | 39 | editorInit.pluginName = 'editorInit' 40 | 41 | export default editorInit 42 | -------------------------------------------------------------------------------- /src/plugins/registry.ts: -------------------------------------------------------------------------------- 1 | import type { IPublicModelPluginContext } from '@alilc/lowcode-types' 2 | import { plugins } from '@alilc/lowcode-engine' 3 | 4 | /** 5 | * More plugins can be found here 6 | * 7 | * https://github.com/cdLab996/lowcode-engine-demo-vue?tab=readme-ov-file#-credits 8 | */ 9 | 10 | import Inject from '@alilc/lowcode-plugin-inject' 11 | import SetRefPropPlugin from '@alilc/lowcode-plugin-set-ref-prop' 12 | import ComponentsPane from '@alilc/lowcode-plugin-components-pane' 13 | import DataSourcePanePlugin from '@alilc/lowcode-plugin-datasource-pane' 14 | import SchemaPlugin from '@alilc/lowcode-plugin-schema' 15 | import SimulatorResizer from '@alilc/lowcode-plugin-simulator-select' 16 | import UndoRedoPlugin from '@alilc/lowcode-plugin-undo-redo' 17 | import CodeEditor from '@knxcloud/lowcode-plugin-vue-code-editor' 18 | import ManualPlugin from '@cdlab996/lowcode-plugin-manual' 19 | import DirectiveLoading from '@cdlab996/plugin-directive-loading' 20 | import PluginSetDocUrlProp from '@cdlab996/lowcode-plugin-set-doc-url' 21 | 22 | // setters 23 | import SetterPlugin from '../setters/index' 24 | 25 | import Actions from './actions' 26 | import ResourceInit from './init' 27 | import { Logo } from '../components/logo/logo' 28 | 29 | export default async function registerPlugins() { 30 | // Inject:支持调试功能 31 | await plugins.register(Inject) 32 | 33 | // 高级设置面板中设置 ref-id(实现:https://lowcode-engine.cn/site/docs/api/material#%E7%A4%BA%E4%BE%8B-8) 34 | await plugins.register(SetRefPropPlugin) 35 | 36 | // 高级面板中设置 v-loading 指令 37 | await plugins.register(DirectiveLoading) 38 | 39 | // 支持给每个组件注入 docUrl 40 | await plugins.register(PluginSetDocUrlProp) 41 | 42 | // 加载默认的资产包、schema 43 | await plugins.register(ResourceInit) 44 | 45 | // 注册 logo 和组件面板 46 | const builtinPluginRegistry = (ctx: IPublicModelPluginContext) => { 47 | return { 48 | name: 'builtin-plugin-registry', 49 | init() { 50 | const { skeleton, project } = ctx 51 | skeleton.add({ 52 | area: 'topArea', 53 | type: 'Widget', 54 | name: 'logo', 55 | content: Logo, 56 | contentProps: { 57 | logo: 'https://img.alicdn.com/imgextra/i4/O1CN013w2bmQ25WAIha4Hx9_!!6000000007533-55-tps-137-26.svg', 58 | href: 'https://lowcode-engine.cn', 59 | }, 60 | props: { 61 | align: 'left', 62 | }, 63 | }) 64 | 65 | const componentsPane = skeleton.add({ 66 | area: 'leftArea', 67 | type: 'PanelDock', 68 | name: 'componentsPane', 69 | content: ComponentsPane, 70 | props: { 71 | align: 'top', 72 | icon: 'zujianku', 73 | description: '组件库', 74 | }, 75 | }) 76 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment 77 | // @ts-expect-error 78 | // eslint-disable-next-line @typescript-eslint/no-unsafe-call 79 | componentsPane?.disable?.() 80 | project.onSimulatorRendererReady(() => { 81 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment 82 | // @ts-expect-error 83 | // eslint-disable-next-line @typescript-eslint/no-unsafe-call 84 | componentsPane?.enable?.() 85 | }) 86 | }, 87 | } 88 | } 89 | builtinPluginRegistry.pluginName = 'builtinPluginRegistry' 90 | await plugins.register(builtinPluginRegistry) 91 | 92 | // 注册数据源面板 93 | await plugins.register(DataSourcePanePlugin) 94 | 95 | // 注册源码面板 96 | await plugins.register(CodeEditor) 97 | 98 | // 注册 Schema 面板 99 | await plugins.register(SchemaPlugin) 100 | 101 | // 注册 使用手册 102 | await plugins.register(ManualPlugin, { 103 | href: 'https://github.com/cdLab996/lowcode-engine-demo-vue', 104 | }) 105 | 106 | // 画布切换 107 | await plugins.register(SimulatorResizer) 108 | 109 | // 注册回退/前进 110 | await plugins.register(UndoRedoPlugin) 111 | 112 | // 注册操作按钮(保存、预览) 113 | await plugins.register(Actions) 114 | 115 | // 注册 Setter 116 | await plugins.register(SetterPlugin) 117 | } 118 | -------------------------------------------------------------------------------- /src/setters/expression-setter/index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * 扩展官方的 ExpressionSetter 组件 3 | */ 4 | import { isJSExpression } from '@alilc/lowcode-utils' 5 | import AliLowCodeEngineExt from '@cdlab996/lowcode-engine-ext-vue' 6 | import { project } from '@alilc/lowcode-engine' 7 | 8 | import Logger from '@/utils/Logger' 9 | 10 | const ReactExpressionSetter = AliLowCodeEngineExt.setterMap.ExpressionSetter 11 | const ReactExpressionSetterView = ReactExpressionSetter.component 12 | 13 | function isPlainObject(val: unknown): val is Record { 14 | return Object.prototype.toString.call(val) === '[object Object]' 15 | } 16 | 17 | function flatObject( 18 | obj: unknown, 19 | parentPath: string[] = [], 20 | target: Record = {} 21 | ): Record { 22 | if (obj && isPlainObject(obj)) { 23 | for (const key in obj) { 24 | // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment 25 | const value = obj[key] 26 | const path = parentPath.concat(key) 27 | // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment 28 | target[path.join('.')] = value 29 | isPlainObject(value) && flatObject(value, path, target) 30 | } 31 | } 32 | return target 33 | } 34 | 35 | class ExpressionSetterView extends ReactExpressionSetterView { 36 | getDataSource(): string[] { 37 | const schema = project.exportSchema() 38 | const stateMap = schema.componentsTree[0].state 39 | const dataSource = [] 40 | 41 | const datasourceMap = schema.componentsTree[0]?.dataSource 42 | const list = datasourceMap?.list || [] 43 | 44 | for (const key in stateMap) { 45 | dataSource.push(`this.${key}`) 46 | 47 | const state = stateMap[key] 48 | if (isJSExpression(state)) { 49 | try { 50 | // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-implied-eval, no-new-func 51 | const data = new Function(`return ${state.value}`)() 52 | const flatted = flatObject(data, ['this', key]) 53 | if (isPlainObject(flatted)) { 54 | dataSource.push(...Object.keys(flatted)) 55 | } 56 | } catch (err) { 57 | Logger.error('parse error', err) 58 | } 59 | } 60 | } 61 | 62 | for (const item of list) { 63 | if (item && item.id) { 64 | dataSource.push(`this.${item.id}`) 65 | } 66 | } 67 | 68 | return dataSource 69 | } 70 | } 71 | 72 | const ExpressionSetter = { 73 | ...ReactExpressionSetter, 74 | component: ExpressionSetterView, 75 | } 76 | 77 | export default ExpressionSetter 78 | -------------------------------------------------------------------------------- /src/setters/index.ts: -------------------------------------------------------------------------------- 1 | import type { IPublicModelPluginContext } from '@alilc/lowcode-types' 2 | import AliLowCodeEngineExt from '@cdlab996/lowcode-engine-ext-vue' 3 | 4 | import ExpressionSetter from './expression-setter' 5 | 6 | // 注册内置 Setter 、事件绑定、变量绑定面板 7 | const setterRegistry = (ctx: IPublicModelPluginContext) => { 8 | const { setterMap, pluginMap } = AliLowCodeEngineExt 9 | return { 10 | name: 'ext-setters-registry', 11 | init() { 12 | const { setters, skeleton } = ctx 13 | 14 | /** 15 | * 注册内置 Setter 16 | */ 17 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment 18 | // @ts-expect-error 19 | setters.registerSetter({ ...setterMap, ExpressionSetter }) 20 | 21 | // TODO: IconSetter 22 | // setters.registerSetter('CIconSetter', IconSetter) 23 | 24 | // 注册事件绑定面板 25 | skeleton.add({ 26 | area: 'centerArea', 27 | type: 'Widget', 28 | content: pluginMap.EventBindDialog, 29 | name: 'eventBindDialog', 30 | props: {}, 31 | }) 32 | 33 | // 注册变量绑定面板 34 | skeleton.add({ 35 | area: 'centerArea', 36 | type: 'Widget', 37 | content: pluginMap.VariableBindDialog, 38 | name: 'variableBindDialog', 39 | props: {}, 40 | }) 41 | }, 42 | } 43 | } 44 | 45 | setterRegistry.pluginName = 'setterRegistry' 46 | 47 | export default setterRegistry 48 | -------------------------------------------------------------------------------- /src/utils/Logger.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unsafe-argument */ 2 | /* eslint-disable no-console */ 3 | 4 | function getTimestamp() { 5 | return `${new Date().toLocaleString()}.${new Date().getMilliseconds()}` 6 | } 7 | 8 | function logWithTimestamp(message?: any, ...optionalParams: any[]) { 9 | console.log(`[${getTimestamp()}]`, message, ...optionalParams) 10 | } 11 | 12 | function infoWithTimestamp(message?: any, ...optionalParams: any[]) { 13 | console.info(`[${getTimestamp()}]`, message, ...optionalParams) 14 | } 15 | 16 | function warnWithTimestamp(message?: any, ...optionalParams: any[]) { 17 | console.warn(`[${getTimestamp()}]`, message, ...optionalParams) 18 | } 19 | 20 | function errorWithTimestamp(message?: any, ...optionalParams: any[]) { 21 | console.error(`[${getTimestamp()}]`, message, ...optionalParams) 22 | } 23 | 24 | const Logger = { 25 | log: logWithTimestamp, 26 | info: infoWithTimestamp, 27 | warn: warnWithTimestamp, 28 | error: errorWithTimestamp, 29 | } 30 | 31 | export default Logger 32 | -------------------------------------------------------------------------------- /src/utils/store.ts: -------------------------------------------------------------------------------- 1 | import { material, project } from '@alilc/lowcode-engine' 2 | import { filterPackages } from '@alilc/lowcode-plugin-inject' 3 | import { 4 | IPublicEnumTransformStage, 5 | type IPublicTypePackage, 6 | type IPublicTypeProjectSchema, 7 | } from '@alilc/lowcode-types' 8 | 9 | export const setPackgesToLocalStorage = async () => { 10 | const packages = await filterPackages(material.getAssets()?.packages) 11 | window.localStorage.setItem('packages', JSON.stringify(packages)) 12 | } 13 | 14 | export const getPackgesToLocalStorage = (): IPublicTypePackage[] => { 15 | const packagesString = window.localStorage.getItem('packages') 16 | if (packagesString) { 17 | return JSON.parse(packagesString) as IPublicTypePackage[] 18 | } 19 | return [] 20 | } 21 | 22 | export const setProjectSchemaToLocalStorage = () => { 23 | window.localStorage.setItem( 24 | 'projectSchema', 25 | JSON.stringify(project.exportSchema(IPublicEnumTransformStage.Save)) 26 | ) 27 | } 28 | 29 | export const getProjectSchemaToLocalStorage = (): 30 | | IPublicTypeProjectSchema 31 | | undefined => { 32 | const schemaString = window.localStorage.getItem('projectSchema') 33 | if (schemaString) { 34 | return JSON.parse(schemaString) as IPublicTypeProjectSchema 35 | } 36 | return undefined 37 | } 38 | 39 | export const saveSchema = async () => { 40 | setProjectSchemaToLocalStorage() 41 | await setPackgesToLocalStorage() 42 | } 43 | -------------------------------------------------------------------------------- /src/vue/preview.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable eslint-comments/no-unlimited-disable */ 2 | /* eslint-disable */ 3 | 4 | import { h, createApp, toRaw, Suspense } from 'vue' 5 | 6 | import type { Asset, IPublicTypeComponentMap, IPublicTypeProjectSchema } from '@alilc/lowcode-types' 7 | import VueRenderer from '@knxcloud/lowcode-vue-renderer' 8 | import { buildComponents, AssetLoader } from '@knxcloud/lowcode-utils' 9 | 10 | // import { getPackgesToLocalStorage, getProjectSchemaToLocalStorage } from '../utils/store' 11 | 12 | const init = async () => { 13 | // const packages = getPackgesToLocalStorage() 14 | // const projectSchema = getProjectSchemaToLocalStorage() 15 | const packages = JSON.parse(window.localStorage.getItem('packages') || '[]') 16 | const projectSchema = JSON.parse( 17 | window.localStorage.getItem('projectSchema') || '{}' 18 | ) as IPublicTypeProjectSchema 19 | const { componentsMap: componentsMapArray = [], componentsTree = [] } = projectSchema 20 | 21 | const componentsMap: { [key: string]: IPublicTypeComponentMap } = {} 22 | componentsMapArray.forEach((component) => { 23 | if (component.componentName) { 24 | componentsMap[component.componentName] = component 25 | } 26 | }) 27 | 28 | const libraryMap: Record = {} 29 | const libraryAsset: Asset = [] 30 | // TODO?: renderUrls is deprecated 31 | // @ts-ignore 32 | packages.forEach(({ package: _package, library, urls, renderUrls }) => { 33 | if (_package) { 34 | libraryMap[_package] = library 35 | } 36 | if (renderUrls) { 37 | libraryAsset.push(renderUrls) 38 | } else if (urls) { 39 | libraryAsset.push(urls) 40 | } 41 | }) 42 | await new AssetLoader().load(libraryAsset) 43 | const components = await buildComponents(libraryMap, componentsMap) 44 | 45 | return { schema: componentsTree[0], components } 46 | } 47 | 48 | void (async () => { 49 | const { schema, components } = await init() 50 | const app = createApp(() => { 51 | return h('div', { class: 'lowcode-plugin-sample-preview' }, [ 52 | h(Suspense, null, { 53 | default: () => 54 | h(VueRenderer, { 55 | class: 'lowcode-plugin-sample-preview-content', 56 | schema: toRaw(schema), 57 | components: toRaw(components), 58 | }), 59 | fallback: () => 60 | h('div', { class: 'lowcode-plugin-sample-preview-loading' }, 'loading...'), 61 | }), 62 | ]) 63 | }) 64 | app.mount('#lce-container') 65 | })() 66 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "declaration": true, 5 | "lib": ["es2015", "dom"], 6 | "module": "ESNext", 7 | "moduleResolution": "Node", 8 | "resolveJsonModule": true, 9 | "useDefineForClassFields": true, 10 | "jsx": "preserve", 11 | "noImplicitThis": true, 12 | "strict": true, 13 | // "verbatimModuleSyntax": true, 14 | "target": "ESNext", 15 | "esModuleInterop": true, 16 | "forceConsistentCasingInFileNames": true, 17 | "skipLibCheck": true, 18 | "paths": { 19 | "@/*": ["src/*"] 20 | } 21 | }, 22 | "include": ["./src/**/*.ts", "./src/**/*.tsx"], 23 | "exclude": ["node_modules"] 24 | } 25 | --------------------------------------------------------------------------------