@cmssy/react 19.31.0 → 19.32.0

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/client.cjs CHANGED
@@ -96,18 +96,18 @@ function hasArea(block) {
96
96
  const rect = block.getBoundingClientRect();
97
97
  return rect.width > 0 && rect.height > 0;
98
98
  }
99
- function isBlockPainted(block) {
99
+ function blockPaint(block) {
100
100
  if (block.childElementCount === 0 && !holdsText(block) && !hasArea(block)) {
101
- return false;
101
+ return "empty";
102
102
  }
103
103
  const copy = laidOut(collectCopy(block));
104
104
  if (copy.length > 0) {
105
105
  const visible2 = copy.filter((state) => state.opacity > TRANSPARENT);
106
- return visible2.length >= copy.length * VISIBLE_TEXT_FRACTION;
106
+ return visible2.length >= copy.length * VISIBLE_TEXT_FRACTION ? "painted" : "transparent";
107
107
  }
108
108
  const media = laidOut(collectMedia(block));
109
- if (media.length === 0) return true;
110
- return media.some((state) => state.opacity > TRANSPARENT);
109
+ if (media.length === 0) return "painted";
110
+ return media.some((state) => state.opacity > TRANSPARENT) ? "painted" : "transparent";
111
111
  }
112
112
 
113
113
  // src/bridge/use-invisible-blocks.ts
@@ -127,7 +127,7 @@ function useInvisibleBlocks(enabled, blocksKey, report) {
127
127
  let reported = "";
128
128
  const flush = () => {
129
129
  const blocks = [...invisible.values()];
130
- const key = blocks.map((block) => `${block.blockId}:${block.blockType}`).sort().join("|");
130
+ const key = blocks.map((block) => `${block.blockId}:${block.blockType}:${block.reason}`).sort().join("|");
131
131
  if (key === reported) return;
132
132
  reported = key;
133
133
  reportRef.current(blocks);
@@ -136,8 +136,9 @@ function useInvisibleBlocks(enabled, blocksKey, report) {
136
136
  const blockId = el.getAttribute("data-block-id");
137
137
  const blockType = el.getAttribute("data-block-type");
138
138
  if (!blockId || !blockType) return;
139
- if (isBlockPainted(el)) invisible.delete(blockId);
140
- else invisible.set(blockId, { blockId, blockType });
139
+ const paint2 = blockPaint(el);
140
+ if (paint2 === "painted") invisible.delete(blockId);
141
+ else invisible.set(blockId, { blockId, blockType, reason: paint2 });
141
142
  flush();
142
143
  };
143
144
  const observer = new IntersectionObserver(
@@ -173,8 +174,11 @@ function useInvisibleBlocks(enabled, blocksKey, report) {
173
174
  const blockId = el.getAttribute("data-block-id");
174
175
  if (!blockId) continue;
175
176
  present.add(blockId);
176
- if (invisible.has(blockId) && isBlockPainted(el)) {
177
- invisible.delete(blockId);
177
+ const reported2 = invisible.get(blockId);
178
+ if (reported2) {
179
+ const paint2 = blockPaint(el);
180
+ if (paint2 === "painted") invisible.delete(blockId);
181
+ else invisible.set(blockId, { ...reported2, reason: paint2 });
178
182
  }
179
183
  }
180
184
  for (const blockId of [...invisible.keys()]) {
package/dist/client.js CHANGED
@@ -94,18 +94,18 @@ function hasArea(block) {
94
94
  const rect = block.getBoundingClientRect();
95
95
  return rect.width > 0 && rect.height > 0;
96
96
  }
97
- function isBlockPainted(block) {
97
+ function blockPaint(block) {
98
98
  if (block.childElementCount === 0 && !holdsText(block) && !hasArea(block)) {
99
- return false;
99
+ return "empty";
100
100
  }
101
101
  const copy = laidOut(collectCopy(block));
102
102
  if (copy.length > 0) {
103
103
  const visible2 = copy.filter((state) => state.opacity > TRANSPARENT);
104
- return visible2.length >= copy.length * VISIBLE_TEXT_FRACTION;
104
+ return visible2.length >= copy.length * VISIBLE_TEXT_FRACTION ? "painted" : "transparent";
105
105
  }
106
106
  const media = laidOut(collectMedia(block));
107
- if (media.length === 0) return true;
108
- return media.some((state) => state.opacity > TRANSPARENT);
107
+ if (media.length === 0) return "painted";
108
+ return media.some((state) => state.opacity > TRANSPARENT) ? "painted" : "transparent";
109
109
  }
110
110
 
111
111
  // src/bridge/use-invisible-blocks.ts
@@ -125,7 +125,7 @@ function useInvisibleBlocks(enabled, blocksKey, report) {
125
125
  let reported = "";
126
126
  const flush = () => {
127
127
  const blocks = [...invisible.values()];
128
- const key = blocks.map((block) => `${block.blockId}:${block.blockType}`).sort().join("|");
128
+ const key = blocks.map((block) => `${block.blockId}:${block.blockType}:${block.reason}`).sort().join("|");
129
129
  if (key === reported) return;
130
130
  reported = key;
131
131
  reportRef.current(blocks);
@@ -134,8 +134,9 @@ function useInvisibleBlocks(enabled, blocksKey, report) {
134
134
  const blockId = el.getAttribute("data-block-id");
135
135
  const blockType = el.getAttribute("data-block-type");
136
136
  if (!blockId || !blockType) return;
137
- if (isBlockPainted(el)) invisible.delete(blockId);
138
- else invisible.set(blockId, { blockId, blockType });
137
+ const paint2 = blockPaint(el);
138
+ if (paint2 === "painted") invisible.delete(blockId);
139
+ else invisible.set(blockId, { blockId, blockType, reason: paint2 });
139
140
  flush();
140
141
  };
141
142
  const observer = new IntersectionObserver(
@@ -171,8 +172,11 @@ function useInvisibleBlocks(enabled, blocksKey, report) {
171
172
  const blockId = el.getAttribute("data-block-id");
172
173
  if (!blockId) continue;
173
174
  present.add(blockId);
174
- if (invisible.has(blockId) && isBlockPainted(el)) {
175
- invisible.delete(blockId);
175
+ const reported2 = invisible.get(blockId);
176
+ if (reported2) {
177
+ const paint2 = blockPaint(el);
178
+ if (paint2 === "painted") invisible.delete(blockId);
179
+ else invisible.set(blockId, { ...reported2, reason: paint2 });
176
180
  }
177
181
  }
178
182
  for (const blockId of [...invisible.keys()]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/react",
3
- "version": "19.31.0",
3
+ "version": "19.32.0",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -109,8 +109,8 @@
109
109
  "vitest": "^2.1.0"
110
110
  },
111
111
  "dependencies": {
112
- "@cmssy/types": "0.75.0",
113
- "@cmssy/core": "19.31.0"
112
+ "@cmssy/types": "0.75.1",
113
+ "@cmssy/core": "19.32.0"
114
114
  },
115
115
  "scripts": {
116
116
  "build": "tsup",