@vxrn/compiler 1.14.4 → 1.15.0

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.
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var cache_exports = {};
22
24
  __export(cache_exports, {
@@ -26,10 +28,10 @@ __export(cache_exports, {
26
28
  setCachedTransform: () => setCachedTransform
27
29
  });
28
30
  module.exports = __toCommonJS(cache_exports);
29
- var import_node_crypto = require("node:crypto"),
30
- import_node_fs = require("node:fs"),
31
- import_node_path = require("node:path"),
32
- import_configure = require("./configure.cjs");
31
+ var import_node_crypto = require("node:crypto");
32
+ var import_node_fs = require("node:fs");
33
+ var import_node_path = require("node:path");
34
+ var import_configure = require("./configure.cjs");
33
35
  const stats = {
34
36
  hits: 0,
35
37
  misses: 0,
@@ -37,9 +39,12 @@ const stats = {
37
39
  };
38
40
  function getCacheDir() {
39
41
  const cacheDir = (0, import_node_path.join)(process.cwd(), "node_modules", ".vxrn", "compiler-cache");
40
- return (0, import_node_fs.existsSync)(cacheDir) || (0, import_node_fs.mkdirSync)(cacheDir, {
41
- recursive: !0
42
- }), cacheDir;
42
+ if (!(0, import_node_fs.existsSync)(cacheDir)) {
43
+ (0, import_node_fs.mkdirSync)(cacheDir, {
44
+ recursive: true
45
+ });
46
+ }
47
+ return cacheDir;
43
48
  }
44
49
  function getConfigFingerprint() {
45
50
  return (0, import_node_crypto.createHash)("sha1").update(JSON.stringify({
@@ -50,45 +55,59 @@ function getConfigFingerprint() {
50
55
  })).digest("hex").slice(0, 8);
51
56
  }
52
57
  function getCacheKey(filePath, environment) {
53
- return (0, import_node_crypto.createHash)("sha1").update(`${environment}:${filePath}:${getConfigFingerprint()}`).digest("hex");
58
+ const hash = (0, import_node_crypto.createHash)("sha1").update(`${environment}:${filePath}:${getConfigFingerprint()}`).digest("hex");
59
+ return hash;
54
60
  }
55
61
  function getContentHash(code) {
56
62
  return (0, import_node_crypto.createHash)("sha1").update(code).digest("hex").slice(0, 16);
57
63
  }
58
64
  function getCachedTransform(filePath, code, environment) {
59
65
  try {
60
- const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath,
61
- cacheDir = getCacheDir(),
62
- cacheKey = getCacheKey(cleanPath, environment),
63
- cachePath = (0, import_node_path.join)(cacheDir, `${cacheKey}.json`);
64
- if (!(0, import_node_fs.existsSync)(cachePath)) return stats.misses++, null;
65
- const cached = JSON.parse((0, import_node_fs.readFileSync)(cachePath, "utf-8")),
66
- currentMtime = (0, import_node_fs.statSync)(cleanPath).mtimeMs;
67
- if (cached.mtime !== currentMtime) return stats.misses++, null;
66
+ const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath;
67
+ const cacheDir = getCacheDir();
68
+ const cacheKey = getCacheKey(cleanPath, environment);
69
+ const cachePath = (0, import_node_path.join)(cacheDir, `${cacheKey}.json`);
70
+ if (!(0, import_node_fs.existsSync)(cachePath)) {
71
+ stats.misses++;
72
+ return null;
73
+ }
74
+ const cached = JSON.parse((0, import_node_fs.readFileSync)(cachePath, "utf-8"));
75
+ const currentMtime = (0, import_node_fs.statSync)(cleanPath).mtimeMs;
76
+ if (cached.mtime !== currentMtime) {
77
+ stats.misses++;
78
+ return null;
79
+ }
68
80
  const currentHash = getContentHash(code);
69
- return cached.hash !== currentHash ? (stats.misses++, null) : (stats.hits++, {
81
+ if (cached.hash !== currentHash) {
82
+ stats.misses++;
83
+ return null;
84
+ }
85
+ stats.hits++;
86
+ return {
70
87
  code: cached.code,
71
88
  map: cached.map
72
- });
73
- } catch {
74
- return stats.misses++, null;
89
+ };
90
+ } catch (err) {
91
+ stats.misses++;
92
+ return null;
75
93
  }
76
94
  }
77
95
  function setCachedTransform(filePath, code, result, environment) {
78
96
  try {
79
- const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath,
80
- cacheDir = getCacheDir(),
81
- cacheKey = getCacheKey(cleanPath, environment),
82
- cachePath = (0, import_node_path.join)(cacheDir, `${cacheKey}.json`),
83
- mtime = (0, import_node_fs.statSync)(cleanPath).mtimeMs,
84
- hash = getContentHash(code),
85
- entry = {
86
- mtime,
87
- hash,
88
- code: result.code,
89
- map: result.map
90
- };
91
- (0, import_node_fs.writeFileSync)(cachePath, JSON.stringify(entry), "utf-8"), stats.writes++;
97
+ const cleanPath = filePath.startsWith("\0") ? filePath.slice(1) : filePath;
98
+ const cacheDir = getCacheDir();
99
+ const cacheKey = getCacheKey(cleanPath, environment);
100
+ const cachePath = (0, import_node_path.join)(cacheDir, `${cacheKey}.json`);
101
+ const mtime = (0, import_node_fs.statSync)(cleanPath).mtimeMs;
102
+ const hash = getContentHash(code);
103
+ const entry = {
104
+ mtime,
105
+ hash,
106
+ code: result.code,
107
+ map: result.map
108
+ };
109
+ (0, import_node_fs.writeFileSync)(cachePath, JSON.stringify(entry), "utf-8");
110
+ stats.writes++;
92
111
  } catch (err) {
93
112
  console.warn(`[cache] Failed to write cache for ${filePath}:`, err);
94
113
  }
@@ -99,7 +118,9 @@ function getCacheStats() {
99
118
  };
100
119
  }
101
120
  function logCacheStats() {
102
- if (!process.env.DEBUG_COMPILER_PERF) return;
121
+ if (!process.env.DEBUG_COMPILER_PERF) {
122
+ return;
123
+ }
103
124
  const total = stats.hits + stats.misses;
104
125
  if (total === 0) return;
105
126
  const hitRate = (stats.hits / total * 100).toFixed(1);
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var configure_exports = {};
22
24
  __export(configure_exports, {
@@ -25,10 +27,10 @@ __export(configure_exports, {
25
27
  });
26
28
  module.exports = __toCommonJS(configure_exports);
27
29
  const configuration = {
28
- enableNativewind: !1,
29
- enableReanimated: !1,
30
- enableCompiler: !1,
31
- enableNativeCSS: !1
30
+ enableNativewind: false,
31
+ enableReanimated: false,
32
+ enableCompiler: false,
33
+ enableNativeCSS: false
32
34
  };
33
35
  function configureVXRNCompilerPlugin(_) {
34
36
  Object.assign(configuration, _);
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var constants_exports = {};
22
24
  __export(constants_exports, {
@@ -29,47 +31,47 @@ __export(constants_exports, {
29
31
  module.exports = __toCommonJS(constants_exports);
30
32
  var import_utils = require("@vxrn/utils");
31
33
  const {
32
- debug
33
- } = (0, import_utils.createDebugger)("vxrn:compiler-plugin"),
34
- runtimePublicPath = "/@react-refresh",
35
- asyncGeneratorRegex = /(async \*|async function\*|for await)/,
36
- parsers = {
37
- ".tsx": {
38
- syntax: "typescript",
39
- tsx: !0,
40
- decorators: !0
41
- },
42
- ".ts": {
43
- syntax: "typescript",
44
- tsx: !1,
45
- decorators: !0
46
- },
47
- ".jsx": {
48
- syntax: "ecmascript",
49
- jsx: !0,
50
- importAttributes: !0,
51
- explicitResourceManagement: !0
52
- },
53
- ".js": {
54
- syntax: "ecmascript",
55
- importAttributes: !0,
56
- explicitResourceManagement: !0
57
- },
58
- ".mjs": {
59
- syntax: "ecmascript",
60
- importAttributes: !0,
61
- explicitResourceManagement: !0
62
- },
63
- ".cjs": {
64
- syntax: "ecmascript",
65
- importAttributes: !0,
66
- explicitResourceManagement: !0
67
- },
68
- ".mdx": {
69
- syntax: "ecmascript",
70
- jsx: !0,
71
- importAttributes: !0,
72
- explicitResourceManagement: !0
73
- }
34
+ debug
35
+ } = (0, import_utils.createDebugger)("vxrn:compiler-plugin");
36
+ const runtimePublicPath = "/@react-refresh";
37
+ const asyncGeneratorRegex = /(async \*|async function\*|for await)/;
38
+ const parsers = {
39
+ ".tsx": {
40
+ syntax: "typescript",
41
+ tsx: true,
42
+ decorators: true
43
+ },
44
+ ".ts": {
45
+ syntax: "typescript",
46
+ tsx: false,
47
+ decorators: true
48
+ },
49
+ ".jsx": {
50
+ syntax: "ecmascript",
51
+ jsx: true,
52
+ importAttributes: true,
53
+ explicitResourceManagement: true
54
+ },
55
+ ".js": {
56
+ syntax: "ecmascript",
57
+ importAttributes: true,
58
+ explicitResourceManagement: true
59
+ },
60
+ ".mjs": {
61
+ syntax: "ecmascript",
62
+ importAttributes: true,
63
+ explicitResourceManagement: true
64
+ },
65
+ ".cjs": {
66
+ syntax: "ecmascript",
67
+ importAttributes: true,
68
+ explicitResourceManagement: true
74
69
  },
75
- validParsers = /* @__PURE__ */new Set([...Object.keys(parsers), ".css"]);
70
+ ".mdx": {
71
+ syntax: "ecmascript",
72
+ jsx: true,
73
+ importAttributes: true,
74
+ explicitResourceManagement: true
75
+ }
76
+ };
77
+ const validParsers = /* @__PURE__ */new Set([...Object.keys(parsers), ".css"]);