tailwind-styled-v4 5.0.7 → 5.0.8

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.
@@ -11,16 +11,18 @@ var fs__default = /*#__PURE__*/_interopDefault(fs);
11
11
  var path__default = /*#__PURE__*/_interopDefault(path);
12
12
 
13
13
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
14
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
15
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
15
16
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
16
17
  }) : x)(function(x) {
17
18
  if (typeof require !== "undefined") return require.apply(this, arguments);
18
19
  throw Error('Dynamic require of "' + x + '" is not supported');
19
20
  });
21
+ var __esm = (fn, res) => function __init() {
22
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
23
+ };
20
24
 
21
25
  // packages/domain/shared/src/native-resolution.ts
22
- var isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
23
- var nodeModuleRef = null;
24
26
  function getNodeModuleRef() {
25
27
  if (isBrowser) return null;
26
28
  if (nodeModuleRef !== null) return nodeModuleRef;
@@ -33,9 +35,6 @@ function getNodeModuleRef() {
33
35
  return null;
34
36
  }
35
37
  }
36
- var _nodeFs = null;
37
- var _nodePath = null;
38
- var _require = null;
39
38
  function getNodeFs() {
40
39
  if (isBrowser) return { existsSync: () => false };
41
40
  const nodeRequire = getNodeModuleRef();
@@ -61,14 +60,6 @@ function getRequire(_importMetaUrl) {
61
60
  if (!_require) _require = nodeRequire.createRequire(_importMetaUrl);
62
61
  return _require;
63
62
  }
64
- var PLATFORM_MAP = {
65
- "linux-x64": ["@tailwind-styled/native-linux-x64"],
66
- "linux-arm64": ["@tailwind-styled/native-linux-arm64"],
67
- "darwin-x64": ["@tailwind-styled/native-darwin-x64"],
68
- "darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
69
- "win32-x64": ["@tailwind-styled/native-win32-x64"],
70
- "win32-arm64": ["@tailwind-styled/native-win32-arm64"]
71
- };
72
63
  function platformKey() {
73
64
  if (isBrowser) return "browser";
74
65
  return `${process.platform}-${process.arch}`;
@@ -122,10 +113,26 @@ function resolveNativeBinary(runtimeDir) {
122
113
  }
123
114
  return { path: null, source: "not-found", platform, tried };
124
115
  }
116
+ var isBrowser, nodeModuleRef, _nodeFs, _nodePath, _require, PLATFORM_MAP;
117
+ var init_native_resolution = __esm({
118
+ "packages/domain/shared/src/native-resolution.ts"() {
119
+ isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
120
+ nodeModuleRef = null;
121
+ _nodeFs = null;
122
+ _nodePath = null;
123
+ _require = null;
124
+ PLATFORM_MAP = {
125
+ "linux-x64": ["@tailwind-styled/native-linux-x64"],
126
+ "linux-arm64": ["@tailwind-styled/native-linux-arm64"],
127
+ "darwin-x64": ["@tailwind-styled/native-darwin-x64"],
128
+ "darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
129
+ "win32-x64": ["@tailwind-styled/native-win32-x64"],
130
+ "win32-arm64": ["@tailwind-styled/native-win32-arm64"]
131
+ };
132
+ }
133
+ });
125
134
 
126
135
  // packages/domain/shared/src/index.ts
127
- var isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
128
- var nodeModuleRef2 = null;
129
136
  function getNodeModuleRef2() {
130
137
  if (isBrowser2) return null;
131
138
  if (nodeModuleRef2 !== null) return nodeModuleRef2;
@@ -138,7 +145,6 @@ function getNodeModuleRef2() {
138
145
  return null;
139
146
  }
140
147
  }
141
- var _nodeUrl = null;
142
148
  function getNodeUrl() {
143
149
  if (isBrowser2) throw new Error("node:url not available in browser");
144
150
  const nodeRequire = getNodeModuleRef2();
@@ -156,7 +162,6 @@ function getRequire2() {
156
162
  });
157
163
  return nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('turbopackLoader.js', document.baseURI).href)));
158
164
  }
