@visactor/vrender-core 0.17.8-alpha.0 → 0.17.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.
Files changed (49) hide show
  1. package/cjs/core/graphic-utils.d.ts +2 -1
  2. package/cjs/core/graphic-utils.js +29 -1
  3. package/cjs/core/graphic-utils.js.map +1 -1
  4. package/cjs/env-check.d.ts +2 -2
  5. package/cjs/env-check.js +19 -2
  6. package/cjs/env-check.js.map +1 -1
  7. package/cjs/graphic/rect.d.ts +1 -1
  8. package/cjs/graphic/rect.js +7 -2
  9. package/cjs/graphic/rect.js.map +1 -1
  10. package/cjs/graphic/text.d.ts +1 -0
  11. package/cjs/graphic/text.js +7 -4
  12. package/cjs/graphic/text.js.map +1 -1
  13. package/cjs/interface/core.d.ts +2 -1
  14. package/cjs/interface/core.js.map +1 -1
  15. package/cjs/modules.d.ts +1 -0
  16. package/cjs/modules.js +11 -5
  17. package/cjs/modules.js.map +1 -1
  18. package/cjs/picker/pick-modules.js +3 -2
  19. package/cjs/picker/pick-modules.js.map +1 -1
  20. package/cjs/render/contributions/render/area-render.js +2 -2
  21. package/cjs/render/contributions/render/area-render.js.map +1 -1
  22. package/cjs/render/contributions/render/draw-contribution.js +2 -2
  23. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  24. package/dist/index.js +237 -137
  25. package/dist/index.min.js +1 -1
  26. package/es/core/graphic-utils.d.ts +2 -1
  27. package/es/core/graphic-utils.js +32 -0
  28. package/es/core/graphic-utils.js.map +1 -1
  29. package/es/env-check.d.ts +2 -2
  30. package/es/env-check.js +19 -2
  31. package/es/env-check.js.map +1 -1
  32. package/es/graphic/rect.d.ts +1 -1
  33. package/es/graphic/rect.js +9 -1
  34. package/es/graphic/rect.js.map +1 -1
  35. package/es/graphic/text.d.ts +1 -0
  36. package/es/graphic/text.js +7 -4
  37. package/es/graphic/text.js.map +1 -1
  38. package/es/interface/core.d.ts +2 -1
  39. package/es/interface/core.js.map +1 -1
  40. package/es/modules.d.ts +1 -0
  41. package/es/modules.js +9 -3
  42. package/es/modules.js.map +1 -1
  43. package/es/picker/pick-modules.js +4 -4
  44. package/es/picker/pick-modules.js.map +1 -1
  45. package/es/render/contributions/render/area-render.js +2 -2
  46. package/es/render/contributions/render/area-render.js.map +1 -1
  47. package/es/render/contributions/render/draw-contribution.js +2 -2
  48. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  49. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -4439,6 +4439,123 @@
4439
4439
  }
4440
4440
  const canvasAllocate = new DefaultCanvasAllocate();
4441
4441
 
