@ni/nimble-components 32.7.1 → 32.8.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.
@@ -20337,7 +20337,42 @@ so this becomes the fallback color for the slot */ ''}
20337
20337
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleCardButton());
20338
20338
 
20339
20339
  const styles$M = css `
20340
+ .error-icon {
20341
+ display: none;
20342
+ }
20343
+
20344
+ :host([error-visible]) .error-icon {
20345
+ display: inline-flex;
20346
+ width: ${iconSize};
20347
+ height: ${iconSize};
20348
+ flex: none;
20349
+ }
20350
+
20351
+ .error-text {
20352
+ display: none;
20353
+ }
20354
+
20355
+ :host([error-visible]) .error-text {
20356
+ display: block;
20357
+ font: ${errorTextFont};
20358
+ color: ${failColor};
20359
+ width: 100%;
20360
+ position: absolute;
20361
+ bottom: calc(-1 * (${errorTextFontLineHeight} + 2px));
20362
+ left: 0px;
20363
+ overflow: hidden;
20364
+ text-overflow: ellipsis;
20365
+ white-space: nowrap;
20366
+ }
20367
+
20368
+ :host([error-visible]) .error-text:empty {
20369
+ display: none;
20370
+ }
20371
+ `;
20372
+
20373
+ const styles$L = css `
20340
20374
  ${display('inline-flex')}
20375
+ ${styles$M}
20341
20376
 
20342
20377
  :host {
20343
20378
  font: ${bodyFont};
@@ -20345,16 +20380,25 @@ so this becomes the fallback color for the slot */ ''}
20345
20380
  cursor: pointer;
20346
20381
  outline: none;
20347
20382
  ${userSelectNone}
20383
+ min-height: ${controlHeight};
20348
20384
  }
20349
20385
 
20350
20386
  :host([disabled]) {
20351
20387
  cursor: default;
20352
20388
  }
20353
20389
 
20390
+ .container {
20391
+ position: relative;
20392
+ display: grid;
20393
+ grid-template-columns: auto 1fr auto;
20394
+ grid-template-rows: ${bodyFontLineHeight} auto;
20395
+ align-items: center;
20396
+ width: 100%;
20397
+ }
20398
+
20354
20399
  .control {
20355
- width: calc(${controlHeight} / 2);
20356
- height: calc(${controlHeight} / 2);
20357
- flex-shrink: 0;
20400
+ width: ${iconSize};
20401
+ height: ${iconSize};
20358
20402
  border: ${borderWidth} solid ${borderColor};
20359
20403
  padding: 2px;
20360
20404
  display: inline-flex;
@@ -20367,6 +20411,8 @@ so this becomes the fallback color for the slot */ ''}
20367
20411
  * Set it to 0 to ensure the outline is just as high as the control.
20368
20412
  */ ''}
20369
20413
  line-height: 0;
20414
+ grid-column: 1;
20415
+ grid-row: 1;
20370
20416
  }
20371
20417
 
20372
20418
  @media (prefers-reduced-motion) {
@@ -20394,7 +20440,9 @@ so this becomes the fallback color for the slot */ ''}
20394
20440
  .label {
20395
20441
  font: inherit;
20396
20442
  color: ${bodyFontColor};
20397
- padding-left: 1ch;
20443
+ padding-left: ${mediumPadding};
20444
+ grid-column: 2;
20445
+ grid-row: 1 / span 2;
20398
20446
  cursor: inherit;
20399
20447
  }
20400
20448
 
@@ -20411,16 +20459,13 @@ so this becomes the fallback color for the slot */ ''}
20411
20459
  height: ${iconSize};
20412
20460
  width: ${iconSize};
20413
20461
  overflow: visible;
20462
+ fill: ${borderColor};
20414
20463
  }
20415
20464
 
20416
20465
  :host(.checked:not(.indeterminate)) slot[name='checked-indicator'] {
20417
20466
  display: contents;
20418
20467
  }
20419
20468
 
20420
- slot[name='checked-indicator'] svg {
20421
- fill: ${borderColor};
20422
- }
20423
-
20424
20469
  :host([disabled]) slot[name='checked-indicator'] svg {
20425
20470
  fill: rgba(${borderRgbPartialColor}, 0.3);
20426
20471
  }
@@ -20442,6 +20487,18 @@ so this becomes the fallback color for the slot */ ''}
20442
20487
  :host([disabled]) slot[name='indeterminate-indicator'] svg {
20443
20488
  fill: rgba(${borderRgbPartialColor}, 0.3);
20444
20489
  }
20490
+
20491
+ .error-icon {
20492
+ grid-column: 3;
20493
+ grid-row: 1;
20494
+ margin: 0px ${smallPadding};
20495
+ }
20496
+ `;
20497
+
20498
+ const errorTextTemplate = html `
20499
+ <div class="error-text" title="${x => x.errorText}" aria-live="polite">
20500
+ ${x => x.errorText}
20501
+ </div>
20445
20502
  `;
20446
20503
 
20447
20504
  const template$B = (_context, definition) => html `
@@ -20456,22 +20513,29 @@ so this becomes the fallback color for the slot */ ''}
20456
20513
  @click="${(x, c) => x.clickHandler(c.event)}"
20457
20514
  class="${x => (x.readOnly ? 'readonly' : '')} ${x => (x.checked ? 'checked' : '')} ${x => (x.indeterminate ? 'indeterminate' : '')}"
20458
20515
  >
20459
- <div part="control" class="control">
20460
- <slot name="checked-indicator">
20461
- ${definition.checkedIndicator || ''}
20462
- </slot>
20463
- <slot name="indeterminate-indicator">
20464
- ${definition.indeterminateIndicator || ''}
20465
- </slot>
20466
- </div>
20467
- <label
20468
- part="label"
20469
- class="${x => (x.defaultSlottedNodes?.length
20516
+ <div part="container" class="container">
20517
+ <div part="control" class="control">
20518
+ <slot name="checked-indicator">
20519
+ ${definition.checkedIndicator || ''}
20520
+ </slot>
20521
+ <slot name="indeterminate-indicator">
20522
+ ${definition.indeterminateIndicator || ''}
20523
+ </slot>
20524
+ </div>
20525
+ <label
20526
+ part="label"
20527
+ class="${x => (x.defaultSlottedNodes?.length
20470
20528
  ? 'label'
20471
20529
  : 'label label__hidden')}"
20472
- >
20473
- <slot ${slotted('defaultSlottedNodes')}></slot>
20474
- </label>
20530
+ >
20531
+ <slot ${slotted('defaultSlottedNodes')}></slot>
20532
+ </label>
20533
+ <${iconExclamationMarkTag}
20534
+ severity="error"
20535
+ class="error-icon"
20536
+ ></${iconExclamationMarkTag}>
20537
+ ${errorTextTemplate}
20538
+ </div>
20475
20539
  </template>
20476
20540
  `;
20477
20541
 
@@ -20479,6 +20543,10 @@ so this becomes the fallback color for the slot */ ''}
20479
20543
  * A nimble-styled checkbox control.
20480
20544
  */
20481
20545
  class Checkbox extends Checkbox$1 {
20546
+ constructor() {
20547
+ super(...arguments);
20548
+ this.errorVisible = false;
20549
+ }
20482
20550
  /**
20483
20551
  * @internal
20484
20552
  */
@@ -20490,18 +20558,24 @@ so this becomes the fallback color for the slot */ ''}
20490
20558
  __decorate$1([
20491
20559
  attr({ attribute: 'tabindex', converter: nullableNumberConverter })
20492
20560
  ], Checkbox.prototype, "tabIndex", void 0);
