@vureact/compiler-core 1.0.2 → 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.
@@ -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
@@ -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
package/lib/cli.esm.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  calcElapsedTime,
13
13
  normalizePath,
14
14
  version
15
- } from "./chunk-BITJMMDW.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
@@ -12,7 +12,7 @@
12
12
 
13
13
 
14
14
 
15
- var _chunkVW3OOYW6js = require('./chunk-VW3OOYW6.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, _chunkVW3OOYW6js.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, _chunkVW3OOYW6js.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, _chunkVW3OOYW6js.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(_chunkVW3OOYW6js.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(_chunkVW3OOYW6js.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(_chunkVW3OOYW6js.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(_chunkVW3OOYW6js.version).parse();
176
+ cli.help().version(_chunkE542D3GCjs.version).parse();
@@ -18,7 +18,7 @@ import {
18
18
  parseOnlyScript,
19
19
  parseSFC,
20
20
  transform
21
- } from "./chunk-BITJMMDW.esm.js";
21
+ } from "./chunk-BVCPVRCO.esm.js";
22
22
  export {
23
23
  BaseCompiler,
24
24
  CacheKey,
@@ -18,7 +18,7 @@
18
18
 
19
19
 
20
20
 
21
- var _chunkVW3OOYW6js = require('./chunk-VW3OOYW6.js');
21
+ var _chunkE542D3GCjs = require('./chunk-E542D3GC.js');
22
22
 
23
23
 
24
24
 
@@ -33,4 +33,4 @@ var _chunkVW3OOYW6js = require('./chunk-VW3OOYW6.js');
33
33
 
34
34
 
35
35
 
36
- exports.BaseCompiler = _chunkVW3OOYW6js.BaseCompiler; exports.CacheKey = _chunkVW3OOYW6js.CacheKey; exports.FileCompiler = _chunkVW3OOYW6js.FileCompiler; exports.Helper = _chunkVW3OOYW6js.Helper; exports.VuReact = _chunkVW3OOYW6js.VuReact; exports.defineConfig = _chunkVW3OOYW6js.defineConfig; exports.generate = _chunkVW3OOYW6js.generate; exports.generateComponent = _chunkVW3OOYW6js.generateComponent; exports.generateOnlyScript = _chunkVW3OOYW6js.generateOnlyScript; exports.parse = _chunkVW3OOYW6js.parse; exports.parseOnlyScript = _chunkVW3OOYW6js.parseOnlyScript; exports.parseSFC = _chunkVW3OOYW6js.parseSFC; exports.transform = _chunkVW3OOYW6js.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.2",
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",