@vureact/compiler-core 1.0.1 → 1.0.3

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vureact/compiler-core v1.0.0
2
+ * @vureact/compiler-core v1.0.2
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -154,12 +154,19 @@ import * as t3 from "@babel/types";
154
154
  function buildFragmentNode(nodeIR) {
155
155
  return t3.jsxFragment(t3.jsxOpeningFragment(), t3.jsxClosingFragment(), nodeIR);
156
156
  }
157
- function buildTextNode(nodeIR) {
158
- return t3.jsxText(nodeIR);
159
- }
160
157
  function buildJsxExpressionNode(nodeIR) {
161
158
  return t3.jsxExpressionContainer(nodeIR);
162
159
  }
160
+ function buildTextNode(nodeIR) {
161
+ if (/[{}]/.test(nodeIR)) {
162
+ return t3.jsxExpressionContainer(t3.stringLiteral(nodeIR));
163
+ }
164
+ const escapedText = escapeHTML(nodeIR);
165
+ return t3.jsxText(escapedText);
166
+ }
167
+ function escapeHTML(text) {
168
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
169
+ }
163
170
 
164
171
  // src/core/codegen/component/jsx/syntax-processor/process/build-jsx-node.ts
165
172
  function buildJsxNode(nodeIR, ctx) {
@@ -863,6 +870,9 @@ function resolveParam(ctx) {
863
870
  }
864
871
  return;
865
872
  }
873
+ if (!propsTSIface.name) {
874
+ return;
875
+ }
866
876
  const typeIdentifier = t12.identifier(propsTSIface.name);
867
877
  propsIdentifier.typeAnnotation = t12.tsTypeAnnotation(t12.tsTypeReference(typeIdentifier));
868
878
  return propsIdentifier;
@@ -879,7 +889,7 @@ function resolveStatements(local, jsx) {
879
889
  return stmts;
880
890
  }
881
891
  function getHasProps(list) {
882
- return Object.keys(list).length > 0;
892
+ return list.length > 0;
883
893
  }
884
894
 
885
895
  // src/core/codegen/component/script/syntax-processor/process/build-program-preamble.ts
@@ -1341,7 +1351,14 @@ var DOLLAR_IDENTIFIERS = [
1341
1351
  "$pinia",
1342
1352
  "$event"
1343
1353
  ];
1344
- var VUE_PACKAGES = ["vue", "vite", "pinia", "nuxt"];
1354
+ var VUE_PACKAGES = [
1355
+ "vue",
1356
+ "vite",
1357
+ "pinia",
1358
+ "nuxt",
1359
+ // 不需要带到 React 项目中
1360
+ "@vureact/compiler-core"
1361
+ ];
1345
1362
 
1346
1363
  // src/plugins/postcss.ts
1347
1364
  import postcss from "postcss";
@@ -5059,7 +5076,7 @@ function transform(ast, ctx, options) {
5059
5076
  }
5060
5077
 
5061
5078
  // package.json
5062
- var version = "1.0.0";
5079
+ var version = "1.0.2";
5063
5080
  var bin = {
5064
5081
  vureact: "./bin/vureact.js"
5065
5082
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9;/**
2
- * @vureact/compiler-core v1.0.0
2
+ * @vureact/compiler-core v1.0.2
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -154,12 +154,19 @@ function convertJsxChildToExpression(nodeIR) {
154
154
  function buildFragmentNode(nodeIR) {
155
155
  return t3.jsxFragment(t3.jsxOpeningFragment(), t3.jsxClosingFragment(), nodeIR);
156
156
  }
157
- function buildTextNode(nodeIR) {
158
- return t3.jsxText(nodeIR);
159
- }
160
157
  function buildJsxExpressionNode(nodeIR) {
161
158
  return t3.jsxExpressionContainer(nodeIR);
162
159
  }
160
+ function buildTextNode(nodeIR) {
161
+ if (/[{}]/.test(nodeIR)) {
162
+ return t3.jsxExpressionContainer(t3.stringLiteral(nodeIR));
163
+ }
164
+ const escapedText = escapeHTML(nodeIR);
165
+ return t3.jsxText(escapedText);
166
+ }
167
+ function escapeHTML(text) {
168
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
169
+ }
163
170
 
164
171
  // src/core/codegen/component/jsx/syntax-processor/process/build-jsx-node.ts
165
172
  function buildJsxNode(nodeIR, ctx) {
@@ -863,6 +870,9 @@ function resolveParam(ctx) {
863
870
  }
864
871
  return;
865
872
  }
873
+ if (!propsTSIface.name) {
874
+ return;
875
+ }
866
876
  const typeIdentifier = t12.identifier(propsTSIface.name);
867
877
  propsIdentifier.typeAnnotation = t12.tsTypeAnnotation(t12.tsTypeReference(typeIdentifier));
868
878
  return propsIdentifier;
@@ -879,7 +889,7 @@ function resolveStatements(local, jsx) {
879
889
  return stmts;
880
890
  }
881
891
  function getHasProps(list) {
882
- return Object.keys(list).length > 0;
892
+ return list.length > 0;
883
893
  }
884
894
 
885
895
  // src/core/codegen/component/script/syntax-processor/process/build-program-preamble.ts
@@ -1341,7 +1351,14 @@ var DOLLAR_IDENTIFIERS = [
1341
1351
  "$pinia",
1342
1352
  "$event"
1343
1353
  ];
1344
- var VUE_PACKAGES = ["vue", "vite", "pinia", "nuxt"];
1354
+ var VUE_PACKAGES = [
1355
+ "vue",
1356
+ "vite",
1357
+ "pinia",
1358
+ "nuxt",
1359
+ // 不需要带到 React 项目中
1360
+ "@vureact/compiler-core"
1361
+ ];
1345
1362
 
1346
1363
  // src/plugins/postcss.ts
1347
1364
  var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
@@ -5059,7 +5076,7 @@ function transform(ast, ctx, options) {
5059
5076
  }
5060
5077
 
5061
5078
  // package.json
5062
- var version = "1.0.0";
5079
+ var version = "1.0.2";
5063
5080
  var bin = {
5064
5081
  vureact: "./bin/vureact.js"
5065
5082
  };
package/lib/cli.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * @vureact/compiler-core v1.0.0
3
+ * @vureact/compiler-core v1.0.2
4
4
  * (c) 2025-present Ruihong Zhong (Ryan John)
5
5
  * @license MIT
6
6
  */
@@ -12,7 +12,7 @@ import {
12
12
  calcElapsedTime,
13
13
  normalizePath,
14
14
  version
15
- } from "./chunk-U72HWKIZ.esm.js";
15
+ } from "./chunk-BVCPVRCO.esm.js";
16
16
 
