efficient-web-builder 59.2.0 → 60.0.0
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 +55 -0
- package/dist/editor/components/SectionThumbnail.js +1 -1
- package/dist/editor/components/storefront-editor.css +21 -7
- package/dist/editor/lib/animation/fields.js +1 -1
- package/dist/editor/lib/animation/hover-fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/Flex/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/Footprint/fields.js +1 -1
- package/dist/editor/lib/document/blocks/general/ListSearch/fields.js +1 -1
- package/dist/editor/lib/document/canvas-typing.js +1 -1
- package/dist/editor/lib/document/card-display-chips.d.ts +4 -2
- package/dist/editor/lib/document/card-display-chips.js +1 -1
- package/dist/editor/lib/document/card-row-fields.d.ts +3 -1
- package/dist/editor/lib/document/card-row-fields.js +1 -1
- package/dist/editor/lib/document/controls.js +1 -1
- package/dist/editor/lib/document/field-groups.js +1 -1
- package/dist/editor/lib/document/mirror-cards-field.js +1 -1
- package/dist/format/lib/animation/hover.d.ts +23 -1
- package/dist/format/lib/animation/hover.js +1 -1
- package/dist/format/lib/content/block-align.d.ts +3 -1
- package/dist/format/lib/content/block-align.js +1 -1
- package/dist/format/lib/content/box-background.d.ts +7 -0
- package/dist/format/lib/content/box-background.js +1 -1
- package/dist/format/lib/content/box-card-rule.d.ts +7 -0
- package/dist/format/lib/content/box-card-rule.js +1 -0
- package/dist/format/lib/content/box-layout.js +1 -1
- package/dist/format/lib/content/box-phone-place.d.ts +4 -4
- package/dist/format/lib/content/box-phone-place.js +1 -1
- package/dist/format/lib/content/box-shape.d.ts +1 -1
- package/dist/format/lib/content/box-shape.js +1 -1
- package/dist/format/lib/content/box-side-space.d.ts +2 -1
- package/dist/format/lib/content/box-side-space.js +1 -1
- package/dist/format/lib/content/button-icon.d.ts +3 -1
- package/dist/format/lib/content/button-icon.js +1 -1
- package/dist/format/lib/content/card-template.d.ts +9 -1
- package/dist/format/lib/content/card-template.js +1 -1
- package/dist/format/lib/content/cell-picture-sizes.js +1 -1
- package/dist/format/lib/content/footprint.d.ts +2 -0
- package/dist/format/lib/content/footprint.js +1 -1
- package/dist/format/lib/content/gallery-card-layout.d.ts +6 -1
- package/dist/format/lib/content/gallery-card-layout.js +1 -1
- package/dist/format/lib/content/hover-media.d.ts +30 -0
- package/dist/format/lib/content/hover-media.js +1 -0
- package/dist/format/lib/content/image-aspect.d.ts +3 -3
- package/dist/format/lib/content/image-aspect.js +1 -1
- package/dist/format/lib/content/ink.d.ts +3 -0
- package/dist/format/lib/content/ink.js +1 -1
- package/dist/format/lib/content/list-position.d.ts +3 -0
- package/dist/format/lib/content/list-position.js +1 -0
- package/dist/format/lib/content/list-query.d.ts +2 -0
- package/dist/format/lib/content/list-query.js +1 -1
- package/dist/format/lib/content/mirror-cards.d.ts +3 -0
- package/dist/format/lib/content/mirror-cards.js +1 -1
- package/dist/format/lib/content/part-display.d.ts +2 -1
- package/dist/format/lib/content/part-display.js +1 -1
- package/dist/format/lib/content/site-gutter.d.ts +2 -0
- package/dist/format/lib/content/site-gutter.js +1 -1
- package/dist/format/lib/content/view-hide-class.d.ts +5 -2
- package/dist/format/lib/content/view-hide-class.js +1 -1
- package/dist/format/lib/content/view-lines.d.ts +2 -1
- package/dist/format/lib/content/view-lines.js +1 -1
- package/dist/format/lib/document/blocks/general/Footprint/card-seed.d.ts +3 -0
- package/dist/format/lib/document/blocks/general/Footprint/card-seed.js +1 -1
- package/dist/format/lib/document/blocks/general/text-part-shapes.json +7 -0
- package/dist/format/lib/document/card-content-switch.js +1 -1
- package/dist/format/lib/document/panel-only.d.ts +2 -0
- package/dist/format/lib/document/panel-only.js +1 -0
- package/dist/format/lib/document/row-hand.js +1 -1
- package/dist/format/lib/document/section-catalog.d.ts +2 -1
- package/dist/format/lib/document/section-catalog.js +10 -10
- package/dist/format/lib/document/section-descriptions.js +1 -1
- package/dist/format/lib/document/seed-shape.d.ts +2 -0
- package/dist/format/lib/document/seed-shape.js +1 -0
- package/dist/format/lib/editor-words-catalogue.d.ts +21 -0
- package/dist/format/lib/editor-words-catalogue.js +4 -4
- package/dist/format/lib/editor-words-kept.js +1 -1
- package/dist/format/lib/fit-words.d.ts +1 -0
- package/dist/format/lib/fit-words.js +9 -8
- package/dist/format/lib/sized-image.js +1 -1
- package/dist/format/lib/source-rules/one-phone-edge.d.ts +13 -0
- package/dist/format/lib/source-rules/one-phone-edge.js +8 -0
- package/dist/format/lib/source-rules/published-mounts.d.ts +22 -0
- package/dist/format/lib/source-rules/published-mounts.js +58 -0
- package/dist/format/lib/source-rules/support/panel-select-cascade.js +1 -2
- package/dist/format/lib/source-rules/support/ts-program.d.ts +4 -0
- package/dist/format/lib/source-rules/support/ts-program.js +2 -0
- package/dist/format/lib/theme.d.ts +1 -0
- package/dist/format/lib/theme.js +3 -3
- package/dist/render/components/ButtonBlock.js +1 -1
- package/dist/render/components/CardRowContext.d.ts +5 -2
- package/dist/render/components/CardRowContext.js +1 -1
- package/dist/render/components/DealerFinder.js +1 -1
- package/dist/render/components/Eyebrow.js +1 -1
- package/dist/render/components/Flex.d.ts +2 -1
- package/dist/render/components/Flex.js +1 -1
- package/dist/render/components/Footprint.js +1 -1
- package/dist/render/components/HeroArrows.d.ts +6 -3
- package/dist/render/components/HeroArrows.js +1 -1
- package/dist/render/components/HeroPictures.js +1 -1
- package/dist/render/components/HoverMediaLayer.d.ts +9 -0
- package/dist/render/components/HoverMediaLayer.js +1 -0
- package/dist/render/components/InBoxContext.d.ts +3 -0
- package/dist/render/components/InBoxContext.js +1 -1
- package/dist/render/components/ListSearchBox.d.ts +2 -1
- package/dist/render/components/ListSearchBox.js +1 -1
- package/dist/render/components/LogoBlock.js +1 -1
- package/dist/render/components/Logos.js +1 -1
- package/dist/render/components/PublishedPartStylesContext.d.ts +2 -1
- package/dist/render/components/PublishedPartStylesContext.js +1 -1
- package/dist/render/components/SectionAnimation.d.ts +4 -2
- package/dist/render/components/SectionAnimation.js +1 -1
- package/dist/render/components/SideListLayout.d.ts +14 -0
- package/dist/render/components/SideListLayout.js +1 -0
- package/dist/render/components/Split.js +1 -1
- package/dist/render/components/Text.js +1 -1
- package/dist/render/components/TitleWithButtons.js +1 -1
- package/dist/render/components/ViewHideRoot.d.ts +7 -1
- package/dist/render/components/ViewHideRoot.js +1 -1
- package/dist/render/lib/content/block-size.d.ts +4 -1
- package/dist/render/lib/content/block-size.js +1 -1
- package/dist/render/lib/content/box-cell-bound.js +1 -1
- package/dist/render/lib/content/box-shared-columns.js +1 -1
- package/dist/render/lib/content/box-stack-line.d.ts +1 -0
- package/dist/render/lib/content/box-stack-line.js +1 -1
- package/dist/render/lib/content/view-values.d.ts +2 -0
- package/dist/render/lib/content/view-values.js +1 -1
- package/dist/render/lib/dealer-source.d.ts +3 -2
- package/dist/render/lib/dealer-source.js +1 -1
- package/dist/render/lib/document/blocks/general/CardList/render.js +1 -1
- package/dist/render/lib/document/blocks/general/Cards/render.js +1 -1
- package/dist/render/lib/document/blocks/general/Flex/render.js +1 -1
- package/dist/render/lib/document/blocks/general/ImageBlock/render.js +1 -1
- package/dist/render/lib/document/blocks/general/ListSearch/render.js +1 -1
- package/dist/render/lib/document/blocks/general/section-to-box-row-parts.d.ts +1 -0
- package/dist/render/lib/document/blocks/general/section-to-box-row-parts.js +1 -1
- package/dist/render/lib/document/blocks/general/section-to-box-rows-cards.js +1 -1
- package/dist/render/lib/document/blocks/general/section-to-box-rows-forms.js +1 -1
- package/dist/render/lib/document/blocks/general/section-to-box-rows-head.js +1 -1
- package/dist/render/lib/document/blocks/general/section-to-box-rows-proof.js +1 -1
- package/dist/render/lib/document/page-render.js +1 -1
- package/dist/render/lib/document/part-styles.d.ts +3 -1
- package/dist/render/lib/document/part-styles.js +2 -2
- package/dist/render/lib/document/passes/block-size.js +1 -1
- package/dist/render/lib/document/passes/clickable-parts.js +1 -1
- package/dist/render/lib/document/passes/hidden-nodes.js +1 -1
- package/dist/render/lib/document/passes/section-animation.js +1 -1
- package/dist/render/lib/document/passes/section-width.js +1 -1
- package/dist/render/lib/document/published-passes.d.ts +13 -0
- package/dist/render/lib/document/published-passes.js +1 -0
- package/dist/render/lib/document/text-parts.d.ts +1 -0
- package/dist/render/lib/document/text-parts.js +1 -1
- package/dist/render/lib/sections/section-to-box.d.ts +4 -0
- package/dist/render/lib/sections/section-to-box.js +1 -1
- package/package.json +1 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import{VIEW_DESKTOP_MIN as r,VIEW_TABLET_MIN as n}from"efficient-easel/screen/lib/content/view-tiers";const
|
|
1
|
+
import{VIEW_DESKTOP_MIN as r,VIEW_TABLET_MIN as n}from"efficient-easel/screen/lib/content/view-tiers";import{PHONE_EDGE as a}from"./content/view-lines.js";const s={fit:"data-fit",fitTablet:"data-fit-tablet",fitPhone:"data-fit-phone",min:"data-fit-min",minTablet:"data-fit-min-tablet",minPhone:"data-fit-min-phone",edge:"data-fit-edge"},e=s,o=i=>i.flatMap(t=>[`[${t}] p`,`[${t}] li`]).join(","),l=String.raw`(function (doc) {
|
|
2
2
|
if (doc.__sfFitWords) return;
|
|
3
3
|
var win = doc.defaultView;
|
|
4
4
|
var SELECTOR = "h1,h2,h3,h4,h5,h6,[class*='font-heading'],[class*='font-display']";
|
|
5
5
|
// Body text a block asked to shrink (its Text group's Shrink), beside
|
|
6
6
|
// the headings: what this script may fit at all. modeOf() decides each one.
|
|
7
|
-
var SHRINK_BODY = ${JSON.stringify(
|
|
7
|
+
var SHRINK_BODY = ${JSON.stringify(o([e.fit,e.fitTablet,e.fitPhone]))};
|
|
8
8
|
var CANDIDATES = SELECTOR + "," + SHRINK_BODY;
|
|
9
|
-
var MIN_SCALE = 0.3, MIN_PX = 16, SLACK = 1, PHONE_BELOW =
|
|
9
|
+
var MIN_SCALE = 0.3, MIN_PX = 16, SLACK = 1, PHONE_BELOW = ${a};
|
|
10
10
|
var TABLET_MIN = ${n}, DESKTOP_MIN = ${r};
|
|
11
11
|
|
|
12
12
|
// A block's own answer (lib/content/block-size, the wrapper's attributes):
|
|
13
13
|
// the fit "wrap" | "shrink" | "line" and the floor, each with a tablet and a
|
|
14
|
-
// phone twin. From 1100 the desktop's;
|
|
15
|
-
//
|
|
14
|
+
// phone twin. From 1100 the desktop's; from the tablet line (800 for a holder
|
|
15
|
+
// in a Box, marked edge; 720 outside one) the tablet's where it has one;
|
|
16
|
+
// under it the phone's, else the tablet's, else the desktop's. With no
|
|
16
17
|
// tablet answer the phone's is read under 800, as before (the edge moves with
|
|
17
18
|
// F1). With none, a heading shrinks and body text wraps, as always.
|
|
18
|
-
// A holder with any tablet attribute takes the three views (
|
|
19
|
+
// A holder with any tablet attribute takes the three views (its line and 1100)
|
|
19
20
|
// for its fit AND its floor together; one with none keeps the 800 edge.
|
|
20
21
|
var TABLET_ATTRS = [${JSON.stringify(e.fitTablet)}, ${JSON.stringify(e.minTablet)}];
|
|
21
22
|
function own(el, attr, tabletAttr, phoneAttr) {
|
|
@@ -24,7 +25,7 @@ import{VIEW_DESKTOP_MIN as r,VIEW_TABLET_MIN as n}from"efficient-easel/screen/li
|
|
|
24
25
|
var w = win.innerWidth, d = holder.getAttribute(attr);
|
|
25
26
|
if (w >= DESKTOP_MIN) return d;
|
|
26
27
|
var t = holder.getAttribute(tabletAttr), p = holder.getAttribute(phoneAttr);
|
|
27
|
-
if (w < TABLET_MIN) return p || t || d;
|
|
28
|
+
if (w < (holder.hasAttribute(${JSON.stringify(e.edge)}) ? PHONE_BELOW : TABLET_MIN)) return p || t || d;
|
|
28
29
|
if (holder.hasAttribute(TABLET_ATTRS[0]) || holder.hasAttribute(TABLET_ATTRS[1])) return t || d;
|
|
29
30
|
return (w < PHONE_BELOW && p) || d;
|
|
30
31
|
}
|
|
@@ -293,4 +294,4 @@ import{VIEW_DESKTOP_MIN as r,VIEW_TABLET_MIN as n}from"efficient-easel/screen/li
|
|
|
293
294
|
// (scripts/test-block-size.tsx §5): which mode an element is in, and its floor.
|
|
294
295
|
doc.__sfFitWords.modeOf = modeOf;
|
|
295
296
|
doc.__sfFitWords.floorOf = floorOf;
|
|
296
|
-
})(document);`,
|
|
297
|
+
})(document);`,d="storefront-fit-words";function c(i){const t=i.createElement("script");return t.id=d,t.textContent=l,(i.head??i.documentElement).appendChild(t),()=>{i.__sfFitWords?.(),t.remove()}}export{l as FIT_WORDS_BOOT,d as FIT_WORDS_SCRIPT_ID,s as TEXT_FIT_ATTR,c as runFitWordsIn};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{imageCopyUrl as s,imageSrcSet as
|
|
1
|
+
import{imageCopyUrl as s,imageSrcSet as S}from"efficient-shell/image-copies";let e;function d(t){e=t}function o(){return e===void 0?{}:{host:e}}const x="(max-width: 800px) 100vw, min(100vw, 1600px)",a="(max-width: 960px) 100vw, 50vw";function m(t,{fallbackWidth:n=1280,maxWidth:r}={}){const i=S(t,{...o(),...r===void 0?{}:{maxWidth:r}});return i?{src:s(t,n,o()),srcSet:i}:{src:t}}const p=/[\s"'()\\;]/,c={"\\":"\\\\",'"':'\\"',"\n":"\\a ","\r":"\\d ","\f":"\\c "};function u(t){return t.replace(/[\\"\n\r\f]/g,n=>c[n]??n)}function E(t){const n=s(t,1920,o());return n===t?p.test(t)?`url("${u(t)}")`:`url(${t})`:`url("${u(n)}")`}export{x as CONTENT_SIZES,a as HALF_SIZES,d as __setImageCopiesHostForTests,E as sizedBackground,m as sizedImage};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type RuleReport, type SourceFile } from "./rule.js";
|
|
2
|
+
export type OnePhoneEdgeKept = {
|
|
3
|
+
readonly reason: string;
|
|
4
|
+
readonly lines: number;
|
|
5
|
+
};
|
|
6
|
+
export type OnePhoneEdgeOptions = {
|
|
7
|
+
readonly minFiles: number;
|
|
8
|
+
readonly keep: Readonly<Record<string, OnePhoneEdgeKept>>;
|
|
9
|
+
};
|
|
10
|
+
export declare function onePhoneEdge(files: readonly SourceFile[], options: OnePhoneEdgeOptions): RuleReport & {
|
|
11
|
+
readonly ok: boolean;
|
|
12
|
+
readonly lines: readonly string[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{failedChecks as x,reportLines as c,ruleChecks as m}from"./rule.js";const E=new RegExp([String.raw`(?<![\w@-])(?:max-)?view-tablet:`,String.raw`\bVIEW_TABLET_MIN\b`,String.raw`\[\s*["'\x60]view-tablet["'\x60]\s*\]`,String.raw`(?<![\w$])(?:TABLET|PHONE)_MEDIA\b`,String.raw`\bBOX_PHONE_PAD_LINE\b`,String.raw`719\.98px`,String.raw`max-width: ?719px`,String.raw`(?:max|min)-\[(?:719(?:\.98)?|720)px\]:`,String.raw`min-width: ?720px`,String.raw`width\s*<\s*720px`,String.raw`720px\s*<=?\s*width`,String.raw`width\s*>=\s*720px`].join("|"),"g"),f="lib/content/view-lines.ts",g=n=>n.split(`
|
|
2
|
+
`).filter(i=>!/^\s*(\*(\s|\/|$)|\/\/|\/\*)/.test(i)).join(`
|
|
3
|
+
`),o=n=>g(n).match(E)?.length??0;function u(n,i){const{check:a,report:p}=m("one phone edge");{const e=['"max-view-tablet:px-4 view-tablet:max-view-desktop:grow max-view-wide:px-5 @max-view-tablet:hidden"','import { VIEW_TABLET_MIN } from "efficient-easel/draw"; const NOT_VIEW_TABLET_MINIMUM = 1;',"`@media (max-width: 719.98px)` `(min-width: 720px)` `(min-width: 800px)`",'import { PHONE_MEDIA, TABLET_MEDIA, EDGE_PHONE_MEDIA, EDGE_TABLET_MEDIA } from "x"; BOX_PHONE_PAD_LINE; VIEW_LINE_PX["view-tablet"];',"@media (width < 720px) {} @media (720px <= width < 1100px) {} @media (width < 800px) {}"," *:has(> [data-x]) { max-view-tablet:hidden }","`max-[720px]:px-2 min-[720px]:grow @media (max-width: 719px)` `max-[800px]:px-2`"," * a comment that says max-view-tablet: is not code"].join(`
|
|
4
|
+
`);a("the reader finds the 15 second-edge values and nothing else",o(e)===15,`found ${o(e)}`)}const r=n.filter(e=>/\.(tsx?|css)$/.test(e.path));a(`read the source (${r.length} TS/TSX/CSS files, at least ${i.minFiles})`,r.length>=i.minFiles,"fewer means the walk broke, and the check below is vacuous");const d=[],w=[];for(const e of r){if(e.path.endsWith(f))continue;const t=o(e.text),s=i.keep[e.path];s===void 0?t>0&&d.push(`${e.path}: ${t}`):t>s.lines&&w.push(`${e.path}: ${t}, kept ${s.lines}`)}a("no second phone edge: read PHONE_EDGE, or name it as view-wide / max-view-wide",d.length===0,`a 720 line outside the kept files:
|
|
5
|
+
${d.join(`
|
|
6
|
+
`)}`),a("no kept file gains a 720 line (its count is a ceiling)",w.length===0,`a kept file grew:
|
|
7
|
+
${w.join(`
|
|
8
|
+
`)}`);const l=Object.keys(i.keep).filter(e=>{const t=r.find(s=>s.path===e);return t===void 0||o(t.text)===0});a("every kept file is in the tree and still keeps a 720 line (else drop it from the list)",l.length===0,l.join(", "));const h=p();return{...h,ok:x(h).length===0,lines:c(h)}}export{u as onePhoneEdge};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type * as TS from "typescript";
|
|
2
|
+
import { type RuleReport, type SourceFile } from "./rule.js";
|
|
3
|
+
export type PublishedMount = {
|
|
4
|
+
readonly call: string;
|
|
5
|
+
readonly callFrom?: string;
|
|
6
|
+
readonly variable: string;
|
|
7
|
+
readonly args?: string;
|
|
8
|
+
readonly inputs?: readonly string[];
|
|
9
|
+
readonly readers?: readonly (string | PublishedReader)[];
|
|
10
|
+
readonly renderFrom?: string;
|
|
11
|
+
};
|
|
12
|
+
export type PublishedReader = {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly from: string;
|
|
15
|
+
};
|
|
16
|
+
export type PublishedMountsOptions = {
|
|
17
|
+
readonly mounts: Readonly<Record<string, PublishedMount>>;
|
|
18
|
+
readonly minFiles: number;
|
|
19
|
+
readonly ts?: typeof TS;
|
|
20
|
+
};
|
|
21
|
+
export declare function mountProblems(text: string, mount: PublishedMount, ts?: typeof TS): string[];
|
|
22
|
+
export declare function publishedMounts(files: readonly SourceFile[], options: PublishedMountsOptions): RuleReport;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import{ruleChecks as M}from"./rule.js";import{programOf as _}from"./support/ts-program.js";function Z(n){const a=[];let e=0,u=0;for(let o=0;o<n.length;o++){const p=n[o];"([{".includes(p)?e++:")]}".includes(p)?e--:p===","&&e===0&&(a.push(n.slice(u,o)),u=o+1)}return a.push(n.slice(u)),a.map(o=>o.trim()).filter(o=>o!=="")}const Y=/^[A-Za-z_$][\w$]*$/,ee=/^(?:@\/|\.\.?\/)/;function te(n,a){const e=_(n,[{path:"mount.tsx",text:a}]);return{sf:e.getSourceFile("/mount.tsx"),checker:e.getTypeChecker()}}function ne(n,a){const e=[],u=o=>{e.push(o),n.forEachChild(o,u)};return u(a),e}function v(n,a){const e=a.parent;return(n.isVariableDeclaration(e)||n.isParameter(e)||n.isBindingElement(e)||n.isFunctionDeclaration(e)||n.isFunctionExpression(e)||n.isClassDeclaration(e)||n.isClassExpression(e)||n.isImportSpecifier(e)||n.isImportClause(e)||n.isNamespaceImport(e)||n.isImportEqualsDeclaration(e))&&e.name===a}function F(n,a){return n.isParenthesizedExpression(a)||n.isAsExpression(a)||n.isNonNullExpression(a)||n.isTypeAssertionExpression(a)||n.isSatisfiesExpression(a)}function ae(n,a){for(;a.parent&&F(n,a.parent);)a=a.parent;return a}function V(n,a){let e=a,u=!1;for(;;){e=ae(n,e);const o=e.parent;if(o&&(n.isPropertyAccessExpression(o)||n.isElementAccessExpression(o))&&o.expression===e){e=o,u=!0;continue}return{top:e,path:u}}}const W=(n,a)=>n.isBinaryExpression(a)&&(a.operatorToken.kind===n.SyntaxKind.QuestionQuestionToken||a.operatorToken.kind===n.SyntaxKind.BarBarToken);function re(n,a){const e=a.parent;if(!e)return"used";if(n.isBinaryExpression(e)&&e.left===a&&e.operatorToken.kind>=n.SyntaxKind.FirstAssignment&&e.operatorToken.kind<=n.SyntaxKind.LastAssignment)return"assigned";if((n.isPrefixUnaryExpression(e)||n.isPostfixUnaryExpression(e))&&(e.operator===n.SyntaxKind.PlusPlusToken||e.operator===n.SyntaxKind.MinusMinusToken))return"changed by ++ or --";if(n.isDeleteExpression(e))return"deleted";if(n.isCallExpression(e)&&e.expression===a)return"called, or a method called on it";if(n.isCallExpression(e)||n.isNewExpression(e))return`handed to ${e.expression.getText()}(…)`;if(n.isJsxExpression(e)&&n.isJsxAttribute(e.parent))return`handed to the JSX attribute ${e.parent.name.getText()}`;if(n.isVariableDeclaration(e)||n.isBindingElement(e))return"aliased by a local";if(n.isSpreadElement(e)||n.isSpreadAssignment(e)||n.isJsxSpreadAttribute(e))return"spread";if(n.isForOfStatement(e)||n.isForInStatement(e))return"looped over";for(let u=a;u.parent;u=u.parent){const o=u.parent;if(n.isBinaryExpression(o)){if(o.left===u&&o.operatorToken.kind===n.SyntaxKind.EqualsToken)return"a destructuring target";break}if(!(n.isObjectLiteralExpression(o)||n.isArrayLiteralExpression(o)||n.isPropertyAssignment(o)||n.isShorthandPropertyAssignment(o)||n.isSpreadAssignment(o)||n.isSpreadElement(o)||F(n,o)))break}return`used in a ${n.SyntaxKind[e.kind]} (syntax kind)`}function G(n,a,e){if(!e)return["the rule was not handed the compiler (`options.ts`)"];const{sf:u,checker:o}=te(e,n),p=ne(e,u),x=p.filter(e.isIdentifier),$=t=>u.getLineAndCharacterOfPosition(t.getStart(u)).line+1,m=t=>e.isShorthandPropertyAssignment(t.parent)&&t.parent.name===t?o.getShorthandAssignmentValueSymbol(t.parent):o.getSymbolAtLocation(t),d=t=>x.filter(r=>r.text===t&&v(e,r)),c=t=>{for(let r=t;r.parent;r=r.parent){const i=r.parent;if(e.isExpressionWithTypeArguments(i)&&i.expression===r)return!1;if(e.isTypeNode(i))return!0}return!1},s=[],C=(t,r,i)=>{const l=p.filter(k=>e.isImportSpecifier(k)&&k.name.text===r),f=l[0],y=f?f.parent.parent.parent.moduleSpecifier.text:"";return l.length!==1?`${t} is not imported once in the mount`:f.propertyName&&f.propertyName.text!==r?`${t} is ${f.propertyName.text} renamed: it is imported by its own name`:f.isTypeOnly||f.parent.parent.isTypeOnly?`${t} is a type-only import`:(i===void 0?!ee.test(y):y!==i)?`${t} comes from "${y}", not ${i===void 0?"a module inside this package":`"${i}"`}`:d(r).length!==1?`${t} is declared again in the mount: it is the imported function`:o.getSymbolAtLocation(f.name)??`${t} has no binding in the mount`},A=d(a.variable);if(A.length!==1)return[`\`${a.variable}\` is declared ${A.length} times, not once`];const h=A[0].parent;if(!e.isVariableDeclaration(h))return[`\`${a.variable}\` is not a variable declaration`];const g=m(A[0]),b=h.initializer;let S=null;const w=C(`the call ${a.call}`,a.call,a.callFrom);if(typeof w=="string"&&s.push(w),!b||!e.isCallExpression(b)||!e.isIdentifier(b.expression)||b.expression.text!==a.call||typeof w!="string"&&m(b.expression)!==w)s.push(`\`${a.variable}\` is not set straight from ${a.call}(…): a pass wraps it, or something follows the call`);else{S=b;const t=n.slice(b.arguments.pos,b.arguments.end).trim();a.args!==void 0&&t!==a.args&&s.push(`${a.call} is handed \`${t}\`, not \`${a.args}\``)}const R=e.findAncestor(h,t=>e.isFunctionDeclaration(t)||e.isFunctionExpression(t)||e.isArrowFunction(t));if(!R||!R.body||h.parent.parent.parent!==R.body)return[...s,`\`${a.variable}\` is not declared at the top level of a component's body`];const T=R.parameters[0]?.name,D=new Map;if(T&&e.isObjectBindingPattern(T))for(const t of T.elements)e.isIdentifier(t.name)&&!t.dotDotDotToken&&D.set(t.name.text,t.name);else s.push("the component does not destructure its props");const B=a.inputs??Z(a.args??"").filter(t=>Y.test(t));B.length===0&&s.push(`${a.call}(…) reads no input the rule can check: name the props it reads in \`inputs\`, or bare names in \`args\``);const N=new Set;for(const t of B){const r=D.get(t);if(!r){s.push(`\`${t}\` is not a prop of the component: the call is handed something made in the mount`);continue}d(t).length!==1&&s.push(`\`${t}\` is declared ${d(t).length} times in the file: a second binding would pass for the input`);const i=m(r);i&&N.add(i)}for(const t of x)t.text==="arguments"&&!v(e,t)&&e.findAncestor(t,r=>r===R)&&s.push(`\`arguments\` is used in the component (line ${$(t)}): it is the props by another name`);for(const t of x)(t.text==="eval"||t.text==="Function")&&!v(e,t)&&!c(t)&&!(e.isPropertyAccessExpression(t.parent)&&t.parent.name===t)&&s.push(`\`${t.text}\` is used in the mount file (line ${$(t)}): code run from a string cannot be read`);const L=new Set;for(const t of a.readers??[]){const r=typeof t=="string"?t:t.name,i=C(`the reader ${r}`,r,typeof t=="string"?void 0:t.from);typeof i=="string"?s.push(i):L.add(i)}const X=t=>{if(!e.isCallExpression(t)||!e.isIdentifier(t.expression))return!1;const r=m(t.expression);return r!==void 0&&L.has(r)};let z=null;const P=p.filter(t=>e.isImportSpecifier(t)&&t.name.text==="Render"),O=a.renderFrom??"efficient-easel/render",q=P.length===1?P[0].parent.parent.parent.moduleSpecifier.text:"",I=p.filter(t=>e.isImportDeclaration(t)&&e.isStringLiteral(t.moduleSpecifier)&&t.moduleSpecifier.text===O&&!t.importClause?.isTypeOnly).flatMap(t=>{const r=t.importClause;if(!r)return[];const i=r.namedBindings;return[...r.name?[r.name.text]:[],...i&&e.isNamespaceImport(i)?[`* as ${i.name.text}`]:[],...i&&e.isNamedImports(i)?i.elements.filter(l=>!l.isTypeOnly).map(l=>l.propertyName?`${l.propertyName.text} as ${l.name.text}`:l.name.text):[]]});(I.length!==1||I[0]!=="Render")&&s.push(`"${O}" gives this file ${I.length} binding(s) (${I.join(", ")||"none"}), not the one \`Render\``);const J=P.length===1&&!P[0].propertyName&&q===O?o.getSymbolAtLocation(P[0].name):void 0;if(!J||d("Render").length!==1)s.push(`\`Render\` is not imported once by its own name from "${O}"`);else{const t=x.filter(i=>!v(e,i)&&m(i)===J),r=t.filter(i=>(e.isJsxOpeningElement(i.parent)||e.isJsxSelfClosingElement(i.parent))&&i.parent.tagName===i);if(r.length!==1||t.length!==1)s.push(`\`Render\` is used ${t.length} times, ${r.length} as a tag: one <Render> and no alias`);else{const l=r[0].parent.attributes.properties;l.some(j=>e.isJsxSpreadAttribute(j))&&s.push("the Render tag has a spread attribute, which can hand it another document");const f=l.filter(j=>e.isJsxAttribute(j)&&j.name.getText()==="data"),y=f.length===1?f[0].initializer:void 0,k=y&&e.isJsxExpression(y)?y.expression:void 0;!k||!e.isIdentifier(k)||m(k)!==g?s.push(`the Render tag draws \`${k?k.getText():f.length===1?f[0].getText():"nothing"}\`, not \`${a.variable}\``):z=k}}const E=new Map;for(const t of N)E.set(t,t.name);g&&E.set(g,a.variable);const H=t=>{for(let r=t;r.parent;r=r.parent){const i=r.parent;if(S&&i===S)return S.arguments.some(f=>f===r);if(!(F(e,i)||e.isObjectLiteralExpression(i)||e.isPropertyAssignment(i)&&i.initializer===r||e.isShorthandPropertyAssignment(i)||e.isSpreadAssignment(i)||e.isArrayLiteralExpression(i)||e.isSpreadElement(i)||e.isConditionalExpression(i)&&i.condition!==r||W(e,i)))return!1}return!1},Q=t=>{let r=t,i=!1;for(;;){const l=r.parent;if(!l)return;if(F(e,l))r=l;else if(e.isConditionalExpression(l)&&l.condition!==r)r=l,i=!0;else if(e.isSpreadAssignment(l)&&e.isObjectLiteralExpression(l.parent))r=l.parent,i=!0;else return e.isVariableDeclaration(l)&&l.initializer===r&&e.isIdentifier(l.name)&&i?m(l.name):void 0}},K=(t,r)=>{if(c(t))return!0;const{top:i,path:l}=V(e,t);if(t===z)return!0;let f=i;for(;f.parent&&(F(e,f.parent)||W(e,f.parent));)f=f.parent;if(f.parent&&X(f.parent)&&f.parent.arguments.some(k=>k===f)||N.has(r)&&H(i))return!0;const y=l?void 0:Q(i);return y?(E.has(y)||E.set(y,y.name),!0):!1};for(let t=-1;t!==E.size;){t=E.size;for(const r of x){if(v(e,r))continue;const i=m(r);i&&E.has(i)&&K(r,i)}}for(const t of x){if(v(e,t))continue;const r=m(t);if(!r||!E.has(r)||K(t,r))continue;const{top:i}=V(e,t),l=E.get(r),f=N.has(r)||r===g?"":" (a local that holds an input or the variable)";s.push(`\`${l}\`${f} is ${re(e,i)} at line ${$(t)}`)}return s}const U=new WeakMap;function ie(n){const a=U.get(n);if(a)return a;const{check:e,report:u}=M("published mounts fixtures"),o=(h,g)=>G(h,g,n),p={call:"publishedPageData",variable:"page",args:"data, metadata",readers:["first"]},x="return <Render config={c} data={page} />;",$=`const page = ${p.call}(data, metadata);`,m=h=>`import { Render } from "efficient-easel/render";
|
|
2
|
+
import { first } from "./first";
|
|
3
|
+
import { ${p.call} } from "./published-passes";
|
|
4
|
+
export default function P({ data, metadata = {} }: Props) {
|
|
5
|
+
${h}
|
|
6
|
+
}`,d=m(`${$}
|
|
7
|
+
${x}`),c=h=>m(`${h}
|
|
8
|
+
${$}
|
|
9
|
+
${x}`),s=h=>m(`${$}
|
|
10
|
+
${h}
|
|
11
|
+
${x}`);e("the one call, drawn, passes",o(d,p).length===0,o(d,p).join("; "));{const h={...p,callFrom:"@/lib/document/published-passes"},g=d.replace('from "./published-passes"',`from "${h.callFrom}"`);e("…the call imported from the module the mount names passes",o(g,h).length===0,o(g,h).join("; ")),e("…and the call imported from another module inside this package fails it",o(d,h).length>0)}e("…a comment naming a wrapper does not fail it",o(`// const page = x(${p.call}(data, metadata));
|
|
12
|
+
${d}`,p).length===0),e("…a path handed to a listed reader does not fail it",o(s("const lead = first(page.content);"),p).length===0),e("…an input spread, and an input as a ternary's last branch, do not fail it",o(s("const facts = ok ? { ...metadata, k: 1 } : metadata;"),p).length===0,o(s("const facts = ok ? { ...metadata, k: 1 } : metadata;"),p).join("; "));{const h="efficient-web-builder/render/lib/document/published-passes",g={call:"publishedChromeData",callFrom:h,variable:"data",inputs:["group"]},b=`import { Render } from "efficient-easel/render";
|
|
13
|
+
import { ${g.call} } from "${h}";
|
|
14
|
+
export default function H({ group }: { group: G }) {
|
|
15
|
+
const data = ${g.call}({ content: [group] } as unknown as D);
|
|
16
|
+
return <Render config={c} data={data} />;
|
|
17
|
+
}`;e("…a chrome mount drawing `data={data}` passes",o(b,g).length===0,o(b,g).join("; ")),e("…and a write into its prop fails it",o(b.replace("const data",`group.props = {};
|
|
18
|
+
const data`),g).length>0);const S="<Render config={headerRenderConfig()} data={data} />",w=`import { Render } from "efficient-easel/render";
|
|
19
|
+
import { ${g.call} } from "${h}";
|
|
20
|
+
export default function PublishedHeader({ group }: { group: G }) {
|
|
21
|
+
const data = ${g.call}({ root: { props: {} }, content: [group], zones: {} } as unknown as D);
|
|
22
|
+
return (
|
|
23
|
+
<Bar sticky={sticky}>
|
|
24
|
+
${S}
|
|
25
|
+
</Bar>
|
|
26
|
+
);
|
|
27
|
+
}`;e("…a header mount drawing `data={data}` inside a wrapper passes",o(w,g).length===0,o(w,g).join("; "));const R=[["`data` assigned after the call",w.replace(" return (",` data = extra;
|
|
28
|
+
return (`)],["a property write on `data`",w.replace(" return (",` data.content = [];
|
|
29
|
+
return (`)],["a second Render with `data={data}` and a spread",w.replace(S,`${S}
|
|
30
|
+
<Render data={data} {...extra} />`)],["its call imported from another module",w.replace(`from "${h}"`,'from "./published-passes"')]];for(const[T,D]of R)e(`…${T} fails it`,o(D,g).length>0)}const C=[["a wrapping pass",m(`const page = extra(${p.call}(data, metadata));
|
|
31
|
+
${x}`)],["a pass after the call",m(`const page = ${p.call}(data, metadata).x;
|
|
32
|
+
${x}`)],["a reassignment",m(`let page = ${p.call}(data, metadata);
|
|
33
|
+
page = extra(page);
|
|
34
|
+
${x}`)],["a pass in the Render prop",m(`${$}
|
|
35
|
+
return <Render data={extra(page)} />;`)],["other arguments",m(`const page = ${p.call}(extra(data), metadata);
|
|
36
|
+
${x}`)],["no call at all",m(x)],["a pass on the input before the call",c("data = extra(data);")],["a compound assignment to the input",c("metadata ??= {};")],["an increment of the input",c("data++;")],["a destructured reassignment of the input",c("({ data } = extra({ data }));")],["an array reassignment of the input",c("[data, metadata] = extra([data, metadata]);")],["a local shadowing the input",c("{ const data = extra(0); }")],["a rebuilt argument named as the args",m(`const d = extra(data);
|
|
37
|
+
const page = ${p.call}(d, metadata);
|
|
38
|
+
${x}`),{...p,args:"d, metadata"}],["an argument that is no prop at all",`const page = ${p.call}(data, metadata);
|
|
39
|
+
${x}`],["a property write",s("page.content = extra(page.content);")],["a deep property write",s("page.root.props = {};")],["a compound property write",s("page.count += 1;")],["a bracket write",s('page["content"] = [];')],["an optional-path write",s("page.root!.props = {};")],["a delete",s("delete page.root;")],["Object.assign into it",s("Object.assign(page, extra(page));")],["the variable handed whole to a call",s("mutate(page);")],["the variable aliased",s("const shown = page;")],["a push on a path from it",s("page.content.push(extra(0));")],["a splice on an optional path from it",s("page.content?.splice(0, 1);")],["a sort on a bracket path from it",s('page["content"].sort();')],["an input handed to a pass through a cast",c("inPlacePass(data as Doc);")],["an input handed whole to a call",c("mutate(data);")],["a push through a cast of an input",c("(data as Doc).content.push(x);")],["a property write through a cast of an input",c("(metadata as any).x = 1;")],["a property write through an old-style cast",c("(<any>metadata).x = 1;")],["a property write through a non-null input",c("(metadata!).x = 1;")],["a push on a non-null input",c("data!.content.push(x);")],["an input aliased through a cast, then written",c(`const d = data as any;
|
|
40
|
+
d.content = [];`)],["an input aliased",c("const d = data;")],["an input path aliased",c("const p = metadata.facts;")],["a path value bound to a local",s("const one = page.content.length === 1;")],["a path alias pushed into",s(`const c = page.content;
|
|
41
|
+
c.push(x);`)],["a path alias written",s(`const r = page.root;
|
|
42
|
+
r.props = {};`)],["a path assigned to a let",s(`let c;
|
|
43
|
+
c = page.content;`)],["a path handed to a writing call",s("mutate(page.content);")],["a path's forEach writing",s("page.content.forEach((s) => { s.props = {}; });")],["a path's for-of writing",s("for (const s of page.content) s.props.x = 1;")],["a path in an array literal",s("const all = [page.content];")],["the variable spread into a copy",s(`const copy = { ...page };
|
|
44
|
+
copy.content.push(x);`)],["a path handed to a method that shares a reader's name",s("evil.first(page.content);")],["a local from an input's ternary branch, written through a cast",c(`const f = ok ? {} : metadata;
|
|
45
|
+
(f as any).x = 1;`)],["a local from an input's ternary branch, handed to a call",c(`const f = ok ? {} : metadata;
|
|
46
|
+
mutate(f);`)],["an input assigned an object with no space",c("data={content: [], root: {}};")],["an input assigned a cast object with no space",c("data={ content: [] } as unknown;")],["a second input assigned with no space",c("metadata={k: 1};")],["an input assigned a string with no space",c('data="";')],["the variable assigned with no space",s("page={content: [], root:{props:{}}} as any;")],["a spread copy of an input, written deep",c(`const copy: any = { ...metadata };
|
|
47
|
+
copy.theme.x = 1;`)],["a spread copy of an input, handed to a call",c(`const copy = { ...metadata };
|
|
48
|
+
mutate(copy);`)],["a reader declared in the mount",`${d}
|
|
49
|
+
function first(x) { x.content = []; }`],["a reader declared as a local arrow",`${d}
|
|
50
|
+
const first = (x) => { x.content = []; };`],["a reader that is not imported",d.replace(`import { first } from "./first";
|
|
51
|
+
`,"")],["eval",s('eval("page.content = []");')],["new Function",s('new Function("p", "p.content = []")(page);')],["Function called",s('Function("p", "p.content = []");')],["a call in a class extends clause",s("class W extends (mutate(page), Object) {}")],["a call in an instantiation expression",s("const g = (mutate(page), id)<number>;")],["a Render from another module",d.replace('from "efficient-easel/render"','from "./fake-render"')],["a second Render import, renamed",d.replace('import { Render } from "efficient-easel/render";',`import { Render } from "efficient-easel/render";
|
|
52
|
+
import { Render as Second } from "efficient-easel/render";`)],["a namespace import of Render's module",d.replace('import { Render } from "efficient-easel/render";',`import { Render } from "efficient-easel/render";
|
|
53
|
+
import * as E from "efficient-easel/render";`)],["a default import of Render's module",d.replace('import { Render } from "efficient-easel/render";',`import { Render } from "efficient-easel/render";
|
|
54
|
+
import E from "efficient-easel/render";`)],["the call declared in the mount, not imported",`${d.replace(`import { ${p.call} } from "./published-passes";
|
|
55
|
+
`,"")}
|
|
56
|
+
function ${p.call}(d, m) { const x: any = d; x.content = []; return x; }`],["the call declared again beside its import",`${d}
|
|
57
|
+
function ${p.call}(d, m) { return d; }`],["the call imported from outside this package",d.replace('from "./published-passes"','from "evil-passes"')],["another function imported as the call",d.replace(`import { ${p.call} }`,`import { evilPass as ${p.call} }`)],["the call as a type-only import",d.replace(`import { ${p.call} }`,`import type { ${p.call} }`)],["a call with no input it can check",m(`const page = ${p.call}({ ...data });
|
|
58
|
+
${x}`),{call:p.call,variable:"page",args:"{ ...data }"}],["a call with no args and no inputs named",d,{call:p.call,variable:"page"}]];for(const[h,g,b]of C)e(`…${h} fails it`,o(g,b??p).length>0);const A=u().checks;return U.set(n,A),A}function le(n,a){const{check:e,report:u}=M("published mounts"),o=a.ts;if(!e("the rule is handed the compiler (`options.ts`)",o!==void 0,"a host passes `ts` from its own typescript"))return u();for(const $ of ie(o))e($.name,$.ok,$.detail);const p=n.filter($=>/\.tsx?$/.test($.path));e(`the source scan reached the tree (${p.length} TS/TSX files, at least ${a.minFiles})`,p.length>=a.minFiles);const x=Object.keys(a.mounts);e("at least one published mount is named",x.length>0);for(const $ of x){const m=p.find(c=>c.path===$);if(!e(`${$} is here`,m!==void 0,"a stale row would shelter nothing"))continue;const d=G(m.text,a.mounts[$],o);e(`${$} draws exactly what ${a.mounts[$].call} returns — a pass belongs in lib/document/published-passes`,d.length===0,d.join("; "))}return u()}export{G as mountProblems,le as publishedMounts};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
function N(
|
|
2
|
-
`};return t.createProgram({rootNames:[...r.keys()],options:s,host:o})}function M(t,i,r){const n=E(t,i),s=n.getTypeChecker();let o;n.getSourceFile(`/${r.file}`)?.forEachChild(a=>{if(t.isFunctionDeclaration(a)&&a.name?.text==="select"&&(o=a),t.isVariableStatement(a))for(const p of a.declarationList.declarations)t.isIdentifier(p.name)&&p.name.text==="select"&&(o=p)});const e=new Set(r.modules??[]),c=a=>{if(!t.isImportSpecifier(a))return!1;const p=a.parent.parent.parent;return(a.propertyName??a.name).text==="select"&&t.isStringLiteral(p.moduleSpecifier)&&e.has(p.moduleSpecifier.text)},u=[];for(const a of n.getSourceFiles()){if(a.isDeclarationFile)continue;const p=a.fileName.slice(1),g=l=>a.getLineAndCharacterOfPosition(l.getStart()).line+1;let S=!1;const m=l=>{t.isStringLiteral(l)&&/(^|\s)sf-[a-z0-9-]/.test(l.text)&&(S=!0),t.isImportDeclaration(l)&&t.isStringLiteral(l.moduleSpecifier)&&/^(editor-shell|efficient-easel)(\/|$)/.test(l.moduleSpecifier.text)&&(S=!0),l.forEachChild(m)};m(a);const h=l=>{if(t.isPropertyAssignment(l)&&t.isIdentifier(l.name)&&l.name.text==="type"&&t.isStringLiteral(l.initializer)&&l.initializer.text==="select"&&u.push({file:p,line:g(l),kind:'field: type "select"',engineDrawn:!0,classes:[]}),t.isCallExpression(l)&&t.isIdentifier(l.expression)){const d=s.getSymbolAtLocation(l.expression),x=d&&d.flags&t.SymbolFlags.Alias?s.getAliasedSymbol(d):d;[...d?.declarations??[],...x?.declarations??[]].some(f=>o!==void 0&&f===o||c(f))&&u.push({file:p,line:g(l),kind:"field: select() helper",engineDrawn:!0,classes:[]})}if(t.isJsxOpeningLikeElement(l)&&l.tagName.getText()==="select"&&S&&p!==r.file){const d=l.attributes.properties.find(b=>t.isJsxAttribute(b)&&t.isIdentifier(b.name)&&b.name.text==="className"),x=d&&d.initializer&&t.isStringLiteral(d.initializer)?d.initializer.text:"";u.push({file:p,line:g(l),kind:"element: <select> in panel markup",engineDrawn:!1,classes:x.split(/\s+/).filter(Boolean)})}l.forEachChild(h)};h(a)}return{population:u,helperDeclared:o!==void 0}}const v=(t,i)=>t[0]-i[0]||t[1]-i[1]||t[2]-i[2],O=t=>`(${t[0]},${t[1]},${t[2]})`;function $(t){const i=[];let r=0,n=null,s="";const o=()=>{const e=s.indexOf(":");e>0&&i.push({prop:s.slice(0,e).trim(),value:s.slice(e+1).trim()}),s=""};for(const e of t){if(n){s+=e,e===n&&(n=null);continue}if(e==='"'||e==="'")n=e;else if(e==="(")r+=1;else if(e===")")r=Math.max(0,r-1);else if(e===";"&&r===0){o();continue}s+=e}return o(),i}function A(t){const i=[];let r=0,n="";for(const s of t){if(s==="("&&(r+=1),s===")"&&(r-=1),r===0&&/[\s>+~]/.test(s)){n.trim()&&i.push(n.trim()),n="";continue}n+=s}return n.trim()&&i.push(n.trim()),i}function C(t){let i=t.trim();const r=[],n=[];let s=null;const o=/^[a-zA-Z][a-zA-Z0-9-]*/.exec(i);for(o&&(s=o[0],i=i.slice(o[0].length));i.length;){let e;if(e=/^\.([A-Za-z0-9_-]+)/.exec(i))r.push(e[1]);else if(e=/^:(focus-visible|focus-within|hover|focus|active|checked|disabled)\b/.exec(i))n.push(e[1]);else if(e=/^:dir\([^)]*\)/.exec(i))n.push("dir");else if(e=/^:not\(\[([A-Za-z-]+)\]\)/.exec(i))r.push(`@not-${e[1]}`);else if(e=/^\[([A-Za-z-]+)(?:[~^$*|]?=[^\]]*)?\]/.exec(i))n.push(`[${e[1]}]`);else if(e=/^:has\(([^)]*)\)/.exec(i)){if(!/^\s*>?\s*[a-z]+\s*$/.test(e[1]))return null;r.push("@has-type")}else return null;i=i.slice(e[0].length)}return{type:s,classes:r,needsState:n}}const D=t=>t.reduce((i,r)=>[i[0],i[1]+r.classes.filter(n=>n!=="@has-type").length+r.needsState.length,i[2]+(r.type?1:0)+(r.classes.includes("@has-type")?1:0)],[0,0,0]);function F(t){if(t===null)return!0;let i=!0;for(const r of t.replace(/^@media\s*/i,"").split(/\s+and\s+/i)){const n=r.trim().replace(/^\(|\)$/g,"").trim(),s=/^([a-z-]+)\s*:\s*(.+)$/.exec(n);if(!s)return null;const o=s[1],e=s[2].trim();if(o==="hover"||o==="any-hover"){if(e==="hover")continue;return e==="none"?!1:null}if(o==="pointer"||o==="any-pointer"){if(e==="fine")continue;return e==="coarse"||e==="none"?!1:null}i=null}return i}const T=t=>t??"(no media query)";function Z(t,i,r,n,s="rest"){const o=[],e=[],c=[],u=s==="hover"?new Set(["hover"]):new Set;return t.forEach((a,p)=>{const g=s==="rest"?a.media===null:F(a.media);for(const S of a.selector.split(",")){const m=S.trim();if(!m||!/(^|[\s,>+~])select\b/.test(m)&&!i.own.some(f=>m.includes(`.${f}`)))continue;const h=A(m).map(C),l=h[h.length-1];if(h.some(f=>f===null)||!l){e.push(`${r}: ${m}`);continue}const d=h;if(l.type&&l.type!=="select")continue;const x=l.classes.filter(f=>!f.startsWith("@"));if(!(!x.every(f=>i.own.includes(f))||!l.type&&x.length===0||!l.needsState.every(f=>u.has(f))||!d.slice(0,-1).every(f=>(!f.type||f.type==="div")&&f.classes.filter(y=>!y.startsWith("@")).every(y=>i.ancestors.includes(y))&&f.needsState.every(y=>u.has(y))))&&g!==!1){if(g===null){c.push({sheet:r,selector:m,media:a.media??"",decls:a.decls});continue}o.push({spec:D(d),order:n+p,decls:a.decls,selector:m,sheet:r})}}}),{applied:o,unreadable:e,undecided:c}}const w={appearance:"auto","background-image":"none","background-size":"auto","background-repeat":"repeat","background-position":"0% 0%","background-color":"transparent","border-color":"currentcolor"};function z(t){const i=t.replace(/url\([\s\S]*?\)/g," "),r=/var\(--[A-Za-z0-9-]+(?:\s*,[^()]*)?\)|#[0-9a-fA-F]{3,8}\b|(?:rgba?|hsla?|color-mix|color)\([^()]*(?:\([^()]*\)[^()]*)*\)|\b(?:transparent|currentcolor|white|black)\b/i.exec(i);return r?r[0]:null}function W(t){const i=new Map;for(const r of $(t.replace(/[^{}]*\{|\}/g,";")))r.prop.startsWith("--")&&i.set(r.prop,r.value);return i}function L(t,i,r=0){if(r>8)return t;let n=!1;const s=t.replace(/var\(\s*(--[A-Za-z0-9-]+)\s*(?:,([^()]*(?:\([^()]*\)[^()]*)*))?\)/g,(o,e)=>{const c=i.get(e);return c===void 0?o:(n=!0,c)});return n?L(s,i,r+1):s}function j(t,i,r=new Map){let n=null;const s=(e,c)=>{(!n||v(e.spec,n.spec)>0||v(e.spec,n.spec)===0&&e.order>=n.order)&&(n={value:c.trim(),from:`${e.sheet} { ${e.selector} }`,spec:e.spec,order:e.order})};for(const e of t)for(const c of $(e.decls)){if(c.prop===i||i==="appearance"&&c.prop==="-webkit-appearance"){s(e,c.value);continue}if(c.prop==="border"&&i==="border-color"){s(e,z(c.value)??w[i]);continue}if(c.prop!=="background"||!i.startsWith("background-"))continue;const u=c.value;s(e,i==="background-image"?/url\([\s\S]*?\)|linear-gradient\([\s\S]*?\)|image-set\([\s\S]*?\)/.exec(u)?.[0]??"none":i==="background-repeat"?/\b(no-repeat|repeat-x|repeat-y|round|space|repeat)\b/.exec(u)?.[0]??"repeat":i==="background-color"?z(u)??w[i]:w[i])}const o=n??{value:w[i],from:"(nothing declares one)"};return{value:L(o.value,r),from:o.from}}const I=["sf-editor","sf-body","sf-panel","sf-insp-body","sf-styles","sf-field","es-field","sf-copybox"];function K(t,i){const r=t.filter(e=>!e.engineDrawn),n=e=>new RegExp(`\\.${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(i),s=e=>[...e.classes].filter(n).sort().join(" "),o=new Set([""]);for(const e of r)o.add(s(e));return[...o].sort().map(e=>({name:e?`house .${e.split(" ").join(".")}`:"house (bare)",own:e?e.split(" "):[],ancestors:[...I],rows:r.filter(c=>s(c)===e).length}))}function P(t,i,r){const n=new Map;for(const s of r)n.set(s,[]);for(const s of i){if(!k(s.path))continue;const o=t.createSourceFile(s.path,s.text,t.ScriptTarget.Latest,!0),e=c=>{if(t.isJsxAttribute(c)&&t.isIdentifier(c.name)&&c.name.text==="className"&&c.initializer&&t.isStringLiteral(c.initializer)){const u=c.initializer.text.split(/\s+/).filter(Boolean);for(const a of r)u.includes(a)&&n.get(a)?.push(s.path)}c.forEachChild(e)};e(o)}return n}export{I as ANCESTORS,w as INITIAL,Z as applicable,M as census,P as chainInMarkup,z as colorIn,C as compound,L as derefVars,K as deriveShapes,N as importsOf,F as mediaHolds,T as mediaLabel,W as readVars,j as resolve,v as specCmp,D as specOf,O as specStr,A as splitCombinators,$ as splitDecls};
|
|
1
|
+
import{isScript as A,programOf as L}from"./ts-program.js";function N(e,i){const r=e.createSourceFile(i.path,i.text,e.ScriptTarget.Latest,!0),n=[],s=o=>{(e.isImportDeclaration(o)||e.isExportDeclaration(o))&&o.moduleSpecifier&&e.isStringLiteral(o.moduleSpecifier)&&n.push(o.moduleSpecifier.text),e.isCallExpression(o)&&(o.expression.kind===e.SyntaxKind.ImportKeyword||e.isIdentifier(o.expression)&&o.expression.text==="require")&&o.arguments.length>0&&e.isStringLiteral(o.arguments[0])&&n.push(o.arguments[0].text),o.forEachChild(s)};return s(r),n}function Z(e,i,r){const n=L(e,i),s=n.getTypeChecker();let o;n.getSourceFile(`/${r.file}`)?.forEachChild(a=>{if(e.isFunctionDeclaration(a)&&a.name?.text==="select"&&(o=a),e.isVariableStatement(a))for(const p of a.declarationList.declarations)e.isIdentifier(p.name)&&p.name.text==="select"&&(o=p)});const t=new Set(r.modules??[]),l=a=>{if(!e.isImportSpecifier(a))return!1;const p=a.parent.parent.parent;return(a.propertyName??a.name).text==="select"&&e.isStringLiteral(p.moduleSpecifier)&&t.has(p.moduleSpecifier.text)},u=[];for(const a of n.getSourceFiles()){if(a.isDeclarationFile)continue;const p=a.fileName.slice(1),g=c=>a.getLineAndCharacterOfPosition(c.getStart()).line+1;let S=!1;const m=c=>{e.isStringLiteral(c)&&/(^|\s)sf-[a-z0-9-]/.test(c.text)&&(S=!0),e.isImportDeclaration(c)&&e.isStringLiteral(c.moduleSpecifier)&&/^(editor-shell|efficient-easel)(\/|$)/.test(c.moduleSpecifier.text)&&(S=!0),c.forEachChild(m)};m(a);const h=c=>{if(e.isPropertyAssignment(c)&&e.isIdentifier(c.name)&&c.name.text==="type"&&e.isStringLiteral(c.initializer)&&c.initializer.text==="select"&&u.push({file:p,line:g(c),kind:'field: type "select"',engineDrawn:!0,classes:[]}),e.isCallExpression(c)&&e.isIdentifier(c.expression)){const d=s.getSymbolAtLocation(c.expression),x=d&&d.flags&e.SymbolFlags.Alias?s.getAliasedSymbol(d):d;[...d?.declarations??[],...x?.declarations??[]].some(f=>o!==void 0&&f===o||l(f))&&u.push({file:p,line:g(c),kind:"field: select() helper",engineDrawn:!0,classes:[]})}if(e.isJsxOpeningLikeElement(c)&&c.tagName.getText()==="select"&&S&&p!==r.file){const d=c.attributes.properties.find(b=>e.isJsxAttribute(b)&&e.isIdentifier(b.name)&&b.name.text==="className"),x=d&&d.initializer&&e.isStringLiteral(d.initializer)?d.initializer.text:"";u.push({file:p,line:g(c),kind:"element: <select> in panel markup",engineDrawn:!1,classes:x.split(/\s+/).filter(Boolean)})}c.forEachChild(h)};h(a)}return{population:u,helperDeclared:o!==void 0}}const w=(e,i)=>e[0]-i[0]||e[1]-i[1]||e[2]-i[2],M=e=>`(${e[0]},${e[1]},${e[2]})`;function v(e){const i=[];let r=0,n=null,s="";const o=()=>{const t=s.indexOf(":");t>0&&i.push({prop:s.slice(0,t).trim(),value:s.slice(t+1).trim()}),s=""};for(const t of e){if(n){s+=t,t===n&&(n=null);continue}if(t==='"'||t==="'")n=t;else if(t==="(")r+=1;else if(t===")")r=Math.max(0,r-1);else if(t===";"&&r===0){o();continue}s+=t}return o(),i}function I(e){const i=[];let r=0,n="";for(const s of e){if(s==="("&&(r+=1),s===")"&&(r-=1),r===0&&/[\s>+~]/.test(s)){n.trim()&&i.push(n.trim()),n="";continue}n+=s}return n.trim()&&i.push(n.trim()),i}function C(e){let i=e.trim();const r=[],n=[];let s=null;const o=/^[a-zA-Z][a-zA-Z0-9-]*/.exec(i);for(o&&(s=o[0],i=i.slice(o[0].length));i.length;){let t;if(t=/^\.([A-Za-z0-9_-]+)/.exec(i))r.push(t[1]);else if(t=/^:(focus-visible|focus-within|hover|focus|active|checked|disabled)\b/.exec(i))n.push(t[1]);else if(t=/^:dir\([^)]*\)/.exec(i))n.push("dir");else if(t=/^:not\(\[([A-Za-z-]+)\]\)/.exec(i))r.push(`@not-${t[1]}`);else if(t=/^\[([A-Za-z-]+)(?:[~^$*|]?=[^\]]*)?\]/.exec(i))n.push(`[${t[1]}]`);else if(t=/^:has\(([^)]*)\)/.exec(i)){if(!/^\s*>?\s*[a-z]+\s*$/.test(t[1]))return null;r.push("@has-type")}else return null;i=i.slice(t[0].length)}return{type:s,classes:r,needsState:n}}const D=e=>e.reduce((i,r)=>[i[0],i[1]+r.classes.filter(n=>n!=="@has-type").length+r.needsState.length,i[2]+(r.type?1:0)+(r.classes.includes("@has-type")?1:0)],[0,0,0]);function E(e){if(e===null)return!0;let i=!0;for(const r of e.replace(/^@media\s*/i,"").split(/\s+and\s+/i)){const n=r.trim().replace(/^\(|\)$/g,"").trim(),s=/^([a-z-]+)\s*:\s*(.+)$/.exec(n);if(!s)return null;const o=s[1],t=s[2].trim();if(o==="hover"||o==="any-hover"){if(t==="hover")continue;return t==="none"?!1:null}if(o==="pointer"||o==="any-pointer"){if(t==="fine")continue;return t==="coarse"||t==="none"?!1:null}i=null}return i}const T=e=>e??"(no media query)";function W(e,i,r,n,s="rest"){const o=[],t=[],l=[],u=s==="hover"?new Set(["hover"]):new Set;return e.forEach((a,p)=>{const g=s==="rest"?a.media===null:E(a.media);for(const S of a.selector.split(",")){const m=S.trim();if(!m||!/(^|[\s,>+~])select\b/.test(m)&&!i.own.some(f=>m.includes(`.${f}`)))continue;const h=I(m).map(C),c=h[h.length-1];if(h.some(f=>f===null)||!c){t.push(`${r}: ${m}`);continue}const d=h;if(c.type&&c.type!=="select")continue;const x=c.classes.filter(f=>!f.startsWith("@"));if(!(!x.every(f=>i.own.includes(f))||!c.type&&x.length===0||!c.needsState.every(f=>u.has(f))||!d.slice(0,-1).every(f=>(!f.type||f.type==="div")&&f.classes.filter(y=>!y.startsWith("@")).every(y=>i.ancestors.includes(y))&&f.needsState.every(y=>u.has(y))))&&g!==!1){if(g===null){l.push({sheet:r,selector:m,media:a.media??"",decls:a.decls});continue}o.push({spec:D(d),order:n+p,decls:a.decls,selector:m,sheet:r})}}}),{applied:o,unreadable:t,undecided:l}}const k={appearance:"auto","background-image":"none","background-size":"auto","background-repeat":"repeat","background-position":"0% 0%","background-color":"transparent","border-color":"currentcolor"};function $(e){const i=e.replace(/url\([\s\S]*?\)/g," "),r=/var\(--[A-Za-z0-9-]+(?:\s*,[^()]*)?\)|#[0-9a-fA-F]{3,8}\b|(?:rgba?|hsla?|color-mix|color)\([^()]*(?:\([^()]*\)[^()]*)*\)|\b(?:transparent|currentcolor|white|black)\b/i.exec(i);return r?r[0]:null}function j(e){const i=new Map;for(const r of v(e.replace(/[^{}]*\{|\}/g,";")))r.prop.startsWith("--")&&i.set(r.prop,r.value);return i}function z(e,i,r=0){if(r>8)return e;let n=!1;const s=e.replace(/var\(\s*(--[A-Za-z0-9-]+)\s*(?:,([^()]*(?:\([^()]*\)[^()]*)*))?\)/g,(o,t)=>{const l=i.get(t);return l===void 0?o:(n=!0,l)});return n?z(s,i,r+1):s}function q(e,i,r=new Map){let n=null;const s=(t,l)=>{(!n||w(t.spec,n.spec)>0||w(t.spec,n.spec)===0&&t.order>=n.order)&&(n={value:l.trim(),from:`${t.sheet} { ${t.selector} }`,spec:t.spec,order:t.order})};for(const t of e)for(const l of v(t.decls)){if(l.prop===i||i==="appearance"&&l.prop==="-webkit-appearance"){s(t,l.value);continue}if(l.prop==="border"&&i==="border-color"){s(t,$(l.value)??k[i]);continue}if(l.prop!=="background"||!i.startsWith("background-"))continue;const u=l.value;s(t,i==="background-image"?/url\([\s\S]*?\)|linear-gradient\([\s\S]*?\)|image-set\([\s\S]*?\)/.exec(u)?.[0]??"none":i==="background-repeat"?/\b(no-repeat|repeat-x|repeat-y|round|space|repeat)\b/.exec(u)?.[0]??"repeat":i==="background-color"?$(u)??k[i]:k[i])}const o=n??{value:k[i],from:"(nothing declares one)"};return{value:z(o.value,r),from:o.from}}const O=["sf-editor","sf-body","sf-panel","sf-insp-body","sf-styles","sf-field","es-field","sf-copybox"];function J(e,i){const r=e.filter(t=>!t.engineDrawn),n=t=>new RegExp(`\\.${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(i),s=t=>[...t.classes].filter(n).sort().join(" "),o=new Set([""]);for(const t of r)o.add(s(t));return[...o].sort().map(t=>({name:t?`house .${t.split(" ").join(".")}`:"house (bare)",own:t?t.split(" "):[],ancestors:[...O],rows:r.filter(l=>s(l)===t).length}))}function K(e,i,r){const n=new Map;for(const s of r)n.set(s,[]);for(const s of i){if(!A(s.path))continue;const o=e.createSourceFile(s.path,s.text,e.ScriptTarget.Latest,!0),t=l=>{if(e.isJsxAttribute(l)&&e.isIdentifier(l.name)&&l.name.text==="className"&&l.initializer&&e.isStringLiteral(l.initializer)){const u=l.initializer.text.split(/\s+/).filter(Boolean);for(const a of r)u.includes(a)&&n.get(a)?.push(s.path)}l.forEachChild(t)};t(o)}return n}export{O as ANCESTORS,k as INITIAL,W as applicable,Z as census,K as chainInMarkup,$ as colorIn,C as compound,z as derefVars,J as deriveShapes,N as importsOf,E as mediaHolds,T as mediaLabel,j as readVars,q as resolve,w as specCmp,D as specOf,M as specStr,I as splitCombinators,v as splitDecls};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const c=t=>/\.(tsx?|mts)$/.test(t)&&!t.endsWith(".d.ts");function u(t,n){const r=new Map,s=new Set(["/"]);for(const e of n){if(!c(e.path))continue;r.set(`/${e.path}`,e.text);const o=e.path.split("/");for(let i=1;i<o.length;i++)s.add(`/${o.slice(0,i).join("/")}`)}const a={noLib:!0,types:[],noEmit:!0,jsx:t.JsxEmit.Preserve,target:t.ScriptTarget.ESNext,module:t.ModuleKind.ESNext,moduleResolution:t.ModuleResolutionKind.Bundler,baseUrl:"/",paths:{"@/*":["./*"]}},l={fileExists:e=>r.has(e),readFile:e=>r.get(e),directoryExists:e=>s.has(e.replace(/\/+$/,"")||"/"),getDirectories:()=>[],realpath:e=>e,getSourceFile:(e,o)=>{const i=r.get(e);return i===void 0?void 0:t.createSourceFile(e,i,o,!0)},getDefaultLibFileName:()=>"/lib.d.ts",writeFile:()=>{},getCurrentDirectory:()=>"/",getCanonicalFileName:e=>e,useCaseSensitiveFileNames:()=>!0,getNewLine:()=>`
|
|
2
|
+
`};return t.createProgram({rootNames:[...r.keys()],options:a,host:l})}export{c as isScript,u as programOf};
|
|
@@ -56,6 +56,7 @@ export { contrastRatio };
|
|
|
56
56
|
export declare const GRADE_LABEL: Record<ReadabilityGrade, string>;
|
|
57
57
|
export declare function gradeContrast(ratio: number): ReadabilityGrade;
|
|
58
58
|
export declare function accentInk(accent: string): string;
|
|
59
|
+
export declare function fillIsDark(fill: string): boolean;
|
|
59
60
|
export declare const ACCENT_DARKEN_STEPS: readonly [0.25, 0.4, 0.55];
|
|
60
61
|
export declare function darkerAccents(accent: string): string[];
|
|
61
62
|
export declare function themeColorStyle(v?: ThemeValue | null): Record<string, string>;
|
package/dist/format/lib/theme.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{contrastRatio as
|
|
1
|
+
import{contrastRatio as q,hexToRgb as g,parseHexColor as s,readableInk as J,relativeLuminance as p}from"efficient-shell/format";const Q="storefront-theme",$e="sf:theme-mode",Fe="sf:theme-switch",Ue="hide",Ge="light",Ye=!1,D=7,H=18;function v(e){return e>=D&&e<H}function ze(e){const{mode:t,override:n,switchShown:r,hour:o}=e;return r&&(n==="light"||n==="dark")?n:t==="auto"?v(o)?"light":"dark":t==="light"?"light":"dark"}function Be(e){const{mode:t,switchShown:n}=e;return`
|
|
2
2
|
try {
|
|
3
3
|
var mode = ${JSON.stringify(t)};
|
|
4
4
|
var shown = ${n?"true":"false"};
|
|
5
|
-
var override = localStorage.getItem(${JSON.stringify(
|
|
5
|
+
var override = localStorage.getItem(${JSON.stringify(Q)});
|
|
6
6
|
var theme;
|
|
7
7
|
if (shown && (override === 'light' || override === 'dark')) {
|
|
8
8
|
theme = override;
|
|
@@ -15,4 +15,4 @@ import{contrastRatio as Z,hexToRgb as d,parseHexColor as s,readableInk as q,rela
|
|
|
15
15
|
if (theme === 'light') document.documentElement.setAttribute('data-theme', 'light');
|
|
16
16
|
else document.documentElement.removeAttribute('data-theme');
|
|
17
17
|
} catch (e) {}
|
|
18
|
-
`}const l={background:"#0a0a0a",surface:"#131313",line:"#2a2a2a",muted:"#9a9388"},v=[{text:"#2e2e2e",accent:"#2e2e2e",background:"#ffffff",surface:"#f7f7f7",line:"#e0e0e0",muted:"#5c5c5c"},{text:"#f7f7f7",accent:"#f7f7f7",background:"#0a0a0a",surface:"#1b1b1b",line:"#363636",muted:"#a3a3a3"},{text:"#ffffff",accent:"#ffffff",background:"#2e2e2e",surface:"#3d3d3d",line:"#545454",muted:"#b0b0b0"},{text:"#0a0a0a",accent:"#0a0a0a",background:"#f7f7f7",surface:"#ffffff",line:"#d9d9d9",muted:"#5c5c5c"}],ee={selected:0,themes:v};function N(e){return!e||!Array.isArray(e.themes)||e.themes.length===0?{...ee}:{selected:Math.min(Math.max(0,e.selected??0),e.themes.length-1),themes:e.themes}}function _(e,t,n){const r=d(e),o=d(t);if(r===null||o===null)return e;const c=(i,a)=>Math.max(0,Math.min(255,Math.round(i+(a-i)*n))).toString(16).padStart(2,"0");return`#${c(r.r,o.r)}${c(r.g,o.g)}${c(r.b,o.b)}`}const te={light:"#ffffff",dark:"#0a0a0a"},Xe=["light","dark"];function We(e,t){const n=te[t],r=t==="light"?"#ffffff":"#000000";return{text:n,accent:n,background:e,surface:_(e,r,.1),line:_(e,r,.22),muted:_(n,e,.35),brandInk:t}}function h(e){const t=N(e);return t.themes[t.selected]}function u(e){return{text:e.text,accent:e.accent,background:e.background||l.background,surface:e.surface||l.surface,line:e.line||l.line,muted:e.muted||l.muted}}function Ke(e){return{fill:u(e).background,accent:e.accent}}const ne=.4,re=4.5,oe=3,je={good:"Good","large-only":"Large text only",hard:"Hard to read"};function Ve(e){return e>=re?"good":e>=oe?"large-only":"hard"}const ce=["#000000","#ffffff"];function g(e){return q(e,ce)}const ie=[.25,.4,.55];function Ze(e){const t=d(e);return t===null?[]:ie.map(n=>"#"+[t.r,t.g,t.b].map(r=>Math.round(r*(1-n)).toString(16).padStart(2,"0")).join(""))}function qe(e){const t=h(e),n={"--theme-fg":t.text},r=p(t.text);return(r===null||r>=ne)&&(n["--overlay-fg"]=t.text),n}const se=82;function E(e){return`color-mix(in srgb, ${e} ${se}%, #000)`}function Je(e){const t=h(e);return{"--theme-accent":t.accent,"--theme-accent-2":E(t.accent),"--theme-accent-ink":g(t.accent)}}function S(e){const t=e?.button;return t&&s(t)===t.toLowerCase()?t.toLowerCase():null}function Qe(e){const t=h(e),n=S(t),r=O(t);if(n===null&&r===null)return{};const o={};return n!==null&&(o["--theme-btn"]=n,o["--theme-btn-2"]=E(n)),o["--theme-btn-ink"]=r??g(n),o}function O(e){const t=e?.buttonInk;return t&&s(t)===t.toLowerCase()?t.toLowerCase():null}function ae(e,t){return O(e)??g(S(e)??t)}function ve(e){const t=h(e);return{fill:S(t)??t.accent.toLowerCase(),ink:ae(t,t.accent)}}function et(e){const t={};return N(e).themes.forEach((n,r)=>{const o=u(n);t[`--theme-preset-${r}-accent`]=o.accent,t[`--theme-preset-${r}-accent-2`]=E(o.accent),t[`--theme-preset-${r}-accent-ink`]=g(o.accent),t[`--theme-preset-${r}-bg`]=o.background,t[`--theme-preset-${r}-fg`]=o.text,t[`--theme-preset-${r}-surface`]=o.surface,t[`--theme-preset-${r}-surface-2`]=`color-mix(in srgb, ${o.surface} 60%, ${o.line})`,t[`--theme-preset-${r}-line`]=o.line,t[`--theme-preset-${r}-muted`]=o.muted}),t}const A=e=>{const t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4},T=e=>255*(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055);function k([e,t,n]){const[r,o,c]=[A(e),A(t),A(n)],i=Math.cbrt(.4122214708*r+.5363325363*o+.0514459929*c),a=Math.cbrt(.2119034982*r+.6806995451*o+.1073969566*c),f=Math.cbrt(.0883024619*r+.2817188376*o+.6299787005*c);return[.2104542553*i+.793617785*a-.0040720468*f,1.9779984951*i-2.428592205*a+.4505937099*f,.0259040371*i+.7827717662*a-.808675766*f]}function ue([e,t,n]){const r=(e+.3963377774*t+.2158037573*n)**3,o=(e-.1055613458*t-.0638541728*n)**3,c=(e-.0894841775*t-1.291485548*n)**3;return[T(4.0767416621*r-3.3077115913*o+.2309699292*c),T(-1.2684380046*r+2.6097574011*o-.3413193965*c),T(-.0041960863*r-.7034186147*o+1.707614701*c)]}const b=e=>{const t=d(e);return t===null?[0,0,0]:[t.r,t.g,t.b]},L=(e,t,n)=>[e[0]*n+t[0]*(1-n),e[1]*n+t[1]*(1-n),e[2]*n+t[2]*(1-n)],P=e=>`#${e.map(t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0")).join("")}`,$=e=>L(b(e.surface),b(e.line),.6);function tt(e){return P($(u(e)))}function F(e){const t=u(e);return P(ue(L(k($(t)),k(b(t.text)),.92)))}function nt(e){return{...e,background:F(e)}}function U(e,t,n,r){const o=e[t];if(!o)return-1;const c=n(o);if(!c)return-1;const i=u(o);return e.findIndex((a,f)=>{if(f===t)return!1;const x=u(a);return s(x.background)!==c?!1:!r||s(x.text??"")===s(i.text??"")&&s(x.accent??"")===s(i.accent??"")})}function rt(e,t){return U(e,t,F,!1)}function ot(e,t){return U(e,t,n=>s(n.surface??""),!0)}const le=1;function fe(e,t){const n=(e??[]).flatMap((r,o)=>{const c=p(r.background??""),i=p(r.text??"");return c!==null&&i!==null&&c<i?[o]:[]});return n.find(r=>r!==t)??n[0]??le}function ct(e){return fe(e?.themes,e?.selected)}const it=["--theme-bg","--theme-surface","--theme-surface-2","--theme-line","--theme-muted"];function st(e){const t=u(h(e)),n=`color-mix(in srgb, ${t.surface} 60%, ${t.line})`,r={"--theme-bg":t.background,"--theme-surface":t.surface,"--theme-line":t.line,"--theme-muted":t.muted};return(t.surface!==l.surface||t.line!==l.line)&&(r["--theme-surface-2"]=n),r}const he=["heading","body","label"],at={heading:"Headings",body:"Body",label:"Labels"};function ut(e){if(!e)return null;for(const t of he)if(e.includes(`--size-${t}`))return t;return/--size-heading(Large|Medium|Small)/.test(e)?"heading":null}const G=["headingLarge","headingMedium","headingSmall","accent","body","label"],lt={headingLarge:"heading",headingMedium:"heading",headingSmall:"heading",accent:"heading",body:"body",label:"label"},ft={headingLarge:null,headingMedium:null,headingSmall:null,accent:null,body:null,label:null},de=8,ge=200;function me(e){if(typeof e!="number"||!Number.isFinite(e))return null;const t=Math.round(e);return t>=de&&t<=ge?t:null}function xe(e){const t={};for(const n of G)t[n]=me(e?.[n]);return t}function ht(e){const t=xe(e),n={};for(const r of G){const o=t[r];o!==null&&(n[`--size-${r}`]=`${o}px`)}return n}const pe=["square","small","large"],_e="small";function Ee(e){return pe.includes(e??"")?e:_e}function dt(e){return z(Ae[Ee(e)])}const C=0,Se=40,Ae={square:0,small:null,large:16},Y={"--sf-card-radius":1,"--sf-button-radius":.5,"--site-radius":.5,"--site-radius-xs":.25,"--site-radius-sm":.5,"--site-radius-md":.75,"--site-radius-lg":1,"--site-radius-xl":1.25,"--site-radius-2xl":1.5,"--site-radius-3xl":2,"--site-radius-4xl":2.5};function I(e){if(e==null||typeof e=="string"&&e.trim()==="")return null;const t=typeof e=="string"?Number(e):e;return Number.isFinite(t)?Math.min(Se,Math.max(C,Math.round(t))):null}function z(e){const t=I(e);return t===null?{}:Object.fromEntries(Object.entries(Y).map(([n,r])=>{const o=t*r/16;return[n,o===0?"0":`${o}rem`]}))}function gt(e){return(I(e)??C)*Y["--sf-button-radius"]}function mt(e){return z(I(e)??C)}const Te=["none","soft","lifted"],be="soft",B="none",Ce=["tight","normal","roomy"],Ie="normal",we="normal",Me=["none","lift","highlight"],ye="lift",Re="highlight",X="#141416";function W(e){return Te.includes(e??"")?e:be}function De(e){return Ce.includes(e??"")?e:Ie}function K(e){return Me.includes(e??"")?e:ye}function He(e){return e&&s(e)===e.toLowerCase()?e.toLowerCase():X}function xt(e){const t=W(e);return t===B?void 0:t}function pt(e){const t=De(e);return t===we?void 0:t}function _t(e){const t=K(e);return t===Re?void 0:t}function Et(e,t,n){const r=He(t);return r===X?{}:W(e)!==B||K(n)==="lift"?{"--sf-shadow-color":r}:{}}const Ne=["normal","tight","compressed"],j="normal";function V(e){return Ne.includes(e??"")?e:j}function St(e){const t=V(e);return t===j?void 0:t}function At(e){switch(V(e)){case"tight":return{lineHeight:.95,letterSpacing:-.01};case"compressed":return{lineHeight:.86,letterSpacing:-.01};default:return{}}}const Tt=["authored","sentence"],bt={case:"authored",weight:null,weightStrong:null,italicStrong:null,maxPx:null,weight2:null,weight3:null,case2:"authored",case3:"authored"},w=100,M=900,Oe=24,ke=200;function m(e,t,n){return typeof e!="number"||!Number.isFinite(e)?null:Math.round(Math.min(Math.max(e,t),n))}function y(e){const t=m(e?.weight,w,M),n=e?.case==="sentence"?"sentence":"authored",r=c=>c==null?t:m(c,w,M),o=c=>c==="sentence"?"sentence":c==="authored"?"authored":n;return{case:n,weight:t,weightStrong:m(e?.weightStrong,w,M),italicStrong:typeof e?.italicStrong=="boolean"?e.italicStrong:null,maxPx:m(e?.maxPx,Oe,ke),weight2:r(e?.weight2),weight3:r(e?.weight3),case2:o(e?.case2),case3:o(e?.case3)}}function Ct(e){const t=y(e),n={};return t.case==="sentence"&&(n["--sf-heading-case"]="none"),t.weight!==null&&(n["--sf-heading-weight"]=String(t.weight)),t.weightStrong!==null&&(n["--sf-heading-weight-strong"]=String(t.weightStrong)),t.maxPx!==null&&(n["--sf-heading-max"]=`${t.maxPx}px`),t.weight2!==null&&t.weight2!==t.weight&&(n["--sf-heading-2-weight"]=String(t.weight2)),t.weight3!==null&&t.weight3!==t.weight&&(n["--sf-heading-3-weight"]=String(t.weight3)),t.case2!==t.case&&(n["--sf-heading-2-case"]=t.case2==="sentence"?"none":"uppercase"),t.case3!==t.case&&(n["--sf-heading-3-case"]=t.case3==="sentence"?"none":"uppercase"),n}function It(e){return y({case:e?.heading_case??void 0,weight:e?.heading_weight,weightStrong:e?.heading_weight_strong,italicStrong:e?.accent_italic,maxPx:e?.heading_max_px,weight2:e?.heading_2_weight??void 0,weight3:e?.heading_3_weight??void 0,case2:e?.heading_2_case??void 0,case3:e?.heading_3_case??void 0})}function wt(e){const t=y(e);return{heading_case:t.case,heading_weight:t.weight,heading_weight_strong:t.weightStrong,heading_max_px:t.maxPx,heading_2_weight:t.weight2,heading_3_weight:t.weight3,heading_2_case:t.case2,heading_3_case:t.case3}}const R="siteTheme";function Le(e){const t=e;if(!t||typeof t!="object"||!Array.isArray(t.themes)||!t.themes.every(r=>!!r&&typeof r=="object"))return{};const n=typeof t.selected=="number"&&Number.isInteger(t.selected)&&t.selected>=0?t.selected:0;return{[R]:{selected:n,themes:t.themes}}}function Mt(e){return Le(e?.[R])[R]}export{ie as ACCENT_DARKEN_STEPS,Xe as BRAND_INKS,Ce as CARD_GAPS,Te as CARD_SHADOWS,Se as CORNER_RADIUS_MAX,C as CORNER_RADIUS_MIN,pe as CORNER_STYLES,Ae as CORNER_STYLE_TO_PX,Ie as DEFAULT_CARD_GAP,be as DEFAULT_CARD_SHADOW,_e as DEFAULT_CORNER_STYLE,j as DEFAULT_HEADING_COMPRESSION,bt as DEFAULT_HEADING_TYPOGRAPHY,ye as DEFAULT_HOVER_EFFECT,X as DEFAULT_SHADOW_COLOR,ft as DEFAULT_SIZES,l as DEFAULT_SURFACES,Ye as DEFAULT_SWITCH_SHOWN,v as DEFAULT_THEMES,Ge as DEFAULT_THEME_MODE,ee as DEFAULT_THEME_VALUE,je as GRADE_LABEL,Tt as HEADING_CASES,Ne as HEADING_COMPRESSIONS,ke as HEADING_MAX_PX_MAX,Oe as HEADING_MAX_PX_MIN,M as HEADING_WEIGHT_MAX,w as HEADING_WEIGHT_MIN,Me as HOVER_EFFECTS,we as IDENTITY_CARD_GAP,B as IDENTITY_CARD_SHADOW,Re as IDENTITY_HOVER_EFFECT,re as READABILITY_AA,oe as READABILITY_AA_LARGE,lt as SCALE_OF_STEP,R as SITE_THEME_KEY,G as SIZE_STEPS,ge as TEXT_SIZE_MAX,de as TEXT_SIZE_MIN,H as THEME_DAY_END_HOUR,D as THEME_DAY_START_HOUR,$e as THEME_MODE_KEY,J as THEME_STORAGE_KEY,it as THEME_SURFACE_KEYS,Ue as THEME_SWITCH_HIDE,Fe as THEME_SWITCH_KEY,he as TYPE_GROUPS,at as TYPE_GROUP_LABELS,g as accentInk,nt as bandPresetFor,rt as bandPresetIndex,We as brandTheme,Be as buildThemeBootScript,pt as cardGapAttr,xt as cardShadowAttr,At as compressionMetrics,Z as contrastRatio,z as cornerRadiusTokens,dt as cornerStyleTokens,ct as darkBandIndex,fe as darkPresetIndex,Ze as darkerAccents,Ve as gradeContrast,St as headingCompressionAttr,It as headingTypographyFromRow,Ct as headingTypographyStyle,wt as headingTypographyToRow,_t as hoverEffectAttr,Q as isDayHour,De as normalizeCardGap,W as normalizeCardShadow,I as normalizeCornerRadius,Ee as normalizeCornerStyle,V as normalizeHeadingCompression,y as normalizeHeadingTypography,K as normalizeHoverEffect,He as normalizeShadowColor,me as normalizeSize,xe as normalizeSizes,N as normalizeTheme,u as normalizeThemeColors,ze as resolveTheme,ae as resolvedButtonInk,F as sectionBandTone,h as selectedThemeColors,Et as shadowColorTokens,ve as siteButtonPaint,gt as siteButtonRadiusPx,mt as siteCornerRadiusTokens,Le as siteThemeMetadata,Mt as siteThemeOf,ot as surfacePresetIndex,tt as surfaceTwoTone,Je as themeAccentStyle,S as themeButtonColour,O as themeButtonInk,Qe as themeButtonStyle,qe as themeColorStyle,et as themePresetAccentVars,st as themeSurfaceStyle,Ke as themeSwatchColors,ut as typeScaleGroupOfClassName,ht as typeSizesStyle};
|
|
18
|
+
`}const l={background:"#0a0a0a",surface:"#131313",line:"#2a2a2a",muted:"#9a9388"},ee=[{text:"#2e2e2e",accent:"#2e2e2e",background:"#ffffff",surface:"#f7f7f7",line:"#e0e0e0",muted:"#5c5c5c"},{text:"#f7f7f7",accent:"#f7f7f7",background:"#0a0a0a",surface:"#1b1b1b",line:"#363636",muted:"#a3a3a3"},{text:"#ffffff",accent:"#ffffff",background:"#2e2e2e",surface:"#3d3d3d",line:"#545454",muted:"#b0b0b0"},{text:"#0a0a0a",accent:"#0a0a0a",background:"#f7f7f7",surface:"#ffffff",line:"#d9d9d9",muted:"#5c5c5c"}],te={selected:0,themes:ee};function N(e){return!e||!Array.isArray(e.themes)||e.themes.length===0?{...te}:{selected:Math.min(Math.max(0,e.selected??0),e.themes.length-1),themes:e.themes}}function _(e,t,n){const r=g(e),o=g(t);if(r===null||o===null)return e;const c=(i,a)=>Math.max(0,Math.min(255,Math.round(i+(a-i)*n))).toString(16).padStart(2,"0");return`#${c(r.r,o.r)}${c(r.g,o.g)}${c(r.b,o.b)}`}const ne={light:"#ffffff",dark:"#0a0a0a"},Xe=["light","dark"];function We(e,t){const n=ne[t],r=t==="light"?"#ffffff":"#000000";return{text:n,accent:n,background:e,surface:_(e,r,.1),line:_(e,r,.22),muted:_(n,e,.35),brandInk:t}}function h(e){const t=N(e);return t.themes[t.selected]}function u(e){return{text:e.text,accent:e.accent,background:e.background||l.background,surface:e.surface||l.surface,line:e.line||l.line,muted:e.muted||l.muted}}function Ke(e){return{fill:u(e).background,accent:e.accent}}const re=.4,oe=4.5,ce=3,je={good:"Good","large-only":"Large text only",hard:"Hard to read"};function Ve(e){return e>=oe?"good":e>=ce?"large-only":"hard"}const k=["#000000","#ffffff"];function d(e){return J(e,k)}function Ze(e){return d(e)===k[1]}const ie=[.25,.4,.55];function qe(e){const t=g(e);return t===null?[]:ie.map(n=>"#"+[t.r,t.g,t.b].map(r=>Math.round(r*(1-n)).toString(16).padStart(2,"0")).join(""))}function Je(e){const t=h(e),n={"--theme-fg":t.text},r=p(t.text);return(r===null||r>=re)&&(n["--overlay-fg"]=t.text),n}const se=82;function E(e){return`color-mix(in srgb, ${e} ${se}%, #000)`}function Qe(e){const t=h(e);return{"--theme-accent":t.accent,"--theme-accent-2":E(t.accent),"--theme-accent-ink":d(t.accent)}}function S(e){const t=e?.button;return t&&s(t)===t.toLowerCase()?t.toLowerCase():null}function ve(e){const t=h(e),n=S(t),r=O(t);if(n===null&&r===null)return{};const o={};return n!==null&&(o["--theme-btn"]=n,o["--theme-btn-2"]=E(n)),o["--theme-btn-ink"]=r??d(n),o}function O(e){const t=e?.buttonInk;return t&&s(t)===t.toLowerCase()?t.toLowerCase():null}function ae(e,t){return O(e)??d(S(e)??t)}function et(e){const t=h(e);return{fill:S(t)??t.accent.toLowerCase(),ink:ae(t,t.accent)}}function tt(e){const t={};return N(e).themes.forEach((n,r)=>{const o=u(n);t[`--theme-preset-${r}-accent`]=o.accent,t[`--theme-preset-${r}-accent-2`]=E(o.accent),t[`--theme-preset-${r}-accent-ink`]=d(o.accent),t[`--theme-preset-${r}-bg`]=o.background,t[`--theme-preset-${r}-fg`]=o.text,t[`--theme-preset-${r}-surface`]=o.surface,t[`--theme-preset-${r}-surface-2`]=`color-mix(in srgb, ${o.surface} 60%, ${o.line})`,t[`--theme-preset-${r}-line`]=o.line,t[`--theme-preset-${r}-muted`]=o.muted}),t}const A=e=>{const t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4},T=e=>255*(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055);function L([e,t,n]){const[r,o,c]=[A(e),A(t),A(n)],i=Math.cbrt(.4122214708*r+.5363325363*o+.0514459929*c),a=Math.cbrt(.2119034982*r+.6806995451*o+.1073969566*c),f=Math.cbrt(.0883024619*r+.2817188376*o+.6299787005*c);return[.2104542553*i+.793617785*a-.0040720468*f,1.9779984951*i-2.428592205*a+.4505937099*f,.0259040371*i+.7827717662*a-.808675766*f]}function ue([e,t,n]){const r=(e+.3963377774*t+.2158037573*n)**3,o=(e-.1055613458*t-.0638541728*n)**3,c=(e-.0894841775*t-1.291485548*n)**3;return[T(4.0767416621*r-3.3077115913*o+.2309699292*c),T(-1.2684380046*r+2.6097574011*o-.3413193965*c),T(-.0041960863*r-.7034186147*o+1.707614701*c)]}const b=e=>{const t=g(e);return t===null?[0,0,0]:[t.r,t.g,t.b]},P=(e,t,n)=>[e[0]*n+t[0]*(1-n),e[1]*n+t[1]*(1-n),e[2]*n+t[2]*(1-n)],$=e=>`#${e.map(t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0")).join("")}`,F=e=>P(b(e.surface),b(e.line),.6);function nt(e){return $(F(u(e)))}function U(e){const t=u(e);return $(ue(P(L(F(t)),L(b(t.text)),.92)))}function rt(e){return{...e,background:U(e)}}function G(e,t,n,r){const o=e[t];if(!o)return-1;const c=n(o);if(!c)return-1;const i=u(o);return e.findIndex((a,f)=>{if(f===t)return!1;const x=u(a);return s(x.background)!==c?!1:!r||s(x.text??"")===s(i.text??"")&&s(x.accent??"")===s(i.accent??"")})}function ot(e,t){return G(e,t,U,!1)}function ct(e,t){return G(e,t,n=>s(n.surface??""),!0)}const le=1;function fe(e,t){const n=(e??[]).flatMap((r,o)=>{const c=p(r.background??""),i=p(r.text??"");return c!==null&&i!==null&&c<i?[o]:[]});return n.find(r=>r!==t)??n[0]??le}function it(e){return fe(e?.themes,e?.selected)}const st=["--theme-bg","--theme-surface","--theme-surface-2","--theme-line","--theme-muted"];function at(e){const t=u(h(e)),n=`color-mix(in srgb, ${t.surface} 60%, ${t.line})`,r={"--theme-bg":t.background,"--theme-surface":t.surface,"--theme-line":t.line,"--theme-muted":t.muted};return(t.surface!==l.surface||t.line!==l.line)&&(r["--theme-surface-2"]=n),r}const he=["heading","body","label"],ut={heading:"Headings",body:"Body",label:"Labels"};function lt(e){if(!e)return null;for(const t of he)if(e.includes(`--size-${t}`))return t;return/--size-heading(Large|Medium|Small)/.test(e)?"heading":null}const Y=["headingLarge","headingMedium","headingSmall","accent","body","label"],ft={headingLarge:"heading",headingMedium:"heading",headingSmall:"heading",accent:"heading",body:"body",label:"label"},ht={headingLarge:null,headingMedium:null,headingSmall:null,accent:null,body:null,label:null},de=8,ge=200;function me(e){if(typeof e!="number"||!Number.isFinite(e))return null;const t=Math.round(e);return t>=de&&t<=ge?t:null}function xe(e){const t={};for(const n of Y)t[n]=me(e?.[n]);return t}function dt(e){const t=xe(e),n={};for(const r of Y){const o=t[r];o!==null&&(n[`--size-${r}`]=`${o}px`)}return n}const pe=["square","small","large"],_e="small";function Ee(e){return pe.includes(e??"")?e:_e}function gt(e){return B(Ae[Ee(e)])}const C=0,Se=40,Ae={square:0,small:null,large:16},z={"--sf-card-radius":1,"--sf-button-radius":.5,"--site-radius":.5,"--site-radius-xs":.25,"--site-radius-sm":.5,"--site-radius-md":.75,"--site-radius-lg":1,"--site-radius-xl":1.25,"--site-radius-2xl":1.5,"--site-radius-3xl":2,"--site-radius-4xl":2.5};function I(e){if(e==null||typeof e=="string"&&e.trim()==="")return null;const t=typeof e=="string"?Number(e):e;return Number.isFinite(t)?Math.min(Se,Math.max(C,Math.round(t))):null}function B(e){const t=I(e);return t===null?{}:Object.fromEntries(Object.entries(z).map(([n,r])=>{const o=t*r/16;return[n,o===0?"0":`${o}rem`]}))}function mt(e){return(I(e)??C)*z["--sf-button-radius"]}function xt(e){return B(I(e)??C)}const Te=["none","soft","lifted"],be="soft",X="none",Ce=["tight","normal","roomy"],Ie="normal",we="normal",Me=["none","lift","highlight"],ye="lift",Re="highlight",W="#141416";function K(e){return Te.includes(e??"")?e:be}function De(e){return Ce.includes(e??"")?e:Ie}function j(e){return Me.includes(e??"")?e:ye}function He(e){return e&&s(e)===e.toLowerCase()?e.toLowerCase():W}function pt(e){const t=K(e);return t===X?void 0:t}function _t(e){const t=De(e);return t===we?void 0:t}function Et(e){const t=j(e);return t===Re?void 0:t}function St(e,t,n){const r=He(t);return r===W?{}:K(e)!==X||j(n)==="lift"?{"--sf-shadow-color":r}:{}}const Ne=["normal","tight","compressed"],V="normal";function Z(e){return Ne.includes(e??"")?e:V}function At(e){const t=Z(e);return t===V?void 0:t}function Tt(e){switch(Z(e)){case"tight":return{lineHeight:.95,letterSpacing:-.01};case"compressed":return{lineHeight:.86,letterSpacing:-.01};default:return{}}}const bt=["authored","sentence"],Ct={case:"authored",weight:null,weightStrong:null,italicStrong:null,maxPx:null,weight2:null,weight3:null,case2:"authored",case3:"authored"},w=100,M=900,ke=24,Oe=200;function m(e,t,n){return typeof e!="number"||!Number.isFinite(e)?null:Math.round(Math.min(Math.max(e,t),n))}function y(e){const t=m(e?.weight,w,M),n=e?.case==="sentence"?"sentence":"authored",r=c=>c==null?t:m(c,w,M),o=c=>c==="sentence"?"sentence":c==="authored"?"authored":n;return{case:n,weight:t,weightStrong:m(e?.weightStrong,w,M),italicStrong:typeof e?.italicStrong=="boolean"?e.italicStrong:null,maxPx:m(e?.maxPx,ke,Oe),weight2:r(e?.weight2),weight3:r(e?.weight3),case2:o(e?.case2),case3:o(e?.case3)}}function It(e){const t=y(e),n={};return t.case==="sentence"&&(n["--sf-heading-case"]="none"),t.weight!==null&&(n["--sf-heading-weight"]=String(t.weight)),t.weightStrong!==null&&(n["--sf-heading-weight-strong"]=String(t.weightStrong)),t.maxPx!==null&&(n["--sf-heading-max"]=`${t.maxPx}px`),t.weight2!==null&&t.weight2!==t.weight&&(n["--sf-heading-2-weight"]=String(t.weight2)),t.weight3!==null&&t.weight3!==t.weight&&(n["--sf-heading-3-weight"]=String(t.weight3)),t.case2!==t.case&&(n["--sf-heading-2-case"]=t.case2==="sentence"?"none":"uppercase"),t.case3!==t.case&&(n["--sf-heading-3-case"]=t.case3==="sentence"?"none":"uppercase"),n}function wt(e){return y({case:e?.heading_case??void 0,weight:e?.heading_weight,weightStrong:e?.heading_weight_strong,italicStrong:e?.accent_italic,maxPx:e?.heading_max_px,weight2:e?.heading_2_weight??void 0,weight3:e?.heading_3_weight??void 0,case2:e?.heading_2_case??void 0,case3:e?.heading_3_case??void 0})}function Mt(e){const t=y(e);return{heading_case:t.case,heading_weight:t.weight,heading_weight_strong:t.weightStrong,heading_max_px:t.maxPx,heading_2_weight:t.weight2,heading_3_weight:t.weight3,heading_2_case:t.case2,heading_3_case:t.case3}}const R="siteTheme";function Le(e){const t=e;if(!t||typeof t!="object"||!Array.isArray(t.themes)||!t.themes.every(r=>!!r&&typeof r=="object"))return{};const n=typeof t.selected=="number"&&Number.isInteger(t.selected)&&t.selected>=0?t.selected:0;return{[R]:{selected:n,themes:t.themes}}}function yt(e){return Le(e?.[R])[R]}export{ie as ACCENT_DARKEN_STEPS,Xe as BRAND_INKS,Ce as CARD_GAPS,Te as CARD_SHADOWS,Se as CORNER_RADIUS_MAX,C as CORNER_RADIUS_MIN,pe as CORNER_STYLES,Ae as CORNER_STYLE_TO_PX,Ie as DEFAULT_CARD_GAP,be as DEFAULT_CARD_SHADOW,_e as DEFAULT_CORNER_STYLE,V as DEFAULT_HEADING_COMPRESSION,Ct as DEFAULT_HEADING_TYPOGRAPHY,ye as DEFAULT_HOVER_EFFECT,W as DEFAULT_SHADOW_COLOR,ht as DEFAULT_SIZES,l as DEFAULT_SURFACES,Ye as DEFAULT_SWITCH_SHOWN,ee as DEFAULT_THEMES,Ge as DEFAULT_THEME_MODE,te as DEFAULT_THEME_VALUE,je as GRADE_LABEL,bt as HEADING_CASES,Ne as HEADING_COMPRESSIONS,Oe as HEADING_MAX_PX_MAX,ke as HEADING_MAX_PX_MIN,M as HEADING_WEIGHT_MAX,w as HEADING_WEIGHT_MIN,Me as HOVER_EFFECTS,we as IDENTITY_CARD_GAP,X as IDENTITY_CARD_SHADOW,Re as IDENTITY_HOVER_EFFECT,oe as READABILITY_AA,ce as READABILITY_AA_LARGE,ft as SCALE_OF_STEP,R as SITE_THEME_KEY,Y as SIZE_STEPS,ge as TEXT_SIZE_MAX,de as TEXT_SIZE_MIN,H as THEME_DAY_END_HOUR,D as THEME_DAY_START_HOUR,$e as THEME_MODE_KEY,Q as THEME_STORAGE_KEY,st as THEME_SURFACE_KEYS,Ue as THEME_SWITCH_HIDE,Fe as THEME_SWITCH_KEY,he as TYPE_GROUPS,ut as TYPE_GROUP_LABELS,d as accentInk,rt as bandPresetFor,ot as bandPresetIndex,We as brandTheme,Be as buildThemeBootScript,_t as cardGapAttr,pt as cardShadowAttr,Tt as compressionMetrics,q as contrastRatio,B as cornerRadiusTokens,gt as cornerStyleTokens,it as darkBandIndex,fe as darkPresetIndex,qe as darkerAccents,Ze as fillIsDark,Ve as gradeContrast,At as headingCompressionAttr,wt as headingTypographyFromRow,It as headingTypographyStyle,Mt as headingTypographyToRow,Et as hoverEffectAttr,v as isDayHour,De as normalizeCardGap,K as normalizeCardShadow,I as normalizeCornerRadius,Ee as normalizeCornerStyle,Z as normalizeHeadingCompression,y as normalizeHeadingTypography,j as normalizeHoverEffect,He as normalizeShadowColor,me as normalizeSize,xe as normalizeSizes,N as normalizeTheme,u as normalizeThemeColors,ze as resolveTheme,ae as resolvedButtonInk,U as sectionBandTone,h as selectedThemeColors,St as shadowColorTokens,et as siteButtonPaint,mt as siteButtonRadiusPx,xt as siteCornerRadiusTokens,Le as siteThemeMetadata,yt as siteThemeOf,ct as surfacePresetIndex,nt as surfaceTwoTone,Qe as themeAccentStyle,S as themeButtonColour,O as themeButtonInk,ve as themeButtonStyle,Je as themeColorStyle,tt as themePresetAccentVars,at as themeSurfaceStyle,Ke as themeSwatchColors,lt as typeScaleGroupOfClassName,dt as typeSizesStyle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{buttonArrowShown as
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{buttonArrowShown as N}from"../../format/lib/content/button-arrow.js";import{buttonIconAtEnd as _,buttonIconSide as j,buttonWidthClass as v,storedButtonIcon as F}from"../../format/lib/content/button-icon.js";import{buttonCornersStyle as O,buttonPadAttrs as R,buttonPaint as $}from"../lib/content/button-look.js";import{ArrowLongRightIcon as G,ArrowRightIcon as U,ArrowUpRightIcon as E,BagIcon as K,CarIcon as V,CartIcon as Y,ChevronRightIcon as z,DownloadIcon as D,EmailIcon as H,ExternalIcon as J,LocationIcon as W,PlayIcon as q,SearchIcon as M,TagIcon as Q}from"efficient-shell/icons/efficient";import X from"./BlockFrame.js";import Z from"./Btn.js";import{renderGold as oo}from"./goldPhrases.js";import{alignViewClasses as to,BLOCK_ALIGN_JUSTIFY as no}from"../../format/lib/content/block-align.js";import{useInBox as ro}from"./InBoxContext.js";const eo="sf-button-block",ao={"arrow-right":U,"arrow-long-right":G,"arrow-up-right":E,"chevron-right":z,external:J,cart:Y,bag:K,tag:Q,email:H,location:W,play:q,download:D,search:M,car:V},io=o=>o?` ${o}`:"";function co(o){const{label:b,href:i,variant:c,align:e,alignTablet:p,alignPhone:I,contained:C,arrow:B,icon:y,iconPosition:s,widthFit:l,widthFitPhone:x,widthFitTablet:S,buttonColor:t,buttonTextColor:d,hrefRewrite:h}=o,m=ro(),n=F(y),u=n&&n!=="none"?ao[n]:void 0,L=n===void 0?N(B)?{}:{arrow:null}:u?{arrow:r(u,{size:16}),...j(s)==="before"?{glyphBefore:!0}:{}}:{arrow:null},f=R(o),g=[v(l,x,S,{atSectionLine:!m}),f?.className??""].filter(Boolean).join(" "),P=g?{className:g}:{},T=_(s,l)?{spread:!0}:{},a=$(o),A=a?a.background==="transparent"?"ghost":"primary":c,w={...a??(t?c==="ghost"?{borderColor:t}:{background:t,borderColor:t}:{}),...d?{color:d}:{},...f?.style??{},...O(o)??{}},k=Object.keys(w).length?{style:w}:{};return r(X,{contained:C,className:`${eo} py-4`,children:r("div",{className:`flex${e?` ${no[e]}`:""}${io(to("justify",e,p,I,{atSectionLine:!m}))}`,children:r(Z,{href:i||"#",variant:A,...P,...T,...L,...k,...i&&h?{hrefRewrite:h}:{},children:oo(b)})})})}export{eo as BUTTON_BLOCK_CLASS,co as default};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { SlotComponent } from "efficient-easel/blocks";
|
|
3
|
+
import { type CardRowFieldSpec } from "../../format/lib/content/card-template.js";
|
|
3
4
|
import { type CardItemAction, type CardRowState, type CardStateLine } from "../../format/lib/content/card-state.js";
|
|
4
5
|
import type { SourceRow } from "../../format/lib/content/block-sources.js";
|
|
5
6
|
export type { CardRowState } from "../../format/lib/content/card-state.js";
|
|
@@ -7,6 +8,7 @@ export type CardRow = {
|
|
|
7
8
|
row: SourceRow;
|
|
8
9
|
index: number;
|
|
9
10
|
ownerType?: string;
|
|
11
|
+
fields?: readonly CardRowFieldSpec[];
|
|
10
12
|
item?: unknown;
|
|
11
13
|
nested?: boolean;
|
|
12
14
|
state?: CardRowState;
|
|
@@ -30,12 +32,13 @@ type CardTemplateRowsProps = {
|
|
|
30
32
|
Template: SlotComponent | undefined;
|
|
31
33
|
rows: readonly SourceRow[];
|
|
32
34
|
items?: readonly unknown[];
|
|
35
|
+
fields?: readonly CardRowFieldSpec[];
|
|
33
36
|
states?: readonly (CardRowState | undefined)[];
|
|
34
37
|
stateLine?: CardStateLine;
|
|
35
38
|
actions?: readonly (CardItemAction | undefined)[];
|
|
36
39
|
fallback: ReactNode;
|
|
37
|
-
copyAttrs?: Readonly<Record<string, string
|
|
40
|
+
copyAttrs?: Readonly<Record<string, string>> | ((row: CardRow) => Readonly<Record<string, string>>);
|
|
38
41
|
wrapCopy?: (copy: ReactNode, row: CardRow) => ReactNode;
|
|
39
42
|
children: (cards: ReactNode) => ReactNode;
|
|
40
43
|
};
|
|
41
|
-
export declare function CardTemplateRows({ ownerId, ownerType, Template, rows, items, states, stateLine, actions, fallback, copyAttrs, wrapCopy, children }: CardTemplateRowsProps): import("react").JSX.Element;
|
|
44
|
+
export declare function CardTemplateRows({ ownerId, ownerType, Template, rows, items, fields, states, stateLine, actions, fallback, copyAttrs, wrapCopy, children }: CardTemplateRowsProps): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as i,jsx as t,jsxs as
|
|
1
|
+
"use client";import{Fragment as i,jsx as t,jsxs as w}from"react/jsx-runtime";import{createContext as g,useContext as d,useId as y}from"react";import{REPEAT_ATTRIBUTE as O,REPEAT_INDEX_ATTRIBUTE as j}from"efficient-easel/draw";import{BOX_LINKED_CLASS as k}from"../../format/lib/content/box-link.js";import{CARD_TEMPLATE_SLOT as v,cardTemplateLinesBetween as F,rowFilledProps as U,templateBoxIsEmpty as X}from"../../format/lib/content/card-template.js";import{CARD_ACTION_ATTR as $,CARD_ACTION_CLASS as G,CARD_STATE_LINE_CLASS as K,CARD_STATE_UNDER_LINE_CLASS as M,cardStateAttrs as V,cardStateValue as q}from"../../format/lib/content/card-state.js";import{usePageRecordRow as z}from"./CurrentRecord.js";import{CardCopyCell as H}from"./InBoxContext.js";import{SECTION_FILL_CLASS as J}from"../../format/lib/content/section-min-height.js";function ct({props:n,editing:o,children:r}){const e=d(u);return!o&&X(n,e?.row)?null:t(i,{children:r})}const u=g(null);function at(){return d(u)}function lt({type:n,props:o,children:r}){const e=d(u),s=z(),a=e?.row??s;return t(i,{children:r(U(n,o,a,e?.ownerType,e?.fields),e,a)})}function Q({attrs:n,selected:o,press:r,children:e}){const s=y();return w("div",{...n,id:s,className:k,children:[t("button",{type:"button",[$]:"",className:G,"aria-pressed":o,"aria-labelledby":s,onClick:r}),e]})}function it({ownerId:n,ownerType:o,Template:r,rows:e,items:s,fields:a,states:L,stateLine:I,actions:N,fallback:h,copyAttrs:m,wrapCopy:p,children:D}){const x=d(u);if(!r||(r.blockCount??0)<=0)return t(i,{children:h});const b=x!==null,_=F(o),A=r.blockCount===1?t(H,{children:t(r,{className:J})}):t(r,{}),B=e.map((P,c)=>{const l=L?.[c],C={row:P,index:c,ownerType:o,item:s?.[c],nested:b,...a?{fields:a}:null,...l?{state:l}:null,..._?{linesBetween:_}:null},R=q(l)?w(i,{children:[A,t("span",{"aria-hidden":"true",className:I==="under"?M:K})]}):A,E={[O]:`${n}:${v}`,[j]:c,...typeof m=="function"?m(C):m},T=N?.[c],f=V(l),S=T?t(Q,{attrs:{...E,...f},selected:l?.selected===!0,press:T.press,children:R}):t("div",{...E,...f,children:R});return t(u.Provider,{value:C,children:p?p(S,C):S},c)});return t(i,{children:D(B)})}export{u as CardRowContext,lt as CardRowDrawn,it as CardTemplateRows,ct as RowEmptyGate,at as useCardRow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as
|
|
1
|
+
"use client";import{jsx as t,jsxs as a,Fragment as q}from"react/jsx-runtime";import{useEffect as K,useMemo as v,useRef as V,useState as d}from"react";import{dealerDistanceLabel as W,dealerPins as O,parseDealerListPosition as Q,useDealerSource as Y}from"../lib/dealer-source.js";import{groupColsClass as G}from"../../format/lib/locations-grid.js";import{say as J}from"../../format/lib/editor-words.js";import U from"./SiteMap.js";import X,{SIDE_MAP_CLASS as Z}from"./SideListLayout.js";const D={near:null,dealers:[]},H=5;function ee({mapLabel:n,mapTheme:p,search:h,searchHint:l,noMatchText:u,listPosition:f,showDistance:L,editing:z}){const o=Y(),[s,m]=d(D),[N,M]=d(""),[E,w]=d(!1),[S,g]=d(null),[B,I]=d(null),b=V(null);K(()=>{if(!o)return;let e=!0;return o({}).then(r=>e&&m(r)).catch(()=>e&&m(D)),()=>{e=!1}},[o]);const i=v(()=>O(s.dealers),[s.dealers]),R=v(()=>new Set(i.map(e=>e.key)),[i]),F=v(()=>s.near==="found"?i.slice(0,H).map(e=>e.key):null,[s.near,i]),P=e=>{g(e),R.has(e)&&I(r=>({key:e,n:(r?.n??0)+1}))},T=e=>{g(e),b.current?.querySelector(`[data-dealer="${CSS.escape(e)}"]`)?.scrollIntoView({block:"nearest"})};if(!o)return z?t("p",{"data-dealers-unavailable":!0,className:"font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.24em] text-fg-dim",children:J("Dealers are not available on this website")}):null;const A=e=>{e.preventDefault();const r=N.trim();w(!0),g(null),o(r?{near:r}:{}).then(m).catch(()=>m($=>({...$,near:"try_again"}))).finally(()=>w(!1))},x=Q(f),k=x!=="below",y=s.near==="not_found"||s.near==="try_again",_=h?a("form",{role:"search",onSubmit:A,className:"mb-4 flex gap-2",children:[t("input",{type:"search",value:N,onChange:e=>M(e.target.value),placeholder:l,"aria-label":l,"aria-invalid":y||void 0,className:["min-w-0 flex-1 border bg-bg px-3 py-2 text-[length:var(--size-body,14px)] text-fg outline-none",y?"border-accent":"border-line focus:border-fg"].join(" ")}),t("button",{type:"submit","aria-label":l,disabled:E,className:"grid w-10 shrink-0 place-items-center bg-fg text-bg disabled:opacity-50",children:a("svg",{"aria-hidden":!0,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t("circle",{cx:"11",cy:"11",r:"7"}),t("path",{d:"M20 20l-3.5-3.5"})]})})]}):null,j=y&&u?t("p",{role:"status",className:"mb-3 text-[length:var(--size-body,14px)] text-fg-dim",children:u}):null,c=s.dealers.map(e=>t(te,{dealer:e,active:S===e.id,onSelect:()=>P(e.id),distance:L?W(e.distanceKm):"",tile:!k},e.id)),C=t(U,{pins:i,mapTheme:p,selectedKey:S,focus:B,onSelect:T,ariaLabel:n,className:Z,groupCrowded:!0,fitTo:F});return k?t(X,{position:x,attrs:{"data-dealer-finder":x},head:a(q,{children:[_,j]}),listRef:b,list:c,map:C}):a("div",{"data-dealer-finder":"below",children:[_,j,C,c.length>0&&t("div",{ref:b,className:["mt-12 grid gap-[2px] bg-bg",G(c.length),c.length>2?"max-view-desktop:grid-cols-2 max-[700px]:grid-cols-1":"max-[700px]:grid-cols-1"].join(" "),children:c})]})}function te({dealer:n,active:p,onSelect:h,distance:l,tile:u}){const f=[n.city,[n.state,n.postcode].filter(Boolean).join(" ")].filter(Boolean).join(" ");return a("div",{"data-dealer":n.id,className:["flex gap-3 bg-bg text-left outline outline-1 -outline-offset-1",u?"px-6 py-5":"border-b border-line px-1 py-4",p?"outline-accent":"outline-transparent hover:outline-line"].join(" "),children:[a("button",{type:"button",onClick:h,"aria-pressed":p,className:"min-w-0 flex-1 text-left",children:[t("span",{className:"block font-display text-[length:var(--size-body,16px)] font-medium leading-[1.25] text-fg",children:n.name}),n.address&&t("span",{className:"mt-1 block text-[length:var(--size-body,14px)] text-fg-dim",children:n.address}),f&&t("span",{className:"block text-[length:var(--size-body,14px)] text-fg-dim",children:f})]}),a("span",{className:"flex shrink-0 flex-col items-end gap-1 text-[length:var(--size-body,14px)]",children:[l&&t("span",{className:"text-fg-dim",children:l}),n.phone&&t("a",{href:`tel:${n.phone.replace(/[^\d+]/g,"")}`,className:"text-fg underline underline-offset-2",children:n.phone}),n.website&&t("a",{href:n.website,target:"_blank",rel:"noopener noreferrer",className:"text-fg underline underline-offset-2",children:n.website.replace(/^https?:\/\//,"").replace(/\/$/,"")})]})]})}export{ee as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as f}from"react/jsx-runtime";import m from"./SectionEyebrow.js";import{DEFAULT_EYEBROW_BLOCK_LOOK as a}from"../../format/lib/sections/section-eyebrow-look.js";import{alignViewClasses as l}from"../../format/lib/content/block-align.js";import{useInBox as c}from"./InBoxContext.js";const p={left:"",center:"justify-center",right:"justify-end"};function u({text:o,align:e="left",alignTablet:r,alignPhone:i,look:t=a,takesViewHide:n=!1}){const s=c();return f(m,{text:o,look:t,takesViewHide:n,classNameAfter:t==="line"?[p[e],l("justify",e,r,i,{atSectionLine:!s})].filter(Boolean).join(" "):""})}export{p as ALIGN_JUSTIFY,u as default};
|
|
@@ -67,6 +67,7 @@ interface FlexProps {
|
|
|
67
67
|
upcoming?: unknown;
|
|
68
68
|
link?: unknown;
|
|
69
69
|
rowLink?: string;
|
|
70
|
+
rowImage?: string;
|
|
70
71
|
highlight?: Record<string, string> | null;
|
|
71
72
|
boxShape?: unknown;
|
|
72
73
|
boxShapePhone?: unknown;
|
|
@@ -88,5 +89,5 @@ interface FlexProps {
|
|
|
88
89
|
rowStyle?: unknown;
|
|
89
90
|
sideSpace?: unknown;
|
|
90
91
|
}
|
|
91
|
-
export default function Flex({ direction: storedDirection, label, tabShape, gap, gapPhone, gapTablet, justify, align, wrap, share: storedShare, sharePhone, shareTablet, wrapPhone, orderPhone: storedOrderPhone, phoneRow, columns, columnsTablet, separator, stackBelow, blockSpacing, bgImage, bgImagePhone, pictureHover, darken, darkenStyle, darkenTablet, darkenPhone, darkenStyleTablet, darkenStylePhone, placement, padV2, border: storedBorder, borderTablet: storedBorderTablet, borderPhone: storedBorderPhone, pad, contained, fillHeight, shadow, shadowTablet, shadowPhone, justifyTablet, justifyPhone, alignTablet, alignPhone, wrapTablet, blockSpacingTablet, blockSpacingPhone, loop, scrollDirection, loopSeconds, loopDelay, editing, fillColor, fillColorTablet, fillColorPhone, swatch, line, upcoming, link, rowLink, highlight, boxShape, boxShapePhone, boxShapeTablet, angle, jumpHighlight, anchor, sharedSides, sharedRows, boxId, slotCount, mirrorCards, content: Content, rowTitle: RowTitle, startsOpen, rowStyle, sideSpace, }: FlexProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
92
|
+
export default function Flex({ direction: storedDirection, label, tabShape, gap, gapPhone, gapTablet, justify, align, wrap, share: storedShare, sharePhone, shareTablet, wrapPhone, orderPhone: storedOrderPhone, phoneRow, columns, columnsTablet, separator, stackBelow, blockSpacing, bgImage: storedBgImage, bgImagePhone: storedBgImagePhone, rowImage: storedRowImage, pictureHover, darken, darkenStyle, darkenTablet, darkenPhone, darkenStyleTablet, darkenStylePhone, placement, padV2, border: storedBorder, borderTablet: storedBorderTablet, borderPhone: storedBorderPhone, pad, contained, fillHeight, shadow, shadowTablet, shadowPhone, justifyTablet, justifyPhone, alignTablet, alignPhone, wrapTablet, blockSpacingTablet, blockSpacingPhone, loop, scrollDirection, loopSeconds, loopDelay, editing, fillColor, fillColorTablet, fillColorPhone, swatch, line, upcoming, link, rowLink, highlight, boxShape, boxShapePhone, boxShapeTablet, angle, jumpHighlight, anchor, sharedSides: storedSharedSides, sharedRows: storedSharedRows, boxId, slotCount, mirrorCards, content: Content, rowTitle: RowTitle, startsOpen, rowStyle, sideSpace, }: FlexProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
92
93
|
export {};
|