tailwind-styled-v4 5.0.9 → 5.0.10
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 +15 -1
- package/dist/{analyzeWorkspace-DuJKh7Ty.d.mts → analyzeWorkspace-BS5O4rhC.d.mts} +47 -2
- package/dist/{analyzeWorkspace-Ct_NTAWt.d.ts → analyzeWorkspace-DDOQdzzI.d.ts} +47 -2
- package/dist/analyzer.d.mts +5 -3
- package/dist/analyzer.d.ts +5 -3
- package/dist/analyzer.js +563 -468
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +562 -467
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.d.mts +4 -7
- package/dist/animate.d.ts +4 -7
- package/dist/animate.js +171 -265
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +165 -264
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.d.mts +22 -1
- package/dist/atomic.d.ts +22 -1
- package/dist/atomic.js +221 -165
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +200 -165
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.d.mts +60 -1
- package/dist/cli.d.ts +60 -1
- package/dist/cli.js +1261 -1517
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1238 -1513
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +38 -7
- package/dist/compiler.d.ts +38 -7
- package/dist/compiler.js +174 -197
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +151 -194
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js +7 -31
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs +7 -31
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.d.mts +134 -63
- package/dist/engine.d.ts +134 -63
- package/dist/engine.js +2863 -2482
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +2852 -2485
- package/dist/engine.mjs.map +1 -1
- package/dist/{index-eWAocnD2.d.mts → index-NDINUhLN.d.mts} +3 -1
- package/dist/{index-eWAocnD2.d.ts → index-NDINUhLN.d.ts} +3 -1
- package/dist/index.d.mts +45 -32
- package/dist/index.d.ts +45 -32
- package/dist/index.js +271 -158
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +251 -158
- package/dist/index.mjs.map +1 -1
- package/dist/{liveTokenEngine-DSUk88P6.d.ts → liveTokenEngine-CN9ian1R.d.ts} +1 -1
- package/dist/{liveTokenEngine-CX5_0c4q.d.mts → liveTokenEngine-DKoWRtqH.d.mts} +1 -1
- package/dist/next.js +20 -39
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +18 -37
- package/dist/next.mjs.map +1 -1
- package/dist/plugin-api.d.mts +8 -2
- package/dist/plugin-api.d.ts +8 -2
- package/dist/plugin-api.js +14 -2
- package/dist/plugin-api.js.map +1 -1
- package/dist/plugin-api.mjs +14 -3
- package/dist/plugin-api.mjs.map +1 -1
- package/dist/plugin-registry.js +51 -11
- package/dist/plugin-registry.js.map +1 -1
- package/dist/plugin-registry.mjs +51 -11
- package/dist/plugin-registry.mjs.map +1 -1
- package/dist/plugin.d.mts +5 -7
- package/dist/plugin.d.ts +5 -7
- package/dist/plugin.js +16 -15
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs +16 -16
- package/dist/plugin.mjs.map +1 -1
- package/dist/rspack.js +17 -38
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs +15 -36
- package/dist/rspack.mjs.map +1 -1
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/scanner.d.mts +10 -1
- package/dist/scanner.d.ts +10 -1
- package/dist/scanner.js +298 -124
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +296 -124
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.d.mts +1 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +104 -176
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +85 -176
- package/dist/shared.mjs.map +1 -1
- package/dist/storybook-addon.d.mts +1 -1
- package/dist/storybook-addon.d.ts +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +166 -3
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +143 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/syntax.js +21 -21
- package/dist/syntax.js.map +1 -1
- package/dist/syntax.mjs +21 -21
- package/dist/syntax.mjs.map +1 -1
- package/dist/testing.js +9 -1
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +9 -1
- package/dist/testing.mjs.map +1 -1
- package/dist/theme.d.mts +2 -2
- package/dist/theme.d.ts +2 -2
- package/dist/theme.js +40 -112
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +37 -110
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +79 -124
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +63 -122
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +1256 -1517
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +1236 -1513
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +1783 -823
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +1767 -821
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +165 -4
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +141 -1
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +65 -108
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +45 -104
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +22 -24
package/dist/animate.js
CHANGED
|
@@ -1,55 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('
|
|
3
|
+
require('crypto');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var url = require('url');
|
|
7
|
+
var module$1 = require('module');
|
|
4
8
|
var zod = require('zod');
|
|
5
9
|
|
|
6
10
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
14
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
15
|
+
|
|
7
16
|
/* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
8
17
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
-
}) : x)(function(x) {
|
|
12
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
-
});
|
|
15
18
|
var __esm = (fn, res) => function __init() {
|
|
16
19
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
17
20
|
};
|
|
18
|
-
|
|
19
|
-
// packages/domain/shared/src/index.ts
|
|
20
|
-
function getNodeModuleRef() {
|
|
21
|
-
if (isBrowser) return null;
|
|
22
|
-
if (nodeModuleRef !== null) return nodeModuleRef;
|
|
23
|
-
try {
|
|
24
|
-
const test = typeof __require === "function" ? __require("module") : null;
|
|
25
|
-
nodeModuleRef = test;
|
|
26
|
-
return test;
|
|
27
|
-
} catch {
|
|
28
|
-
nodeModuleRef = null;
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function getNodeFs() {
|
|
33
|
-
if (isBrowser) throw new Error("node:fs not available in browser");
|
|
34
|
-
const nodeRequire = getNodeModuleRef();
|
|
35
|
-
if (!nodeRequire) throw new Error("require not available");
|
|
36
|
-
if (!_nodeFs) _nodeFs = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.js', document.baseURI).href)))("node:fs");
|
|
37
|
-
return _nodeFs;
|
|
38
|
-
}
|
|
39
|
-
function getNodePath() {
|
|
40
|
-
if (isBrowser) throw new Error("node:path not available in browser");
|
|
41
|
-
const nodeRequire = getNodeModuleRef();
|
|
42
|
-
if (!nodeRequire) throw new Error("require not available");
|
|
43
|
-
if (!_nodePath) _nodePath = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.js', document.baseURI).href)))("node:path");
|
|
44
|
-
return _nodePath;
|
|
45
|
-
}
|
|
46
|
-
function getNodeUrl() {
|
|
47
|
-
if (isBrowser) throw new Error("node:url not available in browser");
|
|
48
|
-
const nodeRequire = getNodeModuleRef();
|
|
49
|
-
if (!nodeRequire) throw new Error("require not available");
|
|
50
|
-
if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.js', document.baseURI).href)))("node:url");
|
|
51
|
-
return _nodeUrl;
|
|
52
|
-
}
|
|
53
21
|
function createDebugLogger(namespace, label) {
|
|
54
22
|
const prefix = label ? `[${namespace}:${label}]` : `[${namespace}]`;
|
|
55
23
|
return (msg) => {
|
|
@@ -58,24 +26,19 @@ function createDebugLogger(namespace, label) {
|
|
|
58
26
|
}
|
|
59
27
|
};
|
|
60
28
|
}
|
|
61
|
-
function formatIssuePath(
|
|
62
|
-
if (!
|
|
63
|
-
return
|
|
29
|
+
function formatIssuePath(path2) {
|
|
30
|
+
if (!path2 || path2.length === 0) return "(root)";
|
|
31
|
+
return path2.map(
|
|
64
32
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
65
33
|
).join(".");
|
|
66
34
|
}
|
|
67
35
|
function loadNativeBinding(options) {
|
|
68
|
-
if (isBrowser) {
|
|
69
|
-
return { binding: null, loadErrors: [{ path: "", message: "Native bindings not available in browser" }] };
|
|
70
|
-
}
|
|
71
36
|
const { runtimeDir, candidates, isValid } = options;
|
|
72
37
|
const loadErrors = [];
|
|
73
|
-
const path = getNodePath();
|
|
74
|
-
const fs2 = getNodeFs();
|
|
75
38
|
for (const candidate of candidates) {
|
|
76
|
-
const candidatePath =
|
|
39
|
+
const candidatePath = path__default.default.resolve(runtimeDir, candidate);
|
|
77
40
|
try {
|
|
78
|
-
if (!
|
|
41
|
+
if (!fs__default.default.existsSync(candidatePath) && !fs__default.default.existsSync(candidatePath + ".node")) {
|
|
79
42
|
continue;
|
|
80
43
|
}
|
|
81
44
|
const mod = requireNativeModule(candidatePath);
|
|
@@ -89,77 +52,56 @@ function loadNativeBinding(options) {
|
|
|
89
52
|
}
|
|
90
53
|
return { binding: null, loadErrors };
|
|
91
54
|
}
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
throw new Error("require not available in browser");
|
|
95
|
-
});
|
|
96
|
-
const nodeRequire = getNodeModuleRef();
|
|
97
|
-
if (!nodeRequire) return (() => {
|
|
98
|
-
throw new Error("require not available");
|
|
99
|
-
});
|
|
100
|
-
return nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.js', document.baseURI).href)));
|
|
101
|
-
}
|
|
102
|
-
function requireNativeModule(path) {
|
|
103
|
-
return _require(path);
|
|
55
|
+
function requireNativeModule(p) {
|
|
56
|
+
return _require(p);
|
|
104
57
|
}
|
|
105
58
|
function resolveNativeBindingCandidates(options) {
|
|
106
|
-
|
|
107
|
-
|
|
59
|
+
const {
|
|
60
|
+
envVarNames = ["TW_NATIVE_PATH", "TWS_NATIVE_PATH"],
|
|
61
|
+
includeDefaultCandidates = true,
|
|
62
|
+
enforceNodeExtensionForEnvPath = false
|
|
63
|
+
} = options;
|
|
64
|
+
const runtimeDir = options.runtimeDir || process.cwd();
|
|
108
65
|
const candidates = [];
|
|
109
|
-
const path = getNodePath();
|
|
110
|
-
const fs2 = getNodeFs();
|
|
111
66
|
for (const envVar of envVarNames) {
|
|
112
67
|
const envPath = process.env[envVar];
|
|
113
68
|
if (envPath) {
|
|
114
|
-
|
|
115
|
-
candidates.push(envPath + ".node");
|
|
116
|
-
} else {
|
|
117
|
-
candidates.push(envPath);
|
|
118
|
-
}
|
|
69
|
+
candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(".node") ? envPath + ".node" : envPath);
|
|
119
70
|
}
|
|
120
71
|
}
|
|
121
72
|
if (!includeDefaultCandidates) return candidates;
|
|
122
|
-
if (
|
|
73
|
+
if (fs__default.default.existsSync(runtimeDir)) {
|
|
123
74
|
try {
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
if (entry.endsWith(".node")) {
|
|
127
|
-
candidates.push(entry);
|
|
128
|
-
}
|
|
75
|
+
for (const entry of fs__default.default.readdirSync(runtimeDir)) {
|
|
76
|
+
if (entry.endsWith(".node")) candidates.push(entry);
|
|
129
77
|
}
|
|
130
78
|
} catch {
|
|
131
79
|
}
|
|
132
80
|
}
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
81
|
+
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
82
|
+
const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
|
|
83
|
+
for (const bin of BINARY_NAMES) {
|
|
84
|
+
candidates.push(path__default.default.resolve(runtimeDir, `${bin}.node`));
|
|
85
|
+
candidates.push(path__default.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
|
|
86
|
+
candidates.push(path__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
|
|
87
|
+
candidates.push(path__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
|
|
88
|
+
candidates.push(path__default.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
|
|
89
|
+
candidates.push(path__default.default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
90
|
+
candidates.push(path__default.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
91
|
+
}
|
|
139
92
|
return Array.from(new Set(candidates));
|
|
140
93
|
}
|
|
141
94
|
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
142
|
-
if (
|
|
143
|
-
if (dir) return getNodePath().resolve(dir);
|
|
95
|
+
if (dir) return path__default.default.resolve(dir);
|
|
144
96
|
try {
|
|
145
|
-
return
|
|
97
|
+
return path__default.default.dirname(url.fileURLToPath(importMetaUrl));
|
|
146
98
|
} catch {
|
|
147
99
|
return process.cwd();
|
|
148
100
|
}
|
|
149
101
|
}
|
|
150
|
-
|
|
151
|
-
if (error instanceof TwError) return error.toString();
|
|
152
|
-
if (error instanceof Error) return error.message;
|
|
153
|
-
return String(error);
|
|
154
|
-
}
|
|
155
|
-
var isBrowser, nodeModuleRef, _nodeFs, _nodePath, _nodeUrl, TwError, _require, LRUCache;
|
|
102
|
+
var TwError, _require, LRUCache;
|
|
156
103
|
var init_src = __esm({
|
|
157
104
|
"packages/domain/shared/src/index.ts"() {
|
|
158
|
-
isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
159
|
-
nodeModuleRef = null;
|
|
160
|
-
_nodeFs = null;
|
|
161
|
-
_nodePath = null;
|
|
162
|
-
_nodeUrl = null;
|
|
163
105
|
TwError = class _TwError extends Error {
|
|
164
106
|
/** @deprecated Gunakan source */
|
|
165
107
|
domain;
|
|
@@ -193,8 +135,8 @@ var init_src = __esm({
|
|
|
193
135
|
/** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
|
|
194
136
|
static fromZod(err) {
|
|
195
137
|
const first = err.issues?.[0] ?? err.errors?.[0];
|
|
196
|
-
const
|
|
197
|
-
const message = first ? `${
|
|
138
|
+
const path2 = formatIssuePath(first?.path);
|
|
139
|
+
const message = first ? `${path2}: ${first.message}` : "Schema validation failed";
|
|
198
140
|
return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
|
|
199
141
|
}
|
|
200
142
|
static wrap(source, code, err) {
|
|
@@ -212,7 +154,7 @@ var init_src = __esm({
|
|
|
212
154
|
return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
|
|
213
155
|
}
|
|
214
156
|
};
|
|
215
|
-
_require =
|
|
157
|
+
_require = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.js', document.baseURI).href)));
|
|
216
158
|
LRUCache = class {
|
|
217
159
|
capacity;
|
|
218
160
|
cache;
|
|
@@ -442,7 +384,7 @@ init_src();
|
|
|
442
384
|
// packages/domain/analyzer/src/utils.ts
|
|
443
385
|
init_src();
|
|
444
386
|
var DEBUG_NAMESPACE2 = "tailwind-styled:analyzer";
|
|
445
|
-
function
|
|
387
|
+
function formatErrorMessage(error) {
|
|
446
388
|
return error instanceof Error ? error.message : String(error);
|
|
447
389
|
}
|
|
448
390
|
var debugLog2 = createDebugLogger(DEBUG_NAMESPACE2, "tailwind-styled/analyzer");
|
|
@@ -532,7 +474,7 @@ async function requireNativeCssCompiler() {
|
|
|
532
474
|
|
|
533
475
|
// packages/domain/analyzer/src/schemas.ts
|
|
534
476
|
init_src();
|
|
535
|
-
var formatIssuePath2 = (
|
|
477
|
+
var formatIssuePath2 = (path2) => path2.length > 0 ? path2.map(
|
|
536
478
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
537
479
|
).join(".") : "<root>";
|
|
538
480
|
var isPlainObject = (value) => {
|
|
@@ -541,8 +483,8 @@ var isPlainObject = (value) => {
|
|
|
541
483
|
return proto === Object.prototype || proto === null;
|
|
542
484
|
};
|
|
543
485
|
var formatIssues = (error) => error.issues.map((issue) => {
|
|
544
|
-
const
|
|
545
|
-
return `${
|
|
486
|
+
const path2 = formatIssuePath2(issue.path);
|
|
487
|
+
return `${path2}: ${issue.message}`;
|
|
546
488
|
}).join("; ");
|
|
547
489
|
var parseWithSchema = (schema, data, label) => {
|
|
548
490
|
const parsed = schema.safeParse(data);
|
|
@@ -636,8 +578,11 @@ var parseNativeCssCompileResult = (result, className) => parseWithSchema(
|
|
|
636
578
|
var parseClassToCssOptions = (options) => parseWithSchema(ClassToCssOptionsSchema, options ?? {}, "classToCss options are invalid");
|
|
637
579
|
|
|
638
580
|
// packages/domain/analyzer/src/classToCss.ts
|
|
639
|
-
var normalizeClassInput = (input) => {
|
|
581
|
+
var normalizeClassInput = (input, _binding) => {
|
|
640
582
|
if (typeof input === "string") {
|
|
583
|
+
if (_binding?.normalizeClassInput) {
|
|
584
|
+
return _binding.normalizeClassInput(input);
|
|
585
|
+
}
|
|
641
586
|
return input.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
|
|
642
587
|
}
|
|
643
588
|
if (!Array.isArray(input)) {
|
|
@@ -659,27 +604,26 @@ var normalizeClassToCssOptions = (options) => {
|
|
|
659
604
|
const prefix = parsed.prefix ?? null;
|
|
660
605
|
return { prefix, strict };
|
|
661
606
|
};
|
|
662
|
-
var mergeDeclarationMap = (target, css) => {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
const property = declaration.slice(0, colonIndex).trim();
|
|
671
|
-
const value = declaration.slice(colonIndex + 1).trim();
|
|
672
|
-
if (property.length === 0 || value.length === 0) continue;
|
|
673
|
-
if (target.has(property)) target.delete(property);
|
|
674
|
-
target.set(property, value);
|
|
675
|
-
}
|
|
607
|
+
var mergeDeclarationMap = (target, css, binding) => {
|
|
608
|
+
if (!binding.parseCssRules) {
|
|
609
|
+
throw new Error("FATAL: Native binding 'parseCssRules' is required but not available.");
|
|
610
|
+
}
|
|
611
|
+
const rules = binding.parseCssRules(css);
|
|
612
|
+
for (const rule of rules) {
|
|
613
|
+
if (target.has(rule.property)) target.delete(rule.property);
|
|
614
|
+
target.set(rule.property, rule.isImportant ? `${rule.value} !important` : rule.value);
|
|
676
615
|
}
|
|
677
616
|
};
|
|
678
|
-
var declarationMapToString = (declarationMap) => {
|
|
679
|
-
|
|
617
|
+
var declarationMapToString = (declarationMap, binding) => {
|
|
618
|
+
const entries = Array.from(declarationMap.entries()).map(([property, value]) => ({ property, value }));
|
|
619
|
+
if (binding?.declarationMapToString) {
|
|
620
|
+
return binding.declarationMapToString(entries);
|
|
621
|
+
}
|
|
622
|
+
return entries.map(({ property, value }) => `${property}: ${value}`).join("; ");
|
|
680
623
|
};
|
|
681
624
|
var classToCss = async (input, options = {}) => {
|
|
682
|
-
const
|
|
625
|
+
const binding = await requireNativeCssCompiler();
|
|
626
|
+
const inputClasses = normalizeClassInput(input, binding);
|
|
683
627
|
const normalizedOptions = normalizeClassToCssOptions(options);
|
|
684
628
|
if (inputClasses.length === 0) {
|
|
685
629
|
return {
|
|
@@ -691,7 +635,6 @@ var classToCss = async (input, options = {}) => {
|
|
|
691
635
|
sizeBytes: 0
|
|
692
636
|
};
|
|
693
637
|
}
|
|
694
|
-
const binding = await requireNativeCssCompiler();
|
|
695
638
|
const prefix = normalizedOptions.prefix;
|
|
696
639
|
const results = await Promise.all(
|
|
697
640
|
inputClasses.map(async (className) => {
|
|
@@ -700,7 +643,7 @@ var classToCss = async (input, options = {}) => {
|
|
|
700
643
|
return binding.compileCss([className], prefix);
|
|
701
644
|
} catch (error) {
|
|
702
645
|
throw new Error(
|
|
703
|
-
`Native analyzer failed while compiling class "${className}": ${
|
|
646
|
+
`Native analyzer failed while compiling class "${className}": ${formatErrorMessage(error)}`,
|
|
704
647
|
{ cause: error }
|
|
705
648
|
);
|
|
706
649
|
}
|
|
@@ -724,7 +667,7 @@ var classToCss = async (input, options = {}) => {
|
|
|
724
667
|
const sizeBytes = results.reduce((sum, r) => sum + r.sizeBytes, 0);
|
|
725
668
|
const declarationMap = /* @__PURE__ */ new Map();
|
|
726
669
|
for (const result of results) {
|
|
727
|
-
mergeDeclarationMap(declarationMap, result.css);
|
|
670
|
+
mergeDeclarationMap(declarationMap, result.css, binding);
|
|
728
671
|
}
|
|
729
672
|
const uniqueUnknown = Array.from(new Set(unknownClasses));
|
|
730
673
|
if (normalizedOptions.strict && uniqueUnknown.length > 0) {
|
|
@@ -733,7 +676,7 @@ var classToCss = async (input, options = {}) => {
|
|
|
733
676
|
return {
|
|
734
677
|
inputClasses,
|
|
735
678
|
css: cssChunks.filter((chunk) => chunk.length > 0).join("\n"),
|
|
736
|
-
declarations: declarationMapToString(declarationMap),
|
|
679
|
+
declarations: declarationMapToString(declarationMap, binding),
|
|
737
680
|
resolvedClasses: Array.from(new Set(resolvedClasses)),
|
|
738
681
|
unknownClasses: uniqueUnknown,
|
|
739
682
|
sizeBytes
|
|
@@ -767,8 +710,8 @@ function stableKeyframesEntries(stops) {
|
|
|
767
710
|
}
|
|
768
711
|
function animationCacheKey(opts) {
|
|
769
712
|
const normalized = {
|
|
770
|
-
from: opts.from.trim(),
|
|
771
|
-
to: opts.to.trim(),
|
|
713
|
+
from: (opts.from ?? "").trim(),
|
|
714
|
+
to: (opts.to ?? "").trim(),
|
|
772
715
|
duration: normalizeNumber(opts.duration, DEFAULT_DURATION),
|
|
773
716
|
easing: (opts.easing ?? DEFAULT_EASING).trim(),
|
|
774
717
|
delay: normalizeNumber(opts.delay, DEFAULT_DELAY),
|
|
@@ -782,7 +725,10 @@ function animationCacheKey(opts) {
|
|
|
782
725
|
function keyframesCacheKey(name, stops) {
|
|
783
726
|
return `${name}::${JSON.stringify(stableKeyframesEntries(stops))}`;
|
|
784
727
|
}
|
|
785
|
-
function splitClasses(classList) {
|
|
728
|
+
function splitClasses(classList, binding) {
|
|
729
|
+
if (binding?.splitAnimateClasses) {
|
|
730
|
+
return binding.splitAnimateClasses(classList);
|
|
731
|
+
}
|
|
786
732
|
return classList.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
|
|
787
733
|
}
|
|
788
734
|
async function validateTailwindClasses(entries) {
|
|
@@ -790,147 +736,101 @@ async function validateTailwindClasses(entries) {
|
|
|
790
736
|
const unknownByContext = /* @__PURE__ */ new Map();
|
|
791
737
|
const failures = [];
|
|
792
738
|
for (const entry of entries) {
|
|
793
|
-
const classes = splitClasses(entry.classList);
|
|
739
|
+
const classes = splitClasses(entry.classList, binding);
|
|
794
740
|
if (classes.length === 0) continue;
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
if (!compiled) {
|
|
799
|
-
failures.push(
|
|
800
|
-
`Animation ${entry.context} failed validation: native compileCss returned no result.`
|
|
801
|
-
);
|
|
802
|
-
continue;
|
|
803
|
-
}
|
|
804
|
-
if (compiled.unknownClasses.length > 0) {
|
|
805
|
-
const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
|
|
806
|
-
for (const className of compiled.unknownClasses) bucket.add(className);
|
|
807
|
-
unknownByContext.set(entry.context, bucket);
|
|
808
|
-
}
|
|
809
|
-
continue;
|
|
810
|
-
}
|
|
811
|
-
const checked = await classToCss(classes, { strict: false });
|
|
812
|
-
if (checked.unknownClasses.length > 0) {
|
|
813
|
-
const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
|
|
814
|
-
for (const className of checked.unknownClasses) bucket.add(className);
|
|
815
|
-
unknownByContext.set(entry.context, bucket);
|
|
816
|
-
}
|
|
817
|
-
} catch (error) {
|
|
818
|
-
failures.push(`Animation ${entry.context} failed validation: ${formatErrorMessage(error)}`);
|
|
741
|
+
const result = await classToCss(classes);
|
|
742
|
+
if (result.unknownClasses.length > 0) {
|
|
743
|
+
unknownByContext.set(entry.context, new Set(result.unknownClasses));
|
|
819
744
|
}
|
|
820
745
|
}
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
issues.push(
|
|
824
|
-
`Animation ${context} contains unknown Tailwind classes: ${Array.from(classes).join(", ")}`
|
|
825
|
-
);
|
|
746
|
+
for (const [context, unknownSet] of unknownByContext.entries()) {
|
|
747
|
+
failures.push(`[${context}] unknown classes: ${Array.from(unknownSet).join(", ")}`);
|
|
826
748
|
}
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
749
|
+
if (failures.length > 0) {
|
|
750
|
+
throw new Error(`Animation validation failed:
|
|
751
|
+
${failures.join("\n")}`);
|
|
830
752
|
}
|
|
831
753
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
}
|
|
842
|
-
async compileAnimation(opts) {
|
|
843
|
-
const signature = animationCacheKey(opts);
|
|
844
|
-
const existingClassName = this.animationBySignature.get(signature);
|
|
845
|
-
if (existingClassName) {
|
|
846
|
-
const cached = this.animations.get(existingClassName);
|
|
754
|
+
function createAnimationRegistry(options = {}) {
|
|
755
|
+
const cacheLimit = normalizeCacheLimit(options.cacheLimit);
|
|
756
|
+
const cache = new LRUCache(cacheLimit);
|
|
757
|
+
const cssChunks = [];
|
|
758
|
+
const classNames = /* @__PURE__ */ new Set();
|
|
759
|
+
return {
|
|
760
|
+
async compileAnimation(opts) {
|
|
761
|
+
const key = animationCacheKey(opts);
|
|
762
|
+
const cached = cache.get(key);
|
|
847
763
|
if (cached) return cached;
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
iterations,
|
|
870
|
-
direction
|
|
871
|
-
);
|
|
872
|
-
if (!compiled) {
|
|
873
|
-
throw new Error(
|
|
874
|
-
`Native animate backend failed to compile animation "${opts.name ?? "anonymous animation"}".`
|
|
764
|
+
const binding = await getAnimateBinding();
|
|
765
|
+
const classesToValidate = [
|
|
766
|
+
{ classList: opts.from ?? "", context: "from" },
|
|
767
|
+
{ classList: opts.to ?? "", context: "to" }
|
|
768
|
+
].filter((entry) => entry.classList.trim().length > 0);
|
|
769
|
+
if (classesToValidate.length > 0) {
|
|
770
|
+
await validateTailwindClasses(classesToValidate);
|
|
771
|
+
}
|
|
772
|
+
if (!binding.compileAnimation) {
|
|
773
|
+
throw new Error("FATAL: Native binding 'compileAnimation' is required but not available.");
|
|
774
|
+
}
|
|
775
|
+
const result = binding.compileAnimation(
|
|
776
|
+
opts.from,
|
|
777
|
+
opts.to,
|
|
778
|
+
opts.name ?? null,
|
|
779
|
+
normalizeNumber(opts.duration, DEFAULT_DURATION),
|
|
780
|
+
opts.easing ?? DEFAULT_EASING,
|
|
781
|
+
normalizeNumber(opts.delay, DEFAULT_DELAY),
|
|
782
|
+
opts.fill ?? DEFAULT_FILL,
|
|
783
|
+
normalizeIterations(opts.iterations),
|
|
784
|
+
opts.direction ?? DEFAULT_DIRECTION
|
|
875
785
|
);
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
const
|
|
786
|
+
if (!result) {
|
|
787
|
+
throw new Error(`compileAnimation returned null for opts: ${JSON.stringify(opts)}`);
|
|
788
|
+
}
|
|
789
|
+
const compiled = {
|
|
790
|
+
className: result.className,
|
|
791
|
+
keyframesCss: result.keyframesCss,
|
|
792
|
+
animationCss: result.animationCss
|
|
793
|
+
};
|
|
794
|
+
cache.set(key, compiled);
|
|
795
|
+
if (result.keyframesCss) cssChunks.push(result.keyframesCss);
|
|
796
|
+
if (result.animationCss) cssChunks.push(result.animationCss);
|
|
797
|
+
return compiled;
|
|
798
|
+
},
|
|
799
|
+
async compileKeyframes(name, stops) {
|
|
800
|
+
const key = keyframesCacheKey(name, stops);
|
|
801
|
+
const cached = cache.get(key);
|
|
891
802
|
if (cached) return cached;
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
803
|
+
const binding = await getAnimateBinding();
|
|
804
|
+
const stopsJson = JSON.stringify(stableKeyframesEntries(stops));
|
|
805
|
+
if (!binding.compileKeyframes) {
|
|
806
|
+
throw new Error("FATAL: Native binding 'compileKeyframes' is required but not available.");
|
|
807
|
+
}
|
|
808
|
+
const result = binding.compileKeyframes(name, stopsJson);
|
|
809
|
+
if (!result) {
|
|
810
|
+
throw new Error(`compileKeyframes returned null for name: ${name}`);
|
|
811
|
+
}
|
|
812
|
+
const compiled = {
|
|
813
|
+
className: result.className,
|
|
814
|
+
keyframesCss: result.keyframesCss,
|
|
815
|
+
animationCss: result.animationCss
|
|
816
|
+
};
|
|
817
|
+
cache.set(key, compiled);
|
|
818
|
+
if (result.keyframesCss) cssChunks.push(result.keyframesCss);
|
|
819
|
+
if (result.animationCss) cssChunks.push(result.animationCss);
|
|
820
|
+
return compiled;
|
|
821
|
+
},
|
|
822
|
+
extractCss() {
|
|
823
|
+
return cssChunks.join("\n");
|
|
824
|
+
},
|
|
825
|
+
reset() {
|
|
826
|
+
cache.clear?.();
|
|
827
|
+
cssChunks.length = 0;
|
|
828
|
+
classNames.clear();
|
|
829
|
+
},
|
|
830
|
+
has(className) {
|
|
831
|
+
return classNames.has(className);
|
|
920
832
|
}
|
|
921
|
-
|
|
922
|
-
}
|
|
923
|
-
reset() {
|
|
924
|
-
this.animations.clear();
|
|
925
|
-
this.animationBySignature.clear();
|
|
926
|
-
this.keyframesBySignature.clear();
|
|
927
|
-
}
|
|
928
|
-
has(className) {
|
|
929
|
-
return this.animations.has(className);
|
|
930
|
-
}
|
|
931
|
-
};
|
|
932
|
-
function createAnimationRegistry(options = {}) {
|
|
933
|
-
return new AnimationRegistry(options);
|
|
833
|
+
};
|
|
934
834
|
}
|
|
935
835
|
|
|
936
836
|
// packages/domain/animate/src/index.ts
|
|
@@ -941,8 +841,14 @@ async function initAnimate2() {
|
|
|
941
841
|
function getDefaultAnimationRegistry() {
|
|
942
842
|
return defaultRegistry;
|
|
943
843
|
}
|
|
944
|
-
async function compileAnimation(
|
|
945
|
-
|
|
844
|
+
async function compileAnimation(optsOrName, secondArg) {
|
|
845
|
+
if (typeof optsOrName === "string") {
|
|
846
|
+
const partialOpts = secondArg && typeof secondArg.compileAnimation !== "function" ? secondArg : {};
|
|
847
|
+
const opts = { from: "", to: "", ...partialOpts, name: optsOrName };
|
|
848
|
+
return defaultRegistry.compileAnimation(opts);
|
|
849
|
+
}
|
|
850
|
+
const registry = secondArg && typeof secondArg.compileAnimation === "function" ? secondArg : defaultRegistry;
|
|
851
|
+
return registry.compileAnimation(optsOrName);
|
|
946
852
|
}
|
|
947
853
|
async function compileKeyframes(name, stops, registry = defaultRegistry) {
|
|
948
854
|
return registry.compileKeyframes(name, stops);
|
|
@@ -983,7 +889,7 @@ function injectAnimationCss(registry = defaultRegistry, options = {}) {
|
|
|
983
889
|
}
|
|
984
890
|
var animations = createAnimationPresets(defaultRegistry);
|
|
985
891
|
|
|
986
|
-
exports.AnimationRegistry =
|
|
892
|
+
exports.AnimationRegistry = createAnimationRegistry;
|
|
987
893
|
exports.animate = animate;
|
|
988
894
|
exports.animations = animations;
|
|
989
895
|
exports.compileAnimation = compileAnimation;
|