• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ringcentral / ringcentral-js-widgets / 21017357600

15 Jan 2026 02:19AM UTC coverage: 61.994% (-1.1%) from 63.06%
21017357600

push

github

web-flow
misc: sync features and bugfixes from 8f9fbb5dfe (#1784)

* misc: sync crius

* chore: update babel-setting deps

* feat(core): update logger and add fromWatch

* misc: fix tsconfig

* misc: fix tsconfig

* misc: update eslint-settings and new eslint-plugin-crius package

* chore: remove ci and nx from package.json

* feat(i18n): new getAcceptLocaleMap and preudo string support

* chore: add preudo i18n

* misc(locale-loader): convert to ts, new format support

* misc(locale-settings): use ts

* chore: add format test in phone number lib

* feat(react-hooks): add more hooks

* chore: add comments

* misc: add more mock files

* misc: update test utils

* misc: update utils

* chore: update tsconfig

* misc: update i18n string, and convert to ts

* feat: update ui components, support emoji input, new video setting ui

* feat: new rcvideo v2 module

* feat: use new subscription register api

* misc(commons): update enums/interfaces

* misc: update Analytics lib

* misc: upgrade uuid and update import

* misc(commons): update formatDuration lib

* misc(test): add test steps

* chore: update tests and more feature tests

* misc: update demo project

* misc: update cli template

* misc: fix deps issue

* misc: remove glip widgets package

* misc: fix wrong import path

* misc: limit jest worker memory

* chore: use npm trusted-publishers

10285 of 18150 branches covered (56.67%)

Branch coverage included in aggregate %.

986 of 2186 new or added lines in 228 files covered. (45.11%)

44 existing lines in 23 files now uncovered.

17404 of 26514 relevant lines covered (65.64%)

167640.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.23
/packages/utils/src/utils/getImagePositionColor.ts
1
import memoize from 'lodash/memoize';
2

3
import { loadImage } from './loadImage';
4
import { rgbToHex } from './rgbToHex';
5

6
/**
7
 * get image position color by url
8
 * @param url image url
9
 * @param position that color of position of the image in relative of `300x300`, by default is `left-center(0, 150)` of the image
10
 * @returns color hex
11
 *
12
 * ### Remember the url should be same origin or allow fetch the source image
13
 */
14
export const getImagePositionColor = async (
305✔
15
  url: string,
16
  position?: { x: number; y: number },
17
) => {
18
  try {
2✔
19
    const img = await loadImage(url);
2✔
20

21
    const canvas = document.createElement('canvas');
2✔
22
    const ctx = canvas.getContext('2d')!;
1✔
23

24
    canvas.width = 300;
1✔
25
    canvas.height = 300;
1✔
26

27
    ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
1✔
28

29
    const p = ctx.getImageData(
1✔
30
      position?.x ?? 0,
1!
31
      position?.y ?? 150, // canvas.height / 2,
1!
32
      1,
33
      1,
34
    ).data;
35
    const hex = rgbToHex(p[0], p[1], p[2]);
1✔
36

37
    canvas.remove();
1✔
38
    img.remove();
1✔
39
    return hex;
1✔
40
  } catch (error) {
41
    return '#FFF';
1✔
42
  }
43
};
44

45
/**
46
 * same as `getImagePositionColor` but with cache based on url and position in one day
47
 */
48
export const getImagePositionColorWithCache = memoize(
305✔
49
  getImagePositionColor,
50
  (url, position) =>
NEW
51
    `${url}_${position?.x ?? 0}_${position?.y ?? 150}_${
×
52
      new Date().toISOString().split('T')[0]
53
    }`,
54
);
55

56
/**
57
 * clear cache of `getImagePositionColorWithCache`
58
 */
59
export const clearImagePositionColorCache = () => {
305✔
NEW
60
  getImagePositionColorWithCache.cache.clear?.();
×
61
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc