修改pods

This commit is contained in:
2025-09-20 17:13:38 +08:00
parent 7787b3ee30
commit 28ff2b0264
5251 changed files with 345029 additions and 285168 deletions

View File

@@ -14,11 +14,13 @@
* limitations under the License.
*/
#import "FIRDocumentSnapshot+Internal.h"
#import <FirebaseCore/FIRTimestamp.h>
#include <utility>
#include <vector>
#import "FIRDocumentSnapshot+Internal.h"
#include "Firestore/core/src/util/warnings.h"
#import "Firestore/Source/API/FIRDocumentReference+Internal.h"
@@ -26,7 +28,6 @@
#import "Firestore/Source/API/FIRFirestore+Internal.h"
#import "Firestore/Source/API/FIRGeoPoint+Internal.h"
#import "Firestore/Source/API/FIRSnapshotMetadata+Internal.h"
#import "Firestore/Source/API/FIRTimestamp+Internal.h"
#import "Firestore/Source/API/FSTUserDataWriter.h"
#import "Firestore/Source/API/converters.h"

View File

@@ -15,6 +15,7 @@
*/
#import "Firestore/Source/API/FIRFieldValue+Internal.h"
#import "Firestore/Source/Public/FirebaseFirestore/FIRVectorValue.h"
NS_ASSUME_NONNULL_BEGIN
@@ -176,6 +177,10 @@ NS_ASSUME_NONNULL_BEGIN
return [[FSTNumericIncrementFieldValue alloc] initWithOperand:@(l)];
}
+ (nonnull FIRVectorValue *)vectorWithArray:(nonnull NSArray<NSNumber *> *)array {
return [[FIRVectorValue alloc] initWithArray:array];
}
@end
NS_ASSUME_NONNULL_END

View File

@@ -1,152 +0,0 @@
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import "Firestore/Source/API/FIRTimestamp+Internal.h"
NS_ASSUME_NONNULL_BEGIN
static const int kNanosPerSecond = 1000000000;
@implementation FIRTimestamp (Internal)
#pragma mark - Internal public methods
- (NSString *)ISO8601String {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss";
formatter.timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
NSDate *secondsDate = [NSDate dateWithTimeIntervalSince1970:self.seconds];
NSString *secondsString = [formatter stringFromDate:secondsDate];
if (secondsString.length != 19) {
[NSException raise:@"Invalid ISO string" format:@"Invalid ISO string: %@", secondsString];
}
NSString *nanosString = [NSString stringWithFormat:@"%09d", self.nanoseconds];
return [NSString stringWithFormat:@"%@.%@Z", secondsString, nanosString];
}
@end
@implementation FIRTimestamp
#pragma mark - Constructors
+ (instancetype)timestampWithDate:(NSDate *)date {
double secondsDouble;
double fraction = modf(date.timeIntervalSince1970, &secondsDouble);
// GCP Timestamps always have non-negative nanos.
if (fraction < 0) {
fraction += 1.0;
secondsDouble -= 1.0;
}
int64_t seconds = (int64_t)secondsDouble;
int32_t nanos = (int32_t)(fraction * kNanosPerSecond);
return [[FIRTimestamp alloc] initWithSeconds:seconds nanoseconds:nanos];
}
+ (instancetype)timestampWithSeconds:(int64_t)seconds nanoseconds:(int32_t)nanoseconds {
return [[FIRTimestamp alloc] initWithSeconds:seconds nanoseconds:nanoseconds];
}
+ (instancetype)timestamp {
return [FIRTimestamp timestampWithDate:[NSDate date]];
}
- (instancetype)initWithSeconds:(int64_t)seconds nanoseconds:(int32_t)nanoseconds {
self = [super init];
if (self) {
if (nanoseconds < 0) {
[NSException raise:@"Invalid timestamp"
format:@"Timestamp nanoseconds out of range: %d", nanoseconds];
}
if (nanoseconds >= 1e9) {
[NSException raise:@"Invalid timestamp"
format:@"Timestamp nanoseconds out of range: %d", nanoseconds];
}
// Midnight at the beginning of 1/1/1 is the earliest timestamp supported.
if (seconds < -62135596800L) {
[NSException raise:@"Invalid timestamp"
format:@"Timestamp seconds out of range: %lld", seconds];
}
// This will break in the year 10,000.
if (seconds >= 253402300800L) {
[NSException raise:@"Invalid timestamp"
format:@"Timestamp seconds out of range: %lld", seconds];
}
_seconds = seconds;
_nanoseconds = nanoseconds;
}
return self;
}
#pragma mark - NSObject methods
- (BOOL)isEqual:(id)object {
if (self == object) {
return YES;
}
if (![object isKindOfClass:[FIRTimestamp class]]) {
return NO;
}
return [self isEqualToTimestamp:(FIRTimestamp *)object];
}
- (NSUInteger)hash {
return (NSUInteger)((self.seconds >> 32) ^ self.seconds ^ self.nanoseconds);
}
- (NSString *)description {
return [NSString stringWithFormat:@"<FIRTimestamp: seconds=%lld nanoseconds=%d>", self.seconds,
self.nanoseconds];
}
/** Implements NSCopying without actually copying because timestamps are immutable. */
- (id)copyWithZone:(__unused NSZone *_Nullable)zone {
return self;
}
#pragma mark - Public methods
- (NSDate *)dateValue {
NSTimeInterval interval = (NSTimeInterval)self.seconds + ((NSTimeInterval)self.nanoseconds) / 1e9;
return [NSDate dateWithTimeIntervalSince1970:interval];
}
- (NSComparisonResult)compare:(FIRTimestamp *)other {
if (self.seconds < other.seconds) {
return NSOrderedAscending;
} else if (self.seconds > other.seconds) {
return NSOrderedDescending;
}
if (self.nanoseconds < other.nanoseconds) {
return NSOrderedAscending;
} else if (self.nanoseconds > other.nanoseconds) {
return NSOrderedDescending;
}
return NSOrderedSame;
}
#pragma mark - Private methods
- (BOOL)isEqualToTimestamp:(FIRTimestamp *)other {
return [self compare:other] == NSOrderedSame;
}
@end
NS_ASSUME_NONNULL_END

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018 Google
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,21 +14,34 @@
* limitations under the License.
*/
#import "FIRTimestamp.h"
#import <Foundation/Foundation.h>
#include "Firestore/Source/Public/FirebaseFirestore/FIRVectorValue.h"
NS_ASSUME_NONNULL_BEGIN
/** Internal FIRTimestamp API we don't want exposed in our public header files. */
@interface FIRTimestamp (Internal)
@implementation FIRVectorValue
/**
* Converts the given date to an ISO 8601 timestamp string, useful for rendering in JSON.
*
* ISO 8601 dates times in UTC look like this: "1912-04-14T23:40:00.000000000Z".
*
* @see http://www.ecma-international.org/ecma-262/6.0/#sec-date-time-string-format
*/
- (NSString *)ISO8601String;
- (instancetype)initWithArray:(NSArray<NSNumber *> *)array {
if (self = [super init]) {
_array = [array valueForKey:@"doubleValue"];
}
return self;
}
- (BOOL)isEqual:(nullable id)object {
if (self == object) {
return YES;
}
if (![object isKindOfClass:[FIRVectorValue class]]) {
return NO;
}
FIRVectorValue *otherVector = ((FIRVectorValue *)object);
return [self.array isEqualToArray:otherVector.array];
}
@end

