Compare commits
7 Commits
v1.0.0
...
92115d3faa
| Author | SHA1 | Date | |
|---|---|---|---|
|
92115d3faa
|
|||
|
21eaee22f7
|
|||
|
44e32ce4f7
|
|||
|
6302ec6ab3
|
|||
|
1c45e7250b
|
|||
|
51ee15749e
|
|||
|
bba90c6783
|
10
package-lock.json
generated
10
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "oxygen-ui",
|
"name": "oxygen-ui",
|
||||||
"version": "1.0.0-SNAPSHOT",
|
"version": "1.0.1-SNAPSHOT",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "oxygen-ui",
|
"name": "oxygen-ui",
|
||||||
"version": "1.0.0-SNAPSHOT",
|
"version": "1.0.1-SNAPSHOT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/icons": "^5.3.7",
|
"@ant-design/icons": "^5.3.7",
|
||||||
"@dnd-kit/core": "^6.1.0",
|
"@dnd-kit/core": "^6.1.0",
|
||||||
@@ -2153,9 +2153,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/acorn": {
|
"node_modules/acorn": {
|
||||||
"version": "8.11.3",
|
"version": "8.12.1",
|
||||||
"resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.11.3.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz",
|
||||||
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
|
"integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "oxygen-ui",
|
"name": "oxygen-ui",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1-SNAPSHOT",
|
||||||
"description": "Oxygen Toolbox browser version",
|
"description": "Oxygen Toolbox browser version",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "FatttSnake",
|
"name": "FatttSnake",
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const Preview = ({
|
|||||||
Compiler.compile(files, importMap, entryPoint)
|
Compiler.compile(files, importMap, entryPoint)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
setCompiledCode(
|
setCompiledCode(
|
||||||
`${preExpansionCode}\n${result.outputFiles[0].text}\n${postExpansionCode}`
|
`(()=>{${preExpansionCode}})();\n(()=>{${result.outputFiles[0].text}})();\n(()=>{${postExpansionCode}})();`
|
||||||
)
|
)
|
||||||
setErrorMsg('')
|
setErrorMsg('')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import esbuild, { Loader, OnLoadArgs, Plugin, PluginBuild } from 'esbuild-wasm'
|
|||||||
import localforage from 'localforage'
|
import localforage from 'localforage'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { IFiles, IImportMap } from '@/components/Playground/shared'
|
import { IFiles, IImportMap } from '@/components/Playground/shared'
|
||||||
import { cssToJs, jsonToJs, addReactImport } from '@/components/Playground/files'
|
import { addReactImport, cssToJs, jsonToJs } from '@/components/Playground/files'
|
||||||
|
|
||||||
class Compiler {
|
class Compiler {
|
||||||
private init = false
|
private init = false
|
||||||
@@ -73,8 +73,7 @@ class Compiler {
|
|||||||
files: IFiles,
|
files: IFiles,
|
||||||
importMap: IImportMap,
|
importMap: IImportMap,
|
||||||
entryPoint: string
|
entryPoint: string
|
||||||
): Plugin => {
|
): Plugin => ({
|
||||||
return {
|
|
||||||
name: 'file-resolver-plugin',
|
name: 'file-resolver-plugin',
|
||||||
setup: (build: PluginBuild) => {
|
setup: (build: PluginBuild) => {
|
||||||
build.onResolve({ filter: /.*/ }, (args: esbuild.OnResolveArgs) => {
|
build.onResolve({ filter: /.*/ }, (args: esbuild.OnResolveArgs) => {
|
||||||
@@ -136,7 +135,12 @@ class Compiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const path = importMap.imports[args.path]
|
let path = importMap.imports[args.path]
|
||||||
|
let tempPath = args.path
|
||||||
|
while (!path && tempPath.includes('/')) {
|
||||||
|
tempPath = tempPath.substring(0, tempPath.lastIndexOf('/'))
|
||||||
|
path = args.path.replace(tempPath, importMap.imports[tempPath])
|
||||||
|
}
|
||||||
|
|
||||||
if (!path) {
|
if (!path) {
|
||||||
throw Error(`Import '${args.path}' not found in Import Map`)
|
throw Error(`Import '${args.path}' not found in Import Map`)
|
||||||
@@ -216,8 +220,7 @@ class Compiler {
|
|||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Compiler()
|
export default new Compiler()
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const Execute = () => {
|
|||||||
const output = result.outputFiles[0].text
|
const output = result.outputFiles[0].text
|
||||||
setCompiledCode('')
|
setCompiledCode('')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setCompiledCode(`${output}\n${baseDist}`)
|
setCompiledCode(`(() => {${output}})();\n(() => {${baseDist}})();`)
|
||||||
}, 100)
|
}, 100)
|
||||||
})
|
})
|
||||||
.catch((reason) => {
|
.catch((reason) => {
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ const Create = () => {
|
|||||||
.compile(files, importMap, template.entryPoint)
|
.compile(files, importMap, template.entryPoint)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
const output = result.outputFiles[0].text
|
const output = result.outputFiles[0].text
|
||||||
setCompiledCode(`${output}\n${baseDist}`)
|
setCompiledCode(`(() => {${output}})();\n(() => {${baseDist}})();`)
|
||||||
})
|
})
|
||||||
.catch((reason) => {
|
.catch((reason) => {
|
||||||
void message.error(`编译失败:${reason}`)
|
void message.error(`编译失败:${reason}`)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const View = () => {
|
|||||||
const output = result.outputFiles[0].text
|
const output = result.outputFiles[0].text
|
||||||
setCompiledCode('')
|
setCompiledCode('')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setCompiledCode(`${output}\n${baseDist}`)
|
setCompiledCode(`(() => {${output}})();\n(() => {${baseDist}})();`)
|
||||||
}, 100)
|
}, 100)
|
||||||
})
|
})
|
||||||
.catch((reason) => {
|
.catch((reason) => {
|
||||||
@@ -49,7 +49,7 @@ const View = () => {
|
|||||||
const dist = base64ToStr(toolVo.dist.data!)
|
const dist = base64ToStr(toolVo.dist.data!)
|
||||||
setCompiledCode('')
|
setCompiledCode('')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setCompiledCode(`${dist}\n${baseDist}`)
|
setCompiledCode(`(() => {${dist}})();\n(() => {${baseDist}})();`)
|
||||||
}, 100)
|
}, 100)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
void message.error('载入工具失败')
|
void message.error('载入工具失败')
|
||||||
|
|||||||
Reference in New Issue
Block a user