@stacksjs/stx 0.2.112 → 0.2.113

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.
@@ -49,8 +49,8 @@ async function tryImportCrosswind(importPath) {
49
49
  } catch {}
50
50
  return null;
51
51
  }
52
- function findCrosswindPaths() {
53
- const paths = [], homeDir = process.env.HOME || process.env.USERPROFILE || "";
52
+ function findProjectCrosswindPaths() {
53
+ const paths = [];
54
54
  let currentDir = process.cwd();
55
55
  while (currentDir !== path.dirname(currentDir)) {
56
56
  paths.push(path.join(currentDir, "node_modules", "@cwcss", "crosswind", "dist", "index.js"));
@@ -61,6 +61,10 @@ function findCrosswindPaths() {
61
61
  paths.push(path.join(currentDir, "pantry", "@stacksjs", "crosswind", "dist", "index.js"));
62
62
  currentDir = path.dirname(currentDir);
63
63
  }
64
+ return paths;
65
+ }
66
+ function findDevCrosswindPaths() {
67
+ const paths = [], homeDir = process.env.HOME || process.env.USERPROFILE || "";
64
68
  if (homeDir) {
65
69
  const devPaths = [
66
70
  path.join(homeDir, "Code", "Tools", "crosswind", "packages", "crosswind", "dist", "index.js"),
@@ -81,6 +85,23 @@ export async function loadCrosswind() {
81
85
  return crosswindModule;
82
86
  crosswindLoadAttempted = !0;
83
87
  try {
88
+ const loadFrom = async (candidates) => {
89
+ for (const candidate of candidates) {
90
+ if (!await Bun.file(candidate).exists())
91
+ continue;
92
+ const result = await tryImportCrosswind(candidate);
93
+ if (result) {
94
+ if (!process.env.STACKS_DEV_QUIET)
95
+ console.log(`${colors.green}[Crosswind]${colors.reset} CSS engine loaded from ${path.dirname(path.dirname(candidate))}`);
96
+ return result;
97
+ }
98
+ }
99
+ return null;
100
+ }, projectModule = await loadFrom(findProjectCrosswindPaths());
101
+ if (projectModule) {
102
+ crosswindModule = projectModule;
103
+ return crosswindModule;
104
+ }
84
105
  const importPaths = [
85
106
  "@cwcss/crosswind",
86
107
  "@cwcss/crosswind/dist/index.js",
@@ -96,17 +117,11 @@ export async function loadCrosswind() {
96
117
  return crosswindModule;
97
118
  }
98
119
  }
99
- const localPaths = findCrosswindPaths();
100
- for (const localPath of localPaths)
101
- if (await Bun.file(localPath).exists()) {
102
- const result = await tryImportCrosswind(localPath);
103
- if (result) {
104
- crosswindModule = result;
105
- if (!process.env.STACKS_DEV_QUIET)
106
- console.log(`${colors.green}[Crosswind]${colors.reset} CSS engine loaded from ${path.dirname(path.dirname(localPath))}`);
107
- return crosswindModule;
108
- }
109
- }
120
+ const devModule = await loadFrom(findDevCrosswindPaths());
121
+ if (devModule) {
122
+ crosswindModule = devModule;
123
+ return crosswindModule;
124
+ }
110
125
  throw Error("Crosswind CSSGenerator not found in any location");
111
126
  } catch {
112
127
  console.warn(`${colors.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${colors.reset}`);