Skip to content

Commit 3fb1a24

Browse files
refactor(collaboration,mobile): delete readerless createPresenceUpdater and requestBackgroundSync (#28402)
domain:ui#5 · os-sales · session_01L6bhgUhKx1XHzkoikGjRB4 <!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuJSyZAA88UvC1TbJJXdgoi2)_ Part of #25921 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:删除 `@object-ui/collaboration` 里的 `createPresenceUpdater` 和 `@object-ui/mobile` 里的 `requestBackgroundSync` 两个函数体,共 50 行。 - 为什么改:上一个 PR 已把这两个名字移出包入口,仓库内再无任何读取者,留着只是死代码。 - 风险与回滚:无公开面变化,两个包都只有一个 `.` 入口,外部无法导入;回滚即 revert 这一个提交。 - 先看:`ui/packages/collaboration/src/usePresence.ts` 末尾、`ui/packages/mobile/src/serviceWorkerSource.ts` 末尾(都是文件尾部整段删除)。 - 两分钟验证:`git grep -nw -e createPresenceUpdater -e requestBackgroundSync -- . ':!**/CHANGELOG.md'` 只应命中 `.changeset/` 里 #25921 的三个 changeset(本 PR 新增的一个,加上 PR #28385 的两个),源码零命中。 - 需要你做的:无,席位落地。 ## What changes Deletes the module-local function `createPresenceUpdater` (`usePresence.ts`) and `requestBackgroundSync` (`serviceWorkerSource.ts`). No imports or types became unused; no test exercised either function (none found by `git grep -w`). Net 50 deletions plus one patch changeset. Changeset vs `skip-changeset`: both packages compile with `tsc` and ship `dist` (`files[]`), so `dist/usePresence.js` and `dist/serviceWorkerSource.js` change bytes; a patch changeset is added and no `skip-changeset` label. It is not a public-surface change: the single `.` export of each package already dropped both names. ## Tests - `pnpm --filter @object-ui/collaboration run type-check` exit 0; `pnpm --dir ui exec vitest run packages/collaboration/` 7 files / 83 tests pass. - `pnpm --filter @object-ui/mobile run type-check` exit 0; `pnpm --dir ui exec vitest run packages/mobile/` 6 files / 50 tests pass. - Dependency closure built first (`@object-ui/collaboration^...`, `@object-ui/mobile^...`). ## Acceptance notes - Premise re-measured on origin/main 125ad06: `git grep -nw` over the whole tree (examples, packages/console, skills, content/docs, READMEs) finds each name only at its definition plus CHANGELOG history. - `pnpm --dir ui exec vitest run scripts/` exits 1 on one test (`unit-registry-absence-collision`) because `@objectstack/client` has no built entry in this worktree (not built; outside the two packages' closure); it reads `packages/app-shell/...`, not the files touched here. Reported as NOT MEASURED for that family; CI builds it. ## Verification <details><summary>Derived gates at bec3be1 (all exit 0 except the one above)</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` run in full, including `node scripts/check-sdui-manifest.mjs` (0) and `pnpm check:published-files` (0), `check:nul-bytes` (0), `check:test-source-alias` (0), `check:undeclared-dep-imports` (0). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01L6bhgUhKx1XHzkoikGjRB4)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgUhKx1XHzkoikGjRB4 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7e9f814 commit 3fb1a24

3 files changed

Lines changed: 11 additions & 50 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@object-ui/collaboration': patch
3+
'@object-ui/mobile': patch
4+
---
5+
6+
refactor(collaboration,mobile): delete the module-local `createPresenceUpdater` and `requestBackgroundSync` helpers that nothing reads
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
Neither name is exported from its package entry (the single `.` export), so no host can import them; the compiled `usePresence.js` and `serviceWorkerSource.js` simply stop carrying the two dead function bodies. Behaviour of every exported name is unchanged.

‎ui/packages/collaboration/src/usePresence.ts‎

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -205,41 +205,3 @@ export function usePresence(
205205
currentUser,
206206
};
207207
}
208-
209-
/**
210-
* Update remote user presence. Call this when receiving presence data
211-
* from other users via the realtime channel.
212-
*
213-
* @returns A function to update or remove a remote user from the presence set.
214-
*/
215-
export function createPresenceUpdater(): {
216-
updateUser: (user: PresenceUser) => void;
217-
removeUser: (userId: string) => void;
218-
getUsers: () => PresenceUser[];
219-
onUsersChange: (callback: (users: Map<string, PresenceUser>) => void) => () => void;
220-
} {
221-
const users = new Map<string, PresenceUser>();
222-
const listeners = new Set<(users: Map<string, PresenceUser>) => void>();
223-
224-
const notify = () => {
225-
listeners.forEach(cb => cb(new Map(users)));
226-
};
227-
228-
return {
229-
updateUser(user: PresenceUser) {
230-
users.set(user.userId, user);
231-
notify();
232-
},
233-
removeUser(userId: string) {
234-
users.delete(userId);
235-
notify();
236-
},
237-
getUsers() {
238-
return Array.from(users.values());
239-
},
240-
onUsersChange(callback: (users: Map<string, PresenceUser>) => void) {
241-
listeners.add(callback);
242-
return () => { listeners.delete(callback); };
243-
},
244-
};
245-
}

‎ui/packages/mobile/src/serviceWorkerSource.ts‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,3 @@ self.addEventListener('sync', (event) => {
9595
});
9696
`;
9797
}
98-
99-
/**
100-
* Request a one-shot background sync. The page should call this after
101-
* enqueuing offline work so the browser will wake the SW when the
102-
* connection returns. Returns false if Background Sync is unsupported.
103-
*/
104-
export async function requestBackgroundSync(tag = 'objectui-offline-queue'): Promise<boolean> {
105-
if (typeof navigator === 'undefined') return false;
106-
const reg: any = await (navigator as any).serviceWorker?.ready;
107-
if (!reg || !reg.sync) return false;
108-
try { await reg.sync.register(tag); return true; } catch { return false; }
109-
}

0 commit comments

Comments
 (0)