20561
+ __decorate$1([
20562
+ attr({ attribute: 'error-text' })
20563
+ ], Checkbox.prototype, "errorText", void 0);
20564
+ __decorate$1([
20565
+ attr({ attribute: 'error-visible', mode: 'boolean' })
20566
+ ], Checkbox.prototype, "errorVisible", void 0);
20493
20567
  const nimbleCheckbox = Checkbox.compose({
20494
20568
  baseName: 'checkbox',
20495
20569
  baseClass: Checkbox$1,
20496
20570
  template: template$B,
20497
- styles: styles$M,
20571
+ styles: styles$L,
20498
20572
  checkedIndicator: check16X16.data,
20499
20573
  indeterminateIndicator: minus16X16.data
20500
20574
  });
20501
20575
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleCheckbox());
20502
20576
  const checkboxTag = 'nimble-checkbox';
20503
20577
 
20504
- const styles$L = css `
20578
+ const styles$K = css `
20505
20579
  ${styles$_}
20506
20580
  ${buttonAppearanceVariantStyles}
20507
20581
 
@@ -20648,7 +20722,7 @@ so this becomes the fallback color for the slot */ ''}
20648
20722
  const nimbleToggleButton = ToggleButton.compose({
20649
20723
  baseName: 'toggle-button',
20650
20724
  template: template$A,
20651
- styles: styles$L,
20725
+ styles: styles$K,
20652
20726
  shadowOptions: {
20653
20727
  delegatesFocus: true
20654
20728
  }
@@ -20656,12 +20730,6 @@ so this becomes the fallback color for the slot */ ''}
20656
20730
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleToggleButton());
20657
20731
  const toggleButtonTag = 'nimble-toggle-button';
20658
20732
 
20659
- const errorTextTemplate = html `
20660
- <div class="error-text" title="${x => x.errorText}" aria-live="polite">
20661
- ${x => x.errorText}
20662
- </div>
20663
- `;
20664
-
20665
20733
  // AUTO-GENERATED FILE - DO NOT EDIT DIRECTLY
20666
20734
  // See generation source in nimble-components/build/generate-icons
20667
20735
  /**
@@ -20686,7 +20754,7 @@ so this becomes the fallback color for the slot */ ''}
20686
20754
  };
20687
20755
 
20688
20756
  // prettier-ignore
20689
- const styles$K = css `
20757
+ const styles$J = css `
20690
20758
  ${display('inline-flex')}
20691
20759
 
20692
20760
  :host {
@@ -20955,40 +21023,6 @@ so this becomes the fallback color for the slot */ ''}
20955
21023
  }
20956
21024
  `));
20957
21025
 
20958
- const styles$J = css `
20959
- .error-icon {
20960
- display: none;
20961
- }
20962
-
20963
- :host([error-visible]) .error-icon {
20964
- display: inline-flex;
20965
- width: ${iconSize};
20966
- height: ${iconSize};
20967
- flex: none;
20968
- }
20969
-
20970
- .error-text {
20971
- display: none;
20972
- }
20973
-
20974
- :host([error-visible]) .error-text {
20975
- display: block;
20976
- font: ${errorTextFont};
20977
- color: ${failColor};
20978
- width: 100%;
20979
- position: absolute;
20980
- bottom: calc(-1 * (${errorTextFontLineHeight} + 2px));
20981
- left: 0px;
20982
- overflow: hidden;
20983
- text-overflow: ellipsis;
20984
- white-space: nowrap;
20985
- }
20986
-
20987
- :host([error-visible]) .error-text:empty {
20988
- display: none;
20989
- }
20990
- `;
20991
-
20992
21026
  /**
20993
21027
  * Types of dropdown appearance.
20994
21028
  * @public
@@ -21004,8 +21038,8 @@ so this becomes the fallback color for the slot */ ''}
21004
21038
  };
21005
21039
 
21006
21040
  const styles$I = css `
21007
- ${styles$K}
21008
21041
  ${styles$J}
21042
+ ${styles$M}
21009
21043
 
21010
21044
  :host {
21011
21045
  --ni-private-hover-bottom-border-width: 2px;
@@ -26514,7 +26548,7 @@ so this becomes the fallback color for the slot */ ''}
26514
26548
 
26515
26549
  const styles$y = css `
26516
26550
  ${display('inline-block')}
26517
- ${styles$J}
26551
+ ${styles$M}
26518
26552
 
26519
26553
  :host {
26520
26554
  font: ${bodyFont};
@@ -26888,7 +26922,7 @@ so this becomes the fallback color for the slot */ ''}
26888
26922
 
26889
26923
  const styles$w = css `
26890
26924
  ${display('inline-block')}
26891
- ${styles$J}
26925
+ ${styles$M}
26892
26926
 
26893
26927
  .positioning-region {
26894
26928
  display: flex;
@@ -45155,7 +45189,7 @@ img.ProseMirror-separator {
45155
45189
  }).withDefault(richTextLabelDefaults.richTextToggleNumberedListLabel);
45156
45190
 
45157
45191
  const styles$u = css `
45158
- ${styles$K}
45192
+ ${styles$J}
45159
45193
 
45160
45194
  :host {
45161
45195
  height: auto;
@@ -45576,7 +45610,7 @@ img.ProseMirror-separator {
45576
45610
 
45577
45611
  const styles$t = css `
45578
45612
  ${display('inline-flex')}
45579
- ${styles$J}
45613
+ ${styles$M}
45580
45614
 
