@plumeria/utils 8.0.3 → 9.0.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.
- package/dist/parser.js +6 -9
- package/dist/resolver.js +51 -21
- package/package.json +1 -1
package/dist/parser.js
CHANGED
|
@@ -32,9 +32,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.t = void 0;
|
|
40
37
|
exports.traverse = traverse;
|
|
@@ -45,8 +42,8 @@ exports.extractOndemandStyles = extractOndemandStyles;
|
|
|
45
42
|
exports.deepMerge = deepMerge;
|
|
46
43
|
const createTheme_1 = require("./createTheme");
|
|
47
44
|
const core_1 = require("@swc/core");
|
|
48
|
-
const
|
|
49
|
-
const
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
50
47
|
const rs = __importStar(require("@rust-gear/glob"));
|
|
51
48
|
const zss_engine_1 = require("zss-engine");
|
|
52
49
|
const viewTransition_1 = require("./viewTransition");
|
|
@@ -110,7 +107,7 @@ function traverse(node, visitor) {
|
|
|
110
107
|
walk(node);
|
|
111
108
|
}
|
|
112
109
|
const PROJECT_ROOT = process.cwd().split('node_modules')[0];
|
|
113
|
-
const PATTERN_PATH =
|
|
110
|
+
const PATTERN_PATH = path.join(PROJECT_ROOT, '**/*.{js,jsx,ts,tsx}');
|
|
114
111
|
const GLOB_OPTIONS = {
|
|
115
112
|
exclude: ['**/node_modules/**', '**/dist/**', '**/build/**', '**/.next/**'],
|
|
116
113
|
cwd: PROJECT_ROOT,
|
|
@@ -557,7 +554,7 @@ function scanAll() {
|
|
|
557
554
|
const isFirstPass = passNumber === 1;
|
|
558
555
|
for (const filePath of files) {
|
|
559
556
|
try {
|
|
560
|
-
const stats =
|
|
557
|
+
const stats = fs.statSync(filePath);
|
|
561
558
|
const cached = fileCache[filePath];
|
|
562
559
|
if (cached && cached.mtimeMs === stats.mtimeMs) {
|
|
563
560
|
if (cached.hasCssUsage) {
|
|
@@ -620,7 +617,7 @@ function scanAll() {
|
|
|
620
617
|
}
|
|
621
618
|
continue;
|
|
622
619
|
}
|
|
623
|
-
const source =
|
|
620
|
+
const source = fs.readFileSync(filePath, 'utf8');
|
|
624
621
|
if (!source.includes('@plumeria/core')) {
|
|
625
622
|
fileCache[filePath] = {
|
|
626
623
|
mtimeMs: stats.mtimeMs,
|
|
@@ -753,7 +750,7 @@ function scanAll() {
|
|
|
753
750
|
const objectName = callee.object.value;
|
|
754
751
|
const propertyName = callee.property.value;
|
|
755
752
|
const alias = plumeriaAliases[objectName];
|
|
756
|
-
if (alias === 'NAMESPACE'
|
|
753
|
+
if (alias === 'NAMESPACE') {
|
|
757
754
|
method = propertyName;
|
|
758
755
|
}
|
|
759
756
|
}
|
package/dist/resolver.js
CHANGED
|
@@ -1,11 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
36
|
exports.resolveImportPath = resolveImportPath;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
9
39
|
const tsConfigCache = new Map();
|
|
10
40
|
const tsConfigPathCache = new Map();
|
|
11
41
|
function getTsConfig(startDir) {
|
|
@@ -16,12 +46,12 @@ function getTsConfig(startDir) {
|
|
|
16
46
|
return null;
|
|
17
47
|
return {
|
|
18
48
|
config: tsConfigCache.get(cachedPath) ?? null,
|
|
19
|
-
basePath:
|
|
49
|
+
basePath: path.dirname(cachedPath),
|
|
20
50
|
};
|
|
21
51
|
}
|
|
22
|
-
while (currentDir !==
|
|
23
|
-
const tsConfigPath =
|
|
24
|
-
if (
|
|
52
|
+
while (currentDir !== path.parse(currentDir).root) {
|
|
53
|
+
const tsConfigPath = path.join(process.cwd(), 'tsconfig.json');
|
|
54
|
+
if (fs.existsSync(tsConfigPath)) {
|
|
25
55
|
if (!tsConfigCache.has(tsConfigPath)) {
|
|
26
56
|
try {
|
|
27
57
|
const config = require(tsConfigPath);
|
|
@@ -34,10 +64,10 @@ function getTsConfig(startDir) {
|
|
|
34
64
|
tsConfigPathCache.set(startDir, tsConfigPath);
|
|
35
65
|
return {
|
|
36
66
|
config: tsConfigCache.get(tsConfigPath) ?? null,
|
|
37
|
-
basePath:
|
|
67
|
+
basePath: path.dirname(tsConfigPath),
|
|
38
68
|
};
|
|
39
69
|
}
|
|
40
|
-
currentDir =
|
|
70
|
+
currentDir = path.dirname(currentDir);
|
|
41
71
|
}
|
|
42
72
|
tsConfigPathCache.set(startDir, null);
|
|
43
73
|
return null;
|
|
@@ -53,20 +83,20 @@ const extensions = [
|
|
|
53
83
|
'/index.jsx',
|
|
54
84
|
];
|
|
55
85
|
function resolveWithExtension(basePath) {
|
|
56
|
-
if (
|
|
86
|
+
if (fs.existsSync(basePath) && fs.statSync(basePath).isFile())
|
|
57
87
|
return basePath;
|
|
58
88
|
for (const ext of extensions) {
|
|
59
89
|
const fullPath = basePath + ext;
|
|
60
|
-
if (
|
|
90
|
+
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile())
|
|
61
91
|
return fullPath;
|
|
62
92
|
}
|
|
63
93
|
return null;
|
|
64
94
|
}
|
|
65
95
|
function resolveImportPath(importPath, importerPath) {
|
|
66
96
|
if (importPath.startsWith('.')) {
|
|
67
|
-
return resolveWithExtension(
|
|
97
|
+
return resolveWithExtension(path.resolve(path.dirname(importerPath), importPath));
|
|
68
98
|
}
|
|
69
|
-
const tsConfig = getTsConfig(
|
|
99
|
+
const tsConfig = getTsConfig(path.dirname(importerPath));
|
|
70
100
|
const config = tsConfig?.config;
|
|
71
101
|
if (config?.paths) {
|
|
72
102
|
const root = tsConfig.basePath;
|
|
@@ -75,7 +105,7 @@ function resolveImportPath(importPath, importerPath) {
|
|
|
75
105
|
if (importPath.startsWith(prefix)) {
|
|
76
106
|
for (const target of targets) {
|
|
77
107
|
const resolvedTarget = target.replace(/\*$/, '');
|
|
78
|
-
const candidate =
|
|
108
|
+
const candidate = path.resolve(root, resolvedTarget + importPath.slice(prefix.length));
|
|
79
109
|
const result = resolveWithExtension(candidate);
|
|
80
110
|
if (result)
|
|
81
111
|
return result;
|
|
@@ -83,12 +113,12 @@ function resolveImportPath(importPath, importerPath) {
|
|
|
83
113
|
}
|
|
84
114
|
}
|
|
85
115
|
}
|
|
86
|
-
let currentDir =
|
|
87
|
-
while (currentDir !==
|
|
88
|
-
if (
|
|
89
|
-
return resolveWithExtension(
|
|
116
|
+
let currentDir = path.dirname(importerPath);
|
|
117
|
+
while (currentDir !== path.parse(currentDir).root) {
|
|
118
|
+
if (fs.existsSync(path.join(currentDir, 'package.json'))) {
|
|
119
|
+
return resolveWithExtension(path.resolve(currentDir, importPath));
|
|
90
120
|
}
|
|
91
|
-
currentDir =
|
|
121
|
+
currentDir = path.dirname(currentDir);
|
|
92
122
|
}
|
|
93
123
|
return null;
|
|
94
124
|
}
|