View File

@@ -22,14 +22,13 @@
#include <string>
#include <utility>
#import "FirebaseAuth/Interop/FIRAuthInterop.h"
#import "FirebaseAuth/Interop/Public/FirebaseAuthInterop/FIRAuthInterop.h"
#import "FirebaseCore/Extension/FIRAppInternal.h"
#import "FirebaseCore/Extension/FIRComponent.h"
#import "FirebaseCore/Extension/FIRComponentContainer.h"
#import "FirebaseCore/Extension/FIRComponentType.h"
#import "FirebaseCore/Extension/FIRDependency.h"
#import "FirebaseCore/Extension/FIRLibrary.h"
#import "FirebaseCore/Extension/FIROptionsInternal.h"
#import "FirebaseCore/Sources/FIROptionsInternal.h"
#import "Firestore/Source/API/FIRFirestore+Internal.h"
#include "Firestore/core/include/firebase/firestore/firestore_version.h"
@@ -160,12 +159,9 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Interoperability
+ (NSArray<FIRComponent *> *)componentsToRegister {
FIRDependency *auth = [FIRDependency dependencyWithProtocol:@protocol(FIRAuthInterop)
isRequired:NO];
FIRComponent *firestoreProvider = [FIRComponent
componentWithProtocol:@protocol(FSTFirestoreMultiDBProvider)
instantiationTiming:FIRInstantiationTimingLazy
dependencies:@[ auth ]
creationBlock:^id _Nullable(FIRComponentContainer *container, BOOL *isCacheable) {
FSTFirestoreComponent *multiDBComponent =
[[FSTFirestoreComponent alloc] initWithApp:container.app];

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
#import "Firestore/Source/API/FSTUserDataReader.h"
#import <FirebaseCore/FIRTimestamp.h>
#include <memory>
#include <set>
@@ -22,8 +22,10 @@
#include <utility>
#include <vector>
#import "Firestore/Source/API/FSTUserDataReader.h"
#import "FIRGeoPoint.h"
#import "FIRTimestamp.h"
#import "FIRVectorValue.h"
#import "Firestore/Source/API/FIRDocumentReference+Internal.h"
#import "Firestore/Source/API/FIRFieldPath+Internal.h"
@@ -340,6 +342,42 @@ NS_ASSUME_NONNULL_BEGIN
return std::move(result);
}
- (Message<google_firestore_v1_Value>)parseVectorValue:(FIRVectorValue *)vectorValue
context:(ParseContext &&)context {
__block Message<google_firestore_v1_Value> result;
result->which_value_type = google_firestore_v1_Value_map_value_tag;
result->map_value = {};
result->map_value.fields_count = 2;
result->map_value.fields = nanopb::MakeArray<google_firestore_v1_MapValue_FieldsEntry>(2);
result->map_value.fields[0].key = nanopb::CopyBytesArray(model::kTypeValueFieldKey);
result->map_value.fields[0].value = *[self encodeStringValue:MakeString(@"__vector__")].release();
NSArray<NSNumber *> *vectorArray = vectorValue.array;
__block Message<google_firestore_v1_Value> arrayMessage;
arrayMessage->which_value_type = google_firestore_v1_Value_array_value_tag;
arrayMessage->array_value.values_count = CheckedSize([vectorArray count]);
arrayMessage->array_value.values =
nanopb::MakeArray<google_firestore_v1_Value>(arrayMessage->array_value.values_count);
[vectorArray enumerateObjectsUsingBlock:^(id entry, NSUInteger idx, BOOL *) {
if (![entry isKindOfClass:[NSNumber class]]) {
ThrowInvalidArgument("VectorValues must only contain numeric values.",
context.FieldDescription());
}
// Vector values must always use Double encoding
arrayMessage->array_value.values[idx] = *[self encodeDouble:[entry doubleValue]].release();
}];
result->map_value.fields[1].key = nanopb::CopyBytesArray(model::kVectorValueFieldKey);
result->map_value.fields[1].value = *arrayMessage.release();
return std::move(result);
}
- (Message<google_firestore_v1_Value>)parseArray:(NSArray<id> *)array
context:(ParseContext &&)context {
__block Message<google_firestore_v1_Value> result;
@@ -528,7 +566,9 @@ NS_ASSUME_NONNULL_BEGIN
_databaseID.database_id(), context.FieldDescription());
}
return [self encodeReference:_databaseID key:reference.key];
} else if ([input isKindOfClass:[FIRVectorValue class]]) {
FIRVectorValue *vector = input;
return [self parseVectorValue:vector context:std::move(context)];
} else {
ThrowInvalidArgument("Unsupported type: %s%s", NSStringFromClass([input class]),
context.FieldDescription());

View File

@@ -21,6 +21,7 @@
#include "Firestore/Protos/nanopb/google/firestore/v1/document.nanopb.h"
#include "Firestore/Source/API/FIRDocumentReference+Internal.h"
#include "Firestore/Source/API/FIRFieldValue+Internal.h"
#include "Firestore/Source/API/converters.h"
#include "Firestore/core/include/firebase/firestore/geo_point.h"
#include "Firestore/core/include/firebase/firestore/timestamp.h"
@@ -105,6 +106,8 @@ NS_ASSUME_NONNULL_BEGIN
case TypeOrder::kGeoPoint:
return MakeFIRGeoPoint(
GeoPoint(value.geo_point_value.latitude, value.geo_point_value.longitude));
case TypeOrder::kVector:
return [self convertedVector:value.map_value];
case TypeOrder::kMaxValue:
// It is not possible for users to construct a kMaxValue manually.
break;
@@ -123,6 +126,18 @@ NS_ASSUME_NONNULL_BEGIN
return result;
}
- (FIRVectorValue *)convertedVector:(const google_firestore_v1_MapValue &)mapValue {
for (pb_size_t i = 0; i < mapValue.fields_count; ++i) {
absl::string_view key = MakeStringView(mapValue.fields[i].key);
const google_firestore_v1_Value &value = mapValue.fields[i].value;
if ((0 == key.compare(absl::string_view("value"))) &&
value.which_value_type == google_firestore_v1_Value_array_value_tag) {
return [FIRFieldValue vectorWithArray:[self convertedArray:value.array_value]];
}
}
return [FIRFieldValue vectorWithArray:@[]];
}
- (NSArray<id> *)convertedArray:(const google_firestore_v1_ArrayValue &)arrayValue {
NSMutableArray *result = [NSMutableArray arrayWithCapacity:arrayValue.values_count];
for (pb_size_t i = 0; i < arrayValue.values_count; ++i) {

View File

@@ -14,12 +14,13 @@
* limitations under the License.
*/
#include "Firestore/Source/API/converters.h"
#import <FirebaseCore/FIRTimestamp.h>
#include <utility>
#include "Firestore/Source/API/converters.h"
#import "FIRGeoPoint.h"
#import "FIRTimestamp.h"
#include "Firestore/Source/API/FIRDocumentReference+Internal.h"
#include "Firestore/core/include/firebase/firestore/geo_point.h"