@ait-co/devtools 0.2.1 → 0.2.2
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/mock/index.js +13 -3
- package/dist/mock/index.js.map +1 -1
- package/dist/panel/index.js +14 -4
- package/dist/panel/index.js.map +1 -1
- package/package.json +1 -1
package/dist/mock/index.js
CHANGED
|
@@ -5,9 +5,19 @@
|
|
|
5
5
|
* 메서드별 마지막 *허용* 호출 시각만 담는 leaf 모듈이다. `state.ts`가 `reset()`에서
|
|
6
6
|
* 이걸 비워야 하는데, 로직 본체(`throttle.ts`)는 거꾸로 `state.ts`를 읽는다 —
|
|
7
7
|
* 그래서 **의존이 없는 이 파일로 레지스트리를 분리해** 순환 import를 피한다.
|
|
8
|
+
*
|
|
9
|
+
* `state.ts`의 `AitStateManager`와 같은 이유로 `globalThis` 싱글턴이어야 한다 (#836):
|
|
10
|
+
* `tsdown.config.ts`가 mock/panel/unplugin entry를 각각 self-contained로 빌드하므로,
|
|
11
|
+
* 소비자가 두 entry를 동시에 import하면 이 모듈이 entry당 하나씩 복제된다. Map을
|
|
12
|
+
* 모듈 지역 변수로 두면 `aitState.reset()`이 비우는 Map(싱글턴을 먼저 생성한 번들의 것)과
|
|
13
|
+
* `throttleErrorFor`가 읽는 Map(mock 번들의 것)이 갈려, 리셋 직후 첫 호출이 낡은
|
|
14
|
+
* 타임스탬프 때문에 거부된다 — 이 파일이 막으려던 바로 그 증상이다.
|
|
8
15
|
*/
|
|
9
|
-
|
|
10
|
-
const
|
|
16
|
+
const SINGLETON_KEY$1 = "__aitDevtoolsThrottleRegistry__";
|
|
17
|
+
const globalRef$1 = globalThis;
|
|
18
|
+
if (!globalRef$1[SINGLETON_KEY$1]) globalRef$1[SINGLETON_KEY$1] = /* @__PURE__ */ new Map();
|
|
19
|
+
/** 메서드별 마지막 *허용* 호출 시각(ms). 페이지 안의 모든 entry가 공유한다. */
|
|
20
|
+
const lastAllowedAt = globalRef$1[SINGLETON_KEY$1];
|
|
11
21
|
/**
|
|
12
22
|
* throttle 레지스트리를 비운다. `aitState.reset()`이 호출한다 — 상태를 되돌렸는데
|
|
13
23
|
* 직전 세션의 호출 시각이 남아 있으면 첫 호출이 이유 없이 거부된다.
|
|
@@ -773,7 +783,7 @@ const fetchAlbumItems = Object.assign(_fetchAlbumItemsWithPermission, { isSuppor
|
|
|
773
783
|
*/
|
|
774
784
|
function throttleErrorFor(method) {
|
|
775
785
|
const dial = aitState.state.failureModes.throttled;
|
|
776
|
-
if (!dial?.methods
|
|
786
|
+
if (!dial?.methods?.includes(method)) return void 0;
|
|
777
787
|
const now = Date.now();
|
|
778
788
|
const prev = lastAllowedAt.get(method);
|
|
779
789
|
if (prev !== void 0 && now - prev < dial.intervalMs) return buildNativeError("APP_BRIDGE_THROTTLED");
|