tempest-react-sdk 0.72.0 → 0.74.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/README.md +6 -4
- package/dist/br/MapMarkers.cjs +1 -1
- package/dist/br/MapMarkers.cjs.map +1 -1
- package/dist/br/MapMarkers.js +19 -22
- package/dist/br/MapMarkers.js.map +1 -1
- package/dist/components/AIChat/AIChatTurn.cjs +1 -1
- package/dist/components/AIChat/AIChatTurn.cjs.map +1 -1
- package/dist/components/AIChat/AIChatTurn.js +1 -1
- package/dist/components/AIChat/AIChatTurn.js.map +1 -1
- package/dist/components/AppShell/AppShell.module.cjs.map +1 -1
- package/dist/components/AppShell/AppShell.module.js.map +1 -1
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.js +41 -36
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.module.cjs.map +1 -1
- package/dist/components/Button/Button.module.js.map +1 -1
- package/dist/components/Button/ButtonContent.cjs +2 -0
- package/dist/components/Button/ButtonContent.cjs.map +1 -0
- package/dist/components/Button/ButtonContent.js +34 -0
- package/dist/components/Button/ButtonContent.js.map +1 -0
- package/dist/components/Button/ButtonSlot.cjs +2 -0
- package/dist/components/Button/ButtonSlot.cjs.map +1 -0
- package/dist/components/Button/ButtonSlot.js +36 -0
- package/dist/components/Button/ButtonSlot.js.map +1 -0
- package/dist/components/Button/button-class.cjs +2 -0
- package/dist/components/Button/button-class.cjs.map +1 -0
- package/dist/components/Button/button-class.js +13 -0
- package/dist/components/Button/button-class.js.map +1 -0
- package/dist/components/Button/link-rel.cjs +2 -0
- package/dist/components/Button/link-rel.cjs.map +1 -0
- package/dist/components/Button/link-rel.js +11 -0
- package/dist/components/Button/link-rel.js.map +1 -0
- package/dist/components/Button/slot.cjs +2 -0
- package/dist/components/Button/slot.cjs.map +1 -0
- package/dist/components/Button/slot.js +41 -0
- package/dist/components/Button/slot.js.map +1 -0
- package/dist/components/Collapsible/Collapsible.cjs +1 -1
- package/dist/components/Collapsible/Collapsible.cjs.map +1 -1
- package/dist/components/Collapsible/Collapsible.js +1 -1
- package/dist/components/Collapsible/Collapsible.js.map +1 -1
- package/dist/components/Form/Form.cjs.map +1 -1
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/InstallButton/InstallButton.cjs.map +1 -1
- package/dist/components/InstallButton/InstallButton.js.map +1 -1
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.js +1 -1
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/Modal/Modal.module.cjs +1 -1
- package/dist/components/Modal/Modal.module.cjs.map +1 -1
- package/dist/components/Modal/Modal.module.js +1 -1
- package/dist/components/Modal/Modal.module.js.map +1 -1
- package/dist/components/Page/Page.cjs +1 -1
- package/dist/components/Page/Page.cjs.map +1 -1
- package/dist/components/Page/Page.js +23 -39
- package/dist/components/Page/Page.js.map +1 -1
- package/dist/components/Page/Page.module.cjs +1 -1
- package/dist/components/Page/Page.module.cjs.map +1 -1
- package/dist/components/Page/Page.module.js +5 -11
- package/dist/components/Page/Page.module.js.map +1 -1
- package/dist/components/Reveal/Reveal.cjs +2 -0
- package/dist/components/Reveal/Reveal.cjs.map +1 -0
- package/dist/components/Reveal/Reveal.js +56 -0
- package/dist/components/Reveal/Reveal.js.map +1 -0
- package/dist/components/Reveal/Reveal.module.cjs +3 -0
- package/dist/components/Reveal/Reveal.module.cjs.map +1 -0
- package/dist/components/Reveal/Reveal.module.js +7 -0
- package/dist/components/Reveal/Reveal.module.js.map +1 -0
- package/dist/components/Reveal/reveal-threshold.cjs +2 -0
- package/dist/components/Reveal/reveal-threshold.cjs.map +1 -0
- package/dist/components/Reveal/reveal-threshold.js +13 -0
- package/dist/components/Reveal/reveal-threshold.js.map +1 -0
- package/dist/components/SectionHeader/SectionHeader.cjs +2 -0
- package/dist/components/SectionHeader/SectionHeader.cjs.map +1 -0
- package/dist/components/SectionHeader/SectionHeader.js +58 -0
- package/dist/components/SectionHeader/SectionHeader.js.map +1 -0
- package/dist/components/SectionHeader/SectionHeader.module.cjs +3 -0
- package/dist/components/SectionHeader/SectionHeader.module.cjs.map +1 -0
- package/dist/components/SectionHeader/SectionHeader.module.js +15 -0
- package/dist/components/SectionHeader/SectionHeader.module.js.map +1 -0
- package/dist/components/Timeline/Timeline.cjs +1 -1
- package/dist/components/Timeline/Timeline.cjs.map +1 -1
- package/dist/components/Timeline/Timeline.js +22 -15
- package/dist/components/Timeline/Timeline.js.map +1 -1
- package/dist/components/Timeline/Timeline.module.cjs +1 -1
- package/dist/components/Timeline/Timeline.module.cjs.map +1 -1
- package/dist/components/Timeline/Timeline.module.js +1 -1
- package/dist/components/Timeline/Timeline.module.js.map +1 -1
- package/dist/styles/Reveal.css +2 -0
- package/dist/styles/SectionHeader.css +2 -0
- package/dist/styles/actions.css +24 -22
- package/dist/styles/base.css +3 -1
- package/dist/styles/component/AppShell.css +1 -1
- package/dist/styles/component/Button.css +24 -22
- package/dist/styles/component/Modal.css +2 -2
- package/dist/styles/component/Page.css +0 -6
- package/dist/styles/component/Reveal.css +9 -0
- package/dist/styles/component/SectionHeader.css +9 -0
- package/dist/styles/component/Timeline.css +5 -5
- package/dist/styles/core.css +3 -1
- package/dist/styles/data.css +5 -5
- package/dist/styles/inverse.css +147 -0
- package/dist/styles/layout.css +9 -7
- package/dist/styles/manifest.json +14 -1
- package/dist/styles/overlay.css +2 -2
- package/dist/styles/utility.css +8 -0
- package/dist/styles.css +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +353 -4
- package/dist/tempest-react-sdk.js +350 -346
- package/dist/theme/create-theme.cjs +3 -3
- package/dist/theme/create-theme.cjs.map +1 -1
- package/dist/theme/create-theme.js +67 -55
- package/dist/theme/create-theme.js.map +1 -1
- package/dist/theme/inverse-render.cjs +3 -0
- package/dist/theme/inverse-render.cjs.map +1 -0
- package/dist/theme/inverse-render.js +10 -0
- package/dist/theme/inverse-render.js.map +1 -0
- package/dist/theme/inverse-surface.cjs +2 -0
- package/dist/theme/inverse-surface.cjs.map +1 -0
- package/dist/theme/inverse-surface.js +258 -0
- package/dist/theme/inverse-surface.js.map +1 -0
- package/dist/theme/status-tokens.cjs +2 -0
- package/dist/theme/status-tokens.cjs.map +1 -0
- package/dist/theme/status-tokens.js +15 -0
- package/dist/theme/status-tokens.js.map +1 -0
- package/dist/vision/core/graph.cjs.map +1 -1
- package/dist/vision/core/graph.js.map +1 -1
- package/dist/vision/core/metadata.cjs +2 -2
- package/dist/vision/core/metadata.cjs.map +1 -1
- package/dist/vision/core/metadata.js +101 -29
- package/dist/vision/core/metadata.js.map +1 -1
- package/dist/vision/core/session.cjs +1 -1
- package/dist/vision/core/session.cjs.map +1 -1
- package/dist/vision/core/session.js +59 -48
- package/dist/vision/core/session.js.map +1 -1
- package/dist/vision/index.cjs +1 -1
- package/dist/vision/index.cjs.map +1 -1
- package/dist/vision/index.js +1 -1
- package/dist/vision/index.js.map +1 -1
- package/dist/vision.d.ts +25 -21
- package/dist/vite/create-vite-config.cjs +1 -1
- package/dist/vite/create-vite-config.cjs.map +1 -1
- package/dist/vite/create-vite-config.js +6 -4
- package/dist/vite/create-vite-config.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./color.cjs"),t=require("./data-viz-ramps.cjs");require("./inverse-render.cjs");const n=require("./status-tokens.cjs");var r=4.5,i=4.75,a=3,o=4.5,s=7,c=[500,600,400,700,300,800,200,900],l={dark:{surfaces:[.046,.094,.14],border:.155,borderStrong:.222},light:{surfaces:[.018,.037,.073],border:.073,borderStrong:.128}},u=.1,d={dark:`#ffffff`,light:`#101828`},f={success:`#16a34a`,warning:`#d97706`,danger:`#dc2626`,info:`#2563eb`},p={light:[`#2563eb`,`#16a34a`,`#f59e0b`,`#7c3aed`,`#ec4899`,`#06b6d4`,`#ea580c`,`#0f766e`],dark:[`#60a5fa`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f472b6`,`#22d3ee`,`#fb923c`,`#2dd4bf`]},m=[`comment`,`punctuation`,`string`,`number`,`keyword`,`literal`,`function`,`tag`,`attribute`,`property`],h={light:[`#5f666e`,`#5d6671`,`#327243`,`#9d5035`,`#625baf`,`#9f4c4f`,`#1a6c94`,`#974d72`,`#127171`,`#127171`],dark:[`#838b93`,`#818b95`,`#589866`,`#c57558`,`#8580d8`,`#c87172`,`#2893c6`,`#c07197`,`#349897`,`#349897`]},g={light:{xs:`0 1px 2px rgba(15, 23, 42, 0.04)`,sm:`0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04)`,md:`0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04)`,lg:`0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06)`,xl:`0 24px 48px rgba(15, 23, 42, 0.18), 0 8px 16px rgba(15, 23, 42, 0.08)`,inner:`inset 0 2px 4px rgba(15, 23, 42, 0.06)`},dark:{xs:`0 1px 2px rgba(0, 0, 0, 0.3)`,sm:`0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2)`,md:`0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2)`,lg:`0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3)`,xl:`0 24px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.3)`,inner:`inset 0 2px 4px rgba(15, 23, 42, 0.06)`}},_=.005;function v(t,n,r,i=t.c){let a=Math.min(1,Math.max(0,t.l+n*r));return e.oklchToHex({l:a,c:i,h:t.h})}function y(t,n){return Math.min(...n.map(n=>e.contrastRatio(t,n)))}function b(t,n,r,i,a){let o=e.hexToOklch(t);for(let e=0;e<=1;e+=_){let t=v(o,n,e);if(y(t,r)>=i)return t;if(n===1&&o.l+e>=1||n===-1&&o.l-e<=0)break}return a}var x={dark:.07,light:.05},S=1.6;function C(e,t,n,r){for(let a=n;a>_;a-=_){let n=[v(e,t,a),v(e,t,a*S)];if(y(r,n)>=i)return n}return[v(e,t,-n),v(e,t,-n*S)]}function w(e,t,n){let r=e=>[1,3,5].map(t=>Number.parseInt(e.slice(t,t+2),16)),[i,a]=[r(e),r(t)];return`#${i.map((e,t)=>Math.round(e+(a[t]-e)*n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function T(r,s){let c=e.readableForeground(r,d.dark,d.light),_=c===d.dark?`dark`:`light`,S=_===`dark`?1:-1,T=e.hexToOklch(r),E=l[_],D={},O=[r,...E.surfaces.map(e=>v(T,S,-e))],[k,A,j,M]=O,N=v(T,S,u),P=[...O,N];D[`--tempest-bg`]=k,D[`--tempest-surface`]=A,D[`--tempest-surface-2`]=j,D[`--tempest-surface-3`]=M,D[`--tempest-border`]=v(T,S,E.border),D[`--tempest-border-strong`]=v(T,S,E.borderStrong);let F=y(c,P),I=T.c*.4;D[`--tempest-text`]=c,D[`--tempest-text-muted`]=b(v(T,S,0,I),S,P,Math.max(i,Math.sqrt(F*i)),c),D[`--tempest-text-subtle`]=b(v(T,S,0,I),S,[k,A,N],i,c);let L={...e.hexToOklch(c),h:T.h};D[`--tempest-primary`]=c,D[`--tempest-primary-hover`]=v(L,S,-.05,T.c*.25),D[`--tempest-primary-active`]=v(L,S,-.1,T.c*.3),D[`--tempest-primary-foreground`]=r,D[`--tempest-text-on-primary`]=r;let[R,z]=C(T,S,x[_],c);D[`--tempest-primary-soft`]=R,D[`--tempest-primary-soft-hover`]=z,D[`--tempest-primary-on-soft`]=b(R,S,[R,z],i,c);let B=b(r,S,P,o,c);D[`--tempest-focus-ring-color`]=B,D[`--tempest-selected-indicator`]=B;let V=e.createColorScale(s.primary,_,{anchor:!1});for(let[e,t]of Object.entries(V))D[`--tempest-primary-${e}`]=t;for(let t of n.THEME_STATUSES){let r=e.createColorScale(s.statuses?.[t]??f[t],_);n.writeStatus(D,t,r,_),D[`--tempest-${t}`]=b(D[`--tempest-${t}`],S,P,i,c),t===`danger`&&(D[`--tempest-danger-hover`]=r[D[`--tempest-danger-on-solid`]===`#ffffff`?_===`dark`?400:700:_===`dark`?600:500])}(s.chart?.length?s.chart:p[_]).forEach((e,t)=>{D[`--tempest-chart-${t+1}`]=b(e,S,[k,A,N],a,c)});let H=t.hueOf(s.chart?.[0]??s.primary),U=s.statuses?.danger?t.hueOf(s.statuses.danger):(H+180)%360;t.buildRamp(H,_).forEach((e,t)=>{D[`--tempest-chart-sequential-${t+1}`]=e});let W=t.buildDivergingRamp({coolHue:H,warmHue:U,mid:M,mode:_});[...W.cool,W.mid,...W.warm].forEach((e,t)=>{D[`--tempest-chart-diverging-${t+1}`]=e}),D[`--tempest-chart-grid`]=D[`--tempest-border`],D[`--tempest-chart-axis`]=D[`--tempest-text-subtle`];let G=[k,A,w(A,c,.1)];m.forEach((e,t)=>{D[`--tempest-code-${e}`]=b(h[_][t],S,G,i,c)});for(let[e,t]of Object.entries(g[_]))D[`--tempest-shadow-${e}`]=t;return{tokens:D,scheme:_,glow:N}}function E(e,t){let n=t=>e[t],i=[n(`--tempest-bg`),n(`--tempest-surface`),n(`--tempest-surface-2`),n(`--tempest-surface-3`)],o=n(`--tempest-primary-foreground`),c=[y(n(`--tempest-text`),[...i,t])/s,y(n(`--tempest-text-muted`),[...i,t])/r,y(n(`--tempest-text-subtle`),[...i.slice(0,2),t])/r,y(n(`--tempest-focus-ring-color`),[...i,t])/a,y(o,[n(`--tempest-primary`),n(`--tempest-primary-hover`),n(`--tempest-primary-active`)])/r];return Math.min(...c)-1}function D(t){let n=e.createColorScale(t.primary,`light`),r=null,i=-1/0;for(let e of c){let a=T(n[e],t),o=E(a.tokens,a.glow);if(o>=0)return{tokens:a.tokens,scheme:a.scheme,step:e};o>i&&(r={tokens:a.tokens,scheme:a.scheme,step:e},i=o)}return r}exports.DEFAULT_CHART_COLORS=p,exports.DEFAULT_CODE_COLORS=h,exports.DEFAULT_STATUS_COLORS=f,exports.createInverseSurface=D;
|
|
2
|
+
//# sourceMappingURL=inverse-surface.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inverse-surface.cjs","names":[],"sources":["../../src/theme/inverse-surface.ts"],"sourcesContent":["/**\n * @tempest-limits file-lines — the inverse surface is a whole scheme: surfaces,\n * text, the action color, focus, selection, statuses, charts and syntax colors,\n * each derived and then measured against the brand fill it sits on. Splitting\n * the derivation from the table it is measured against is how the two drift.\n */\n/**\n * Inverse surface: the token set for a section painted in the brand color —\n * a hero, a call-to-action band, a footer — so the components inside it invert\n * instead of inheriting the page's tokens.\n *\n * Every value is derived from the brand and measured against the fill it will\n * sit on, the same way {@link createTheme} measures the page schemes. Overriding\n * eight tokens by hand (what #409 had to do) leaves the rest of the scheme on\n * the page's values: measured over a navy `#1e2a5a`, the inherited\n * `--tempest-text-subtle` lands at 2.75:1, `--tempest-danger` at 2.12:1, the\n * selected indicator at 2.01:1, and a `Card` puts white text on\n * `--tempest-surface` at 1.05:1.\n */\nimport {\n contrastRatio,\n createColorScale,\n hexToOklch,\n oklchToHex,\n readableForeground,\n type ColorScale,\n type Oklch,\n type ScaleStep,\n} from \"./color\";\nimport { buildDivergingRamp, buildRamp, hueOf } from \"./data-viz-ramps\";\nimport type { InverseScheme, InverseSurface, InverseSurfaceOptions } from \"./inverse-render\";\nimport { THEME_STATUSES, writeStatus, type ThemeStatus } from \"./status-tokens\";\n\nexport { INVERSE_SELECTOR, renderInverseSurface } from \"./inverse-render\";\nexport type {\n InverseScheme,\n InverseSurface,\n InverseSurfaceGenerator,\n InverseSurfaceOptions,\n} from \"./inverse-render\";\n\n/** WCAG 2.x AA floor for body text. */\nconst AA_TEXT = 4.5;\n\n/**\n * What text is fitted to, rather than the floor itself.\n *\n * The margin the SDK's dark theme keeps on `--tempest-text-subtle` (4.79 over its\n * surface): a value solved to exactly 4.5 turns the next rounding into a failure.\n */\nconst TEXT_TARGET = 4.75;\n\n/** WCAG 2.2 SC 1.4.11 floor for a non-text indicator. */\nconst INDICATOR_FLOOR = 3;\n\n/**\n * What the focus ring and the selected indicator are fitted to.\n *\n * Well above the 3:1 floor on purpose: the SDK's own rings keep 5.40:1 (dark)\n * and 5.50:1 (light) worst case, because a ring travels onto surfaces nobody\n * validated it against.\n */\nconst RING_TARGET = 4.5;\n\n/**\n * The smallest contrast the ink must keep — on the fill, the surfaces and the\n * glow — before the fill is accepted.\n *\n * AA (4.5) is not enough here, because the surface has three text levels — text,\n * muted and subtle — and all three must clear AA. With text at 4.83:1 (white on\n * the default `#0066ff`) the three collapse into one color. 7:1 (AAA) leaves room\n * for muted to sit visibly between text and subtle.\n */\nconst MIN_TEXT_RATIO = 7;\n\n/**\n * Fill candidates, nearest the brand first, darker before lighter on a tie.\n *\n * `500` is the brand itself and wins whenever it can carry the scheme. When it\n * cannot — a mid-tone brand such as `#0066ff`, where white measures 4.83:1 —\n * the walk moves one step at a time, so the section stays as close to the brand\n * as the measurement allows.\n *\n * Measuring the glow is what most of the walking pays for: against the flat\n * fill and the surfaces alone, 9 of the 14 test brands keep their `500`; with\n * the glow, 6 do. The three that move (`#8100D7`, `#22d3ee`, `#14b8a6`) are the\n * ones whose subtle text would fail on a lifted region of their own band.\n */\nconst FILL_CANDIDATES: readonly ScaleStep[] = [500, 600, 400, 700, 300, 800, 200, 900];\n\n/**\n * Lightness offsets from the fill, per scheme.\n *\n * The sizes are the SDK's own, measured in OKLCH: the dark theme's surfaces sit\n * 0.046, 0.094 and 0.140 from `#0b0d12`, its borders 0.155 and 0.222; the light\n * theme's surfaces sit 0.018, 0.037 and 0.073 from white, its borders 0.073 and\n * 0.128.\n *\n * The direction is not the SDK's. On the page, raised surfaces move toward the\n * ink, which costs nothing there: the page fill is near-white or near-black, so\n * the ink keeps 13:1 or more on the third surface. A brand fill sits mid-axis,\n * and moving toward the ink spends exactly the contrast the text needs. Measured\n * across the fourteen brands of the contrast test, every text level held to AA\n * on every surface and on the glow ({@link GLOW_OFFSET}):\n *\n * | surfaces move | brands keeping their own `500` | where `#8100D7` / `#4f46e5` land |\n * | --- | --- | --- |\n * | toward the ink | 6 of 14 | `800` / `800` |\n * | away from the ink | 6 of 14 | `700` / `700` |\n *\n * Never worse and one step nearer the brand for the purples, and with every\n * surface carrying the ink at least as well as the fill does.\n *\n * So surfaces move away from the ink — a card in a navy band is a deeper navy,\n * one in a yellow band a paler yellow — and every surface then carries the ink\n * at least as well as the fill does. Borders still move toward the ink, since a\n * border has to separate from the fill and the surfaces alike.\n */\nconst OFFSETS: Record<\n InverseScheme,\n { surfaces: readonly [number, number, number]; border: number; borderStrong: number }\n> = {\n dark: { surfaces: [0.046, 0.094, 0.14], border: 0.155, borderStrong: 0.222 },\n light: { surfaces: [0.018, 0.037, 0.073], border: 0.073, borderStrong: 0.128 },\n};\n\n/**\n * How far toward the ink a region of the band may lift and still be measured.\n *\n * A brand section is rarely one flat color: the landing that opened #409 lays a\n * radial glow of `#1f3f8f` at 55% over its navy `#03184b`, which lifts the\n * ground by 0.09 in OKLCH lightness, and a hover tint does the same. Text fitted\n * to the flat fill alone failed there — subtle measured 3.64:1 on that glow. So\n * every text and indicator token is also fitted against the fill lifted by this\n * much; darker variations (the landing's `#020f30` footer) only add contrast.\n */\nconst GLOW_OFFSET = 0.1;\n\n/** Text ink per scheme — the SDK's own extremes. */\nconst INK: Record<InverseScheme, string> = { dark: \"#ffffff\", light: \"#101828\" };\n\n/**\n * The SDK's default status colors, used when a theme names none.\n *\n * Ported from `src/styles/colors.css` (`--tempest-*-solid` in the light block),\n * and pinned by a test that reads that file.\n */\nexport const DEFAULT_STATUS_COLORS: Record<ThemeStatus, string> = {\n success: \"#16a34a\",\n warning: \"#d97706\",\n danger: \"#dc2626\",\n info: \"#2563eb\",\n};\n\n/**\n * The SDK's categorical chart colors, per scheme.\n *\n * Ported from `src/styles/colors.css` (`--tempest-chart-1` … `-8`), pinned by a\n * test that reads that file. Used as the starting hue for each slot, then fitted\n * to the inverse fill.\n */\nexport const DEFAULT_CHART_COLORS: Record<InverseScheme, readonly string[]> = {\n light: [\"#2563eb\", \"#16a34a\", \"#f59e0b\", \"#7c3aed\", \"#ec4899\", \"#06b6d4\", \"#ea580c\", \"#0f766e\"],\n dark: [\"#60a5fa\", \"#4ade80\", \"#fbbf24\", \"#a78bfa\", \"#f472b6\", \"#22d3ee\", \"#fb923c\", \"#2dd4bf\"],\n};\n\n/** Names of the `CodeBlock` syntax tokens, in `colors.css` order. */\nconst CODE_TOKENS = [\n \"comment\",\n \"punctuation\",\n \"string\",\n \"number\",\n \"keyword\",\n \"literal\",\n \"function\",\n \"tag\",\n \"attribute\",\n \"property\",\n] as const;\n\n/**\n * The SDK's syntax colors, per scheme, in {@link CODE_TOKENS} order.\n *\n * Ported from `src/styles/colors.css` (`--tempest-code-*`), pinned by a test\n * that reads that file. Used as the starting hue, then fitted to the inverse\n * code grounds.\n */\nexport const DEFAULT_CODE_COLORS: Record<InverseScheme, readonly string[]> = {\n light: [\n \"#5f666e\",\n \"#5d6671\",\n \"#327243\",\n \"#9d5035\",\n \"#625baf\",\n \"#9f4c4f\",\n \"#1a6c94\",\n \"#974d72\",\n \"#127171\",\n \"#127171\",\n ],\n dark: [\n \"#838b93\",\n \"#818b95\",\n \"#589866\",\n \"#c57558\",\n \"#8580d8\",\n \"#c87172\",\n \"#2893c6\",\n \"#c07197\",\n \"#349897\",\n \"#349897\",\n ],\n};\n\n/**\n * The SDK's elevation shadows, per scheme.\n *\n * Ported from `src/styles/colors.css` (`--tempest-shadow-*`). A light-ink fill\n * takes the dark theme's heavier shadows, since a faint shadow vanishes on it.\n * The dark block does not override `--tempest-shadow-inner`, so the dark row\n * carries the light value it inherits.\n */\nconst SHADOWS: Record<InverseScheme, Record<string, string>> = {\n light: {\n xs: \"0 1px 2px rgba(15, 23, 42, 0.04)\",\n sm: \"0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04)\",\n md: \"0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04)\",\n lg: \"0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06)\",\n xl: \"0 24px 48px rgba(15, 23, 42, 0.18), 0 8px 16px rgba(15, 23, 42, 0.08)\",\n inner: \"inset 0 2px 4px rgba(15, 23, 42, 0.06)\",\n },\n dark: {\n xs: \"0 1px 2px rgba(0, 0, 0, 0.3)\",\n sm: \"0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2)\",\n md: \"0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2)\",\n lg: \"0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3)\",\n xl: \"0 24px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.3)\",\n inner: \"inset 0 2px 4px rgba(15, 23, 42, 0.06)\",\n },\n};\n\n/** Lightness step used when fitting a color toward the ink. */\nconst FIT_STEP = 0.005;\n\n/**\n * Move a color along the lightness axis toward (positive `delta`) or away from\n * the ink, keeping its hue.\n *\n * @param base - The color to move, in OKLCH.\n * @param direction - `1` when the ink is lighter than the fill, `-1` otherwise.\n * @param delta - How far to move, in OKLCH lightness.\n * @param chroma - Chroma of the result; defaults to the base's.\n * @returns The moved color as hex, gamut-mapped.\n */\nfunction shift(base: Oklch, direction: 1 | -1, delta: number, chroma: number = base.c): string {\n const l = Math.min(1, Math.max(0, base.l + direction * delta));\n return oklchToHex({ l, c: chroma, h: base.h });\n}\n\n/** Weakest contrast of `color` against every ground. */\nfunction worst(color: string, grounds: readonly string[]): number {\n return Math.min(...grounds.map((ground) => contrastRatio(color, ground)));\n}\n\n/**\n * Walk a color toward the ink until it clears `floor` against every ground.\n *\n * Hue and chroma are kept, so a danger stays red and a keyword stays violet;\n * only lightness moves, and only as far as the measurement asks. When the walk\n * reaches the end of the lightness axis without clearing, the ink itself is\n * returned — it is the most contrasting color the scheme has.\n *\n * @param start - Where to start, as hex.\n * @param direction - `1` when the ink is lighter than the grounds, `-1` otherwise.\n * @param grounds - Every background the color will sit on.\n * @param floor - The ratio to clear against all of them.\n * @param ink - Fallback when nothing on the walk clears.\n * @returns The first color on the walk that clears, else `ink`.\n */\nfunction fitToward(\n start: string,\n direction: 1 | -1,\n grounds: readonly string[],\n floor: number,\n ink: string,\n): string {\n const base = hexToOklch(start);\n for (let delta = 0; delta <= 1; delta += FIT_STEP) {\n const candidate = shift(base, direction, delta);\n if (worst(candidate, grounds) >= floor) return candidate;\n if ((direction === 1 && base.l + delta >= 1) || (direction === -1 && base.l - delta <= 0)) {\n break;\n }\n }\n return ink;\n}\n\n/**\n * How far the soft tint sits from the fill, per scheme; the hover tint sits\n * {@link SOFT_HOVER_FACTOR} times as far.\n */\nconst SOFT_OFFSET: Record<InverseScheme, number> = { dark: 0.07, light: 0.05 };\n\n/** Distance of the soft hover tint, relative to the soft tint's. */\nconst SOFT_HOVER_FACTOR = 1.6;\n\n/**\n * The soft tint and its hover, lifted toward the ink only as far as the ink\n * still reads on both.\n *\n * A tint toward the ink is what reads as \"highlighted\" on a fill, and it is also\n * what eats the ink's contrast: on the `#8100D7` fill, the full offset left white\n * at 4.42:1 on the hover tint. So the offset shrinks until the ink clears\n * {@link TEXT_TARGET} on both, and when even a sliver cannot — the fill gives the\n * ink no room — the tints move away from the ink instead, like the surfaces.\n *\n * @param base - The fill, in OKLCH.\n * @param direction - `1` when the ink is lighter than the fill, `-1` otherwise.\n * @param offset - The preferred distance of the soft tint.\n * @param ink - The scheme's text ink.\n * @returns The soft tint and its hover, as hex.\n */\nfunction softTints(base: Oklch, direction: 1 | -1, offset: number, ink: string): [string, string] {\n for (let delta = offset; delta > FIT_STEP; delta -= FIT_STEP) {\n const tints: [string, string] = [\n shift(base, direction, delta),\n shift(base, direction, delta * SOFT_HOVER_FACTOR),\n ];\n if (worst(ink, tints) >= TEXT_TARGET) return tints;\n }\n return [shift(base, direction, -offset), shift(base, direction, -offset * SOFT_HOVER_FACTOR)];\n}\n\n/** Mix `top` over `bottom` at `amount`, the way `color-mix(in srgb, …)` composites. */\nfunction mix(bottom: string, top: string, amount: number): string {\n const parse = (hex: string): number[] =>\n [1, 3, 5].map((index) => Number.parseInt(hex.slice(index, index + 2), 16));\n const [a, b] = [parse(bottom), parse(top)];\n const channels = a.map((channel, index) =>\n Math.round(channel + ((b[index] as number) - channel) * amount),\n );\n return `#${channels.map((channel) => channel.toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n\n/**\n * Derive the inverse scheme over one candidate fill.\n *\n * Text is three levels, like the page: the ink, then `muted` fitted to the\n * geometric mean of the ink's contrast and {@link TEXT_TARGET} (so it sits\n * visibly between the two), then `subtle` fitted to {@link TEXT_TARGET} on\n * `bg` and `surface` — the same pairs the SDK holds its own `text-subtle` to.\n *\n * The action color is the ink itself: a white button on a navy band, labelled in\n * the fill. Hover and active step back toward the fill, because the ink is\n * already the end of the axis and has nowhere further to go.\n *\n * `--tempest-danger-hover` steps toward the side that keeps `-on-solid`\n * readable: darker when the ink is white, lighter when it is dark. A fixed\n * direction cannot hold one ink over both fills — over the dark scheme's\n * `#dc2626` it measured 4.00:1 with the lighter hover.\n *\n * The ramp (`--tempest-primary-50` … `-900`) is emitted too, because `Tag` and\n * `Sidebar` pair raw steps (`100` under `700`). It is the scheme's unanchored\n * ramp, so that pair keeps the shape it has on the page.\n *\n * @param fill - The fill, as hex.\n * @param options - The brand description.\n * @returns The token map and the scheme it reads as.\n */\nfunction deriveOver(\n fill: string,\n options: InverseSurfaceOptions,\n): { tokens: Record<string, string>; scheme: InverseScheme; glow: string } {\n const ink = readableForeground(fill, INK.dark, INK.light);\n const scheme: InverseScheme = ink === INK.dark ? \"dark\" : \"light\";\n const direction: 1 | -1 = scheme === \"dark\" ? 1 : -1;\n const base = hexToOklch(fill);\n const offsets = OFFSETS[scheme];\n const tokens: Record<string, string> = {};\n\n const surfaces = [fill, ...offsets.surfaces.map((delta) => shift(base, direction, -delta))];\n const [bg, surface, surface2, surface3] = surfaces as [string, string, string, string];\n const glow = shift(base, direction, GLOW_OFFSET);\n const grounds = [...surfaces, glow];\n tokens[\"--tempest-bg\"] = bg;\n tokens[\"--tempest-surface\"] = surface;\n tokens[\"--tempest-surface-2\"] = surface2;\n tokens[\"--tempest-surface-3\"] = surface3;\n tokens[\"--tempest-border\"] = shift(base, direction, offsets.border);\n tokens[\"--tempest-border-strong\"] = shift(base, direction, offsets.borderStrong);\n\n const textWorst = worst(ink, grounds);\n const tint = base.c * 0.4;\n tokens[\"--tempest-text\"] = ink;\n tokens[\"--tempest-text-muted\"] = fitToward(\n shift(base, direction, 0, tint),\n direction,\n grounds,\n Math.max(TEXT_TARGET, Math.sqrt(textWorst * TEXT_TARGET)),\n ink,\n );\n tokens[\"--tempest-text-subtle\"] = fitToward(\n shift(base, direction, 0, tint),\n direction,\n [bg, surface, glow],\n TEXT_TARGET,\n ink,\n );\n\n const inkBase: Oklch = { ...hexToOklch(ink), h: base.h };\n tokens[\"--tempest-primary\"] = ink;\n tokens[\"--tempest-primary-hover\"] = shift(inkBase, direction, -0.05, base.c * 0.25);\n tokens[\"--tempest-primary-active\"] = shift(inkBase, direction, -0.1, base.c * 0.3);\n tokens[\"--tempest-primary-foreground\"] = fill;\n tokens[\"--tempest-text-on-primary\"] = fill;\n\n const [soft, softHover] = softTints(base, direction, SOFT_OFFSET[scheme], ink);\n tokens[\"--tempest-primary-soft\"] = soft;\n tokens[\"--tempest-primary-soft-hover\"] = softHover;\n tokens[\"--tempest-primary-on-soft\"] = fitToward(\n soft,\n direction,\n [soft, softHover],\n TEXT_TARGET,\n ink,\n );\n\n const ring = fitToward(fill, direction, grounds, RING_TARGET, ink);\n tokens[\"--tempest-focus-ring-color\"] = ring;\n tokens[\"--tempest-selected-indicator\"] = ring;\n\n const ramp: ColorScale = createColorScale(options.primary, scheme, { anchor: false });\n for (const [step, value] of Object.entries(ramp)) {\n tokens[`--tempest-primary-${step}`] = value;\n }\n\n for (const status of THEME_STATUSES) {\n const scale = createColorScale(\n options.statuses?.[status] ?? DEFAULT_STATUS_COLORS[status],\n scheme,\n );\n writeStatus(tokens, status, scale, scheme);\n tokens[`--tempest-${status}`] = fitToward(\n tokens[`--tempest-${status}`] as string,\n direction,\n grounds,\n TEXT_TARGET,\n ink,\n );\n if (status === \"danger\") {\n const whiteInk = tokens[\"--tempest-danger-on-solid\"] === \"#ffffff\";\n const darker: ScaleStep = scheme === \"dark\" ? 400 : 700;\n const lighter: ScaleStep = scheme === \"dark\" ? 600 : 500;\n tokens[\"--tempest-danger-hover\"] = scale[whiteInk ? darker : lighter];\n }\n }\n\n const chart = options.chart?.length ? options.chart : DEFAULT_CHART_COLORS[scheme];\n chart.forEach((color, index) => {\n tokens[`--tempest-chart-${index + 1}`] = fitToward(\n color,\n direction,\n [bg, surface, glow],\n INDICATOR_FLOOR,\n ink,\n );\n });\n const coolHue = hueOf(options.chart?.[0] ?? options.primary);\n const warmHue = options.statuses?.danger\n ? hueOf(options.statuses.danger)\n : (coolHue + 180) % 360;\n buildRamp(coolHue, scheme).forEach((value, index) => {\n tokens[`--tempest-chart-sequential-${index + 1}`] = value;\n });\n const diverging = buildDivergingRamp({ coolHue, warmHue, mid: surface3, mode: scheme });\n [...diverging.cool, diverging.mid, ...diverging.warm].forEach((value, index) => {\n tokens[`--tempest-chart-diverging-${index + 1}`] = value;\n });\n tokens[\"--tempest-chart-grid\"] = tokens[\"--tempest-border\"] as string;\n tokens[\"--tempest-chart-axis\"] = tokens[\"--tempest-text-subtle\"] as string;\n\n const codeGrounds = [bg, surface, mix(surface, ink, 0.1)];\n CODE_TOKENS.forEach((name, index) => {\n tokens[`--tempest-code-${name}`] = fitToward(\n DEFAULT_CODE_COLORS[scheme][index] as string,\n direction,\n codeGrounds,\n TEXT_TARGET,\n ink,\n );\n });\n\n for (const [name, value] of Object.entries(SHADOWS[scheme])) {\n tokens[`--tempest-shadow-${name}`] = value;\n }\n\n return { tokens, scheme, glow };\n}\n\n/**\n * The gates a candidate fill must clear before it is accepted.\n *\n * Text reaches {@link MIN_TEXT_RATIO} on every surface, every fitted text token\n * clears AA where it is used, the ring clears 3:1 on every surface, and the\n * action label clears AA on all three button states.\n *\n * @param tokens - A derived token map.\n * @param glow - The fill lifted by {@link GLOW_OFFSET}, measured alongside the surfaces.\n * @returns The weakest margin over its floor across all gates; `>= 0` passes.\n */\nfunction margin(tokens: Record<string, string>, glow: string): number {\n const read = (name: string): string => tokens[name] as string;\n const surfaces = [\n read(\"--tempest-bg\"),\n read(\"--tempest-surface\"),\n read(\"--tempest-surface-2\"),\n read(\"--tempest-surface-3\"),\n ];\n const label = read(\"--tempest-primary-foreground\");\n const checks: number[] = [\n worst(read(\"--tempest-text\"), [...surfaces, glow]) / MIN_TEXT_RATIO,\n worst(read(\"--tempest-text-muted\"), [...surfaces, glow]) / AA_TEXT,\n worst(read(\"--tempest-text-subtle\"), [...surfaces.slice(0, 2), glow]) / AA_TEXT,\n worst(read(\"--tempest-focus-ring-color\"), [...surfaces, glow]) / INDICATOR_FLOOR,\n worst(label, [\n read(\"--tempest-primary\"),\n read(\"--tempest-primary-hover\"),\n read(\"--tempest-primary-active\"),\n ]) / AA_TEXT,\n ];\n return Math.min(...checks) - 1;\n}\n\n/**\n * Build the inverse surface for a brand.\n *\n * The fill is the brand's own `500` whenever it can carry the scheme, and\n * otherwise the nearest ramp step that can (see {@link FILL_CANDIDATES}). Whether\n * the surface reads light-on-dark or dark-on-light follows the fill, so a yellow\n * brand gets dark ink and a navy one white — the same pick `createTheme` makes\n * for `--tempest-primary-foreground`.\n *\n * The values are literal colors, not references to the page's ramp, so the\n * section paints the same in the light and the dark page scheme: the brand is\n * the brand in both.\n *\n * @param options - The brand, plus the status and chart colors the theme names.\n * @returns The token map, the scheme it reads as, and the fill step used.\n */\nexport function createInverseSurface(options: InverseSurfaceOptions): InverseSurface {\n const ramp = createColorScale(options.primary, \"light\");\n let best: InverseSurface | null = null;\n let bestMargin = Number.NEGATIVE_INFINITY;\n for (const step of FILL_CANDIDATES) {\n const derived = deriveOver(ramp[step], options);\n const measured = margin(derived.tokens, derived.glow);\n if (measured >= 0) return { tokens: derived.tokens, scheme: derived.scheme, step };\n if (measured > bestMargin) {\n best = { tokens: derived.tokens, scheme: derived.scheme, step };\n bestMargin = measured;\n }\n }\n return best as InverseSurface;\n}\n"],"mappings":"wIA0CA,IAAM,EAAU,IAQV,EAAc,KAGd,EAAkB,EASlB,EAAc,IAWd,EAAiB,EAejB,EAAwC,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,GAAG,EA8B/E,EAGF,CACA,KAAM,CAAE,SAAU,CAAC,KAAO,KAAO,GAAI,EAAG,OAAQ,KAAO,aAAc,IAAM,EAC3E,MAAO,CAAE,SAAU,CAAC,KAAO,KAAO,IAAK,EAAG,OAAQ,KAAO,aAAc,IAAM,CACjF,EAYM,EAAc,GAGd,EAAqC,CAAE,KAAM,UAAW,MAAO,SAAU,EAQlE,EAAqD,CAC9D,QAAS,UACT,QAAS,UACT,OAAQ,UACR,KAAM,SACV,EASa,EAAiE,CAC1E,MAAO,CAAC,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,SAAS,EAC9F,KAAM,CAAC,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,SAAS,CACjG,EAGM,EAAc,CAChB,UACA,cACA,SACA,SACA,UACA,UACA,WACA,MACA,YACA,UACJ,EASa,EAAgE,CACzE,MAAO,CACH,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,SACJ,EACA,KAAM,CACF,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,SACJ,CACJ,EAUM,EAAyD,CAC3D,MAAO,CACH,GAAI,mCACJ,GAAI,qEACJ,GAAI,sEACJ,GAAI,uEACJ,GAAI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C,GAAG,EAAU,CAAI,CAAC,EAAI,EACrD,EAAM,EAAK,sBAAsB,EAAG,CAAC,GAAG,EAAU,CAAI,CAAC,EAAI,EAC3D,EAAM,EAAK,uBAAuB,EAAG,CAAC,GAAG,EAAS,MAAM,EAAG,CAAC,EAAG,CAAI,CAAC,EAAI,EACxE,EAAM,EAAK,4BAA4B,EAAG,CAAC,GAAG,EAAU,CAAI,CAAC,EAAI,EACjE,EAAM,EAAO,CACT,EAAK,mBAAmB,EACxB,EAAK,yBAAyB,EAC9B,EAAK,0BAA0B,CACnC,CAAC,EAAI,CACT,EACA,OAAO,KAAK,IAAI,GAAG,CAAM,EAAI,CACjC,CAkBA,SAAgB,EAAqB,EAAgD,CACjF,IAAM,EAAO,EAAA,iBAAiB,EAAQ,QAAS,OAAO,EAClD,EAA8B,KAC9B,EAAa,KACjB,IAAK,IAAM,KAAQ,EAAiB,CAChC,IAAM,EAAU,EAAW,EAAK,GAAO,CAAO,EACxC,EAAW,EAAO,EAAQ,OAAQ,EAAQ,IAAI,EACpD,GAAI,GAAY,EAAG,MAAO,CAAE,OAAQ,EAAQ,OAAQ,OAAQ,EAAQ,OAAQ,MAAK,EAC7E,EAAW,IACX,EAAO,CAAE,OAAQ,EAAQ,OAAQ,OAAQ,EAAQ,OAAQ,MAAK,EAC9D,EAAa,EAErB,CACA,OAAO,CACX"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { contrastRatio as e, createColorScale as t, hexToOklch as n, oklchToHex as r, readableForeground as i } from "./color.js";
|
|
2
|
+
import { buildDivergingRamp as a, buildRamp as o, hueOf as s } from "./data-viz-ramps.js";
|
|
3
|
+
import "./inverse-render.js";
|
|
4
|
+
import { THEME_STATUSES as c, writeStatus as l } from "./status-tokens.js";
|
|
5
|
+
//#region src/theme/inverse-surface.ts
|
|
6
|
+
var u = 4.5, d = 4.75, f = 3, p = 4.5, m = 7, h = [
|
|
7
|
+
500,
|
|
8
|
+
600,
|
|
9
|
+
400,
|
|
10
|
+
700,
|
|
11
|
+
300,
|
|
12
|
+
800,
|
|
13
|
+
200,
|
|
14
|
+
900
|
|
15
|
+
], g = {
|
|
16
|
+
dark: {
|
|
17
|
+
surfaces: [
|
|
18
|
+
.046,
|
|
19
|
+
.094,
|
|
20
|
+
.14
|
|
21
|
+
],
|
|
22
|
+
border: .155,
|
|
23
|
+
borderStrong: .222
|
|
24
|
+
},
|
|
25
|
+
light: {
|
|
26
|
+
surfaces: [
|
|
27
|
+
.018,
|
|
28
|
+
.037,
|
|
29
|
+
.073
|
|
30
|
+
],
|
|
31
|
+
border: .073,
|
|
32
|
+
borderStrong: .128
|
|
33
|
+
}
|
|
34
|
+
}, _ = .1, v = {
|
|
35
|
+
dark: "#ffffff",
|
|
36
|
+
light: "#101828"
|
|
37
|
+
}, y = {
|
|
38
|
+
success: "#16a34a",
|
|
39
|
+
warning: "#d97706",
|
|
40
|
+
danger: "#dc2626",
|
|
41
|
+
info: "#2563eb"
|
|
42
|
+
}, b = {
|
|
43
|
+
light: [
|
|
44
|
+
"#2563eb",
|
|
45
|
+
"#16a34a",
|
|
46
|
+
"#f59e0b",
|
|
47
|
+
"#7c3aed",
|
|
48
|
+
"#ec4899",
|
|
49
|
+
"#06b6d4",
|
|
50
|
+
"#ea580c",
|
|
51
|
+
"#0f766e"
|
|
52
|
+
],
|
|
53
|
+
dark: [
|
|
54
|
+
"#60a5fa",
|
|
55
|
+
"#4ade80",
|
|
56
|
+
"#fbbf24",
|
|
57
|
+
"#a78bfa",
|
|
58
|
+
"#f472b6",
|
|
59
|
+
"#22d3ee",
|
|
60
|
+
"#fb923c",
|
|
61
|
+
"#2dd4bf"
|
|
62
|
+
]
|
|
63
|
+
}, x = [
|
|
64
|
+
"comment",
|
|
65
|
+
"punctuation",
|
|
66
|
+
"string",
|
|
67
|
+
"number",
|
|
68
|
+
"keyword",
|
|
69
|
+
"literal",
|
|
70
|
+
"function",
|
|
71
|
+
"tag",
|
|
72
|
+
"attribute",
|
|
73
|
+
"property"
|
|
74
|
+
], S = {
|
|
75
|
+
light: [
|
|
76
|
+
"#5f666e",
|
|
77
|
+
"#5d6671",
|
|
78
|
+
"#327243",
|
|
79
|
+
"#9d5035",
|
|
80
|
+
"#625baf",
|
|
81
|
+
"#9f4c4f",
|
|
82
|
+
"#1a6c94",
|
|
83
|
+
"#974d72",
|
|
84
|
+
"#127171",
|
|
85
|
+
"#127171"
|
|
86
|
+
],
|
|
87
|
+
dark: [
|
|
88
|
+
"#838b93",
|
|
89
|
+
"#818b95",
|
|
90
|
+
"#589866",
|
|
91
|
+
"#c57558",
|
|
92
|
+
"#8580d8",
|
|
93
|
+
"#c87172",
|
|
94
|
+
"#2893c6",
|
|
95
|
+
"#c07197",
|
|
96
|
+
"#349897",
|
|
97
|
+
"#349897"
|
|
98
|
+
]
|
|
99
|
+
}, C = {
|
|
100
|
+
light: {
|
|
101
|
+
xs: "0 1px 2px rgba(15, 23, 42, 0.04)",
|
|
102
|
+
sm: "0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04)",
|
|
103
|
+
md: "0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04)",
|
|
104
|
+
lg: "0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06)",
|
|
105
|
+
xl: "0 24px 48px rgba(15, 23, 42, 0.18), 0 8px 16px rgba(15, 23, 42, 0.08)",
|
|
106
|
+
inner: "inset 0 2px 4px rgba(15, 23, 42, 0.06)"
|
|
107
|
+
},
|
|
108
|
+
dark: {
|
|
109
|
+
xs: "0 1px 2px rgba(0, 0, 0, 0.3)",
|
|
110
|
+
sm: "0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2)",
|
|
111
|
+
md: "0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2)",
|
|
112
|
+
lg: "0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3)",
|
|
113
|
+
xl: "0 24px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.3)",
|
|
114
|
+
inner: "inset 0 2px 4px rgba(15, 23, 42, 0.06)"
|
|
115
|
+
}
|
|
116
|
+
}, w = .005;
|
|
117
|
+
function T(e, t, n, i = e.c) {
|
|
118
|
+
let a = Math.min(1, Math.max(0, e.l + t * n));
|
|
119
|
+
return r({
|
|
120
|
+
l: a,
|
|
121
|
+
c: i,
|
|
122
|
+
h: e.h
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function E(t, n) {
|
|
126
|
+
return Math.min(...n.map((n) => e(t, n)));
|
|
127
|
+
}
|
|
128
|
+
function D(e, t, r, i, a) {
|
|
129
|
+
let o = n(e);
|
|
130
|
+
for (let e = 0; e <= 1; e += w) {
|
|
131
|
+
let n = T(o, t, e);
|
|
132
|
+
if (E(n, r) >= i) return n;
|
|
133
|
+
if (t === 1 && o.l + e >= 1 || t === -1 && o.l - e <= 0) break;
|
|
134
|
+
}
|
|
135
|
+
return a;
|
|
136
|
+
}
|
|
137
|
+
var O = {
|
|
138
|
+
dark: .07,
|
|
139
|
+
light: .05
|
|
140
|
+
}, k = 1.6;
|
|
141
|
+
function A(e, t, n, r) {
|
|
142
|
+
for (let i = n; i > w; i -= w) {
|
|
143
|
+
let n = [T(e, t, i), T(e, t, i * k)];
|
|
144
|
+
if (E(r, n) >= d) return n;
|
|
145
|
+
}
|
|
146
|
+
return [T(e, t, -n), T(e, t, -n * k)];
|
|
147
|
+
}
|
|
148
|
+
function j(e, t, n) {
|
|
149
|
+
let r = (e) => [
|
|
150
|
+
1,
|
|
151
|
+
3,
|
|
152
|
+
5
|
|
153
|
+
].map((t) => Number.parseInt(e.slice(t, t + 2), 16)), [i, a] = [r(e), r(t)];
|
|
154
|
+
return `#${i.map((e, t) => Math.round(e + (a[t] - e) * n)).map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
155
|
+
}
|
|
156
|
+
function M(e, r) {
|
|
157
|
+
let u = i(e, v.dark, v.light), m = u === v.dark ? "dark" : "light", h = m === "dark" ? 1 : -1, w = n(e), k = g[m], M = {}, N = [e, ...k.surfaces.map((e) => T(w, h, -e))], [P, F, I, L] = N, R = T(w, h, _), z = [...N, R];
|
|
158
|
+
M["--tempest-bg"] = P, M["--tempest-surface"] = F, M["--tempest-surface-2"] = I, M["--tempest-surface-3"] = L, M["--tempest-border"] = T(w, h, k.border), M["--tempest-border-strong"] = T(w, h, k.borderStrong);
|
|
159
|
+
let B = E(u, z), V = w.c * .4;
|
|
160
|
+
M["--tempest-text"] = u, M["--tempest-text-muted"] = D(T(w, h, 0, V), h, z, Math.max(d, Math.sqrt(B * d)), u), M["--tempest-text-subtle"] = D(T(w, h, 0, V), h, [
|
|
161
|
+
P,
|
|
162
|
+
F,
|
|
163
|
+
R
|
|
164
|
+
], d, u);
|
|
165
|
+
let H = {
|
|
166
|
+
...n(u),
|
|
167
|
+
h: w.h
|
|
168
|
+
};
|
|
169
|
+
M["--tempest-primary"] = u, M["--tempest-primary-hover"] = T(H, h, -.05, w.c * .25), M["--tempest-primary-active"] = T(H, h, -.1, w.c * .3), M["--tempest-primary-foreground"] = e, M["--tempest-text-on-primary"] = e;
|
|
170
|
+
let [U, W] = A(w, h, O[m], u);
|
|
171
|
+
M["--tempest-primary-soft"] = U, M["--tempest-primary-soft-hover"] = W, M["--tempest-primary-on-soft"] = D(U, h, [U, W], d, u);
|
|
172
|
+
let G = D(e, h, z, p, u);
|
|
173
|
+
M["--tempest-focus-ring-color"] = G, M["--tempest-selected-indicator"] = G;
|
|
174
|
+
let K = t(r.primary, m, { anchor: !1 });
|
|
175
|
+
for (let [e, t] of Object.entries(K)) M[`--tempest-primary-${e}`] = t;
|
|
176
|
+
for (let e of c) {
|
|
177
|
+
let n = t(r.statuses?.[e] ?? y[e], m);
|
|
178
|
+
l(M, e, n, m), M[`--tempest-${e}`] = D(M[`--tempest-${e}`], h, z, d, u), e === "danger" && (M["--tempest-danger-hover"] = n[M["--tempest-danger-on-solid"] === "#ffffff" ? m === "dark" ? 400 : 700 : m === "dark" ? 600 : 500]);
|
|
179
|
+
}
|
|
180
|
+
(r.chart?.length ? r.chart : b[m]).forEach((e, t) => {
|
|
181
|
+
M[`--tempest-chart-${t + 1}`] = D(e, h, [
|
|
182
|
+
P,
|
|
183
|
+
F,
|
|
184
|
+
R
|
|
185
|
+
], f, u);
|
|
186
|
+
});
|
|
187
|
+
let q = s(r.chart?.[0] ?? r.primary), J = r.statuses?.danger ? s(r.statuses.danger) : (q + 180) % 360;
|
|
188
|
+
o(q, m).forEach((e, t) => {
|
|
189
|
+
M[`--tempest-chart-sequential-${t + 1}`] = e;
|
|
190
|
+
});
|
|
191
|
+
let Y = a({
|
|
192
|
+
coolHue: q,
|
|
193
|
+
warmHue: J,
|
|
194
|
+
mid: L,
|
|
195
|
+
mode: m
|
|
196
|
+
});
|
|
197
|
+
[
|
|
198
|
+
...Y.cool,
|
|
199
|
+
Y.mid,
|
|
200
|
+
...Y.warm
|
|
201
|
+
].forEach((e, t) => {
|
|
202
|
+
M[`--tempest-chart-diverging-${t + 1}`] = e;
|
|
203
|
+
}), M["--tempest-chart-grid"] = M["--tempest-border"], M["--tempest-chart-axis"] = M["--tempest-text-subtle"];
|
|
204
|
+
let X = [
|
|
205
|
+
P,
|
|
206
|
+
F,
|
|
207
|
+
j(F, u, .1)
|
|
208
|
+
];
|
|
209
|
+
x.forEach((e, t) => {
|
|
210
|
+
M[`--tempest-code-${e}`] = D(S[m][t], h, X, d, u);
|
|
211
|
+
});
|
|
212
|
+
for (let [e, t] of Object.entries(C[m])) M[`--tempest-shadow-${e}`] = t;
|
|
213
|
+
return {
|
|
214
|
+
tokens: M,
|
|
215
|
+
scheme: m,
|
|
216
|
+
glow: R
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function N(e, t) {
|
|
220
|
+
let n = (t) => e[t], r = [
|
|
221
|
+
n("--tempest-bg"),
|
|
222
|
+
n("--tempest-surface"),
|
|
223
|
+
n("--tempest-surface-2"),
|
|
224
|
+
n("--tempest-surface-3")
|
|
225
|
+
], i = n("--tempest-primary-foreground"), a = [
|
|
226
|
+
E(n("--tempest-text"), [...r, t]) / m,
|
|
227
|
+
E(n("--tempest-text-muted"), [...r, t]) / u,
|
|
228
|
+
E(n("--tempest-text-subtle"), [...r.slice(0, 2), t]) / u,
|
|
229
|
+
E(n("--tempest-focus-ring-color"), [...r, t]) / f,
|
|
230
|
+
E(i, [
|
|
231
|
+
n("--tempest-primary"),
|
|
232
|
+
n("--tempest-primary-hover"),
|
|
233
|
+
n("--tempest-primary-active")
|
|
234
|
+
]) / u
|
|
235
|
+
];
|
|
236
|
+
return Math.min(...a) - 1;
|
|
237
|
+
}
|
|
238
|
+
function P(e) {
|
|
239
|
+
let n = t(e.primary, "light"), r = null, i = -Infinity;
|
|
240
|
+
for (let t of h) {
|
|
241
|
+
let a = M(n[t], e), o = N(a.tokens, a.glow);
|
|
242
|
+
if (o >= 0) return {
|
|
243
|
+
tokens: a.tokens,
|
|
244
|
+
scheme: a.scheme,
|
|
245
|
+
step: t
|
|
246
|
+
};
|
|
247
|
+
o > i && (r = {
|
|
248
|
+
tokens: a.tokens,
|
|
249
|
+
scheme: a.scheme,
|
|
250
|
+
step: t
|
|
251
|
+
}, i = o);
|
|
252
|
+
}
|
|
253
|
+
return r;
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
export { b as DEFAULT_CHART_COLORS, S as DEFAULT_CODE_COLORS, y as DEFAULT_STATUS_COLORS, P as createInverseSurface };
|
|
257
|
+
|
|
258
|
+
//# sourceMappingURL=inverse-surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inverse-surface.js","names":[],"sources":["../../src/theme/inverse-surface.ts"],"sourcesContent":["/**\n * @tempest-limits file-lines — the inverse surface is a whole scheme: surfaces,\n * text, the action color, focus, selection, statuses, charts and syntax colors,\n * each derived and then measured against the brand fill it sits on. Splitting\n * the derivation from the table it is measured against is how the two drift.\n */\n/**\n * Inverse surface: the token set for a section painted in the brand color —\n * a hero, a call-to-action band, a footer — so the components inside it invert\n * instead of inheriting the page's tokens.\n *\n * Every value is derived from the brand and measured against the fill it will\n * sit on, the same way {@link createTheme} measures the page schemes. Overriding\n * eight tokens by hand (what #409 had to do) leaves the rest of the scheme on\n * the page's values: measured over a navy `#1e2a5a`, the inherited\n * `--tempest-text-subtle` lands at 2.75:1, `--tempest-danger` at 2.12:1, the\n * selected indicator at 2.01:1, and a `Card` puts white text on\n * `--tempest-surface` at 1.05:1.\n */\nimport {\n contrastRatio,\n createColorScale,\n hexToOklch,\n oklchToHex,\n readableForeground,\n type ColorScale,\n type Oklch,\n type ScaleStep,\n} from \"./color\";\nimport { buildDivergingRamp, buildRamp, hueOf } from \"./data-viz-ramps\";\nimport type { InverseScheme, InverseSurface, InverseSurfaceOptions } from \"./inverse-render\";\nimport { THEME_STATUSES, writeStatus, type ThemeStatus } from \"./status-tokens\";\n\nexport { INVERSE_SELECTOR, renderInverseSurface } from \"./inverse-render\";\nexport type {\n InverseScheme,\n InverseSurface,\n InverseSurfaceGenerator,\n InverseSurfaceOptions,\n} from \"./inverse-render\";\n\n/** WCAG 2.x AA floor for body text. */\nconst AA_TEXT = 4.5;\n\n/**\n * What text is fitted to, rather than the floor itself.\n *\n * The margin the SDK's dark theme keeps on `--tempest-text-subtle` (4.79 over its\n * surface): a value solved to exactly 4.5 turns the next rounding into a failure.\n */\nconst TEXT_TARGET = 4.75;\n\n/** WCAG 2.2 SC 1.4.11 floor for a non-text indicator. */\nconst INDICATOR_FLOOR = 3;\n\n/**\n * What the focus ring and the selected indicator are fitted to.\n *\n * Well above the 3:1 floor on purpose: the SDK's own rings keep 5.40:1 (dark)\n * and 5.50:1 (light) worst case, because a ring travels onto surfaces nobody\n * validated it against.\n */\nconst RING_TARGET = 4.5;\n\n/**\n * The smallest contrast the ink must keep — on the fill, the surfaces and the\n * glow — before the fill is accepted.\n *\n * AA (4.5) is not enough here, because the surface has three text levels — text,\n * muted and subtle — and all three must clear AA. With text at 4.83:1 (white on\n * the default `#0066ff`) the three collapse into one color. 7:1 (AAA) leaves room\n * for muted to sit visibly between text and subtle.\n */\nconst MIN_TEXT_RATIO = 7;\n\n/**\n * Fill candidates, nearest the brand first, darker before lighter on a tie.\n *\n * `500` is the brand itself and wins whenever it can carry the scheme. When it\n * cannot — a mid-tone brand such as `#0066ff`, where white measures 4.83:1 —\n * the walk moves one step at a time, so the section stays as close to the brand\n * as the measurement allows.\n *\n * Measuring the glow is what most of the walking pays for: against the flat\n * fill and the surfaces alone, 9 of the 14 test brands keep their `500`; with\n * the glow, 6 do. The three that move (`#8100D7`, `#22d3ee`, `#14b8a6`) are the\n * ones whose subtle text would fail on a lifted region of their own band.\n */\nconst FILL_CANDIDATES: readonly ScaleStep[] = [500, 600, 400, 700, 300, 800, 200, 900];\n\n/**\n * Lightness offsets from the fill, per scheme.\n *\n * The sizes are the SDK's own, measured in OKLCH: the dark theme's surfaces sit\n * 0.046, 0.094 and 0.140 from `#0b0d12`, its borders 0.155 and 0.222; the light\n * theme's surfaces sit 0.018, 0.037 and 0.073 from white, its borders 0.073 and\n * 0.128.\n *\n * The direction is not the SDK's. On the page, raised surfaces move toward the\n * ink, which costs nothing there: the page fill is near-white or near-black, so\n * the ink keeps 13:1 or more on the third surface. A brand fill sits mid-axis,\n * and moving toward the ink spends exactly the contrast the text needs. Measured\n * across the fourteen brands of the contrast test, every text level held to AA\n * on every surface and on the glow ({@link GLOW_OFFSET}):\n *\n * | surfaces move | brands keeping their own `500` | where `#8100D7` / `#4f46e5` land |\n * | --- | --- | --- |\n * | toward the ink | 6 of 14 | `800` / `800` |\n * | away from the ink | 6 of 14 | `700` / `700` |\n *\n * Never worse and one step nearer the brand for the purples, and with every\n * surface carrying the ink at least as well as the fill does.\n *\n * So surfaces move away from the ink — a card in a navy band is a deeper navy,\n * one in a yellow band a paler yellow — and every surface then carries the ink\n * at least as well as the fill does. Borders still move toward the ink, since a\n * border has to separate from the fill and the surfaces alike.\n */\nconst OFFSETS: Record<\n InverseScheme,\n { surfaces: readonly [number, number, number]; border: number; borderStrong: number }\n> = {\n dark: { surfaces: [0.046, 0.094, 0.14], border: 0.155, borderStrong: 0.222 },\n light: { surfaces: [0.018, 0.037, 0.073], border: 0.073, borderStrong: 0.128 },\n};\n\n/**\n * How far toward the ink a region of the band may lift and still be measured.\n *\n * A brand section is rarely one flat color: the landing that opened #409 lays a\n * radial glow of `#1f3f8f` at 55% over its navy `#03184b`, which lifts the\n * ground by 0.09 in OKLCH lightness, and a hover tint does the same. Text fitted\n * to the flat fill alone failed there — subtle measured 3.64:1 on that glow. So\n * every text and indicator token is also fitted against the fill lifted by this\n * much; darker variations (the landing's `#020f30` footer) only add contrast.\n */\nconst GLOW_OFFSET = 0.1;\n\n/** Text ink per scheme — the SDK's own extremes. */\nconst INK: Record<InverseScheme, string> = { dark: \"#ffffff\", light: \"#101828\" };\n\n/**\n * The SDK's default status colors, used when a theme names none.\n *\n * Ported from `src/styles/colors.css` (`--tempest-*-solid` in the light block),\n * and pinned by a test that reads that file.\n */\nexport const DEFAULT_STATUS_COLORS: Record<ThemeStatus, string> = {\n success: \"#16a34a\",\n warning: \"#d97706\",\n danger: \"#dc2626\",\n info: \"#2563eb\",\n};\n\n/**\n * The SDK's categorical chart colors, per scheme.\n *\n * Ported from `src/styles/colors.css` (`--tempest-chart-1` … `-8`), pinned by a\n * test that reads that file. Used as the starting hue for each slot, then fitted\n * to the inverse fill.\n */\nexport const DEFAULT_CHART_COLORS: Record<InverseScheme, readonly string[]> = {\n light: [\"#2563eb\", \"#16a34a\", \"#f59e0b\", \"#7c3aed\", \"#ec4899\", \"#06b6d4\", \"#ea580c\", \"#0f766e\"],\n dark: [\"#60a5fa\", \"#4ade80\", \"#fbbf24\", \"#a78bfa\", \"#f472b6\", \"#22d3ee\", \"#fb923c\", \"#2dd4bf\"],\n};\n\n/** Names of the `CodeBlock` syntax tokens, in `colors.css` order. */\nconst CODE_TOKENS = [\n \"comment\",\n \"punctuation\",\n \"string\",\n \"number\",\n \"keyword\",\n \"literal\",\n \"function\",\n \"tag\",\n \"attribute\",\n \"property\",\n] as const;\n\n/**\n * The SDK's syntax colors, per scheme, in {@link CODE_TOKENS} order.\n *\n * Ported from `src/styles/colors.css` (`--tempest-code-*`), pinned by a test\n * that reads that file. Used as the starting hue, then fitted to the inverse\n * code grounds.\n */\nexport const DEFAULT_CODE_COLORS: Record<InverseScheme, readonly string[]> = {\n light: [\n \"#5f666e\",\n \"#5d6671\",\n \"#327243\",\n \"#9d5035\",\n \"#625baf\",\n \"#9f4c4f\",\n \"#1a6c94\",\n \"#974d72\",\n \"#127171\",\n \"#127171\",\n ],\n dark: [\n \"#838b93\",\n \"#818b95\",\n \"#589866\",\n \"#c57558\",\n \"#8580d8\",\n \"#c87172\",\n \"#2893c6\",\n \"#c07197\",\n \"#349897\",\n \"#349897\",\n ],\n};\n\n/**\n * The SDK's elevation shadows, per scheme.\n *\n * Ported from `src/styles/colors.css` (`--tempest-shadow-*`). A light-ink fill\n * takes the dark theme's heavier shadows, since a faint shadow vanishes on it.\n * The dark block does not override `--tempest-shadow-inner`, so the dark row\n * carries the light value it inherits.\n */\nconst SHADOWS: Record<InverseScheme, Record<string, string>> = {\n light: {\n xs: \"0 1px 2px rgba(15, 23, 42, 0.04)\",\n sm: \"0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04)\",\n md: \"0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04)\",\n lg: \"0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06)\",\n xl: \"0 24px 48px rgba(15, 23, 42, 0.18), 0 8px 16px rgba(15, 23, 42, 0.08)\",\n inner: \"inset 0 2px 4px rgba(15, 23, 42, 0.06)\",\n },\n dark: {\n xs: \"0 1px 2px rgba(0, 0, 0, 0.3)\",\n sm: \"0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.2)\",\n md: \"0 4px 12px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2)\",\n lg: \"0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3)\",\n xl: \"0 24px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.3)\",\n inner: \"inset 0 2px 4px rgba(15, 23, 42, 0.06)\",\n },\n};\n\n/** Lightness step used when fitting a color toward the ink. */\nconst FIT_STEP = 0.005;\n\n/**\n * Move a color along the lightness axis toward (positive `delta`) or away from\n * the ink, keeping its hue.\n *\n * @param base - The color to move, in OKLCH.\n * @param direction - `1` when the ink is lighter than the fill, `-1` otherwise.\n * @param delta - How far to move, in OKLCH lightness.\n * @param chroma - Chroma of the result; defaults to the base's.\n * @returns The moved color as hex, gamut-mapped.\n */\nfunction shift(base: Oklch, direction: 1 | -1, delta: number, chroma: number = base.c): string {\n const l = Math.min(1, Math.max(0, base.l + direction * delta));\n return oklchToHex({ l, c: chroma, h: base.h });\n}\n\n/** Weakest contrast of `color` against every ground. */\nfunction worst(color: string, grounds: readonly string[]): number {\n return Math.min(...grounds.map((ground) => contrastRatio(color, ground)));\n}\n\n/**\n * Walk a color toward the ink until it clears `floor` against every ground.\n *\n * Hue and chroma are kept, so a danger stays red and a keyword stays violet;\n * only lightness moves, and only as far as the measurement asks. When the walk\n * reaches the end of the lightness axis without clearing, the ink itself is\n * returned — it is the most contrasting color the scheme has.\n *\n * @param start - Where to start, as hex.\n * @param direction - `1` when the ink is lighter than the grounds, `-1` otherwise.\n * @param grounds - Every background the color will sit on.\n * @param floor - The ratio to clear against all of them.\n * @param ink - Fallback when nothing on the walk clears.\n * @returns The first color on the walk that clears, else `ink`.\n */\nfunction fitToward(\n start: string,\n direction: 1 | -1,\n grounds: readonly string[],\n floor: number,\n ink: string,\n): string {\n const base = hexToOklch(start);\n for (let delta = 0; delta <= 1; delta += FIT_STEP) {\n const candidate = shift(base, direction, delta);\n if (worst(candidate, grounds) >= floor) return candidate;\n if ((direction === 1 && base.l + delta >= 1) || (direction === -1 && base.l - delta <= 0)) {\n break;\n }\n }\n return ink;\n}\n\n/**\n * How far the soft tint sits from the fill, per scheme; the hover tint sits\n * {@link SOFT_HOVER_FACTOR} times as far.\n */\nconst SOFT_OFFSET: Record<InverseScheme, number> = { dark: 0.07, light: 0.05 };\n\n/** Distance of the soft hover tint, relative to the soft tint's. */\nconst SOFT_HOVER_FACTOR = 1.6;\n\n/**\n * The soft tint and its hover, lifted toward the ink only as far as the ink\n * still reads on both.\n *\n * A tint toward the ink is what reads as \"highlighted\" on a fill, and it is also\n * what eats the ink's contrast: on the `#8100D7` fill, the full offset left white\n * at 4.42:1 on the hover tint. So the offset shrinks until the ink clears\n * {@link TEXT_TARGET} on both, and when even a sliver cannot — the fill gives the\n * ink no room — the tints move away from the ink instead, like the surfaces.\n *\n * @param base - The fill, in OKLCH.\n * @param direction - `1` when the ink is lighter than the fill, `-1` otherwise.\n * @param offset - The preferred distance of the soft tint.\n * @param ink - The scheme's text ink.\n * @returns The soft tint and its hover, as hex.\n */\nfunction softTints(base: Oklch, direction: 1 | -1, offset: number, ink: string): [string, string] {\n for (let delta = offset; delta > FIT_STEP; delta -= FIT_STEP) {\n const tints: [string, string] = [\n shift(base, direction, delta),\n shift(base, direction, delta * SOFT_HOVER_FACTOR),\n ];\n if (worst(ink, tints) >= TEXT_TARGET) return tints;\n }\n return [shift(base, direction, -offset), shift(base, direction, -offset * SOFT_HOVER_FACTOR)];\n}\n\n/** Mix `top` over `bottom` at `amount`, the way `color-mix(in srgb, …)` composites. */\nfunction mix(bottom: string, top: string, amount: number): string {\n const parse = (hex: string): number[] =>\n [1, 3, 5].map((index) => Number.parseInt(hex.slice(index, index + 2), 16));\n const [a, b] = [parse(bottom), parse(top)];\n const channels = a.map((channel, index) =>\n Math.round(channel + ((b[index] as number) - channel) * amount),\n );\n return `#${channels.map((channel) => channel.toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n\n/**\n * Derive the inverse scheme over one candidate fill.\n *\n * Text is three levels, like the page: the ink, then `muted` fitted to the\n * geometric mean of the ink's contrast and {@link TEXT_TARGET} (so it sits\n * visibly between the two), then `subtle` fitted to {@link TEXT_TARGET} on\n * `bg` and `surface` — the same pairs the SDK holds its own `text-subtle` to.\n *\n * The action color is the ink itself: a white button on a navy band, labelled in\n * the fill. Hover and active step back toward the fill, because the ink is\n * already the end of the axis and has nowhere further to go.\n *\n * `--tempest-danger-hover` steps toward the side that keeps `-on-solid`\n * readable: darker when the ink is white, lighter when it is dark. A fixed\n * direction cannot hold one ink over both fills — over the dark scheme's\n * `#dc2626` it measured 4.00:1 with the lighter hover.\n *\n * The ramp (`--tempest-primary-50` … `-900`) is emitted too, because `Tag` and\n * `Sidebar` pair raw steps (`100` under `700`). It is the scheme's unanchored\n * ramp, so that pair keeps the shape it has on the page.\n *\n * @param fill - The fill, as hex.\n * @param options - The brand description.\n * @returns The token map and the scheme it reads as.\n */\nfunction deriveOver(\n fill: string,\n options: InverseSurfaceOptions,\n): { tokens: Record<string, string>; scheme: InverseScheme; glow: string } {\n const ink = readableForeground(fill, INK.dark, INK.light);\n const scheme: InverseScheme = ink === INK.dark ? \"dark\" : \"light\";\n const direction: 1 | -1 = scheme === \"dark\" ? 1 : -1;\n const base = hexToOklch(fill);\n const offsets = OFFSETS[scheme];\n const tokens: Record<string, string> = {};\n\n const surfaces = [fill, ...offsets.surfaces.map((delta) => shift(base, direction, -delta))];\n const [bg, surface, surface2, surface3] = surfaces as [string, string, string, string];\n const glow = shift(base, direction, GLOW_OFFSET);\n const grounds = [...surfaces, glow];\n tokens[\"--tempest-bg\"] = bg;\n tokens[\"--tempest-surface\"] = surface;\n tokens[\"--tempest-surface-2\"] = surface2;\n tokens[\"--tempest-surface-3\"] = surface3;\n tokens[\"--tempest-border\"] = shift(base, direction, offsets.border);\n tokens[\"--tempest-border-strong\"] = shift(base, direction, offsets.borderStrong);\n\n const textWorst = worst(ink, grounds);\n const tint = base.c * 0.4;\n tokens[\"--tempest-text\"] = ink;\n tokens[\"--tempest-text-muted\"] = fitToward(\n shift(base, direction, 0, tint),\n direction,\n grounds,\n Math.max(TEXT_TARGET, Math.sqrt(textWorst * TEXT_TARGET)),\n ink,\n );\n tokens[\"--tempest-text-subtle\"] = fitToward(\n shift(base, direction, 0, tint),\n direction,\n [bg, surface, glow],\n TEXT_TARGET,\n ink,\n );\n\n const inkBase: Oklch = { ...hexToOklch(ink), h: base.h };\n tokens[\"--tempest-primary\"] = ink;\n tokens[\"--tempest-primary-hover\"] = shift(inkBase, direction, -0.05, base.c * 0.25);\n tokens[\"--tempest-primary-active\"] = shift(inkBase, direction, -0.1, base.c * 0.3);\n tokens[\"--tempest-primary-foreground\"] = fill;\n tokens[\"--tempest-text-on-primary\"] = fill;\n\n const [soft, softHover] = softTints(base, direction, SOFT_OFFSET[scheme], ink);\n tokens[\"--tempest-primary-soft\"] = soft;\n tokens[\"--tempest-primary-soft-hover\"] = softHover;\n tokens[\"--tempest-primary-on-soft\"] = fitToward(\n soft,\n direction,\n [soft, softHover],\n TEXT_TARGET,\n ink,\n );\n\n const ring = fitToward(fill, direction, grounds, RING_TARGET, ink);\n tokens[\"--tempest-focus-ring-color\"] = ring;\n tokens[\"--tempest-selected-indicator\"] = ring;\n\n const ramp: ColorScale = createColorScale(options.primary, scheme, { anchor: false });\n for (const [step, value] of Object.entries(ramp)) {\n tokens[`--tempest-primary-${step}`] = value;\n }\n\n for (const status of THEME_STATUSES) {\n const scale = createColorScale(\n options.statuses?.[status] ?? DEFAULT_STATUS_COLORS[status],\n scheme,\n );\n writeStatus(tokens, status, scale, scheme);\n tokens[`--tempest-${status}`] = fitToward(\n tokens[`--tempest-${status}`] as string,\n direction,\n grounds,\n TEXT_TARGET,\n ink,\n );\n if (status === \"danger\") {\n const whiteInk = tokens[\"--tempest-danger-on-solid\"] === \"#ffffff\";\n const darker: ScaleStep = scheme === \"dark\" ? 400 : 700;\n const lighter: ScaleStep = scheme === \"dark\" ? 600 : 500;\n tokens[\"--tempest-danger-hover\"] = scale[whiteInk ? darker : lighter];\n }\n }\n\n const chart = options.chart?.length ? options.chart : DEFAULT_CHART_COLORS[scheme];\n chart.forEach((color, index) => {\n tokens[`--tempest-chart-${index + 1}`] = fitToward(\n color,\n direction,\n [bg, surface, glow],\n INDICATOR_FLOOR,\n ink,\n );\n });\n const coolHue = hueOf(options.chart?.[0] ?? options.primary);\n const warmHue = options.statuses?.danger\n ? hueOf(options.statuses.danger)\n : (coolHue + 180) % 360;\n buildRamp(coolHue, scheme).forEach((value, index) => {\n tokens[`--tempest-chart-sequential-${index + 1}`] = value;\n });\n const diverging = buildDivergingRamp({ coolHue, warmHue, mid: surface3, mode: scheme });\n [...diverging.cool, diverging.mid, ...diverging.warm].forEach((value, index) => {\n tokens[`--tempest-chart-diverging-${index + 1}`] = value;\n });\n tokens[\"--tempest-chart-grid\"] = tokens[\"--tempest-border\"] as string;\n tokens[\"--tempest-chart-axis\"] = tokens[\"--tempest-text-subtle\"] as string;\n\n const codeGrounds = [bg, surface, mix(surface, ink, 0.1)];\n CODE_TOKENS.forEach((name, index) => {\n tokens[`--tempest-code-${name}`] = fitToward(\n DEFAULT_CODE_COLORS[scheme][index] as string,\n direction,\n codeGrounds,\n TEXT_TARGET,\n ink,\n );\n });\n\n for (const [name, value] of Object.entries(SHADOWS[scheme])) {\n tokens[`--tempest-shadow-${name}`] = value;\n }\n\n return { tokens, scheme, glow };\n}\n\n/**\n * The gates a candidate fill must clear before it is accepted.\n *\n * Text reaches {@link MIN_TEXT_RATIO} on every surface, every fitted text token\n * clears AA where it is used, the ring clears 3:1 on every surface, and the\n * action label clears AA on all three button states.\n *\n * @param tokens - A derived token map.\n * @param glow - The fill lifted by {@link GLOW_OFFSET}, measured alongside the surfaces.\n * @returns The weakest margin over its floor across all gates; `>= 0` passes.\n */\nfunction margin(tokens: Record<string, string>, glow: string): number {\n const read = (name: string): string => tokens[name] as string;\n const surfaces = [\n read(\"--tempest-bg\"),\n read(\"--tempest-surface\"),\n read(\"--tempest-surface-2\"),\n read(\"--tempest-surface-3\"),\n ];\n const label = read(\"--tempest-primary-foreground\");\n const checks: number[] = [\n worst(read(\"--tempest-text\"), [...surfaces, glow]) / MIN_TEXT_RATIO,\n worst(read(\"--tempest-text-muted\"), [...surfaces, glow]) / AA_TEXT,\n worst(read(\"--tempest-text-subtle\"), [...surfaces.slice(0, 2), glow]) / AA_TEXT,\n worst(read(\"--tempest-focus-ring-color\"), [...surfaces, glow]) / INDICATOR_FLOOR,\n worst(label, [\n read(\"--tempest-primary\"),\n read(\"--tempest-primary-hover\"),\n read(\"--tempest-primary-active\"),\n ]) / AA_TEXT,\n ];\n return Math.min(...checks) - 1;\n}\n\n/**\n * Build the inverse surface for a brand.\n *\n * The fill is the brand's own `500` whenever it can carry the scheme, and\n * otherwise the nearest ramp step that can (see {@link FILL_CANDIDATES}). Whether\n * the surface reads light-on-dark or dark-on-light follows the fill, so a yellow\n * brand gets dark ink and a navy one white — the same pick `createTheme` makes\n * for `--tempest-primary-foreground`.\n *\n * The values are literal colors, not references to the page's ramp, so the\n * section paints the same in the light and the dark page scheme: the brand is\n * the brand in both.\n *\n * @param options - The brand, plus the status and chart colors the theme names.\n * @returns The token map, the scheme it reads as, and the fill step used.\n */\nexport function createInverseSurface(options: InverseSurfaceOptions): InverseSurface {\n const ramp = createColorScale(options.primary, \"light\");\n let best: InverseSurface | null = null;\n let bestMargin = Number.NEGATIVE_INFINITY;\n for (const step of FILL_CANDIDATES) {\n const derived = deriveOver(ramp[step], options);\n const measured = margin(derived.tokens, derived.glow);\n if (measured >= 0) return { tokens: derived.tokens, scheme: derived.scheme, step };\n if (measured > bestMargin) {\n best = { tokens: derived.tokens, scheme: derived.scheme, step };\n bestMargin = measured;\n }\n }\n return best as InverseSurface;\n}\n"],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,IAAI,GAAG,CAAM,IAAI;AACjC;AAkBA,SAAgB,EAAqB,GAAgD;CACjF,IAAM,IAAO,EAAiB,EAAQ,SAAS,OAAO,GAClD,IAA8B,MAC9B,IAAa;CACjB,KAAK,IAAM,KAAQ,GAAiB;EAChC,IAAM,IAAU,EAAW,EAAK,IAAO,CAAO,GACxC,IAAW,EAAO,EAAQ,QAAQ,EAAQ,IAAI;EACpD,IAAI,KAAY,GAAG,OAAO;GAAE,QAAQ,EAAQ;GAAQ,QAAQ,EAAQ;GAAQ;EAAK;EACjF,AAAI,IAAW,MACX,IAAO;GAAE,QAAQ,EAAQ;GAAQ,QAAQ,EAAQ;GAAQ;EAAK,GAC9D,IAAa;CAErB;CACA,OAAO;AACX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./color.cjs");var t=[`success`,`warning`,`danger`,`info`],n=`#1f0606`;function r(t,r,i,a){a===`light`?(t[`--tempest-${r}`]=i[700],t[`--tempest-${r}-fg`]=i[800],t[`--tempest-${r}-bg`]=i[50],t[`--tempest-${r}-border`]=i[200],t[`--tempest-${r}-solid`]=i[600],t[`--tempest-${r}-on-solid`]=e.readableForeground(i[600],`#ffffff`,n)):(t[`--tempest-${r}`]=i[700],t[`--tempest-${r}-fg`]=i[700],t[`--tempest-${r}-bg`]=i[50],t[`--tempest-${r}-border`]=i[200],t[`--tempest-${r}-solid`]=i[500],t[`--tempest-${r}-on-solid`]=e.readableForeground(i[500],`#ffffff`,n))}exports.ON_SOLID_INK=n,exports.THEME_STATUSES=t,exports.writeStatus=r;
|
|
2
|
+
//# sourceMappingURL=status-tokens.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-tokens.cjs","names":[],"sources":["../../src/theme/status-tokens.ts"],"sourcesContent":["/**\n * Status token families, shared by the page schemes {@link createTheme} emits and\n * by the inverse surface.\n */\nimport { readableForeground, type ColorScale } from \"./color\";\n\n/** Status token families that {@link createTheme} can regenerate. */\nexport type ThemeStatus = \"success\" | \"warning\" | \"danger\" | \"info\";\n\n/** The four status families, in the order they are emitted. */\nexport const THEME_STATUSES: readonly ThemeStatus[] = [\"success\", \"warning\", \"danger\", \"info\"];\n\n/**\n * The dark ink for content sitting on a saturated fill.\n *\n * Near-black tinted toward warm rather than pure black, matching the value\n * `colors.css` uses for the same job: it reads as part of the swatch instead of\n * a hole punched in it.\n */\nexport const ON_SOLID_INK = \"#1f0606\";\n\n/**\n * Emit one status family (`--tempest-danger`, `-fg`, `-bg`, `-border`, `-solid`).\n *\n * `-fg` is the text shade over `-bg`, so it has to cross the ramp in opposite\n * directions per scheme; `-solid` stays the saturated fill used by badges.\n *\n * `-on-solid` is derived from the `-solid` this call just emitted, rather than\n * left to fall through. Falling through was the bug: the SDK's own\n * `-on-solid` values are measured against the SDK's own fills, so a brand whose\n * `danger-600` lands light kept white ink over it and nothing said so. The\n * generated neutral hit exactly that — white over a generated `gray-700` of\n * `#a8b2c6` measures 2.13:1.\n *\n * @param tokens - The token map for this scheme, written in place.\n * @param name - Which status family.\n * @param scale - The generated ramp for that status, in the scheme's direction.\n * @param scheme - Which scheme is being emitted.\n */\nexport function writeStatus(\n tokens: Record<string, string>,\n name: ThemeStatus,\n scale: ColorScale,\n scheme: \"light\" | \"dark\",\n): void {\n if (scheme === \"light\") {\n tokens[`--tempest-${name}`] = scale[700];\n tokens[`--tempest-${name}-fg`] = scale[800];\n tokens[`--tempest-${name}-bg`] = scale[50];\n tokens[`--tempest-${name}-border`] = scale[200];\n tokens[`--tempest-${name}-solid`] = scale[600];\n tokens[`--tempest-${name}-on-solid`] = readableForeground(\n scale[600],\n \"#ffffff\",\n ON_SOLID_INK,\n );\n } else {\n tokens[`--tempest-${name}`] = scale[700];\n tokens[`--tempest-${name}-fg`] = scale[700];\n tokens[`--tempest-${name}-bg`] = scale[50];\n tokens[`--tempest-${name}-border`] = scale[200];\n tokens[`--tempest-${name}-solid`] = scale[500];\n tokens[`--tempest-${name}-on-solid`] = readableForeground(\n scale[500],\n \"#ffffff\",\n ON_SOLID_INK,\n );\n }\n}\n"],"mappings":"+BAUA,IAAa,EAAyC,CAAC,UAAW,UAAW,SAAU,MAAM,EAShF,EAAe,UAoB5B,SAAgB,EACZ,EACA,EACA,EACA,EACI,CACA,IAAW,SACX,EAAO,aAAa,KAAU,EAAM,KACpC,EAAO,aAAa,EAAK,MAAQ,EAAM,KACvC,EAAO,aAAa,EAAK,MAAQ,EAAM,IACvC,EAAO,aAAa,EAAK,UAAY,EAAM,KAC3C,EAAO,aAAa,EAAK,SAAW,EAAM,KAC1C,EAAO,aAAa,EAAK,YAAc,EAAA,mBACnC,EAAM,KACN,UACA,CACJ,IAEA,EAAO,aAAa,KAAU,EAAM,KACpC,EAAO,aAAa,EAAK,MAAQ,EAAM,KACvC,EAAO,aAAa,EAAK,MAAQ,EAAM,IACvC,EAAO,aAAa,EAAK,UAAY,EAAM,KAC3C,EAAO,aAAa,EAAK,SAAW,EAAM,KAC1C,EAAO,aAAa,EAAK,YAAc,EAAA,mBACnC,EAAM,KACN,UACA,CACJ,EAER"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { readableForeground as e } from "./color.js";
|
|
2
|
+
//#region src/theme/status-tokens.ts
|
|
3
|
+
var t = [
|
|
4
|
+
"success",
|
|
5
|
+
"warning",
|
|
6
|
+
"danger",
|
|
7
|
+
"info"
|
|
8
|
+
], n = "#1f0606";
|
|
9
|
+
function r(t, r, i, a) {
|
|
10
|
+
a === "light" ? (t[`--tempest-${r}`] = i[700], t[`--tempest-${r}-fg`] = i[800], t[`--tempest-${r}-bg`] = i[50], t[`--tempest-${r}-border`] = i[200], t[`--tempest-${r}-solid`] = i[600], t[`--tempest-${r}-on-solid`] = e(i[600], "#ffffff", n)) : (t[`--tempest-${r}`] = i[700], t[`--tempest-${r}-fg`] = i[700], t[`--tempest-${r}-bg`] = i[50], t[`--tempest-${r}-border`] = i[200], t[`--tempest-${r}-solid`] = i[500], t[`--tempest-${r}-on-solid`] = e(i[500], "#ffffff", n));
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as ON_SOLID_INK, t as THEME_STATUSES, r as writeStatus };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=status-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-tokens.js","names":[],"sources":["../../src/theme/status-tokens.ts"],"sourcesContent":["/**\n * Status token families, shared by the page schemes {@link createTheme} emits and\n * by the inverse surface.\n */\nimport { readableForeground, type ColorScale } from \"./color\";\n\n/** Status token families that {@link createTheme} can regenerate. */\nexport type ThemeStatus = \"success\" | \"warning\" | \"danger\" | \"info\";\n\n/** The four status families, in the order they are emitted. */\nexport const THEME_STATUSES: readonly ThemeStatus[] = [\"success\", \"warning\", \"danger\", \"info\"];\n\n/**\n * The dark ink for content sitting on a saturated fill.\n *\n * Near-black tinted toward warm rather than pure black, matching the value\n * `colors.css` uses for the same job: it reads as part of the swatch instead of\n * a hole punched in it.\n */\nexport const ON_SOLID_INK = \"#1f0606\";\n\n/**\n * Emit one status family (`--tempest-danger`, `-fg`, `-bg`, `-border`, `-solid`).\n *\n * `-fg` is the text shade over `-bg`, so it has to cross the ramp in opposite\n * directions per scheme; `-solid` stays the saturated fill used by badges.\n *\n * `-on-solid` is derived from the `-solid` this call just emitted, rather than\n * left to fall through. Falling through was the bug: the SDK's own\n * `-on-solid` values are measured against the SDK's own fills, so a brand whose\n * `danger-600` lands light kept white ink over it and nothing said so. The\n * generated neutral hit exactly that — white over a generated `gray-700` of\n * `#a8b2c6` measures 2.13:1.\n *\n * @param tokens - The token map for this scheme, written in place.\n * @param name - Which status family.\n * @param scale - The generated ramp for that status, in the scheme's direction.\n * @param scheme - Which scheme is being emitted.\n */\nexport function writeStatus(\n tokens: Record<string, string>,\n name: ThemeStatus,\n scale: ColorScale,\n scheme: \"light\" | \"dark\",\n): void {\n if (scheme === \"light\") {\n tokens[`--tempest-${name}`] = scale[700];\n tokens[`--tempest-${name}-fg`] = scale[800];\n tokens[`--tempest-${name}-bg`] = scale[50];\n tokens[`--tempest-${name}-border`] = scale[200];\n tokens[`--tempest-${name}-solid`] = scale[600];\n tokens[`--tempest-${name}-on-solid`] = readableForeground(\n scale[600],\n \"#ffffff\",\n ON_SOLID_INK,\n );\n } else {\n tokens[`--tempest-${name}`] = scale[700];\n tokens[`--tempest-${name}-fg`] = scale[700];\n tokens[`--tempest-${name}-bg`] = scale[50];\n tokens[`--tempest-${name}-border`] = scale[200];\n tokens[`--tempest-${name}-solid`] = scale[500];\n tokens[`--tempest-${name}-on-solid`] = readableForeground(\n scale[500],\n \"#ffffff\",\n ON_SOLID_INK,\n );\n }\n}\n"],"mappings":";;AAUA,IAAa,IAAyC;CAAC;CAAW;CAAW;CAAU;AAAM,GAShF,IAAe;AAoB5B,SAAgB,EACZ,GACA,GACA,GACA,GACI;CACJ,AAAI,MAAW,WACX,EAAO,aAAa,OAAU,EAAM,MACpC,EAAO,aAAa,EAAK,QAAQ,EAAM,MACvC,EAAO,aAAa,EAAK,QAAQ,EAAM,KACvC,EAAO,aAAa,EAAK,YAAY,EAAM,MAC3C,EAAO,aAAa,EAAK,WAAW,EAAM,MAC1C,EAAO,aAAa,EAAK,cAAc,EACnC,EAAM,MACN,WACA,CACJ,MAEA,EAAO,aAAa,OAAU,EAAM,MACpC,EAAO,aAAa,EAAK,QAAQ,EAAM,MACvC,EAAO,aAAa,EAAK,QAAQ,EAAM,KACvC,EAAO,aAAa,EAAK,YAAY,EAAM,MAC3C,EAAO,aAAa,EAAK,WAAW,EAAM,MAC1C,EAAO,aAAa,EAAK,cAAc,EACnC,EAAM,MACN,WACA,CACJ;AAER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.cjs","names":[],"sources":["../../../src/vision/core/graph.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * What the ONNX graph itself says about its inputs.\n *\n * The resolution a session must be fed at is a property of the exported model,\n * not of the configuration around it. Feeding a 640x640 tensor to a graph\n * exported at 224x224 makes ORT abort the run with\n * `Got invalid dimensions for input: images ... Got: 640 Expected: 224`, and the\n * caller has no way to see that coming from the outside — the number lives in\n * the file. So the SDK reads it from the graph and treats any configured size as\n * a fallback for when the graph leaves it open.\n */\n\nimport type * as ort from \"onnxruntime-web\";\n\n/**\n * One declared dimension: a number when the graph pins it, `null` when the\n * dimension is symbolic (dynamic).\n */\nexport type DeclaredDim = number | null;\n\n/** A declared input/output shape, dynamic axes appearing as `null`. */\nexport type DeclaredShape = readonly DeclaredDim[];\n\n/**\n * Convert ORT value metadata into declared shapes.\n *\n * @param metadata Metadata as reported by `InferenceSession.inputMetadata`, or\n * `undefined` on ORT builds that predate it (
|
|
1
|
+
{"version":3,"file":"graph.cjs","names":[],"sources":["../../../src/vision/core/graph.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * What the ONNX graph itself says about its inputs.\n *\n * The resolution a session must be fed at is a property of the exported model,\n * not of the configuration around it. Feeding a 640x640 tensor to a graph\n * exported at 224x224 makes ORT abort the run with\n * `Got invalid dimensions for input: images ... Got: 640 Expected: 224`, and the\n * caller has no way to see that coming from the outside — the number lives in\n * the file. So the SDK reads it from the graph and treats any configured size as\n * a fallback for when the graph leaves it open.\n */\n\nimport type * as ort from \"onnxruntime-web\";\n\n/**\n * One declared dimension: a number when the graph pins it, `null` when the\n * dimension is symbolic (dynamic).\n */\nexport type DeclaredDim = number | null;\n\n/** A declared input/output shape, dynamic axes appearing as `null`. */\nexport type DeclaredShape = readonly DeclaredDim[];\n\n/**\n * Convert ORT value metadata into declared shapes.\n *\n * @param metadata Metadata as reported by `InferenceSession.inputMetadata`, or\n * `undefined` on ORT builds that predate it (`onnxruntime-web` < 1.22,\n * measured). The session then falls back to the shapes in the model file.\n * @returns One shape per value, in declaration order. Non-tensor values and\n * builds without metadata yield empty shapes, which read as \"nothing\n * declared\" everywhere downstream.\n */\nexport function declaredShapesFrom(\n metadata: readonly ort.InferenceSession.ValueMetadata[] | undefined,\n): readonly DeclaredShape[] {\n if (metadata === undefined) return [];\n return metadata.map((value) =>\n value.isTensor\n ? value.shape.map((dim) =>\n typeof dim === \"number\" && Number.isInteger(dim) && dim > 0 ? dim : null,\n )\n : [],\n );\n}\n\n/**\n * Read the spatial input size out of a declared NCHW shape.\n *\n * @param shape The declared shape of the model's image input.\n * @returns `[width, height]` in pixels, or `null` when the shape is not 4D or\n * leaves either spatial axis dynamic — in which case the model accepts more\n * than one resolution and there is nothing to correct.\n */\nexport function spatialInputSize(shape: DeclaredShape): readonly [number, number] | null {\n if (shape.length !== 4) return null;\n const height = shape[2];\n const width = shape[3];\n if (height === null || height === undefined || width === null || width === undefined)\n return null;\n return [width, height];\n}\n\n/**\n * Infer how many classes a YOLO detection/segmentation head emits.\n *\n * Such a head declares `(B, 4 + nc, N)` — four box coordinates stacked above one\n * score per class, over `N` candidate anchors. `N` is in the thousands and the\n * batch is 1, so the channel axis is the smallest static axis above 1.\n *\n * @param shape Declared shape of the model's first output.\n * @returns The class count, or `null` when the shape leaves it undeterminable —\n * fully dynamic, or too small to hold boxes plus at least one class.\n */\nexport function detectionNumClasses(shape: DeclaredShape): number | null {\n const staticDims = shape.filter((dim): dim is number => dim !== null && dim > 1);\n if (staticDims.length === 0) return null;\n const channels = Math.min(...staticDims);\n if (channels < 5) return null;\n return channels - 4;\n}\n\n/**\n * Mask coefficients per anchor when no prototype shape says otherwise.\n *\n * Every Ultralytics seg head (v8, v11) emits 32; it is the fallback when the\n * prototype output's channel axis is dynamic or the runtime reports no shapes.\n */\nconst DEFAULT_MASK_COEFS = 32;\n\n/**\n * Infer how many classes a YOLO segmentation head emits.\n *\n * The per-anchor output declares `(B, 4 + nc + nm, N)`: the detection layout\n * with `nm` mask coefficients stacked under the class scores. Reading it with\n * {@link detectionNumClasses} counts those coefficients as classes — 33 for a\n * one-class YOLO11n-seg, 112 for a COCO one — and the label check then rejects\n * the model's own baked-in names. `nm` is the channel axis of the prototype\n * output `(B, nm, H, W)`, so it is read from there.\n *\n * @param shapes Declared shapes of every output, in declaration order.\n * @returns The class count, or `null` when the per-anchor shape is missing or\n * leaves it undeterminable.\n */\nexport function segmentationNumClasses(shapes: readonly DeclaredShape[]): number | null {\n const perAnchor = shapes.find((shape) => shape.length === 3);\n if (perAnchor === undefined) return null;\n const staticDims = perAnchor.filter((dim): dim is number => dim !== null && dim > 1);\n if (staticDims.length === 0) return null;\n const channels = Math.min(...staticDims);\n const prototypes = shapes.find((shape) => shape.length === 4);\n const declared = prototypes?.[1];\n const coefs = typeof declared === \"number\" && declared > 0 ? declared : DEFAULT_MASK_COEFS;\n const classes = channels - 4 - coefs;\n return classes > 0 ? classes : null;\n}\n\n/**\n * Infer how many classes a classification head emits.\n *\n * A classifier declares `(B, nc)`, so the count is the last static axis.\n *\n * @param shape Declared shape of the model's first output.\n * @returns The class count, or `null` when the last axis is dynamic or absent.\n */\nexport function classificationNumClasses(shape: DeclaredShape): number | null {\n const last = shape[shape.length - 1];\n if (last === null || last === undefined || last < 1) return null;\n return last;\n}\n\nexport interface ResolveInputSizeOptions {\n /** Declared shape of the model's image input, from {@link declaredShapesFrom}. */\n readonly graphShape?: DeclaredShape;\n /** Size the caller asked for, if any. */\n readonly requested?: readonly [number, number];\n /** Size to use when neither the graph nor the caller pins one. */\n readonly fallback: readonly [number, number];\n}\n\n/**\n * Decide the input size a task will preprocess to.\n *\n * Precedence is graph → caller → fallback. The graph wins over an explicit\n * `inputSize` because a static shape is not a preference, it is what ORT will\n * accept: honoring the caller there would only turn a fixable mismatch into a\n * failed run. A disagreement is a configuration bug in the caller, so it is\n * reported through `console.warn` instead of being swallowed.\n *\n * @param options Graph shape, requested size and per-task fallback.\n * @returns The `[width, height]` to preprocess to.\n */\nexport function resolveInputSize(options: ResolveInputSizeOptions): readonly [number, number] {\n const graph = options.graphShape === undefined ? null : spatialInputSize(options.graphShape);\n const requested = options.requested;\n if (graph === null) return requested ?? options.fallback;\n if (requested !== undefined && (requested[0] !== graph[0] || requested[1] !== graph[1])) {\n console.warn(\n `[ort-vision-sdk] The model declares a ${graph[0]}x${graph[1]} input; ` +\n `ignoring the requested ${requested[0]}x${requested[1]}, which ONNX Runtime would reject.`,\n );\n }\n return graph;\n}\n"],"mappings":"AAkCA,SAAgB,EACZ,EACwB,CAExB,OADI,IAAa,IAAA,GAAkB,CAAC,EAC7B,EAAS,IAAK,GACjB,EAAM,SACA,EAAM,MAAM,IAAK,GACb,OAAO,GAAQ,UAAY,OAAO,UAAU,CAAG,GAAK,EAAM,EAAI,EAAM,IACxE,EACA,CAAC,CACX,CACJ,CAUA,SAAgB,EAAiB,EAAwD,CACrF,GAAI,EAAM,SAAW,EAAG,OAAO,KAC/B,IAAM,EAAS,EAAM,GACf,EAAQ,EAAM,GAGpB,OAFI,GAAW,MAAgC,GAAU,KAC9C,KACJ,CAAC,EAAO,CAAM,CACzB,CAaA,SAAgB,EAAoB,EAAqC,CACrE,IAAM,EAAa,EAAM,OAAQ,GAAuB,IAAQ,MAAQ,EAAM,CAAC,EAC/E,GAAI,EAAW,SAAW,EAAG,OAAO,KACpC,IAAM,EAAW,KAAK,IAAI,GAAG,CAAU,EAEvC,OADI,EAAW,EAAU,KAClB,EAAW,CACtB,CAwBA,SAAgB,EAAuB,EAAiD,CACpF,IAAM,EAAY,EAAO,KAAM,GAAU,EAAM,SAAW,CAAC,EAC3D,GAAI,IAAc,IAAA,GAAW,OAAO,KACpC,IAAM,EAAa,EAAU,OAAQ,GAAuB,IAAQ,MAAQ,EAAM,CAAC,EACnF,GAAI,EAAW,SAAW,EAAG,OAAO,KACpC,IAAM,EAAW,KAAK,IAAI,GAAG,CAAU,EAEjC,EADa,EAAO,KAAM,GAAU,EAAM,SAAW,CAC1C,CAAA,GAAa,GACxB,EAAQ,OAAO,GAAa,UAAY,EAAW,EAAI,EAAW,GAClE,EAAU,EAAW,EAAI,EAC/B,OAAO,EAAU,EAAI,EAAU,IACnC,CAUA,SAAgB,EAAyB,EAAqC,CAC1E,IAAM,EAAO,EAAM,EAAM,OAAS,GAElC,OADI,GAAS,MAA8B,EAAO,EAAU,KACrD,CACX,CAuBA,SAAgB,EAAiB,EAA6D,CAC1F,IAAM,EAAQ,EAAQ,aAAe,IAAA,GAAY,KAAO,EAAiB,EAAQ,UAAU,EACrF,EAAY,EAAQ,UAQ1B,OAPI,IAAU,KAAa,GAAa,EAAQ,UAC5C,IAAc,IAAA,KAAc,EAAU,KAAO,EAAM,IAAM,EAAU,KAAO,EAAM,KAChF,QAAQ,KACJ,yCAAyC,EAAM,GAAG,GAAG,EAAM,GAAG,iCAChC,EAAU,GAAG,GAAG,EAAU,GAAG,mCAC/D,EAEG,EACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.js","names":[],"sources":["../../../src/vision/core/graph.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * What the ONNX graph itself says about its inputs.\n *\n * The resolution a session must be fed at is a property of the exported model,\n * not of the configuration around it. Feeding a 640x640 tensor to a graph\n * exported at 224x224 makes ORT abort the run with\n * `Got invalid dimensions for input: images ... Got: 640 Expected: 224`, and the\n * caller has no way to see that coming from the outside — the number lives in\n * the file. So the SDK reads it from the graph and treats any configured size as\n * a fallback for when the graph leaves it open.\n */\n\nimport type * as ort from \"onnxruntime-web\";\n\n/**\n * One declared dimension: a number when the graph pins it, `null` when the\n * dimension is symbolic (dynamic).\n */\nexport type DeclaredDim = number | null;\n\n/** A declared input/output shape, dynamic axes appearing as `null`. */\nexport type DeclaredShape = readonly DeclaredDim[];\n\n/**\n * Convert ORT value metadata into declared shapes.\n *\n * @param metadata Metadata as reported by `InferenceSession.inputMetadata`, or\n * `undefined` on ORT builds that predate it (
|
|
1
|
+
{"version":3,"file":"graph.js","names":[],"sources":["../../../src/vision/core/graph.ts"],"sourcesContent":["/** @generated Vendored from @mauriciobenjamin700/ort-vision-sdk-web. Do not hand-edit — regenerate with `npm run vendor:vision`. */\n/**\n * What the ONNX graph itself says about its inputs.\n *\n * The resolution a session must be fed at is a property of the exported model,\n * not of the configuration around it. Feeding a 640x640 tensor to a graph\n * exported at 224x224 makes ORT abort the run with\n * `Got invalid dimensions for input: images ... Got: 640 Expected: 224`, and the\n * caller has no way to see that coming from the outside — the number lives in\n * the file. So the SDK reads it from the graph and treats any configured size as\n * a fallback for when the graph leaves it open.\n */\n\nimport type * as ort from \"onnxruntime-web\";\n\n/**\n * One declared dimension: a number when the graph pins it, `null` when the\n * dimension is symbolic (dynamic).\n */\nexport type DeclaredDim = number | null;\n\n/** A declared input/output shape, dynamic axes appearing as `null`. */\nexport type DeclaredShape = readonly DeclaredDim[];\n\n/**\n * Convert ORT value metadata into declared shapes.\n *\n * @param metadata Metadata as reported by `InferenceSession.inputMetadata`, or\n * `undefined` on ORT builds that predate it (`onnxruntime-web` < 1.22,\n * measured). The session then falls back to the shapes in the model file.\n * @returns One shape per value, in declaration order. Non-tensor values and\n * builds without metadata yield empty shapes, which read as \"nothing\n * declared\" everywhere downstream.\n */\nexport function declaredShapesFrom(\n metadata: readonly ort.InferenceSession.ValueMetadata[] | undefined,\n): readonly DeclaredShape[] {\n if (metadata === undefined) return [];\n return metadata.map((value) =>\n value.isTensor\n ? value.shape.map((dim) =>\n typeof dim === \"number\" && Number.isInteger(dim) && dim > 0 ? dim : null,\n )\n : [],\n );\n}\n\n/**\n * Read the spatial input size out of a declared NCHW shape.\n *\n * @param shape The declared shape of the model's image input.\n * @returns `[width, height]` in pixels, or `null` when the shape is not 4D or\n * leaves either spatial axis dynamic — in which case the model accepts more\n * than one resolution and there is nothing to correct.\n */\nexport function spatialInputSize(shape: DeclaredShape): readonly [number, number] | null {\n if (shape.length !== 4) return null;\n const height = shape[2];\n const width = shape[3];\n if (height === null || height === undefined || width === null || width === undefined)\n return null;\n return [width, height];\n}\n\n/**\n * Infer how many classes a YOLO detection/segmentation head emits.\n *\n * Such a head declares `(B, 4 + nc, N)` — four box coordinates stacked above one\n * score per class, over `N` candidate anchors. `N` is in the thousands and the\n * batch is 1, so the channel axis is the smallest static axis above 1.\n *\n * @param shape Declared shape of the model's first output.\n * @returns The class count, or `null` when the shape leaves it undeterminable —\n * fully dynamic, or too small to hold boxes plus at least one class.\n */\nexport function detectionNumClasses(shape: DeclaredShape): number | null {\n const staticDims = shape.filter((dim): dim is number => dim !== null && dim > 1);\n if (staticDims.length === 0) return null;\n const channels = Math.min(...staticDims);\n if (channels < 5) return null;\n return channels - 4;\n}\n\n/**\n * Mask coefficients per anchor when no prototype shape says otherwise.\n *\n * Every Ultralytics seg head (v8, v11) emits 32; it is the fallback when the\n * prototype output's channel axis is dynamic or the runtime reports no shapes.\n */\nconst DEFAULT_MASK_COEFS = 32;\n\n/**\n * Infer how many classes a YOLO segmentation head emits.\n *\n * The per-anchor output declares `(B, 4 + nc + nm, N)`: the detection layout\n * with `nm` mask coefficients stacked under the class scores. Reading it with\n * {@link detectionNumClasses} counts those coefficients as classes — 33 for a\n * one-class YOLO11n-seg, 112 for a COCO one — and the label check then rejects\n * the model's own baked-in names. `nm` is the channel axis of the prototype\n * output `(B, nm, H, W)`, so it is read from there.\n *\n * @param shapes Declared shapes of every output, in declaration order.\n * @returns The class count, or `null` when the per-anchor shape is missing or\n * leaves it undeterminable.\n */\nexport function segmentationNumClasses(shapes: readonly DeclaredShape[]): number | null {\n const perAnchor = shapes.find((shape) => shape.length === 3);\n if (perAnchor === undefined) return null;\n const staticDims = perAnchor.filter((dim): dim is number => dim !== null && dim > 1);\n if (staticDims.length === 0) return null;\n const channels = Math.min(...staticDims);\n const prototypes = shapes.find((shape) => shape.length === 4);\n const declared = prototypes?.[1];\n const coefs = typeof declared === \"number\" && declared > 0 ? declared : DEFAULT_MASK_COEFS;\n const classes = channels - 4 - coefs;\n return classes > 0 ? classes : null;\n}\n\n/**\n * Infer how many classes a classification head emits.\n *\n * A classifier declares `(B, nc)`, so the count is the last static axis.\n *\n * @param shape Declared shape of the model's first output.\n * @returns The class count, or `null` when the last axis is dynamic or absent.\n */\nexport function classificationNumClasses(shape: DeclaredShape): number | null {\n const last = shape[shape.length - 1];\n if (last === null || last === undefined || last < 1) return null;\n return last;\n}\n\nexport interface ResolveInputSizeOptions {\n /** Declared shape of the model's image input, from {@link declaredShapesFrom}. */\n readonly graphShape?: DeclaredShape;\n /** Size the caller asked for, if any. */\n readonly requested?: readonly [number, number];\n /** Size to use when neither the graph nor the caller pins one. */\n readonly fallback: readonly [number, number];\n}\n\n/**\n * Decide the input size a task will preprocess to.\n *\n * Precedence is graph → caller → fallback. The graph wins over an explicit\n * `inputSize` because a static shape is not a preference, it is what ORT will\n * accept: honoring the caller there would only turn a fixable mismatch into a\n * failed run. A disagreement is a configuration bug in the caller, so it is\n * reported through `console.warn` instead of being swallowed.\n *\n * @param options Graph shape, requested size and per-task fallback.\n * @returns The `[width, height]` to preprocess to.\n */\nexport function resolveInputSize(options: ResolveInputSizeOptions): readonly [number, number] {\n const graph = options.graphShape === undefined ? null : spatialInputSize(options.graphShape);\n const requested = options.requested;\n if (graph === null) return requested ?? options.fallback;\n if (requested !== undefined && (requested[0] !== graph[0] || requested[1] !== graph[1])) {\n console.warn(\n `[ort-vision-sdk] The model declares a ${graph[0]}x${graph[1]} input; ` +\n `ignoring the requested ${requested[0]}x${requested[1]}, which ONNX Runtime would reject.`,\n );\n }\n return graph;\n}\n"],"mappings":";AAkCA,SAAgB,EACZ,GACwB;CAExB,OADI,MAAa,KAAA,IAAkB,CAAC,IAC7B,EAAS,KAAK,MACjB,EAAM,WACA,EAAM,MAAM,KAAK,MACb,OAAO,KAAQ,YAAY,OAAO,UAAU,CAAG,KAAK,IAAM,IAAI,IAAM,IACxE,IACA,CAAC,CACX;AACJ;AAUA,SAAgB,EAAiB,GAAwD;CACrF,IAA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GAEG;AACX"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
function e(e){let t=0,n=0;for(;e.pos<e.end;){let r=e.bytes[e.pos];if(e.pos+=1,t+=(r&127)*2**n,!(r&128))return t;if(n+=7,n>63)return null}return null}function t(t,n){switch(n){case 0:return e(t)!==null;case 1:return t.pos+=8,t.pos<=t.end;case 2:{let n=e(t);return n!==null&&(t.pos+=n,t.pos<=t.end)}case 5:return t.pos+=4,t.pos<=t.end;default:return!1}}function n(t,n=1048576){let r=e(t);if(r===null||r>n)return null;let i=t.pos,a=i+r;return a>t.end?null:(t.pos=a,{start:i,end:a})}function r(r,i,a){let o={bytes:r,end:a,pos:i},s=new TextDecoder(`utf-8`,{fatal:!1}),c=null,l=null;for(;o.pos<a;){let i=e(o);if(i===null)return null;let a=i>>>3,u=i&7;if(u===2&&(a===1||a===2)){let e=n(o);if(e===null)return null;let t=s.decode(r.subarray(e.start,e.end));a===1?c=t:l=t;continue}if(!t(o,u))return null}return c===null||l===null?null:[c,l]}function i(i){let a=i instanceof Uint8Array?i:new Uint8Array(i),o={bytes:a,end:a.length,pos:0},s={};for(;o.pos<o.end;){let i=e(o);if(i===null)break;let c=i>>>3,l=i&7;if(c===14&&l===2){let e=n(o);if(e===null)break;let t=r(a,e.start,e.end);t&&(s[t[0]]=t[1]);continue}if(!t(o,l))break}return s}function
|
|
2
|
-
`:t===`r`?`\r`:t===`t`?` `:t)}exports.modelNames=
|
|
1
|
+
function e(e){let t=0,n=0;for(;e.pos<e.end;){let r=e.bytes[e.pos];if(e.pos+=1,t+=(r&127)*2**n,!(r&128))return t;if(n+=7,n>63)return null}return null}function t(t,n){switch(n){case 0:return e(t)!==null;case 1:return t.pos+=8,t.pos<=t.end;case 2:{let n=e(t);return n!==null&&(t.pos+=n,t.pos<=t.end)}case 5:return t.pos+=4,t.pos<=t.end;default:return!1}}function n(t,n=1048576){let r=e(t);if(r===null||r>n)return null;let i=t.pos,a=i+r;return a>t.end?null:(t.pos=a,{start:i,end:a})}function r(r,i,a){let o={bytes:r,end:a,pos:i},s=new TextDecoder(`utf-8`,{fatal:!1}),c=null,l=null;for(;o.pos<a;){let i=e(o);if(i===null)return null;let a=i>>>3,u=i&7;if(u===2&&(a===1||a===2)){let e=n(o);if(e===null)return null;let t=s.decode(r.subarray(e.start,e.end));a===1?c=t:l=t;continue}if(!t(o,u))return null}return c===null||l===null?null:[c,l]}function i(i){let a=i instanceof Uint8Array?i:new Uint8Array(i),o={bytes:a,end:a.length,pos:0},s={};for(;o.pos<o.end;){let i=e(o);if(i===null)break;let c=i>>>3,l=i&7;if(c===14&&l===2){let e=n(o);if(e===null)break;let t=r(a,e.start,e.end);t&&(s[t[0]]=t[1]);continue}if(!t(o,l))break}return s}var a={elemType:null,shape:[]};function o(n,r,i){let a={bytes:n,end:i,pos:r};for(;a.pos<a.end;){let n=e(a);if(n===null)return null;let r=n>>>3,i=n&7;if(r===1&&i===0){let t=e(a);return t!==null&&Number.isSafeInteger(t)&&t>0?t:null}if(!t(a,i))return null}return null}function s(r,i,a){let s={bytes:r,end:a,pos:i},c=[];for(;s.pos<s.end;){let i=e(s);if(i===null)return[];let a=i>>>3,l=i&7;if(a===1&&l===2){let e=n(s);if(e===null)return[];c.push(o(r,e.start,e.end));continue}if(!t(s,l))return[]}return c}function c(r,i,a){let o={bytes:r,end:a,pos:i},c=null,l=[];for(;o.pos<o.end;){let i=e(o);if(i===null)break;let a=i>>>3,u=i&7;if(a===1&&u===0){c=e(o);continue}if(a===2&&u===2){let e=n(o);if(e===null)break;l=s(r,e.start,e.end);continue}if(!t(o,u))break}return{elemType:c,shape:l}}function l(r,i,o){let s={bytes:r,end:o,pos:i};for(;s.pos<s.end;){let i=e(s);if(i===null)return a;let o=i>>>3,l=i&7;if(o===1&&l===2){let e=n(s);return e===null?a:c(r,e.start,e.end)}if(!t(s,l))return a}return a}function u(r,i,o){let s={bytes:r,end:o,pos:i},c=null,u=a;for(;s.pos<s.end;){let i=e(s);if(i===null)return null;let a=i>>>3,o=i&7;if(o===2){let e=n(s);if(e===null)return null;a===1?c=new TextDecoder(`utf-8`,{fatal:!1}).decode(r.subarray(e.start,e.end)):a===2&&(u=l(r,e.start,e.end));continue}if(!t(s,o))return null}return c===null?null:{name:c,...u}}function d(r){let i=r instanceof Uint8Array?r:new Uint8Array(r),a={bytes:i,end:i.length,pos:0},o=[],s=[];for(;a.pos<a.end;){let r=e(a);if(r===null)break;let c=r>>>3,l=r&7;if(c===7&&l===2){let r=n(a,i.length);if(r===null)break;let c={bytes:i,end:r.end,pos:r.start};for(;c.pos<c.end;){let r=e(c);if(r===null)break;let a=r>>>3,l=r&7;if((a===11||a===12)&&l===2){let e=n(c);if(e===null)break;let t=u(i,e.start,e.end);t&&(a===11?o:s).push(t);continue}if(!t(c,l))break}continue}if(!t(a,l))break}return{inputs:o,outputs:s}}function f(e){let t={};for(let n of d(e).inputs)n.elemType!==null&&(t[n.name]=n.elemType);return t}function p(e){let{inputs:t,outputs:n}=d(e);return{inputs:Object.fromEntries(t.map(e=>[e.name,e.shape])),outputs:Object.fromEntries(n.map(e=>[e.name,e.shape]))}}function m(e){return h(e?.names)}function h(e){let t=e?.trim();if(!t||!t.startsWith(`{`)||!t.endsWith(`}`))return null;let n=t.slice(1,-1).trim();if(!n)return null;let r=new Map,i=/(-?\d+)\s*:\s*(?:'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)")/g,a=0;for(let e of n.matchAll(i)){let t=Number(e[1]),n=e[2]??e[3];if(!Number.isInteger(t)||n===void 0)return null;r.set(t,g(n)),a+=e[0].length}if(r.size===0||n.length-a>r.size*3)return null;let o=[];for(let e=0;e<r.size;e+=1){let t=r.get(e);if(t===void 0)return null;o.push(t)}return o}function g(e){return e.replace(/\\(.)/g,(e,t)=>t===`n`?`
|
|
2
|
+
`:t===`r`?`\r`:t===`t`?` `:t)}exports.modelNames=m,exports.parseNames=h,exports.readModelInputTypes=f,exports.readModelMetadata=i,exports.readModelShapes=p;
|
|
3
3
|
//# sourceMappingURL=metadata.cjs.map
|