yh-hiprint 2.6.9 → 2.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/libs/es62es5.js DELETED
@@ -1,42 +0,0 @@
1
- import * as babelCore from "@babel/core";
2
- import parser from "@babel/parser";
3
-
4
- // ✅ 只导入实际用到的插件
5
- import pluginTransformArrowFunctions from "@babel/plugin-transform-arrow-functions";
6
- import pluginTransformBlockScoping from "@babel/plugin-transform-block-scoping";
7
- import pluginTransformTemplateLiterals from "@babel/plugin-transform-template-literals";
8
- import pluginTransformShorthandProperties from "@babel/plugin-transform-shorthand-properties";
9
- import pluginTransformComputedProperties from "@babel/plugin-transform-computed-properties";
10
-
11
- /**
12
- * 将 ES6 代码转换为 ES5
13
- * @param {string} code - 用户输入的 ES6+ 代码
14
- * @returns {string} - 编译后的 ES5 代码
15
- */
16
- export default function compileES6toES5 (code) {
17
- try {
18
- // 1. 解析为 AST
19
- const ast = parser.parse(code, {
20
- sourceType: "script",
21
- plugins: [],
22
- });
23
-
24
- // 2. 转换 AST → ES5(内部自动调用 generator)
25
- const result = babelCore.transformFromAstSync(ast, code, {
26
- plugins: [
27
- pluginTransformArrowFunctions,
28
- pluginTransformBlockScoping,
29
- pluginTransformTemplateLiterals,
30
- pluginTransformShorthandProperties,
31
- pluginTransformComputedProperties,
32
- ],
33
- sourceMaps: false,
34
- ast: false, // ✅ 如果你不需要返回 AST,设为 false 更轻量
35
- });
36
-
37
- return result.code;
38
- } catch (err) {
39
- console.error("Babel 编译错误:", err);
40
- throw new Error("编译失败:" + (err.message || err));
41
- }
42
- }