tailwind-styled-v4 5.0.11 → 5.0.13
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/README.md +100 -4
- package/dist/{analyzeWorkspace-DDOQdzzI.d.ts → analyzeWorkspace-CopJNGmi.d.ts} +2 -0
- package/dist/{analyzeWorkspace-BS5O4rhC.d.mts → analyzeWorkspace-DpVPccjz.d.mts} +2 -0
- package/dist/analyzer.d.mts +4 -4
- package/dist/analyzer.d.ts +4 -4
- package/dist/analyzer.js +34 -69
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +33 -68
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.d.mts +4 -0
- package/dist/animate.d.ts +4 -0
- package/dist/animate.js +33 -11
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +33 -11
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.js +57 -6
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +57 -6
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.js +404 -190
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +401 -187
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +2700 -212
- package/dist/compiler.d.ts +2700 -212
- package/dist/compiler.js +1996 -503
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +1847 -448
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js +17 -4
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs +17 -4
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.d.mts +11 -470
- package/dist/engine.d.ts +11 -470
- package/dist/engine.js +2777 -455
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +2776 -454
- package/dist/engine.mjs.map +1 -1
- package/dist/index-BDQw13kn.d.ts +464 -0
- package/dist/index-DJv28Uzq.d.mts +464 -0
- package/dist/index.browser.mjs +143 -255
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.mts +23 -39
- package/dist/index.d.ts +23 -39
- package/dist/index.js +7234 -1400
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7234 -1400
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +44 -1
- package/dist/next.d.ts +44 -1
- package/dist/next.js +3224 -1065
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +3223 -1066
- package/dist/next.mjs.map +1 -1
- package/dist/rspack.d.mts +9 -0
- package/dist/rspack.d.ts +9 -0
- package/dist/rspack.js +99 -61
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs +99 -61
- package/dist/rspack.mjs.map +1 -1
- package/dist/runtime-css.d.mts +8 -0
- package/dist/runtime-css.d.ts +8 -0
- package/dist/runtime-css.js +23 -7
- package/dist/runtime-css.js.map +1 -1
- package/dist/runtime-css.mjs +23 -7
- package/dist/runtime-css.mjs.map +1 -1
- package/dist/scanner.js +16 -37
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +15 -36
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.d.mts +107 -1
- package/dist/shared.d.ts +107 -1
- package/dist/shared.js +3014 -466
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +3008 -445
- package/dist/shared.mjs.map +1 -1
- package/dist/svelte.js +39 -35
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +38 -34
- package/dist/svelte.mjs.map +1 -1
- package/dist/theme.js +85 -76
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +83 -74
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +2351 -187
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +2351 -187
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +404 -190
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +401 -187
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +2657 -320
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +2657 -320
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.js +39 -35
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +38 -34
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +190 -33
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +190 -33
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/index.node +0 -0
- package/native/tailwind-styled-native.node +0 -0
- package/native/tailwind-styled-native.win32-x64-msvc.node +0 -0
- package/package.json +9 -4
- package/CHANGELOG.md +0 -285
package/dist/rspack.d.mts
CHANGED
|
@@ -6,6 +6,7 @@ declare const RspackPluginOptionsSchema: z.ZodObject<{
|
|
|
6
6
|
addDataAttr: z.ZodOptional<z.ZodBoolean>;
|
|
7
7
|
analyze: z.ZodOptional<z.ZodBoolean>;
|
|
8
8
|
cssEntry: z.ZodOptional<z.ZodString>;
|
|
9
|
+
safelistPath: z.ZodOptional<z.ZodString>;
|
|
9
10
|
}, z.core.$strip>;
|
|
10
11
|
type RspackPluginOptionsInput = z.infer<typeof RspackPluginOptionsSchema>;
|
|
11
12
|
declare const parseRspackPluginOptions: (options: unknown) => {
|
|
@@ -14,6 +15,7 @@ declare const parseRspackPluginOptions: (options: unknown) => {
|
|
|
14
15
|
addDataAttr?: boolean | undefined;
|
|
15
16
|
analyze?: boolean | undefined;
|
|
16
17
|
cssEntry?: string | undefined;
|
|
18
|
+
safelistPath?: string | undefined;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -40,6 +42,7 @@ interface RspackRule {
|
|
|
40
42
|
mode: "zero-runtime";
|
|
41
43
|
addDataAttr: boolean;
|
|
42
44
|
preserveImports: boolean;
|
|
45
|
+
safelistPath?: string;
|
|
43
46
|
};
|
|
44
47
|
}>;
|
|
45
48
|
}
|
|
@@ -60,6 +63,12 @@ interface RspackPluginOptions {
|
|
|
60
63
|
addDataAttr?: boolean;
|
|
61
64
|
/** Enable analyzer. Default: false */
|
|
62
65
|
analyze?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Path ke safelist CSS file.
|
|
68
|
+
* `_tw-state-static.css` ditulis di direktori yang sama.
|
|
69
|
+
* Default: `<cwd>/__tw_safelist.css`
|
|
70
|
+
*/
|
|
71
|
+
safelistPath?: string;
|
|
63
72
|
}
|
|
64
73
|
declare class TailwindStyledRspackPlugin {
|
|
65
74
|
private opts;
|
package/dist/rspack.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare const RspackPluginOptionsSchema: z.ZodObject<{
|
|
|
6
6
|
addDataAttr: z.ZodOptional<z.ZodBoolean>;
|
|
7
7
|
analyze: z.ZodOptional<z.ZodBoolean>;
|
|
8
8
|
cssEntry: z.ZodOptional<z.ZodString>;
|
|
9
|
+
safelistPath: z.ZodOptional<z.ZodString>;
|
|
9
10
|
}, z.core.$strip>;
|
|
10
11
|
type RspackPluginOptionsInput = z.infer<typeof RspackPluginOptionsSchema>;
|
|
11
12
|
declare const parseRspackPluginOptions: (options: unknown) => {
|
|
@@ -14,6 +15,7 @@ declare const parseRspackPluginOptions: (options: unknown) => {
|
|
|
14
15
|
addDataAttr?: boolean | undefined;
|
|
15
16
|
analyze?: boolean | undefined;
|
|
16
17
|
cssEntry?: string | undefined;
|
|
18
|
+
safelistPath?: string | undefined;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -40,6 +42,7 @@ interface RspackRule {
|
|
|
40
42
|
mode: "zero-runtime";
|
|
41
43
|
addDataAttr: boolean;
|
|
42
44
|
preserveImports: boolean;
|
|
45
|
+
safelistPath?: string;
|
|
43
46
|
};
|
|
44
47
|
}>;
|
|
45
48
|
}
|
|
@@ -60,6 +63,12 @@ interface RspackPluginOptions {
|
|
|
60
63
|
addDataAttr?: boolean;
|
|
61
64
|
/** Enable analyzer. Default: false */
|
|
62
65
|
analyze?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Path ke safelist CSS file.
|
|
68
|
+
* `_tw-state-static.css` ditulis di direktori yang sama.
|
|
69
|
+
* Default: `<cwd>/__tw_safelist.css`
|
|
70
|
+
*/
|
|
71
|
+
safelistPath?: string;
|
|
63
72
|
}
|
|
64
73
|
declare class TailwindStyledRspackPlugin {
|
|
65
74
|
private opts;
|
package/dist/rspack.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
require('crypto');
|
|
3
4
|
var fs2 = require('fs');
|
|
4
5
|
var path2 = require('path');
|
|
5
|
-
require('crypto');
|
|
6
6
|
require('url');
|
|
7
7
|
var module$1 = require('module');
|
|
8
8
|
var zod = require('zod');
|
|
@@ -14,16 +14,18 @@ var fs2__default = /*#__PURE__*/_interopDefault(fs2);
|
|
|
14
14
|
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
15
15
|
|
|
16
16
|
/* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
17
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
17
18
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
18
19
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
19
20
|
}) : x)(function(x) {
|
|
20
21
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
21
22
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
22
23
|
});
|
|
24
|
+
var __esm = (fn, res) => function __init() {
|
|
25
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
26
|
+
};
|
|
23
27
|
|
|
24
28
|
// packages/domain/shared/src/esmHelpers.ts
|
|
25
|
-
var isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
26
|
-
var nodeModuleRef = null;
|
|
27
29
|
function getNodeModuleRef() {
|
|
28
30
|
if (isBrowser) return null;
|
|
29
31
|
if (nodeModuleRef !== null) return nodeModuleRef;
|
|
@@ -36,8 +38,6 @@ function getNodeModuleRef() {
|
|
|
36
38
|
return null;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
|
-
var _nodePath = null;
|
|
40
|
-
var _nodeUrl = null;
|
|
41
41
|
function getNodePath() {
|
|
42
42
|
if (isBrowser) throw new Error("node:path not available in browser");
|
|
43
43
|
const nodeRequire = getNodeModuleRef();
|
|
@@ -58,67 +58,86 @@ function getDirname(importMetaUrl) {
|
|
|
58
58
|
const nodeUrl = getNodeUrl();
|
|
59
59
|
return nodePath.dirname(nodeUrl.fileURLToPath(importMetaUrl));
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
var isBrowser, nodeModuleRef, _nodePath, _nodeUrl;
|
|
62
|
+
var init_esmHelpers = __esm({
|
|
63
|
+
"packages/domain/shared/src/esmHelpers.ts"() {
|
|
64
|
+
isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
65
|
+
nodeModuleRef = null;
|
|
66
|
+
_nodePath = null;
|
|
67
|
+
_nodeUrl = null;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
63
70
|
function formatIssuePath(path3) {
|
|
64
71
|
if (!path3 || path3.length === 0) return "(root)";
|
|
65
72
|
return path3.map(
|
|
66
73
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
67
74
|
).join(".");
|
|
68
75
|
}
|
|
69
|
-
var TwError
|
|
70
|
-
|
|
71
|
-
domain
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
76
|
+
var TwError;
|
|
77
|
+
var init_src = __esm({
|
|
78
|
+
"packages/domain/shared/src/index.ts"() {
|
|
79
|
+
init_esmHelpers();
|
|
80
|
+
TwError = class _TwError extends Error {
|
|
81
|
+
/** @deprecated Gunakan source */
|
|
82
|
+
domain;
|
|
83
|
+
source;
|
|
84
|
+
code;
|
|
85
|
+
originalCause;
|
|
86
|
+
constructor(domainOrSource, code, message, cause) {
|
|
87
|
+
super(message);
|
|
88
|
+
this.name = "TwError";
|
|
89
|
+
this.domain = domainOrSource;
|
|
90
|
+
this.source = domainOrSource;
|
|
91
|
+
this.code = code;
|
|
92
|
+
this.originalCause = cause;
|
|
93
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, _TwError);
|
|
94
|
+
}
|
|
95
|
+
static fromIo(code, message) {
|
|
96
|
+
return new _TwError("io", code, message);
|
|
97
|
+
}
|
|
98
|
+
static fromCompile(code, message) {
|
|
99
|
+
return new _TwError("compile", code, message);
|
|
100
|
+
}
|
|
101
|
+
static fromRust(err) {
|
|
102
|
+
if (err instanceof _TwError) return err;
|
|
103
|
+
if (err instanceof Error) return new _TwError("rust", "RUST_ERROR", err.message, err);
|
|
104
|
+
if (err && typeof err === "object") {
|
|
105
|
+
const e = err;
|
|
106
|
+
return new _TwError("rust", e.code ?? "RUST_ERROR", e.message ?? String(err), err);
|
|
107
|
+
}
|
|
108
|
+
return new _TwError("rust", "RUST_ERROR", String(err), err);
|
|
109
|
+
}
|
|
110
|
+
/** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
|
|
111
|
+
static fromZod(err) {
|
|
112
|
+
const first = err.issues?.[0] ?? err.errors?.[0];
|
|
113
|
+
const path3 = formatIssuePath(first?.path);
|
|
114
|
+
const message = first ? `${path3}: ${first.message}` : "Schema validation failed";
|
|
115
|
+
return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
|
|
116
|
+
}
|
|
117
|
+
static wrap(source, code, err) {
|
|
118
|
+
if (err instanceof _TwError) return err;
|
|
119
|
+
if (err instanceof Error) return new _TwError(source, code, err.message, err);
|
|
120
|
+
return new _TwError(source, code, String(err), err);
|
|
121
|
+
}
|
|
122
|
+
toString() {
|
|
123
|
+
return `TwError [${this.source}:${this.code}] ${this.message}`;
|
|
124
|
+
}
|
|
125
|
+
toJSON() {
|
|
126
|
+
return { name: this.name, source: this.source, code: this.code, message: this.message };
|
|
127
|
+
}
|
|
128
|
+
toCliMessage() {
|
|
129
|
+
return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('rspack.js', document.baseURI).href)));
|
|
119
133
|
}
|
|
120
|
-
};
|
|
121
|
-
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// packages/presentation/rspack/src/index.ts
|
|
137
|
+
init_src();
|
|
138
|
+
|
|
139
|
+
// packages/presentation/rspack/src/schemas.ts
|
|
140
|
+
init_src();
|
|
122
141
|
var formatIssuePath2 = (path3) => path3.length > 0 ? path3.map(
|
|
123
142
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
124
143
|
).join(".") : "<root>";
|
|
@@ -142,7 +161,9 @@ var RspackPluginOptionsSchema = zod.z.object({
|
|
|
142
161
|
exclude: zod.z.instanceof(RegExp).optional(),
|
|
143
162
|
addDataAttr: zod.z.boolean().optional(),
|
|
144
163
|
analyze: zod.z.boolean().optional(),
|
|
145
|
-
cssEntry: zod.z.string().optional()
|
|
164
|
+
cssEntry: zod.z.string().optional(),
|
|
165
|
+
/** Path ke safelist CSS file. Default: <cwd>/__tw_safelist.css */
|
|
166
|
+
safelistPath: zod.z.string().optional()
|
|
146
167
|
});
|
|
147
168
|
var parseRspackPluginOptions = (options) => parseWithSchema(RspackPluginOptionsSchema, options ?? {}, "rspack plugin options are invalid");
|
|
148
169
|
|
|
@@ -178,6 +199,22 @@ var TailwindStyledRspackPlugin = class {
|
|
|
178
199
|
(rule2) => typeof rule2 === "object" && rule2 !== null && rule2._tailwindStyledRspackMarker === true
|
|
179
200
|
);
|
|
180
201
|
if (alreadyRegistered) return;
|
|
202
|
+
const safelistPath = this.opts.safelistPath ?? path2__default.default.join(process.cwd(), "__tw_safelist.css");
|
|
203
|
+
const stateStaticPath = path2__default.default.join(path2__default.default.dirname(safelistPath), "_tw-state-static.css");
|
|
204
|
+
if (!fs2__default.default.existsSync(stateStaticPath)) {
|
|
205
|
+
try {
|
|
206
|
+
fs2__default.default.mkdirSync(path2__default.default.dirname(stateStaticPath), { recursive: true });
|
|
207
|
+
fs2__default.default.writeFileSync(
|
|
208
|
+
stateStaticPath,
|
|
209
|
+
`/* _tw-state-static.css \u2014 Auto-generated by tailwind-styled-v4. DO NOT EDIT.
|
|
210
|
+
* Import di CSS entry: @import "./_tw-state-static.css";
|
|
211
|
+
*/
|
|
212
|
+
`,
|
|
213
|
+
"utf-8"
|
|
214
|
+
);
|
|
215
|
+
} catch {
|
|
216
|
+
}
|
|
217
|
+
}
|
|
181
218
|
const rule = {
|
|
182
219
|
_tailwindStyledRspackMarker: true,
|
|
183
220
|
test: this.opts.include ?? /\.[jt]sx?$/,
|
|
@@ -188,7 +225,8 @@ var TailwindStyledRspackPlugin = class {
|
|
|
188
225
|
options: {
|
|
189
226
|
mode: "zero-runtime",
|
|
190
227
|
addDataAttr: this.opts.addDataAttr ?? isDev,
|
|
191
|
-
preserveImports: true
|
|
228
|
+
preserveImports: true,
|
|
229
|
+
safelistPath
|
|
192
230
|
}
|
|
193
231
|
}
|
|
194
232
|
]
|
package/dist/rspack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../packages/domain/shared/src/esmHelpers.ts","../packages/domain/shared/src/index.ts","../packages/presentation/rspack/src/schemas.ts","../packages/presentation/rspack/src/index.ts"],"names":["path","createRequire","formatIssuePath","z","getDirname","fs","rule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,QAAA,KAAa,WAAA;AAGvE,IAAI,aAAA,GAAqB,IAAA;AACzB,SAAS,gBAAA,GAAmB;AAC1B,EAAA,IAAI,WAAW,OAAO,IAAA;AACtB,EAAA,IAAI,aAAA,KAAkB,MAAM,OAAO,aAAA;AACnC,EAAA,IAAI;AAEF,IAAA,MAAM,OAAO,OAAO,SAAA,KAAY,UAAA,GAAa,SAAA,CAAQ,QAAa,CAAA,GAAI,IAAA;AACtE,IAAA,aAAA,GAAgB,IAAA;AAChB,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,aAAA,GAAgB,IAAA;AAChB,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,IAAI,SAAA,GAAiB,IAAA;AACrB,IAAI,QAAA,GAAgB,IAAA;AAKpB,SAAS,WAAA,GAAc;AACrB,EAAA,IAAI,SAAA,EAAW,MAAM,IAAI,KAAA,CAAM,oCAAoC,CAAA;AACnE,EAAA,MAAM,cAAc,gBAAA,EAAiB;AACrC,EAAA,IAAI,CAAC,WAAA,EAAa,MAAM,IAAI,MAAM,uBAAuB,CAAA;AACzD,EAAA,IAAI,CAAC,WAAW,SAAA,GAAY,WAAA,CAAY,cAAc,2PAAe,EAAE,WAAW,CAAA;AAClF,EAAA,OAAO,SAAA;AACT;AACA,SAAS,UAAA,GAAa;AACpB,EAAA,IAAI,SAAA,EAAW,MAAM,IAAI,KAAA,CAAM,mCA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MAAM,KAAA,GAAQ,QAAA,CAAS,OAAA,CAAQ,IAAA,KAAS,YAAA;AACxC,IAAA,MAAM,UAAA,GAAa,kBAAkB,QAAQ,CAAA;AAC7C,IAAA,MAAM,QAAA,GAAW,QAAA,CAAS,OAAA,CAAQ,MAAA,EAAQ,SAAS,EAAC;AACpD,IAAA,MAAM,oBAAoB,QAAA,CAAS,IAAA;AAAA,MACjC,CAACM,UACC,OAAOA,KAAAA,KAAS,YAAYA,KAAAA,KAAS,IAAA,IAAQA,MAAK,2BAAA,KAAgC;AAAA,KACtF;AAEA,IAAA,IAAI,iBAAA,EAAmB;AAEvB,IAAA,MAAM,IAAA,GAAmB;AAAA,MACvB,2BAAA,EAA6B,IAAA;AAAA,MAC7B,IAAA,EAAM,IAAA,CAAK,IAAA,CAAK,OAAA,IAAW,YAAA;AAAA,MAC3B,OAAA,EAAS,IAAA,CAAK,IAAA,CAAK,OAAA,IAAW,cAAA;AAAA,MAC9B,GAAA,EAAK;AAAA,QACH;AAAA,UACE,MAAA,EAAQ,UAAA;AAAA,UACR,OAAA,EAAS;AAAA,YACP,IAAA,EAAM,cAAA;AAAA,YACN,WAAA,EAAa,IAAA,CAAK,IAAA,CAAK,WAAA,IAAe,KAAA;AAAA,YACtC,eAAA,EAAiB;AAAA;AACnB;AACF;AACF,KACF;AAEA,IAAA,QAAA,CAAS,QAAQ,MAAA,GAAS;AAAA,MACxB,GAAI,QAAA,CAAS,OAAA,CAAQ,MAAA,IAAU,EAAC;AAAA,MAChC,KAAA,EAAO,CAAC,IAAA,EAAM,GAAG,QAAQ;AAAA,KAC3B;AAAA,EACF;AACF;AAEO,SAAS,0BAAA,CACd,IAAA,GAA4B,EAAC,EACD;AAC5B,EAAA,OAAO,IAAI,2BAA2B,IAAI,CAAA;AAC5C","file":"rspack.js","sourcesContent":["/**\r\n * ESM-safe runtime helpers untuk monorepo.\r\n *\r\n * Menggantikan pola fragile seperti:\r\n * - `createRequire(import.meta.url)` → gunakan `createEsmRequire()`\r\n * - `__dirname` → gunakan `getDirname(import.meta.url)`\r\n * - `__filename` → gunakan `getFilename(import.meta.url)`\r\n *\r\n * Semua helper ini bekerja di ESM dan CJS.\r\n *\r\n * @module @tailwind-styled/shared/esmHelpers\r\n */\r\n\r\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\n// Safe check for require availability - works in both CJS and ESM\r\nlet nodeModuleRef: any = null\r\nfunction getNodeModuleRef() {\r\n if (isBrowser) return null\r\n if (nodeModuleRef !== null) return nodeModuleRef\r\n try {\r\n // Test if require actually works\r\n const test = typeof require === 'function' ? require('node:module') : null\r\n nodeModuleRef = test\r\n return test\r\n } catch {\r\n nodeModuleRef = null\r\n return null\r\n }\r\n}\r\n\r\nlet _nodePath: any = null\r\nlet _nodeUrl: any = null\r\nlet _nodeFs: any = null\r\nlet _nodeCrypto: any = null\r\nlet _nodeOs: any = null\r\n\r\nfunction getNodePath() {\r\n if (isBrowser) throw new Error(\"node:path not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodePath) _nodePath = nodeRequire.createRequire(import.meta.url)(\"node:path\")\r\n return _nodePath!\r\n}\r\nfunction getNodeUrl() {\r\n if (isBrowser) throw new Error(\"node:url not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire(import.meta.url)(\"node:url\")\r\n return _nodeUrl!\r\n}\r\nfunction getNodeFs() {\r\n if (isBrowser) throw new Error(\"node:fs not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeFs) _nodeFs = nodeRequire.createRequire(import.meta.url)(\"node:fs\")\r\n return _nodeFs!\r\n}\r\nfunction getNodeCrypto() {\r\n if (isBrowser) throw new Error(\"node:crypto not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeCrypto) _nodeCrypto = nodeRequire.createRequire(import.meta.url)(\"node:crypto\")\r\n return _nodeCrypto!\r\n}\r\nfunction getNodeOs() {\r\n if (isBrowser) throw new Error(\"node:os not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeOs) _nodeOs = nodeRequire.createRequire(import.meta.url)(\"node:os\")\r\n return _nodeOs!\r\n}\r\n\r\n/**\r\n * Buat `require()` function yang relative terhadap sebuah ESM module.\r\n *\r\n * @example\r\n * // Ganti: createRequire(import.meta.url)(\"some-pkg\")\r\n * const req = createEsmRequire(import.meta.url)\r\n * const mod = req(\"some-pkg\")\r\n */\r\nexport function createEsmRequire(importMetaUrl: string): NodeRequire {\r\n if (isBrowser) throw new Error(\"require not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n return nodeRequire.createRequire(importMetaUrl)\r\n}\r\n\r\n/**\r\n * Dapat `__dirname` dari `import.meta.url`.\r\n *\r\n * @example\r\n * // Ganti: const __dirname = ...\r\n * const dir = getDirname(import.meta.url)\r\n */\r\nexport function getDirname(importMetaUrl: string): string {\r\n if (isBrowser) return \"\"\r\n const nodePath = getNodePath()\r\n const nodeUrl = getNodeUrl()\r\n return nodePath.dirname(nodeUrl.fileURLToPath(importMetaUrl))\r\n}\r\n\r\n/**\r\n * Dapat `__filename` dari `import.meta.url`.\r\n */\r\nexport function getFilename(importMetaUrl: string): string {\r\n if (isBrowser) return \"\"\r\n return getNodeUrl().fileURLToPath(importMetaUrl)\r\n}\r\n\r\n/**\r\n * Resolve path dari root monorepo (bukan CWD).\r\n * Berguna untuk scripts dan tools yang dipanggil dari lokasi berbeda.\r\n *\r\n * @example\r\n * const root = resolveFromRoot(\"packages/domain/shared/src\")\r\n */\r\nexport function resolveFromRoot(...segments: string[]): string {\r\n if (isBrowser) return segments.join(\"/\")\r\n\r\n const nodePath = getNodePath()\r\n const nodeFs = getNodeFs()\r\n \r\n let dir = getDirname(import.meta.url)\r\n for (let i = 0; i < 10; i++) {\r\n const pkgPath = nodePath.join(dir, \"package.json\")\r\n try {\r\n const pkg = JSON.parse(nodeFs.readFileSync(pkgPath, \"utf-8\"))\r\n if (pkg.workspaces) {\r\n return nodePath.resolve(dir, ...segments)\r\n }\r\n } catch { /* intentionally silent */ }\r\n dir = nodePath.dirname(dir)\r\n }\r\n return nodePath.resolve(process.cwd(), ...segments)\r\n}\r\n\r\n/**\r\n * Require sebuah module dengan fallback ke null jika tidak tersedia.\r\n * Berguna untuk optional dependencies.\r\n *\r\n * @example\r\n * const oxc = tryRequire(\"oxc-parser\", import.meta.url)\r\n * if (!oxc) console.warn(\"oxc-parser not installed\")\r\n */\r\nexport function tryRequire<T = unknown>(\r\n moduleName: string,\r\n importMetaUrl: string\r\n): T | null {\r\n if (isBrowser) return null\r\n try {\r\n return createEsmRequire(importMetaUrl)(moduleName) as T\r\n } catch { /* intentionally silent — optional dep */ }\r\n return null\r\n}\r\n\r\n/**\r\n * Resolve .node binary path yang cross-platform dan ESM-safe.\r\n * Menggantikan pola `path.resolve(__dirname, \"../native.node\")`.\r\n */\r\nexport function resolveNativeNodePath(\r\n importMetaUrl: string,\r\n ...relativeSegments: string[]\r\n): string {\r\n if (isBrowser) return relativeSegments.join(\"/\")\r\n return getNodePath().resolve(getDirname(importMetaUrl), ...relativeSegments)\r\n}\r\n","import { createHash } from \"node:crypto\"\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\nimport { fileURLToPath } from \"node:url\"\r\nimport { createRequire } from \"node:module\"\r\n\r\n// Native-only: Node.js is always available. No browser fallback.\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Types\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type TokenMap = Record<string, string>\r\n\r\nexport type VariantValue = string | number | boolean | undefined\r\n\r\nexport type VariantProps = Record<string, VariantValue>\r\n\r\nexport type HtmlTagName = keyof HTMLElementTagNameMap\r\n\r\nexport type CompoundCondition = Record<string, string | number | boolean>\r\n\r\nexport type VariantMatrix = Record<string, Array<string | number | boolean>>\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Logging\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface Logger {\r\n warn(...args: unknown[]): void\r\n debug(...args: unknown[]): void\r\n error(...args: unknown[]): void\r\n log(...args: unknown[]): void\r\n}\r\n\r\nexport function createLogger(namespace: string): Logger {\r\n const prefix = `[${namespace}]`\r\n return {\r\n warn(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n debug(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n error(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n log(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n }\r\n}\r\n\r\nexport function createDebugLogger(namespace: string, label?: string): (msg: string) => void {\r\n const prefix = label ? `[${namespace}:${label}]` : `[${namespace}]`\r\n return (msg: string) => {\r\n if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {\r\n console.debug(prefix, msg)\r\n }\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error handling\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type ErrorSource = \"rust\" | \"validation\" | \"compile\" | \"io\" | \"config\" | \"unknown\"\r\n\r\ntype ZodLikeIssue = {\r\n path?: readonly PropertyKey[]\r\n message?: string\r\n}\r\n\r\nfunction formatIssuePath(path?: readonly PropertyKey[]): string {\r\n if (!path || path.length === 0) return \"(root)\"\r\n return path\r\n .map((segment) =>\r\n typeof segment === \"symbol\" ? segment.description ?? segment.toString() : String(segment)\r\n )\r\n .join(\".\")\r\n}\r\n\r\nexport class TwError extends Error {\r\n /** @deprecated Gunakan source */\r\n public readonly domain: string\r\n public readonly source: ErrorSource\r\n public readonly code: string\r\n public readonly originalCause?: unknown\r\n\r\n constructor(domainOrSource: string, code: string, message: string, cause?: unknown) {\r\n super(message)\r\n this.name = \"TwError\"\r\n this.domain = domainOrSource\r\n this.source = domainOrSource as ErrorSource\r\n this.code = code\r\n this.originalCause = cause\r\n if (Error.captureStackTrace) Error.captureStackTrace(this, TwError)\r\n }\r\n\r\n static fromIo(code: string, message: string): TwError {\r\n return new TwError(\"io\", code, message)\r\n }\r\n\r\n static fromCompile(code: string, message: string): TwError {\r\n return new TwError(\"compile\", code, message)\r\n }\r\n\r\n static fromRust(err: { code?: string; message?: string } | Error | unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(\"rust\", \"RUST_ERROR\", err.message, err)\r\n if (err && typeof err === \"object\") {\r\n const e = err as { code?: string; message?: string }\r\n return new TwError(\"rust\", e.code ?? \"RUST_ERROR\", e.message ?? String(err), err)\r\n }\r\n return new TwError(\"rust\", \"RUST_ERROR\", String(err), err)\r\n }\r\n\r\n /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */\r\n static fromZod(err: { issues?: ZodLikeIssue[]; errors?: ZodLikeIssue[] }): TwError {\r\n const first = err.issues?.[0] ?? err.errors?.[0]\r\n const path = formatIssuePath(first?.path)\r\n const message = first ? `${path}: ${first.message}` : \"Schema validation failed\"\r\n return new TwError(\"validation\", \"SCHEMA_VALIDATION_FAILED\", message, err)\r\n }\r\n\r\n static wrap(source: string, code: string, err: unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(source, code, err.message, err)\r\n return new TwError(source, code, String(err), err)\r\n }\r\n\r\n override toString(): string {\r\n return `TwError [${this.source}:${this.code}] ${this.message}`\r\n }\r\n\r\n toJSON(): { name: string; source: string; code: string; message: string } {\r\n return { name: this.name, source: this.source, code: this.code, message: this.message }\r\n }\r\n\r\n toCliMessage(): string {\r\n return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`\r\n }\r\n}\r\n\r\nexport function wrapUnknownError(domain: string, code: string, error: unknown): TwError {\r\n return TwError.wrap(domain, code, error)\r\n}\r\n\r\nexport function isTwError(err: unknown): err is TwError {\r\n return err instanceof TwError\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Native binding resolution\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface LoadNativeBindingOptions<T> {\r\n runtimeDir: string\r\n candidates: string[]\r\n isValid: (module: unknown) => module is T\r\n invalidExportMessage: string\r\n}\r\n\r\nexport interface LoadNativeBindingResult<T> {\r\n binding: T | null\r\n loadErrors: Array<{ path: string; message: string }>\r\n loadedPath?: string\r\n}\r\n\r\nexport function loadNativeBinding<T>(options: LoadNativeBindingOptions<T>): LoadNativeBindingResult<T> {\r\n const { runtimeDir, candidates, isValid } = options\r\n const loadErrors: Array<{ path: string; message: string }> = []\r\n\r\n for (const candidate of candidates) {\r\n const candidatePath = path.resolve(runtimeDir, candidate)\r\n try {\r\n if (!fs.existsSync(candidatePath) && !fs.existsSync(candidatePath + \".node\")) {\r\n continue\r\n }\r\n const mod = requireNativeModule(candidatePath)\r\n if (mod && isValid(mod)) {\r\n return { binding: mod, loadErrors, loadedPath: candidatePath }\r\n }\r\n loadErrors.push({ path: candidatePath, message: options.invalidExportMessage })\r\n } catch (e) {\r\n loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) })\r\n }\r\n }\r\n\r\n return { binding: null, loadErrors }\r\n}\r\n\r\nconst _require = createRequire(import.meta.url)\r\n\r\nfunction requireNativeModule(p: string): unknown {\r\n return _require(p)\r\n}\r\n\r\nexport interface ResolveCandidatesOptions {\r\n runtimeDir?: string\r\n envVarNames?: string[]\r\n includeDefaultCandidates?: boolean\r\n enforceNodeExtensionForEnvPath?: boolean\r\n /** @deprecated — ignored, kept for backward compat */\r\n packageName?: string\r\n}\r\n\r\nexport function resolveNativeBindingCandidates(options: ResolveCandidatesOptions): string[] {\r\n const {\r\n envVarNames = [\"TW_NATIVE_PATH\", \"TWS_NATIVE_PATH\"],\r\n includeDefaultCandidates = true,\r\n enforceNodeExtensionForEnvPath = false,\r\n } = options\r\n // Default ke cwd kalau runtimeDir tidak disediakan\r\n const runtimeDir = options.runtimeDir || process.cwd()\r\n const candidates: string[] = []\r\n\r\n for (const envVar of envVarNames) {\r\n const envPath = process.env[envVar]\r\n if (envPath) {\r\n candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(\".node\") ? envPath + \".node\" : envPath)\r\n }\r\n }\r\n\r\n if (!includeDefaultCandidates) return candidates\r\n\r\n if (fs.existsSync(runtimeDir)) {\r\n try {\r\n for (const entry of fs.readdirSync(runtimeDir)) {\r\n if (entry.endsWith(\".node\")) candidates.push(entry)\r\n }\r\n } catch { /* ignore read errors */ }\r\n }\r\n\r\n const BINARY_NAMES = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n const napiPlatform = process.platform === \"linux\" && process.arch === \"x64\" ? \"linux-x64-gnu\"\r\n : process.platform === \"linux\" && process.arch === \"arm64\" ? \"linux-arm64-gnu\"\r\n : `${process.platform}-${process.arch}`\r\n\r\n for (const bin of BINARY_NAMES) {\r\n candidates.push(path.resolve(runtimeDir, `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, `${bin}.${napiPlatform}.node`))\r\n // 1 level: dist/ → package-root/native/ (published npm package)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // cwd fallback (user project root)\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.${napiPlatform}.node`))\r\n // 4 level: dist/ → package/ → domain/ → packages/ → repo-root/ (monorepo dev)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // 3 level fallback\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n }\r\n\r\n return Array.from(new Set(candidates))\r\n}\r\n\r\nexport function resolveRuntimeDir(dir: string | undefined, importMetaUrl: string): string {\r\n if (dir) return path.resolve(dir)\r\n try {\r\n return path.dirname(fileURLToPath(importMetaUrl))\r\n } catch {\r\n return process.cwd()\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Hashing\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function hashContent(content: string, algorithm: string = \"md5\", length?: number): string {\r\n const hash = createHash(algorithm).update(content).digest(\"hex\")\r\n return length ? hash.slice(0, length) : hash\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error formatting\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function formatErrorMessage(error: unknown): string {\r\n if (error instanceof TwError) return error.toString()\r\n if (error instanceof Error) return error.message\r\n return String(error)\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// LRU Cache\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport class LRUCache<K, V> {\r\n private capacity: number\r\n private cache: Map<K, V>\r\n\r\n constructor(capacity: number) {\r\n this.capacity = capacity\r\n this.cache = new Map()\r\n }\r\n\r\n get(key: K): V | undefined {\r\n if (!this.cache.has(key)) return undefined\r\n const value = this.cache.get(key)!\r\n this.cache.delete(key)\r\n this.cache.set(key, value)\r\n return value\r\n }\r\n\r\n set(key: K, value: V): void {\r\n if (this.cache.has(key)) {\r\n this.cache.delete(key)\r\n } else if (this.cache.size >= this.capacity) {\r\n const firstKey = this.cache.keys().next().value\r\n if (firstKey !== undefined) {\r\n this.cache.delete(firstKey)\r\n }\r\n }\r\n this.cache.set(key, value)\r\n }\r\n\r\n delete(key: K): boolean {\r\n return this.cache.delete(key)\r\n }\r\n\r\n has(key: K): boolean {\r\n return this.cache.has(key)\r\n }\r\n\r\n clear(): void {\r\n this.cache.clear()\r\n }\r\n\r\n entries(): IterableIterator<[K, V]> {\r\n return this.cache.entries()\r\n }\r\n\r\n get size(): number {\r\n return this.cache.size\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Trace Utilities\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TraceSnapshot, TraceSummary } from \"./trace\"\r\nexport {\r\n getHealthColor,\r\n getModeColor,\r\n formatMemory,\r\n formatDuration,\r\n calculateHealth,\r\n getBuildTimeColor,\r\n getMemoryColor,\r\n createTraceSnapshot,\r\n getPipelinePercentages,\r\n} from \"./trace\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Performance Telemetry\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error Codes\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { ErrorCode } from \"./error-codes\"\r\nexport { ERROR_CODES, getSuggestion, formatErrorCode } from \"./error-codes\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Tailwind Compatibility\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TailwindInfo } from \"./compatibility\"\r\nexport { detectTailwind, assertTailwindV4, getTailwindVersion, isTailwindV4 } from \"./compatibility\"\r\n\r\n// ── Native binding schemas (Zod boundary validation)\r\nexport {\r\n NativeScanFileSchema, NativeScanResultSchema,\r\n NativeAnalyzerReportSchema, NativeTransformResultSchema,\r\n NativeCssCompileResultSchema, NativeWatchResultSchema,\r\n NativeCacheEntrySchema, NativeCacheReadResultSchema,\r\n safeParseNative, parseNative,\r\n} from './native-schemas'\r\n\r\n// ── ESM-safe runtime helpers ──────────────────────────────────────────────\r\nexport {\r\n createEsmRequire,\r\n getDirname,\r\n getFilename,\r\n resolveFromRoot,\r\n tryRequire,\r\n resolveNativeNodePath,\r\n} from \"./esmHelpers\"\r\n\r\n// ── Performance telemetry ────────────────────────────────────────────────────\r\nexport {\r\n TelemetryCollector,\r\n getGlobalTelemetry,\r\n resetGlobalTelemetry,\r\n createBuildTimer,\r\n type BuildTelemetry,\r\n type TelemetrySummary,\r\n type BuildPhases,\r\n} from \"./telemetry\"\r\n\r\n// ── Config/JSON schema validation ─────────────────────────────────────────────\r\nexport {\r\n ScanCacheSchema,\r\n ScanCacheClassEntrySchema,\r\n TailwindConfigSchema,\r\n RegistryPluginEntrySchema,\r\n RegistryFileSchema,\r\n PackageJsonSchema,\r\n parseJsonWithSchema,\r\n parseJsonFileWithSchema,\r\n type ScanCache,\r\n type ScanCacheClassEntry,\r\n type TailwindConfig,\r\n type RegistryPluginEntry,\r\n type RegistryFile,\r\n type PackageJson,\r\n} from \"./configSchemas\"\r\n\r\n// ── Worker/bootstrap path resolution ─────────────────────────────────────────\r\nexport {\r\n resolveWorkerPath,\r\n resolveLoaderPath,\r\n type WorkerPathOptions,\r\n type WorkerPathResult,\r\n} from \"./workerResolver\"\r\n\r\n// ── Codegen helpers ───────────────────────────────────────────────────────────\r\nexport {\r\n generateComponentCode,\r\n generateStorybookStory,\r\n generateClassRenameCodemod,\r\n generateBarrelFile,\r\n type ComponentCodegenOptions,\r\n} from \"./codegen\"\r\n\r\n// ── Native binary resolution (QA #1) ─────────────────────────────────────────\r\nexport {\r\n resolveNativeBinary,\r\n formatNativeNotFoundError,\r\n type NativeResolutionResult,\r\n} from \"./native-resolution\"\r\n\r\n// ── Shared observability contract ────────────────────────────────────────────\r\nexport {\r\n createObservabilityClient,\r\n type ClassInspection,\r\n type ClassProperty,\r\n type ClassUsageLocation,\r\n type BuildTrace,\r\n type BuildPhaseTrace,\r\n type DashboardMetrics,\r\n type DashboardSummary,\r\n type ObservabilityClient,\r\n} from \"./observability\"","import { z } from \"zod\"\r\nimport { TwError } from \"@tailwind-styled/shared\"\r\n\r\nconst formatIssuePath = (path: readonly PropertyKey[]): string =>\r\n path.length > 0\r\n ? path\r\n .map((segment) =>\r\n typeof segment === \"symbol\" ? segment.description ?? segment.toString() : String(segment)\r\n )\r\n .join(\".\")\r\n : \"<root>\"\r\n\r\nconst formatIssues = (error: z.ZodError): string =>\r\n error.issues\r\n .map((issue) => {\r\n const p = formatIssuePath(issue.path)\r\n return `${p}: ${issue.message}`\r\n })\r\n .join(\"; \")\r\n\r\nconst parseWithSchema = <T>(schema: z.ZodType<T>, data: unknown, label: string): T => {\r\n const parsed = schema.safeParse(data)\r\n if (parsed.success) return parsed.data\r\n const details = formatIssues(parsed.error)\r\n throw new TwError(\r\n \"validation\",\r\n \"SCHEMA_VALIDATION_FAILED\",\r\n details ? `${label}: ${details}` : label,\r\n parsed.error\r\n )\r\n}\r\n\r\nexport const RspackPluginOptionsSchema = z.object({\r\n include: z.instanceof(RegExp).optional(),\r\n exclude: z.instanceof(RegExp).optional(),\r\n addDataAttr: z.boolean().optional(),\r\n analyze: z.boolean().optional(),\r\n cssEntry: z.string().optional(),\r\n})\r\n\r\nexport type RspackPluginOptionsInput = z.infer<typeof RspackPluginOptionsSchema>\r\n\r\nexport const parseRspackPluginOptions = (options: unknown) =>\r\n parseWithSchema(RspackPluginOptionsSchema, options ?? {}, \"rspack plugin options are invalid\")\r\n","/**\r\n * tailwind-styled-v4 - Rspack Plugin v5 (stable)\r\n *\r\n * Usage:\r\n * import { tailwindStyledRspackPlugin } from \"@tailwind-styled/rspack\"\r\n *\r\n * export default defineConfig({\r\n * plugins: [tailwindStyledRspackPlugin()],\r\n * })\r\n *\r\n * v5:\r\n * - Simplified API\r\n * - Mode always zero-runtime\r\n */\r\n\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\nimport { getDirname as getEsmDirname } from \"@tailwind-styled/shared\"\r\n\r\nimport { parseRspackPluginOptions } from \"./schemas\"\r\n\r\nfunction getDirname(): string {\r\n if (typeof __dirname !== \"undefined\") {\r\n return __dirname\r\n }\r\n if (typeof import.meta !== \"undefined\" && import.meta.url) {\r\n return getEsmDirname(import.meta.url)\r\n }\r\n return process.cwd()\r\n}\r\n\r\nfunction resolveLoaderPath(basename: string): string {\r\n const runtimeDir = getDirname()\r\n const preferredExtensions =\r\n typeof __dirname !== \"undefined\" && __dirname.length > 0 ? [\".cjs\", \".js\"] : [\".js\", \".cjs\"]\r\n\r\n for (const ext of preferredExtensions) {\r\n const candidate = path.resolve(runtimeDir, `${basename}${ext}`)\r\n if (fs.existsSync(candidate)) return candidate\r\n }\r\n\r\n return path.resolve(runtimeDir, `${basename}.js`)\r\n}\r\n\r\ninterface RspackRule {\r\n _tailwindStyledRspackMarker?: boolean\r\n test?: RegExp\r\n exclude?: RegExp\r\n use?: Array<{\r\n loader: string\r\n options: {\r\n mode: \"zero-runtime\"\r\n addDataAttr: boolean\r\n preserveImports: boolean\r\n }\r\n }>\r\n}\r\n\r\ninterface RspackCompiler {\r\n options: {\r\n mode?: string\r\n module?: {\r\n rules?: RspackRule[]\r\n }\r\n }\r\n}\r\n\r\nexport interface RspackPluginOptions {\r\n /** File patterns to include. Default: /\\.[jt]sx?$/ */\r\n include?: RegExp\r\n /** File patterns to exclude. Default: /node_modules/ */\r\n exclude?: RegExp\r\n /** Add data-tw debug attributes in dev. Default: true in dev */\r\n addDataAttr?: boolean\r\n /** Enable analyzer. Default: false */\r\n analyze?: boolean\r\n}\r\n\r\nexport class TailwindStyledRspackPlugin {\r\n private opts: RspackPluginOptions\r\n\r\n constructor(opts: RspackPluginOptions = {}) {\r\n this.opts = parseRspackPluginOptions(opts)\r\n }\r\n\r\n apply(compiler: RspackCompiler): void {\r\n const isDev = compiler.options.mode !== \"production\"\r\n const loaderPath = resolveLoaderPath(\"loader\")\r\n const existing = compiler.options.module?.rules ?? []\r\n const alreadyRegistered = existing.some(\r\n (rule) =>\r\n typeof rule === \"object\" && rule !== null && rule._tailwindStyledRspackMarker === true\r\n )\r\n\r\n if (alreadyRegistered) return\r\n\r\n const rule: RspackRule = {\r\n _tailwindStyledRspackMarker: true,\r\n test: this.opts.include ?? /\\.[jt]sx?$/,\r\n exclude: this.opts.exclude ?? /node_modules/,\r\n use: [\r\n {\r\n loader: loaderPath,\r\n options: {\r\n mode: \"zero-runtime\",\r\n addDataAttr: this.opts.addDataAttr ?? isDev,\r\n preserveImports: true,\r\n },\r\n },\r\n ],\r\n }\r\n\r\n compiler.options.module = {\r\n ...(compiler.options.module ?? {}),\r\n rules: [rule, ...existing],\r\n }\r\n }\r\n}\r\n\r\nexport function tailwindStyledRspackPlugin(\r\n opts: RspackPluginOptions = {}\r\n): TailwindStyledRspackPlugin {\r\n return new TailwindStyledRspackPlugin(opts)\r\n}\r\n\r\nexport default tailwindStyledRspackPlugin\r\n\r\nexport {\r\n parseRspackPluginOptions,\r\n type RspackPluginOptionsInput,\r\n RspackPluginOptionsSchema,\r\n} from \"./schemas\"\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../packages/domain/shared/src/esmHelpers.ts","../packages/domain/shared/src/index.ts","../packages/presentation/rspack/src/index.ts","../packages/presentation/rspack/src/schemas.ts"],"names":["path","createRequire","formatIssuePath","z","getDirname","fs","rule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAS,gBAAA,GAAwD;AAC/D,EAAA,IAAI,WAAW,OAAO,IAAA;AACtB,EAAA,IAAI,aAAA,KAAkB,MAAM,OAAO,aAAA;AACnC,EAAA,IAAI;AAEF,IAAA,MAAM,OAAO,OAAO,SAAA,KAAY,UAAA,GAAc,SAAA,CAAQ,QAAa,CAAA,GAAqC,IAAA;AACxG,IAAA,aAAA,GAAgB,IAAA;AAChB,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,aAAA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ACF,KACF;AAEA,IAAA,QAAA,CAAS,QAAQ,MAAA,GAAS;AAAA,MACxB,GAAI,QAAA,CAAS,OAAA,CAAQ,MAAA,IAAU,EAAC;AAAA,MAChC,KAAA,EAAO,CAAC,IAAA,EAAM,GAAG,QAAQ;AAAA,KAC3B;AAAA,EACF;AACF;AAEO,SAAS,0BAAA,CACd,IAAA,GAA4B,EAAC,EACD;AAC5B,EAAA,OAAO,IAAI,2BAA2B,IAAI,CAAA;AAC5C","file":"rspack.js","sourcesContent":["/**\r\n * ESM-safe runtime helpers untuk monorepo.\r\n *\r\n * Menggantikan pola fragile seperti:\r\n * - `createRequire(import.meta.url)` → gunakan `createEsmRequire()`\r\n * - `__dirname` → gunakan `getDirname(import.meta.url)`\r\n * - `__filename` → gunakan `getFilename(import.meta.url)`\r\n *\r\n * Semua helper ini bekerja di ESM dan CJS.\r\n *\r\n * @module @tailwind-styled/shared/esmHelpers\r\n */\r\n\r\nconst isBrowser = typeof window !== \"undefined\" || typeof document !== \"undefined\"\r\n\r\n// Safe check for require availability - works in both CJS and ESM\r\nlet nodeModuleRef: typeof import(\"node:module\") | null = null\r\nfunction getNodeModuleRef(): typeof import(\"node:module\") | null {\r\n if (isBrowser) return null\r\n if (nodeModuleRef !== null) return nodeModuleRef\r\n try {\r\n // Test if require actually works\r\n const test = typeof require === 'function' ? (require('node:module') as typeof import(\"node:module\")) : null\r\n nodeModuleRef = test\r\n return test\r\n } catch {\r\n nodeModuleRef = null\r\n return null\r\n }\r\n}\r\n\r\nlet _nodePath: typeof import(\"node:path\") | null = null\r\nlet _nodeUrl: typeof import(\"node:url\") | null = null\r\nlet _nodeFs: typeof import(\"node:fs\") | null = null\r\nlet _nodeCrypto: typeof import(\"node:crypto\") | null = null\r\nlet _nodeOs: typeof import(\"node:os\") | null = null\r\n\r\nfunction getNodePath(): typeof import(\"node:path\") {\r\n if (isBrowser) throw new Error(\"node:path not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodePath) _nodePath = nodeRequire.createRequire(import.meta.url)(\"node:path\") as typeof import(\"node:path\")\r\n return _nodePath!\r\n}\r\nfunction getNodeUrl(): typeof import(\"node:url\") {\r\n if (isBrowser) throw new Error(\"node:url not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire(import.meta.url)(\"node:url\") as typeof import(\"node:url\")\r\n return _nodeUrl!\r\n}\r\nfunction getNodeFs(): typeof import(\"node:fs\") {\r\n if (isBrowser) throw new Error(\"node:fs not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeFs) _nodeFs = nodeRequire.createRequire(import.meta.url)(\"node:fs\") as typeof import(\"node:fs\")\r\n return _nodeFs!\r\n}\r\nfunction getNodeCrypto(): typeof import(\"node:crypto\") {\r\n if (isBrowser) throw new Error(\"node:crypto not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeCrypto) _nodeCrypto = nodeRequire.createRequire(import.meta.url)(\"node:crypto\") as typeof import(\"node:crypto\")\r\n return _nodeCrypto!\r\n}\r\nfunction getNodeOs(): typeof import(\"node:os\") {\r\n if (isBrowser) throw new Error(\"node:os not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n if (!_nodeOs) _nodeOs = nodeRequire.createRequire(import.meta.url)(\"node:os\") as typeof import(\"node:os\")\r\n return _nodeOs!\r\n}\r\n\r\n/**\r\n * Buat `require()` function yang relative terhadap sebuah ESM module.\r\n *\r\n * @example\r\n * // Ganti: createRequire(import.meta.url)(\"some-pkg\")\r\n * const req = createEsmRequire(import.meta.url)\r\n * const mod = req(\"some-pkg\")\r\n */\r\nexport function createEsmRequire(importMetaUrl: string): NodeRequire {\r\n if (isBrowser) throw new Error(\"require not available in browser\")\r\n const nodeRequire = getNodeModuleRef()\r\n if (!nodeRequire) throw new Error(\"require not available\")\r\n return nodeRequire.createRequire(importMetaUrl)\r\n}\r\n\r\n/**\r\n * Dapat `__dirname` dari `import.meta.url`.\r\n *\r\n * @example\r\n * // Ganti: const __dirname = ...\r\n * const dir = getDirname(import.meta.url)\r\n */\r\nexport function getDirname(importMetaUrl: string): string {\r\n if (isBrowser) return \"\"\r\n const nodePath = getNodePath()\r\n const nodeUrl = getNodeUrl()\r\n return nodePath.dirname(nodeUrl.fileURLToPath(importMetaUrl))\r\n}\r\n\r\n/**\r\n * Dapat `__filename` dari `import.meta.url`.\r\n */\r\nexport function getFilename(importMetaUrl: string): string {\r\n if (isBrowser) return \"\"\r\n return getNodeUrl().fileURLToPath(importMetaUrl)\r\n}\r\n\r\n/**\r\n * Resolve path dari root monorepo (bukan CWD).\r\n * Berguna untuk scripts dan tools yang dipanggil dari lokasi berbeda.\r\n *\r\n * @example\r\n * const root = resolveFromRoot(\"packages/domain/shared/src\")\r\n */\r\nexport function resolveFromRoot(...segments: string[]): string {\r\n if (isBrowser) return segments.join(\"/\")\r\n\r\n const nodePath = getNodePath()\r\n const nodeFs = getNodeFs()\r\n \r\n let dir = getDirname(import.meta.url)\r\n for (let i = 0; i < 10; i++) {\r\n const pkgPath = nodePath.join(dir, \"package.json\")\r\n try {\r\n const pkg = JSON.parse(nodeFs.readFileSync(pkgPath, \"utf-8\"))\r\n if (pkg.workspaces) {\r\n return nodePath.resolve(dir, ...segments)\r\n }\r\n } catch { /* intentionally silent */ }\r\n dir = nodePath.dirname(dir)\r\n }\r\n return nodePath.resolve(process.cwd(), ...segments)\r\n}\r\n\r\n/**\r\n * Require sebuah module dengan fallback ke null jika tidak tersedia.\r\n * Berguna untuk optional dependencies.\r\n *\r\n * @example\r\n * const oxc = tryRequire(\"oxc-parser\", import.meta.url)\r\n * if (!oxc) console.warn(\"oxc-parser not installed\")\r\n */\r\nexport function tryRequire<T = unknown>(\r\n moduleName: string,\r\n importMetaUrl: string\r\n): T | null {\r\n if (isBrowser) return null\r\n try {\r\n return createEsmRequire(importMetaUrl)(moduleName) as T\r\n } catch { /* intentionally silent — optional dep */ }\r\n return null\r\n}\r\n\r\n/**\r\n * Resolve .node binary path yang cross-platform dan ESM-safe.\r\n * Menggantikan pola `path.resolve(__dirname, \"../native.node\")`.\r\n */\r\nexport function resolveNativeNodePath(\r\n importMetaUrl: string,\r\n ...relativeSegments: string[]\r\n): string {\r\n if (isBrowser) return relativeSegments.join(\"/\")\r\n return getNodePath().resolve(getDirname(importMetaUrl), ...relativeSegments)\r\n}","import { createHash } from \"node:crypto\"\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\nimport { fileURLToPath } from \"node:url\"\r\nimport { createRequire } from \"node:module\"\r\n\r\n// Native-only: Node.js is always available. No browser fallback.\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Types\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type TokenMap = Record<string, string>\r\n\r\nexport type VariantValue = string | number | boolean | undefined\r\n\r\nexport type VariantProps = Record<string, VariantValue>\r\n\r\nexport type HtmlTagName = keyof HTMLElementTagNameMap\r\n\r\nexport type CompoundCondition = Record<string, string | number | boolean>\r\n\r\nexport type VariantMatrix = Record<string, Array<string | number | boolean>>\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Logging\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface Logger {\r\n warn(...args: unknown[]): void\r\n debug(...args: unknown[]): void\r\n error(...args: unknown[]): void\r\n log(...args: unknown[]): void\r\n}\r\n\r\nexport function createLogger(namespace: string): Logger {\r\n const prefix = `[${namespace}]`\r\n return {\r\n warn(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n debug(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n error(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n log(...args: unknown[]) {\r\n process.stderr.write(`${prefix} ${args.map(a => typeof a === \"string\" ? a : String(a)).join(\" \")}\\n`)\r\n },\r\n }\r\n}\r\n\r\nexport function createDebugLogger(namespace: string, label?: string): (msg: string) => void {\r\n const prefix = label ? `[${namespace}:${label}]` : `[${namespace}]`\r\n return (msg: string) => {\r\n if (process.env.DEBUG?.includes(namespace) || process.env.TW_DEBUG) {\r\n console.debug(prefix, msg)\r\n }\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error handling\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type ErrorSource = \"rust\" | \"validation\" | \"compile\" | \"io\" | \"config\" | \"unknown\"\r\n\r\ntype ZodLikeIssue = {\r\n path?: readonly PropertyKey[]\r\n message?: string\r\n}\r\n\r\nfunction formatIssuePath(path?: readonly PropertyKey[]): string {\r\n if (!path || path.length === 0) return \"(root)\"\r\n return path\r\n .map((segment) =>\r\n typeof segment === \"symbol\" ? segment.description ?? segment.toString() : String(segment)\r\n )\r\n .join(\".\")\r\n}\r\n\r\nexport class TwError extends Error {\r\n /** @deprecated Gunakan source */\r\n public readonly domain: string\r\n public readonly source: ErrorSource\r\n public readonly code: string\r\n public readonly originalCause?: unknown\r\n\r\n constructor(domainOrSource: string, code: string, message: string, cause?: unknown) {\r\n super(message)\r\n this.name = \"TwError\"\r\n this.domain = domainOrSource\r\n this.source = domainOrSource as ErrorSource\r\n this.code = code\r\n this.originalCause = cause\r\n if (Error.captureStackTrace) Error.captureStackTrace(this, TwError)\r\n }\r\n\r\n static fromIo(code: string, message: string): TwError {\r\n return new TwError(\"io\", code, message)\r\n }\r\n\r\n static fromCompile(code: string, message: string): TwError {\r\n return new TwError(\"compile\", code, message)\r\n }\r\n\r\n static fromRust(err: { code?: string; message?: string } | Error | unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(\"rust\", \"RUST_ERROR\", err.message, err)\r\n if (err && typeof err === \"object\") {\r\n const e = err as { code?: string; message?: string }\r\n return new TwError(\"rust\", e.code ?? \"RUST_ERROR\", e.message ?? String(err), err)\r\n }\r\n return new TwError(\"rust\", \"RUST_ERROR\", String(err), err)\r\n }\r\n\r\n /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */\r\n static fromZod(err: { issues?: ZodLikeIssue[]; errors?: ZodLikeIssue[] }): TwError {\r\n const first = err.issues?.[0] ?? err.errors?.[0]\r\n const path = formatIssuePath(first?.path)\r\n const message = first ? `${path}: ${first.message}` : \"Schema validation failed\"\r\n return new TwError(\"validation\", \"SCHEMA_VALIDATION_FAILED\", message, err)\r\n }\r\n\r\n static wrap(source: string, code: string, err: unknown): TwError {\r\n if (err instanceof TwError) return err\r\n if (err instanceof Error) return new TwError(source, code, err.message, err)\r\n return new TwError(source, code, String(err), err)\r\n }\r\n\r\n override toString(): string {\r\n return `TwError [${this.source}:${this.code}] ${this.message}`\r\n }\r\n\r\n toJSON(): { name: string; source: string; code: string; message: string } {\r\n return { name: this.name, source: this.source, code: this.code, message: this.message }\r\n }\r\n\r\n toCliMessage(): string {\r\n return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`\r\n }\r\n}\r\n\r\nexport function wrapUnknownError(domain: string, code: string, error: unknown): TwError {\r\n return TwError.wrap(domain, code, error)\r\n}\r\n\r\nexport function isTwError(err: unknown): err is TwError {\r\n return err instanceof TwError\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Native binding resolution\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport interface LoadNativeBindingOptions<T> {\r\n runtimeDir: string\r\n candidates: string[]\r\n isValid: (module: unknown) => module is T\r\n invalidExportMessage: string\r\n}\r\n\r\nexport interface LoadNativeBindingResult<T> {\r\n binding: T | null\r\n loadErrors: Array<{ path: string; message: string }>\r\n loadedPath?: string\r\n}\r\n\r\nexport function loadNativeBinding<T>(options: LoadNativeBindingOptions<T>): LoadNativeBindingResult<T> {\r\n const { runtimeDir, candidates, isValid } = options\r\n const loadErrors: Array<{ path: string; message: string }> = []\r\n\r\n for (const candidate of candidates) {\r\n const candidatePath = path.resolve(runtimeDir, candidate)\r\n try {\r\n if (!fs.existsSync(candidatePath) && !fs.existsSync(candidatePath + \".node\")) {\r\n continue\r\n }\r\n const mod = requireNativeModule(candidatePath)\r\n if (mod && isValid(mod)) {\r\n return { binding: mod, loadErrors, loadedPath: candidatePath }\r\n }\r\n loadErrors.push({ path: candidatePath, message: options.invalidExportMessage })\r\n } catch (e) {\r\n loadErrors.push({ path: candidatePath, message: e instanceof Error ? e.message : String(e) })\r\n }\r\n }\r\n\r\n return { binding: null, loadErrors }\r\n}\r\n\r\nconst _require = createRequire(import.meta.url)\r\n\r\nfunction requireNativeModule(p: string): unknown {\r\n return _require(p)\r\n}\r\n\r\nexport interface ResolveCandidatesOptions {\r\n runtimeDir?: string\r\n envVarNames?: string[]\r\n includeDefaultCandidates?: boolean\r\n enforceNodeExtensionForEnvPath?: boolean\r\n /** @deprecated — ignored, kept for backward compat */\r\n packageName?: string\r\n}\r\n\r\nexport function resolveNativeBindingCandidates(options: ResolveCandidatesOptions): string[] {\r\n const {\r\n envVarNames = [\"TW_NATIVE_PATH\", \"TWS_NATIVE_PATH\"],\r\n includeDefaultCandidates = true,\r\n enforceNodeExtensionForEnvPath = false,\r\n } = options\r\n // Default ke cwd kalau runtimeDir tidak disediakan\r\n const runtimeDir = options.runtimeDir || process.cwd()\r\n const candidates: string[] = []\r\n\r\n for (const envVar of envVarNames) {\r\n const envPath = process.env[envVar]\r\n if (envPath) {\r\n candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(\".node\") ? envPath + \".node\" : envPath)\r\n }\r\n }\r\n\r\n if (!includeDefaultCandidates) return candidates\r\n\r\n if (fs.existsSync(runtimeDir)) {\r\n try {\r\n for (const entry of fs.readdirSync(runtimeDir)) {\r\n if (entry.endsWith(\".node\")) candidates.push(entry)\r\n }\r\n } catch { /* ignore read errors */ }\r\n }\r\n\r\n const BINARY_NAMES = [\"tailwind-styled-native\", \"tailwind_styled_parser\"]\r\n const napiPlatform = process.platform === \"linux\" && process.arch === \"x64\" ? \"linux-x64-gnu\"\r\n : process.platform === \"linux\" && process.arch === \"arm64\" ? \"linux-arm64-gnu\"\r\n : `${process.platform}-${process.arch}`\r\n\r\n for (const bin of BINARY_NAMES) {\r\n candidates.push(path.resolve(runtimeDir, `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, `${bin}.${napiPlatform}.node`))\r\n // 1 level: dist/ → package-root/native/ (published npm package)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // cwd fallback (user project root)\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(process.cwd(), \"native\", `${bin}.${napiPlatform}.node`))\r\n // 4 level: dist/ → package/ → domain/ → packages/ → repo-root/ (monorepo dev)\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"..\", \"native\", `${bin}.${napiPlatform}.node`))\r\n // 3 level fallback\r\n candidates.push(path.resolve(runtimeDir, \"..\", \"..\", \"..\", \"native\", `${bin}.node`))\r\n }\r\n\r\n return Array.from(new Set(candidates))\r\n}\r\n\r\nexport function resolveRuntimeDir(dir: string | undefined, importMetaUrl: string): string {\r\n if (dir) return path.resolve(dir)\r\n try {\r\n return path.dirname(fileURLToPath(importMetaUrl))\r\n } catch {\r\n return process.cwd()\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Hashing\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function hashContent(content: string, algorithm: string = \"md5\", length?: number): string {\r\n const hash = createHash(algorithm).update(content).digest(\"hex\")\r\n return length ? hash.slice(0, length) : hash\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error formatting\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport function formatErrorMessage(error: unknown): string {\r\n if (error instanceof TwError) return error.toString()\r\n if (error instanceof Error) return error.message\r\n return String(error)\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// LRU Cache\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport class LRUCache<K, V> {\r\n private capacity: number\r\n private cache: Map<K, V>\r\n\r\n constructor(capacity: number) {\r\n this.capacity = capacity\r\n this.cache = new Map()\r\n }\r\n\r\n get(key: K): V | undefined {\r\n if (!this.cache.has(key)) return undefined\r\n const value = this.cache.get(key)!\r\n this.cache.delete(key)\r\n this.cache.set(key, value)\r\n return value\r\n }\r\n\r\n set(key: K, value: V): void {\r\n if (this.cache.has(key)) {\r\n this.cache.delete(key)\r\n } else if (this.cache.size >= this.capacity) {\r\n const firstKey = this.cache.keys().next().value\r\n if (firstKey !== undefined) {\r\n this.cache.delete(firstKey)\r\n }\r\n }\r\n this.cache.set(key, value)\r\n }\r\n\r\n delete(key: K): boolean {\r\n return this.cache.delete(key)\r\n }\r\n\r\n has(key: K): boolean {\r\n return this.cache.has(key)\r\n }\r\n\r\n clear(): void {\r\n this.cache.clear()\r\n }\r\n\r\n entries(): IterableIterator<[K, V]> {\r\n return this.cache.entries()\r\n }\r\n\r\n get size(): number {\r\n return this.cache.size\r\n }\r\n}\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Trace Utilities\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TraceSnapshot, TraceSummary } from \"./trace\"\r\nexport {\r\n getHealthColor,\r\n getModeColor,\r\n formatMemory,\r\n formatDuration,\r\n calculateHealth,\r\n getBuildTimeColor,\r\n getMemoryColor,\r\n createTraceSnapshot,\r\n getPipelinePercentages,\r\n} from \"./trace\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Performance Telemetry\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\n\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Error Codes\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { ErrorCode } from \"./error-codes\"\r\nexport { ERROR_CODES, getSuggestion, formatErrorCode } from \"./error-codes\"\r\n\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n// Tailwind Compatibility\r\n// ─────────────────────────────────────────────────────────────────────────────\r\n\r\nexport type { TailwindInfo } from \"./compatibility\"\r\nexport { detectTailwind, assertTailwindV4, getTailwindVersion, isTailwindV4 } from \"./compatibility\"\r\n\r\n// ── Native binding schemas (Zod boundary validation)\r\nexport {\r\n NativeScanFileSchema, NativeScanResultSchema,\r\n NativeAnalyzerReportSchema, NativeTransformResultSchema,\r\n NativeCssCompileResultSchema, NativeWatchResultSchema,\r\n NativeCacheEntrySchema, NativeCacheReadResultSchema,\r\n safeParseNative, parseNative,\r\n} from './native-schemas'\r\n\r\n// ── ESM-safe runtime helpers ──────────────────────────────────────────────\r\nexport {\r\n createEsmRequire,\r\n getDirname,\r\n getFilename,\r\n resolveFromRoot,\r\n tryRequire,\r\n resolveNativeNodePath,\r\n} from \"./esmHelpers\"\r\n\r\n// ── Performance telemetry ────────────────────────────────────────────────────\r\nexport {\r\n TelemetryCollector,\r\n getGlobalTelemetry,\r\n resetGlobalTelemetry,\r\n createBuildTimer,\r\n type BuildTelemetry,\r\n type TelemetrySummary,\r\n type BuildPhases,\r\n} from \"./telemetry\"\r\n\r\n// ── Config/JSON schema validation ─────────────────────────────────────────────\r\nexport {\r\n ScanCacheSchema,\r\n ScanCacheClassEntrySchema,\r\n TailwindConfigSchema,\r\n RegistryPluginEntrySchema,\r\n RegistryFileSchema,\r\n PackageJsonSchema,\r\n parseJsonWithSchema,\r\n parseJsonFileWithSchema,\r\n type ScanCache,\r\n type ScanCacheClassEntry,\r\n type TailwindConfig,\r\n type RegistryPluginEntry,\r\n type RegistryFile,\r\n type PackageJson,\r\n} from \"./configSchemas\"\r\n\r\n// ── Worker/bootstrap path resolution ─────────────────────────────────────────\r\nexport {\r\n resolveWorkerPath,\r\n resolveLoaderPath,\r\n type WorkerPathOptions,\r\n type WorkerPathResult,\r\n} from \"./workerResolver\"\r\n\r\n// ── Codegen helpers ───────────────────────────────────────────────────────────\r\nexport {\r\n generateComponentCode,\r\n generateStorybookStory,\r\n generateClassRenameCodemod,\r\n generateBarrelFile,\r\n type ComponentCodegenOptions,\r\n} from \"./codegen\"\r\n\r\n// ── Native binary resolution (QA #1) ─────────────────────────────────────────\r\nexport {\r\n resolveNativeBinary,\r\n formatNativeNotFoundError,\r\n type NativeResolutionResult,\r\n} from \"./native-resolution\"\r\n\r\n// ── Shared observability contract ────────────────────────────────────────────\r\nexport {\r\n createObservabilityClient,\r\n type ClassInspection,\r\n type ClassProperty,\r\n type ClassUsageLocation,\r\n type BuildTrace,\r\n type BuildPhaseTrace,\r\n type DashboardMetrics,\r\n type DashboardSummary,\r\n type ObservabilityClient,\r\n} from \"./observability\"\r\n\r\nexport {\r\n TW_STATE_STATIC_FILENAME,\r\n extractStaticStateCss,\r\n appendStaticStateCssToSafelist,\r\n type TwStateConfigEntry,\r\n type StaticStateCssInput,\r\n type GeneratedStateRule,\r\n type StaticStateExtractionResult,\r\n} from \"./staticStateExtractor\"\r\nexport { setGlobalLogFile } from \"./logger\"","/**\r\n * tailwind-styled-v4 - Rspack Plugin v5 (stable)\r\n *\r\n * Usage:\r\n * import { tailwindStyledRspackPlugin } from \"@tailwind-styled/rspack\"\r\n *\r\n * export default defineConfig({\r\n * plugins: [tailwindStyledRspackPlugin()],\r\n * })\r\n *\r\n * v5:\r\n * - Simplified API\r\n * - Mode always zero-runtime\r\n */\r\n\r\nimport fs from \"node:fs\"\r\nimport path from \"node:path\"\r\nimport { getDirname as getEsmDirname } from \"@tailwind-styled/shared\"\r\n\r\nimport { parseRspackPluginOptions } from \"./schemas\"\r\n\r\nfunction getDirname(): string {\r\n if (typeof __dirname !== \"undefined\") {\r\n return __dirname\r\n }\r\n if (typeof import.meta !== \"undefined\" && import.meta.url) {\r\n return getEsmDirname(import.meta.url)\r\n }\r\n return process.cwd()\r\n}\r\n\r\nfunction resolveLoaderPath(basename: string): string {\r\n const runtimeDir = getDirname()\r\n const preferredExtensions =\r\n typeof __dirname !== \"undefined\" && __dirname.length > 0 ? [\".cjs\", \".js\"] : [\".js\", \".cjs\"]\r\n\r\n for (const ext of preferredExtensions) {\r\n const candidate = path.resolve(runtimeDir, `${basename}${ext}`)\r\n if (fs.existsSync(candidate)) return candidate\r\n }\r\n\r\n return path.resolve(runtimeDir, `${basename}.js`)\r\n}\r\n\r\ninterface RspackRule {\r\n _tailwindStyledRspackMarker?: boolean\r\n test?: RegExp\r\n exclude?: RegExp\r\n use?: Array<{\r\n loader: string\r\n options: {\r\n mode: \"zero-runtime\"\r\n addDataAttr: boolean\r\n preserveImports: boolean\r\n safelistPath?: string\r\n }\r\n }>\r\n}\r\n\r\ninterface RspackCompiler {\r\n options: {\r\n mode?: string\r\n module?: {\r\n rules?: RspackRule[]\r\n }\r\n }\r\n}\r\n\r\nexport interface RspackPluginOptions {\r\n /** File patterns to include. Default: /\\.[jt]sx?$/ */\r\n include?: RegExp\r\n /** File patterns to exclude. Default: /node_modules/ */\r\n exclude?: RegExp\r\n /** Add data-tw debug attributes in dev. Default: true in dev */\r\n addDataAttr?: boolean\r\n /** Enable analyzer. Default: false */\r\n analyze?: boolean\r\n /**\r\n * Path ke safelist CSS file.\r\n * `_tw-state-static.css` ditulis di direktori yang sama.\r\n * Default: `<cwd>/__tw_safelist.css`\r\n */\r\n safelistPath?: string\r\n}\r\n\r\nexport class TailwindStyledRspackPlugin {\r\n private opts: RspackPluginOptions\r\n\r\n constructor(opts: RspackPluginOptions = {}) {\r\n this.opts = parseRspackPluginOptions(opts)\r\n }\r\n\r\n apply(compiler: RspackCompiler): void {\r\n const isDev = compiler.options.mode !== \"production\"\r\n const loaderPath = resolveLoaderPath(\"loader\")\r\n const existing = compiler.options.module?.rules ?? []\r\n const alreadyRegistered = existing.some(\r\n (rule) =>\r\n typeof rule === \"object\" && rule !== null && rule._tailwindStyledRspackMarker === true\r\n )\r\n\r\n if (alreadyRegistered) return\r\n\r\n const safelistPath =\r\n this.opts.safelistPath ?? path.join(process.cwd(), \"__tw_safelist.css\")\r\n\r\n // Tulis placeholder agar @import di CSS entry tidak error saat cold start\r\n const stateStaticPath = path.join(path.dirname(safelistPath), \"_tw-state-static.css\")\r\n if (!fs.existsSync(stateStaticPath)) {\r\n try {\r\n fs.mkdirSync(path.dirname(stateStaticPath), { recursive: true })\r\n fs.writeFileSync(\r\n stateStaticPath,\r\n `/* _tw-state-static.css — Auto-generated by tailwind-styled-v4. DO NOT EDIT.\\n` +\r\n ` * Import di CSS entry: @import \"./_tw-state-static.css\";\\n` +\r\n ` */\\n`,\r\n \"utf-8\"\r\n )\r\n } catch { /* non-fatal */ }\r\n }\r\n\r\n const rule: RspackRule = {\r\n _tailwindStyledRspackMarker: true,\r\n test: this.opts.include ?? /\\.[jt]sx?$/,\r\n exclude: this.opts.exclude ?? /node_modules/,\r\n use: [\r\n {\r\n loader: loaderPath,\r\n options: {\r\n mode: \"zero-runtime\",\r\n addDataAttr: this.opts.addDataAttr ?? isDev,\r\n preserveImports: true,\r\n safelistPath,\r\n },\r\n },\r\n ],\r\n }\r\n\r\n compiler.options.module = {\r\n ...(compiler.options.module ?? {}),\r\n rules: [rule, ...existing],\r\n }\r\n }\r\n}\r\n\r\nexport function tailwindStyledRspackPlugin(\r\n opts: RspackPluginOptions = {}\r\n): TailwindStyledRspackPlugin {\r\n return new TailwindStyledRspackPlugin(opts)\r\n}\r\n\r\nexport default tailwindStyledRspackPlugin\r\n\r\nexport {\r\n parseRspackPluginOptions,\r\n type RspackPluginOptionsInput,\r\n RspackPluginOptionsSchema,\r\n} from \"./schemas\"\r\n","import { z } from \"zod\"\r\nimport { TwError } from \"@tailwind-styled/shared\"\r\n\r\nconst formatIssuePath = (path: readonly PropertyKey[]): string =>\r\n path.length > 0\r\n ? path\r\n .map((segment) =>\r\n typeof segment === \"symbol\" ? segment.description ?? segment.toString() : String(segment)\r\n )\r\n .join(\".\")\r\n : \"<root>\"\r\n\r\nconst formatIssues = (error: z.ZodError): string =>\r\n error.issues\r\n .map((issue) => {\r\n const p = formatIssuePath(issue.path)\r\n return `${p}: ${issue.message}`\r\n })\r\n .join(\"; \")\r\n\r\nconst parseWithSchema = <T>(schema: z.ZodType<T>, data: unknown, label: string): T => {\r\n const parsed = schema.safeParse(data)\r\n if (parsed.success) return parsed.data\r\n const details = formatIssues(parsed.error)\r\n throw new TwError(\r\n \"validation\",\r\n \"SCHEMA_VALIDATION_FAILED\",\r\n details ? `${label}: ${details}` : label,\r\n parsed.error\r\n )\r\n}\r\n\r\nexport const RspackPluginOptionsSchema = z.object({\r\n include: z.instanceof(RegExp).optional(),\r\n exclude: z.instanceof(RegExp).optional(),\r\n addDataAttr: z.boolean().optional(),\r\n analyze: z.boolean().optional(),\r\n cssEntry: z.string().optional(),\r\n /** Path ke safelist CSS file. Default: <cwd>/__tw_safelist.css */\r\n safelistPath: z.string().optional(),\r\n})\r\n\r\nexport type RspackPluginOptionsInput = z.infer<typeof RspackPluginOptionsSchema>\r\n\r\nexport const parseRspackPluginOptions = (options: unknown) =>\r\n parseWithSchema(RspackPluginOptionsSchema, options ?? {}, \"rspack plugin options are invalid\")\r\n"]}
|