xxf_react 0.4.7 → 0.4.9

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.
@@ -3,5 +3,6 @@ declare global {
3
3
  bindErrorNotice(filter?: (error: any) => boolean): Promise<T>;
4
4
  }
5
5
  }
6
+ export declare function isSafariLoadFailed(error: unknown): boolean;
6
7
  export declare function initPromiseErrorExtension(): void;
7
8
  //# sourceMappingURL=promise_ext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promise_ext.d.ts","sourceRoot":"","sources":["../../src/flow/promise_ext.ts"],"names":[],"mappings":"AAIA,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,OAAO,CAAC,CAAC;QACf,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;KACjE;CACJ;AAED,wBAAgB,yBAAyB,IAAI,IAAI,CAgDhD"}
1
+ {"version":3,"file":"promise_ext.d.ts","sourceRoot":"","sources":["../../src/flow/promise_ext.ts"],"names":[],"mappings":"AAIA,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,OAAO,CAAC,CAAC;QACf,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;KACjE;CACJ;AAGD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM1D;AAED,wBAAgB,yBAAyB,IAAI,IAAI,CAgDhD"}
@@ -1,5 +1,11 @@
1
1
  // src/lib/promise_ext.ts
2
2
  import { toast } from "react-toastify";
3
+ // 或者更完整的判断
4
+ export function isSafariLoadFailed(error) {
5
+ return (error instanceof TypeError &&
6
+ (error.message === 'Load failed' ||
7
+ error.message.includes('Load failed')));
8
+ }
3
9
  export function initPromiseErrorExtension() {
4
10
  if (typeof Promise === 'undefined') {
5
11
  console.warn('Promise is not available in this environment.');
@@ -14,7 +20,7 @@ export function initPromiseErrorExtension() {
14
20
  Object.defineProperty(Promise.prototype, 'bindErrorNotice', {
15
21
  value: function (filter) {
16
22
  return this.catch((error) => {
17
- const shouldHandle = filter ? filter(error) : true;
23
+ const shouldHandle = filter ? filter(error) : !isSafariLoadFailed(error);
18
24
  if (shouldHandle) {
19
25
  // 错误处理逻辑
20
26
  console.error('==========>[Promise Error Notice]', {
@@ -2,6 +2,7 @@ import { RefObject } from 'react';
2
2
  /**
3
3
  * 监听元素及其所有祖先的可见性
4
4
  * 支持检测 display: none、visibility: hidden、opacity: 0
5
+ * 支持 Radix UI 的 data-state 属性变化(如 Tabs.Content)
5
6
  *
6
7
  * @param ref - 要监听的元素 ref
7
8
  * @param debounceMs - 防抖时间(毫秒),默认 16ms(约一帧)
@@ -1 +1 @@
1
- {"version":3,"file":"ElementVisibilityHooks.d.ts","sourceRoot":"","sources":["../../../src/layout/visibility/ElementVisibilityHooks.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA8B,SAAS,EAAC,MAAM,OAAO,CAAA;AAE5D;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAChC,GAAG,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAClC,UAAU,GAAE,MAAW,EACvB,QAAQ,GAAE,OAAc,GACzB,OAAO,GAAG,IAAI,CAwHhB"}
1
+ {"version":3,"file":"ElementVisibilityHooks.d.ts","sourceRoot":"","sources":["../../../src/layout/visibility/ElementVisibilityHooks.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA8B,SAAS,EAAC,MAAM,OAAO,CAAA;AAE5D;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAChC,GAAG,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAClC,UAAU,GAAE,MAAW,EACvB,QAAQ,GAAE,OAAc,GACzB,OAAO,GAAG,IAAI,CAyHhB"}
@@ -3,6 +3,7 @@ import { useState, useEffect, useRef } from 'react';
3
3
  /**
4
4
  * 监听元素及其所有祖先的可见性
5
5
  * 支持检测 display: none、visibility: hidden、opacity: 0
6
+ * 支持 Radix UI 的 data-state 属性变化(如 Tabs.Content)
6
7
  *
7
8
  * @param ref - 要监听的元素 ref
8
9
  * @param debounceMs - 防抖时间(毫秒),默认 16ms(约一帧)
@@ -71,7 +72,8 @@ export function useElementVisibility(ref, debounceMs = 16, ancestor = true) {
71
72
  while (parent) {
72
73
  observer.observe(parent, {
73
74
  attributes: true,
74
- attributeFilter: ['style', 'class'],
75
+ // 监听 style、class、以及 data-state(Radix UI)
76
+ attributeFilter: ['style', 'class', 'data-state'],
75
77
  });
76
78
  // 如果不检查祖先,只监听当前元素后退出
77
79
  if (!ancestor)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xxf_react",
3
- "version": "0.4.7",
3
+ "version": "0.4.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",