From a73800e0ef0ec16dbaed1dab8282038eaf4ab72e Mon Sep 17 00:00:00 2001 From: Peter White <1788320+peterwhite@users.noreply.github.com> Date: Mon, 12 Oct 2026 11:22:25 +0200 Subject: [PATCH] Upgrade object-identity (#4675) --- .changeset/typed-cache-identities.md | 5 +++++ bun.lock | 4 ++-- packages/gitbook/package.json | 2 +- packages/gitbook/src/lib/cache.test.ts | 11 +++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 .changeset/typed-cache-identities.md diff --git a/.changeset/typed-cache-identities.md b/.changeset/typed-cache-identities.md new file mode 100644 index 000000000..d03a77658 --- /dev/null +++ b/.changeset/typed-cache-identities.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Upgrade object-identity to preserve value types when caching object arguments. diff --git a/bun.lock b/bun.lock index b8158ccac..7b2ffc3b3 100644 --- a/bun.lock +++ b/bun.lock @@ -164,7 +164,7 @@ "next-themes": "^0.4.6", "nuqs": "^2.2.3", "object-hash": "^3.0.0", - "object-identity": "^0.1.2", + "object-identity": "^0.2.1", "openapi-types": "^12.1.3", "p-map": "^7.0.3", "p-retry": "^8.0.0", @@ -2677,7 +2677,7 @@ "object-hash": ["object-hash@3.0.0", "", {}, "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw=="], - "object-identity": ["object-identity@0.1.2", "", {}, "sha512-Px5puVllX5L2aBjbcfXpiG5xXeq6OE8RckryTeP2Zq+0PgYrCGJXmC6LblWgknKSJs11Je2W4U2NOWFj3t/QXQ=="], + "object-identity": ["object-identity@0.2.1", "", {}, "sha512-itX2N4m0IvaLhFZMi9YkW4nFML6FshKCCpnn6iKJZVIkCNM/ZRaG4t1bzD2ncaW4r6cHJa59XY+7oZAH7tg8tA=="], "object-inspect": ["object-inspect@1.13.2", "", {}, "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g=="], diff --git a/packages/gitbook/package.json b/packages/gitbook/package.json index b5fadf715..41e0715f4 100644 --- a/packages/gitbook/package.json +++ b/packages/gitbook/package.json @@ -55,7 +55,7 @@ "next-themes": "^0.4.6", "nuqs": "^2.2.3", "object-hash": "^3.0.0", - "object-identity": "^0.1.2", + "object-identity": "^0.2.1", "openapi-types": "^12.1.3", "p-map": "^7.0.3", "p-retry": "^8.0.0", diff --git a/packages/gitbook/src/lib/cache.test.ts b/packages/gitbook/src/lib/cache.test.ts index 4a54f6499..fb155ad4f 100644 --- a/packages/gitbook/src/lib/cache.test.ts +++ b/packages/gitbook/src/lib/cache.test.ts @@ -67,6 +67,17 @@ describe('withStableRef', () => { expect(ref1).not.toBe(ref2); }); + it('should preserve value types in object references', () => { + const toStableRef = withStableRef(); + const numeric = { id: 1 }; + const textual = { id: '1' }; + + expect(toStableRef(numeric)).toBe(numeric); + expect(toStableRef(textual)).toBe(textual); + expect(toStableRef({ id: 1 })).toBe(numeric); + expect(toStableRef({ id: '1' })).toBe(textual); + }); + it('should maintain reference stability across multiple calls', () => { const toStableRef = withStableRef();