4442
+ const VWindow = Symbol.for('VWindow');
4443
+ const WindowHandlerContribution = Symbol.for('WindowHandlerContribution');
4444
+ exports.DefaultWindow = class DefaultWindow {
4445
+ get width() {
4446
+ if (this._handler) {
4447
+ const wh = this._handler.getWH();
4448
+ return (this._width = wh.width);
4449
+ }
4450
+ return this._width;
4451
+ }
4452
+ get height() {
4453
+ if (this._handler) {
4454
+ const wh = this._handler.getWH();
4455
+ return (this._height = wh.height);
4456
+ }
4457
+ return this._height;
4458
+ }
4459
+ get dpr() {
4460
+ return this._handler.getDpr();
4461
+ }
4462
+ constructor() {
4463
+ this.hooks = {
4464
+ onChange: new SyncHook(['x', 'y', 'width', 'height'])
4465
+ };
4466
+ this._uid = Generator.GenAutoIncrementId();
4467
+ this.global = application.global;
4468
+ this.postInit();
4469
+ }
4470
+ postInit() {
4471
+ this.global.hooks.onSetEnv.tap('window', () => {
4472
+ this.active();
4473
+ });
4474
+ this.active();
4475
+ }
4476
+ active() {
4477
+ const global = this.global;
4478
+ if (!global.env || this.actived) {
4479
+ return;
4480
+ }
4481
+ const handler = container.getNamed(WindowHandlerContribution, global.env);
4482
+ handler.configure(this, global);
4483
+ this.actived = true;
4484
+ }
4485
+ get style() {
4486
+ return this._handler.getStyle();
4487
+ }
4488
+ set style(style) {
4489
+ this._handler.setStyle(style);
4490
+ }
4491
+ create(params) {
4492
+ this._handler.createWindow(params);
4493
+ const windowWH = this._handler.getWH();
4494
+ this._width = windowWH.width;
4495
+ this._height = windowWH.height;
4496
+ this.title = this._handler.getTitle();
4497
+ this.resizable = true;
4498
+ }
4499
+ setWindowHandler(handler) {
4500
+ this._handler = handler;
4501
+ }
4502
+ setDpr(dpr) {
4503
+ return this._handler.setDpr(dpr);
4504
+ }
4505
+ resize(w, h) {
4506
+ return this._handler.resizeWindow(w, h);
4507
+ }
4508
+ configure() {
4509
+ throw new Error('暂不支持');
4510
+ }
4511
+ release() {
4512
+ return this._handler.releaseWindow();
4513
+ }
4514
+ getContext() {
4515
+ return this._handler.getContext();
4516
+ }
4517
+ getNativeHandler() {
4518
+ return this._handler.getNativeHandler();
4519
+ }
4520
+ getImageBuffer(type) {
4521
+ if (!this._handler.getImageBuffer) {
4522
+ return null;
4523
+ }
4524
+ return this._handler.getImageBuffer(type);
4525
+ }
4526
+ addEventListener(type, listener, options) {
4527
+ return this._handler.addEventListener(type, listener, options);
4528
+ }
4529
+ removeEventListener(type, listener, options) {
4530
+ return this._handler.removeEventListener(type, listener, options);
4531
+ }
4532
+ dispatchEvent(event) {
4533
+ return this._handler.dispatchEvent(event);
4534
+ }
4535
+ getBoundingClientRect() {
4536
+ return this._handler.getBoundingClientRect();
4537
+ }
4538
+ getContainer() {
4539
+ return this._handler.container;
4540
+ }
4541
+ clearViewBox(viewBox, color) {
4542
+ this._handler.clearViewBox(viewBox, color);
4543
+ }
4544
+ isVisible(bbox) {
4545
+ return this._handler.isVisible(bbox);
4546
+ }
4547
+ onVisibleChange(cb) {
4548
+ return this._handler.onVisibleChange(cb);
4549
+ }
4550
+ getTopLeft(baseWindow) {
4551
+ return this._handler.getTopLeft(baseWindow);
4552
+ }
4553
+ };
4554
+ exports.DefaultWindow = __decorate([
4555
+ injectable(),
4556
+ __metadata("design:paramtypes", [])
4557
+ ], exports.DefaultWindow);
4558
+
4442
4559
  exports.DefaultGraphicUtil = class DefaultGraphicUtil {
4443
4560
  get canvas() {
4444
4561
  this.tryInitCanvas();
@@ -4501,6 +4618,46 @@
4501
4618
  fontSize: DefaultTextStyle.fontSize
4502
4619
  }, getCanvasForMeasure: getCanvasForMeasure || (() => this.canvas), getTextBounds: undefined, specialCharSet: '-/: .,@%\'"~' + vutils.TextMeasure.ALPHABET_CHAR_SET + vutils.TextMeasure.ALPHABET_CHAR_SET.toUpperCase() }, (option !== null && option !== void 0 ? option : {})), textSpec);
4503
4620
  }
4621
+ drawGraphicToCanvas(graphic, stage, canvas) {
4622
+ if (!stage.defaultLayer) {
4623
+ return null;
4624
+ }
4625
+ const window = container.get(VWindow);
4626
+ const bounds = graphic.AABBBounds;
4627
+ const width = bounds.width();
4628
+ const height = bounds.height();
4629
+ window.create({
4630
+ width,
4631
+ height,
4632
+ canvas,
4633
+ dpr: stage.window.dpr,
4634
+ canvasControled: true,
4635
+ offscreen: true,
4636
+ title: ''
4637
+ });
4638
+ const x = -bounds.x1;
4639
+ const y = -bounds.y1;
4640
+ const disableCheckGraphicWidthOutRange = stage.params.optimize.disableCheckGraphicWidthOutRange;
4641
+ stage.params.optimize.disableCheckGraphicWidthOutRange = true;
4642
+ stage.defaultLayer.getNativeHandler().drawTo(window, [graphic], {
4643
+ x,
4644
+ y,
4645
+ width,
4646
+ height,
4647
+ stage,
4648
+ layer: stage.defaultLayer,
4649
+ renderService: stage.renderService,
4650
+ background: 'transparent',
4651
+ clear: true,
4652
+ updateBounds: false
4653
+ });
4654
+ stage.params.optimize.disableCheckGraphicWidthOutRange = disableCheckGraphicWidthOutRange;
4655
+ const c = window.getNativeHandler();
4656
+ if (c.nativeCanvas) {
4657
+ return c.nativeCanvas;
4658
+ }
4659
+ return null;
4660
+ }
4504
4661
  };
