Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: blockCompiler #906

Merged
merged 31 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d59400c
feat: blockCompiler
chilingling Nov 16, 2024
7fa3acc
feat: block compile to blobURL
chilingling Nov 22, 2024
00c8cf6
feat: block-compiler
chilingling Nov 25, 2024
4386161
fix: add dev alias
chilingling Nov 25, 2024
067712f
fix: del unnecessary comments
chilingling Nov 27, 2024
923fc44
feat: del old block web component logic
chilingling Nov 28, 2024
a999cb9
fix: scope id error
chilingling Nov 28, 2024
cbd25bf
feat: del umd block support
chilingling Nov 28, 2024
4e4e40a
feat: del block deploy progress bar
chilingling Nov 28, 2024
84ce397
feat: del block progress request
chilingling Nov 28, 2024
6417b95
fix: del customElement relative logic
chilingling Nov 30, 2024
b695611
feat: add block loading and error status view
chilingling Nov 30, 2024
cb22f97
fix: select blockSchema by historyid
chilingling Nov 30, 2024
0b04c86
fix: block schema should select by version
chilingling Nov 30, 2024
5ab7e73
feat: add block compile cache
chilingling Dec 2, 2024
015248a
fix: add source code cache
chilingling Dec 2, 2024
8271cef
fix: add default material import map
chilingling Dec 3, 2024
28f51b5
feat: update builtin-component version
chilingling Dec 14, 2024
59f664b
feat(block-compiler): support compile jsx
chilingling Dec 14, 2024
3a9ac7c
feat: support block compileCache
chilingling Dec 14, 2024
bf5a8d5
feat: update block version slient refresh
chilingling Dec 16, 2024
3fa90e6
fix: update @vue/babel-plusin-jsx version
chilingling Dec 17, 2024
6095aa1
fix: type checking
chilingling Dec 17, 2024
06a0a0f
fix: typescript build error
chilingling Dec 18, 2024
103366d
fix: imporve type checking
chilingling Dec 18, 2024
7b317bb
feat: use new block compile cache realize
chilingling Dec 18, 2024
33e5954
fix(block-compiler): remove deps order check
chilingling Dec 19, 2024
6f219a9
fix: use has method check the specified key exists in the map instead…
chilingling Dec 19, 2024
12d2163
fix: optimize deps
chilingling Dec 19, 2024
51d6716
fix: update cache name params
chilingling Dec 19, 2024
ca63a35
Merge branch 'refactor/develop' into feat/blockCompiler
hexqi Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions packages/block-compiler/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const path = require('path')
const { rules } = require('../../.eslintrc')

module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
projectService: true,
project: [path.join(__dirname, './tsconfig.json') ],
ecmaVersion: 'latest',
},
plugins: ['@typescript-eslint'],
env: {
browser: true,
es2015: true,
node: true
},
rules: {
...rules,
// 允许 @ts-ignore
"@typescript-eslint/ban-ts-comment": "off",
// 允许非空断言
"@typescript-eslint/no-non-null-asserted-optional-chain": "off"
},
ignorePatterns: ['test/sample/*.vue', '.eslintrc.cjs']
}
2 changes: 2 additions & 0 deletions packages/block-compiler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# @opentiny/tiny-engine 低代码引擎区编译器

