ice-render 1.4.8 → 1.4.10

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.
@@ -91,6 +91,18 @@ declare class ICE {
91
91
  * 支持:HTMLCanvasElement、CanvasRenderingContext2D;解析不出则返回 null。
92
92
  */
93
93
  private __resolveCanvasEl;
94
+ /**
95
+ * 读画布矩形(border-box)。
96
+ *
97
+ * **小程序 / 无 DOM 的运行时没有 `getBoundingClientRect`**:那里的 canvas 节点只有
98
+ * `width` / `height` / `getContext`,尺寸要自己用 `wx.createSelectorQuery()` 拿。
99
+ * 这种情况下退回「原点在 (0,0)、尺寸取画布自身尺寸」的矩形 —— 正好对上小程序触摸事件
100
+ * 的坐标语义(`touch.x/y` 就是相对画布的),输入换算与内容盒计算因此有确定输入,
101
+ * 宿主不需要再包一层假 DOM。
102
+ *
103
+ * 有原生实现的运行时(浏览器、jsdom)行为完全不变。
104
+ */
105
+ readCanvasRect(el?: any): any;
94
106
  /**
95
107
  * @param ctx DOM id、HTMLCanvasElement 或 CanvasRenderingContext2D
96
108
  * @param options 渲染配置。renderMode: 'dirty-rect'(默认) | 'full'
@@ -91,6 +91,18 @@ declare class ICE {
91
91
  * 支持:HTMLCanvasElement、CanvasRenderingContext2D;解析不出则返回 null。
92
92
  */
93
93
  private __resolveCanvasEl;
94
+ /**
95
+ * 读画布矩形(border-box)。
96
+ *
97
+ * **小程序 / 无 DOM 的运行时没有 `getBoundingClientRect`**:那里的 canvas 节点只有
98
+ * `width` / `height` / `getContext`,尺寸要自己用 `wx.createSelectorQuery()` 拿。
99
+ * 这种情况下退回「原点在 (0,0)、尺寸取画布自身尺寸」的矩形 —— 正好对上小程序触摸事件
100
+ * 的坐标语义(`touch.x/y` 就是相对画布的),输入换算与内容盒计算因此有确定输入,
101
+ * 宿主不需要再包一层假 DOM。
102
+ *
103
+ * 有原生实现的运行时(浏览器、jsdom)行为完全不变。
104
+ */
105
+ readCanvasRect(el?: any): any;
94
106
  /**
95
107
  * @param ctx DOM id、HTMLCanvasElement 或 CanvasRenderingContext2D
96
108
  * @param options 渲染配置。renderMode: 'dirty-rect'(默认) | 'full'
@@ -25,6 +25,14 @@ declare class ObjectCache {
25
25
  private map;
26
26
  /** 已缓存位图的累计字节数(用于总预算门控;WeakMap 不可遍历,故显式记账)。 */
27
27
  private __bytes;
28
+ /**
29
+ * 运行时是否**没有**离屏 canvas 能力。
30
+ *
31
+ * 小程序老基础库没有 `wx.createOffscreenCanvas`,极简 headless 环境也没有 —— 这类运行时
32
+ * 建位图会抛错;由于 build 发生在帧回调里,抛出去就是未捕获异常(小程序直接白屏)。
33
+ * 一旦探测到这种情况就整体关掉缓存,退化为直接落墨。
34
+ */
35
+ private __offscreenUnavailable;
28
36
  /** 上一帧的渲染视口(复用同一对象,避免每帧分配)。 */
29
37
  private __vp;
30
38
  /** 本帧的渲染视口是否与上一帧不同。视口变化帧一律不缓存,见 `beginFrame()`。 */
@@ -62,6 +70,11 @@ declare class ObjectCache {
62
70
  * @returns true = 已由缓存处理;false = 组件不可缓存,调用方应回退到 component.render()。
63
71
  */
64
72
  render(component: any): boolean;
73
+ /**
74
+ * 是否「完全不透明」:自身 `state.opacity` × 祖先链,语义与 `ICEComponent.getEffectiveOpacity()`
75
+ * 一致。组件没提供该方法时(测试替身 / 宿主对象)退化成只看自身 `state.opacity`。
76
+ */
77
+ private __isOpaque;
65
78
  /** 组件的「真实落墨盒」(世界坐标):几何盒 + paint pad。 */
66
79
  private __paintBox;
67
80
  private build;
@@ -25,6 +25,14 @@ declare class ObjectCache {
25
25
  private map;
26
26
  /** 已缓存位图的累计字节数(用于总预算门控;WeakMap 不可遍历,故显式记账)。 */
27
27
  private __bytes;
28
+ /**
29
+ * 运行时是否**没有**离屏 canvas 能力。
30
+ *
31
+ * 小程序老基础库没有 `wx.createOffscreenCanvas`,极简 headless 环境也没有 —— 这类运行时
32
+ * 建位图会抛错;由于 build 发生在帧回调里,抛出去就是未捕获异常(小程序直接白屏)。
33
+ * 一旦探测到这种情况就整体关掉缓存,退化为直接落墨。
34
+ */
35
+ private __offscreenUnavailable;
28
36
  /** 上一帧的渲染视口(复用同一对象,避免每帧分配)。 */
29
37
  private __vp;
30
38
  /** 本帧的渲染视口是否与上一帧不同。视口变化帧一律不缓存,见 `beginFrame()`。 */
@@ -62,6 +70,11 @@ declare class ObjectCache {
62
70
  * @returns true = 已由缓存处理;false = 组件不可缓存,调用方应回退到 component.render()。
63
71
  */
64
72
  render(component: any): boolean;
73
+ /**
74
+ * 是否「完全不透明」:自身 `state.opacity` × 祖先链,语义与 `ICEComponent.getEffectiveOpacity()`
75
+ * 一致。组件没提供该方法时(测试替身 / 宿主对象)退化成只看自身 `state.opacity`。
76
+ */
77
+ private __isOpaque;
65
78
  /** 组件的「真实落墨盒」(世界坐标):几何盒 + paint pad。 */
66
79
  private __paintBox;
67
80
  private build;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "大漠穷秋",
3
3
  "name": "ice-render",
4
- "version": "1.4.8",
4
+ "version": "1.4.10",
5
5
  "description": "A canvas engine for interactive graphics.",
6
6
  "repository": {
7
7
  "type": "git",