Skip to content

Commit 909ae8f

Browse files
Merge main into release
2 parents 4e6a5c6 + 3418ef8 commit 909ae8f

File tree

14 files changed

+369
-474
lines changed

14 files changed

+369
-474
lines changed

.changeset/slimy-chicken-mix.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@firebase/firestore': patch
3+
'firebase': patch
4+
---
5+
6+
Reverted a change to use UTF-8 encoding in string comparisons which caused a performance issue. See [GitHub issue #8778](https://github.com/firebase/firebase-js-sdk/issues/8778)

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ packages/app-check-types @hsubox76 @firebase/jssdk-global-approvers
7272
packages/app-check-interop-types @hsubox76 @firebase/jssdk-global-approvers
7373

7474
# Documentation Changes
75-
packages/firebase/index.d.ts @egilmorez @firebase/jssdk-global-approvers
75+
packages/firebase/compat/index.d.ts @egilmorez @firebase/jssdk-global-approvers
7676
scripts/docgen/content-sources/ @egilmorez @firebase/jssdk-global-approvers
7777
docs-devsite/ @firebase/firebase-techwriters
7878

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,7 @@ docs/
100100

101101
# vertexai test data
102102
vertexai-sdk-test-data
103-
mocks-lookup.ts
103+
mocks-lookup.ts
104+
105+
# temp changeset output
106+
changeset-temp.json

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Reference docs for the Firebase [JS SDK](https://firebase.google.com/docs/refere
206206
[Typedoc](https://typedoc.org/).
207207
208208
Typedoc generates this documentation from the main
209-
[firebase index.d.ts type definition file](packages/firebase/index.d.ts). Any updates to
209+
[firebase index.d.ts type definition file](packages/firebase/compat/index.d.ts). Any updates to
210210
documentation should be made in that file.
211211
212212
If any pages are added or removed by your change (by adding or removing a class or interface), the

e2e/fix-jsdom-environment.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@
1818
import JSDOMEnvironment from 'jest-environment-jsdom';
1919

2020
/**
21-
* JSDOMEnvironment patch to polyfill missing fetch with native
22-
* Node fetch
21+
* JSDOMEnvironment patch to polyfill missing APIs with Node APIs.
2322
*/
2423
// https://github.com/facebook/jest/blob/v29.4.3/website/versioned_docs/version-29.4/Configuration.md#testenvironment-string
2524
export default class FixJSDOMEnvironment extends JSDOMEnvironment {
2625
constructor(...args: ConstructorParameters<typeof JSDOMEnvironment>) {
2726
super(...args);
2827

29-
// FIXME https://github.com/jsdom/jsdom/issues/1724
28+
// Fetch
29+
// FIXME: https://github.com/jsdom/jsdom/issues/1724
3030
this.global.fetch = fetch;
3131
this.global.Headers = Headers;
3232
this.global.Request = Request;
3333
this.global.Response = Response;
34+
35+
// Util
36+
this.global.TextEncoder = TextEncoder;
3437
}
3538
}

e2e/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"setup": "node test-setup.js",
87
"test": "yarn jest",
98
"test:compat": "yarn jest tests/compat.test.ts",
109
"test:modular": "yarn jest tests/modular.test.ts",
@@ -18,7 +17,7 @@
1817
"author": "",
1918
"license": "ISC",
2019
"dependencies": {
21-
"firebase": "11.0.2"
20+
"firebase": "11.3.0"
2221
},
2322
"devDependencies": {
2423
"@babel/core": "7.26.0",

e2e/yarn.lock

Lines changed: 235 additions & 229 deletions
Large diffs are not rendered by default.

packages/firestore/src/local/indexeddb_remote_document_cache.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,5 @@ export function dbKeyComparator(l: DocumentKey, r: DocumentKey): number {
655655
return cmp;
656656
}
657657

658-
// TODO(b/329441702): Document IDs should be sorted by UTF-8 encoded byte
659-
// order, but IndexedDB sorts strings lexicographically. Document ID
660-
// comparison here still relies on primitive comparison to avoid mismatches
661-
// observed in snapshot listeners with Unicode characters in documentIds
662658
return primitiveComparator(left[left.length - 1], right[right.length - 1]);
663659
}

packages/firestore/src/model/path.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { Integer } from '@firebase/webchannel-wrapper/bloom-blob';
1919

2020
import { debugAssert, fail } from '../util/assert';
2121
import { Code, FirestoreError } from '../util/error';
22-
import { primitiveComparator, compareUtf8Strings } from '../util/misc';
2322

2423
export const DOCUMENT_KEY_NAME = '__name__';
2524

@@ -182,7 +181,7 @@ abstract class BasePath<B extends BasePath<B>> {
182181
return comparison;
183182
}
184183
}
185-
return primitiveComparator(p1.length, p2.length);
184+
return Math.sign(p1.length - p2.length);
186185
}
187186

188187
private static compareSegments(lhs: string, rhs: string): number {
@@ -202,7 +201,13 @@ abstract class BasePath<B extends BasePath<B>> {
202201
);
203202
} else {
204203
// both non-numeric
205-
return compareUtf8Strings(lhs, rhs);
204+
if (lhs < rhs) {
205+
return -1;
206+
}
207+
if (lhs > rhs) {
208+
return 1;
209+
}
210+
return 0;
206211
}
207212
}
208213

packages/firestore/src/model/values.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ import {
2525
Value
2626
} from '../protos/firestore_proto_api';
2727
import { fail } from '../util/assert';
28-
import {
29-
arrayEquals,
30-
primitiveComparator,
31-
compareUtf8Strings
32-
} from '../util/misc';
28+
import { arrayEquals, primitiveComparator } from '../util/misc';
3329
import { forEach, objectSize } from '../util/obj';
3430
import { isNegativeZero } from '../util/types';
3531

@@ -255,7 +251,7 @@ export function valueCompare(left: Value, right: Value): number {
255251
getLocalWriteTime(right)
256252
);
257253
case TypeOrder.StringValue:
258-
return compareUtf8Strings(left.stringValue!, right.stringValue!);
254+
return primitiveComparator(left.stringValue!, right.stringValue!);
259255
case TypeOrder.BlobValue:
260256
return compareBlobs(left.bytesValue!, right.bytesValue!);
261257
case TypeOrder.RefValue:
@@ -404,7 +400,7 @@ function compareMaps(left: MapValue, right: MapValue): number {
404400
rightKeys.sort();
405401

406402
for (let i = 0; i < leftKeys.length && i < rightKeys.length; ++i) {
407-
const keyCompare = compareUtf8Strings(leftKeys[i], rightKeys[i]);
403+
const keyCompare = primitiveComparator(leftKeys[i], rightKeys[i]);
408404
if (keyCompare !== 0) {
409405
return keyCompare;
410406
}

0 commit comments

Comments
 (0)