zrender-nightly 5.4.4-dev.20231115 → 5.4.4-dev.20231116

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/src/tool/color.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import LRU from '../core/LRU';
2
+ import { extend, isGradientObject, isString, map } from '../core/util';
3
+ import { GradientObject } from '../graphic/Gradient';
2
4
 
3
5
  const kCSSColorTable = {
4
6
  'transparent': [0, 0, 0, 0], 'aliceblue': [240, 248, 255, 1],
@@ -566,4 +568,28 @@ export function random(): string {
566
568
  Math.round(Math.random() * 255),
567
569
  Math.round(Math.random() * 255)
568
570
  ], 'rgb');
569
- }
571
+ }
572
+
573
+ const liftedColorCache = new LRU<string>(100);
574
+ export function liftColor(color: GradientObject): GradientObject;
575
+ export function liftColor(color: string): string;
576
+ export function liftColor(color: string | GradientObject): string | GradientObject {
577
+ if (isString(color)) {
578
+ let liftedColor = liftedColorCache.get(color);
579
+ if (!liftedColor) {
580
+ liftedColor = lift(color, -0.1);
581
+ liftedColorCache.put(color, liftedColor);
582
+ }
583
+ return liftedColor;
584
+ }
585
+ else if (isGradientObject(color)) {
586
+ const ret = extend({}, color) as GradientObject;
587
+ ret.colorStops = map(color.colorStops, stop => ({
588
+ offset: stop.offset,
589
+ color: lift(stop.color, -0.1)
590
+ }));
591
+ return ret;
592
+ }
593
+ // Change nothing.
594
+ return color;
595
+ }
package/src/zrender.ts CHANGED
@@ -482,10 +482,27 @@ export function registerPainter(name: string, Ctor: PainterBaseCtor) {
482
482
  painterCtors[name] = Ctor;
483
483
  }
484
484
 
485
+ export type ElementSSRData = zrUtil.HashMap<unknown>;
486
+ export type ElementSSRDataGetter<T> = (el: Element) => zrUtil.HashMap<T>;
487
+
488
+ let ssrDataGetter = function (el: Element): ElementSSRData {
489
+ return null;
490
+ }
491
+
492
+ export function getElementSSRData(el: Element): ElementSSRData {
493
+ if (typeof ssrDataGetter === 'function') {
494
+ return ssrDataGetter(el);
495
+ }
496
+ }
497
+
498
+ export function registerSSRDataGetter<T>(getter: ElementSSRDataGetter<T>) {
499
+ ssrDataGetter = getter;
500
+ }
501
+
485
502
  /**
486
503
  * @type {string}
487
504
  */
488
- export const version = '5.4.4-dev.20231115';
505
+ export const version = '5.4.4-dev.20231116';
489
506
 
490
507
 
491
508
  export interface ZRenderType extends ZRender {};