4505
4662
  exports.DefaultGraphicUtil = __decorate([
4506
4663
  injectable(),
@@ -12643,123 +12800,6 @@
12643
12800
  __metadata("design:paramtypes", [])
12644
12801
  ], exports.DefaultLayerService);
12645
12802
 
12646
- const VWindow = Symbol.for('VWindow');
12647
- const WindowHandlerContribution = Symbol.for('WindowHandlerContribution');
12648
- exports.DefaultWindow = class DefaultWindow {
12649
- get width() {
12650
- if (this._handler) {
12651
- const wh = this._handler.getWH();
12652
- return (this._width = wh.width);
12653
- }
12654
- return this._width;
12655
- }
12656
- get height() {
12657
- if (this._handler) {
12658
- const wh = this._handler.getWH();
12659
- return (this._height = wh.height);
12660
- }
12661
- return this._height;
12662
- }
12663
- get dpr() {
12664
- return this._handler.getDpr();
12665
- }
12666
- constructor() {
12667
- this.hooks = {
12668
- onChange: new SyncHook(['x', 'y', 'width', 'height'])
12669
- };
12670
- this._uid = Generator.GenAutoIncrementId();
12671
- this.global = application.global;
12672
- this.postInit();
12673
- }
12674
- postInit() {
12675
- this.global.hooks.onSetEnv.tap('window', () => {
12676
- this.active();
12677
- });
12678
- this.active();
12679
- }
12680
- active() {
12681
- const global = this.global;
12682
- if (!global.env || this.actived) {
12683
- return;
12684
- }
12685
- const handler = container.getNamed(WindowHandlerContribution, global.env);
12686
- handler.configure(this, global);
12687
- this.actived = true;
12688
- }
12689
- get style() {
12690
- return this._handler.getStyle();
12691
- }
12692
- set style(style) {
12693
- this._handler.setStyle(style);
12694
- }
12695
- create(params) {
12696
- this._handler.createWindow(params);
12697
- const windowWH = this._handler.getWH();
12698
- this._width = windowWH.width;
12699
- this._height = windowWH.height;
12700
- this.title = this._handler.getTitle();
12701
- this.resizable = true;
12702
- }
12703
- setWindowHandler(handler) {
12704
- this._handler = handler;
12705
- }
12706
- setDpr(dpr) {
12707
- return this._handler.setDpr(dpr);
12708
- }
12709
- resize(w, h) {
12710
- return this._handler.resizeWindow(w, h);
12711
- }
12712
- configure() {
12713
- throw new Error('暂不支持');
12714
- }
12715
- release() {
12716
- return this._handler.releaseWindow();
12717
- }
12718
- getContext() {
12719
- return this._handler.getContext();
12720
- }
12721
- getNativeHandler() {
12722
- return this._handler.getNativeHandler();
12723
- }
12724
- getImageBuffer(type) {
12725
- if (!this._handler.getImageBuffer) {
12726
- return null;
12727
- }
12728
- return this._handler.getImageBuffer(type);
12729
- }
12730
- addEventListener(type, listener, options) {
12731
- return this._handler.addEventListener(type, listener, options);
12732
- }
12733
- removeEventListener(type, listener, options) {
12734
- return this._handler.removeEventListener(type, listener, options);
12735
- }
12736
- dispatchEvent(event) {
12737
- return this._handler.dispatchEvent(event);
12738
- }
12739
- getBoundingClientRect() {
12740
- return this._handler.getBoundingClientRect();
12741
- }
12742
- getContainer() {
12743
- return this._handler.container;
12744
- }
12745
- clearViewBox(viewBox, color) {
12746
- this._handler.clearViewBox(viewBox, color);
12747
- }
12748
- isVisible(bbox) {
12749
- return this._handler.isVisible(bbox);
12750
- }
12751
- onVisibleChange(cb) {
12752
- return this._handler.onVisibleChange(cb);
12753
- }
12754
- getTopLeft(baseWindow) {
12755
- return this._handler.getTopLeft(baseWindow);
12756
- }
12757
- };
12758
- exports.DefaultWindow = __decorate([
12759
- injectable(),
12760
- __metadata("design:paramtypes", [])
12761
- ], exports.DefaultWindow);
12762
-
12763
12803
  var coreModule = new ContainerModule(bind => {
12764
12804
  bind(VGlobal).to(exports.DefaultGlobal).inSingletonScope();
12765
12805
  bind(VWindow).to(exports.DefaultWindow);
@@ -13550,7 +13590,7 @@
13550
13590
  var _a;
13551
13591
  const attribute = this.attribute;
13552
13592
  const textTheme = getTheme(this).text;
13553
- if (this.isMultiLine) {
13593
+ if (!this.isSimplify()) {
13554
13594
  return undefined;
13555
13595
  }
13556
13596
  const { maxLineWidth = textTheme.maxLineWidth } = attribute;
@@ -13561,7 +13601,7 @@
13561
13601
  return this.cache.clipedText;
13562
13602
  }
13563
13603
  get clipedWidth() {
13564
- if (this.isMultiLine) {
13604
+ if (!this.isSimplify()) {
13565
13605
  return undefined;
13566
13606
  }
13567
13607
  this.tryUpdateAABBBounds();
@@ -13570,7 +13610,7 @@
13570
13610
  get cliped() {
13571
13611
  const textTheme = getTheme(this).text;
13572
13612
  const attribute = this.attribute;
13573
- if (this.isMultiLine) {
13613
+ if (!this.isSimplify()) {
13574
13614
  return undefined;
13575
13615
  }
13576
13616
  const { maxLineWidth = textTheme.maxLineWidth } = attribute;
@@ -13578,6 +13618,9 @@
13578
13618
  return false;
13579
13619
  }
13580
13620
  this.tryUpdateAABBBounds();
13621
+ if (this.clipedText == null) {
13622
+ return false;
13623
+ }
13581
13624
  return this.clipedText !== attribute.text.toString();
13582
13625
  }
13583
13626
  get multilineLayout() {
@@ -13587,6 +13630,9 @@
13587
13630
  this.tryUpdateAABBBounds();
13588
13631
  return this.cache.layoutData;
13589
13632
  }
13633
+ isSimplify() {
13634
+ return !this.isMultiLine && this.attribute.direction !== 'vertical';
13635
+ }
13590
13636
  get isMultiLine() {
13591
13637
  return Array.isArray(this.attribute.text) || this.attribute.whiteSpace === 'normal';
13592
13638
  }
@@ -15202,7 +15248,23 @@
15202
15248
  return super.needUpdateTag(key, RECT_UPDATE_TAG_KEY);
15203
15249
  }
15204
15250
  toCustomPath() {
15205
- throw new Error('暂不支持');
15251
+ const attribute = this.attribute;
15252
+ let width = vutils.isNil(attribute.width) ? attribute.x1 - attribute.x : attribute.width;
15253
+ let height = vutils.isNil(attribute.height) ? attribute.y1 - attribute.y : attribute.height;
15254
+ let x = 0;
15255
+ let y = 0;
15256
+ if (width < 0) {
15257
+ x = width;
15258
+ width = -width;
15259
+ }
15260
+ if (height < 0) {
15261
+ y = height;
15262
+ height = -height;
15263
+ }
15264
+ const path = new CustomPath2D();
15265
+ path.moveTo(x, y);
15266
+ path.rect(x, y, width, height);
15267
+ return path;
15206
15268
  }
15207
15269
  clone() {
15208
15270
  return new Rect(Object.assign({}, this.attribute));
@@ -20782,8 +20844,10 @@
20782
20844
  y: (_d = endPoint.y1) !== null && _d !== void 0 ? _d : endPoint.y
20783
20845
  });
20784
20846
  }
20785
- lastBottomSeg = calcLineCache(bottomPoints, curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType);
20786
- bottomCaches.unshift(lastBottomSeg);
20847
+ if (bottomPoints.length > 1) {
20848
+ lastBottomSeg = calcLineCache(bottomPoints, curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType);
20849
+ bottomCaches.unshift(lastBottomSeg);
20850
+ }
20787
20851
  }