35 changes: 35 additions & 0 deletions packages/block-compiler/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>block-compiler</title>
<link rel="stylesheet" href="https://unpkg.com/@opentiny/[email protected]/index.css" />
<script type="importmap">
{
"imports": {
"vue": "https://unpkg.com/[email protected]/dist/vue.runtime.esm-browser.js",
"vue/server-renderer": "https://unpkg.com/@vue/[email protected]/dist/server-renderer.esm-browser.js",
"vue-i18n": "https://unpkg.com/[email protected]/dist/vue-i18n.esm-browser.js",
"vue-router": "https://unpkg.com/[email protected]/dist/vue-router.esm-browser.js",
"@vue/devtools-api": "https://unpkg.com/@vue/[email protected]/lib/esm/index.js",
"@vueuse/core": "https://unpkg.com/@vueuse/[email protected]/index.mjs",
"@vueuse/shared": "https://unpkg.com/@vueuse/[email protected]/index.mjs",
"axios": "https://unpkg.com/[email protected]/dist/esm/axios.js",
"@opentiny/tiny-engine-i18n-host": "https://unpkg.com/@opentiny/tiny-engine-i18n-host@1/dist/lowcode-design-i18n-host.es.js",
"@opentiny/tiny-engine-builtin-component": "https://unpkg.com/@opentiny/tiny-engine-builtin-component@^2.0.0/dist/index.js",
"pinia": "https://unpkg.com/[email protected]/dist/pinia.esm-browser.js",
"@opentiny/vue": "https://unpkg.com/@opentiny/[email protected]/runtime/tiny-vue.mjs",
"@opentiny/vue-icon": "https://unpkg.com/@opentiny/[email protected]/runtime/tiny-vue-icon.mjs",
"@opentiny/vue-common": "https://unpkg.com/@opentiny/[email protected]/runtime/tiny-vue-common.mjs",
"@opentiny/vue-locale": "https://unpkg.com/@opentiny/[email protected]/runtime/tiny-vue-locale.mjs",
"@opentiny/vue-renderless/": "https://unpkg.com/@opentiny/[email protected]/"
}
}
</script>
</head>
<body>
<div id="app"></div>
<script type="module" src="./src/dev.ts"></script>
</body>
</html>
49 changes: 49 additions & 0 deletions packages/block-compiler/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@opentiny/tiny-engine-block-compiler",
"version": "2.0.0-rc.2",
"publishConfig": {
"access": "public"
},
"description": "block runtime compiler",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"files": [
"dist"
],
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/opentiny/tiny-engine",
"directory": "packages/block-compiler"
},
"bugs": {
"url": "https://github.com/opentiny/tiny-engine/issues"
},
"author": "OpenTiny Team",
"license": "MIT",
"homepage": "https://opentiny.design/tiny-engine",
"dependencies": {},
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@types/babel__core": "^7.20.5",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"@vitejs/plugin-vue": "^5.1.2",
"eslint": "^8.38.0",
"typescript": "~5.4.2",
"vite": "^5.4.2",
"vite-plugin-dts": "^4.3.0"
},
"peerDependencies": {
"@babel/core": "^7.26.0",
"@vue/babel-plugin-jsx": "^1.2.5",
"vue": "^3.4.15",
"@vue/compiler-sfc": "^3.4.15"
}
}
78 changes: 78 additions & 0 deletions packages/block-compiler/src/dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// @ts-ignore
import { createApp, defineAsyncComponent, h } from 'https://unpkg.com/[email protected]/dist/vue.runtime.esm-browser.js'
import { compile } from './index'
import BlockFileName from '../test/sample/BlockFileName.vue?raw'
import BlockHead from '../test/sample/BlockHead.vue?raw'
import BlockMenu from '../test/sample/BlockMenu.vue?raw'
import BlockTest from '../test/sample/BlockTest.vue?raw'
import BlockJsxTest from '../test/sample/slotModelValueTest.vue?raw'

const RenderMain = {
setup() {
const componentMap = compile(
[
{
fileName: 'BlockHead',
sourceCode: BlockHead
},
{
fileName: 'BlockFileName',
sourceCode: BlockFileName
},
{
fileName: 'BlockMenu',
sourceCode: BlockMenu
},
{
fileName: 'BlockTest',
sourceCode: BlockTest
},
{
fileName: 'BlockJsxTest',
sourceCode: BlockJsxTest
}
],
{}
)

const blockComponents: { [key: string]: unknown } = {}

// @ts-ignore
window.getBlockComponentBlobUrl = (name) => {
return componentMap?.[name]?.blobURL
}

for (const [fileName, value] of Object.entries(componentMap)) {
blockComponents[fileName] = defineAsyncComponent(() => import(/* @vite-ignore */ value.blobURL))
}

const css = Object.values(componentMap)
.map((item) => item.style)
.join('')

const stylesheet = document.querySelector('#block-stylesheet')

if (stylesheet) {
stylesheet.remove()
} else {
const newStyleSheet = document.createElement('style')

newStyleSheet.innerHTML = css

document.head.appendChild(newStyleSheet)
}

return () =>
h('div', {}, [
h(blockComponents.BlockJsxTest),
h(blockComponents.BlockTest),
h(blockComponents.BlockHead),
h(blockComponents.BlockFileName),
h('span', {}, 'testtest')
])
}
}

const App = createApp(RenderMain)

App.mount(document.querySelector('#app')!)
Loading
Loading