17
17
  // src/cli/index.ts
18
18
  import { cac } from "cac";
package/lib/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
3
- * @vureact/compiler-core v1.0.0
3
+ * @vureact/compiler-core v1.0.2
4
4
  * (c) 2025-present Ruihong Zhong (Ryan John)
5
5
  * @license MIT
6
6
  */
@@ -12,7 +12,7 @@
12
12
 
13
13
 
14
14
 
15
- var _chunk5M5CTYQRjs = require('./chunk-5M5CTYQR.js');
15
+ var _chunkE542D3GCjs = require('./chunk-E542D3GC.js');
16
16
 
17
17
  // src/cli/index.ts
18
18
  var _cac = require('cac');
@@ -28,7 +28,7 @@ async function resolveAction(root, options) {
28
28
  const projectRoot = root ? _path2.default.resolve(process.cwd(), root) : process.cwd();
29
29
  const userConfig = await loadUserConfig(projectRoot);
30
30
  const finalConfig = mergeConfig(projectRoot, options, userConfig);
31
- const compiler = new (0, _chunk5M5CTYQRjs.VuReact)(finalConfig);
31
+ const compiler = new (0, _chunkE542D3GCjs.VuReact)(finalConfig);
32
32
  await compiler.execute();
33
33
  if (finalConfig.watch) {
34
34
  setupWatcher(compiler, finalConfig);
@@ -82,7 +82,7 @@ function mergeConfig(projectRoot, options, userConfig) {
82
82
  }
83
83
  function setupWatcher(compiler, config) {
84
84
  const spinner = _ora2.default.call(void 0, );
85
- const cmpHelper = new (0, _chunk5M5CTYQRjs.Helper)(config);
85
+ const cmpHelper = new (0, _chunkE542D3GCjs.Helper)(config);
86
86
  const watcher = _chokidar2.default.watch(cmpHelper.getInputPath(), {
87
87
  ignored: cmpHelper.getExcludes(),
88
88
  persistent: true,
@@ -114,7 +114,7 @@ function setupWatcher(compiler, config) {
114
114
  const fn = processors[ext];
115
115
  const unit = await fn(filePath);
116
116
  cmpHelper.printCoreLogs();
117
- cmpHelper.printCompileInfo(filePath, _chunk5M5CTYQRjs.calcElapsedTime.call(void 0, startTime));
117
+ cmpHelper.printCompileInfo(filePath, _chunkE542D3GCjs.calcElapsedTime.call(void 0, startTime));
118
118
  if (unit) {
119
119
  await _optionalChain([config, 'access', _11 => _11.onChange, 'optionalCall', _12 => _12(event, unit)]);
120
120
  }
@@ -123,7 +123,7 @@ function setupWatcher(compiler, config) {
123
123
  await compiler.processAsset(filePath);
124
124
  cmpHelper.print(
125
125
  _kleur2.default.blue("Copied Asset"),
126
- _kleur2.default.dim(_chunk5M5CTYQRjs.normalizePath.call(void 0, cmpHelper.relativePath(filePath)))
126
+ _kleur2.default.dim(_chunkE542D3GCjs.normalizePath.call(void 0, cmpHelper.relativePath(filePath)))
127
127
  );
128
128
  }
129
129
  spinner.stop();
@@ -134,7 +134,7 @@ function setupWatcher(compiler, config) {
134
134
  await compiler.removeOutputPath(filePath, type2);
135
135
  cmpHelper.print(
136
136
  _kleur2.default.yellow("Removed"),
137
- _kleur2.default.dim(_chunk5M5CTYQRjs.normalizePath.call(void 0, cmpHelper.relativePath(filePath)))
137
+ _kleur2.default.dim(_chunkE542D3GCjs.normalizePath.call(void 0, cmpHelper.relativePath(filePath)))
138
138
  );
139
139
  };
140
140
  if (type === "unlink") {
@@ -163,7 +163,7 @@ function resolveOptions(command) {
163
163
  }
164
164
 
165
165
  // src/cli/index.ts
166
- var [programName] = Object.keys(_chunk5M5CTYQRjs.bin);
166
+ var [programName] = Object.keys(_chunkE542D3GCjs.bin);
167
167
  var cli = _cac.cac.call(void 0, programName);
168
168
  var buildCommand = cli.command("build [root]", "Compile Vue3 to React (one-time)");
169
169
  resolveOptions(buildCommand).action((root, options) => {
@@ -173,4 +173,4 @@ var watchCommand = cli.command("watch [root]", "Compile Vue3 to React and watch
173
173
  resolveOptions(watchCommand).action((root, options) => {
174
174
  resolveAction(root, { ...options, watch: true });
175
175
  });
176
- cli.help().version(_chunk5M5CTYQRjs.version).parse();
176
+ cli.help().version(_chunkE542D3GCjs.version).parse();
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vureact/compiler-core v1.0.0
2
+ * @vureact/compiler-core v1.0.2
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -18,7 +18,7 @@ import {
18
18
  parseOnlyScript,
19
19
  parseSFC,
20
20
  transform
21
- } from "./chunk-U72HWKIZ.esm.js";
21
+ } from "./chunk-BVCPVRCO.esm.js";
22
22
  export {
23
23
  BaseCompiler,
24
24
  CacheKey,
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});/**
2
- * @vureact/compiler-core v1.0.0
2
+ * @vureact/compiler-core v1.0.2
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -18,7 +18,7 @@
18
18
 
19
19
 
20
20
 
21
- var _chunk5M5CTYQRjs = require('./chunk-5M5CTYQR.js');
21
+ var _chunkE542D3GCjs = require('./chunk-E542D3GC.js');
22
22
 
23
23
 
24
24
 
@@ -33,4 +33,4 @@ var _chunk5M5CTYQRjs = require('./chunk-5M5CTYQR.js');
33
33
 
34
34
 
35
35
 
36
- exports.BaseCompiler = _chunk5M5CTYQRjs.BaseCompiler; exports.CacheKey = _chunk5M5CTYQRjs.CacheKey; exports.FileCompiler = _chunk5M5CTYQRjs.FileCompiler; exports.Helper = _chunk5M5CTYQRjs.Helper; exports.VuReact = _chunk5M5CTYQRjs.VuReact; exports.defineConfig = _chunk5M5CTYQRjs.defineConfig; exports.generate = _chunk5M5CTYQRjs.generate; exports.generateComponent = _chunk5M5CTYQRjs.generateComponent; exports.generateOnlyScript = _chunk5M5CTYQRjs.generateOnlyScript; exports.parse = _chunk5M5CTYQRjs.parse; exports.parseOnlyScript = _chunk5M5CTYQRjs.parseOnlyScript; exports.parseSFC = _chunk5M5CTYQRjs.parseSFC; exports.transform = _chunk5M5CTYQRjs.transform;
36
+ exports.BaseCompiler = _chunkE542D3GCjs.BaseCompiler; exports.CacheKey = _chunkE542D3GCjs.CacheKey; exports.FileCompiler = _chunkE542D3GCjs.FileCompiler; exports.Helper = _chunkE542D3GCjs.Helper; exports.VuReact = _chunkE542D3GCjs.VuReact; exports.defineConfig = _chunkE542D3GCjs.defineConfig; exports.generate = _chunkE542D3GCjs.generate; exports.generateComponent = _chunkE542D3GCjs.generateComponent; exports.generateOnlyScript = _chunkE542D3GCjs.generateOnlyScript; exports.parse = _chunkE542D3GCjs.parse; exports.parseOnlyScript = _chunkE542D3GCjs.parseOnlyScript; exports.parseSFC = _chunkE542D3GCjs.parseSFC; exports.transform = _chunkE542D3GCjs.transform;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vureact/compiler-core",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Next Vue to React compiler, compiles Vue 3 syntax into runnable React 18+ code.",
5
5
  "author": "Ruihong Zhong (Ryan John)",
6
6
  "license": "MIT",