@wafertools/wafermap 0.40.0 → 0.41.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/AGENTS.md +20 -21
- package/CHANGELOG.md +154 -0
- package/README.md +6 -6
- package/dist/packages/canvas-adapter/canvasTheme.d.ts +12 -0
- package/dist/packages/canvas-adapter/canvasTheme.js +1 -1
- package/dist/packages/canvas-adapter/cellShade.d.ts +2 -2
- package/dist/packages/canvas-adapter/cellShade.js +1 -1
- package/dist/packages/canvas-adapter/chartPopulation.d.ts +3 -0
- package/dist/packages/canvas-adapter/chartPopulation.js +1 -1
- package/dist/packages/canvas-adapter/charts/capability.d.ts +3 -0
- package/dist/packages/canvas-adapter/charts/capability.js +1 -1
- package/dist/packages/canvas-adapter/charts/cardAbout.d.ts +2 -1
- package/dist/packages/canvas-adapter/charts/cardAbout.js +1 -1
- package/dist/packages/canvas-adapter/charts/chartShell.d.ts +47 -27
- package/dist/packages/canvas-adapter/charts/chartShell.js +1 -1
- package/dist/packages/canvas-adapter/charts/commonality.js +4 -4
- package/dist/packages/canvas-adapter/charts/correlation.d.ts +6 -12
- package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
- package/dist/packages/canvas-adapter/charts/divergingScale.d.ts +45 -15
- package/dist/packages/canvas-adapter/charts/divergingScale.js +1 -1
- package/dist/packages/canvas-adapter/charts/groupComparison.js +1 -1
- package/dist/packages/canvas-adapter/charts/palette.d.ts +16 -30
- package/dist/packages/canvas-adapter/charts/palette.js +1 -1
- package/dist/packages/canvas-adapter/charts/patCard.js +1 -1
- package/dist/packages/canvas-adapter/charts/plotChart.d.ts +29 -3
- package/dist/packages/canvas-adapter/charts/plotChart.js +1 -1
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.d.ts +3 -0
- package/dist/packages/canvas-adapter/charts/regionYieldDiagram.js +1 -1
- package/dist/packages/canvas-adapter/charts/sweep.d.ts +3 -0
- package/dist/packages/canvas-adapter/charts/sweep.js +1 -1
- package/dist/packages/canvas-adapter/chromeRow.d.ts +68 -0
- package/dist/packages/canvas-adapter/chromeRow.js +1 -0
- package/dist/packages/canvas-adapter/chunked.d.ts +6 -0
- package/dist/packages/canvas-adapter/chunked.js +1 -1
- package/dist/packages/canvas-adapter/columnFilterPopup.d.ts +25 -0
- package/dist/packages/canvas-adapter/columnFilterPopup.js +1 -0
- package/dist/packages/canvas-adapter/composePng.d.ts +37 -0
- package/dist/packages/canvas-adapter/composePng.js +1 -0
- package/dist/packages/canvas-adapter/dataTab.d.ts +39 -6
- package/dist/packages/canvas-adapter/dataTab.js +1 -1
- package/dist/packages/canvas-adapter/dieList.js +1 -1
- package/dist/packages/canvas-adapter/differenceMapPanel.d.ts +3 -1
- package/dist/packages/canvas-adapter/differenceMapPanel.js +1 -1
- package/dist/packages/canvas-adapter/drilldown.d.ts +20 -1
- package/dist/packages/canvas-adapter/drilldown.js +1 -1
- package/dist/packages/canvas-adapter/filterButton.d.ts +2 -0
- package/dist/packages/canvas-adapter/filterButton.js +1 -1
- package/dist/packages/canvas-adapter/filterEditor.d.ts +5 -0
- package/dist/packages/canvas-adapter/filterEditor.js +1 -1
- package/dist/packages/canvas-adapter/guideWindow.js +1 -1
- package/dist/packages/canvas-adapter/icons.js +1 -1
- package/dist/packages/canvas-adapter/identityHeader.d.ts +5 -0
- package/dist/packages/canvas-adapter/identityHeader.js +1 -1
- package/dist/packages/canvas-adapter/index.d.ts +7 -0
- package/dist/packages/canvas-adapter/index.js +1 -1
- package/dist/packages/canvas-adapter/insightsTab.d.ts +32 -9
- package/dist/packages/canvas-adapter/insightsTab.js +1 -1
- package/dist/packages/canvas-adapter/maplessSummary.d.ts +4 -2
- package/dist/packages/canvas-adapter/maplessSummary.js +1 -1
- package/dist/packages/canvas-adapter/openWaferMode.d.ts +7 -0
- package/dist/packages/canvas-adapter/openWaferMode.js +1 -0
- package/dist/packages/canvas-adapter/panelChart.d.ts +7 -0
- package/dist/packages/canvas-adapter/panelChart.js +1 -0
- package/dist/packages/canvas-adapter/panelTable.d.ts +50 -0
- package/dist/packages/canvas-adapter/panelTable.js +1 -0
- package/dist/packages/canvas-adapter/plotCard.js +1 -1
- package/dist/packages/canvas-adapter/plotEditor.d.ts +12 -0
- package/dist/packages/canvas-adapter/plotEditor.js +10 -10
- package/dist/packages/canvas-adapter/plotItems.d.ts +9 -4
- package/dist/packages/canvas-adapter/plotItems.js +1 -1
- package/dist/packages/canvas-adapter/plotJsonComplete.js +1 -1
- package/dist/packages/canvas-adapter/plotModal.d.ts +7 -0
- package/dist/packages/canvas-adapter/plotModal.js +1 -1
- package/dist/packages/canvas-adapter/plotStore.js +1 -1
- package/dist/packages/canvas-adapter/plotTab.d.ts +60 -2
- package/dist/packages/canvas-adapter/plotTab.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +7 -0
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.d.ts +41 -9
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/reportCharts.d.ts +41 -0
- package/dist/packages/canvas-adapter/reportCharts.js +1 -0
- package/dist/packages/canvas-adapter/reportExport.d.ts +91 -0
- package/dist/packages/canvas-adapter/reportExport.js +1 -0
- package/dist/packages/canvas-adapter/reportFigures.d.ts +29 -0
- package/dist/packages/canvas-adapter/reportFigures.js +1 -0
- package/dist/packages/canvas-adapter/reportRun.d.ts +9 -0
- package/dist/packages/canvas-adapter/reportRun.js +1 -0
- package/dist/packages/canvas-adapter/selectionOverlay.d.ts +12 -0
- package/dist/packages/canvas-adapter/selectionOverlay.js +1 -0
- package/dist/packages/canvas-adapter/summaryPanel.d.ts +152 -111
- package/dist/packages/canvas-adapter/summaryPanel.js +7 -4
- package/dist/packages/canvas-adapter/summaryToggle.js +1 -1
- package/dist/packages/canvas-adapter/tableDrilldown.d.ts +48 -0
- package/dist/packages/canvas-adapter/tableDrilldown.js +1 -0
- package/dist/packages/canvas-adapter/tableFilter.d.ts +42 -0
- package/dist/packages/canvas-adapter/tableFilter.js +1 -0
- package/dist/packages/canvas-adapter/tablePlots.d.ts +85 -0
- package/dist/packages/canvas-adapter/tablePlots.js +1 -0
- package/dist/packages/canvas-adapter/themeWatch.d.ts +7 -0
- package/dist/packages/canvas-adapter/themeWatch.js +1 -0
- package/dist/packages/canvas-adapter/toCanvas.d.ts +3 -0
- package/dist/packages/canvas-adapter/toCanvas.js +1 -1
- package/dist/packages/canvas-adapter/toolbar.d.ts +125 -36
- package/dist/packages/canvas-adapter/toolbar.js +2 -2
- package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
- package/dist/packages/canvas-adapter/userGuideHtml.js +530 -414
- package/dist/packages/canvas-adapter/version.d.ts +2 -2
- package/dist/packages/canvas-adapter/version.js +1 -1
- package/dist/packages/canvas-adapter/viewSwitch.js +1 -1
- package/dist/packages/canvas-adapter/virtualTable.d.ts +37 -7
- package/dist/packages/canvas-adapter/virtualTable.js +1 -1
- package/dist/packages/core/aggregates.d.ts +14 -0
- package/dist/packages/core/aggregates.js +1 -1
- package/dist/packages/core/dies.d.ts +7 -0
- package/dist/packages/core/dies.js +1 -1
- package/dist/packages/core/utils.d.ts +2 -0
- package/dist/packages/core/utils.js +1 -1
- package/dist/packages/experimental/charts.d.ts +4 -0
- package/dist/packages/experimental/charts.js +1 -0
- package/dist/packages/renderer/binColors.d.ts +6 -2
- package/dist/packages/renderer/binColors.js +1 -1
- package/dist/packages/renderer/buildView.d.ts +36 -14
- package/dist/packages/renderer/buildView.js +1 -1
- package/dist/packages/renderer/buildWaferMap.d.ts +8 -0
- package/dist/packages/renderer/buildWaferMap.js +1 -1
- package/dist/packages/renderer/categoryColors.d.ts +3 -0
- package/dist/packages/renderer/categoryColors.js +1 -0
- package/dist/packages/renderer/colorMap.d.ts +15 -16
- package/dist/packages/renderer/colorMap.js +1 -1
- package/dist/packages/renderer/colorSchemes.d.ts +34 -30
- package/dist/packages/renderer/colorSchemes.js +1 -1
- package/dist/packages/renderer/dataColors.d.ts +126 -0
- package/dist/packages/renderer/dataColors.js +1 -0
- package/dist/packages/renderer/deprecate.js +1 -1
- package/dist/packages/renderer/fmt.d.ts +16 -0
- package/dist/packages/renderer/fmt.js +1 -1
- package/dist/packages/renderer/index.d.ts +2 -0
- package/dist/packages/renderer/index.js +1 -1
- package/dist/packages/renderer/spec.d.ts +5 -0
- package/dist/packages/renderer/spec.js +1 -1
- package/dist/packages/renderer/stacks.d.ts +21 -0
- package/dist/packages/renderer/stacks.js +1 -0
- package/dist/packages/renderer/timeAxis.d.ts +19 -0
- package/dist/packages/renderer/timeAxis.js +1 -0
- package/dist/packages/stats/analyzeWaferLot.js +1 -1
- package/dist/packages/stats/analyzeWaferMap.d.ts +2 -4
- package/dist/packages/stats/analyzeWaferMap.js +1 -1
- package/dist/packages/stats/binRows.js +1 -1
- package/dist/packages/stats/binShifts.d.ts +59 -0
- package/dist/packages/stats/binShifts.js +1 -0
- package/dist/packages/stats/capability.d.ts +6 -1
- package/dist/packages/stats/capability.js +1 -1
- package/dist/packages/stats/chartCatalogue.d.ts +3 -0
- package/dist/packages/stats/chartCatalogue.js +1 -1
- package/dist/packages/stats/clusterDetection.js +1 -1
- package/dist/packages/stats/columnPlot.d.ts +38 -0
- package/dist/packages/stats/columnPlot.js +1 -0
- package/dist/packages/stats/commonality.d.ts +8 -1
- package/dist/packages/stats/commonality.js +1 -1
- package/dist/packages/stats/correlation.d.ts +7 -2
- package/dist/packages/stats/correlation.js +1 -1
- package/dist/packages/stats/dataTable.d.ts +44 -0
- package/dist/packages/stats/dataTable.js +1 -0
- package/dist/packages/stats/dieRegions.js +1 -1
- package/dist/packages/stats/examplePicks.js +1 -1
- package/dist/packages/stats/facets.d.ts +11 -0
- package/dist/packages/stats/facets.js +1 -1
- package/dist/packages/stats/filterFindings.d.ts +21 -0
- package/dist/packages/stats/filterFindings.js +1 -1
- package/dist/packages/stats/groupEffects.d.ts +8 -0
- package/dist/packages/stats/groupEffects.js +1 -1
- package/dist/packages/stats/math.d.ts +2 -0
- package/dist/packages/stats/math.js +1 -1
- package/dist/packages/stats/overview.d.ts +114 -0
- package/dist/packages/stats/overview.js +1 -0
- package/dist/packages/stats/pat.d.ts +0 -2
- package/dist/packages/stats/pat.js +1 -1
- package/dist/packages/stats/patternClassification.d.ts +20 -3
- package/dist/packages/stats/patternClassification.js +1 -1
- package/dist/packages/stats/permutationNull.d.ts +16 -0
- package/dist/packages/stats/permutationNull.js +1 -0
- package/dist/packages/stats/plotData.d.ts +138 -12
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/plotSpec.d.ts +10 -1
- package/dist/packages/stats/plotSpec.js +3 -3
- package/dist/packages/stats/plotTable.js +1 -1
- package/dist/packages/stats/plotWords.d.ts +52 -0
- package/dist/packages/stats/plotWords.js +1 -0
- package/dist/packages/stats/presentation.d.ts +63 -14
- package/dist/packages/stats/presentation.js +1 -1
- package/dist/packages/stats/presentationPresets.d.ts +35 -0
- package/dist/packages/stats/presentationPresets.js +1 -0
- package/dist/packages/stats/presentationSections.d.ts +83 -0
- package/dist/packages/stats/presentationSections.js +1 -0
- package/dist/packages/stats/renderSummaryReport.d.ts +80 -2
- package/dist/packages/stats/renderSummaryReport.js +1 -67
- package/dist/packages/stats/reportBlocks.d.ts +249 -0
- package/dist/packages/stats/reportBlocks.js +1 -0
- package/dist/packages/stats/reportContents.d.ts +22 -0
- package/dist/packages/stats/reportContents.js +1 -0
- package/dist/packages/stats/reportDeck.d.ts +245 -0
- package/dist/packages/stats/reportDeck.js +212 -0
- package/dist/packages/stats/reportHtml.d.ts +44 -43
- package/dist/packages/stats/reportHtml.js +82 -46
- package/dist/packages/stats/reportMaps.d.ts +67 -0
- package/dist/packages/stats/reportMaps.js +1 -0
- package/dist/packages/stats/reportSections.d.ts +55 -0
- package/dist/packages/stats/reportSections.js +1 -0
- package/dist/packages/stats/sweep.d.ts +14 -6
- package/dist/packages/stats/sweep.js +1 -1
- package/dist/packages/stats/synthesis.d.ts +87 -10
- package/dist/packages/stats/synthesis.js +1 -1
- package/dist/packages/stats/types.d.ts +22 -0
- package/dist/packages/stats/worthItems.d.ts +15 -0
- package/dist/packages/stats/worthItems.js +1 -0
- package/dist/packages/stats/yield.d.ts +13 -0
- package/dist/packages/stats/yield.js +1 -1
- package/llms.txt +1 -1
- package/package.json +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createWafer as Q}from"../core/wafer.js";import{isYieldEligibleDie as ve,getDieKey as X,hasPosition as I,positionKey as Se}from"../core/dies.js";import{applyOrientation as se,transformDies as Ce,clipDiesToWafer as ke}from"../core/transforms.js";import{generateDies as Oe}from"../core/dies.js";import{dieHasAnyTestData as Ae,dieLink as U,finaliseDie as z,linkDie as $e,recordedVerdict as Ne,recordedVerdictsReader as Re,tableFromRows as Ee,testValue as Z,testsPresent as Te,VERDICT_FAIL as Fe,VERDICT_NONE as Ie,VERDICT_PASS as We}from"../core/dieTable.js";import{isDieColumns as _e,linkColumns as Pe,linkRows as re,relink as oe}from"./columnarInput.js";import{affineRotation as Be,affineMirror as Ve,affineCompose as Le,affinePoint as Ye}from"../core/transforms.js";import{inferWaferFromXY as Xe}from"../core/inference/wafer.js";import{resolveGridPitch as Ke}from"../core/inference/pitch.js";import{assignGridIndices as je}from"../core/inference/grid.js";import{generateReticleGrid as He}from"../core/reticle.js";import{applyDerivedTests as Ue}from"./derivedTests/apply.js";import{isStdfBin as ze,isStdfCoord as ae,isStdfTestNumber as de,isStdfSite as Ge,STDF_BIN_MAX as qe,STDF_COORD_MAX as fe,STDF_TEST_NUM_MAX as Je,STDF_SITE_MAX as Qe}from"../core/stdf.js";import{hasAnyKey as Ze,maxOf as ee,minOf as le,modeOf as et}from"../core/utils.js";import{aggregateValues as ue,aggregateBinCounts as tt,stackHoldsMeasurements as nt,stackBinsAreData as it}from"../core/aggregates.js";import{normalizePassBins as ce}from"../core/passBins.js";import{defaultRingCount as te}from"../core/ringCount.js";import{applyValueFilter as st,mergeValueFilterTests as rt,valueFilterWarning as ot}from"./valueFilter.js";export function isParametricTest(n){return n?.testType!=="F"}export function isBuiltMap(n){return"wafer"in n&&"dies"in n&&"dataAxisFlip"in n}function at(n){const e=(i,a)=>({ringCount:i,ringCountWarning:{code:"analysis-option-corrected",severity:"warning",message:`ringCount=${String(n)} ${a} (using ${i}).`}});if(n===void 0)return{ringCount:te(),ringCountWarning:void 0};if(typeof n!="number"||!Number.isFinite(n))return e(te(),"is not a finite number");const t=Math.max(1,Math.round(n));return t===n?{ringCount:n,ringCountWarning:void 0}:e(t,"is not a whole number of at least 1")}function dt(n,e){const t=Array.isArray(n)?{}:n,i={hbin:0,sbin:0,siteNum:0,testValues:0,testPass:0};let a;const d=(u,C)=>{i[u]++,a??=`${u} ${JSON.stringify(C)}`},o={bins:0,positions:0,values:0,sites:0,orientation:0},r=new Set;let p=0;if(e){i.testValues+=e.wrongValues,i.testPass+=e.wrongVerdicts,e.example!==void 0&&(a??=e.example),o.values+=e.nonFinite;for(const u of e.badTestNumbers)r.add(u)}const h=u=>u==null?!0:typeof u!="number"?!1:Number.isNaN(u)?(p++,!1):ze(u)?!0:(o.bins++,!1);function l(u){const C=new Set,D=new Set;for(let S=0;S<u.length;S+=S<50?1:100){const N=u[S];if(!(N===null||typeof N!="object")){if(N.testValues&&typeof N.testValues=="object")for(const M of Object.keys(N.testValues))C.add(M);if(N.testPass&&typeof N.testPass=="object")for(const M of Object.keys(N.testPass))D.add(M)}}const g=[...C],b=[...D],k=S=>de(Number(S));for(const S of new Set([...g,...b]))k(S)||r.add(S);const R=g.map(k),v=b.map(k),F=g.map(Number),L=b.map(Number);let K;for(let S=0;S<u.length;S++){const N=u[S];if(N===null||typeof N!="object")continue;const M=N;let E;const $=()=>E??={...M};M.hbin!=null&&typeof M.hbin!="number"&&d("hbin",M.hbin),M.sbin!=null&&typeof M.sbin!="number"&&d("sbin",M.sbin),h(M.hbin)||($().hbin=void 0),h(M.sbin)||($().sbin=void 0);const Y=typeof M.x=="number"&&!ae(M.x),j=typeof M.y=="number"&&!ae(M.y);if(Y||j){o.positions+=(Y?1:0)+(j?1:0);const s=$();s.x=void 0,s.y=void 0}M.siteNum!=null&&typeof M.siteNum!="number"?(d("siteNum",M.siteNum),$().siteNum=void 0):typeof M.siteNum=="number"&&!Ge(M.siteNum)&&(o.sites++,$().siteNum=void 0);const P=M.testValues;if(P&&typeof P=="object"){let s;for(let x=0;x<g.length;x++){const A=g[x],O=P[F[x]];if(O!=null){if(!R[x]){s??={...P},delete s[A];continue}typeof O!="number"?(d("testValues",O),s??={...P},delete s[A]):Number.isFinite(O)||(o.values++,s??={...P},delete s[A])}}s&&($().testValues=s)}const W=M.testPass;if(W&&typeof W=="object"){let s;for(let x=0;x<b.length;x++){const A=b[x],O=W[L[x]];if(O!=null){if(!v[x]){s??={...W},delete s[A];continue}typeof O!="boolean"&&(d("testPass",O),s??={...W},delete s[A])}}s&&($().testPass=s)}E&&((K??=u.slice())[S]=E)}return K}const f={warnings:[]};if(Array.isArray(n))f.results=l(n);else{Array.isArray(t.results)&&(f.results=l(t.results)),Array.isArray(t.dies)&&(f.dies=l(t.dies));const u=t.lotStack?.results;if(Array.isArray(u)){const C=u.map(D=>Array.isArray(D)?l(D):void 0);C.some(Boolean)&&(f.stackResults=C.map((D,g)=>D??u[g]))}}if(Array.isArray(t.testDefs)){const u=t.testDefs,C=u.filter(D=>D==null||typeof D.testNumber!="number"||de(D.testNumber));for(const D of u)C.includes(D)||r.add(String(D.testNumber));C.length!==u.length&&(f.testDefs=C)}const y=t.waferConfig?.orientation;if(typeof y=="number"){const u=Number.isFinite(y)?(y%360+360)%360:NaN;u===0||u===90||u===180||u===270?f.orientation=u:(o.orientation++,f.orientation=0)}const m=(u,C,D=`${C}s`)=>`${u} ${u===1?C:D}`,c=[];if(i.hbin&&c.push(m(i.hbin,"hard bin")),i.sbin&&c.push(m(i.sbin,"soft bin")),i.siteNum&&c.push(m(i.siteNum,"site number")),i.testValues&&c.push(m(i.testValues,"test value")),i.testPass&&c.push(m(i.testPass,"pass/fail verdict")),c.length){const u=`buildWaferMap received ${c.join(", ")} of the wrong type (for example ${a}), treated as missing. Bins, sites and test values must be numbers and verdicts true/false \u2014 a bin of "1" is not pass bin 1 \u2014 so those dies have no bin, no site, no value or no verdict, and yield and every chart leave them out. Convert them with Number() (and verdicts to booleans) and rebuild.`;console.warn(`[wafermap] ${u}`),f.warnings.push({code:"input-values-not-numbers",message:u,severity:"error"})}const w=[];if(o.bins&&w.push(`${m(o.bins,"bin")} (legal: whole numbers 0\u2013${qe}) \u2014 those dies have no bin`),o.positions&&w.push(`${m(o.positions,"coordinate")} (legal: whole numbers \u2212${fe} to ${fe}) \u2014 those dies have no position`),r.size&&w.push(`${m(r.size,"test number")} (legal: whole numbers 0\u2013${Je}) \u2014 those tests are left out`),o.values&&w.push(`${m(o.values,"test value")} that ${o.values===1?"is":"are"} not finite \u2014 left out`),o.sites&&w.push(`${m(o.sites,"site number")} (legal: 0\u2013${Qe}) \u2014 those dies have no site`),o.orientation&&w.push("a waferConfig.orientation other than 0, 90, 180 or 270 \u2014 the map is built at 0"),w.length||p){const u=[];w.length&&u.push(`buildWaferMap received values outside the STDF V4 ranges, treated as missing: ${w.join("; ")}.`),p&&u.push(`${m(p,"bin was","bins were")} NaN and ${p===1?"is":"are"} treated as no bin.`);const C=u.join(" ");console.warn(`[wafermap] ${C}`),f.warnings.push({code:"input-values-outside-stdf",message:C,severity:"warning"})}return f}function pe(n){const e=(h,l)=>h!==null&&typeof h=="object"&&h[l]!==void 0,t=Array.isArray(n)?{}:n,i=[],a=(h,l,f)=>{h&&i.push(`\`${l}\` (now \`${f}\`)`)};a(e(t,"data"),"data","results"),a(e(t,"die"),"die","dieConfig"),a(e(t,"stack"),"stack","lotStack"),a(e(t.dieConfig,"origin"),"dieConfig.origin","dieConfig.coordinateOrigin"),a(e(t.waferConfig,"flat"),"waferConfig.flat","waferConfig.notch"),a(e(t.reticleConfig,"anchor"),"reticleConfig.anchor","reticleConfig.anchorDie"),a(e(t.lotStack,"aggr"),"lotStack.aggr","lotStack.method"),a(Array.isArray(t.testDefs)&&t.testDefs.some(h=>e(h,"index")&&!e(h,"testNumber")),"TestDef.index","TestDef.testNumber");const d=e(t.lotStack,"results")?t.lotStack.results:[],o=(Array.isArray(n)?[n]:[t.results,...Array.isArray(d)?d:[]]).filter(h=>Array.isArray(h));if(a(o.some(h=>h.slice(0,100).some(l=>e(l,"values"))),"values","testValues"),!i.length)return;const r=i.length>1,p=`buildWaferMap ignored ${i.join(", ")}: ${r?"these names were":"that name was"} removed in an earlier release, so what ${r?"they":"it"} described is not on this map. Rename and rebuild.`;return console.warn(`[wafermap] ${p}`),{code:"input-field-removed",message:p,severity:"error"}}function ft(n){if(n.results!==void 0||n.lotStack!==void 0)throw new Error("buildWaferMap: pass `layout`, `results` or `lotStack` \u2014 only one.");const e=n.waferConfig?.diameter,t=n.dieConfig?.width,i=n.dieConfig?.height;if(!(e>0&&t>0&&i>0))throw new Error("buildWaferMap: `layout` needs waferConfig.diameter and dieConfig.width and height, all positive.");const a=Q({diameter:e,notch:n.waferConfig?.notch,orientation:0}),d=ke(Oe(a,{width:t,height:i}),a,{width:t,height:i}).filter(l=>!l.partial),{flipX:o,flipY:r}=me(n.dieConfig,{type:"center"}),{layout:p,...h}=n;return{...h,results:d.map(l=>({x:o?-l.x:l.x,y:r?-l.y:l.y})),waferConfig:{...n.waferConfig,center:{x:0,y:0}},dieConfig:{...n.dieConfig,coordinateOrigin:{type:"center"}}}}function lt(n){if(!Array.isArray(n)&&"results"in n&&n.results!==void 0&&"lotStack"in n&&n.lotStack!==void 0)throw new Error("buildWaferMap: pass either `results` or `lotStack`, not both.");const e={wrongVerdicts:0,wrongValues:0,nonFinite:0,badTestNumbers:[]},t=!Array.isArray(n)&&_e(n.results)?{...n,results:Pe(n.results,e).records}:n,i=dt(t,e);return Array.isArray(t)?{results:ne(i.results??t),waferOpts:void 0,dieOpts:void 0,explicitDies:void 0,reticleOpts:void 0,lotStackOpts:void 0,passBins:ce(void 0),ringCount:te(),valueFilter:"validity",ringCountWarning:void 0,removedFieldWarning:pe(t),inputValueWarnings:i.warnings,standardDiameters:void 0,testDefs:void 0,hbinDefs:void 0,sbinDefs:void 0,metadataFields:void 0,derivedTests:void 0,retestPolicy:"last",edgeDieYieldMode:"exclude"}:{results:ne(i.results??t.results??[]),waferOpts:i.orientation===void 0||t.waferConfig===void 0?t.waferConfig:{...t.waferConfig,orientation:i.orientation},dieOpts:t.dieConfig,explicitDies:i.dies??t.dies,reticleOpts:t.reticleConfig,lotStackOpts:t.lotStack?{...t.lotStack,results:(i.stackResults??t.lotStack.results).map(ne)}:void 0,passBins:ce(t.passBins),valueFilter:t.valueFilter??"validity",...at(t.ringCount),removedFieldWarning:pe(t),inputValueWarnings:i.warnings,standardDiameters:t.standardDiameters,testDefs:(i.testDefs??t.testDefs)?.length?i.testDefs??t.testDefs:void 0,hbinDefs:t.hbinDefs,sbinDefs:t.sbinDefs,metadataFields:t.metadataFields,derivedTests:t.derivedTests?.length?t.derivedTests:void 0,retestPolicy:t.retestPolicy??"last",edgeDieYieldMode:t.edgeDieYieldMode??"exclude"}}function ne(n){return n.length>0&&U(n[0])!==void 0?n:re(n).records}function ut(n,e){return e?.coordinateOrigin?e.coordinateOrigin:{type:"center"}}function ct(n,e,t){if(e.type==="custom"&&e.offset)return{offsetX:e.offset.x,offsetY:e.offset.y};if(e.type!=="center"){let i=1/0,a=-1/0,d=1/0,o=-1/0;for(const r of n)r.x<i&&(i=r.x),r.x>a&&(a=r.x),r.y<d&&(d=r.y),r.y>o&&(o=r.y);return{offsetX:Math.round((a+i)/2),offsetY:Math.round((o+d)/2)}}return{offsetX:t.offsetX,offsetY:t.offsetY}}function pt(n,e){if(n.length<xe)return!1;const t=he(n),i=(a,d,o)=>{const r=o-d+1;return a<d-r||a>o+r};return i(Math.round(e.x),t.xMin,t.xMax)||i(Math.round(e.y),t.yMin,t.yMax)}function he(n){let e=1/0,t=-1/0,i=1/0,a=-1/0;for(const d of n){const o=Math.round(d.x),r=Math.round(d.y);o<e&&(e=o),o>t&&(t=o),r<i&&(i=r),r>a&&(a=r)}return{xMin:e,xMax:t,yMin:i,yMax:a}}const ht="The supplied wafer centre";function mt(n,e){const t=he(n);return`${ht} (${e.x}, ${e.y}) is far outside the tested dies (X ${t.xMin}\u2026${t.xMax}, Y ${t.yMin}\u2026${t.yMax}), so it was ignored and the centre was worked out from the dies. Used as given, it would draw a wafer many times the size of the dies, with all of them in one corner.`}const gt="If the supplied centre is correct, also supply waferConfig.diameter.";function yt(n,e,t,i,a,d){if(d)return{colMidX:(Math.round(d.x)-e)*i,colMidY:(Math.round(d.y)-t)*a,anchored:!0};if(n.length===0)return{colMidX:0,colMidY:0,anchored:!1};let o=1/0,r=-1/0,p=1/0,h=-1/0;for(const l of n){const f=Math.round(l.x)-e,y=Math.round(l.y)-t;f<o&&(o=f),f>r&&(r=f),y<p&&(p=y),y>h&&(h=y)}return{colMidX:(o+r)/2*i,colMidY:(p+h)/2*a,anchored:!1}}function bt(n,e,t){let i=1/0,a=-1/0,d=1/0,o=-1/0,r=0,p=0;for(const f of n){const y=Math.round(f.x)-e,m=Math.round(f.y)-t;r+=y,p+=m,y<i&&(i=y),y>a&&(a=y),m<d&&(d=m),m>o&&(o=m)}const h=n.length,l=(f,y,m)=>{const c=(m-y)/2;return c<=0?0:Math.abs(f/h-(y+m)/2)/c};return l(r,i,a)>.11||l(p,d,o)>.11}function me(n,e){let t=n?.xAxisDirection==="left",i=n?.yAxisDirection==="down";return(e.type==="UL"||e.type==="UR")&&(i=!0),(e.type==="LR"||e.type==="UR")&&(t=!0),{flipX:t,flipY:i}}function wt(n){const e={...n};return delete e.limitLow,delete e.limitHigh,delete e.limitLowInclusive,delete e.limitHighInclusive,delete e.specLow,delete e.specHigh,e}function xt(n,e){const{method:t,targetBin:i}=n,a=n.results.map(d=>d.filter(I));if(t==="mean"||t==="median"||t==="stddev"||t==="min"||t==="max"||t==="count"){const d=new Set((e??[]).filter(l=>!isParametricTest(l)).map(l=>l.testNumber)),o=new Set;for(const l of a)for(const f of Te(l,"values"))d.has(f)||o.add(f);if(o.size===0)return ue(a,t);const r=[...o],p=r.map(l=>ue(a,t,l)),h=new Map;for(let l=0;l<r.length;l++){const f=r[l];for(const y of p[l]){const m=X(y);h.has(m)||h.set(m,{template:y,testValues:{}});const c=h.get(m),w=y.testValues?.[0];w!==void 0&&(c.testValues[f]=w)}}return[...h.values()].map(({template:l,testValues:f})=>({...l,testValues:Ze(f)?f:void 0}))}if(t==="countBin"||t==="percent"){if(i===void 0)return[];const d=tt(a,i,"hard");if(t==="countBin")return d;const o=a.length;return d.map(r=>({...r,testValues:{0:o>0?(r.testValues?.[0]??0)/o*100:0}}))}if(t==="mode"){const d=new Map;for(const r of a)for(const p of r){const h=X(p);d.has(h)||d.set(h,[]),d.get(h).push(p)}const o=[];for(const[r,p]of d){const h=r.split(","),l=Number(h[0]),f=Number(h[1]),y=p.map(c=>c.hbin).filter(c=>c!==void 0),m=et(y);m!==null&&o.push({x:l,y:f,hbin:m})}return o}return[]}export function computeCoverage(n){const e=n.filter(I),t=e.length,i=e.filter(d=>d.edgeExcluded).length,a=e.filter(d=>d.hbin!==void 0||d.sbin!==void 0||dieHasTestData(d)).length;return{filledDies:a,totalDies:t,edgeExcludedDies:i,unpositionedDies:n.length-e.length,ratio:t>0?a/t:0}}export function computeYield(n,e,t="exclude",i=!0){const a=new Set(e),o=n.filter(c=>!c.partial).filter(c=>c.edgeExcluded&&!c.filteredOut).length,r=n.filter(c=>c.partial).length;if(!i)return{passDies:0,failDies:0,edgeExcludedDies:o,partialDies:r,totalDies:0,yieldPercent:null,yieldPercentGross:null};let p=0,h=0,l=!1;for(const c of n){if(!ve(c))continue;const w=c.hbin??c.sbin;w!==void 0&&(l=!0,a.has(w)?p++:h++)}const f=p+h,y=l&&f>0?p/f*100:null;let m=null;if(t==="denominator-only"){const c=f+o;m=l&&c>0?p/c*100:null}return{passDies:p,failDies:h,edgeExcludedDies:o,partialDies:r,totalDies:f,yieldPercent:y,yieldPercentGross:m}}function ge(n,e,t,i,a,d=0,o=0,r=0,p=0,h=0,l=!1,f=!1){if(!n)return[];const y=n.anchorDie??{x:0,y:0},m=He(e,{width:n.width,height:n.height,diePitchX:i,diePitchY:a,anchorDie:{x:y.x-d,y:y.y-o},gridOrigin:{x:-r,y:-p}}),c=Le(Ve(l,f,e.center.x,e.center.y),Be(h,e.center.x,e.center.y));return m.filter(w=>{const u=w.width/2,C=w.height/2,D=[[w.x-u,w.y-C],[w.x+u,w.y-C],[w.x+u,w.y+C],[w.x-u,w.y+C]].map(([v,F])=>Ye(c,v,F)),g=le(D.map(v=>v.x)),b=ee(D.map(v=>v.x)),k=le(D.map(v=>v.y)),R=ee(D.map(v=>v.y));return t.some(v=>v.physX>=g&&v.physX<b&&v.physY>=k&&v.physY<R)})}function Dt(n,e,t){const a=Math.max(0,e.radius-t)**2;return n.map(d=>{const o=d.physX-e.center.x,r=d.physY-e.center.y;return o*o+r*r>a?{...d,edgeExcluded:!0}:d})}const Mt=.2;function vt(n){const e=new Set;for(const t of n){if(t.supersedes!==void 0||!I(t))return!1;const i=Se(t);if(e.has(i))return!1;e.add(i)}return!0}function St(n,e,t){if(vt(n))return{results:n.slice(),warning:void 0};const i=new Set(t);function a(g,b){if(e==="last")return!0;if(e==="first")return!1;const k=G(g.hbin),R=G(b.hbin);if(k===void 0||R===void 0)return!1;const v=i.has(k),F=i.has(R);return e==="best"?F!==v?F:R<k:F!==v?v:R>k}const d=(g,b)=>b.supersedes!==void 0||a(g,b),o=g=>{const b=g.partId===void 0?"":String(g.partId).trim();return b===""?void 0:b},r=n.filter(g=>!I(g)),p=new Map;for(const g of r){const b=o(g);b!==void 0&&p.set(b,(p.get(b)??0)+1)}const l=(r.length===0?0:Math.max(0,...p.values())/r.length)<=Mt,f=new Map,y=[],m=new Map;let c=0,w=0;for(const g of n){const b=o(g);let k;if(I(g)?k=`p:${X(g)}`:l&&b!==void 0?k=`i:${b}`:k=`u:${w++}`,g.supersedes==="partId"&&b!==void 0){const v=m.get(b);v!==void 0&&v!==k&&f.has(v)&&f.delete(v)}const R=f.get(k);R===void 0?(f.set(k,{winner:g,count:1}),y.push(k)):(R.count++,k.startsWith("i:")&&c++,d(R.winner,g)&&(R.winner=g)),b!==void 0&&m.set(b,k)}const u=[],C=[...y.filter(g=>g.startsWith("p:")),...y.filter(g=>!g.startsWith("p:"))];for(const g of C){const b=f.get(g);b!==void 0&&u.push(b.count>1?{...b.winner,retestCount:b.count}:b.winner)}const D=c>0?{code:"retests-by-part-id",severity:"info",message:`${c} record${c===1?"":"s"} with no position shared a part ID with an earlier record and ${c===1?"was":"were"} treated as a retest of it.`}:void 0;return{results:u,warning:D}}export function getDieTestValue(n,e){return Z(n,e)}export function getTestPassStatus(n,e,t){const i=Ne(n,e);return i!==void 0?i:t!==void 0&&!isParametricTest(t)?ye(Z(n,e)):void 0}function ye(n){return n===0||n===1?n===1:void 0}export function testPassStatusReader(n){const e=n.map(a=>a.testNumber),t=Re(e),i=n.map(a=>!isParametricTest(a));return function(d,o){t(d,o);for(let r=0;r<o.length;r++){if(o[r]!==Ie||!i[r])continue;const p=ye(Z(d,e[r]));p!==void 0&&(o[r]=p?We:Fe)}return o}}export function dieHasTestData(n){return Ae(n)}function G(n){return n===void 0||Number.isNaN(n)?void 0:n}function q(n,e){const t={},i=G(e.hbin),a=G(e.sbin);i!==void 0&&(t.hbin=i),a!==void 0&&(t.sbin=a),e.retestCount!==void 0&&(t.retestCount=e.retestCount),e.siteNum!==void 0&&(t.siteNum=e.siteNum),e.partId!==void 0&&(t.partId=e.partId),e.metadata!==void 0&&(t.metadata=e.metadata);const d=U(e);return $e({...n,...t},d.table,d.row)}function be(n){return n.some(dieHasTestData)?"value":defaultBinMode([n])}export function defaultBinMode(n){const e=t=>n.some(i=>i.some(a=>t(a)!=null));return e(t=>t.hbin)?"hardBin":e(t=>t.sbin)?"softBin":"hardBin"}function we(n,e){return n.map(({code:t,message:i})=>({code:t,message:i,severity:t==="non-standard-diameter"||t==="diameter-exceeds-die-extent"||t==="implausible-center"?"warning":"error",confidence:e.wafer.confidence}))}const Ct="do not fit inside the supplied",kt="Inferred wafer diameter",Ot="The probed dies reach only",At=.75,xe=20;export const STANDARD_WAFER_DIAMETERS_MM=[100,125,150,200,300];const $t=.02;function De(n,e){return e.reduce((t,i)=>Math.abs(i-n)<Math.abs(t-n)?i:t)}function Nt(n,e){if(!e.length)return!0;const t=De(n,e);return Math.abs(t-n)/t<=$t}function Rt(n){return n===void 0?STANDARD_WAFER_DIAMETERS_MM:n.filter(e=>Number.isFinite(e)&&e>0)}export function buildWaferMap(n){const e=lt(!Array.isArray(n)&&n.layout?ft(n):n),t=[];let i;if(e.valueFilter!=="none"&&e.testDefs){const s=e.valueFilter,x=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(O=>{const _=O.length>0?U(O[0]):void 0;if(!_)return[];const T=st(_.table,e.testDefs,s);return T.tests.length>0&&oe(O,T.table),T.tests}),A=rt(x);if(A.length>0){i={mode:s,tests:A};const O=ot(s,A,e.testDefs);O&&t.push(O)}}if(e.derivedTests){const s=new Set(e.passBins),x=_=>{const T=_.length>0?U(_[0]):void 0,H=Ue(_,T?.table??Ee([]),e.testDefs,e.derivedTests,s);return T&&oe(_,H.table),H},O=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(x);e.testDefs=O[0]?.testDefs??e.testDefs,t.push(...O[0]?.warnings??[])}e.lotStackOpts&&!nt(e.lotStackOpts.method)&&(e.testDefs=e.testDefs?.map(wt));const a=e.lotStackOpts?re(xt(e.lotStackOpts,e.testDefs)).records:e.results;for(let s=0;s<Math.min(5,a.length);s++){const x=a[s];if(typeof x.x=="string"||typeof x.y=="string")throw new TypeError("buildWaferMap: x and y must be numbers, received strings. Did you forget to cast CSV values? e.g. { x: +row.x, y: +row.y }")}for(const s of a)if(s.x==null!=(s.y==null))throw new TypeError(`buildWaferMap: die has only one of x/y set (x=${String(s.x)}, y=${String(s.y)}). A die must be either fully positioned (both x and y) or fully unpositioned (neither) \u2014 omit both to mark a die as having no reported position.`);const{results:d,warning:o}=St(a,e.retestPolicy,e.passBins),r={wafer:{confidence:1,method:"provided"},diePitch:{confidence:1,units:"mm"},grid:{confidence:1}},p=[];if(e.explicitDies){let s=e.explicitDies.filter(I);const x=e.explicitDies.filter(V=>!I(V)),A=d.filter(I),O=d.filter(V=>!I(V));if(A.length>0){const V=new Map(A.map(B=>[X(B),B]));s=s.map(B=>{const ie=V.get(X(B));return ie?q(B,ie):B})}const _=e.waferOpts?.diameter??300,T=Q({diameter:_,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});T.orientation!==0&&(s=se(s,T)),s=s.map(z);const H=ge(e.reticleOpts,T,s,s[0]?.width??1,s[0]?.height??1,0,0,0,0,T.orientation),Me=O.map((V,B)=>z(q({id:`unpositioned_${B}`,width:s[0]?.width??1,height:s[0]?.height??1},V))),J=[...s,...x,...Me];return{wafer:T,dies:J,dataAxisFlip:{x:!1,y:!1},reticleConfig:e.reticleOpts,units:"mm",inference:r,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...we(p,r),...t,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:be(d),metadata:T.metadata??null,isLotStack:!1,dataCoverage:computeCoverage(J),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:computeYield(J,e.passBins,e.edgeDieYieldMode),reticles:H,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields}}const h=d.filter(I),l=d.filter(s=>!I(s)),f=h.map(s=>({x:s.x,y:s.y})),y=Ke(f,e.dieOpts,e.waferOpts?.diameter);r.diePitch={confidence:y.confidence,units:y.units};const{pitchX:m,pitchY:c}=y,w=y.units,u=ut(h,e.dieOpts),C=je(f);r.grid={confidence:C.confidence};const{offsetX:D,offsetY:g}=ct(f,u,C),{flipX:b,flipY:k}=me(e.dieOpts,u),R=e.waferOpts?.diameter===void 0&&e.waferOpts?.center!==void 0&&pt(f,e.waferOpts.center),v=R?void 0:e.waferOpts?.center;if(R){const s=mt(f,e.waferOpts.center);console.warn(`[wafermap] ${s} ${gt}`),p.push({code:"implausible-center",message:s})}const{colMidX:F,colMidY:L,anchored:K}=yt(f,D,g,m,c,v);let S=e.waferOpts?.diameter;const N=f.map(s=>({x:(Math.round(s.x)-D)*m-F,y:(Math.round(s.y)-g)*c-L})),M=ee(N.map(({x:s,y:x})=>Math.hypot(Math.abs(s)+m/2,Math.abs(x)+c/2)));if(S===void 0)if(f.length>0)if(w==="mm"){const s=Xe(N,{minRadius:M});S=s.diameter,r.wafer={confidence:s.confidence,method:s.method};const x=Rt(e.standardDiameters);if(!Nt(S,x)){const A=De(S,x);p.push({code:"non-standard-diameter",message:`${kt} ${S.toFixed(1)} mm is not a standard wafer size (nearest is ${A} mm). The diameter was derived from the die extent, which assumes the probed grid reaches the wafer edge \u2014 a non-standard result usually means it does not, because the outer dies were never probed. Every die is then placed against a wafer that is too small, which moves dies between rings and changes ring and edge findings. Supply waferConfig.diameter.`})}}else S=M*2,r.wafer={confidence:y.confidence*.8,method:"extent"};else S=w==="mm"?300:30,r.wafer={confidence:0,method:"default"};if(!K&&f.length>0&&bt(f,D,g)&&(r.wafer.method="inferred-partial",p.push({code:"partial-coverage",message:"Wafer geometry was inferred from die positions alone. The data does not span a full symmetric wafer, so the inferred diameter and centre may be wrong and dies may be mis-positioned relative to the true wafer boundary. Supply waferConfig.diameter and waferConfig.center (the prober coordinate of the wafer centre) to position partial data correctly."})),e.waferOpts?.diameter!==void 0&&v===void 0&&M>0&&f.length>=xe){const s=M/(S/2);s<At&&p.push({code:"diameter-exceeds-die-extent",message:`${Ot} ${(s*100).toFixed(0)}% of the ${S} mm wafer's radius. Either the diameter is larger than the real one, or this is a partial map covering only part of the wafer. Ring bands are equal-radius, so the outer rings are mostly or entirely empty and ring, quadrant and edge findings describe the assumed wafer rather than the probed area. Check waferConfig.diameter, or drop it and let the diameter be inferred from the die extent.`})}if(e.waferOpts?.diameter!==void 0){const s=e.dieOpts?.width!==void 0&&e.dieOpts?.height!==void 0;if(s&&M>S/2+1e-9){const x=N.filter(({x:A,y:O})=>Math.hypot(Math.abs(A)+m/2,Math.abs(O)+c/2)>S/2+1e-9).length;p.push({code:"geometry-conflict",message:`${x} of ${N.length} probed die positions ${Ct} ${S} mm wafer at the supplied die pitch of ${m} \xD7 ${c} mm. A die with test results is a real prober position and is always fully on the wafer, so one of the two supplied values must be wrong: containing these dies at this pitch would need a diameter of at least ${(M*2).toFixed(1)} mm. Check waferConfig.diameter and dieConfig.width/height against the real device.`})}}const E=Q({diameter:S,units:w,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});let $=h.map(s=>{const x=Math.round(s.x)-D,A=Math.round(s.y)-g,O={id:`${x}_${A}`,x,y:A,physX:x*m-F,physY:A*c-L,width:m,height:c,insideWafer:!0,partial:!1};return q(O,s)});(D!==0||g!==0)&&($=$.map(s=>({...s,x:s.x+D,y:s.y+g,id:`${s.x+D}_${s.y+g}`}))),$=se($,E),(b||k)&&($=Ce($,{flipX:b,flipY:k},E.center));const Y=[];e.waferOpts?.edgeExclusion&&e.waferOpts.edgeExclusion>0&&($=Dt($,E,e.waferOpts.edgeExclusion),e.waferOpts.edgeExclusion>E.radius&&Y.push({code:"edge-exclusion-exceeds-radius",message:`edgeExclusion (${e.waferOpts.edgeExclusion}mm) exceeds the resolved wafer radius (${E.radius}mm) \u2014 the entire wafer is excluded.`,severity:"warning"})),$=$.map(z);const j=ge(e.reticleOpts,E,$,m,c,D,g,F,L,E.orientation,b,k),P=l.map((s,x)=>z(q({id:`unpositioned_${x}`,width:m,height:c},s))),W=[...$,...P];return{wafer:E,dies:W,dataAxisFlip:{x:b,y:k},reticleConfig:e.reticleOpts,units:w,inference:r,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...we(p,r),...Y,...t,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:be(d),metadata:E.metadata??null,isLotStack:e.lotStackOpts!==void 0,dataCoverage:computeCoverage(W),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:computeYield(W,e.passBins,e.edgeDieYieldMode,it(e.lotStackOpts!==void 0,e.lotStackOpts?.method)),reticles:j,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields,aggrMethod:e.lotStackOpts?.method,lotSize:e.lotStackOpts?.results.length}}
|
|
1
|
+
import{createWafer as Q}from"../core/wafer.js";import{isYieldEligibleDie as ve,getDieKey as X,hasPosition as I,positionKey as Se}from"../core/dies.js";import{applyOrientation as se,transformDies as Ce,clipDiesToWafer as ke}from"../core/transforms.js";import{generateDies as Oe}from"../core/dies.js";import{dieHasAnyTestData as Ae,dieLink as U,finaliseDie as z,linkDie as $e,recordedVerdict as Ne,recordedVerdictsReader as Re,tableFromRows as Ee,testValue as Z,testsPresent as Fe,VERDICT_FAIL as Te,VERDICT_NONE as Ie,VERDICT_PASS as We}from"../core/dieTable.js";import{isDieColumns as _e,linkColumns as Pe,linkRows as re,relink as oe}from"./columnarInput.js";import{affineRotation as Be,affineMirror as Ve,affineCompose as Le,affinePoint as Ye}from"../core/transforms.js";import{inferWaferFromXY as Xe}from"../core/inference/wafer.js";import{resolveGridPitch as Ke}from"../core/inference/pitch.js";import{assignGridIndices as je}from"../core/inference/grid.js";import{generateReticleGrid as He}from"../core/reticle.js";import{applyDerivedTests as Ue}from"./derivedTests/apply.js";import{isStdfBin as ze,isStdfCoord as ae,isStdfTestNumber as de,isStdfSite as Ge,STDF_BIN_MAX as qe,STDF_COORD_MAX as fe,STDF_TEST_NUM_MAX as Je,STDF_SITE_MAX as Qe}from"../core/stdf.js";import{hasAnyKey as Ze,maxOf as ee,minOf as le,modeOf as et}from"../core/utils.js";import{aggregateValues as ue,aggregateBinCounts as tt,stackHoldsMeasurements as nt,stackBinsAreData as it}from"../core/aggregates.js";import{normalizePassBins as ce}from"../core/passBins.js";import{defaultRingCount as te}from"../core/ringCount.js";import{applyValueFilter as st,mergeValueFilterTests as rt,valueFilterWarning as ot}from"./valueFilter.js";export function isParametricTest(n){return n?.testType!=="F"}export function isBuiltMap(n){return"wafer"in n&&"dies"in n&&"dataAxisFlip"in n}function at(n){const e=(i,a)=>({ringCount:i,ringCountWarning:{code:"analysis-option-corrected",severity:"warning",message:`ringCount=${String(n)} ${a} (using ${i}).`}});if(n===void 0)return{ringCount:te(),ringCountWarning:void 0};if(typeof n!="number"||!Number.isFinite(n))return e(te(),"is not a finite number");const t=Math.max(1,Math.round(n));return t===n?{ringCount:n,ringCountWarning:void 0}:e(t,"is not a whole number of at least 1")}function dt(n,e){const t=Array.isArray(n)?{}:n,i={hbin:0,sbin:0,siteNum:0,testValues:0,testPass:0};let a;const d=(u,C)=>{i[u]++,a??=`${u} ${JSON.stringify(C)}`},o={bins:0,positions:0,values:0,sites:0,orientation:0},r=new Set;let p=0;if(e){i.testValues+=e.wrongValues,i.testPass+=e.wrongVerdicts,e.example!==void 0&&(a??=e.example),o.values+=e.nonFinite;for(const u of e.badTestNumbers)r.add(u)}const h=u=>u==null?!0:typeof u!="number"?!1:Number.isNaN(u)?(p++,!1):ze(u)?!0:(o.bins++,!1);function l(u){const C=new Set,D=new Set;for(let S=0;S<u.length;S+=S<50?1:100){const N=u[S];if(!(N===null||typeof N!="object")){if(N.testValues&&typeof N.testValues=="object")for(const M of Object.keys(N.testValues))C.add(M);if(N.testPass&&typeof N.testPass=="object")for(const M of Object.keys(N.testPass))D.add(M)}}const g=[...C],b=[...D],k=S=>de(Number(S));for(const S of new Set([...g,...b]))k(S)||r.add(S);const R=g.map(k),v=b.map(k),T=g.map(Number),L=b.map(Number);let K;for(let S=0;S<u.length;S++){const N=u[S];if(N===null||typeof N!="object")continue;const M=N;let E;const $=()=>E??={...M};M.hbin!=null&&typeof M.hbin!="number"&&d("hbin",M.hbin),M.sbin!=null&&typeof M.sbin!="number"&&d("sbin",M.sbin),h(M.hbin)||($().hbin=void 0),h(M.sbin)||($().sbin=void 0);const Y=typeof M.x=="number"&&!ae(M.x),j=typeof M.y=="number"&&!ae(M.y);if(Y||j){o.positions+=(Y?1:0)+(j?1:0);const s=$();s.x=void 0,s.y=void 0}M.siteNum!=null&&typeof M.siteNum!="number"?(d("siteNum",M.siteNum),$().siteNum=void 0):typeof M.siteNum=="number"&&!Ge(M.siteNum)&&(o.sites++,$().siteNum=void 0);const P=M.testValues;if(P&&typeof P=="object"){let s;for(let x=0;x<g.length;x++){const A=g[x],O=P[T[x]];if(O!=null){if(!R[x]){s??={...P},delete s[A];continue}typeof O!="number"?(d("testValues",O),s??={...P},delete s[A]):Number.isFinite(O)||(o.values++,s??={...P},delete s[A])}}s&&($().testValues=s)}const W=M.testPass;if(W&&typeof W=="object"){let s;for(let x=0;x<b.length;x++){const A=b[x],O=W[L[x]];if(O!=null){if(!v[x]){s??={...W},delete s[A];continue}typeof O!="boolean"&&(d("testPass",O),s??={...W},delete s[A])}}s&&($().testPass=s)}E&&((K??=u.slice())[S]=E)}return K}const f={warnings:[]};if(Array.isArray(n))f.results=l(n);else{Array.isArray(t.results)&&(f.results=l(t.results)),Array.isArray(t.dies)&&(f.dies=l(t.dies));const u=t.lotStack?.results;if(Array.isArray(u)){const C=u.map(D=>Array.isArray(D)?l(D):void 0);C.some(Boolean)&&(f.stackResults=C.map((D,g)=>D??u[g]))}}if(Array.isArray(t.testDefs)){const u=t.testDefs,C=u.filter(D=>D==null||typeof D.testNumber!="number"||de(D.testNumber));for(const D of u)C.includes(D)||r.add(String(D.testNumber));C.length!==u.length&&(f.testDefs=C)}const y=t.waferConfig?.orientation;if(typeof y=="number"){const u=Number.isFinite(y)?(y%360+360)%360:NaN;u===0||u===90||u===180||u===270?f.orientation=u:(o.orientation++,f.orientation=0)}const m=(u,C,D=`${C}s`)=>`${u} ${u===1?C:D}`,c=[];if(i.hbin&&c.push(m(i.hbin,"hard bin")),i.sbin&&c.push(m(i.sbin,"soft bin")),i.siteNum&&c.push(m(i.siteNum,"site number")),i.testValues&&c.push(m(i.testValues,"test value")),i.testPass&&c.push(m(i.testPass,"pass/fail verdict")),c.length){const u=`buildWaferMap received ${c.join(", ")} of the wrong type (for example ${a}), treated as missing. Bins, sites and test values must be numbers and verdicts true/false \u2014 a bin of "1" is not pass bin 1 \u2014 so those dies have no bin, no site, no value or no verdict, and yield and every chart leave them out. Convert them with Number() (and verdicts to booleans) and rebuild.`;console.warn(`[wafermap] ${u}`),f.warnings.push({code:"input-values-not-numbers",message:u,severity:"error"})}const w=[];if(o.bins&&w.push(`${m(o.bins,"bin")} (legal: whole numbers 0\u2013${qe}) \u2014 those dies have no bin`),o.positions&&w.push(`${m(o.positions,"coordinate")} (legal: whole numbers \u2212${fe} to ${fe}) \u2014 those dies have no position`),r.size&&w.push(`${m(r.size,"test number")} (legal: whole numbers 0\u2013${Je}) \u2014 those tests are left out`),o.values&&w.push(`${m(o.values,"test value")} that ${o.values===1?"is":"are"} not finite \u2014 left out`),o.sites&&w.push(`${m(o.sites,"site number")} (legal: 0\u2013${Qe}) \u2014 those dies have no site`),o.orientation&&w.push("a waferConfig.orientation other than 0, 90, 180 or 270 \u2014 the map is built at 0"),w.length||p){const u=[];w.length&&u.push(`buildWaferMap received values outside the STDF V4 ranges, treated as missing: ${w.join("; ")}.`),p&&u.push(`${m(p,"bin was","bins were")} NaN and ${p===1?"is":"are"} treated as no bin.`);const C=u.join(" ");console.warn(`[wafermap] ${C}`),f.warnings.push({code:"input-values-outside-stdf",message:C,severity:"warning"})}return f}function pe(n){const e=(h,l)=>h!==null&&typeof h=="object"&&h[l]!==void 0,t=Array.isArray(n)?{}:n,i=[],a=(h,l,f)=>{h&&i.push(`\`${l}\` (now \`${f}\`)`)};a(e(t,"data"),"data","results"),a(e(t,"die"),"die","dieConfig"),a(e(t,"stack"),"stack","lotStack"),a(e(t.dieConfig,"origin"),"dieConfig.origin","dieConfig.coordinateOrigin"),a(e(t.waferConfig,"flat"),"waferConfig.flat","waferConfig.notch"),a(e(t.reticleConfig,"anchor"),"reticleConfig.anchor","reticleConfig.anchorDie"),a(e(t.lotStack,"aggr"),"lotStack.aggr","lotStack.method"),a(Array.isArray(t.testDefs)&&t.testDefs.some(h=>e(h,"index")&&!e(h,"testNumber")),"TestDef.index","TestDef.testNumber");const d=e(t.lotStack,"results")?t.lotStack.results:[],o=(Array.isArray(n)?[n]:[t.results,...Array.isArray(d)?d:[]]).filter(h=>Array.isArray(h));if(a(o.some(h=>h.slice(0,100).some(l=>e(l,"values"))),"values","testValues"),!i.length)return;const r=i.length>1,p=`buildWaferMap ignored ${i.join(", ")}: ${r?"these names were":"that name was"} removed in an earlier release, so what ${r?"they":"it"} described is not on this map. Rename and rebuild.`;return console.warn(`[wafermap] ${p}`),{code:"input-field-removed",message:p,severity:"error"}}function ft(n){if(n.results!==void 0||n.lotStack!==void 0)throw new Error("buildWaferMap: pass `layout`, `results` or `lotStack` \u2014 only one.");const e=n.waferConfig?.diameter,t=n.dieConfig?.width,i=n.dieConfig?.height;if(!(e>0&&t>0&&i>0))throw new Error("buildWaferMap: `layout` needs waferConfig.diameter and dieConfig.width and height, all positive.");const a=Q({diameter:e,notch:n.waferConfig?.notch,orientation:0}),d=ke(Oe(a,{width:t,height:i}),a,{width:t,height:i}).filter(l=>!l.partial),{flipX:o,flipY:r}=me(n.dieConfig,{type:"center"}),{layout:p,...h}=n;return{...h,results:d.map(l=>({x:o?-l.x:l.x,y:r?-l.y:l.y})),waferConfig:{...n.waferConfig,center:{x:0,y:0}},dieConfig:{...n.dieConfig,coordinateOrigin:{type:"center"}}}}function lt(n){if(!Array.isArray(n)&&"results"in n&&n.results!==void 0&&"lotStack"in n&&n.lotStack!==void 0)throw new Error("buildWaferMap: pass either `results` or `lotStack`, not both.");const e={wrongVerdicts:0,wrongValues:0,nonFinite:0,badTestNumbers:[]},t=!Array.isArray(n)&&_e(n.results)?{...n,results:Pe(n.results,e).records}:n,i=dt(t,e);return Array.isArray(t)?{results:ne(i.results??t),waferOpts:void 0,dieOpts:void 0,explicitDies:void 0,reticleOpts:void 0,lotStackOpts:void 0,passBins:ce(void 0),ringCount:te(),valueFilter:"validity",ringCountWarning:void 0,removedFieldWarning:pe(t),inputValueWarnings:i.warnings,standardDiameters:void 0,testDefs:void 0,hbinDefs:void 0,sbinDefs:void 0,metadataFields:void 0,derivedTests:void 0,retestPolicy:"last",edgeDieYieldMode:"exclude"}:{results:ne(i.results??t.results??[]),waferOpts:i.orientation===void 0||t.waferConfig===void 0?t.waferConfig:{...t.waferConfig,orientation:i.orientation},dieOpts:t.dieConfig,explicitDies:i.dies??t.dies,reticleOpts:t.reticleConfig,lotStackOpts:t.lotStack?{...t.lotStack,results:(i.stackResults??t.lotStack.results).map(ne)}:void 0,passBins:ce(t.passBins),valueFilter:t.valueFilter??"validity",...at(t.ringCount),removedFieldWarning:pe(t),inputValueWarnings:i.warnings,standardDiameters:t.standardDiameters,testDefs:(i.testDefs??t.testDefs)?.length?i.testDefs??t.testDefs:void 0,hbinDefs:t.hbinDefs,sbinDefs:t.sbinDefs,metadataFields:t.metadataFields,derivedTests:t.derivedTests?.length?t.derivedTests:void 0,retestPolicy:t.retestPolicy??"last",edgeDieYieldMode:t.edgeDieYieldMode??"exclude"}}function ne(n){return n.length>0&&U(n[0])!==void 0?n:re(n).records}function ut(n,e){return e?.coordinateOrigin?e.coordinateOrigin:{type:"center"}}function ct(n,e,t){if(e.type==="custom"&&e.offset)return{offsetX:e.offset.x,offsetY:e.offset.y};if(e.type!=="center"){let i=1/0,a=-1/0,d=1/0,o=-1/0;for(const r of n)r.x<i&&(i=r.x),r.x>a&&(a=r.x),r.y<d&&(d=r.y),r.y>o&&(o=r.y);return{offsetX:Math.round((a+i)/2),offsetY:Math.round((o+d)/2)}}return{offsetX:t.offsetX,offsetY:t.offsetY}}function pt(n,e){if(n.length<xe)return!1;const t=he(n),i=(a,d,o)=>{const r=o-d+1;return a<d-r||a>o+r};return i(Math.round(e.x),t.xMin,t.xMax)||i(Math.round(e.y),t.yMin,t.yMax)}function he(n){let e=1/0,t=-1/0,i=1/0,a=-1/0;for(const d of n){const o=Math.round(d.x),r=Math.round(d.y);o<e&&(e=o),o>t&&(t=o),r<i&&(i=r),r>a&&(a=r)}return{xMin:e,xMax:t,yMin:i,yMax:a}}const ht="The supplied wafer centre";function mt(n,e){const t=he(n);return`${ht} (${e.x}, ${e.y}) is far outside the tested dies (X ${t.xMin}\u2026${t.xMax}, Y ${t.yMin}\u2026${t.yMax}), so it was ignored and the centre was worked out from the dies. Used as given, it would draw a wafer many times the size of the dies, with all of them in one corner.`}const gt="If the supplied centre is correct, also supply waferConfig.diameter.";function yt(n,e,t,i,a,d){if(d)return{colMidX:(Math.round(d.x)-e)*i,colMidY:(Math.round(d.y)-t)*a,anchored:!0};if(n.length===0)return{colMidX:0,colMidY:0,anchored:!1};let o=1/0,r=-1/0,p=1/0,h=-1/0;for(const l of n){const f=Math.round(l.x)-e,y=Math.round(l.y)-t;f<o&&(o=f),f>r&&(r=f),y<p&&(p=y),y>h&&(h=y)}return{colMidX:(o+r)/2*i,colMidY:(p+h)/2*a,anchored:!1}}function bt(n,e,t){let i=1/0,a=-1/0,d=1/0,o=-1/0,r=0,p=0;for(const f of n){const y=Math.round(f.x)-e,m=Math.round(f.y)-t;r+=y,p+=m,y<i&&(i=y),y>a&&(a=y),m<d&&(d=m),m>o&&(o=m)}const h=n.length,l=(f,y,m)=>{const c=(m-y)/2;return c<=0?0:Math.abs(f/h-(y+m)/2)/c};return l(r,i,a)>.11||l(p,d,o)>.11}function me(n,e){let t=n?.xAxisDirection==="left",i=n?.yAxisDirection==="down";return(e.type==="UL"||e.type==="UR")&&(i=!0),(e.type==="LR"||e.type==="UR")&&(t=!0),{flipX:t,flipY:i}}function wt(n){const e={...n};return delete e.limitLow,delete e.limitHigh,delete e.limitLowInclusive,delete e.limitHighInclusive,delete e.specLow,delete e.specHigh,e}function xt(n,e){const{method:t,targetBin:i}=n,a=n.results.map(d=>d.filter(I));if(t==="mean"||t==="median"||t==="stddev"||t==="min"||t==="max"||t==="count"){const d=new Set((e??[]).filter(l=>!isParametricTest(l)).map(l=>l.testNumber)),o=new Set;for(const l of a)for(const f of Fe(l,"values"))d.has(f)||o.add(f);if(o.size===0)return ue(a,t);const r=[...o],p=r.map(l=>ue(a,t,l)),h=new Map;for(let l=0;l<r.length;l++){const f=r[l];for(const y of p[l]){const m=X(y);h.has(m)||h.set(m,{template:y,testValues:{}});const c=h.get(m),w=y.testValues?.[0];w!==void 0&&(c.testValues[f]=w)}}return[...h.values()].map(({template:l,testValues:f})=>({...l,testValues:Ze(f)?f:void 0}))}if(t==="countBin"||t==="percent"){if(i===void 0)return[];const d=tt(a,i,"hard");if(t==="countBin")return d;const o=a.length;return d.map(r=>({...r,testValues:{0:o>0?(r.testValues?.[0]??0)/o*100:0}}))}if(t==="mode"){const d=new Map;for(const r of a)for(const p of r){const h=X(p);d.has(h)||d.set(h,[]),d.get(h).push(p)}const o=[];for(const[r,p]of d){const h=r.split(","),l=Number(h[0]),f=Number(h[1]),y=p.map(c=>c.hbin).filter(c=>c!==void 0),m=et(y);m!==null&&o.push({x:l,y:f,hbin:m})}return o}return[]}export function computeCoverage(n){const e=n.filter(I),t=e.length,i=e.filter(d=>d.edgeExcluded).length,a=e.filter(d=>d.hbin!==void 0||d.sbin!==void 0||dieHasTestData(d)).length;return{filledDies:a,totalDies:t,edgeExcludedDies:i,unpositionedDies:n.length-e.length,ratio:t>0?a/t:0}}export function computeYield(n,e,t="exclude",i=!0){const a=new Set(e),o=n.filter(c=>!c.partial).filter(c=>c.edgeExcluded&&!c.filteredOut).length,r=n.filter(c=>c.partial).length;if(!i)return{passDies:0,failDies:0,edgeExcludedDies:o,partialDies:r,totalDies:0,yieldPercent:null,yieldPercentGross:null};let p=0,h=0,l=!1;for(const c of n){if(!ve(c))continue;const w=c.hbin??c.sbin;w!==void 0&&(l=!0,a.has(w)?p++:h++)}const f=p+h,y=l&&f>0?p/f*100:null;let m=null;if(t==="denominator-only"){const c=f+o;m=l&&c>0?p/c*100:null}return{passDies:p,failDies:h,edgeExcludedDies:o,partialDies:r,totalDies:f,yieldPercent:y,yieldPercentGross:m}}function ge(n,e,t,i,a,d=0,o=0,r=0,p=0,h=0,l=!1,f=!1){if(!n)return[];const y=n.anchorDie??{x:0,y:0},m=He(e,{width:n.width,height:n.height,diePitchX:i,diePitchY:a,anchorDie:{x:y.x-d,y:y.y-o},gridOrigin:{x:-r,y:-p}}),c=Le(Ve(l,f,e.center.x,e.center.y),Be(h,e.center.x,e.center.y));return m.filter(w=>{const u=w.width/2,C=w.height/2,D=[[w.x-u,w.y-C],[w.x+u,w.y-C],[w.x+u,w.y+C],[w.x-u,w.y+C]].map(([v,T])=>Ye(c,v,T)),g=le(D.map(v=>v.x)),b=ee(D.map(v=>v.x)),k=le(D.map(v=>v.y)),R=ee(D.map(v=>v.y));return t.some(v=>v.physX>=g&&v.physX<b&&v.physY>=k&&v.physY<R)})}function Dt(n,e,t){const a=Math.max(0,e.radius-t)**2;return n.map(d=>{const o=d.physX-e.center.x,r=d.physY-e.center.y;return o*o+r*r>a?{...d,edgeExcluded:!0}:d})}const Mt=.2;function vt(n){const e=new Set;for(const t of n){if(t.supersedes!==void 0||!I(t))return!1;const i=Se(t);if(e.has(i))return!1;e.add(i)}return!0}function St(n,e,t){if(vt(n))return{results:n.slice(),warning:void 0};const i=new Set(t);function a(g,b){if(e==="last")return!0;if(e==="first")return!1;const k=G(g.hbin),R=G(b.hbin);if(k===void 0||R===void 0)return!1;const v=i.has(k),T=i.has(R);return e==="best"?T!==v?T:R<k:T!==v?v:R>k}const d=(g,b)=>b.supersedes!==void 0||a(g,b),o=g=>{const b=g.partId===void 0?"":String(g.partId).trim();return b===""?void 0:b},r=n.filter(g=>!I(g)),p=new Map;for(const g of r){const b=o(g);b!==void 0&&p.set(b,(p.get(b)??0)+1)}const l=(r.length===0?0:Math.max(0,...p.values())/r.length)<=Mt,f=new Map,y=[],m=new Map;let c=0,w=0;for(const g of n){const b=o(g);let k;if(I(g)?k=`p:${X(g)}`:l&&b!==void 0?k=`i:${b}`:k=`u:${w++}`,g.supersedes==="partId"&&b!==void 0){const v=m.get(b);v!==void 0&&v!==k&&f.has(v)&&f.delete(v)}const R=f.get(k);R===void 0?(f.set(k,{winner:g,count:1}),y.push(k)):(R.count++,k.startsWith("i:")&&c++,d(R.winner,g)&&(R.winner=g)),b!==void 0&&m.set(b,k)}const u=[],C=[...y.filter(g=>g.startsWith("p:")),...y.filter(g=>!g.startsWith("p:"))];for(const g of C){const b=f.get(g);b!==void 0&&u.push(b.count>1?{...b.winner,retestCount:b.count}:b.winner)}const D=c>0?{code:"retests-by-part-id",severity:"info",message:`${c} record${c===1?"":"s"} with no position shared a part ID with an earlier record and ${c===1?"was":"were"} treated as a retest of it.`}:void 0;return{results:u,warning:D}}export function getDieTestValue(n,e){return Z(n,e)}export function getTestPassStatus(n,e,t){const i=Ne(n,e);return i!==void 0?i:t!==void 0&&!isParametricTest(t)?ye(Z(n,e)):void 0}function ye(n){return n===0||n===1?n===1:void 0}export function testPassStatusReader(n){const e=n.map(a=>a.testNumber),t=Re(e),i=n.map(a=>!isParametricTest(a));return function(d,o){t(d,o);for(let r=0;r<o.length;r++){if(o[r]!==Ie||!i[r])continue;const p=ye(Z(d,e[r]));p!==void 0&&(o[r]=p?We:Te)}return o}}export function dieHasTestData(n){return Ae(n)}function G(n){return n===void 0||Number.isNaN(n)?void 0:n}function q(n,e){const t={},i=G(e.hbin),a=G(e.sbin);i!==void 0&&(t.hbin=i),a!==void 0&&(t.sbin=a),e.retestCount!==void 0&&(t.retestCount=e.retestCount),e.siteNum!==void 0&&(t.siteNum=e.siteNum),e.partId!==void 0&&(t.partId=e.partId),e.metadata!==void 0&&(t.metadata=e.metadata);const d=U(e);return $e({...n,...t},d.table,d.row)}function be(n){return n.some(dieHasTestData)?"value":defaultBinMode([n])}export function defaultBinMode(n){const e=t=>n.some(i=>i.some(a=>t(a)!=null));return e(t=>t.hbin)?"hardBin":e(t=>t.sbin)?"softBin":"hardBin"}export function binFieldOf(n){return defaultBinMode(n)==="softBin"?"sbin":"hbin"}function we(n,e){return n.map(({code:t,message:i})=>({code:t,message:i,severity:t==="non-standard-diameter"||t==="diameter-exceeds-die-extent"||t==="implausible-center"?"warning":"error",confidence:e.wafer.confidence}))}const Ct="do not fit inside the supplied",kt="Inferred wafer diameter",Ot="The probed dies reach only",At=.75,xe=20;export const STANDARD_WAFER_DIAMETERS_MM=[100,125,150,200,300];const $t=.02;function De(n,e){return e.reduce((t,i)=>Math.abs(i-n)<Math.abs(t-n)?i:t)}function Nt(n,e){if(!e.length)return!0;const t=De(n,e);return Math.abs(t-n)/t<=$t}function Rt(n){return n===void 0?STANDARD_WAFER_DIAMETERS_MM:n.filter(e=>Number.isFinite(e)&&e>0)}export function buildWaferMap(n){const e=lt(!Array.isArray(n)&&n.layout?ft(n):n),t=[];let i;if(e.valueFilter!=="none"&&e.testDefs){const s=e.valueFilter,x=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(O=>{const _=O.length>0?U(O[0]):void 0;if(!_)return[];const F=st(_.table,e.testDefs,s);return F.tests.length>0&&oe(O,F.table),F.tests}),A=rt(x);if(A.length>0){i={mode:s,tests:A};const O=ot(s,A,e.testDefs);O&&t.push(O)}}if(e.derivedTests){const s=new Set(e.passBins),x=_=>{const F=_.length>0?U(_[0]):void 0,H=Ue(_,F?.table??Ee([]),e.testDefs,e.derivedTests,s);return F&&oe(_,H.table),H},O=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(x);e.testDefs=O[0]?.testDefs??e.testDefs,t.push(...O[0]?.warnings??[])}e.lotStackOpts&&!nt(e.lotStackOpts.method)&&(e.testDefs=e.testDefs?.map(wt));const a=e.lotStackOpts?re(xt(e.lotStackOpts,e.testDefs)).records:e.results;for(let s=0;s<Math.min(5,a.length);s++){const x=a[s];if(typeof x.x=="string"||typeof x.y=="string")throw new TypeError("buildWaferMap: x and y must be numbers, received strings. Did you forget to cast CSV values? e.g. { x: +row.x, y: +row.y }")}for(const s of a)if(s.x==null!=(s.y==null))throw new TypeError(`buildWaferMap: die has only one of x/y set (x=${String(s.x)}, y=${String(s.y)}). A die must be either fully positioned (both x and y) or fully unpositioned (neither) \u2014 omit both to mark a die as having no reported position.`);const{results:d,warning:o}=St(a,e.retestPolicy,e.passBins),r={wafer:{confidence:1,method:"provided"},diePitch:{confidence:1,units:"mm"},grid:{confidence:1}},p=[];if(e.explicitDies){let s=e.explicitDies.filter(I);const x=e.explicitDies.filter(V=>!I(V)),A=d.filter(I),O=d.filter(V=>!I(V));if(A.length>0){const V=new Map(A.map(B=>[X(B),B]));s=s.map(B=>{const ie=V.get(X(B));return ie?q(B,ie):B})}const _=e.waferOpts?.diameter??300,F=Q({diameter:_,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});F.orientation!==0&&(s=se(s,F)),s=s.map(z);const H=ge(e.reticleOpts,F,s,s[0]?.width??1,s[0]?.height??1,0,0,0,0,F.orientation),Me=O.map((V,B)=>z(q({id:`unpositioned_${B}`,width:s[0]?.width??1,height:s[0]?.height??1},V))),J=[...s,...x,...Me];return{wafer:F,dies:J,dataAxisFlip:{x:!1,y:!1},reticleConfig:e.reticleOpts,units:"mm",inference:r,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...we(p,r),...t,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:be(d),metadata:F.metadata??null,isLotStack:!1,dataCoverage:computeCoverage(J),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:computeYield(J,e.passBins,e.edgeDieYieldMode),reticles:H,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields}}const h=d.filter(I),l=d.filter(s=>!I(s)),f=h.map(s=>({x:s.x,y:s.y})),y=Ke(f,e.dieOpts,e.waferOpts?.diameter);r.diePitch={confidence:y.confidence,units:y.units};const{pitchX:m,pitchY:c}=y,w=y.units,u=ut(h,e.dieOpts),C=je(f);r.grid={confidence:C.confidence};const{offsetX:D,offsetY:g}=ct(f,u,C),{flipX:b,flipY:k}=me(e.dieOpts,u),R=e.waferOpts?.diameter===void 0&&e.waferOpts?.center!==void 0&&pt(f,e.waferOpts.center),v=R?void 0:e.waferOpts?.center;if(R){const s=mt(f,e.waferOpts.center);console.warn(`[wafermap] ${s} ${gt}`),p.push({code:"implausible-center",message:s})}const{colMidX:T,colMidY:L,anchored:K}=yt(f,D,g,m,c,v);let S=e.waferOpts?.diameter;const N=f.map(s=>({x:(Math.round(s.x)-D)*m-T,y:(Math.round(s.y)-g)*c-L})),M=ee(N.map(({x:s,y:x})=>Math.hypot(Math.abs(s)+m/2,Math.abs(x)+c/2)));if(S===void 0)if(f.length>0)if(w==="mm"){const s=Xe(N,{minRadius:M});S=s.diameter,r.wafer={confidence:s.confidence,method:s.method};const x=Rt(e.standardDiameters);if(!Nt(S,x)){const A=De(S,x);p.push({code:"non-standard-diameter",message:`${kt} ${S.toFixed(1)} mm is not a standard wafer size (nearest is ${A} mm). The diameter was derived from the die extent, which assumes the probed grid reaches the wafer edge \u2014 a non-standard result usually means it does not, because the outer dies were never probed. Every die is then placed against a wafer that is too small, which moves dies between rings and changes ring and edge findings. Supply waferConfig.diameter.`})}}else S=M*2,r.wafer={confidence:y.confidence*.8,method:"extent"};else S=w==="mm"?300:30,r.wafer={confidence:0,method:"default"};if(!K&&f.length>0&&bt(f,D,g)&&(r.wafer.method="inferred-partial",p.push({code:"partial-coverage",message:"Wafer geometry was inferred from die positions alone. The data does not span a full symmetric wafer, so the inferred diameter and centre may be wrong and dies may be mis-positioned relative to the true wafer boundary. Supply waferConfig.diameter and waferConfig.center (the prober coordinate of the wafer centre) to position partial data correctly."})),e.waferOpts?.diameter!==void 0&&v===void 0&&M>0&&f.length>=xe){const s=M/(S/2);s<At&&p.push({code:"diameter-exceeds-die-extent",message:`${Ot} ${(s*100).toFixed(0)}% of the ${S} mm wafer's radius. Either the diameter is larger than the real one, or this is a partial map covering only part of the wafer. Ring bands are equal-radius, so the outer rings are mostly or entirely empty and ring, quadrant and edge findings describe the assumed wafer rather than the probed area. Check waferConfig.diameter, or drop it and let the diameter be inferred from the die extent.`})}if(e.waferOpts?.diameter!==void 0){const s=e.dieOpts?.width!==void 0&&e.dieOpts?.height!==void 0;if(s&&M>S/2+1e-9){const x=N.filter(({x:A,y:O})=>Math.hypot(Math.abs(A)+m/2,Math.abs(O)+c/2)>S/2+1e-9).length;p.push({code:"geometry-conflict",message:`${x} of ${N.length} probed die positions ${Ct} ${S} mm wafer at the supplied die pitch of ${m} \xD7 ${c} mm. A die with test results is a real prober position and is always fully on the wafer, so one of the two supplied values must be wrong: containing these dies at this pitch would need a diameter of at least ${(M*2).toFixed(1)} mm. Check waferConfig.diameter and dieConfig.width/height against the real device.`})}}const E=Q({diameter:S,units:w,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});let $=h.map(s=>{const x=Math.round(s.x)-D,A=Math.round(s.y)-g,O={id:`${x}_${A}`,x,y:A,physX:x*m-T,physY:A*c-L,width:m,height:c,insideWafer:!0,partial:!1};return q(O,s)});(D!==0||g!==0)&&($=$.map(s=>({...s,x:s.x+D,y:s.y+g,id:`${s.x+D}_${s.y+g}`}))),$=se($,E),(b||k)&&($=Ce($,{flipX:b,flipY:k},E.center));const Y=[];e.waferOpts?.edgeExclusion&&e.waferOpts.edgeExclusion>0&&($=Dt($,E,e.waferOpts.edgeExclusion),e.waferOpts.edgeExclusion>E.radius&&Y.push({code:"edge-exclusion-exceeds-radius",message:`edgeExclusion (${e.waferOpts.edgeExclusion}mm) exceeds the resolved wafer radius (${E.radius}mm) \u2014 the entire wafer is excluded.`,severity:"warning"})),$=$.map(z);const j=ge(e.reticleOpts,E,$,m,c,D,g,T,L,E.orientation,b,k),P=l.map((s,x)=>z(q({id:`unpositioned_${x}`,width:m,height:c},s))),W=[...$,...P];return{wafer:E,dies:W,dataAxisFlip:{x:b,y:k},reticleConfig:e.reticleOpts,units:w,inference:r,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...we(p,r),...Y,...t,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:be(d),metadata:E.metadata??null,isLotStack:e.lotStackOpts!==void 0,dataCoverage:computeCoverage(W),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:computeYield(W,e.passBins,e.edgeDieYieldMode,it(e.lotStackOpts!==void 0,e.lotStackOpts?.method)),reticles:j,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields,aggrMethod:e.lotStackOpts?.method,lotSize:e.lotStackOpts?.results.length}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dataColorsFor as e}from"./dataColors.js";export function categorical(o,r){const t=e(r).categories;return t[(o%t.length+t.length)%t.length]}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Spec pass/fail die colours, shared by the value-map renderer and the spec legend so both use one
|
|
3
|
-
* definition. Pass = green, fail-low (below limitLow) = blue, fail-high (above limitHigh) = red.
|
|
4
|
-
*/
|
|
5
|
-
export declare const SPEC_PASS_FILL = "#2ecc71";
|
|
6
|
-
export declare const SPEC_FAIL_LOW = "#3498db";
|
|
7
|
-
export declare const SPEC_FAIL_HIGH = "#e74c3c";
|
|
8
1
|
/**
|
|
9
2
|
* Fill for a die with no value for what is being plotted — no bin in a bin
|
|
10
3
|
* mode, no reading in a value mode. Shared by the map and every surface that
|
|
@@ -29,18 +22,24 @@ export declare function wangHash(n: number): number;
|
|
|
29
22
|
export declare function lerpKp(kp: readonly [number, number, number][], t: number): string;
|
|
30
23
|
export declare const VIRIDIS: readonly [number, number, number][];
|
|
31
24
|
/**
|
|
32
|
-
* Categorical colour for the `index`-th distinct value of an active
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* iteration order). Ordered assignment, not hashing, for the first
|
|
36
|
-
* `METADATA_PALETTE.length` slots — this maximizes distinctness for the
|
|
37
|
-
* common case of a handful of categories, unlike a hash which doesn't
|
|
38
|
-
* optimize for a *known* small set. Falls back to hashing into `BIN_PALETTE`
|
|
39
|
-
* for wafers with an unusually large category count.
|
|
25
|
+
* Categorical colour for the `index`-th distinct value of an active `'metadata'` field, where `index` is the value's place in
|
|
26
|
+
* the whole lot's values, listed in the order every surface lists them (natural order, never die order). The same palette as
|
|
27
|
+
* the charts' Group by (`categorical`), so a value is one colour on the map and in every chart.
|
|
40
28
|
*/
|
|
41
|
-
export declare function metadataValueColor(index: number): string;
|
|
29
|
+
export declare function metadataValueColor(index: number, dataColors?: string): string;
|
|
42
30
|
/** Map t ∈ [0, 1] to a greyscale rgb string (range 30–230 to avoid pure black/white). */
|
|
43
31
|
export declare function valueToGreyscale(t: number): string;
|
|
32
|
+
/**
|
|
33
|
+
* A CSS colour as `[r, g, b]` (0–255): `#rgb`, `#rrggbb`, `#rrggbbaa` (alpha ignored), `rgb()` or `rgba()`. `null` for
|
|
34
|
+
* anything else (a named colour, `color-mix()`, an empty string), so a caller can fall back rather than guess.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseCssColor(css: string): [number, number, number] | null;
|
|
37
|
+
/** WCAG relative luminance (0 black, 1 white) of an sRGB colour. */
|
|
38
|
+
export declare function relativeLuminance([r, g, b]: readonly [number, number, number]): number;
|
|
39
|
+
/** Whether a CSS colour is dark (relative luminance under 0.2): the one test a theme's dark forms follow. `false` when it cannot be read. */
|
|
40
|
+
export declare function isDarkColour(css: string | undefined): boolean;
|
|
41
|
+
/** `a` moved a fraction `t` of the way toward `b`, as `rgb()`; `null` when either colour cannot be read. */
|
|
42
|
+
export declare function mixCssColors(a: string, b: string, t: number): string | null;
|
|
44
43
|
/** Return '#000000' or '#ffffff' for maximum contrast against the given colour. */
|
|
45
44
|
export declare function contrastTextColor(cssColor: string): '#000000' | '#ffffff';
|
|
46
45
|
//# sourceMappingURL=colorMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{clamp01 as
|
|
1
|
+
import{categorical as u}from"./categoryColors.js";import{clamp01 as l}from"../core/utils.js";export const NO_DATA_FILL="#d6d9dd",BIN_PALETTE=["#95a5a6","#1eb84b","#932cdd","#b8a51e","#2cbfdd","#b81e71","#58dd2c","#251eb8","#dd672c","#1eb87f","#ce2cdd","#98b81e","#2c84dd","#b81e3e","#2cdd3b","#581eb8","#dda22c","#1eb8b2","#dd2cb0","#64b81e","#2c49dd","#b8321e","#2cdd76","#8c1eb8","#dcdd2c","#1e8bb8","#dd2c75","#31b81e","#4b2cdd","#b8651e","#2cddb1","#b81eb1","#a1dd2c","#1e57b8","#dd2c3a","#1eb83f","#852cdd","#b8991e","#2ccddd","#b81e7e","#66dd2c","#1e24b8","#dd5a2c","#1eb872","#c02cdd","#a4b81e","#2c92dd","#b81e4a","#2cdd2e","#4c1eb8","#dd942c","#1eb8a6","#dd2cbe","#70b81e","#2c57dd","#b8261e","#2cdd69","#801eb8","#ddcf2c","#1e97b8","#dd2c83","#3db81e","#3d2cdd","#b8591e"];export function wangHash(t){let e=t|0;return e=Math.imul(e^e>>>16,73244475),e=Math.imul(e^e>>>16,73244475),(e^e>>>16)>>>0}export function lerpKp(t,e){const d=l(e)*(t.length-1),c=Math.floor(d),n=Math.min(c+1,t.length-1),s=d-c,o=Math.round(t[c][0]+s*(t[n][0]-t[c][0])),b=Math.round(t[c][1]+s*(t[n][1]-t[c][1])),a=Math.round(t[c][2]+s*(t[n][2]-t[c][2]));return`rgb(${o},${b},${a})`}export const VIRIDIS=[[68,1,84],[59,82,139],[33,145,140],[94,201,98],[253,231,37]];export function metadataValueColor(t,e){return u(t,e)}export function valueToGreyscale(t){const e=Math.round(l(t)*200+30);return`rgb(${e},${e},${e})`}export function parseCssColor(t){const e=t.trim(),r=e.match(/^rgba?\(\s*(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)/);if(r)return[+r[1],+r[2],+r[3]];const d=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e)?.[1];if(!d)return null;const c=d.length===3?[...d].map(n=>n+n).join(""):d;return[parseInt(c.slice(0,2),16),parseInt(c.slice(2,4),16),parseInt(c.slice(4,6),16)]}export function relativeLuminance([t,e,r]){const d=c=>{const n=c/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4};return .2126*d(t)+.7152*d(e)+.0722*d(r)}export function isDarkColour(t){const e=t?parseCssColor(t):null;return!!e&&relativeLuminance(e)<.2}export function mixCssColors(t,e,r){const d=parseCssColor(t),c=parseCssColor(e);if(!d||!c)return null;const[n,s,o]=d.map((b,a)=>Math.round(b+(c[a]-b)*l(r)));return`rgb(${n},${s},${o})`}export function contrastTextColor(t){let e=0,r=0,d=0;const c=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(c)e=+c[1],r=+c[2],d=+c[3];else{const o=t.replace("#","");e=parseInt(o.slice(0,2),16),r=parseInt(o.slice(2,4),16),d=parseInt(o.slice(4,6),16)}const n=o=>{const b=o/255;return b<=.03928?b/12.92:((b+.055)/1.055)**2.4};return .2126*n(e)+.7152*n(r)+.0722*n(d)>.179?"#000000":"#ffffff"}
|
|
@@ -6,19 +6,30 @@ export interface ValueColorScheme {
|
|
|
6
6
|
* pre-normalized by buildView before this is called.
|
|
7
7
|
*/
|
|
8
8
|
forValue: (t: number) => string;
|
|
9
|
+
/**
|
|
10
|
+
* The same gradient for a dark theme, when it must differ there (a scale whose quiet end is the card colour). Used in
|
|
11
|
+
* place of `forValue` when the caller says the map is drawn on a dark theme.
|
|
12
|
+
*/
|
|
13
|
+
forDarkValue?: (t: number) => string;
|
|
9
14
|
}
|
|
15
|
+
/** @internal The registration count, for caches built from these registries. */
|
|
16
|
+
export declare const colorRegistryVersion: () => number;
|
|
10
17
|
/**
|
|
11
|
-
* Register a named value gradient, making it selectable via the
|
|
12
|
-
*
|
|
13
|
-
*
|
|
18
|
+
* Register a named value gradient, making it selectable via the `valueColorScheme` option and listed under its label in
|
|
19
|
+
* the Colours menu for value and stacked maps. It replaces the data colour scheme's measured ramp while it is chosen,
|
|
20
|
+
* whichever scheme the reader picks. Call once at startup, before rendering.
|
|
14
21
|
*
|
|
15
|
-
* `forValue` must return a valid CSS colour
|
|
16
|
-
*
|
|
22
|
+
* `forValue` must return a valid CSS colour (`#rrggbb`, `#rgb` or `rgb()`); an invalid string renders as a silent blank
|
|
23
|
+
* or black die.
|
|
17
24
|
*/
|
|
18
25
|
export declare function registerValueColorScheme(name: string, scheme: ValueColorScheme): void;
|
|
26
|
+
/** @internal Whether `name` is a gradient a host registered (listed in the Colours menu), not one of the library's. */
|
|
27
|
+
export declare const isHostGradient: (name: string) => boolean;
|
|
28
|
+
/** @internal Whether `name` is a registered gradient. */
|
|
29
|
+
export declare const hasValueColorScheme: (name: string) => boolean;
|
|
19
30
|
/** Retrieve a value gradient by name. Falls back to `'default'`, never undefined. */
|
|
20
31
|
export declare function getValueColorScheme(name?: string): ValueColorScheme;
|
|
21
|
-
/**
|
|
32
|
+
/** The registered value gradients, as `{ name, label }`, in registration order (`'default'`, Viridis, first). */
|
|
22
33
|
export declare function listValueColorSchemes(): Array<{
|
|
23
34
|
name: string;
|
|
24
35
|
label: string;
|
|
@@ -35,40 +46,33 @@ export declare function listValueColorSchemes(): Array<{
|
|
|
35
46
|
* to be missed. Reversing is a flag rather than a second registered entry per
|
|
36
47
|
* ramp so the menu stays one list and a host's own gradient gets it for free.
|
|
37
48
|
*/
|
|
38
|
-
export declare function resolveValueColorFn(name?: string, reversed?: boolean): (t: number) => string;
|
|
49
|
+
export declare function resolveValueColorFn(name?: string, reversed?: boolean, dark?: boolean): (t: number) => string;
|
|
50
|
+
/** A bin palette: pass colours, then fail colours, each taken in bin-number order. */
|
|
39
51
|
export interface BinColorScheme {
|
|
40
|
-
/**
|
|
52
|
+
/** Name shown in the Colours menu. */
|
|
41
53
|
label: string;
|
|
42
|
-
/**
|
|
43
|
-
* Colours for passing bins, indexed by bin number: pass bin 1 takes the first,
|
|
44
|
-
* pass bin 2 the second, wrapping round. Convention is greens: an engineer
|
|
45
|
-
* reads green as pass before reading the legend.
|
|
46
|
-
*/
|
|
47
54
|
pass: readonly string[];
|
|
48
|
-
/**
|
|
49
|
-
* Colours for failing bins, indexed by bin number: fail bin 2 takes the
|
|
50
|
-
* first, bin 3 the second, wrapping round. Put the most distinct colours at
|
|
51
|
-
* the front — the low bin numbers most programs use land there. Must not
|
|
52
|
-
* resemble the pass colours — a fail bin that reads as a pass is the most
|
|
53
|
-
* expensive misreading a wafer map can produce.
|
|
54
|
-
*/
|
|
55
55
|
fail: readonly string[];
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
|
-
* Register a named bin palette, making it selectable via the `binColorScheme`
|
|
59
|
-
*
|
|
60
|
-
* startup, before rendering.
|
|
61
|
-
*
|
|
62
|
-
* Throws on an empty `pass` or `fail` list: there would be nothing to colour
|
|
63
|
-
* that category with, and the failure is better at registration than as
|
|
64
|
-
* uncoloured dies later.
|
|
58
|
+
* Register a named bin palette, making it selectable via the `binColorScheme` option and listed under its label in the
|
|
59
|
+
* Colours menu for bin maps. It replaces the data colour scheme's bin palette while it is chosen, whichever scheme the
|
|
60
|
+
* reader picks; `BinDef.color` still wins over it. Call once at startup, before rendering.
|
|
65
61
|
*/
|
|
66
62
|
export declare function registerBinColorScheme(name: string, scheme: BinColorScheme): void;
|
|
67
|
-
/**
|
|
68
|
-
export declare
|
|
69
|
-
/**
|
|
63
|
+
/** @internal A host's bin palette by name, or undefined. */
|
|
64
|
+
export declare const getBinColorScheme: (name: string | undefined) => BinColorScheme | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* The bin palettes, as `{ name, label }`: `'default'` (the data colour scheme's own bins), `'accessible'` (the Okabe-Ito
|
|
67
|
+
* scheme's colour-blind safe bins), then each a host registered, in registration order.
|
|
68
|
+
*/
|
|
70
69
|
export declare function listBinColorSchemes(): Array<{
|
|
71
70
|
name: string;
|
|
72
71
|
label: string;
|
|
73
72
|
}>;
|
|
73
|
+
/** @internal The host-registered bin palettes, as `{ name, label }`, for the Colours menu. */
|
|
74
|
+
export declare const listHostBinColorSchemes: () => Array<{
|
|
75
|
+
name: string;
|
|
76
|
+
label: string;
|
|
77
|
+
}>;
|
|
74
78
|
//# sourceMappingURL=colorSchemes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{VIRIDIS as
|
|
1
|
+
import{VIRIDIS as b,lerpKp as r,valueToGreyscale as p}from"./colorMap.js";const t=new Map,i=new Set;let a=0;export const colorRegistryVersion=()=>a;function o(e,l){t.set(e,l),i.add(e),a++}export function registerValueColorScheme(e,l){t.set(e,l),i.delete(e),a++}export const isHostGradient=e=>t.has(e)&&!i.has(e),hasValueColorScheme=e=>t.has(e);export function getValueColorScheme(e){return t.get(e??"default")??t.get("default")}export function listValueColorSchemes(){return[...t.entries()].map(([e,l])=>({name:e,label:l.label}))}export function resolveValueColorFn(e,l,u){const n=getValueColorScheme(e),c=u&&n.forDarkValue?n.forDarkValue:n.forValue;return l?f=>c(1-f):c}o("default",{label:"Default (Viridis)",forValue:e=>r(b,e)});const V=[[0,32,77],[54,68,130],[107,107,145],[180,154,108],[253,228,32]];o("cividis",{label:"Cividis (colour-blind safe)",forValue:e=>r(V,e)}),o("greyscale",{label:"Greyscale",forValue:e=>p(e)});const d=[[13,8,135],[126,3,168],[204,71,120],[248,149,64],[240,249,33]];o("plasma",{label:"Plasma",forValue:e=>r(d,e)});const g=[[0,0,4],[87,16,110],[188,55,84],[249,142,9],[252,255,164]];o("inferno",{label:"Inferno",forValue:e=>r(g,e)});const h=[[11,4,5],[43,28,53],[62,53,107],[59,86,152],[53,123,163],[53,159,171],[75,194,173],[153,221,182],[222,245,229]];o("mako",{label:"Mako",forValue:e=>r(h,e)});const C=[[46,204,113],[241,196,15],[231,76,60]];o("traffic",{label:"Traffic (green\u2013yellow\u2013red)",forValue:e=>r(C,e)});const S=[[0,0,128],[0,0,255],[0,255,255],[255,255,0],[255,0,0],[128,0,0]];o("jet",{label:"Jet (MATLAB rainbow)",forValue:e=>r(S,e)});const s=new Map;export function registerBinColorScheme(e,l){if(!l.pass.length||!l.fail.length)throw new Error(`registerBinColorScheme('${e}'): 'pass' and 'fail' must each list at least one colour`);if(e==="default"||e==="accessible")throw new Error(`registerBinColorScheme('${e}'): '${e}' is a built-in name; choose another`);s.set(e,{label:l.label,pass:[...l.pass],fail:[...l.fail]}),a++}export const getBinColorScheme=e=>e?s.get(e):void 0;export function listBinColorSchemes(){return[{name:"default",label:"Default"},{name:"accessible",label:"Colour-blind safe"},...[...s.entries()].map(([e,l])=>({name:e,label:l.label}))]}export const listHostBinColorSchemes=()=>[...s.entries()].map(([e,l])=>({name:e,label:l.label}));
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { PlotMode } from './buildView.js';
|
|
2
|
+
export type Rgb = [number, number, number];
|
|
3
|
+
/** A role's stops for a light theme and for a dark one, from the low end (t = 0) to the high end (t = 1). */
|
|
4
|
+
export interface RoleStops {
|
|
5
|
+
light: readonly string[];
|
|
6
|
+
dark: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export interface DataColorScheme {
|
|
9
|
+
/** Name shown in the Data colours menu. */
|
|
10
|
+
label: string;
|
|
11
|
+
/** A measured value, low to high. */
|
|
12
|
+
measured: readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* Good to bad, drawn from the worst (t = 0, a yield of 0%) to the best (t = 1, 100%). A yield has no neutral
|
|
15
|
+
* middle, so this is not a two-ended scale: lightness changes one way only, the worst the strongest (dark on a light
|
|
16
|
+
* card, bright on a dark one) and the best the calmest, and hue only helps.
|
|
17
|
+
*/
|
|
18
|
+
rating: RoleStops;
|
|
19
|
+
/** Below to above a centre: the lowest value (t = 0), the centre (0.5), the highest (1). */
|
|
20
|
+
signed: RoleStops;
|
|
21
|
+
/** None to the most: t = 0 is the quiet colour. */
|
|
22
|
+
counts: RoleStops;
|
|
23
|
+
/** Which-one-is-this colours, in order; the list wraps. */
|
|
24
|
+
categories: readonly string[];
|
|
25
|
+
/** The bin palette: pass colours, indexed by bin number, then fail colours. */
|
|
26
|
+
bins: {
|
|
27
|
+
pass: readonly string[];
|
|
28
|
+
fail: readonly string[];
|
|
29
|
+
};
|
|
30
|
+
/** The pass/fail display of a value map. */
|
|
31
|
+
passFail: {
|
|
32
|
+
pass: string;
|
|
33
|
+
failLow: string;
|
|
34
|
+
failHigh: string;
|
|
35
|
+
};
|
|
36
|
+
/** The fill of a bar that says only "how much". */
|
|
37
|
+
quantity: string;
|
|
38
|
+
}
|
|
39
|
+
/** @internal A ramp's colour at `t` in [0, 1] (clamped; a non-finite `t` reads as 0). */
|
|
40
|
+
export declare function rampRgb(stops: readonly string[], t: number): Rgb;
|
|
41
|
+
export declare const cssRgb: (c: readonly number[]) => string;
|
|
42
|
+
/** The scheme used when none is chosen, or the name is not registered. */
|
|
43
|
+
export declare const DEFAULT_DATA_COLORS = "classic";
|
|
44
|
+
/**
|
|
45
|
+
* Add a scheme a reader can choose in the Data colours menu, or replace one by name. Call once at startup, before
|
|
46
|
+
* rendering. Every role must be complete: a missing stop would draw a blank or black die.
|
|
47
|
+
*/
|
|
48
|
+
export declare function registerDataColorScheme(name: string, scheme: DataColorScheme): void;
|
|
49
|
+
/** The registered schemes as `{ name, label }`, in registration order (Classic first). */
|
|
50
|
+
export declare function listDataColorSchemes(): Array<{
|
|
51
|
+
name: string;
|
|
52
|
+
label: string;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* @internal The one rule for which scheme a surface draws: the reader's when registered (or a scheme with a host's bin
|
|
56
|
+
* palette or value gradient over it, from {@link effectiveDataColors}), else Classic.
|
|
57
|
+
*/
|
|
58
|
+
export declare function dataColorsName(preferred: string | undefined): string;
|
|
59
|
+
/** @internal The scheme named `name`; an unknown or missing name is Classic, never undefined. */
|
|
60
|
+
export declare function dataColorsFor(name?: string): DataColorScheme;
|
|
61
|
+
/**
|
|
62
|
+
* @internal The scheme name every surface draws by: the reader's data colour scheme (`dataColors`), with the bin palette
|
|
63
|
+
* (`binColorScheme`) and value gradient (`valueColorScheme`) they chose in its place where they chose one.
|
|
64
|
+
*/
|
|
65
|
+
export declare function effectiveDataColors(dataColors: string | undefined, binColorScheme?: string, valueColorScheme?: string): string;
|
|
66
|
+
/** @internal The reader's data colour scheme within a name from {@link effectiveDataColors}. */
|
|
67
|
+
export declare function baseDataColors(name: string | undefined): string;
|
|
68
|
+
/** The yield and pass-rate key: a linear scale from 0% to 100%, named at these points. Fixed, not a setting. */
|
|
69
|
+
export declare const RATING_BREAKS: readonly number[];
|
|
70
|
+
/**
|
|
71
|
+
* @internal Where a yield or pass rate, in percent, sits on the rating scale: 0 at 0%, 1 at 100%, linear between, so
|
|
72
|
+
* equal distances on the key are equal differences in yield and a lot yielding 15% is told apart from one yielding 45%.
|
|
73
|
+
*/
|
|
74
|
+
export declare function ratingT(percent: number): number;
|
|
75
|
+
/** @internal The inverse of {@link ratingT}: the percent at `t`, for a colour key's ticks. */
|
|
76
|
+
export declare function ratingPercentAt(t: number): number;
|
|
77
|
+
/** @internal Good to bad: `t` 0 is the worst (a yield of 0%), 1 the best (100%). */
|
|
78
|
+
export declare const ratingColor: (t: number, scheme: DataColorScheme, dark: boolean) => Rgb;
|
|
79
|
+
/** @internal Below to above a centre: `t` 0 is the lowest value, 0.5 the centre. */
|
|
80
|
+
export declare const signedColor: (t: number, scheme: DataColorScheme, dark: boolean) => Rgb;
|
|
81
|
+
/**
|
|
82
|
+
* @internal None to the most: `t` 0 is the quiet colour. Any `t` above 0 starts 15% along, so a single occurrence is
|
|
83
|
+
* never mistaken for none.
|
|
84
|
+
*/
|
|
85
|
+
export declare function countColor(t: number, scheme: DataColorScheme, dark: boolean): Rgb;
|
|
86
|
+
/** @internal A measured value; `reversed` flips the ramp (Reverse applies to this role only). */
|
|
87
|
+
export declare const measuredColor: (t: number, scheme: DataColorScheme, reversed?: boolean, greyscale?: boolean) => Rgb;
|
|
88
|
+
/** How much of that colour a table cell takes: a tint, never a fill, so the number stays legible on a light or dark card. */
|
|
89
|
+
export declare const SHORTFALL_ALPHA: Readonly<Record<1 | 2 | 3, number>>;
|
|
90
|
+
/** @internal The solid colour of shortfall step 1, 2 or 3 (a bar's fill), from the rating scale's bad side. */
|
|
91
|
+
export declare const shortfallRgb: (step: 1 | 2 | 3, scheme: DataColorScheme, dark?: boolean) => Rgb;
|
|
92
|
+
/** @internal The translucent tint of shortfall step 1, 2 or 3 (a table cell's background). */
|
|
93
|
+
export declare const shortfallTint: (step: 1 | 2 | 3, scheme: DataColorScheme) => string;
|
|
94
|
+
/** A bar's fill on a white page (a report): the quantity colour at 55%, the rest white. */
|
|
95
|
+
export declare const barOnWhite: (quantity: string) => string;
|
|
96
|
+
/** The five colours the pass/fail display of a value map and its legend draw. */
|
|
97
|
+
export interface PassFailFills {
|
|
98
|
+
pass: string;
|
|
99
|
+
failLow: string;
|
|
100
|
+
failHigh: string;
|
|
101
|
+
}
|
|
102
|
+
/** Which role of the scheme colours a map's dies. */
|
|
103
|
+
export type ValueRole = 'measured' | 'counts' | 'signed';
|
|
104
|
+
/**
|
|
105
|
+
* @internal The one rule for which role colours a map, and whether Reverse applies. A stacked count map takes `counts`
|
|
106
|
+
* and a signed map (the difference map) `signed`, whatever the reader chose; any other map takes the scheme's `measured`
|
|
107
|
+
* ramp. Reverse applies to `measured` only (a reversed counts scale would make none the strong colour).
|
|
108
|
+
*/
|
|
109
|
+
export declare function valueSchemeFor(plotMode: PlotMode | undefined, options?: {
|
|
110
|
+
signed?: boolean;
|
|
111
|
+
}): {
|
|
112
|
+
role: ValueRole;
|
|
113
|
+
reversible: boolean;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* The colour function a value surface must use: the scheme's role at `t` in [0, 1], reversed for `measured` when asked.
|
|
117
|
+
*
|
|
118
|
+
* **Every surface that colours a map value resolves through this** (die fills, the colour bar, the mapless summary's bars),
|
|
119
|
+
* so one reading is one colour on the whole screen.
|
|
120
|
+
*/
|
|
121
|
+
export declare function valueColorFn(schemeName: string | undefined, role: ValueRole, reversed: boolean, dark: boolean, greyscale?: boolean): (t: number) => string;
|
|
122
|
+
/** @internal The pass/fail display's fills for a scheme. */
|
|
123
|
+
export declare const passFailFillsFor: (schemeName: string | undefined) => PassFailFills;
|
|
124
|
+
/** The CSS custom properties a surface sets on its root so a table tint or panel bar needs no plumbing from the scheme. */
|
|
125
|
+
export declare function dataColorVars(schemeName: string | undefined, dark: boolean): Record<string, string>;
|
|
126
|
+
//# sourceMappingURL=dataColors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{noticeOnce as D}from"./deprecate.js";import{colorRegistryVersion as E,getBinColorScheme as x,hasValueColorScheme as M,resolveValueColorFn as C}from"./colorSchemes.js";const o=e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)],d=e=>"#"+e.map(a=>Math.round(a).toString(16).padStart(2,"0")).join(""),p=(e,a,t)=>[e[0]+(a[0]-e[0])*t,e[1]+(a[1]-e[1])*t,e[2]+(a[2]-e[2])*t];export function rampRgb(e,a){const s=(Number.isFinite(a)?Math.min(1,Math.max(0,a)):0)*(e.length-1),n=Math.min(e.length-2,Math.floor(s));return p(o(e[n]),o(e[n+1]),s-n)}export const cssRgb=e=>`rgb(${Math.round(e[0])}, ${Math.round(e[1])}, ${Math.round(e[2])})`;const v=[62,62,66],R=e=>[e[1],d(p(o(e[1]),v,.55)),d(v),d(p(o(e[3]),v,.55)),e[3]],l=e=>({light:e,dark:R(e)}),u=(e,a)=>({light:["#e3e3e3",...e],dark:["#3a3a3d",...a]}),k=["#882255","#117733","#AA4499","#DDCC77","#44AA99","#6C5B9E","#B8B84A","#4D4D4D"],b=e=>[...e,...k.filter(a=>!e.some(t=>t.toLowerCase()===a.toLowerCase()))],$={classic:{label:"Classic",measured:["#440154","#3b528b","#21918c","#5ec962","#fde725"],rating:{light:["#6e0616","#8c0b13","#a82309","#ba4400","#c76300","#ca8500","#c0ab40","#c0cd89","#8ce9ff"],dark:["#ffa390","#ff9373","#f5854c","#dc7f21","#b77e00","#887e00","#4d7b28","#00707a","#004794"]},signed:l(["#c51b7d","#e9a3c9","#f7f7f7","#a1d76a","#4d9221"]),counts:u(["#fdd49e","#fc8d59","#d7301f","#7f0000"],["#843016","#c0441f","#f07a45","#fdc497"]),categories:b(["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#A06CD5","#8C6D31"]),bins:{pass:["#43a047","#1b5e20","#a5d6a7"],fail:["#b2182b","#17becf","#f6a600","#f7b6d2","#225555","#7986cb","#aa4499","#654522","#ff8a65","#999933","#848482","#fff176","#cc6677","#0067a5","#a1caf1","#009988","#9c755f","#555555","#d55e00","#663333","#e377c2","#604e97","#c49c94"]},passFail:{pass:"#43a047",failLow:"#3498db",failHigh:"#b2182b"},quantity:"#4e79a7"},"okabe-ito":{label:"Okabe-Ito",measured:["#00204d","#36448a","#6b6b91","#b49a6c","#fde420"],rating:{light:["#67170d","#871904","#a42a00","#bb4300","#cc6000","#d38000","#c9a836","#c3cd80","#94e8ff"],dark:["#ffa589","#fe956e","#f28649","#dd7e1c","#bc7c00","#887e00","#148043","#007088","#004890"]},signed:l(["#5e3c99","#b2abd2","#f5f5f5","#fdb863","#c26a00"]),counts:u(["#fde0b2","#f0a35e","#d55e00","#7a2e00"],["#7a3a10","#b5551a","#e8873d","#f8cf9c"]),categories:b(["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#A06CD5","#8C6D31"]),bins:{pass:["#009e73","#44bb99"],fail:["#d55e00","#604e97","#882d17","#f3c300","#225555","#a1caf1","#9467bd","#8c564b","#b07aa1","#eedd88","#f38400","#663333"]},passFail:{pass:"#009e73",failLow:"#0072b2",failHigh:"#d55e00"},quantity:"#5a7fa8"},calm:{label:"Calm",measured:["#2a1a5e","#3f5a9e","#4f9bb0","#9fd0a0","#f0f5c8"],rating:{light:["#5a241c","#742f20","#8c4223","#a05826","#ae7130","#b78c41","#b9ac62","#c3cc93","#a6e6ff"],dark:["#f9ab99","#f19b81","#e48e63","#d08447","#b37f36","#8f7b2d","#57793f","#006d77","#00457d"]},signed:l(["#762a83","#c2a5cf","#f7f7f7","#acd39e","#1b7837"]),counts:u(["#ecd9a8","#c99a4e","#8c5a1e","#4a2a06"],["#5c4020","#8c6430","#c49a50","#efdcae"]),categories:b(["#A06CD5","#88CCEE","#44AA99","#117733","#999933","#DDCC77","#CC6677","#882255","#AA4499"]),bins:{pass:["#44aa99","#1d6b5c","#a6dccf"],fail:["#cc6677","#f0e442","#33bbee","#f38400","#604e97","#654522","#ffcccc","#848482","#0077bb","#ce93d8","#cc3311","#882255","#999933","#555555","#f99379","#9c755f","#7986cb","#ffbe7d","#aa4499"]},passFail:{pass:"#44aa99",failLow:"#88ccee",failHigh:"#cc6677"},quantity:"#6f8faf"},vivid:{label:"Vivid",measured:["#000004","#57106e","#bc3754","#f98e09","#fcffa4"],rating:{light:["#7a000e","#9c0008","#bd0000","#d51200","#e24a00","#dd7a00","#c7a914","#c2ce75","#7feaff"],dark:["#ff9987","#ff8569","#ff7845","#ed730c","#c67600","#848000","#008356","#00718c","#00479e"]},signed:l(["#8e0152","#de77ae","#f7f7f7","#7fbc41","#276419"]),counts:u(["#ffd39a","#ff8a3d","#d42a00","#6b0000"],["#7a1e00","#c43a00","#ff7a2e","#ffd2a0"]),categories:b(["#0077BB","#33BBEE","#009988","#EE7733","#CC3311","#EE3377","#BBBBBB","#5B3A9E"]),bins:{pass:["#009988","#00574d","#6fe0d0"],fail:["#cc3311","#66ccee","#dcd300","#f7b6d2","#0072b2","#aa3377","#f28e2b","#79706e","#9575cd","#ee6677","#663333","#999933","#654522","#c49c94","#e377c2","#604e97"]},passFail:{pass:"#009988",failLow:"#0077bb",failHigh:"#cc3311"},quantity:"#3a6ea5"},night:{label:"Night",measured:["#3a2f6b","#3d6aa8","#37a0b4","#6fd6b8","#def5e5"],rating:{light:["#73002d","#90002f","#ab192a","#bd3f22","#c8621b","#ca8423","#c4aa49","#c4cc87","#9ae7ff"],dark:["#ff9aae","#ff8b8f","#fa8062","#e3793d","#bf791f","#8b7d12","#1d8045","#006f7b","#004790"]},signed:l(["#6a3d9a","#b39ddb","#f2f2f2","#a5d6a7","#2e7d32"]),counts:u(["#f4a7c3","#e0628f","#ad1457","#4a0026"],["#9a3a64","#c45589","#e889b0","#fbd3e3"]),categories:b(["#88CCEE","#EE8866","#DDCC77","#CC6677","#AA4499","#44AA99","#BBCC33","#DDDDDD"]),bins:{pass:["#4dd0e1","#1e8fa3","#b8f0f7"],fail:["#f06292","#dcd300","#64b5f6","#ff7f0e","#604e97","#882d17","#848482","#ffcccc","#0072b2","#882255","#ce93d8","#555555","#999933","#7986cb","#9c755f","#ffb74d","#f99379","#654522","#d62728","#aa4499","#c2b280","#e25822"]},passFail:{pass:"#4dd0e1",failLow:"#64b5f6",failHigh:"#f06292"},quantity:"#5c8fbf"}},f=new Map(Object.entries($));export const DEFAULT_DATA_COLORS="classic";export function registerDataColorScheme(e,a){const t=(i,r)=>{if(!i)throw new Error(`registerDataColorScheme('${e}'): ${r}`)};t(a.measured.length>=2,"'measured' needs at least two colours");for(const i of["rating","signed","counts"])t(a[i].light.length>=2&&a[i].dark.length>=2,`'${i}' needs at least two light and two dark colours`);t(a.categories.length>=1,"'categories' needs at least one colour"),t(a.bins.pass.length>=1&&a.bins.fail.length>=1,"'bins.pass' and 'bins.fail' must each list at least one colour");const s=i=>typeof i=="string"&&/^#[0-9a-fA-F]{6}$/.test(i),n=[...a.measured,...a.rating.light,...a.rating.dark,...a.signed.light,...a.signed.dark,...a.counts.light,...a.counts.dark,...a.categories,...a.bins.pass,...a.bins.fail,a.passFail?.pass,a.passFail?.failLow,a.passFail?.failHigh,a.quantity];t(!!a.passFail&&!!a.quantity,"'passFail' (pass, failLow, failHigh) and 'quantity' are required"),t(n.every(s),"every colour must be written as #rrggbb"),f.set(e,a)}export function listDataColorSchemes(){return[...f.entries()].map(([e,a])=>({name:e,label:a.label}))}export function dataColorsName(e){return e&&(f.has(e)||h(e))?e:DEFAULT_DATA_COLORS}export function dataColorsFor(e){const a=dataColorsName(e);return f.get(a)??S(a).scheme}const L=/^(.*)\|bins:([^|]*)\|values:([^|]*)$/;function h(e){const a=L.exec(e);if(a)return{base:f.has(a[1])?a[1]:DEFAULT_DATA_COLORS,bins:w(a[2]),values:A(a[3])}}function w(e){if(!(!e||e==="default")){if(e==="accessible"||x(e))return e;D(`binColorScheme:${e}`,`binColorScheme '${e}' is not registered; the colour scheme's own bin colours are used. Register it with registerBinColorScheme.`)}}function A(e){if(!(!e||e==="default")){if(M(e))return e;D(`valueColorScheme:${e}`,`valueColorScheme '${e}' is not registered; the colour scheme's own colours are used. Register it with registerValueColorScheme.`)}}export function effectiveDataColors(e,a,t){const s=e?h(e):void 0,n=s?s.base:dataColorsName(e),i=w(a)??s?.bins,r=A(t)??s?.values;return i||r?`${n}|bins:${i??""}|values:${r??""}`:n}export function baseDataColors(e){const a=e?h(e):void 0;return a?a.base:dataColorsName(e)}function O(e){const a=e.trim();if(/^#[0-9a-f]{6}$/i.test(a))return o(a);if(/^#[0-9a-f]{3}$/i.test(a))return o("#"+a[1]+a[1]+a[2]+a[2]+a[3]+a[3]);const t=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(a);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:void 0}function F(e){const a=[];for(let t=0;t<=64;t++){const s=O(e(t/64));if(!s)return;a.push(d(s))}return a}const m=new Map;function S(e){const a=m.get(e);if(a&&a.version===E())return a;const t=h(e),n={...f.get(t.base)};if(t.bins){const r=t.bins==="accessible"?f.get("okabe-ito").bins:x(t.bins);n.bins={pass:r.pass,fail:r.fail}}if(t.values){const r=F(C(t.values,!1,!1)),g=F(C(t.values,!1,!0));r&&(n.measured=r,n.counts={light:r,dark:g??r})}const i={scheme:n,values:t.values,version:E()};return m.set(e,i),i}export const RATING_BREAKS=[0,25,50,75,100];export function ratingT(e){if(!Number.isFinite(e)||e<=RATING_BREAKS[0])return 0;if(e>=100)return 1;for(let a=1;a<RATING_BREAKS.length;a++)if(e<=RATING_BREAKS[a])return(a-1+(e-RATING_BREAKS[a-1])/(RATING_BREAKS[a]-RATING_BREAKS[a-1]))/(RATING_BREAKS.length-1);return 1}export function ratingPercentAt(e){const a=Math.min(1,Math.max(0,e))*(RATING_BREAKS.length-1),t=Math.min(RATING_BREAKS.length-2,Math.floor(a));return RATING_BREAKS[t]+(RATING_BREAKS[t+1]-RATING_BREAKS[t])*(a-t)}export const ratingColor=(e,a,t)=>rampRgb(t?a.rating.dark:a.rating.light,e),signedColor=(e,a,t)=>rampRgb(t?a.signed.dark:a.signed.light,Number.isFinite(e)?e:.5);export function countColor(e,a,t){const s=Number.isFinite(e)?Math.min(1,Math.max(0,e)):0;return rampRgb(t?a.counts.dark:a.counts.light,s>0?.15+.85*s:0)}export const measuredColor=(e,a,t=!1,s=!1)=>rampRgb(s?y:a.measured,t?1-(Number.isFinite(e)?e:0):e);const y=["#1e1e1e","#5c5c5c","#8a8a8a","#b8b8b8","#e6e6e6"],B={1:.625,2:.45,3:.25};export const SHORTFALL_ALPHA={1:.14,2:.26,3:.42},shortfallRgb=(e,a,t=!1)=>ratingColor(B[e],a,t),shortfallTint=(e,a)=>{const[t,s,n]=ratingColor(B[e],a,!1);return`rgba(${Math.round(t)}, ${Math.round(s)}, ${Math.round(n)}, ${SHORTFALL_ALPHA[e]})`},barOnWhite=e=>d(p(o("#ffffff"),o(e),.55));const H=new Set(["stackedBins","stackedSoftBins","stackedFails"]);export function valueSchemeFor(e,a={}){return e&&H.has(e)?{role:"counts",reversible:!1}:a.signed?{role:"signed",reversible:!1}:{role:"measured",reversible:!0}}export function valueColorFn(e,a,t,s,n=!1){const i=dataColorsFor(e),r=dataColorsName(e),g=f.has(r)?void 0:S(r).values;return g&&(a==="measured"||a==="counts")&&!n?C(g,t,s):a==="counts"?c=>cssRgb(countColor(c,i,s)):a==="signed"?c=>cssRgb(signedColor(c,i,s)):c=>cssRgb(measuredColor(c,i,t,n))}export const passFailFillsFor=e=>({...dataColorsFor(e).passFail});export function dataColorVars(e,a){const t=dataColorsFor(e);return{"--wmap-data-scheme":dataColorsName(e),"--wmap-data-quantity":t.quantity,"--wmap-data-shortfall-1":shortfallTint(1,t),"--wmap-data-shortfall-2":shortfallTint(2,t),"--wmap-data-shortfall-3":shortfallTint(3,t),"--wmap-data-signed-low":cssRgb(signedColor(0,t,a)),"--wmap-data-signed-high":cssRgb(signedColor(1,t,a))}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DEPRECATED_REMOVAL_VERSION="0.32.0",DEPRECATED_REMOVALS=new Map,DEPRECATED_EXPORTS=new Map;const o=new Set;export function noticeOnce(t
|
|
1
|
+
export const DEPRECATED_REMOVAL_VERSION="0.32.0",DEPRECATED_REMOVALS=new Map,DEPRECATED_EXPORTS=new Map;const o=new Set;export function noticeOnce(e,t){o.has(e)||(o.add(e),console.warn(`[wafermap] ${t}`))}export function deprecated(e,t,s,n=DEPRECATED_REMOVAL_VERSION){DEPRECATED_EXPORTS.set(t,"function"),DEPRECATED_REMOVALS.set(t,n);const r=e;return((...c)=>(noticeOnce(t,`${t} is deprecated and will be removed in ${n}. ${s} If you still need it, say so at https://github.com/wafertools/wafermap/issues.`),r(...c)))}
|
|
@@ -16,6 +16,8 @@ export declare function nameStatesUnit(name: string | null | undefined, unit: st
|
|
|
16
16
|
export declare const AGGREGATION_METHOD_LABELS: Record<string, string>;
|
|
17
17
|
/** Format an aggregation method for display, falling back to the raw key or "aggregated". */
|
|
18
18
|
export declare function fmtAggregationMethod(method: string | undefined): string;
|
|
19
|
+
/** A lot stack as the header and the Summary panel name it: "25 wafers stacked · occurrence count". */
|
|
20
|
+
export declare function fmtStackedLabel(lotSize: number, method: string | undefined): string;
|
|
19
21
|
/**
|
|
20
22
|
* Map internal bin terms to plain language for display — "HBin 2" →
|
|
21
23
|
* "hard bin 2" (CLAUDE.md: internal API terms must never appear in the UI).
|
|
@@ -43,6 +45,13 @@ export declare function fmtExact(v: number): string;
|
|
|
43
45
|
* engineering notation (E±N, multiples of 3) outside that range.
|
|
44
46
|
*/
|
|
45
47
|
export declare function fmt(v: number, unit?: string, fallbackFormat?: 'si' | 'engineering'): string;
|
|
48
|
+
/**
|
|
49
|
+
* A quantity written as people write one: thousands separators, no exponent and no prefix. For a count or a sum
|
|
50
|
+
* (orders, revenue, dies) where `fmt` would write "767E+3" and an axis would carry "(×10³)". `step`, the spacing of the
|
|
51
|
+
* ticks being labelled, fixes the decimals of a tick grid as `fmtColorbarAxis` does; without it a whole number has none
|
|
52
|
+
* and a fraction the figures `fmt` gives it.
|
|
53
|
+
*/
|
|
54
|
+
export declare function fmtPlainNumber(v: number, step?: number): string;
|
|
46
55
|
export interface AxisFormat {
|
|
47
56
|
/** A tick label: a bare number in the axis's shared scale. */
|
|
48
57
|
tickFmt: (v: number) => string;
|
|
@@ -64,4 +73,11 @@ export interface AxisFormat {
|
|
|
64
73
|
* `fmt()` as before.
|
|
65
74
|
*/
|
|
66
75
|
export declare function fmtColorbarAxis(vRef: number, name: string | null | undefined, unit: string | undefined, fallbackFormat?: 'si' | 'engineering', step?: number): AxisFormat;
|
|
76
|
+
/**
|
|
77
|
+
* One formatter for a row of one test's values (a statistics row: min, quartiles, mean, max, spread), so every cell of
|
|
78
|
+
* the row is in one unit: "1760 MHz" beside "127 MHz", never "1.76 GHz" beside "127 MHz". The unit is the one the map's
|
|
79
|
+
* colour bar gives a value of `ref`'s size (`fmtColorbarAxis`), so the table and the map name a test alike: `fmax_MHz`
|
|
80
|
+
* stays in MHz. A unitless or percentage value has no prefix to share and is formatted cell by cell, as `fmt` does.
|
|
81
|
+
*/
|
|
82
|
+
export declare function fmtRow(ref: number, unit: string | undefined, name?: string | null, fallbackFormat?: 'si' | 'engineering'): (v: number) => string;
|
|
67
83
|
//# sourceMappingURL=fmt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{stepDecimals as
|
|
1
|
+
import{stepDecimals as M}from"./axisTicks.js";const p=[[1e12,"T"],[1e9,"G"],[1e6,"M"],[1e3,"k"],[1,""],[.001,"m"],[1e-6,"\xB5"],[1e-9,"n"],[1e-12,"p"],[1e-15,"f"]];export const SI_PREFIX_SCALE={T:1e12,G:1e9,M:1e6,k:1e3,m:.001,\u00B5:1e-6,u:1e-6,n:1e-9,p:1e-12,f:1e-15},KNOWN_BASE_UNITS=["Hz","V","A","W","F","\u03A9","Ohm","ohm","S","H","J","C","s"];function b(e){for(const t of KNOWN_BASE_UNITS)if(e.length===t.length+1&&e.endsWith(t)){const n=e[0];if(n in SI_PREFIX_SCALE)return{preScale:SI_PREFIX_SCALE[n],base:t}}return{preScale:1,base:e}}export function nameStatesUnit(e,t){if(!e||!t)return!1;let n=e.trimEnd();if((n.endsWith(")")||n.endsWith("]"))&&(n=n.slice(0,-1)),!n.endsWith(t))return!1;const r=n.length===t.length?"":n[n.length-t.length-1];return r===""||/[\s_\-/([]/.test(r)}function S(e,t){const{preScale:n,base:r}=b(t),i=e*n,o=Math.abs(i),[c,f]=p.find(([s])=>o>=s*.9999)??[1e-15,"f"],d=i/c,g=Math.abs(d),u=g>=100?0:g>=10?1:2;return`${d.toFixed(u)} ${f}${r}`}function E(e){const t=Math.abs(e);if(t===0)return"0%";const n=t>=100?0:t>=10?1:t>=1?2:Math.min(6,1-Math.floor(Math.log10(t)));return`${e.toFixed(n)}%`}function N(e){const t=Math.abs(e),n=Math.floor(Math.log10(t)/3)*3,r=Math.max(-15,Math.min(12,n)),i=e/Math.pow(10,r),o=Math.abs(i),c=o>=100?0:o>=10?1:2,f=r===0?"":`E${r>0?"+":""}${r}`;return`${i.toFixed(c)}${f}`}export const AGGREGATION_METHOD_LABELS={mean:"mean",median:"median",stddev:"std dev",min:"min",max:"max",count:"count",countBin:"occurrence count",percent:"occurrence %"};export function fmtAggregationMethod(e){return AGGREGATION_METHOD_LABELS[e??""]??e??"aggregated"}export function fmtStackedLabel(e,t){return t?`${e} wafers stacked \xB7 ${fmtAggregationMethod(t)}`:`${e} wafers stacked`}export function plainBinTerms(e){return e.replace(/\bHBin\b/g,"hard bin").replace(/\bSBin\b/g,"soft bin")}export function fmtExact(e){if(!Number.isFinite(e)||Math.fround(e)!==e)return String(e);for(let t=1;t<=9;t++){const n=Number(e.toPrecision(t));if(Math.fround(n)===e)return String(n)}return String(e)}export function fmt(e,t,n){if(!isFinite(e))return String(e);if(t==="%")return E(e);const r=Math.abs(e);return r===0?t?`0 ${t}`:"0":t!==void 0?S(e,t):n==="si"?S(e,""):r>=.1&&r<1e4?r>=1e3?e.toFixed(0):r>=100?e.toFixed(1):r>=10?e.toFixed(2):e.toFixed(3):N(e)}export function fmtPlainNumber(e,t){if(!Number.isFinite(e))return String(e);const n=Math.abs(e),r=t!==void 0&&t>0?Math.min(9,M(t)):Number.isInteger(e)||n>=1e3?0:n>=100?1:n>=10?2:3;return e.toLocaleString("en-GB",{minimumFractionDigits:r,maximumFractionDigits:r})}function A(e,t){const n=t!==void 0&&t>0?M(t/e):void 0;return r=>{if(!isFinite(r))return String(r);if(r===0)return"0";const i=r/e;if(n!==void 0)return i.toFixed(n);const o=Math.abs(i),c=o>=100?0:o>=10?1:2;return i.toFixed(c)}}function T(e,t,n){if(t===void 0||!(t>0))return n;const r=M(t/e)+1;return i=>{if(!isFinite(i))return String(i);if(i===0)return"0";const o=(i/e).toFixed(r);return o.endsWith("0")?o.slice(0,r===1?-2:-1):o}}const I={"-":"\u207B",0:"\u2070",1:"\xB9",2:"\xB2",3:"\xB3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079"},F=e=>e===0?"":`\xD710${[...String(e)].map(t=>I[t]).join("")}`;export function fmtColorbarAxis(e,t,n,r="engineering",i){const o=Math.abs(e),c=(s,h,a,l)=>{const x=l&&i===void 0?l:A(s,i);return{tickFmt:x,edgeFmt:T(s,i,x),axisLabel:h,scaledUnit:a}};if(n==="%")return c(1,t?`${t} (%)`:"%","%");if(n&&nameStatesUnit(t,n)){const s=o===0||o>=.1&&o<1e4;return b(n).preScale!==1||s?c(1,t,n):fmtColorbarAxis(e,t,void 0,r,i)}if(n){const{preScale:s,base:h}=b(n),a=o*s,[l,x]=a===0?[1,""]:p.find(([$])=>a>=$*.9999)??[1e-15,"f"],m=`${x}${h}`;return c(l/s,t?`${t} (${m})`:m,m)}if(o===0||o>=.1&&o<1e4)return c(1,t??"","",s=>fmt(s,void 0,r));if(r==="si"){const[s]=p.find(([l])=>o>=l*.9999)??[1e-15,"f"],h=Math.round(Math.log10(s)),a=F(h);return c(s,t?a?`${t} (${a})`:t:a,a)}const f=Math.floor(Math.log10(o)/3)*3,d=Math.max(-15,Math.min(12,f)),g=Math.pow(10,d),u=F(d);return c(g,t?u?`${t} (${u})`:t:u,u)}export function fmtRow(e,t,n,r){const i=s=>fmt(s,t,r);if(!t||t==="%"||!Number.isFinite(e))return i;const{preScale:o,base:c}=b(t),{scaledUnit:f}=fmtColorbarAxis(e,n,t,r);if(!f.endsWith(c))return i;const d=f.slice(0,f.length-c.length),g=d===""?1:SI_PREFIX_SCALE[d];if(g===void 0)return i;const u=o/g;return s=>{if(!Number.isFinite(s))return String(s);const h=s*u,a=Math.abs(h);if(a===0)return`0 ${f}`;const l=a>=100?0:a>=10?1:a>=1?2:Math.min(6,2-Math.floor(Math.log10(a)));return`${h.toFixed(l)} ${f}`}}
|
|
@@ -4,6 +4,8 @@ export { buildWaferMap, getTestPassStatus } from './buildWaferMap.js';
|
|
|
4
4
|
export type { DerivedTestDef, DieResult, WaferConfig, DieConfig, ReticleConfig, LotStackConfig, TestDef, BinDef, MetadataFieldDef, WaferMapInputBase, WaferMapInputSingle, WaferMapInputLotStack, WaferMapInputLayout, WaferMapInput, YieldSummary, WaferWarning, WaferMapResult, } from './buildWaferMap.js';
|
|
5
5
|
export type { DieColumns } from './columnarInput.js';
|
|
6
6
|
export type { WaferMetadata, DieMetadata } from '../core/metadata.js';
|
|
7
|
+
export { registerDataColorScheme, listDataColorSchemes } from './dataColors.js';
|
|
8
|
+
export type { DataColorScheme, RoleStops } from './dataColors.js';
|
|
7
9
|
export { registerValueColorScheme, listValueColorSchemes, resolveValueColorFn, registerBinColorScheme, listBinColorSchemes } from './colorSchemes.js';
|
|
8
10
|
export type { ValueColorScheme, BinColorScheme } from './colorSchemes.js';
|
|
9
11
|
export type { BinColors, BinColorSource, MapBinColorOptions } from './binColors.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{getDieKey}from"./buildView.js";export{buildWaferMap,getTestPassStatus}from"./buildWaferMap.js";export{registerValueColorScheme,listValueColorSchemes,resolveValueColorFn,registerBinColorScheme,listBinColorSchemes}from"./colorSchemes.js";export{binColorsForMaps}from"./binColors.js";export{DERIVED_MARK,DERIVED_KEY}from"./testLabel.js";export{fmtExact}from"./fmt.js";export{checkDerivedExpression}from"./derivedTests/check.js";
|
|
1
|
+
export{getDieKey}from"./buildView.js";export{buildWaferMap,getTestPassStatus}from"./buildWaferMap.js";export{registerDataColorScheme,listDataColorSchemes}from"./dataColors.js";export{registerValueColorScheme,listValueColorSchemes,resolveValueColorFn,registerBinColorScheme,listBinColorSchemes}from"./colorSchemes.js";export{binColorsForMaps}from"./binColors.js";export{DERIVED_MARK,DERIVED_KEY}from"./testLabel.js";export{fmtExact}from"./fmt.js";export{checkDerivedExpression}from"./derivedTests/check.js";
|
|
@@ -59,6 +59,11 @@ export declare function isOutOfSpec(category: SpecCategory | null): boolean;
|
|
|
59
59
|
/** How many of `values` are out of spec: exactly the per-value
|
|
60
60
|
* {@link classifySpec} judgement, counted. Any order. */
|
|
61
61
|
export declare function countOutOfSpec(values: ArrayLike<number>, limits: SpecLimits): number;
|
|
62
|
+
/** How many of `values` lie below the low limit and above the high limit, by {@link classifySpec}. Any order. */
|
|
63
|
+
export declare function countOutOfSpecSides(values: ArrayLike<number>, limits: SpecLimits): {
|
|
64
|
+
low: number;
|
|
65
|
+
high: number;
|
|
66
|
+
};
|
|
62
67
|
/** True when `limits` can produce a verdict at all — i.e. at least one limit is
|
|
63
68
|
* defined. Used to reject `specPass[n]` at parse time rather than silently
|
|
64
69
|
* yielding no-data for every die. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function belowLow(n,e
|
|
1
|
+
export function belowLow(n,i,e){return e===!1?n<=i:n<i}export function aboveHigh(n,i,e){return e===!1?n>=i:n>i}export function classifySpec(n,i){return n===void 0||!Number.isFinite(n)||i===void 0||i.limitLow===void 0&&i.limitHigh===void 0?null:i.limitLow!==void 0&&belowLow(n,i.limitLow,i.limitLowInclusive)?"failLow":i.limitHigh!==void 0&&aboveHigh(n,i.limitHigh,i.limitHighInclusive)?"failHigh":"pass"}export function isOutOfSpec(n){return n==="failLow"||n==="failHigh"}export function countOutOfSpec(n,i){let e=0;for(let f=0;f<n.length;f++)isOutOfSpec(classifySpec(n[f],i))&&e++;return e}export function countOutOfSpecSides(n,i){let e=0,f=0;for(let t=0;t<n.length;t++){const r=classifySpec(n[t],i);r==="failLow"?e++:r==="failHigh"&&f++}return{low:e,high:f}}export function hasSpecLimits(n){return n!==void 0&&(n.limitLow!==void 0||n.limitHigh!==void 0)}
|