20788
20852
  area.cacheArea = bottomCaches.map((item, index) => ({
20789
20853
  top: topCaches[index],
@@ -22049,8 +22113,11 @@
22049
22113
  injectable()
22050
22114
  ], exports.Canvas3DPickItemInterceptor);
22051
22115
 
22052
- var pickModule = new ContainerModule(bind => {
22053
- bind(PickerService).toService(GlobalPickerService);
22116
+ var pickModule = new ContainerModule((bind, unbind, isBound) => {
22117
+ if (!isBound(PickerService)) {
22118
+ bind(GlobalPickerService).toSelf();
22119
+ bind(PickerService).toService(GlobalPickerService);
22120
+ }
22054
22121
  bind(exports.Canvas3DPickItemInterceptor).toSelf().inSingletonScope();
22055
22122
  bind(PickItemInterceptor).toService(exports.Canvas3DPickItemInterceptor);
22056
22123
  bind(exports.ShadowRootPickItemInterceptorContribution).toSelf().inSingletonScope();
@@ -22937,8 +23004,8 @@
22937
23004
  context.inuse = true;
22938
23005
  context.clearMatrix();
22939
23006
  context.setTransformForCurrent(true);
22940
- const drawInArea = dirtyBounds.width() * context.dpr !== context.canvas.width ||
22941
- dirtyBounds.height() * context.dpr !== context.canvas.height;
23007
+ const drawInArea = dirtyBounds.width() * context.dpr < context.canvas.width ||
23008
+ dirtyBounds.height() * context.dpr < context.canvas.height;
22942
23009
  context.save();
22943
23010
  context.translate(x, y, true);
22944
23011
  if (drawInArea) {
@@ -22958,7 +23025,9 @@
22958
23025
  return ((_a = a.attribute.zIndex) !== null && _a !== void 0 ? _a : DefaultAttribute.zIndex) - ((_b = b.attribute.zIndex) !== null && _b !== void 0 ? _b : DefaultAttribute.zIndex);
22959
23026
  })
22960
23027
  .forEach(group => {
22961
- this.renderGroup(group, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));
23028
+ group.isContainer
23029
+ ? this.renderGroup(group, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0))
23030
+ : this.renderItem(group, drawContext);
22962
23031
  });
22963
23032
  context.restore();
22964
23033
  context.restore();
@@ -23677,13 +23746,21 @@
23677
23746
  container.load(renderModule);
23678
23747
  }
23679
23748
 
23680
- container.load(coreModule);
23681
- container.load(graphicModule);
23682
- container.load(renderModule$1);
23683
- container.load(pickModule);
23684
- container.load(pluginModule);
23685
- load$1(container);
23686
- load(container);
23749
+ let loaded = false;
23750
+ function preLoadAllModule() {
23751
+ if (loaded) {
23752
+ return;
23753
+ }
23754
+ loaded = true;
23755
+ container.load(coreModule);
23756
+ container.load(graphicModule);
23757
+ container.load(renderModule$1);
23758
+ container.load(pickModule);
23759
+ container.load(pluginModule);
23760
+ load$1(container);
23761
+ load(container);
23762
+ }
23763
+ preLoadAllModule();
23687
23764
  const vglobal = container.get(VGlobal);
23688
23765
  application.global = vglobal;
23689
23766
  const graphicUtil = container.get(GraphicUtil);
@@ -24681,11 +24758,33 @@
24681
24758
  }