159
- getRequire2();
160
165
  function resolveRuntimeDir(dir, importMetaUrl) {
161
166
  if (isBrowser2) return "";
162
167
  try {
@@ -165,57 +170,80 @@ function resolveRuntimeDir(dir, importMetaUrl) {
165
170
  return process.cwd();
166
171
  }
167
172
  }
168
- var log = (...args) => {
169
- if (process.env.DEBUG?.includes("compiler:native")) {
170
- console.log("[compiler:native]", ...args);
171
- }
172
- };
173
- var NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
174
- var nativeBridge = null;
175
- var bridgeLoadAttempted = false;
176
- var bridgeLoadError = null;
177
- var isValidNativeBridge = (mod) => {
178
- const m = mod;
179
- return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
180
- };
181
- var getNativeBridge = () => {
182
- if (nativeBridge) {
183
- return nativeBridge;
184
- }
185
- if (bridgeLoadAttempted) {
186
- if (bridgeLoadError) {
187
- throw bridgeLoadError;
188
- }
189
- throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
173
+ var isBrowser2, nodeModuleRef2, _nodeUrl;
174
+ var init_src = __esm({
175
+ "packages/domain/shared/src/index.ts"() {
176
+ init_native_resolution();
177
+ isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
178
+ nodeModuleRef2 = null;
179
+ _nodeUrl = null;
180
+ getRequire2();
190
181
  }
191
- bridgeLoadAttempted = true;
192
- try {
193
- const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('turbopackLoader.js', document.baseURI).href)));
194
- const require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('turbopackLoader.js', document.baseURI).href)));
195
- const result = resolveNativeBinary(runtimeDir);
196
- if (result.path && result.path.endsWith(".node")) {
197
- try {
198
- const binding = require2(result.path);
199
- if (isValidNativeBridge(binding)) {
200
- nativeBridge = binding;
201
- log("Native bridge loaded successfully from:", result.path);
202
- return nativeBridge;
182
+ });
183
+ var log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
184
+ var init_nativeBridge = __esm({
185
+ "packages/domain/compiler/src/nativeBridge.ts"() {
186
+ init_src();
187
+ log = (...args) => {
188
+ if (process.env.DEBUG?.includes("compiler:native")) {
189
+ console.log("[compiler:native]", ...args);
190
+ }
191
+ };
192
+ NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/compiler v5] Native binding is required but not available.\nThis package requires native Rust bindings. There is no JavaScript fallback.\nPlease ensure:\n 1. The native module is properly installed\n 2. You have run: npm run build:rust (or use prebuilt binary)\n\nFor help, see: https://tailwind-styled.dev/docs/install";
193
+ nativeBridge = null;
194
+ bridgeLoadAttempted = false;
195
+ bridgeLoadError = null;
196
+ isValidNativeBridge = (mod) => {
197
+ const m = mod;
198
+ return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
199
+ };
200
+ getNativeBridge = () => {
201
+ if (nativeBridge) {
202
+ return nativeBridge;
203
+ }
204
+ if (bridgeLoadAttempted) {
205
+ if (bridgeLoadError) {
206
+ throw bridgeLoadError;
203
207
  }
204
- } catch (e) {
205
- log("Failed to require native binding:", e);
208
+ throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
206
209
  }
207
- }
208
- throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
210
+ bridgeLoadAttempted = true;
211
+ try {
212
+ const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('turbopackLoader.js', document.baseURI).href)));
213
+ const require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('turbopackLoader.js', document.baseURI).href)));
214
+ const result = resolveNativeBinary(runtimeDir);
215
+ if (result.path && result.path.endsWith(".node")) {
216
+ try {
217
+ const binding = require2(result.path);
218
+ if (isValidNativeBridge(binding)) {
219
+ nativeBridge = binding;
220
+ log("Native bridge loaded successfully from:", result.path);
221
+ return nativeBridge;
222
+ }
223
+ } catch (e) {
224
+ log("Failed to require native binding:", e);
225
+ }
226
+ }
227
+ throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
209
228
 
