tailwind-styled-v4 5.0.7 → 5.0.9
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/CHANGELOG.md +184 -410
- package/README.md +45 -15
- package/dist/cli.js +62 -52
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +62 -52
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +8 -3
- package/dist/compiler.d.ts +8 -3
- package/dist/compiler.js +214 -127
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +195 -103
- package/dist/compiler.mjs.map +1 -1
- package/dist/engine.js +146 -66
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +146 -66
- package/dist/engine.mjs.map +1 -1
- package/dist/index.d.mts +26 -8
- package/dist/index.d.ts +26 -8
- package/dist/index.js +72 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -19
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +12 -40
- package/dist/next.d.ts +12 -40
- package/dist/next.js +27 -320
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +27 -320
- package/dist/next.mjs.map +1 -1
- package/dist/turbopackLoader.js +137 -88
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +137 -88
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +62 -52
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +62 -52
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +146 -66
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +146 -66
- package/dist/vite.mjs.map +1 -1
- package/dist/webpackLoader.js +92 -83
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +92 -83
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -142,9 +142,32 @@ function Alert({ type, children }) {
|
|
|
142
142
|
}
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
### 6. Sub-components
|
|
145
|
+
### 6. Sub-components
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
Ada **dua cara** mendefinisikan sub-components:
|
|
148
|
+
|
|
149
|
+
#### A. Config Object — Direkomendasikan (Autocomplete + Type Safe)
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
const Card = tw.div({
|
|
153
|
+
base: "flex flex-col p-4 rounded-xl bg-white shadow",
|
|
154
|
+
sub: {
|
|
155
|
+
header: "font-bold text-lg border-b pb-2",
|
|
156
|
+
body: "text-gray-600 py-2",
|
|
157
|
+
footer: "border-t pt-2 text-sm text-gray-400",
|
|
158
|
+
},
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
// TypeScript infer keys dari object literal → autocomplete penuh
|
|
162
|
+
<Card>
|
|
163
|
+
<Card.header>Judul</Card.header> // ✅ autocomplete
|
|
164
|
+
<Card.body>Konten</Card.body> // ✅ autocomplete
|
|
165
|
+
<Card.footer>Footer</Card.footer> // ✅ autocomplete
|
|
166
|
+
<Card.xyz>?</Card.xyz> // ❌ TypeScript error
|
|
167
|
+
</Card>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### B. Template Literal Inline — Ringkas (tanpa autocomplete)
|
|
148
171
|
|
|
149
172
|
```tsx
|
|
150
173
|
const Card = tw.div`
|
|
@@ -154,24 +177,18 @@ const Card = tw.div`
|
|
|
154
177
|
[footer] { border-t pt-2 text-sm text-gray-400 }
|
|
155
178
|
`
|
|
156
179
|
|
|
157
|
-
// TypeScript
|
|
180
|
+
// Runtime benar, tapi TypeScript tidak bisa infer nama dari multiline template —
|
|
181
|
+
// ini limitasi TypeScript, bukan bug library. Gunakan config object untuk type safety.
|
|
158
182
|
<Card>
|
|
159
183
|
<Card.header>Judul</Card.header>
|
|
160
184
|
<Card.body>Konten</Card.body>
|
|
161
185
|
<Card.footer>Footer</Card.footer>
|
|
162
186
|
</Card>
|
|
163
|
-
|
|
164
|
-
// Autocomplete ✓ — Card.nonexistent akan error TypeScript
|
|
165
187
|
```
|
|
166
188
|
|
|
167
|
-
>
|
|
189
|
+
> Sub-components **tidak mewarisi** style base. Untuk mewarisi, pakai `.extend()` (lihat Pattern B di bawah).
|
|
168
190
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
```tsx
|
|
172
|
-
// Kasus khusus — nama tidak ada di template
|
|
173
|
-
const Modal = tw.div`fixed inset-0`.withSub<"overlay" | "content">()
|
|
174
|
-
```
|
|
191
|
+
> **Sub-component tidak terdefinisi** tidak akan crash — library otomatis fallback ke `<span>` passthrough. Tapi tetap gunakan config object untuk catch typo di TypeScript.
|
|
175
192
|
|
|
176
193
|
### 7. State Engine — Zero-JS State Management
|
|
177
194
|
|
|
@@ -248,9 +265,22 @@ const IconButton = Button.extend`p-2 rounded-full`
|
|
|
248
265
|
|
|
249
266
|
### Pattern Sub-components
|
|
250
267
|
|
|
251
|
-
**Pattern A:
|
|
268
|
+
**Pattern A: Config Object — Direkomendasikan (autocomplete + type safe)**
|
|
269
|
+
|
|
270
|
+
```tsx
|
|
271
|
+
const Card = tw.div({
|
|
272
|
+
base: "flex flex-col p-4 rounded-xl bg-white shadow",
|
|
273
|
+
sub: {
|
|
274
|
+
header: "font-bold text-lg border-b pb-2",
|
|
275
|
+
body: "text-gray-600 py-2",
|
|
276
|
+
footer: "border-t pt-2 text-sm",
|
|
277
|
+
},
|
|
278
|
+
})
|
|
279
|
+
// TypeScript infer: Card.header, Card.body, Card.footer ✅ autocomplete
|
|
280
|
+
// Card.xyz → TypeScript error ✅
|
|
281
|
+
```
|
|
252
282
|
|
|
253
|
-
|
|
283
|
+
**Pattern A2: Inline Template `[name] { }` — Ringkas (tanpa autocomplete)**
|
|
254
284
|
|
|
255
285
|
```tsx
|
|
256
286
|
const Card = tw.div`
|
|
@@ -259,7 +289,7 @@ const Card = tw.div`
|
|
|
259
289
|
[body] { text-gray-600 py-2 }
|
|
260
290
|
[footer] { border-t pt-2 text-sm }
|
|
261
291
|
`
|
|
262
|
-
// TypeScript
|
|
292
|
+
// Runtime benar — TypeScript tidak bisa infer nama dari multiline template literal
|
|
263
293
|
```
|
|
264
294
|
|
|
265
295
|
**Pattern B: `.extend()` — Sub-components Mewarisi Style Base**
|
package/dist/cli.js
CHANGED
|
@@ -5940,6 +5940,67 @@ var init_createApp = __esm({
|
|
|
5940
5940
|
};
|
|
5941
5941
|
}
|
|
5942
5942
|
});
|
|
5943
|
+
var log3, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge;
|
|
5944
|
+
var init_nativeBridge = __esm({
|
|
5945
|
+
"packages/domain/compiler/src/nativeBridge.ts"() {
|
|
5946
|
+
init_src();
|
|
5947
|
+
log3 = (...args) => {
|
|
5948
|
+
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
5949
|
+
console.log("[compiler:native]", ...args);
|
|
5950
|
+
}
|
|
5951
|
+
};
|
|
5952
|
+
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";
|
|
5953
|
+
nativeBridge = null;
|
|
5954
|
+
bridgeLoadAttempted = false;
|
|
5955
|
+
bridgeLoadError = null;
|
|
5956
|
+
isValidNativeBridge = (mod) => {
|
|
5957
|
+
const m = mod;
|
|
5958
|
+
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
5959
|
+
};
|
|
5960
|
+
getNativeBridge = () => {
|
|
5961
|
+
if (nativeBridge) {
|
|
5962
|
+
return nativeBridge;
|
|
5963
|
+
}
|
|
5964
|
+
if (bridgeLoadAttempted) {
|
|
5965
|
+
if (bridgeLoadError) {
|
|
5966
|
+
throw bridgeLoadError;
|
|
5967
|
+
}
|
|
5968
|
+
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
5969
|
+
}
|
|
5970
|
+
bridgeLoadAttempted = true;
|
|
5971
|
+
try {
|
|
5972
|
+
const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
5973
|
+
const require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
5974
|
+
const result = resolveNativeBinary(runtimeDir);
|
|
5975
|
+
if (result.path && result.path.endsWith(".node")) {
|
|
5976
|
+
try {
|
|
5977
|
+
const binding = require2(result.path);
|
|
5978
|
+
if (isValidNativeBridge(binding)) {
|
|
5979
|
+
nativeBridge = binding;
|
|
5980
|
+
log3("Native bridge loaded successfully from:", result.path);
|
|
5981
|
+
return nativeBridge;
|
|
5982
|
+
}
|
|
5983
|
+
} catch (e) {
|
|
5984
|
+
log3("Failed to require native binding:", e);
|
|
5985
|
+
}
|
|
5986
|
+
}
|
|
5987
|
+
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
5988
|
+
|
|
5989
|
+
Tried paths: ${result.tried.join("\n")}`);
|
|
5990
|
+
} catch (err) {
|
|
5991
|
+
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
5992
|
+
log3("Failed to load native bridge:", bridgeLoadError.message);
|
|
5993
|
+
throw bridgeLoadError;
|
|
5994
|
+
}
|
|
5995
|
+
};
|
|
5996
|
+
if (typeof process !== "undefined" && !bridgeLoadAttempted) {
|
|
5997
|
+
try {
|
|
5998
|
+
getNativeBridge();
|
|
5999
|
+
} catch {
|
|
6000
|
+
}
|
|
6001
|
+
}
|
|
6002
|
+
}
|
|
6003
|
+
});
|
|
5943
6004
|
|
|
5944
6005
|
// packages/infrastructure/cli/src/commands/program.ts
|
|
5945
6006
|
init_esm();
|
|
@@ -9070,59 +9131,8 @@ var syncCommand = {
|
|
|
9070
9131
|
var import_picocolors5 = __toESM(require_picocolors());
|
|
9071
9132
|
init_errors();
|
|
9072
9133
|
|
|
9073
|
-
// packages/domain/compiler/src/nativeBridge.ts
|
|
9074
|
-
init_src();
|
|
9075
|
-
var log3 = (...args) => {
|
|
9076
|
-
if (process.env.DEBUG?.includes("compiler:native")) {
|
|
9077
|
-
console.log("[compiler:native]", ...args);
|
|
9078
|
-
}
|
|
9079
|
-
};
|
|
9080
|
-
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";
|
|
9081
|
-
var nativeBridge = null;
|
|
9082
|
-
var bridgeLoadAttempted = false;
|
|
9083
|
-
var bridgeLoadError = null;
|
|
9084
|
-
var isValidNativeBridge = (mod) => {
|
|
9085
|
-
const m = mod;
|
|
9086
|
-
return !!(typeof m.transformSource === "function" || typeof m.extractAllClasses === "function" || typeof m.hasTwUsage === "function");
|
|
9087
|
-
};
|
|
9088
|
-
var getNativeBridge = () => {
|
|
9089
|
-
if (nativeBridge) {
|
|
9090
|
-
return nativeBridge;
|
|
9091
|
-
}
|
|
9092
|
-
if (bridgeLoadAttempted) {
|
|
9093
|
-
if (bridgeLoadError) {
|
|
9094
|
-
throw bridgeLoadError;
|
|
9095
|
-
}
|
|
9096
|
-
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
9097
|
-
}
|
|
9098
|
-
bridgeLoadAttempted = true;
|
|
9099
|
-
try {
|
|
9100
|
-
const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
9101
|
-
const require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
9102
|
-
const result = resolveNativeBinary(runtimeDir);
|
|
9103
|
-
if (result.path && result.path.endsWith(".node")) {
|
|
9104
|
-
try {
|
|
9105
|
-
const binding = require2(result.path);
|
|
9106
|
-
if (isValidNativeBridge(binding)) {
|
|
9107
|
-
nativeBridge = binding;
|
|
9108
|
-
log3("Native bridge loaded successfully from:", result.path);
|
|
9109
|
-
return nativeBridge;
|
|
9110
|
-
}
|
|
9111
|
-
} catch (e) {
|
|
9112
|
-
log3("Failed to require native binding:", e);
|
|
9113
|
-
}
|
|
9114
|
-
}
|
|
9115
|
-
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
9116
|
-
|
|
9117
|
-
Tried paths: ${result.tried.join("\n")}`);
|
|
9118
|
-
} catch (err) {
|
|
9119
|
-
bridgeLoadError = err instanceof Error ? err : new Error(String(err));
|
|
9120
|
-
log3("Failed to load native bridge:", bridgeLoadError.message);
|
|
9121
|
-
throw bridgeLoadError;
|
|
9122
|
-
}
|
|
9123
|
-
};
|
|
9124
|
-
|
|
9125
9134
|
// packages/domain/compiler/src/index.ts
|
|
9135
|
+
init_nativeBridge();
|
|
9126
9136
|
var compileCssFromClasses = (classes, prefix) => {
|
|
9127
9137
|
const native = getNativeBridge();
|
|
9128
9138
|
if (!native?.transformSource) {
|