@angular/fire 17.1.0 → 18.0.0-canary.c866d08

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