@open-feishu-card/adapter 0.3.8 → 0.3.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.
|
@@ -10,7 +10,7 @@ export type CustomColorEntry = {
|
|
|
10
10
|
export type ColorRegistry = Record<string, CustomColorEntry>;
|
|
11
11
|
export declare function readColorRegistry(card: Record<string, unknown>): ColorRegistry;
|
|
12
12
|
export declare function isCustomColorAlias(value: unknown): value is string;
|
|
13
|
-
/** column / column_set background_style cus-N → customBackgroundStyle */
|
|
13
|
+
/** column / column_set / interactive_container background_style cus-N → customBackgroundStyle */
|
|
14
14
|
export declare function expandBackgroundStyleAlias(style: unknown, registry: ColorRegistry): {
|
|
15
15
|
light_mode: string;
|
|
16
16
|
dark_mode: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expand-dsl-colors.d.ts","sourceRoot":"","sources":["../src/expand-dsl-colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,MAAM,gBAAgB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AACzE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE7D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAiB9E;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAElE;AAED,
|
|
1
|
+
{"version":3,"file":"expand-dsl-colors.d.ts","sourceRoot":"","sources":["../src/expand-dsl-colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,MAAM,gBAAgB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AACzE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE7D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAiB9E;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAElE;AAED,iGAAiG;AACjG,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,aAAa,GACtB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAKvD;AAED,6DAA6D;AAC7D,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,QAAQ,EAAE,aAAa,GACtB,SAAS,GAAG,SAAS,CAWvB;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,aAAa,GACtB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAEvD;AAED,0CAA0C;AAC1C,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,WAAW,EAAE,GAAG,SAAS,EACnC,QAAQ,EAAE,aAAa,GACtB,WAAW,EAAE,GAAG,SAAS,CAG3B;AAuCD,4DAA4D;AAC5D,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,MAAM,CAGR"}
|
package/dist/index.cjs
CHANGED
|
@@ -843,13 +843,27 @@ function buildProperty(el, tag, colors) {
|
|
|
843
843
|
const property = {};
|
|
844
844
|
for (const [k, v] of Object.entries(el)) {
|
|
845
845
|
if (k === "tag" || k === "id") continue;
|
|
846
|
-
if ((k === "background_style" || k === "backgroundStyle") && (tag === "column" || tag === "column_set")) {
|
|
846
|
+
if ((k === "background_style" || k === "backgroundStyle") && (tag === "column" || tag === "column_set" || tag === "interactive_container")) {
|
|
847
847
|
const renamed = renameKey(k);
|
|
848
848
|
property[renamed] = v;
|
|
849
849
|
const expanded = expandBackgroundStyleAlias(v, colors);
|
|
850
850
|
if (expanded) property.customBackgroundStyle = expanded;
|
|
851
851
|
continue;
|
|
852
852
|
}
|
|
853
|
+
if ((k === "background_color" || k === "backgroundColor") && tag === "collapsible_panel") {
|
|
854
|
+
const renamed = renameKey(k);
|
|
855
|
+
property[renamed] = v;
|
|
856
|
+
const expanded = expandBackgroundStyleAlias(v, colors);
|
|
857
|
+
if (expanded) property.customBackgroundStyle = expanded;
|
|
858
|
+
continue;
|
|
859
|
+
}
|
|
860
|
+
if (k === "border" && tag === "collapsible_panel" && isRecord2(v)) {
|
|
861
|
+
const border = { ...v };
|
|
862
|
+
const expanded = expandBackgroundStyleAlias(border.color, colors);
|
|
863
|
+
if (expanded) border.color = expanded.light_mode;
|
|
864
|
+
property.border = border;
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
853
867
|
if ((k === "border_color" || k === "borderColor") && tag === "interactive_container") {
|
|
854
868
|
const renamed = renameKey(k);
|
|
855
869
|
property[renamed] = v;
|
|
@@ -1034,12 +1048,45 @@ function readCustomBackgroundStyle(node) {
|
|
|
1034
1048
|
function readCustomBorderColor(node) {
|
|
1035
1049
|
return readThemeColorPair(node.custom_border_color ?? node.customBorderColor);
|
|
1036
1050
|
}
|
|
1051
|
+
function seedRegistryFromConfigStyle(dsl, colorEntries, bgKeyToAlias, textKeyToAlias) {
|
|
1052
|
+
let bgSeq = 0;
|
|
1053
|
+
let textSeq = 0;
|
|
1054
|
+
const config = dsl.config;
|
|
1055
|
+
if (!config || typeof config !== "object") return { bgSeq, textSeq };
|
|
1056
|
+
const style = config.style;
|
|
1057
|
+
if (!style || typeof style !== "object") return { bgSeq, textSeq };
|
|
1058
|
+
const colors = style.color;
|
|
1059
|
+
if (!colors || typeof colors !== "object") return { bgSeq, textSeq };
|
|
1060
|
+
for (const [alias, entry] of Object.entries(colors)) {
|
|
1061
|
+
if (!entry || typeof entry !== "object") continue;
|
|
1062
|
+
const pair = entry;
|
|
1063
|
+
if (typeof pair.light_mode !== "string" || typeof pair.dark_mode !== "string") continue;
|
|
1064
|
+
const themePair = { light_mode: pair.light_mode, dark_mode: pair.dark_mode };
|
|
1065
|
+
colorEntries[alias] = themePair;
|
|
1066
|
+
const key = colorEntryKey(themePair);
|
|
1067
|
+
if (alias.startsWith("cus-text")) {
|
|
1068
|
+
textKeyToAlias.set(key, alias);
|
|
1069
|
+
const n = /^cus-text-(\d+)$/.exec(alias);
|
|
1070
|
+
if (n) textSeq = Math.max(textSeq, Number(n[1]) + 1);
|
|
1071
|
+
} else {
|
|
1072
|
+
bgKeyToAlias.set(key, alias);
|
|
1073
|
+
const n = /^cus-bg-(\d+)$/.exec(alias);
|
|
1074
|
+
if (n) bgSeq = Math.max(bgSeq, Number(n[1]) + 1);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
return { bgSeq, textSeq };
|
|
1078
|
+
}
|
|
1037
1079
|
function normalizeStoredCardColors(dsl, preRegistered) {
|
|
1038
1080
|
const colorEntries = { ...preRegistered?.entries ?? {} };
|
|
1039
1081
|
const bgKeyToAlias = new Map(preRegistered?.bgKeyToAlias ?? []);
|
|
1040
1082
|
const textKeyToAlias = new Map(preRegistered?.textKeyToAlias ?? []);
|
|
1041
1083
|
let bgSeq = preRegistered?.bgSeq ?? 0;
|
|
1042
1084
|
let textSeq = preRegistered?.textSeq ?? 0;
|
|
1085
|
+
if (!preRegistered) {
|
|
1086
|
+
const seeded = seedRegistryFromConfigStyle(dsl, colorEntries, bgKeyToAlias, textKeyToAlias);
|
|
1087
|
+
bgSeq = Math.max(bgSeq, seeded.bgSeq);
|
|
1088
|
+
textSeq = Math.max(textSeq, seeded.textSeq);
|
|
1089
|
+
}
|
|
1043
1090
|
const ensureAlias = (prefix, entry) => {
|
|
1044
1091
|
const map = prefix === "cus-bg" ? bgKeyToAlias : textKeyToAlias;
|
|
1045
1092
|
const existing2 = map.get(colorEntryKey(entry));
|
|
@@ -1064,6 +1111,11 @@ function normalizeStoredCardColors(dsl, preRegistered) {
|
|
|
1064
1111
|
}
|
|
1065
1112
|
}
|
|
1066
1113
|
if (obj.tag === "interactive_container") {
|
|
1114
|
+
const customBg = readCustomBackgroundStyle(obj);
|
|
1115
|
+
if (customBg) {
|
|
1116
|
+
obj.background_style = ensureAlias("cus-bg", customBg);
|
|
1117
|
+
delete obj.custom_background_style;
|
|
1118
|
+
}
|
|
1067
1119
|
const border = readCustomBorderColor(obj);
|
|
1068
1120
|
if (border) {
|
|
1069
1121
|
obj.border_color = ensureAlias("cus-bg", border);
|
package/dist/index.js
CHANGED
|
@@ -841,13 +841,27 @@ function buildProperty(el, tag, colors) {
|
|
|
841
841
|
const property = {};
|
|
842
842
|
for (const [k, v] of Object.entries(el)) {
|
|
843
843
|
if (k === "tag" || k === "id") continue;
|
|
844
|
-
if ((k === "background_style" || k === "backgroundStyle") && (tag === "column" || tag === "column_set")) {
|
|
844
|
+
if ((k === "background_style" || k === "backgroundStyle") && (tag === "column" || tag === "column_set" || tag === "interactive_container")) {
|
|
845
845
|
const renamed = renameKey(k);
|
|
846
846
|
property[renamed] = v;
|
|
847
847
|
const expanded = expandBackgroundStyleAlias(v, colors);
|
|
848
848
|
if (expanded) property.customBackgroundStyle = expanded;
|
|
849
849
|
continue;
|
|
850
850
|
}
|
|
851
|
+
if ((k === "background_color" || k === "backgroundColor") && tag === "collapsible_panel") {
|
|
852
|
+
const renamed = renameKey(k);
|
|
853
|
+
property[renamed] = v;
|
|
854
|
+
const expanded = expandBackgroundStyleAlias(v, colors);
|
|
855
|
+
if (expanded) property.customBackgroundStyle = expanded;
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
858
|
+
if (k === "border" && tag === "collapsible_panel" && isRecord2(v)) {
|
|
859
|
+
const border = { ...v };
|
|
860
|
+
const expanded = expandBackgroundStyleAlias(border.color, colors);
|
|
861
|
+
if (expanded) border.color = expanded.light_mode;
|
|
862
|
+
property.border = border;
|
|
863
|
+
continue;
|
|
864
|
+
}
|
|
851
865
|
if ((k === "border_color" || k === "borderColor") && tag === "interactive_container") {
|
|
852
866
|
const renamed = renameKey(k);
|
|
853
867
|
property[renamed] = v;
|
|
@@ -1032,12 +1046,45 @@ function readCustomBackgroundStyle(node) {
|
|
|
1032
1046
|
function readCustomBorderColor(node) {
|
|
1033
1047
|
return readThemeColorPair(node.custom_border_color ?? node.customBorderColor);
|
|
1034
1048
|
}
|
|
1049
|
+
function seedRegistryFromConfigStyle(dsl, colorEntries, bgKeyToAlias, textKeyToAlias) {
|
|
1050
|
+
let bgSeq = 0;
|
|
1051
|
+
let textSeq = 0;
|
|
1052
|
+
const config = dsl.config;
|
|
1053
|
+
if (!config || typeof config !== "object") return { bgSeq, textSeq };
|
|
1054
|
+
const style = config.style;
|
|
1055
|
+
if (!style || typeof style !== "object") return { bgSeq, textSeq };
|
|
1056
|
+
const colors = style.color;
|
|
1057
|
+
if (!colors || typeof colors !== "object") return { bgSeq, textSeq };
|
|
1058
|
+
for (const [alias, entry] of Object.entries(colors)) {
|
|
1059
|
+
if (!entry || typeof entry !== "object") continue;
|
|
1060
|
+
const pair = entry;
|
|
1061
|
+
if (typeof pair.light_mode !== "string" || typeof pair.dark_mode !== "string") continue;
|
|
1062
|
+
const themePair = { light_mode: pair.light_mode, dark_mode: pair.dark_mode };
|
|
1063
|
+
colorEntries[alias] = themePair;
|
|
1064
|
+
const key = colorEntryKey(themePair);
|
|
1065
|
+
if (alias.startsWith("cus-text")) {
|
|
1066
|
+
textKeyToAlias.set(key, alias);
|
|
1067
|
+
const n = /^cus-text-(\d+)$/.exec(alias);
|
|
1068
|
+
if (n) textSeq = Math.max(textSeq, Number(n[1]) + 1);
|
|
1069
|
+
} else {
|
|
1070
|
+
bgKeyToAlias.set(key, alias);
|
|
1071
|
+
const n = /^cus-bg-(\d+)$/.exec(alias);
|
|
1072
|
+
if (n) bgSeq = Math.max(bgSeq, Number(n[1]) + 1);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
return { bgSeq, textSeq };
|
|
1076
|
+
}
|
|
1035
1077
|
function normalizeStoredCardColors(dsl, preRegistered) {
|
|
1036
1078
|
const colorEntries = { ...preRegistered?.entries ?? {} };
|
|
1037
1079
|
const bgKeyToAlias = new Map(preRegistered?.bgKeyToAlias ?? []);
|
|
1038
1080
|
const textKeyToAlias = new Map(preRegistered?.textKeyToAlias ?? []);
|
|
1039
1081
|
let bgSeq = preRegistered?.bgSeq ?? 0;
|
|
1040
1082
|
let textSeq = preRegistered?.textSeq ?? 0;
|
|
1083
|
+
if (!preRegistered) {
|
|
1084
|
+
const seeded = seedRegistryFromConfigStyle(dsl, colorEntries, bgKeyToAlias, textKeyToAlias);
|
|
1085
|
+
bgSeq = Math.max(bgSeq, seeded.bgSeq);
|
|
1086
|
+
textSeq = Math.max(textSeq, seeded.textSeq);
|
|
1087
|
+
}
|
|
1041
1088
|
const ensureAlias = (prefix, entry) => {
|
|
1042
1089
|
const map = prefix === "cus-bg" ? bgKeyToAlias : textKeyToAlias;
|
|
1043
1090
|
const existing2 = map.get(colorEntryKey(entry));
|
|
@@ -1062,6 +1109,11 @@ function normalizeStoredCardColors(dsl, preRegistered) {
|
|
|
1062
1109
|
}
|
|
1063
1110
|
}
|
|
1064
1111
|
if (obj.tag === "interactive_container") {
|
|
1112
|
+
const customBg = readCustomBackgroundStyle(obj);
|
|
1113
|
+
if (customBg) {
|
|
1114
|
+
obj.background_style = ensureAlias("cus-bg", customBg);
|
|
1115
|
+
delete obj.custom_background_style;
|
|
1116
|
+
}
|
|
1065
1117
|
const border = readCustomBorderColor(obj);
|
|
1066
1118
|
if (border) {
|
|
1067
1119
|
obj.border_color = ensureAlias("cus-bg", border);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-stored-colors.d.ts","sourceRoot":"","sources":["../src/normalize-stored-colors.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,sDAAsD;IACtD,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,aAAa,CAEnD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAE7D;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,QAAQ,GAAG,UAAU,GAC5B,MAAM,CAWR;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgB9D;
|
|
1
|
+
{"version":3,"file":"normalize-stored-colors.d.ts","sourceRoot":"","sources":["../src/normalize-stored-colors.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,sDAAsD;IACtD,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,aAAa,CAEnD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAE7D;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,QAAQ,GAAG,UAAU,GAC5B,MAAM,CAWR;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgB9D;AA8DD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,aAAa,CAAC,EAAE,aAAa,GAC5B,IAAI,CA+HN"}
|