tailwind-styled-v4 5.1.11 → 5.1.12
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/dist/index.browser.mjs +48 -5
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.js +50 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -5
- package/dist/index.mjs.map +1 -1
- package/dist/runtime-css.js +1 -0
- package/dist/runtime-css.mjs +1 -0
- package/dist/runtime.js +1 -0
- package/dist/runtime.mjs +1 -0
- package/dist/theme.js +1 -0
- package/dist/theme.mjs +1 -0
- package/package.json +1 -1
- package/dist/metafile-cjs.json +0 -1
package/dist/index.browser.mjs
CHANGED
|
@@ -918,8 +918,48 @@ function wrapWithSubProxy(component, tagLabel) {
|
|
|
918
918
|
});
|
|
919
919
|
}
|
|
920
920
|
|
|
921
|
+
// packages/domain/core/src/parseTemplateFallback.ts
|
|
922
|
+
var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
|
|
923
|
+
var COMMENT_RE = /\/\/[^\n]*/g;
|
|
924
|
+
function collapseSpaces(s) {
|
|
925
|
+
return s.replace(/\s+/g, " ").trim();
|
|
926
|
+
}
|
|
927
|
+
function cleanBlock(raw) {
|
|
928
|
+
const noComments = raw.replace(COMMENT_RE, "");
|
|
929
|
+
const lines = noComments.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
930
|
+
return collapseSpaces(lines.join(" "));
|
|
931
|
+
}
|
|
932
|
+
function parseTemplateJs(raw) {
|
|
933
|
+
const subs = {};
|
|
934
|
+
let base = raw;
|
|
935
|
+
for (const match of raw.matchAll(SUB_RE)) {
|
|
936
|
+
const fullMatch = match[0];
|
|
937
|
+
const name = match[1] ?? match[2] ?? "";
|
|
938
|
+
const innerRaw = match[3] ?? "";
|
|
939
|
+
if (name) {
|
|
940
|
+
subs[name] = cleanBlock(innerRaw);
|
|
941
|
+
}
|
|
942
|
+
base = base.replace(fullMatch, "");
|
|
943
|
+
}
|
|
944
|
+
return {
|
|
945
|
+
base: cleanBlock(base),
|
|
946
|
+
subs,
|
|
947
|
+
hasSubs: Object.keys(subs).length > 0
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
|
|
921
951
|
// packages/domain/core/src/twProxy.ts
|
|
922
952
|
var _parsedTemplateCache = /* @__PURE__ */ new Map();
|
|
953
|
+
var warnedParseTemplateFallback = false;
|
|
954
|
+
function warnParseTemplateFallbackOnce() {
|
|
955
|
+
if (warnedParseTemplateFallback) return;
|
|
956
|
+
warnedParseTemplateFallback = true;
|
|
957
|
+
if (typeof console !== "undefined") {
|
|
958
|
+
console.warn(
|
|
959
|
+
"[tailwind-styled-v4] Native binding 'parseTemplate' tidak tersedia (normal di browser, untuk komponen yang di-chain dengan .extend/.withVariants/.animate/.withSub) \u2014 pakai pure-TS port dari algoritma Rust-nya. Hasil tetap benar; ini cuma informasi, bukan error."
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
923
963
|
function parseTemplate(strings, exprs) {
|
|
924
964
|
const raw = strings.raw.reduce((acc, str, i) => {
|
|
925
965
|
const expr = exprs[i];
|
|
@@ -929,12 +969,15 @@ function parseTemplate(strings, exprs) {
|
|
|
929
969
|
const cached = _parsedTemplateCache.get(raw);
|
|
930
970
|
if (cached) return cached;
|
|
931
971
|
const binding = getNativeBinding();
|
|
932
|
-
|
|
933
|
-
|
|
972
|
+
let result;
|
|
973
|
+
if (binding?.parseTemplate) {
|
|
974
|
+
const r = binding.parseTemplate(raw);
|
|
975
|
+
const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
|
|
976
|
+
result = { base: r.base, subs, hasSubs: r.hasSubs };
|
|
977
|
+
} else {
|
|
978
|
+
warnParseTemplateFallbackOnce();
|
|
979
|
+
result = parseTemplateJs(raw);
|
|
934
980
|
}
|
|
935
|
-
const r = binding.parseTemplate(raw);
|
|
936
|
-
const subs = r.hasSubs ? JSON.parse(r.subsJson) : {};
|
|
937
|
-
const result = { base: r.base, subs, hasSubs: r.hasSubs };
|
|
938
981
|
_parsedTemplateCache.set(raw, result);
|
|
939
982
|
return result;
|
|
940
983
|
}
|