@ohhwells/bridge 0.1.180-next.483 → 0.1.180-next.484
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.cjs +28 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2985,26 +2985,30 @@ function readRootVar(doc, name) {
|
|
|
2985
2985
|
const root = doc.documentElement;
|
|
2986
2986
|
return root.style.getPropertyValue(name).trim() || getComputedStyle(root).getPropertyValue(name).trim();
|
|
2987
2987
|
}
|
|
2988
|
+
function readVarAt(el, name) {
|
|
2989
|
+
const local = el.isConnected ? getComputedStyle(el).getPropertyValue(name).trim() : "";
|
|
2990
|
+
return local || readRootVar(el.ownerDocument, name);
|
|
2991
|
+
}
|
|
2988
2992
|
function sameColor(a, b) {
|
|
2989
2993
|
return Math.round(a.r) === Math.round(b.r) && Math.round(a.g) === Math.round(b.g) && Math.round(a.b) === Math.round(b.b) && Math.abs(a.a - b.a) < 0.02;
|
|
2990
2994
|
}
|
|
2991
|
-
function brandTrackedColor(
|
|
2995
|
+
function brandTrackedColor(el, color, roles) {
|
|
2992
2996
|
if (!color || color.includes("var(")) return color;
|
|
2993
2997
|
const parsed = parseColor(color);
|
|
2994
2998
|
if (!parsed || isTransparent(parsed)) return color;
|
|
2995
2999
|
for (const role of roles) {
|
|
2996
3000
|
const name = `--brand-${role}`;
|
|
2997
|
-
const token = parseColor(
|
|
3001
|
+
const token = parseColor(readVarAt(el, name));
|
|
2998
3002
|
if (token && !isTransparent(token) && sameColor(parsed, token)) return `var(${name}, ${color})`;
|
|
2999
3003
|
}
|
|
3000
3004
|
return color;
|
|
3001
3005
|
}
|
|
3002
|
-
function brandTrackedChrome(
|
|
3006
|
+
function brandTrackedChrome(el, chrome) {
|
|
3003
3007
|
return {
|
|
3004
3008
|
...chrome,
|
|
3005
|
-
background: brandTrackedColor(
|
|
3006
|
-
color: brandTrackedColor(
|
|
3007
|
-
borderColor: brandTrackedColor(
|
|
3009
|
+
background: brandTrackedColor(el, chrome.background, BRAND_TRACK_PRECEDENCE.background),
|
|
3010
|
+
color: brandTrackedColor(el, chrome.color, BRAND_TRACK_PRECEDENCE.color),
|
|
3011
|
+
borderColor: brandTrackedColor(el, chrome.borderColor, BRAND_TRACK_PRECEDENCE.borderColor)
|
|
3008
3012
|
};
|
|
3009
3013
|
}
|
|
3010
3014
|
function firstFamily(stack2) {
|
|
@@ -3049,17 +3053,23 @@ function surfaceBehind(el) {
|
|
|
3049
3053
|
}
|
|
3050
3054
|
return { r: 255, g: 255, b: 255, a: 1 };
|
|
3051
3055
|
}
|
|
3056
|
+
function parseTrackedColor(el, value) {
|
|
3057
|
+
if (!value) return null;
|
|
3058
|
+
const tracked = value.trim().match(/^var\(\s*(--[\w-]+)\s*(?:,\s*(.+))?\)$/);
|
|
3059
|
+
if (!tracked) return parseColor(value);
|
|
3060
|
+
return parseColor(readVarAt(el, tracked[1])) ?? (tracked[2] ? parseTrackedColor(el, tracked[2]) : null);
|
|
3061
|
+
}
|
|
3052
3062
|
function readableOnSurface(el, chrome, primary) {
|
|
3053
|
-
const fill =
|
|
3063
|
+
const fill = parseTrackedColor(el, chrome.background);
|
|
3054
3064
|
if (fill && !isTransparent(fill)) return chrome;
|
|
3055
|
-
const ink =
|
|
3065
|
+
const ink = parseTrackedColor(el, chrome.color);
|
|
3056
3066
|
if (!ink || isTransparent(ink)) return chrome;
|
|
3057
3067
|
const surface = surfaceBehind(el);
|
|
3058
3068
|
const dark = surface ? relativeLuminance(surface) < 0.4 : toneFor(el) === "dark";
|
|
3059
3069
|
const readable = surface ? contrastRatio({ ...ink, a: 1 }, surface) >= 3 : dark === relativeLuminance(ink) > 0.4;
|
|
3060
3070
|
if (readable) return chrome;
|
|
3061
|
-
const primaryFill =
|
|
3062
|
-
const primaryLabel =
|
|
3071
|
+
const primaryFill = parseTrackedColor(el, primary.background);
|
|
3072
|
+
const primaryLabel = parseTrackedColor(el, primary.color);
|
|
3063
3073
|
let next;
|
|
3064
3074
|
if (dark) {
|
|
3065
3075
|
next = primaryLabel && relativeLuminance(primaryLabel) > 0.55 ? toCss({ ...primaryLabel, a: 1 }) : "rgb(255, 255, 255)";
|
|
@@ -3137,9 +3147,9 @@ function applyButtonStyle(el, assignment, tokens) {
|
|
|
3137
3147
|
const tracked = {
|
|
3138
3148
|
...tokens,
|
|
3139
3149
|
variants: {
|
|
3140
|
-
primary: brandTrackedChrome(
|
|
3141
|
-
secondary: brandTrackedChrome(
|
|
3142
|
-
ghost: brandTrackedChrome(
|
|
3150
|
+
primary: brandTrackedChrome(el, tokens.variants.primary),
|
|
3151
|
+
secondary: brandTrackedChrome(el, tokens.variants.secondary),
|
|
3152
|
+
ghost: brandTrackedChrome(el, tokens.variants.ghost)
|
|
3143
3153
|
}
|
|
3144
3154
|
};
|
|
3145
3155
|
paintLockByEl.set(el, { assignment, tokens: tracked });
|
|
@@ -3917,7 +3927,7 @@ function syncCollectionEmpty(collection) {
|
|
|
3917
3927
|
const marked = collection.hasAttribute(EMPTY_ATTR);
|
|
3918
3928
|
if (empty && !marked) {
|
|
3919
3929
|
collection.setAttribute(EMPTY_ATTR, collection.style.display);
|
|
3920
|
-
collection.style.display
|
|
3930
|
+
collection.style.setProperty("display", "none", "important");
|
|
3921
3931
|
} else if (!empty && marked) {
|
|
3922
3932
|
collection.style.display = collection.getAttribute(EMPTY_ATTR) ?? "";
|
|
3923
3933
|
collection.removeAttribute(EMPTY_ATTR);
|
|
@@ -4346,7 +4356,7 @@ function persistCollectionOrder(collection, content) {
|
|
|
4346
4356
|
function hideButton(el) {
|
|
4347
4357
|
if (el.getAttribute("data-ohw-button-hidden") === "") return;
|
|
4348
4358
|
el.setAttribute("data-ohw-button-hidden", "");
|
|
4349
|
-
el.style.display
|
|
4359
|
+
el.style.setProperty("display", "none", "important");
|
|
4350
4360
|
}
|
|
4351
4361
|
function syncButtonsFromContent(doc, content) {
|
|
4352
4362
|
reconcileButtonCollections(doc, content);
|
|
@@ -22540,7 +22550,7 @@ function apiBase() {
|
|
|
22540
22550
|
function bridgeVersion() {
|
|
22541
22551
|
try {
|
|
22542
22552
|
if (true) {
|
|
22543
|
-
return "0.1.180-next.
|
|
22553
|
+
return "0.1.180-next.484";
|
|
22544
22554
|
}
|
|
22545
22555
|
} catch {
|
|
22546
22556
|
}
|
|
@@ -22554,7 +22564,7 @@ function stampBridgeVersionOnDocument() {
|
|
|
22554
22564
|
return;
|
|
22555
22565
|
}
|
|
22556
22566
|
try {
|
|
22557
|
-
const v = true ? "0.1.180-next.
|
|
22567
|
+
const v = true ? "0.1.180-next.484" : "";
|
|
22558
22568
|
if (v) {
|
|
22559
22569
|
document.documentElement.setAttribute("data-ohw-bridge-version", v);
|
|
22560
22570
|
window.__OHW_BRIDGE_VERSION__ = v;
|
|
@@ -37871,7 +37881,7 @@ function OhhwellsBridge() {
|
|
|
37871
37881
|
postToParent2({
|
|
37872
37882
|
type: "ow:ready",
|
|
37873
37883
|
version: "1",
|
|
37874
|
-
bridgeVersion: "0.1.180-next.
|
|
37884
|
+
bridgeVersion: "0.1.180-next.484",
|
|
37875
37885
|
path: pathname,
|
|
37876
37886
|
nodes: collectEditableNodes(editContentRef.current),
|
|
37877
37887
|
sections
|