45581
45615
  :host {
45582
45616
  font: ${bodyFont};
@@ -60340,8 +60374,8 @@ img.ProseMirror-separator {
60340
60374
  .register(nimbleRichTextViewer());
60341
60375
 
60342
60376
  const styles$r = css `
60343
- ${styles$K}
60344
60377
  ${styles$J}
60378
+ ${styles$M}
60345
60379
 
60346
60380
  ${
60347
60381
  /* We are using flex `order` to define the visual ordering of the selected value,
@@ -66091,6 +66125,7 @@ focus outline in that case.
66091
66125
 
66092
66126
  .header-row-action-container {
66093
66127
  display: flex;
66128
+ align-items: center;
66094
66129
  }
66095
66130
 
66096
66131
  .checkbox-container {
@@ -74172,7 +74207,7 @@ focus outline in that case.
74172
74207
 
74173
74208
  const styles$6 = css `
74174
74209
  ${display('inline-flex')}
74175
- ${styles$J}
74210
+ ${styles$M}
74176
74211
 
74177
74212
  :host {
74178
74213
  font: ${bodyFont};
@@ -74517,7 +74552,7 @@ focus outline in that case.
74517
74552
 
74518
74553
  const styles$5 = css `
74519
74554
  ${display('inline-block')}
74520
- ${styles$J}
74555
+ ${styles$M}
74521
74556
 
74522
74557
  :host {
74523
74558
  font: ${bodyFont};
@@ -83716,7 +83751,7 @@ focus outline in that case.
83716
83751
  constructor(parent, rowIndex) {
83717
83752
  this[kParent] = parent;
83718
83753
  this[kRowIndex] = rowIndex;
83719
- return new Proxy(this, new StructRowProxyHandler());
83754
+ return new Proxy(this, structRowProxyHandler);
83720
83755
  }
83721
83756
  toArray() { return Object.values(this.toJSON()); }
83722
83757
  toJSON() {
@@ -83776,10 +83811,10 @@ focus outline in that case.
83776
83811
  return row[kParent].type.children.map((f) => f.name);
83777
83812
  }
83778
83813
  has(row, key) {
83779
- return row[kParent].type.children.findIndex((f) => f.name === key) !== -1;
83814
+ return row[kParent].type.children.some((f) => f.name === key);
83780
83815
  }
83781
83816
  getOwnPropertyDescriptor(row, key) {
83782
- if (row[kParent].type.children.findIndex((f) => f.name === key) !== -1) {
83817
+ if (row[kParent].type.children.some((f) => f.name === key)) {
83783
83818
  return { writable: true, enumerable: true, configurable: true };
83784
83819
  }
83785
83820
  return;
@@ -83810,6 +83845,7 @@ focus outline in that case.
83810
83845
  return false;
83811
83846
  }
83812
83847
  }
83848
+ const structRowProxyHandler = new StructRowProxyHandler();
83813
83849
 
83814
83850
  // Licensed to the Apache Software Foundation (ASF) under one
83815
83851
  // or more contributor license agreements. See the NOTICE file
@@ -85731,7 +85767,7 @@ focus outline in that case.
85731
85767
  this.fields = (fields || []);
85732
85768
  this.metadata = metadata || new Map();
85733
85769
  if (!dictionaries) {
85734
- dictionaries = generateDictionaryMap(fields);
85770
+ dictionaries = generateDictionaryMap(this.fields);
85735
85771
  }
85736
85772
  this.dictionaries = dictionaries;
85737
85773
  this.metadataVersion = metadataVersion;
@@ -89128,13 +89164,10 @@ focus outline in that case.
89128
89164
  const { id, isDelta } = header;
89129
89165
  const { dictionaries, schema } = this;
89130
89166
  const dictionary = dictionaries.get(id);
89131
- if (isDelta || !dictionary) {
89132
- const type = schema.dictionaries.get(id);
89133
- const data = this._loadVectors(header.data, body, [type]);
89134
- return (dictionary && isDelta ? dictionary.concat(new Vector(data)) :
89135
- new Vector(data)).memoize();
89136
- }
89137
- return dictionary.memoize();
89167
+ const type = schema.dictionaries.get(id);
89168
+ const data = this._loadVectors(header.data, body, [type]);
89169
+ return (dictionary && isDelta ? dictionary.concat(new Vector(data)) :
89170
+ new Vector(data)).memoize();
89138
89171
  }
89139
89172
  _loadVectors(header, body, types) {
89140
89173
  return new VectorLoader(body, header.nodes, header.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(types);
@@ -91513,7 +91546,24 @@ focus outline in that case.
91513
91546
  endpoint.close();
91514
91547
  }
91515
91548
  function wrap(ep, target) {
91516
- return createProxy(ep, [], target);
91549
+ const pendingListeners = new Map();
91550
+ ep.addEventListener("message", function handleMessage(ev) {
91551
+ const { data } = ev;
91552
+ if (!data || !data.id) {
91553
+ return;
91554
+ }
91555
+ const resolver = pendingListeners.get(data.id);
91556
+ if (!resolver) {
91557
+ return;
91558
+ }
91559
+ try {
91560
+ resolver(data);
91561
+ }
91562
+ finally {
91563
+ pendingListeners.delete(data.id);
91564
+ }
91565
+ });
91566
+ return createProxy(ep, pendingListeners, [], target);
91517
91567
  }
91518
91568
  function throwIfProxyReleased(isReleased) {
91519
91569
  if (isReleased) {
@@ -91521,7 +91571,7 @@ focus outline in that case.
91521
91571
  }
91522
91572
  }
91523
91573
  function releaseEndpoint(ep) {
91524
- return requestResponseMessage(ep, {
91574
+ return requestResponseMessage(ep, new Map(), {
91525
91575
  type: "RELEASE" /* MessageType.RELEASE */,
91526
91576
  }).then(() => {
91527
91577
  closeEndPoint(ep);
@@ -91548,7 +91598,7 @@ focus outline in that case.
91548
91598
  proxyFinalizers.unregister(proxy);
91549
91599
  }
91550
91600
  }
91551
- function createProxy(ep, path = [], target = function () { }) {
91601
+ function createProxy(ep, pendingListeners, path = [], target = function () { }) {
91552
91602
  let isProxyReleased = false;
91553
91603
  const proxy = new Proxy(target, {
91554
91604
  get(_target, prop) {
@@ -91557,6 +91607,7 @@ focus outline in that case.
91557
91607
  return () => {
91558
91608
  unregisterProxy(proxy);
91559
91609
  releaseEndpoint(ep);
91610
+ pendingListeners.clear();
91560
91611
  isProxyReleased = true;
91561
91612
  };
91562
91613
  }
@@ -91564,20 +91615,20 @@ focus outline in that case.
91564
91615
  if (path.length === 0) {
91565
91616
  return { then: () => proxy };
91566
91617
  }
91567
- const r = requestResponseMessage(ep, {
91618
+ const r = requestResponseMessage(ep, pendingListeners, {
91568
91619
  type: "GET" /* MessageType.GET */,
91569
91620
  path: path.map((p) => p.toString()),
91570
91621
  }).then(fromWireValue);
91571
91622
  return r.then.bind(r);
91572
91623
  }
91573
- return createProxy(ep, [...path, prop]);
91624
+ return createProxy(ep, pendingListeners, [...path, prop]);
91574
91625
  },
91575
91626
  set(_target, prop, rawValue) {
91576
91627
  throwIfProxyReleased(isProxyReleased);
91577
91628
  // FIXME: ES6 Proxy Handler `set` methods are supposed to return a
91578
91629
  // boolean. To show good will, we return true asynchronously ¯\_(ツ)_/¯
91579
91630
  const [value, transferables] = toWireValue(rawValue);
91580
- return requestResponseMessage(ep, {
91631
+ return requestResponseMessage(ep, pendingListeners, {
91581
91632
  type: "SET" /* MessageType.SET */,
91582
91633
  path: [...path, prop].map((p) => p.toString()),
91583
91634
  value,
@@ -91587,16 +91638,16 @@ focus outline in that case.
91587
91638
  throwIfProxyReleased(isProxyReleased);
91588
91639
  const last = path[path.length - 1];
91589
91640
  if (last === createEndpoint) {
91590
- return requestResponseMessage(ep, {
91641
+ return requestResponseMessage(ep, pendingListeners, {
91591
91642
  type: "ENDPOINT" /* MessageType.ENDPOINT */,
91592
91643
  }).then(fromWireValue);
91593
91644
  }
91594
91645
  // We just pretend that `bind()` didn’t happen.
91595
91646
  if (last === "bind") {
91596
- return createProxy(ep, path.slice(0, -1));
91647
+ return createProxy(ep, pendingListeners, path.slice(0, -1));
91597
91648
  }
91598
91649
  const [argumentList, transferables] = processArguments(rawArgumentList);
91599
- return requestResponseMessage(ep, {
91650
+ return requestResponseMessage(ep, pendingListeners, {
91600
91651
  type: "APPLY" /* MessageType.APPLY */,
91601
91652
  path: path.map((p) => p.toString()),
91602
91653
  argumentList,
@@ -91605,7 +91656,7 @@ focus outline in that case.
91605
91656
  construct(_target, rawArgumentList) {
91606
91657
  throwIfProxyReleased(isProxyReleased);
91607
91658
  const [argumentList, transferables] = processArguments(rawArgumentList);
91608
- return requestResponseMessage(ep, {
91659
+ return requestResponseMessage(ep, pendingListeners, {
91609
91660
  type: "CONSTRUCT" /* MessageType.CONSTRUCT */,
91610
91661
  path: path.map((p) => p.toString()),
91611
91662
  argumentList,
@@ -91660,16 +91711,10 @@ focus outline in that case.
91660
91711
  return value.value;
91661
91712
  }
91662
91713
  }
91663
- function requestResponseMessage(ep, msg, transfers) {
91714
+ function requestResponseMessage(ep, pendingListeners, msg, transfers) {
91664
91715
  return new Promise((resolve) => {
91665
91716
  const id = generateUUID();
91666
- ep.addEventListener("message", function l(ev) {
91667
- if (!ev.data || !ev.data.id || ev.data.id !== id) {
91668
- return;
91669
- }
91670
- ep.removeEventListener("message", l);
91671
- resolve(ev.data);
91672
- });
91717
+ pendingListeners.set(id, resolve);
91673
91718
  if (ep.start) {
91674
91719
  ep.start();
91675
91720
  }
@@ -91683,7 +91728,7 @@ focus outline in that case.
91683
91728
  .join("-");
91684
91729
  }
91685
91730
 
91686
- const workerCode = "var MatrixRenderer = (function (exports) {\n 'use strict';\n\n /**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n const proxyMarker = Symbol(\"Comlink.proxy\");\n const createEndpoint = Symbol(\"Comlink.endpoint\");\n const releaseProxy = Symbol(\"Comlink.releaseProxy\");\n const finalizer = Symbol(\"Comlink.finalizer\");\n const throwMarker = Symbol(\"Comlink.thrown\");\n const isObject = (val) => (typeof val === \"object\" && val !== null) || typeof val === \"function\";\n /**\n * Internal transfer handle to handle objects marked to proxy.\n */\n const proxyTransferHandler = {\n canHandle: (val) => isObject(val) && val[proxyMarker],\n serialize(obj) {\n const { port1, port2 } = new MessageChannel();\n expose(obj, port1);\n return [port2, [port2]];\n },\n deserialize(port) {\n port.start();\n return wrap(port);\n },\n };\n /**\n * Internal transfer handler to handle thrown exceptions.\n */\n const throwTransferHandler = {\n canHandle: (value) => isObject(value) && throwMarker in value,\n serialize({ value }) {\n let serialized;\n if (value instanceof Error) {\n serialized = {\n isError: true,\n value: {\n message: value.message,\n name: value.name,\n stack: value.stack,\n },\n };\n }\n else {\n serialized = { isError: false, value };\n }\n return [serialized, []];\n },\n deserialize(serialized) {\n if (serialized.isError) {\n throw Object.assign(new Error(serialized.value.message), serialized.value);\n }\n throw serialized.value;\n },\n };\n /**\n * Allows customizing the serialization of certain values.\n */\n const transferHandlers = new Map([\n [\"proxy\", proxyTransferHandler],\n [\"throw\", throwTransferHandler],\n ]);\n function isAllowedOrigin(allowedOrigins, origin) {\n for (const allowedOrigin of allowedOrigins) {\n if (origin === allowedOrigin || allowedOrigin === \"*\") {\n return true;\n }\n if (allowedOrigin instanceof RegExp && allowedOrigin.test(origin)) {\n return true;\n }\n }\n return false;\n }\n function expose(obj, ep = globalThis, allowedOrigins = [\"*\"]) {\n ep.addEventListener(\"message\", function callback(ev) {\n if (!ev || !ev.data) {\n return;\n }\n if (!isAllowedOrigin(allowedOrigins, ev.origin)) {\n console.warn(`Invalid origin '${ev.origin}' for comlink proxy`);\n return;\n }\n const { id, type, path } = Object.assign({ path: [] }, ev.data);\n const argumentList = (ev.data.argumentList || []).map(fromWireValue);\n let returnValue;\n try {\n const parent = path.slice(0, -1).reduce((obj, prop) => obj[prop], obj);\n const rawValue = path.reduce((obj, prop) => obj[prop], obj);\n switch (type) {\n case \"GET\" /* MessageType.GET */:\n {\n returnValue = rawValue;\n }\n break;\n case \"SET\" /* MessageType.SET */:\n {\n parent[path.slice(-1)[0]] = fromWireValue(ev.data.value);\n returnValue = true;\n }\n break;\n case \"APPLY\" /* MessageType.APPLY */:\n {\n returnValue = rawValue.apply(parent, argumentList);\n }\n break;\n case \"CONSTRUCT\" /* MessageType.CONSTRUCT */:\n {\n const value = new rawValue(...argumentList);\n returnValue = proxy(value);\n }\n break;\n case \"ENDPOINT\" /* MessageType.ENDPOINT */:\n {\n const { port1, port2 } = new MessageChannel();\n expose(obj, port2);\n returnValue = transfer(port1, [port1]);\n }\n break;\n case \"RELEASE\" /* MessageType.RELEASE */:\n {\n returnValue = undefined;\n }\n break;\n default:\n return;\n }\n }\n catch (value) {\n returnValue = { value, [throwMarker]: 0 };\n }\n Promise.resolve(returnValue)\n .catch((value) => {\n return { value, [throwMarker]: 0 };\n })\n .then((returnValue) => {\n const [wireValue, transferables] = toWireValue(returnValue);\n ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);\n if (type === \"RELEASE\" /* MessageType.RELEASE */) {\n // detach and deactive after sending release response above.\n ep.removeEventListener(\"message\", callback);\n closeEndPoint(ep);\n if (finalizer in obj && typeof obj[finalizer] === \"function\") {\n obj[finalizer]();\n }\n }\n })\n .catch((error) => {\n // Send Serialization Error To Caller\n const [wireValue, transferables] = toWireValue({\n value: new TypeError(\"Unserializable return value\"),\n [throwMarker]: 0,\n });\n ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);\n });\n });\n if (ep.start) {\n ep.start();\n }\n }\n function isMessagePort(endpoint) {\n return endpoint.constructor.name === \"MessagePort\";\n }\n function closeEndPoint(endpoint) {\n if (isMessagePort(endpoint))\n endpoint.close();\n }\n function wrap(ep, target) {\n return createProxy(ep, [], target);\n }\n function throwIfProxyReleased(isReleased) {\n if (isReleased) {\n throw new Error(\"Proxy has been released and is not useable\");\n }\n }\n function releaseEndpoint(ep) {\n return requestResponseMessage(ep, {\n type: \"RELEASE\" /* MessageType.RELEASE */,\n }).then(() => {\n closeEndPoint(ep);\n });\n }\n const proxyCounter = new WeakMap();\n const proxyFinalizers = \"FinalizationRegistry\" in globalThis &&\n new FinalizationRegistry((ep) => {\n const newCount = (proxyCounter.get(ep) || 0) - 1;\n proxyCounter.set(ep, newCount);\n if (newCount === 0) {\n releaseEndpoint(ep);\n }\n });\n function registerProxy(proxy, ep) {\n const newCount = (proxyCounter.get(ep) || 0) + 1;\n proxyCounter.set(ep, newCount);\n if (proxyFinalizers) {\n proxyFinalizers.register(proxy, ep, proxy);\n }\n }\n function unregisterProxy(proxy) {\n if (proxyFinalizers) {\n proxyFinalizers.unregister(proxy);\n }\n }\n function createProxy(ep, path = [], target = function () { }) {\n let isProxyReleased = false;\n const proxy = new Proxy(target, {\n get(_target, prop) {\n throwIfProxyReleased(isProxyReleased);\n if (prop === releaseProxy) {\n return () => {\n unregisterProxy(proxy);\n releaseEndpoint(ep);\n isProxyReleased = true;\n };\n }\n if (prop === \"then\") {\n if (path.length === 0) {\n return { then: () => proxy };\n }\n const r = requestResponseMessage(ep, {\n type: \"GET\" /* MessageType.GET */,\n path: path.map((p) => p.toString()),\n }).then(fromWireValue);\n return r.then.bind(r);\n }\n return createProxy(ep, [...path, prop]);\n },\n set(_target, prop, rawValue) {\n throwIfProxyReleased(isProxyReleased);\n // FIXME: ES6 Proxy Handler `set` methods are supposed to return a\n // boolean. To show good will, we return true asynchronously ¯\\_(ツ)_/¯\n const [value, transferables] = toWireValue(rawValue);\n return requestResponseMessage(ep, {\n type: \"SET\" /* MessageType.SET */,\n path: [...path, prop].map((p) => p.toString()),\n value,\n }, transferables).then(fromWireValue);\n },\n apply(_target, _thisArg, rawArgumentList) {\n throwIfProxyReleased(isProxyReleased);\n const last = path[path.length - 1];\n if (last === createEndpoint) {\n return requestResponseMessage(ep, {\n type: \"ENDPOINT\" /* MessageType.ENDPOINT */,\n }).then(fromWireValue);\n }\n // We just pretend that `bind()` didn’t happen.\n if (last === \"bind\") {\n return createProxy(ep, path.slice(0, -1));\n }\n const [argumentList, transferables] = processArguments(rawArgumentList);\n return requestResponseMessage(ep, {\n type: \"APPLY\" /* MessageType.APPLY */,\n path: path.map((p) => p.toString()),\n argumentList,\n }, transferables).then(fromWireValue);\n },\n construct(_target, rawArgumentList) {\n throwIfProxyReleased(isProxyReleased);\n const [argumentList, transferables] = processArguments(rawArgumentList);\n return requestResponseMessage(ep, {\n type: \"CONSTRUCT\" /* MessageType.CONSTRUCT */,\n path: path.map((p) => p.toString()),\n argumentList,\n }, transferables).then(fromWireValue);\n },\n });\n registerProxy(proxy, ep);\n return proxy;\n }\n function myFlat(arr) {\n return Array.prototype.concat.apply([], arr);\n }\n function processArguments(argumentList) {\n const processed = argumentList.map(toWireValue);\n return [processed.map((v) => v[0]), myFlat(processed.map((v) => v[1]))];\n }\n const transferCache = new WeakMap();\n function transfer(obj, transfers) {\n transferCache.set(obj, transfers);\n return obj;\n }\n function proxy(obj) {\n return Object.assign(obj, { [proxyMarker]: true });\n }\n function toWireValue(value) {\n for (const [name, handler] of transferHandlers) {\n if (handler.canHandle(value)) {\n const [serializedValue, transferables] = handler.serialize(value);\n return [\n {\n type: \"HANDLER\" /* WireValueType.HANDLER */,\n name,\n value: serializedValue,\n },\n transferables,\n ];\n }\n }\n return [\n {\n type: \"RAW\" /* WireValueType.RAW */,\n value,\n },\n transferCache.get(value) || [],\n ];\n }\n function fromWireValue(value) {\n switch (value.type) {\n case \"HANDLER\" /* WireValueType.HANDLER */:\n return transferHandlers.get(value.name).deserialize(value.value);\n case \"RAW\" /* WireValueType.RAW */:\n return value.value;\n }\n }\n function requestResponseMessage(ep, msg, transfers) {\n return new Promise((resolve) => {\n const id = generateUUID();\n ep.addEventListener(\"message\", function l(ev) {\n if (!ev.data || !ev.data.id || ev.data.id !== id) {\n return;\n }\n ep.removeEventListener(\"message\", l);\n resolve(ev.data);\n });\n if (ep.start) {\n ep.start();\n }\n ep.postMessage(Object.assign({ id }, msg), transfers);\n });\n }\n function generateUUID() {\n return new Array(4)\n .fill(0)\n .map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16))\n .join(\"-\");\n }\n\n /**\n * MatrixRenderer class is meant to be used within a Web Worker context,\n * using Comlink to facilitate communication between the main thread and the worker.\n * The MatrixRenderer class manages a matrix of dies, once an instance of MatrixRenderer is created,\n * it is exposed to the main thread using Comlink's `expose` method.\n * This setup is used in the wafer-map component to perform heavy computational duties\n */\n class MatrixRenderer {\n constructor() {\n this.values = Float64Array.from([]);\n this.scaledColumnIndices = Float64Array.from([]);\n this.scaledRowIndices = Float64Array.from([]);\n this.columnIndicesPositions = Int32Array.from([]);\n this.colorIndices = Int32Array.from([]);\n this.colors = [];\n this.colorValues = Float64Array.from([]);\n this.outsideRangeDieColor = 'rgba(218,223,236,1)';\n this.fontSizeFactor = 0.8;\n this.renderConfig = {\n dieDimensions: {\n width: 0,\n height: 0\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n verticalCoefficient: 1,\n horizontalCoefficient: 1,\n horizontalConstant: 0,\n verticalConstant: 0,\n gridMinX: 0,\n gridMaxX: 0,\n gridMinY: 0,\n gridMaxY: 0,\n labelsFontSize: 0,\n colorScale: [],\n dieLabelsSuffix: '',\n maxCharacters: 0\n };\n this.transformConfig = {\n transform: {\n k: 1,\n x: 0,\n y: 0\n },\n topLeftCanvasCorner: {\n x: 0,\n y: 0\n },\n bottomRightCanvasCorner: {\n x: 0,\n y: 0\n }\n };\n }\n setMatrixData(columnIndices, rowIndices, valuesBuffer) {\n const scaledColumnIndex = [];\n const columnPositions = [];\n const scaledRowIndices = [];\n const values = [];\n const colorIndices = [];\n let prevXIndex;\n let dieCount = 0;\n for (let i = 0; i < columnIndices.length; i++) {\n const xIndex = columnIndices[i];\n const yIndex = rowIndices[i];\n if (this.isDieInGrid(xIndex, yIndex)) {\n if (xIndex !== prevXIndex) {\n scaledColumnIndex.push(this.calculateHorizontalScaledIndices(xIndex));\n columnPositions.push(dieCount);\n prevXIndex = xIndex;\n }\n scaledRowIndices.push(this.calculateVerticalScaledIndices(yIndex));\n const value = valuesBuffer[i];\n values.push(value);\n colorIndices.push(this.findColorIndex(value));\n dieCount += 1;\n }\n }\n this.scaledColumnIndices = Float64Array.from(scaledColumnIndex);\n this.columnIndicesPositions = Int32Array.from(columnPositions);\n this.scaledRowIndices = Float64Array.from(scaledRowIndices);\n this.values = Float64Array.from(values);\n this.colorIndices = Int32Array.from(colorIndices);\n }\n setRenderConfig(renderConfig) {\n this.renderConfig = renderConfig;\n this.colors = renderConfig.colorScale.map(marker => marker.color);\n this.colorValues = Float64Array.from(renderConfig.colorScale.map(marker => marker.value));\n }\n setTransformConfig(transformData) {\n this.transformConfig = transformData;\n }\n setCanvas(canvas) {\n this.canvas = canvas;\n this.context = canvas.getContext('2d');\n }\n scaleCanvas() {\n this.context.translate(this.transformConfig.transform.x, this.transformConfig.transform.y);\n this.context.scale(this.transformConfig.transform.k, this.transformConfig.transform.k);\n }\n setCanvasDimensions(data) {\n this.canvas.width = data.width;\n this.canvas.height = data.height;\n }\n getCanvasDimensions() {\n return {\n width: this.canvas.width,\n height: this.canvas.height\n };\n }\n clearCanvas() {\n this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);\n }\n drawWafer() {\n this.context.restore();\n this.context.save();\n this.clearCanvas();\n this.scaleCanvas();\n for (let i = 0; i < this.scaledColumnIndices.length; i++) {\n const scaledX = this.scaledColumnIndices[i];\n if (!(scaledX >= this.transformConfig.topLeftCanvasCorner.x\n && scaledX < this.transformConfig.bottomRightCanvasCorner.x)) {\n continue;\n }\n // columnIndexPositions is used to get chunks to determine the start and end index of the column, it looks something like [0, 1, 4, 9, 12]\n // This means that the first column has a start index of 0 and an end index of 1, the second column has a start index of 1 and an end index of 4, and so on\n // scaledRowIndices is used when we reach the end of the columnIndexPositions, when columnIndexPositions is [0, 1, 4, 9, 12], scaledRowIndices is 13\n const columnEndIndex = this.columnIndicesPositions[i + 1] !== undefined\n ? this.columnIndicesPositions[i + 1]\n : this.scaledRowIndices.length;\n for (let columnStartIndex = this.columnIndicesPositions[i]; columnStartIndex < columnEndIndex; columnStartIndex++) {\n const scaledY = this.scaledRowIndices[columnStartIndex];\n if (!(scaledY >= this.transformConfig.topLeftCanvasCorner.y\n && scaledY < this.transformConfig.bottomRightCanvasCorner.y)) {\n continue;\n }\n // Fill style is temporary green for all dies, will be replaced with a color based on the value of the die in a future implementation\n this.context.fillStyle = this.colors[this.colorIndices[columnStartIndex]]\n ?? this.outsideRangeDieColor;\n this.context.fillRect(scaledX, scaledY, this.renderConfig.dieDimensions.width, this.renderConfig.dieDimensions.height);\n }\n }\n }\n drawText() {\n this.context.font = `${this.renderConfig.labelsFontSize.toString()}px sans-serif`;\n this.context.fillStyle = '#ffffff';\n this.context.textAlign = 'center';\n this.context.lineCap = 'butt';\n const approximateTextHeight = this.context.measureText('M');\n for (let i = 0; i < this.scaledColumnIndices.length; i++) {\n const scaledX = this.scaledColumnIndices[i];\n if (!(scaledX >= this.transformConfig.topLeftCanvasCorner.x\n && scaledX < this.transformConfig.bottomRightCanvasCorner.x)) {\n continue;\n }\n // columnIndexPositions is used to get chunks to determine the start and end index of the column, it looks something like [0, 1, 4, 9, 12]\n // This means that the first column has a start index of 0 and an end index of 1, the second column has a start index of 1 and an end index of 4, and so on\n // scaledRowIndices is used when we reach the end of the columnIndexPositions, when columnIndexPositions is [0, 1, 4, 9, 12], scaledRowIndices is 13\n const columnEndIndex = this.columnIndicesPositions[i + 1] !== undefined\n ? this.columnIndicesPositions[i + 1]\n : this.scaledRowIndices.length;\n for (let columnStartIndex = this.columnIndicesPositions[i]; columnStartIndex < columnEndIndex; columnStartIndex++) {\n const scaledY = this.scaledRowIndices[columnStartIndex];\n if (!(scaledY >= this.transformConfig.topLeftCanvasCorner.y\n && scaledY < this.transformConfig.bottomRightCanvasCorner.y)) {\n continue;\n }\n let label = `${this.values[columnStartIndex] || 'NaN'}${this.renderConfig.dieLabelsSuffix}`;\n if (label.length >= this.renderConfig.maxCharacters) {\n label = `${label.substring(0, this.renderConfig.maxCharacters)}…`;\n }\n this.context.fillText(label, scaledX + this.renderConfig.dieDimensions.width / 2, scaledY\n + this.renderConfig.dieDimensions.height / 2\n + approximateTextHeight.width / 2, this.renderConfig.dieDimensions.width * this.fontSizeFactor);\n }\n }\n }\n isDieInGrid(x, y) {\n return (x >= this.renderConfig.gridMinX\n && x <= this.renderConfig.gridMaxX\n && y >= this.renderConfig.gridMinY\n && y <= this.renderConfig.gridMaxY);\n }\n calculateHorizontalScaledIndices(columnIndex) {\n return (this.renderConfig.horizontalCoefficient * columnIndex\n + this.renderConfig.horizontalConstant\n + this.renderConfig.margin.left);\n }\n calculateVerticalScaledIndices(rowIndex) {\n return (this.renderConfig.verticalCoefficient * rowIndex\n + this.renderConfig.verticalConstant\n + this.renderConfig.margin.top);\n }\n findColorIndex(value) {\n let index = -1;\n if (this.colorValues.length === 0 || this.colorValues[0] >= value) {\n return index;\n }\n for (let i = 0; i < this.colorValues.length; i++) {\n if (value <= this.colorValues[i]) {\n index = i;\n break;\n }\n }\n return index;\n }\n }\n expose(MatrixRenderer);\n\n exports.MatrixRenderer = MatrixRenderer;\n\n return exports;\n\n})({});\n";
91731
+ const workerCode = "var MatrixRenderer = (function (exports) {\n 'use strict';\n\n /**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n const proxyMarker = Symbol(\"Comlink.proxy\");\n const createEndpoint = Symbol(\"Comlink.endpoint\");\n const releaseProxy = Symbol(\"Comlink.releaseProxy\");\n const finalizer = Symbol(\"Comlink.finalizer\");\n const throwMarker = Symbol(\"Comlink.thrown\");\n const isObject = (val) => (typeof val === \"object\" && val !== null) || typeof val === \"function\";\n /**\n * Internal transfer handle to handle objects marked to proxy.\n */\n const proxyTransferHandler = {\n canHandle: (val) => isObject(val) && val[proxyMarker],\n serialize(obj) {\n const { port1, port2 } = new MessageChannel();\n expose(obj, port1);\n return [port2, [port2]];\n },\n deserialize(port) {\n port.start();\n return wrap(port);\n },\n };\n /**\n * Internal transfer handler to handle thrown exceptions.\n */\n const throwTransferHandler = {\n canHandle: (value) => isObject(value) && throwMarker in value,\n serialize({ value }) {\n let serialized;\n if (value instanceof Error) {\n serialized = {\n isError: true,\n value: {\n message: value.message,\n name: value.name,\n stack: value.stack,\n },\n };\n }\n else {\n serialized = { isError: false, value };\n }\n return [serialized, []];\n },\n deserialize(serialized) {\n if (serialized.isError) {\n throw Object.assign(new Error(serialized.value.message), serialized.value);\n }\n throw serialized.value;\n },\n };\n /**\n * Allows customizing the serialization of certain values.\n */\n const transferHandlers = new Map([\n [\"proxy\", proxyTransferHandler],\n [\"throw\", throwTransferHandler],\n ]);\n function isAllowedOrigin(allowedOrigins, origin) {\n for (const allowedOrigin of allowedOrigins) {\n if (origin === allowedOrigin || allowedOrigin === \"*\") {\n return true;\n }\n if (allowedOrigin instanceof RegExp && allowedOrigin.test(origin)) {\n return true;\n }\n }\n return false;\n }\n function expose(obj, ep = globalThis, allowedOrigins = [\"*\"]) {\n ep.addEventListener(\"message\", function callback(ev) {\n if (!ev || !ev.data) {\n return;\n }\n if (!isAllowedOrigin(allowedOrigins, ev.origin)) {\n console.warn(`Invalid origin '${ev.origin}' for comlink proxy`);\n return;\n }\n const { id, type, path } = Object.assign({ path: [] }, ev.data);\n const argumentList = (ev.data.argumentList || []).map(fromWireValue);\n let returnValue;\n try {\n const parent = path.slice(0, -1).reduce((obj, prop) => obj[prop], obj);\n const rawValue = path.reduce((obj, prop) => obj[prop], obj);\n switch (type) {\n case \"GET\" /* MessageType.GET */:\n {\n returnValue = rawValue;\n }\n break;\n case \"SET\" /* MessageType.SET */:\n {\n parent[path.slice(-1)[0]] = fromWireValue(ev.data.value);\n returnValue = true;\n }\n break;\n case \"APPLY\" /* MessageType.APPLY */:\n {\n returnValue = rawValue.apply(parent, argumentList);\n }\n break;\n case \"CONSTRUCT\" /* MessageType.CONSTRUCT */:\n {\n const value = new rawValue(...argumentList);\n returnValue = proxy(value);\n }\n break;\n case \"ENDPOINT\" /* MessageType.ENDPOINT */:\n {\n const { port1, port2 } = new MessageChannel();\n expose(obj, port2);\n returnValue = transfer(port1, [port1]);\n }\n break;\n case \"RELEASE\" /* MessageType.RELEASE */:\n {\n returnValue = undefined;\n }\n break;\n default:\n return;\n }\n }\n catch (value) {\n returnValue = { value, [throwMarker]: 0 };\n }\n Promise.resolve(returnValue)\n .catch((value) => {\n return { value, [throwMarker]: 0 };\n })\n .then((returnValue) => {\n const [wireValue, transferables] = toWireValue(returnValue);\n ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);\n if (type === \"RELEASE\" /* MessageType.RELEASE */) {\n // detach and deactive after sending release response above.\n ep.removeEventListener(\"message\", callback);\n closeEndPoint(ep);\n if (finalizer in obj && typeof obj[finalizer] === \"function\") {\n obj[finalizer]();\n }\n }\n })\n .catch((error) => {\n // Send Serialization Error To Caller\n const [wireValue, transferables] = toWireValue({\n value: new TypeError(\"Unserializable return value\"),\n [throwMarker]: 0,\n });\n ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);\n });\n });\n if (ep.start) {\n ep.start();\n }\n }\n function isMessagePort(endpoint) {\n return endpoint.constructor.name === \"MessagePort\";\n }\n function closeEndPoint(endpoint) {\n if (isMessagePort(endpoint))\n endpoint.close();\n }\n function wrap(ep, target) {\n const pendingListeners = new Map();\n ep.addEventListener(\"message\", function handleMessage(ev) {\n const { data } = ev;\n if (!data || !data.id) {\n return;\n }\n const resolver = pendingListeners.get(data.id);\n if (!resolver) {\n return;\n }\n try {\n resolver(data);\n }\n finally {\n pendingListeners.delete(data.id);\n }\n });\n return createProxy(ep, pendingListeners, [], target);\n }\n function throwIfProxyReleased(isReleased) {\n if (isReleased) {\n throw new Error(\"Proxy has been released and is not useable\");\n }\n }\n function releaseEndpoint(ep) {\n return requestResponseMessage(ep, new Map(), {\n type: \"RELEASE\" /* MessageType.RELEASE */,\n }).then(() => {\n closeEndPoint(ep);\n });\n }\n const proxyCounter = new WeakMap();\n const proxyFinalizers = \"FinalizationRegistry\" in globalThis &&\n new FinalizationRegistry((ep) => {\n const newCount = (proxyCounter.get(ep) || 0) - 1;\n proxyCounter.set(ep, newCount);\n if (newCount === 0) {\n releaseEndpoint(ep);\n }\n });\n function registerProxy(proxy, ep) {\n const newCount = (proxyCounter.get(ep) || 0) + 1;\n proxyCounter.set(ep, newCount);\n if (proxyFinalizers) {\n proxyFinalizers.register(proxy, ep, proxy);\n }\n }\n function unregisterProxy(proxy) {\n if (proxyFinalizers) {\n proxyFinalizers.unregister(proxy);\n }\n }\n function createProxy(ep, pendingListeners, path = [], target = function () { }) {\n let isProxyReleased = false;\n const proxy = new Proxy(target, {\n get(_target, prop) {\n throwIfProxyReleased(isProxyReleased);\n if (prop === releaseProxy) {\n return () => {\n unregisterProxy(proxy);\n releaseEndpoint(ep);\n pendingListeners.clear();\n isProxyReleased = true;\n };\n }\n if (prop === \"then\") {\n if (path.length === 0) {\n return { then: () => proxy };\n }\n const r = requestResponseMessage(ep, pendingListeners, {\n type: \"GET\" /* MessageType.GET */,\n path: path.map((p) => p.toString()),\n }).then(fromWireValue);\n return r.then.bind(r);\n }\n return createProxy(ep, pendingListeners, [...path, prop]);\n },\n set(_target, prop, rawValue) {\n throwIfProxyReleased(isProxyReleased);\n // FIXME: ES6 Proxy Handler `set` methods are supposed to return a\n // boolean. To show good will, we return true asynchronously ¯\\_(ツ)_/¯\n const [value, transferables] = toWireValue(rawValue);\n return requestResponseMessage(ep, pendingListeners, {\n type: \"SET\" /* MessageType.SET */,\n path: [...path, prop].map((p) => p.toString()),\n value,\n }, transferables).then(fromWireValue);\n },\n apply(_target, _thisArg, rawArgumentList) {\n throwIfProxyReleased(isProxyReleased);\n const last = path[path.length - 1];\n if (last === createEndpoint) {\n return requestResponseMessage(ep, pendingListeners, {\n type: \"ENDPOINT\" /* MessageType.ENDPOINT */,\n }).then(fromWireValue);\n }\n // We just pretend that `bind()` didn’t happen.\n if (last === \"bind\") {\n return createProxy(ep, pendingListeners, path.slice(0, -1));\n }\n const [argumentList, transferables] = processArguments(rawArgumentList);\n return requestResponseMessage(ep, pendingListeners, {\n type: \"APPLY\" /* MessageType.APPLY */,\n path: path.map((p) => p.toString()),\n argumentList,\n }, transferables).then(fromWireValue);\n },\n construct(_target, rawArgumentList) {\n throwIfProxyReleased(isProxyReleased);\n const [argumentList, transferables] = processArguments(rawArgumentList);\n return requestResponseMessage(ep, pendingListeners, {\n type: \"CONSTRUCT\" /* MessageType.CONSTRUCT */,\n path: path.map((p) => p.toString()),\n argumentList,\n }, transferables).then(fromWireValue);\n },\n });\n registerProxy(proxy, ep);\n return proxy;\n }\n function myFlat(arr) {\n return Array.prototype.concat.apply([], arr);\n }\n function processArguments(argumentList) {\n const processed = argumentList.map(toWireValue);\n return [processed.map((v) => v[0]), myFlat(processed.map((v) => v[1]))];\n }\n const transferCache = new WeakMap();\n function transfer(obj, transfers) {\n transferCache.set(obj, transfers);\n return obj;\n }\n function proxy(obj) {\n return Object.assign(obj, { [proxyMarker]: true });\n }\n function toWireValue(value) {\n for (const [name, handler] of transferHandlers) {\n if (handler.canHandle(value)) {\n const [serializedValue, transferables] = handler.serialize(value);\n return [\n {\n type: \"HANDLER\" /* WireValueType.HANDLER */,\n name,\n value: serializedValue,\n },\n transferables,\n ];\n }\n }\n return [\n {\n type: \"RAW\" /* WireValueType.RAW */,\n value,\n },\n transferCache.get(value) || [],\n ];\n }\n function fromWireValue(value) {\n switch (value.type) {\n case \"HANDLER\" /* WireValueType.HANDLER */:\n return transferHandlers.get(value.name).deserialize(value.value);\n case \"RAW\" /* WireValueType.RAW */:\n return value.value;\n }\n }\n function requestResponseMessage(ep, pendingListeners, msg, transfers) {\n return new Promise((resolve) => {\n const id = generateUUID();\n pendingListeners.set(id, resolve);\n if (ep.start) {\n ep.start();\n }\n ep.postMessage(Object.assign({ id }, msg), transfers);\n });\n }\n function generateUUID() {\n return new Array(4)\n .fill(0)\n .map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16))\n .join(\"-\");\n }\n\n /**\n * MatrixRenderer class is meant to be used within a Web Worker context,\n * using Comlink to facilitate communication between the main thread and the worker.\n * The MatrixRenderer class manages a matrix of dies, once an instance of MatrixRenderer is created,\n * it is exposed to the main thread using Comlink's `expose` method.\n * This setup is used in the wafer-map component to perform heavy computational duties\n */\n class MatrixRenderer {\n constructor() {\n this.values = Float64Array.from([]);\n this.scaledColumnIndices = Float64Array.from([]);\n this.scaledRowIndices = Float64Array.from([]);\n this.columnIndicesPositions = Int32Array.from([]);\n this.colorIndices = Int32Array.from([]);\n this.colors = [];\n this.colorValues = Float64Array.from([]);\n this.outsideRangeDieColor = 'rgba(218,223,236,1)';\n this.fontSizeFactor = 0.8;\n this.renderConfig = {\n dieDimensions: {\n width: 0,\n height: 0\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n verticalCoefficient: 1,\n horizontalCoefficient: 1,\n horizontalConstant: 0,\n verticalConstant: 0,\n gridMinX: 0,\n gridMaxX: 0,\n gridMinY: 0,\n gridMaxY: 0,\n labelsFontSize: 0,\n colorScale: [],\n dieLabelsSuffix: '',\n maxCharacters: 0\n };\n this.transformConfig = {\n transform: {\n k: 1,\n x: 0,\n y: 0\n },\n topLeftCanvasCorner: {\n x: 0,\n y: 0\n },\n bottomRightCanvasCorner: {\n x: 0,\n y: 0\n }\n };\n }\n setMatrixData(columnIndices, rowIndices, valuesBuffer) {\n const scaledColumnIndex = [];\n const columnPositions = [];\n const scaledRowIndices = [];\n const values = [];\n const colorIndices = [];\n let prevXIndex;\n let dieCount = 0;\n for (let i = 0; i < columnIndices.length; i++) {\n const xIndex = columnIndices[i];\n const yIndex = rowIndices[i];\n if (this.isDieInGrid(xIndex, yIndex)) {\n if (xIndex !== prevXIndex) {\n scaledColumnIndex.push(this.calculateHorizontalScaledIndices(xIndex));\n columnPositions.push(dieCount);\n prevXIndex = xIndex;\n }\n scaledRowIndices.push(this.calculateVerticalScaledIndices(yIndex));\n const value = valuesBuffer[i];\n values.push(value);\n colorIndices.push(this.findColorIndex(value));\n dieCount += 1;\n }\n }\n this.scaledColumnIndices = Float64Array.from(scaledColumnIndex);\n this.columnIndicesPositions = Int32Array.from(columnPositions);\n this.scaledRowIndices = Float64Array.from(scaledRowIndices);\n this.values = Float64Array.from(values);\n this.colorIndices = Int32Array.from(colorIndices);\n }\n setRenderConfig(renderConfig) {\n this.renderConfig = renderConfig;\n this.colors = renderConfig.colorScale.map(marker => marker.color);\n this.colorValues = Float64Array.from(renderConfig.colorScale.map(marker => marker.value));\n }\n setTransformConfig(transformData) {\n this.transformConfig = transformData;\n }\n setCanvas(canvas) {\n this.canvas = canvas;\n this.context = canvas.getContext('2d');\n }\n scaleCanvas() {\n this.context.translate(this.transformConfig.transform.x, this.transformConfig.transform.y);\n this.context.scale(this.transformConfig.transform.k, this.transformConfig.transform.k);\n }\n setCanvasDimensions(data) {\n this.canvas.width = data.width;\n this.canvas.height = data.height;\n }\n getCanvasDimensions() {\n return {\n width: this.canvas.width,\n height: this.canvas.height\n };\n }\n clearCanvas() {\n this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);\n }\n drawWafer() {\n this.context.restore();\n this.context.save();\n this.clearCanvas();\n this.scaleCanvas();\n for (let i = 0; i < this.scaledColumnIndices.length; i++) {\n const scaledX = this.scaledColumnIndices[i];\n if (!(scaledX >= this.transformConfig.topLeftCanvasCorner.x\n && scaledX < this.transformConfig.bottomRightCanvasCorner.x)) {\n continue;\n }\n // columnIndexPositions is used to get chunks to determine the start and end index of the column, it looks something like [0, 1, 4, 9, 12]\n // This means that the first column has a start index of 0 and an end index of 1, the second column has a start index of 1 and an end index of 4, and so on\n // scaledRowIndices is used when we reach the end of the columnIndexPositions, when columnIndexPositions is [0, 1, 4, 9, 12], scaledRowIndices is 13\n const columnEndIndex = this.columnIndicesPositions[i + 1] !== undefined\n ? this.columnIndicesPositions[i + 1]\n : this.scaledRowIndices.length;\n for (let columnStartIndex = this.columnIndicesPositions[i]; columnStartIndex < columnEndIndex; columnStartIndex++) {\n const scaledY = this.scaledRowIndices[columnStartIndex];\n if (!(scaledY >= this.transformConfig.topLeftCanvasCorner.y\n && scaledY < this.transformConfig.bottomRightCanvasCorner.y)) {\n continue;\n }\n // Fill style is temporary green for all dies, will be replaced with a color based on the value of the die in a future implementation\n this.context.fillStyle = this.colors[this.colorIndices[columnStartIndex]]\n ?? this.outsideRangeDieColor;\n this.context.fillRect(scaledX, scaledY, this.renderConfig.dieDimensions.width, this.renderConfig.dieDimensions.height);\n }\n }\n }\n drawText() {\n this.context.font = `${this.renderConfig.labelsFontSize.toString()}px sans-serif`;\n this.context.fillStyle = '#ffffff';\n this.context.textAlign = 'center';\n this.context.lineCap = 'butt';\n const approximateTextHeight = this.context.measureText('M');\n for (let i = 0; i < this.scaledColumnIndices.length; i++) {\n const scaledX = this.scaledColumnIndices[i];\n if (!(scaledX >= this.transformConfig.topLeftCanvasCorner.x\n && scaledX < this.transformConfig.bottomRightCanvasCorner.x)) {\n continue;\n }\n // columnIndexPositions is used to get chunks to determine the start and end index of the column, it looks something like [0, 1, 4, 9, 12]\n // This means that the first column has a start index of 0 and an end index of 1, the second column has a start index of 1 and an end index of 4, and so on\n // scaledRowIndices is used when we reach the end of the columnIndexPositions, when columnIndexPositions is [0, 1, 4, 9, 12], scaledRowIndices is 13\n const columnEndIndex = this.columnIndicesPositions[i + 1] !== undefined\n ? this.columnIndicesPositions[i + 1]\n : this.scaledRowIndices.length;\n for (let columnStartIndex = this.columnIndicesPositions[i]; columnStartIndex < columnEndIndex; columnStartIndex++) {\n const scaledY = this.scaledRowIndices[columnStartIndex];\n if (!(scaledY >= this.transformConfig.topLeftCanvasCorner.y\n && scaledY < this.transformConfig.bottomRightCanvasCorner.y)) {\n continue;\n }\n let label = `${this.values[columnStartIndex] || 'NaN'}${this.renderConfig.dieLabelsSuffix}`;\n if (label.length >= this.renderConfig.maxCharacters) {\n label = `${label.substring(0, this.renderConfig.maxCharacters)}…`;\n }\n this.context.fillText(label, scaledX + this.renderConfig.dieDimensions.width / 2, scaledY\n + this.renderConfig.dieDimensions.height / 2\n + approximateTextHeight.width / 2, this.renderConfig.dieDimensions.width * this.fontSizeFactor);\n }\n }\n }\n isDieInGrid(x, y) {\n return (x >= this.renderConfig.gridMinX\n && x <= this.renderConfig.gridMaxX\n && y >= this.renderConfig.gridMinY\n && y <= this.renderConfig.gridMaxY);\n }\n calculateHorizontalScaledIndices(columnIndex) {\n return (this.renderConfig.horizontalCoefficient * columnIndex\n + this.renderConfig.horizontalConstant\n + this.renderConfig.margin.left);\n }\n calculateVerticalScaledIndices(rowIndex) {\n return (this.renderConfig.verticalCoefficient * rowIndex\n + this.renderConfig.verticalConstant\n + this.renderConfig.margin.top);\n }\n findColorIndex(value) {\n let index = -1;\n if (this.colorValues.length === 0 || this.colorValues[0] >= value) {\n return index;\n }\n for (let i = 0; i < this.colorValues.length; i++) {\n if (value <= this.colorValues[i]) {\n index = i;\n break;\n }\n }\n return index;\n }\n }\n expose(MatrixRenderer);\n\n exports.MatrixRenderer = MatrixRenderer;\n\n return exports;\n\n})({});\n";
91687
91732
 
91688
91733
  let url;
91689
91734
  /**