24682
24759
  }
24683
24760
 
24761
+ let _isBrowserEnv;
24762
+ function initIsBrowserEnv() {
24763
+ if (_isBrowserEnv != null) {
24764
+ return;
24765
+ }
24766
+ try {
24767
+ _isBrowserEnv = !!window;
24768
+ }
24769
+ catch (err) {
24770
+ _isBrowserEnv = false;
24771
+ }
24772
+ if (_isBrowserEnv) {
24773
+ try {
24774
+ _isBrowserEnv = !tt;
24775
+ }
24776
+ catch (err) {
24777
+ _isBrowserEnv = true;
24778
+ }
24779
+ }
24780
+ }
24684
24781
  function isBrowserEnv() {
24685
- return new Function('try {return this===window;}catch(e){ return false;}')();
24782
+ initIsBrowserEnv();
24783
+ return _isBrowserEnv;
24686
24784
  }
24687
24785
  function isNodeEnv() {
24688
- return new Function('try {return this===global;}catch(e){return false;}')();
24786
+ initIsBrowserEnv();
24787
+ return !_isBrowserEnv;
24689
24788
  }
24690
24789
  function getCurrentEnv() {
24691
24790
  return isBrowserEnv() ? 'browser' : 'node';
@@ -27535,6 +27634,7 @@
27535
27634
  exports.pointsEqual = pointsEqual;
27536
27635
  exports.pointsInterpolation = pointsInterpolation;
27537
27636
  exports.polygonModule = polygonModule;
27637
+ exports.preLoadAllModule = preLoadAllModule;
27538
27638
  exports.pyramid3dModule = pyramid3dModule;
27539
27639
  exports.rafBasedSto = rafBasedSto;
27540
27640
  exports.rect3dModule = rect3dModule;