vim-web 0.5.0-dev.6 → 0.5.0-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vim-web.js CHANGED
@@ -58368,33 +58368,41 @@ class ColorManager {
58368
58368
  }
58369
58369
  /**
58370
58370
  * Creates or retrieves cached color instances for multiple hex values.
58371
- * @param c - Array of RGBA32 color values
58371
+ * @param colors - Array of color values or undefined for no color
58372
58372
  * @returns Promise resolving to an array of ColorHandles in the same order as input, or undefined if creation fails
58373
58373
  * @remarks Duplicate hex values will be mapped to the same color instance for efficiency
58374
58374
  */
58375
- async getColors(c) {
58376
- const result = new Array(c.length);
58375
+ async getColors(colors) {
58376
+ const result = new Array(colors.length);
58377
58377
  const hexToIndices = /* @__PURE__ */ new Map();
58378
58378
  const toCreate = [];
58379
- for (let i = 0; i < c.length; i++) {
58380
- const color = c[i];
58381
- const hex = color.getHex();
58382
- if (this._hexToColor.has(hex)) {
58383
- result[i] = this._hexToColor.get(hex);
58384
- } else if (hexToIndices.has(hex)) {
58379
+ for (let i = 0; i < colors.length; i++) {
58380
+ const color = colors[i];
58381
+ if (color === void 0) {
58382
+ result[i] = void 0;
58383
+ continue;
58384
+ }
58385
+ const hex = (color == null ? void 0 : color.getHex()) ?? -1;
58386
+ const remoteColor = this._hexToColor.get(hex);
58387
+ if (remoteColor) {
58388
+ result[i] = remoteColor;
58389
+ continue;
58390
+ }
58391
+ const indices = hexToIndices.get(hex);
58392
+ if (indices) {
58385
58393
  hexToIndices.get(hex).push(i);
58386
- } else {
58387
- toCreate.push(color);
58388
- hexToIndices.set(hex, [i]);
58394
+ continue;
58389
58395
  }
58396
+ toCreate.push(color);
58397
+ hexToIndices.set(hex, [i]);
58390
58398
  }
58391
- const colors = await this._createColors(toCreate);
58392
- if (!colors) return void 0;
58393
- for (let i = 0; i < colors.length; i++) {
58399
+ const remoteColors = await this._createColors(toCreate);
58400
+ if (!remoteColors) return void 0;
58401
+ for (let i = 0; i < remoteColors.length; i++) {
58394
58402
  const color = toCreate[i];
58395
58403
  const indices = hexToIndices.get(color.getHex());
58396
58404
  for (const index2 of indices) {
58397
- result[index2] = colors[i];
58405
+ result[index2] = remoteColors[i];
58398
58406
  }
58399
58407
  }
58400
58408
  return result;
@@ -60877,6 +60885,7 @@ class Vim2 {
60877
60885
  // default state
60878
60886
  );
60879
60887
  }
60888
+ //TODO: Rename this to getElementFromNode, prefer using element instead
60880
60889
  getElement(elementIndex) {
60881
60890
  if (this._objects.has(elementIndex)) {
60882
60891
  return this._objects.get(elementIndex);
@@ -60889,7 +60898,7 @@ class Vim2 {
60889
60898
  throw new Error("Method not implemented.");
60890
60899
  }
60891
60900
  getElementFromIndex(element) {
60892
- throw new Error("Method not implemented.");
60901
+ return this.getElement(element);
60893
60902
  }
60894
60903
  getObjectsInBox(box) {
60895
60904
  throw new Error("Method not implemented.");
@@ -61017,22 +61026,22 @@ class Vim2 {
61017
61026
  const colors = new Array(elementIndex.length).fill(color);
61018
61027
  this.applyColor(elementIndex, colors);
61019
61028
  }
61020
- async setColors(nodes, color) {
61021
- if (color.length !== nodes.length) {
61022
- throw new Error("Color and nodes length must be equal");
61029
+ async setColors(elements, color) {
61030
+ if (color.length !== elements.length) {
61031
+ throw new Error("Color and elements length must be equal");
61023
61032
  }
61024
- this.applyColor(nodes, color);
61033
+ this.applyColor(elements, color);
61025
61034
  }
61026
- applyColor(nodes, color) {
61035
+ applyColor(elements, color) {
61027
61036
  for (let i = 0; i < color.length; i++) {
61028
61037
  const c = color[i];
61029
- const n = nodes[i];
61038
+ const element = elements[i];
61030
61039
  if (c === void 0) {
61031
- this._elementColors.delete(n);
61040
+ this._elementColors.delete(element);
61032
61041
  } else {
61033
- this._elementColors.set(n, c);
61042
+ this._elementColors.set(element, c);
61034
61043
  }
61035
- this._updatedColors.add(n);
61044
+ this._updatedColors.add(element);
61036
61045
  }
61037
61046
  this.scheduleColorUpdate();
61038
61047
  }
@@ -61068,11 +61077,11 @@ class Vim2 {
61068
61077
  this._renderer.notifySceneUpdated();
61069
61078
  }
61070
61079
  async updateRemoteColors() {
61071
- const nodes = Array.from(this._updatedColors);
61072
- const colors = nodes.map((n) => this._elementColors.get(n));
61080
+ const elements = Array.from(this._updatedColors);
61081
+ const colors = elements.map((n) => this._elementColors.get(n));
61073
61082
  const remoteColors = await this._colors.getColors(colors);
61074
61083
  const colorIds = remoteColors.map((c) => (c == null ? void 0 : c.id) ?? -1);
61075
- this._rpc.RPCSetMaterialOverridesForElements(this._handle, nodes, colorIds);
61084
+ this._rpc.RPCSetMaterialOverridesForElements(this._handle, elements, colorIds);
61076
61085
  this._updatedColors.clear();
61077
61086
  }
61078
61087
  }
@@ -76268,6 +76277,7 @@ function createAdapter(viewer) {
76268
76277
  obj.state = VisibilityState.HIGHLIGHTED;
76269
76278
  });
76270
76279
  },
76280
+ // TODO: Change this api to use elements
76271
76281
  isolate: (instances) => {
76272
76282
  hide("all");
76273
76283
  viewer.selection.getAll().forEach((obj) => {