210
229
  Tried paths: ${result.tried.join("\n")}`);
211
- } catch (err) {
212
- bridgeLoadError = err instanceof Error ? err : new Error(String(err));
213
- log("Failed to load native bridge:", bridgeLoadError.message);
214
- throw bridgeLoadError;
230
+ } catch (err) {
231
+ bridgeLoadError = err instanceof Error ? err : new Error(String(err));
232
+ log("Failed to load native bridge:", bridgeLoadError.message);
233
+ throw bridgeLoadError;
234
+ }
235
+ };
236
+ if (typeof process !== "undefined" && !bridgeLoadAttempted) {
237
+ try {
238
+ getNativeBridge();
239
+ } catch {
240
+ }
241
+ }
215
242
  }
216
- };
243
+ });
217
244
 
218
245
  // packages/domain/compiler/src/index.ts
246
+ init_nativeBridge();
219
247
  var transformSource = (source, opts) => {
220
248
  const native = getNativeBridge();
221
249
  if (!native?.transformSource) {
@@ -236,30 +264,7 @@ var runLoaderTransform = (ctx) => {
236
264
  classes: result?.classes || []
237
265
  };
238
266
  };
239
- var fileToRoute = (filepath) => {
240
- const normalized = filepath.replace(/\\/g, "/");
241
- if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
242
- return "__global";
243
- }
244
- const appPageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
245
- if (appPageMatch) return `/${appPageMatch[1]}`;
246
- const appRootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
247
- if (appRootPage) return "/";
248
- const pagesMatch = normalized.match(/\/pages\/(.+?)\.[tj]sx?$/);
249
- if (pagesMatch) {
250
- const pagePath = pagesMatch[1];
251
- if (pagePath.startsWith("_") || pagePath.startsWith("api/")) return "__global";
252
- return pagePath === "index" ? "/" : `/${pagePath}`;
253
- }
254
- return null;
255
- };
256
- var _routeClassMap = /* @__PURE__ */ new Map();
257
267
  var registerFileClasses = (filepath, classes) => {
258
- if (!classes.length) return;
259
- const route = fileToRoute(filepath) ?? "__global";
260
- const existing = _routeClassMap.get(route) ?? /* @__PURE__ */ new Set();
261
- for (const cls of classes) existing.add(cls);
262
- _routeClassMap.set(route, existing);
263
268
  };
264
269
  function parseBool(val, fallback = false) {
265
270
  if (typeof val === "boolean") return val;
@@ -289,6 +294,37 @@ function extractDirective(source) {
289
294
  const stripped = source.slice(match[0].length);
290
295
  return { directive, stripped };
291
296
  }
297
+ var CYCLE_SENTINEL = "_cycle.txt";
298
+ var START_SENTINEL = "_start.txt";
299
+ var _workerCache = /* @__PURE__ */ new Map();
300
+ function getTwClassesDir(safelistPath) {
301
+ return path__default.default.join(path__default.default.dirname(safelistPath), "tw-classes");
302
+ }
303
+ function readSentinel(filePath) {
304
+ try {
305
+ return fs__default.default.readFileSync(filePath, "utf-8").trim();
306
+ } catch {
307
+ return "";
308
+ }
309
+ }
310
+ function clearAndMarkCycle(twClassesDir, startId) {
311
+ try {
312
+ if (fs__default.default.existsSync(twClassesDir)) {
313
+ for (const file of fs__default.default.readdirSync(twClassesDir)) {
314
+ if (file === START_SENTINEL || file === "_webpack-merged.css") continue;
315
+ try {
316
+ fs__default.default.unlinkSync(path__default.default.join(twClassesDir, file));
317
+ } catch {
318
+ }
319
+ }
320
+ } else {
321
+ fs__default.default.mkdirSync(twClassesDir, { recursive: true });
322
+ }
323
+ fs__default.default.writeFileSync(path__default.default.join(twClassesDir, CYCLE_SENTINEL), startId, "utf-8");
324
+ _workerCache.set(twClassesDir, startId);
325
+ } catch {
326
+ }
327
+ }
292
328
  function getPerFileSafelistPath(safelistDir, resourcePath) {
293
329
  const normalized = resourcePath.replace(/\\/g, "/");
294
330
  const slug = normalized.replace(/^.*\/src\//, "").replace(/\.[tj]sx?$/, "").replace(/[^a-zA-Z0-9]/g, "_").slice(0, 80);
@@ -297,9 +333,15 @@ function getPerFileSafelistPath(safelistDir, resourcePath) {
297
333
  function writePerFileSafelist(safelistPath, resourcePath, classes) {
298
334
  if (!safelistPath || classes.length === 0) return;
299
335
  try {
300
- const safelistDir = path__default.default.join(path__default.default.dirname(safelistPath), "tw-classes");
301
- const outPath = getPerFileSafelistPath(safelistDir, resourcePath);
302
- if (!fs__default.default.existsSync(safelistDir)) fs__default.default.mkdirSync(safelistDir, { recursive: true });
336
+ const twClassesDir = getTwClassesDir(safelistPath);
337
+ const startId = readSentinel(path__default.default.join(twClassesDir, START_SENTINEL));
338
+ const cachedCycle = _workerCache.get(twClassesDir) ?? readSentinel(path__default.default.join(twClassesDir, CYCLE_SENTINEL));
339
+ if (startId && cachedCycle !== startId) {
340
+ clearAndMarkCycle(twClassesDir, startId);
341
+ } else if (!fs__default.default.existsSync(twClassesDir)) {
342
+ fs__default.default.mkdirSync(twClassesDir, { recursive: true });
343
+ }
344
+ const outPath = getPerFileSafelistPath(twClassesDir, resourcePath);
303
345
  const sorted = [...new Set(classes)].sort();
304
346
  const css = [
305
347
  `/* tw-safelist: ${path__default.default.basename(resourcePath)} \u2014 auto-generated */`,
@@ -307,6 +349,10 @@ function writePerFileSafelist(safelistPath, resourcePath, classes) {
307
349
  sorted.map((cls) => `.${cls.replace(/([^a-zA-Z0-9_-])/g, "\\$1")} {}`).join("\n"),
308
350
  "}"
309
351
  ].join("\n");
352
+ try {
353
+ if (fs__default.default.readFileSync(outPath, "utf-8") === css) return;
354
+ } catch {
355
+ }
310
356
  fs__default.default.writeFileSync(outPath, css, "utf-8");
311
357
  } catch {
312
358
  }