@angular/fire 18.0.0 → 18.0.1-canary.3639e41
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/esm2022/analytics/analytics.module.mjs +5 -5
- package/esm2022/analytics/screen-tracking.service.mjs +4 -4
- package/esm2022/analytics/user-tracking.service.mjs +4 -4
- package/esm2022/app/app.module.mjs +5 -5
- package/esm2022/app-check/app-check.module.mjs +5 -5
- package/esm2022/auth/auth.module.mjs +5 -5
- package/esm2022/auth-guard/auth-guard.mjs +4 -4
- package/esm2022/auth-guard/auth-guard.module.mjs +5 -5
- package/esm2022/compat/analytics/analytics.mjs +4 -4
- package/esm2022/compat/analytics/analytics.module.mjs +5 -5
- package/esm2022/compat/analytics/screen-tracking.service.mjs +4 -4
- package/esm2022/compat/analytics/user-tracking.service.mjs +4 -4
- package/esm2022/compat/auth/auth.mjs +4 -4
- package/esm2022/compat/auth/auth.module.mjs +5 -5
- package/esm2022/compat/auth-guard/auth-guard.mjs +4 -4
- package/esm2022/compat/auth-guard/auth-guard.module.mjs +5 -5
- package/esm2022/compat/database/database.mjs +4 -4
- package/esm2022/compat/database/database.module.mjs +5 -5
- package/esm2022/compat/firebase.app.module.mjs +5 -5
- package/esm2022/compat/firestore/firestore.mjs +4 -4
- package/esm2022/compat/firestore/firestore.module.mjs +5 -5
- package/esm2022/compat/functions/functions.mjs +4 -4
- package/esm2022/compat/functions/functions.module.mjs +5 -5
- package/esm2022/compat/messaging/messaging.mjs +4 -4
- package/esm2022/compat/messaging/messaging.module.mjs +5 -5
- package/esm2022/compat/performance/performance.mjs +4 -4
- package/esm2022/compat/performance/performance.module.mjs +5 -5
- package/esm2022/compat/performance/performance.service.mjs +4 -4
- package/esm2022/compat/remote-config/remote-config.mjs +4 -4
- package/esm2022/compat/remote-config/remote-config.module.mjs +5 -5
- package/esm2022/compat/storage/pipes/storageUrl.pipe.mjs +8 -8
- package/esm2022/compat/storage/storage.mjs +4 -4
- package/esm2022/compat/storage/storage.module.mjs +5 -5
- package/esm2022/database/database.module.mjs +5 -5
- package/esm2022/firestore/firestore.module.mjs +5 -5
- package/esm2022/firestore/lite/lite.module.mjs +5 -5
- package/esm2022/functions/functions.module.mjs +5 -5
- package/esm2022/messaging/messaging.module.mjs +5 -5
- package/esm2022/performance/performance.module.mjs +5 -5
- package/esm2022/remote-config/remote-config.module.mjs +5 -5
- package/esm2022/storage/storage.module.mjs +5 -5
- package/esm2022/vertexai-preview/vertexai.module.mjs +5 -5
- package/esm2022/zones.mjs +4 -4
- package/fesm2022/angular-fire-analytics.mjs +297 -410
- package/fesm2022/angular-fire-analytics.mjs.map +1 -7
- package/fesm2022/angular-fire-app-check.mjs +91 -162
- package/fesm2022/angular-fire-app-check.mjs.map +1 -7
- package/fesm2022/angular-fire-app.mjs +108 -181
- package/fesm2022/angular-fire-app.mjs.map +1 -7
- package/fesm2022/angular-fire-auth-guard.mjs +73 -83
- package/fesm2022/angular-fire-auth-guard.mjs.map +1 -7
- package/fesm2022/angular-fire-auth.mjs +142 -421
- package/fesm2022/angular-fire-auth.mjs.map +1 -7
- package/fesm2022/angular-fire-compat-analytics.mjs +271 -262
- package/fesm2022/angular-fire-compat-analytics.mjs.map +1 -7
- package/fesm2022/angular-fire-compat-auth-guard.mjs +72 -83
- package/fesm2022/angular-fire-compat-auth-guard.mjs.map +1 -7
- package/fesm2022/angular-fire-compat-auth.mjs +214 -215
- package/fesm2022/angular-fire-compat-auth.mjs.map +1 -7
- package/fesm2022/angular-fire-compat-database.mjs +378 -375
- package/fesm2022/angular-fire-compat-database.mjs.map +1 -7
- package/fesm2022/angular-fire-compat-firestore.mjs +677 -537
- package/fesm2022/angular-fire-compat-firestore.mjs.map +1 -7
- package/fesm2022/angular-fire-compat-functions.mjs +94 -98
- package/fesm2022/angular-fire-compat-functions.mjs.map +1 -7
- package/fesm2022/angular-fire-compat-messaging.mjs +107 -107
- package/fesm2022/angular-fire-compat-messaging.mjs.map +1 -7
- package/fesm2022/angular-fire-compat-performance.mjs +152 -158
- package/fesm2022/angular-fire-compat-performance.mjs.map +1 -7
- package/fesm2022/angular-fire-compat-remote-config.mjs +232 -216
- package/fesm2022/angular-fire-compat-remote-config.mjs.map +1 -7
- package/fesm2022/angular-fire-compat-storage.mjs +231 -226
- package/fesm2022/angular-fire-compat-storage.mjs.map +1 -7
- package/fesm2022/angular-fire-compat.mjs +153 -140
- package/fesm2022/angular-fire-compat.mjs.map +1 -7
- package/fesm2022/angular-fire-database.mjs +136 -376
- package/fesm2022/angular-fire-database.mjs.map +1 -7
- package/fesm2022/angular-fire-firestore-lite.mjs +139 -388
- package/fesm2022/angular-fire-firestore-lite.mjs.map +1 -7
- package/fesm2022/angular-fire-firestore.mjs +167 -526
- package/fesm2022/angular-fire-firestore.mjs.map +1 -7
- package/fesm2022/angular-fire-functions.mjs +93 -166
- package/fesm2022/angular-fire-functions.mjs.map +1 -7
- package/fesm2022/angular-fire-messaging.mjs +118 -196
- package/fesm2022/angular-fire-messaging.mjs.map +1 -7
- package/fesm2022/angular-fire-performance.mjs +104 -178
- package/fesm2022/angular-fire-performance.mjs.map +1 -7
- package/fesm2022/angular-fire-remote-config.mjs +132 -254
- package/fesm2022/angular-fire-remote-config.mjs.map +1 -7
- package/fesm2022/angular-fire-storage.mjs +105 -225
- package/fesm2022/angular-fire-storage.mjs.map +1 -7
- package/fesm2022/angular-fire-vertexai-preview.mjs +85 -146
- package/fesm2022/angular-fire-vertexai-preview.mjs.map +1 -7
- package/fesm2022/angular-fire.mjs +213 -183
- package/fesm2022/angular-fire.mjs.map +1 -7
- package/package.json +1 -1
|
@@ -1,446 +1,449 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, PLATFORM_ID, Injectable, Inject, Optional, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/fire';
|
|
4
|
+
import { keepUnstableUntilFirst, VERSION } from '@angular/fire';
|
|
5
|
+
import * as i3 from '@angular/fire/app-check';
|
|
6
|
+
import { ɵfirebaseAppFactory as _firebaseAppFactory, ɵcacheInstance as _cacheInstance, FIREBASE_OPTIONS, FIREBASE_APP_NAME } from '@angular/fire/compat';
|
|
7
|
+
import * as i2 from '@angular/fire/compat/auth';
|
|
8
|
+
import { ɵauthFactory as _authFactory, USE_EMULATOR as USE_EMULATOR$1, SETTINGS, TENANT_ID, LANGUAGE_CODE, USE_DEVICE_LANGUAGE, PERSISTENCE } from '@angular/fire/compat/auth';
|
|
9
|
+
import { map, share, scan, withLatestFrom, skipWhile, switchMap, distinctUntilChanged } from 'rxjs/operators';
|
|
10
|
+
import { Observable, asyncScheduler, merge, of } from 'rxjs';
|
|
11
|
+
import 'firebase/compat/auth';
|
|
12
|
+
import 'firebase/compat/database';
|
|
13
|
+
import firebase from 'firebase/compat/app';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Create an observable from a Database Reference or Database Query.
|
|
17
|
+
* @param ref Database Reference
|
|
18
|
+
* @param event Listen event type ('value', 'added', 'changed', 'removed', 'moved')
|
|
19
|
+
* @param listenType 'on' or 'once'
|
|
20
|
+
* @param scheduler - Rxjs scheduler
|
|
21
|
+
*/
|
|
22
|
+
function fromRef(ref, event, listenType = 'on', scheduler = asyncScheduler) {
|
|
23
|
+
return new Observable(subscriber => {
|
|
24
|
+
let fn = null;
|
|
25
|
+
fn = ref[listenType](event, (snapshot, prevKey) => {
|
|
26
|
+
scheduler.schedule(() => {
|
|
27
|
+
subscriber.next({ snapshot, prevKey });
|
|
28
|
+
});
|
|
29
|
+
if (listenType === 'once') {
|
|
30
|
+
scheduler.schedule(() => subscriber.complete());
|
|
31
|
+
}
|
|
32
|
+
}, err => {
|
|
33
|
+
scheduler.schedule(() => subscriber.error(err));
|
|
34
|
+
});
|
|
35
|
+
if (listenType === 'on') {
|
|
36
|
+
return {
|
|
37
|
+
unsubscribe() {
|
|
38
|
+
if (fn != null) {
|
|
39
|
+
ref.off(event, fn);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
23
43
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
44
|
+
else {
|
|
45
|
+
return {
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
47
|
+
unsubscribe() {
|
|
48
|
+
}
|
|
49
|
+
};
|
|
29
50
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return { type: event, payload: snapshot, prevKey, key };
|
|
39
|
-
}), share());
|
|
51
|
+
}).pipe(map(payload => {
|
|
52
|
+
const { snapshot, prevKey } = payload;
|
|
53
|
+
let key = null;
|
|
54
|
+
if (snapshot.exists()) {
|
|
55
|
+
key = snapshot.key;
|
|
56
|
+
}
|
|
57
|
+
return { type: event, payload: snapshot, prevKey, key };
|
|
58
|
+
}), share());
|
|
40
59
|
}
|
|
41
60
|
|
|
42
|
-
// utils.mjs
|
|
43
61
|
function isString(value) {
|
|
44
|
-
|
|
62
|
+
return typeof value === 'string';
|
|
45
63
|
}
|
|
46
64
|
function isFirebaseDataSnapshot(value) {
|
|
47
|
-
|
|
65
|
+
return typeof value.exportVal === 'function';
|
|
48
66
|
}
|
|
49
67
|
function isNil(obj) {
|
|
50
|
-
|
|
68
|
+
return obj === undefined || obj === null;
|
|
51
69
|
}
|
|
52
70
|
function isFirebaseRef(value) {
|
|
53
|
-
|
|
71
|
+
return typeof value.set === 'function';
|
|
54
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Returns a database reference given a Firebase App and an
|
|
75
|
+
* absolute or relative path.
|
|
76
|
+
* @param database - Firebase Database
|
|
77
|
+
* @param pathRef - Database path, relative or absolute
|
|
78
|
+
*/
|
|
55
79
|
function getRef(database, pathRef) {
|
|
56
|
-
|
|
80
|
+
// if a db ref was passed in, just return it
|
|
81
|
+
return isFirebaseRef(pathRef) ? pathRef
|
|
82
|
+
: database.ref(pathRef);
|
|
57
83
|
}
|
|
58
84
|
function checkOperationCases(item, cases) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
85
|
+
if (isString(item)) {
|
|
86
|
+
return cases.stringCase();
|
|
87
|
+
}
|
|
88
|
+
else if (isFirebaseRef(item)) {
|
|
89
|
+
return cases.firebaseCase();
|
|
90
|
+
}
|
|
91
|
+
else if (isFirebaseDataSnapshot(item)) {
|
|
92
|
+
return cases.snapshotCase();
|
|
93
|
+
}
|
|
94
|
+
throw new Error(`Expects a string, snapshot, or reference. Got: ${typeof item}`);
|
|
67
95
|
}
|
|
68
96
|
|
|
69
|
-
// list/utils.mjs
|
|
70
97
|
function validateEventsArray(events) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
98
|
+
if (isNil(events) || events.length === 0) {
|
|
99
|
+
events = ['child_added', 'child_removed', 'child_changed', 'child_moved'];
|
|
100
|
+
}
|
|
101
|
+
return events;
|
|
75
102
|
}
|
|
76
103
|
|
|
77
|
-
// list/state-changes.mjs
|
|
78
|
-
import { merge } from "rxjs";
|
|
79
104
|
function stateChanges(query, events, scheduler) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
105
|
+
events = validateEventsArray(events);
|
|
106
|
+
const childEvent$ = events.map(event => fromRef(query, event, 'on', scheduler));
|
|
107
|
+
return merge(...childEvent$);
|
|
83
108
|
}
|
|
84
109
|
|
|
85
|
-
// list/audit-trail.mjs
|
|
86
|
-
import { map as map2, scan, skipWhile, withLatestFrom } from "rxjs/operators";
|
|
87
110
|
function auditTrail(query, events, scheduler) {
|
|
88
|
-
|
|
89
|
-
|
|
111
|
+
const auditTrail$ = stateChanges(query, events)
|
|
112
|
+
.pipe(scan((current, action) => [...current, action], []));
|
|
113
|
+
return waitForLoaded(query, auditTrail$, scheduler);
|
|
90
114
|
}
|
|
91
115
|
function loadedData(query, scheduler) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
116
|
+
// Create an observable of loaded values to retrieve the
|
|
117
|
+
// known dataset. This will allow us to know what key to
|
|
118
|
+
// emit the "whole" array at when listening for child events.
|
|
119
|
+
return fromRef(query, 'value', 'on', scheduler)
|
|
120
|
+
.pipe(map(data => {
|
|
121
|
+
// Store the last key in the data set
|
|
122
|
+
let lastKeyToLoad;
|
|
123
|
+
// Loop through loaded dataset to find the last key
|
|
124
|
+
data.payload.forEach(child => {
|
|
125
|
+
lastKeyToLoad = child.key;
|
|
126
|
+
return false;
|
|
127
|
+
});
|
|
128
|
+
// return data set and the current last key loaded
|
|
129
|
+
return { data, lastKeyToLoad };
|
|
130
|
+
}));
|
|
100
131
|
}
|
|
101
132
|
function waitForLoaded(query, action$, scheduler) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
133
|
+
const loaded$ = loadedData(query, scheduler);
|
|
134
|
+
return loaded$
|
|
135
|
+
.pipe(withLatestFrom(action$),
|
|
105
136
|
// Get the latest values from the "loaded" and "child" datasets
|
|
106
137
|
// We can use both datasets to form an array of the latest values.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
138
|
+
map(([loaded, actions]) => {
|
|
139
|
+
// Store the last key in the data set
|
|
140
|
+
const lastKeyToLoad = loaded.lastKeyToLoad;
|
|
141
|
+
// Store all child keys loaded at this point
|
|
142
|
+
const loadedKeys = actions.map(snap => snap.key);
|
|
143
|
+
return { actions, lastKeyToLoad, loadedKeys };
|
|
144
|
+
}),
|
|
112
145
|
// This is the magical part, only emit when the last load key
|
|
113
146
|
// in the dataset has been loaded by a child event. At this point
|
|
114
147
|
// we can assume the dataset is "whole".
|
|
115
|
-
skipWhile(
|
|
148
|
+
skipWhile(meta => meta.loadedKeys.indexOf(meta.lastKeyToLoad) === -1),
|
|
116
149
|
// Pluck off the meta data because the user only cares
|
|
117
150
|
// to iterate through the snapshots
|
|
118
|
-
|
|
119
|
-
);
|
|
151
|
+
map(meta => meta.actions));
|
|
120
152
|
}
|
|
121
153
|
|
|
122
|
-
// list/data-operation.mjs
|
|
123
154
|
function createDataOperationMethod(ref, operation) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
155
|
+
return function dataOperation(item, value) {
|
|
156
|
+
return checkOperationCases(item, {
|
|
157
|
+
stringCase: () => ref.child(item)[operation](value),
|
|
158
|
+
firebaseCase: () => item[operation](value),
|
|
159
|
+
snapshotCase: () => item.ref[operation](value)
|
|
160
|
+
});
|
|
161
|
+
};
|
|
131
162
|
}
|
|
132
163
|
|
|
133
|
-
//
|
|
164
|
+
// TODO(davideast): Find out why TS thinks this returns firebase.Primise
|
|
165
|
+
// instead of Promise.
|
|
134
166
|
function createRemoveMethod(ref) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
167
|
+
return function remove(item) {
|
|
168
|
+
if (!item) {
|
|
169
|
+
return ref.remove();
|
|
170
|
+
}
|
|
171
|
+
return checkOperationCases(item, {
|
|
172
|
+
stringCase: () => ref.child(item).remove(),
|
|
173
|
+
firebaseCase: () => item.remove(),
|
|
174
|
+
snapshotCase: () => item.ref.remove()
|
|
175
|
+
});
|
|
176
|
+
};
|
|
145
177
|
}
|
|
146
178
|
|
|
147
|
-
// list/changes.mjs
|
|
148
|
-
import { merge as merge2, of } from "rxjs";
|
|
149
|
-
import { distinctUntilChanged, scan as scan2, switchMap } from "rxjs/operators";
|
|
150
179
|
function listChanges(ref, events, scheduler) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
180
|
+
return fromRef(ref, 'value', 'once', scheduler).pipe(switchMap(snapshotAction => {
|
|
181
|
+
const childEvent$ = [of(snapshotAction)];
|
|
182
|
+
events.forEach(event => childEvent$.push(fromRef(ref, event, 'on', scheduler)));
|
|
183
|
+
return merge(...childEvent$).pipe(scan(buildView, []));
|
|
184
|
+
}), distinctUntilChanged());
|
|
156
185
|
}
|
|
157
186
|
function positionFor(changes, key) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
187
|
+
const len = changes.length;
|
|
188
|
+
for (let i = 0; i < len; i++) {
|
|
189
|
+
if (changes[i].payload.key === key) {
|
|
190
|
+
return i;
|
|
191
|
+
}
|
|
162
192
|
}
|
|
163
|
-
|
|
164
|
-
return -1;
|
|
193
|
+
return -1;
|
|
165
194
|
}
|
|
166
195
|
function positionAfter(changes, prevKey) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
196
|
+
if (isNil(prevKey)) {
|
|
197
|
+
return 0;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const i = positionFor(changes, prevKey);
|
|
201
|
+
if (i === -1) {
|
|
202
|
+
return changes.length;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
return i + 1;
|
|
206
|
+
}
|
|
175
207
|
}
|
|
176
|
-
}
|
|
177
208
|
}
|
|
178
209
|
function buildView(current, action) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
210
|
+
const { payload, prevKey, key } = action;
|
|
211
|
+
const currentKeyPosition = positionFor(current, key);
|
|
212
|
+
const afterPreviousKeyPosition = positionAfter(current, prevKey);
|
|
213
|
+
switch (action.type) {
|
|
214
|
+
case 'value':
|
|
215
|
+
if (action.payload?.exists()) {
|
|
216
|
+
let prevKey = null;
|
|
217
|
+
action.payload.forEach(payload => {
|
|
218
|
+
const action = { payload, type: 'value', prevKey, key: payload.key };
|
|
219
|
+
prevKey = payload.key;
|
|
220
|
+
current = [...current, action];
|
|
221
|
+
return false;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
return current;
|
|
225
|
+
case 'child_added':
|
|
226
|
+
if (currentKeyPosition > -1) {
|
|
227
|
+
// check that the previouskey is what we expect, else reorder
|
|
228
|
+
const previous = current[currentKeyPosition - 1];
|
|
229
|
+
if ((previous?.key || null) !== prevKey) {
|
|
230
|
+
current = current.filter(x => x.payload.key !== payload.key);
|
|
231
|
+
current.splice(afterPreviousKeyPosition, 0, action);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else if (prevKey == null) {
|
|
235
|
+
return [action, ...current];
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
current = current.slice();
|
|
239
|
+
current.splice(afterPreviousKeyPosition, 0, action);
|
|
240
|
+
}
|
|
241
|
+
return current;
|
|
242
|
+
case 'child_removed':
|
|
243
|
+
return current.filter(x => x.payload.key !== payload.key);
|
|
244
|
+
case 'child_changed':
|
|
245
|
+
return current.map(x => x.payload.key === key ? action : x);
|
|
246
|
+
case 'child_moved':
|
|
247
|
+
if (currentKeyPosition > -1) {
|
|
248
|
+
const data = current.splice(currentKeyPosition, 1)[0];
|
|
249
|
+
current = current.slice();
|
|
250
|
+
current.splice(afterPreviousKeyPosition, 0, data);
|
|
251
|
+
return current;
|
|
252
|
+
}
|
|
253
|
+
return current;
|
|
254
|
+
// default will also remove null results
|
|
255
|
+
default:
|
|
256
|
+
return current;
|
|
257
|
+
}
|
|
223
258
|
}
|
|
224
259
|
|
|
225
|
-
// list/snapshot-changes.mjs
|
|
226
260
|
function snapshotChanges(query, events, scheduler) {
|
|
227
|
-
|
|
228
|
-
|
|
261
|
+
events = validateEventsArray(events);
|
|
262
|
+
return listChanges(query, events, scheduler);
|
|
229
263
|
}
|
|
230
264
|
|
|
231
|
-
// list/create-reference.mjs
|
|
232
|
-
import { keepUnstableUntilFirst } from "@angular/fire";
|
|
233
|
-
import { map as map3 } from "rxjs/operators";
|
|
234
265
|
function createListReference(query, afDatabase) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
266
|
+
const outsideAngularScheduler = afDatabase.schedulers.outsideAngular;
|
|
267
|
+
const refInZone = afDatabase.schedulers.ngZone.run(() => query.ref);
|
|
268
|
+
return {
|
|
269
|
+
query,
|
|
270
|
+
update: createDataOperationMethod(refInZone, 'update'),
|
|
271
|
+
set: createDataOperationMethod(refInZone, 'set'),
|
|
272
|
+
push: (data) => refInZone.push(data),
|
|
273
|
+
remove: createRemoveMethod(refInZone),
|
|
274
|
+
snapshotChanges(events) {
|
|
275
|
+
return snapshotChanges(query, events, outsideAngularScheduler).pipe(keepUnstableUntilFirst);
|
|
276
|
+
},
|
|
277
|
+
stateChanges(events) {
|
|
278
|
+
return stateChanges(query, events, outsideAngularScheduler).pipe(keepUnstableUntilFirst);
|
|
279
|
+
},
|
|
280
|
+
auditTrail(events) {
|
|
281
|
+
return auditTrail(query, events, outsideAngularScheduler).pipe(keepUnstableUntilFirst);
|
|
282
|
+
},
|
|
283
|
+
valueChanges(events, options) {
|
|
284
|
+
const snapshotChanges$ = snapshotChanges(query, events, outsideAngularScheduler);
|
|
285
|
+
return snapshotChanges$.pipe(map(actions => actions.map(a => {
|
|
286
|
+
if (options && options.idField) {
|
|
287
|
+
return {
|
|
288
|
+
...a.payload.val(),
|
|
289
|
+
...{
|
|
290
|
+
[options.idField]: a.key
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
return a.payload.val();
|
|
296
|
+
}
|
|
297
|
+
})), keepUnstableUntilFirst);
|
|
264
298
|
}
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
};
|
|
299
|
+
};
|
|
268
300
|
}
|
|
269
301
|
|
|
270
|
-
// object/snapshot-changes.mjs
|
|
271
302
|
function createObjectSnapshotChanges(query, scheduler) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
303
|
+
return function snapshotChanges() {
|
|
304
|
+
return fromRef(query, 'value', 'on', scheduler);
|
|
305
|
+
};
|
|
275
306
|
}
|
|
276
307
|
|
|
277
|
-
// object/create-reference.mjs
|
|
278
|
-
import { keepUnstableUntilFirst as keepUnstableUntilFirst2 } from "@angular/fire";
|
|
279
|
-
import { map as map4 } from "rxjs/operators";
|
|
280
308
|
function createObjectReference(query, afDatabase) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
},
|
|
295
|
-
valueChanges() {
|
|
296
|
-
const snapshotChanges$ = createObjectSnapshotChanges(query, afDatabase.schedulers.outsideAngular)();
|
|
297
|
-
return snapshotChanges$.pipe(keepUnstableUntilFirst2, map4((action) => action.payload.exists() ? action.payload.val() : null));
|
|
298
|
-
}
|
|
299
|
-
};
|
|
309
|
+
return {
|
|
310
|
+
query,
|
|
311
|
+
snapshotChanges() {
|
|
312
|
+
return createObjectSnapshotChanges(query, afDatabase.schedulers.outsideAngular)().pipe(keepUnstableUntilFirst);
|
|
313
|
+
},
|
|
314
|
+
update(data) { return query.ref.update(data); },
|
|
315
|
+
set(data) { return query.ref.set(data); },
|
|
316
|
+
remove() { return query.ref.remove(); },
|
|
317
|
+
valueChanges() {
|
|
318
|
+
const snapshotChanges$ = createObjectSnapshotChanges(query, afDatabase.schedulers.outsideAngular)();
|
|
319
|
+
return snapshotChanges$.pipe(keepUnstableUntilFirst, map(action => action.payload.exists() ? action.payload.val() : null));
|
|
320
|
+
},
|
|
321
|
+
};
|
|
300
322
|
}
|
|
301
323
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
324
|
+
const URL = new InjectionToken('angularfire2.realtimeDatabaseURL');
|
|
325
|
+
const USE_EMULATOR = new InjectionToken('angularfire2.database.use-emulator');
|
|
326
|
+
class AngularFireDatabase {
|
|
327
|
+
schedulers;
|
|
328
|
+
database;
|
|
329
|
+
constructor(options, name, databaseURL,
|
|
330
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
331
|
+
platformId, zone, schedulers, _useEmulator, // tuple isn't working here
|
|
332
|
+
auth, useAuthEmulator, authSettings, // can't use firebase.auth.AuthSettings here
|
|
333
|
+
tenantId, languageCode, useDeviceLanguage, persistence, _appCheckInstances) {
|
|
334
|
+
this.schedulers = schedulers;
|
|
335
|
+
const useEmulator = _useEmulator;
|
|
336
|
+
const app = _firebaseAppFactory(options, zone, name);
|
|
337
|
+
if (auth) {
|
|
338
|
+
_authFactory(app, zone, useAuthEmulator, tenantId, languageCode, useDeviceLanguage, authSettings, persistence);
|
|
339
|
+
}
|
|
340
|
+
this.database = _cacheInstance(`${app.name}.database.${databaseURL}`, 'AngularFireDatabase', app.name, () => {
|
|
341
|
+
const database = zone.runOutsideAngular(() => app.database(databaseURL || undefined));
|
|
342
|
+
if (useEmulator) {
|
|
343
|
+
database.useEmulator(...useEmulator);
|
|
344
|
+
}
|
|
345
|
+
return database;
|
|
346
|
+
}, [useEmulator]);
|
|
347
|
+
}
|
|
348
|
+
list(pathOrRef, queryFn) {
|
|
349
|
+
const ref = this.schedulers.ngZone.runOutsideAngular(() => getRef(this.database, pathOrRef));
|
|
350
|
+
let query = ref;
|
|
351
|
+
if (queryFn) {
|
|
352
|
+
query = queryFn(ref);
|
|
353
|
+
}
|
|
354
|
+
return createListReference(query, this);
|
|
355
|
+
}
|
|
356
|
+
object(pathOrRef) {
|
|
357
|
+
const ref = this.schedulers.ngZone.runOutsideAngular(() => getRef(this.database, pathOrRef));
|
|
358
|
+
return createObjectReference(ref, this);
|
|
325
359
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
database.useEmulator(...useEmulator);
|
|
330
|
-
}
|
|
331
|
-
return database;
|
|
332
|
-
}, [useEmulator]);
|
|
333
|
-
}
|
|
334
|
-
list(pathOrRef, queryFn) {
|
|
335
|
-
const ref = this.schedulers.ngZone.runOutsideAngular(() => getRef(this.database, pathOrRef));
|
|
336
|
-
let query = ref;
|
|
337
|
-
if (queryFn) {
|
|
338
|
-
query = queryFn(ref);
|
|
360
|
+
createPushId() {
|
|
361
|
+
const ref = this.schedulers.ngZone.runOutsideAngular(() => this.database.ref());
|
|
362
|
+
return ref.push().key;
|
|
339
363
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}] }, { type:
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
}] }, { type:
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}, {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}] }, { type:
|
|
382
|
-
|
|
383
|
-
}, {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}] }, { type:
|
|
387
|
-
|
|
388
|
-
}, {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}] }, { type:
|
|
392
|
-
|
|
393
|
-
}, {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}] }, { type:
|
|
397
|
-
|
|
398
|
-
}, {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}] }, { type:
|
|
402
|
-
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
364
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: AngularFireDatabase, deps: [{ token: FIREBASE_OPTIONS }, { token: FIREBASE_APP_NAME, optional: true }, { token: URL, optional: true }, { token: PLATFORM_ID }, { token: i0.NgZone }, { token: i1.ɵAngularFireSchedulers }, { token: USE_EMULATOR, optional: true }, { token: i2.AngularFireAuth, optional: true }, { token: USE_EMULATOR$1, optional: true }, { token: SETTINGS, optional: true }, { token: TENANT_ID, optional: true }, { token: LANGUAGE_CODE, optional: true }, { token: USE_DEVICE_LANGUAGE, optional: true }, { token: PERSISTENCE, optional: true }, { token: i3.AppCheckInstances, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
365
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: AngularFireDatabase, providedIn: 'any' });
|
|
366
|
+
}
|
|
367
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: AngularFireDatabase, decorators: [{
|
|
368
|
+
type: Injectable,
|
|
369
|
+
args: [{
|
|
370
|
+
providedIn: 'any'
|
|
371
|
+
}]
|
|
372
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
373
|
+
type: Inject,
|
|
374
|
+
args: [FIREBASE_OPTIONS]
|
|
375
|
+
}] }, { type: undefined, decorators: [{
|
|
376
|
+
type: Optional
|
|
377
|
+
}, {
|
|
378
|
+
type: Inject,
|
|
379
|
+
args: [FIREBASE_APP_NAME]
|
|
380
|
+
}] }, { type: undefined, decorators: [{
|
|
381
|
+
type: Optional
|
|
382
|
+
}, {
|
|
383
|
+
type: Inject,
|
|
384
|
+
args: [URL]
|
|
385
|
+
}] }, { type: Object, decorators: [{
|
|
386
|
+
type: Inject,
|
|
387
|
+
args: [PLATFORM_ID]
|
|
388
|
+
}] }, { type: i0.NgZone }, { type: i1.ɵAngularFireSchedulers }, { type: undefined, decorators: [{
|
|
389
|
+
type: Optional
|
|
390
|
+
}, {
|
|
391
|
+
type: Inject,
|
|
392
|
+
args: [USE_EMULATOR]
|
|
393
|
+
}] }, { type: i2.AngularFireAuth, decorators: [{
|
|
394
|
+
type: Optional
|
|
395
|
+
}] }, { type: undefined, decorators: [{
|
|
396
|
+
type: Optional
|
|
397
|
+
}, {
|
|
398
|
+
type: Inject,
|
|
399
|
+
args: [USE_EMULATOR$1]
|
|
400
|
+
}] }, { type: undefined, decorators: [{
|
|
401
|
+
type: Optional
|
|
402
|
+
}, {
|
|
403
|
+
type: Inject,
|
|
404
|
+
args: [SETTINGS]
|
|
405
|
+
}] }, { type: undefined, decorators: [{
|
|
406
|
+
type: Optional
|
|
407
|
+
}, {
|
|
408
|
+
type: Inject,
|
|
409
|
+
args: [TENANT_ID]
|
|
410
|
+
}] }, { type: undefined, decorators: [{
|
|
411
|
+
type: Optional
|
|
412
|
+
}, {
|
|
413
|
+
type: Inject,
|
|
414
|
+
args: [LANGUAGE_CODE]
|
|
415
|
+
}] }, { type: undefined, decorators: [{
|
|
416
|
+
type: Optional
|
|
417
|
+
}, {
|
|
418
|
+
type: Inject,
|
|
419
|
+
args: [USE_DEVICE_LANGUAGE]
|
|
420
|
+
}] }, { type: undefined, decorators: [{
|
|
421
|
+
type: Optional
|
|
422
|
+
}, {
|
|
423
|
+
type: Inject,
|
|
424
|
+
args: [PERSISTENCE]
|
|
425
|
+
}] }, { type: i3.AppCheckInstances, decorators: [{
|
|
426
|
+
type: Optional
|
|
427
|
+
}] }] });
|
|
428
|
+
|
|
429
|
+
class AngularFireDatabaseModule {
|
|
430
|
+
constructor() {
|
|
431
|
+
firebase.registerVersion('angularfire', VERSION.full, 'rtdb-compat');
|
|
432
|
+
}
|
|
433
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: AngularFireDatabaseModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
434
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.0", ngImport: i0, type: AngularFireDatabaseModule });
|
|
435
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: AngularFireDatabaseModule, providers: [AngularFireDatabase] });
|
|
436
|
+
}
|
|
437
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0", ngImport: i0, type: AngularFireDatabaseModule, decorators: [{
|
|
438
|
+
type: NgModule,
|
|
439
|
+
args: [{
|
|
440
|
+
providers: [AngularFireDatabase]
|
|
441
|
+
}]
|
|
442
|
+
}], ctorParameters: () => [] });
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Generated bundle index. Do not edit.
|
|
446
|
+
*/
|
|
414
447
|
|
|
415
|
-
|
|
416
|
-
import { NgModule } from "@angular/core";
|
|
417
|
-
import { VERSION } from "@angular/fire";
|
|
418
|
-
import firebase from "firebase/compat/app";
|
|
419
|
-
import * as i02 from "@angular/core";
|
|
420
|
-
var AngularFireDatabaseModule = class _AngularFireDatabaseModule {
|
|
421
|
-
constructor() {
|
|
422
|
-
firebase.registerVersion("angularfire", VERSION.full, "rtdb-compat");
|
|
423
|
-
}
|
|
424
|
-
static ɵfac = i02.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-rc.3", ngImport: i02, type: _AngularFireDatabaseModule, deps: [], target: i02.ɵɵFactoryTarget.NgModule });
|
|
425
|
-
static ɵmod = i02.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.0-rc.3", ngImport: i02, type: _AngularFireDatabaseModule });
|
|
426
|
-
static ɵinj = i02.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.0-rc.3", ngImport: i02, type: _AngularFireDatabaseModule, providers: [AngularFireDatabase] });
|
|
427
|
-
};
|
|
428
|
-
i02.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-rc.3", ngImport: i02, type: AngularFireDatabaseModule, decorators: [{
|
|
429
|
-
type: NgModule,
|
|
430
|
-
args: [{
|
|
431
|
-
providers: [AngularFireDatabase]
|
|
432
|
-
}]
|
|
433
|
-
}], ctorParameters: () => [] });
|
|
434
|
-
export {
|
|
435
|
-
AngularFireDatabase,
|
|
436
|
-
AngularFireDatabaseModule,
|
|
437
|
-
URL,
|
|
438
|
-
USE_EMULATOR,
|
|
439
|
-
auditTrail,
|
|
440
|
-
createListReference,
|
|
441
|
-
fromRef,
|
|
442
|
-
listChanges,
|
|
443
|
-
snapshotChanges,
|
|
444
|
-
stateChanges
|
|
445
|
-
};
|
|
448
|
+
export { AngularFireDatabase, AngularFireDatabaseModule, URL, USE_EMULATOR, auditTrail, createListReference, fromRef, listChanges, snapshotChanges, stateChanges };
|
|
446
449
|
//# sourceMappingURL=angular-fire-compat-database.mjs.map
|