@o3r/mobile 15.3.0-prerelease.16 → 15.3.0-prerelease.17
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/fesm2022/o3r-mobile.mjs +220 -208
- package/fesm2022/o3r-mobile.mjs.map +1 -1
- package/package.json +6 -6
- package/types/o3r-mobile.d.ts +51 -59
- package/types/o3r-mobile.d.ts.map +1 -1
package/fesm2022/o3r-mobile.mjs
CHANGED
|
@@ -1,218 +1,230 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import { takeUntilDestroyed } from
|
|
4
|
-
import { Browser } from
|
|
5
|
-
import { fromEvent } from
|
|
6
|
-
import { Device } from
|
|
7
|
-
import { Store, StoreModule } from
|
|
8
|
-
import { LoggerService, provideLogger } from
|
|
9
|
-
import {
|
|
10
|
-
import { Preferences } from
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns the capacitor platform
|
|
14
|
-
*/
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { DestroyRef, Injectable, InjectionToken, NgModule, inject, makeEnvironmentProviders } from "@angular/core";
|
|
3
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
4
|
+
import { Browser } from "@capacitor/browser";
|
|
5
|
+
import { fromEvent } from "rxjs";
|
|
6
|
+
import { Device } from "@capacitor/device";
|
|
7
|
+
import { Store, StoreModule } from "@ngrx/store";
|
|
8
|
+
import { LoggerService, provideLogger } from "@o3r/logger";
|
|
9
|
+
import { dateReviver, isLocalStorageConfig, isSerializer, rehydrateAction } from "@o3r/store-sync";
|
|
10
|
+
import { Preferences } from "@capacitor/preferences";
|
|
15
11
|
async function getCapacitorPlatform() {
|
|
16
|
-
|
|
17
|
-
return info.platform;
|
|
12
|
+
return (await Device.getInfo()).platform;
|
|
18
13
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Returns true if in a capacitor context (mobile app) or false for web
|
|
21
|
-
*/
|
|
22
14
|
async function isCapacitorContext() {
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
const platform = await getCapacitorPlatform();
|
|
16
|
+
return platform === "ios" || platform === "android";
|
|
25
17
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Returns the baseUrl that can be used depending on the platform
|
|
28
|
-
*/
|
|
29
18
|
async function getBaseUrl() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
case ('android'): {
|
|
36
|
-
return 'http://localhost';
|
|
37
|
-
}
|
|
38
|
-
default: {
|
|
39
|
-
return window.location.href;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
class CapacitorTargetService {
|
|
45
|
-
constructor() {
|
|
46
|
-
this.destroyRef = inject(DestroyRef);
|
|
47
|
-
this.hijackDone = false;
|
|
48
|
-
}
|
|
49
|
-
async openInCapacitorBrowser(element, event) {
|
|
50
|
-
if (await isCapacitorContext() && element instanceof Element) {
|
|
51
|
-
if (element.tagName === 'A') {
|
|
52
|
-
const url = element.getAttribute('href');
|
|
53
|
-
if (element.getAttribute('target') === '_blank' && url) {
|
|
54
|
-
event.preventDefault();
|
|
55
|
-
await Browser.open({ url, presentationStyle: 'popover' });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
await this.openInCapacitorBrowser(element.parentElement, event);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Method called for 'hijacking' the click event on <a> tags with target _blank attribute.
|
|
65
|
-
* Instead of the default action, it will open the URL using the CapacitorJS Browser plugin.
|
|
66
|
-
*/
|
|
67
|
-
hijackClick() {
|
|
68
|
-
if (!this.hijackDone) {
|
|
69
|
-
fromEvent(document, 'click').pipe(takeUntilDestroyed(this.destroyRef)).subscribe(async (event) => {
|
|
70
|
-
const element = event.target;
|
|
71
|
-
await this.openInCapacitorBrowser(element, event);
|
|
72
|
-
});
|
|
73
|
-
this.hijackDone = true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.3", ngImport: i0, type: CapacitorTargetService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
77
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.3", ngImport: i0, type: CapacitorTargetService, providedIn: 'root' }); }
|
|
19
|
+
switch (await getCapacitorPlatform()) {
|
|
20
|
+
case "ios": return "capacitor://localhost";
|
|
21
|
+
case "android": return "http://localhost";
|
|
22
|
+
default: return window.location.href;
|
|
23
|
+
}
|
|
78
24
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
25
|
+
var CapacitorTargetService = class CapacitorTargetService {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.destroyRef = inject(DestroyRef);
|
|
28
|
+
this.hijackDone = false;
|
|
29
|
+
}
|
|
30
|
+
async openInCapacitorBrowser(element, event) {
|
|
31
|
+
if (await isCapacitorContext() && element instanceof Element) {
|
|
32
|
+
if (element.tagName === "A") {
|
|
33
|
+
const url = element.getAttribute("href");
|
|
34
|
+
if (element.getAttribute("target") === "_blank" && url) {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
await Browser.open({
|
|
37
|
+
url,
|
|
38
|
+
presentationStyle: "popover"
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
} else await this.openInCapacitorBrowser(element.parentElement, event);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
hijackClick() {
|
|
45
|
+
if (!this.hijackDone) {
|
|
46
|
+
fromEvent(document, "click").pipe(takeUntilDestroyed(this.destroyRef)).subscribe(async (event) => {
|
|
47
|
+
const element = event.target;
|
|
48
|
+
await this.openInCapacitorBrowser(element, event);
|
|
49
|
+
});
|
|
50
|
+
this.hijackDone = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
static {
|
|
54
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
55
|
+
minVersion: "12.0.0",
|
|
56
|
+
version: "22.2.3",
|
|
57
|
+
ngImport: i0,
|
|
58
|
+
type: CapacitorTargetService,
|
|
59
|
+
deps: [],
|
|
60
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
static {
|
|
64
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
65
|
+
minVersion: "12.0.0",
|
|
66
|
+
version: "22.2.3",
|
|
67
|
+
ngImport: i0,
|
|
68
|
+
type: CapacitorTargetService,
|
|
69
|
+
providedIn: "root"
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
74
|
+
minVersion: "12.0.0",
|
|
75
|
+
version: "22.2.3",
|
|
76
|
+
ngImport: i0,
|
|
77
|
+
type: CapacitorTargetService,
|
|
78
|
+
decorators: [{
|
|
79
|
+
type: Injectable,
|
|
80
|
+
args: [{ providedIn: "root" }]
|
|
81
|
+
}]
|
|
82
|
+
});
|
|
83
|
+
const STORAGE_SYNC_OPTIONS = new InjectionToken("STORAGE_SYNC_OPTIONS");
|
|
90
84
|
const noopDeserializer = (raw) => raw;
|
|
91
|
-
class CapacitorRehydrater {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
85
|
+
var CapacitorRehydrater = class CapacitorRehydrater {
|
|
86
|
+
constructor() {
|
|
87
|
+
this.store = inject(Store);
|
|
88
|
+
this.logger = inject(LoggerService);
|
|
89
|
+
const options = inject(STORAGE_SYNC_OPTIONS);
|
|
90
|
+
this.options = {
|
|
91
|
+
keys: [],
|
|
92
|
+
...options
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async rehydrate() {
|
|
96
|
+
if (isLocalStorageConfig(this.options)) {
|
|
97
|
+
this.logger.warn("A non-async storage is used, rehydration is not supported");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const storageCalls = this.options.keys.map(async (key) => {
|
|
101
|
+
const storeName = Object.keys(key)[0];
|
|
102
|
+
const storeSynchronizer = key[storeName];
|
|
103
|
+
let reviver = this.options.restoreDates ? dateReviver : void 0;
|
|
104
|
+
let deserialize = noopDeserializer;
|
|
105
|
+
if (isSerializer(storeSynchronizer)) {
|
|
106
|
+
if (storeSynchronizer.reviver) reviver = storeSynchronizer.reviver;
|
|
107
|
+
if (storeSynchronizer.deserialize) deserialize = storeSynchronizer.deserialize;
|
|
108
|
+
}
|
|
109
|
+
const stateSlice = await this.options.storage.getItem(this.options.storageKeySerializer ? this.options.storageKeySerializer(storeName) : storeName);
|
|
110
|
+
if (stateSlice) {
|
|
111
|
+
const isObjectRegex = /{|\[/;
|
|
112
|
+
let raw = stateSlice;
|
|
113
|
+
if (stateSlice === "null" || stateSlice === "true" || stateSlice === "false" || isObjectRegex.test(stateSlice.charAt(0))) raw = JSON.parse(stateSlice, reviver);
|
|
114
|
+
return { [storeName]: deserialize(raw) };
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
const result = await Promise.all(storageCalls);
|
|
118
|
+
this.store.dispatch(rehydrateAction({ payload: result.reduce((acc, store) => ({
|
|
119
|
+
...acc,
|
|
120
|
+
...store
|
|
121
|
+
}), {}) }));
|
|
122
|
+
}
|
|
123
|
+
static {
|
|
124
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
125
|
+
minVersion: "12.0.0",
|
|
126
|
+
version: "22.2.3",
|
|
127
|
+
ngImport: i0,
|
|
128
|
+
type: CapacitorRehydrater,
|
|
129
|
+
deps: [],
|
|
130
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
static {
|
|
134
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
135
|
+
minVersion: "12.0.0",
|
|
136
|
+
version: "22.2.3",
|
|
137
|
+
ngImport: i0,
|
|
138
|
+
type: CapacitorRehydrater
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
143
|
+
minVersion: "12.0.0",
|
|
144
|
+
version: "22.2.3",
|
|
145
|
+
ngImport: i0,
|
|
146
|
+
type: CapacitorRehydrater,
|
|
147
|
+
decorators: [{ type: Injectable }],
|
|
148
|
+
ctorParameters: () => []
|
|
149
|
+
});
|
|
150
|
+
var CapacitorRehydraterModule = class CapacitorRehydraterModule {
|
|
151
|
+
static forRoot(options) {
|
|
152
|
+
return {
|
|
153
|
+
ngModule: CapacitorRehydraterModule,
|
|
154
|
+
providers: [provideLogger(), {
|
|
155
|
+
provide: STORAGE_SYNC_OPTIONS,
|
|
156
|
+
useValue: options
|
|
157
|
+
}]
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
static {
|
|
161
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
162
|
+
minVersion: "12.0.0",
|
|
163
|
+
version: "22.2.3",
|
|
164
|
+
ngImport: i0,
|
|
165
|
+
type: CapacitorRehydraterModule,
|
|
166
|
+
deps: [],
|
|
167
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
static {
|
|
171
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
172
|
+
minVersion: "14.0.0",
|
|
173
|
+
version: "22.2.3",
|
|
174
|
+
ngImport: i0,
|
|
175
|
+
type: CapacitorRehydraterModule,
|
|
176
|
+
imports: [StoreModule]
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
static {
|
|
180
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
181
|
+
minVersion: "12.0.0",
|
|
182
|
+
version: "22.2.3",
|
|
183
|
+
ngImport: i0,
|
|
184
|
+
type: CapacitorRehydraterModule,
|
|
185
|
+
providers: [CapacitorRehydrater],
|
|
186
|
+
imports: [StoreModule]
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
191
|
+
minVersion: "12.0.0",
|
|
192
|
+
version: "22.2.3",
|
|
193
|
+
ngImport: i0,
|
|
194
|
+
type: CapacitorRehydraterModule,
|
|
195
|
+
decorators: [{
|
|
196
|
+
type: NgModule,
|
|
197
|
+
args: [{
|
|
198
|
+
imports: [StoreModule],
|
|
199
|
+
providers: [CapacitorRehydrater]
|
|
200
|
+
}]
|
|
201
|
+
}]
|
|
202
|
+
});
|
|
180
203
|
function provideCapacitorRehydrater(options) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
* Capacitor storage
|
|
190
|
-
*/
|
|
191
|
-
class OtterCapacitorStorage {
|
|
192
|
-
/**
|
|
193
|
-
* @inheritdoc
|
|
194
|
-
*/
|
|
195
|
-
removeItem(key) {
|
|
196
|
-
void Preferences.remove({ key });
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* @inheritdoc
|
|
200
|
-
*/
|
|
201
|
-
setItem(key, value) {
|
|
202
|
-
void Preferences.set({ key, value });
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* @inheritdoc
|
|
206
|
-
*/
|
|
207
|
-
async getItem(key) {
|
|
208
|
-
const { value } = await Preferences.get({ key });
|
|
209
|
-
return value;
|
|
210
|
-
}
|
|
204
|
+
return makeEnvironmentProviders([
|
|
205
|
+
provideLogger(),
|
|
206
|
+
{
|
|
207
|
+
provide: STORAGE_SYNC_OPTIONS,
|
|
208
|
+
useValue: options
|
|
209
|
+
},
|
|
210
|
+
CapacitorRehydrater
|
|
211
|
+
]);
|
|
211
212
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
var OtterCapacitorStorage = class {
|
|
214
|
+
removeItem(key) {
|
|
215
|
+
Preferences.remove({ key });
|
|
216
|
+
}
|
|
217
|
+
setItem(key, value) {
|
|
218
|
+
Preferences.set({
|
|
219
|
+
key,
|
|
220
|
+
value
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
async getItem(key) {
|
|
224
|
+
const { value } = await Preferences.get({ key });
|
|
225
|
+
return value;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
217
228
|
export { CapacitorRehydrater, CapacitorRehydraterModule, CapacitorTargetService, OtterCapacitorStorage, STORAGE_SYNC_OPTIONS, getBaseUrl, getCapacitorPlatform, isCapacitorContext, provideCapacitorRehydrater };
|
|
218
|
-
|
|
229
|
+
|
|
230
|
+
//# sourceMappingURL=o3r-mobile.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o3r-mobile.mjs","sources":["../../src/capacitor/helpers.ts","../../src/capacitor/capacitor-target-service.ts","../../src/capacitor/storage/rehydrater.ts","../../src/capacitor/storage/rehydrater-module.ts","../../src/capacitor/storage/storage.ts","../../src/o3r-mobile.ts"],"sourcesContent":["import {\n Device,\n} from '@capacitor/device';\n\n/**\n * Type for the 3 capacitor platforms\n */\nexport type CapacitorPlatforms = 'ios' | 'android' | 'web';\n\n/**\n * Returns the capacitor platform\n */\nexport async function getCapacitorPlatform(): Promise<CapacitorPlatforms> {\n const info = await Device.getInfo();\n return info.platform;\n}\n\n/**\n * Returns true if in a capacitor context (mobile app) or false for web\n */\nexport async function isCapacitorContext(): Promise<boolean> {\n const platform = await getCapacitorPlatform();\n return (platform === 'ios') || (platform === 'android');\n}\n\n/**\n * Returns the baseUrl that can be used depending on the platform\n */\nexport async function getBaseUrl(): Promise<string> {\n const platform = await getCapacitorPlatform();\n switch (platform) {\n case ('ios'): {\n return 'capacitor://localhost';\n }\n case ('android'): {\n return 'http://localhost';\n }\n default: {\n return window.location.href;\n }\n }\n}\n","import {\n DestroyRef,\n inject,\n Injectable,\n} from '@angular/core';\nimport {\n takeUntilDestroyed,\n} from '@angular/core/rxjs-interop';\nimport {\n Browser,\n} from '@capacitor/browser';\nimport {\n fromEvent,\n} from 'rxjs';\nimport {\n isCapacitorContext,\n} from './helpers';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class CapacitorTargetService {\n private readonly destroyRef = inject(DestroyRef);\n private hijackDone = false;\n\n private async openInCapacitorBrowser(element: EventTarget | null, event: Event) {\n if (await isCapacitorContext() && element instanceof Element) {\n if (element.tagName === 'A') {\n const url = element.getAttribute('href');\n if (element.getAttribute('target') === '_blank' && url) {\n event.preventDefault();\n await Browser.open({ url, presentationStyle: 'popover' });\n }\n } else {\n await this.openInCapacitorBrowser(element.parentElement, event);\n }\n }\n }\n\n /**\n * Method called for 'hijacking' the click event on <a> tags with target _blank attribute.\n * Instead of the default action, it will open the URL using the CapacitorJS Browser plugin.\n */\n public hijackClick(): void {\n if (!this.hijackDone) {\n fromEvent(document, 'click').pipe(takeUntilDestroyed(this.destroyRef)).subscribe(async (event) => {\n const element: EventTarget | null = event.target;\n await this.openInCapacitorBrowser(element, event);\n });\n this.hijackDone = true;\n }\n }\n}\n","import {\n inject,\n Injectable,\n InjectionToken,\n} from '@angular/core';\nimport {\n Store,\n} from '@ngrx/store';\nimport {\n LoggerService,\n} from '@o3r/logger';\nimport {\n dateReviver,\n isLocalStorageConfig,\n isSerializer,\n rehydrateAction,\n StorageSyncOptions,\n} from '@o3r/store-sync';\n\n/**\n * Injection token for the storage sync options\n */\nexport const STORAGE_SYNC_OPTIONS = new InjectionToken<Partial<StorageSyncOptions>>('STORAGE_SYNC_OPTIONS');\n\nconst noopDeserializer = (raw: string) => raw;\n\n@Injectable()\nexport class CapacitorRehydrater {\n private readonly store = inject<Store<any>>(Store);\n private readonly logger = inject(LoggerService);\n\n private readonly options: StorageSyncOptions;\n constructor() {\n const options = inject<Partial<StorageSyncOptions>>(STORAGE_SYNC_OPTIONS);\n\n this.options = { keys: [], ...options };\n }\n\n /**\n * Dispatch an action to rehydrate the store with the data from the storage\n */\n public async rehydrate() {\n if (isLocalStorageConfig(this.options)) {\n this.logger.warn('A non-async storage is used, rehydration is not supported');\n return;\n }\n const storageCalls: Promise<Record<string, any> | undefined>[] = this.options.keys\n .map(async (key) => {\n const storeName = Object.keys(key)[0];\n const storeSynchronizer = (key as any)[storeName];\n let reviver = this.options.restoreDates ? dateReviver : undefined;\n let deserialize = noopDeserializer;\n\n if (isSerializer(storeSynchronizer)) {\n if (storeSynchronizer.reviver) {\n reviver = storeSynchronizer.reviver;\n }\n if (storeSynchronizer.deserialize) {\n deserialize = storeSynchronizer.deserialize;\n }\n }\n\n const stateSlice = await this.options.storage!.getItem(\n this.options.storageKeySerializer\n ? this.options.storageKeySerializer(storeName)\n : storeName\n );\n if (stateSlice) {\n const isObjectRegex = /{|\\[/;\n let raw = stateSlice;\n\n if (stateSlice === 'null' || stateSlice === 'true' || stateSlice === 'false' || isObjectRegex.test(stateSlice.charAt(0))) {\n raw = JSON.parse(stateSlice, reviver);\n }\n\n return {\n [storeName]: deserialize(raw)\n };\n }\n });\n\n const result = await Promise.all(storageCalls);\n\n this.store.dispatch(\n rehydrateAction({\n payload: result.reduce(\n (acc: Record<string, any>, store) => ({ ...acc, ...store }),\n {}\n )\n })\n );\n }\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n ModuleWithProviders,\n NgModule,\n} from '@angular/core';\nimport {\n StoreModule,\n} from '@ngrx/store';\nimport {\n provideLogger,\n} from '@o3r/logger';\nimport type {\n StorageSyncOptions,\n} from '@o3r/store-sync';\nimport {\n CapacitorRehydrater,\n STORAGE_SYNC_OPTIONS,\n} from './rehydrater';\n\n/**\n * @deprecated Will be removed in v16. Use {@link provideCapacitorRehydrater} instead.\n */\n@NgModule({\n imports: [\n StoreModule\n ],\n providers: [\n CapacitorRehydrater\n ]\n})\nexport class CapacitorRehydraterModule {\n public static forRoot(options: StorageSyncOptions): ModuleWithProviders<CapacitorRehydraterModule> {\n return {\n ngModule: CapacitorRehydraterModule,\n providers: [\n provideLogger(),\n { provide: STORAGE_SYNC_OPTIONS, useValue: options }\n ]\n };\n }\n}\n\n/**\n * Provide capacitor rehydrater.\n * @param options Storage sync options\n */\nexport function provideCapacitorRehydrater(options: StorageSyncOptions): EnvironmentProviders {\n return makeEnvironmentProviders([\n provideLogger(),\n { provide: STORAGE_SYNC_OPTIONS, useValue: options },\n CapacitorRehydrater\n ]);\n}\n","import {\n Preferences as CapacitorStorage,\n} from '@capacitor/preferences';\nimport type {\n AsyncStorage,\n} from '@o3r/store-sync';\n\n/**\n * Capacitor storage\n */\nexport class OtterCapacitorStorage implements AsyncStorage {\n /**\n * @inheritdoc\n */\n public removeItem(key: string): void {\n void CapacitorStorage.remove({ key });\n }\n\n /**\n * @inheritdoc\n */\n public setItem(key: string, value: string): void {\n void CapacitorStorage.set({ key, value });\n }\n\n /**\n * @inheritdoc\n */\n public async getItem(key: string): Promise<string | null> {\n const { value } = await CapacitorStorage.get({ key });\n return value;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["CapacitorStorage"],"mappings":";;;;;;;;;;;AASA;;AAEG;AACI,eAAe,oBAAoB,GAAA;AACxC,IAAA,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE;IACnC,OAAO,IAAI,CAAC,QAAQ;AACtB;AAEA;;AAEG;AACI,eAAe,kBAAkB,GAAA;AACtC,IAAA,MAAM,QAAQ,GAAG,MAAM,oBAAoB,EAAE;IAC7C,OAAO,CAAC,QAAQ,KAAK,KAAK,MAAM,QAAQ,KAAK,SAAS,CAAC;AACzD;AAEA;;AAEG;AACI,eAAe,UAAU,GAAA;AAC9B,IAAA,MAAM,QAAQ,GAAG,MAAM,oBAAoB,EAAE;IAC7C,QAAQ,QAAQ;AACd,QAAA,MAAM,KAAK,GAAG;AACZ,YAAA,OAAO,uBAAuB;QAChC;AACA,QAAA,MAAM,SAAS,GAAG;AAChB,YAAA,OAAO,kBAAkB;QAC3B;QACA,SAAS;AACP,YAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI;QAC7B;;AAEJ;;MCpBa,sBAAsB,CA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,QAAA,EAAE,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,OAAO,EAAE;QACpD;AACD,KAAA,CAAC;AACJ;;AC9CA;;AAEG;MACU,qBAAqB,CAAA;AAChC;;AAEG;AACI,IAAA,UAAU,CAAC,GAAW,EAAA;QAC3B,KAAKA,WAAgB,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;IACvC;AAEA;;AAEG;IACI,OAAO,CAAC,GAAW,EAAE,KAAa,EAAA;QACvC,KAAKA,WAAgB,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;IAC3C;AAEA;;AAEG;IACI,MAAM,OAAO,CAAC,GAAW,EAAA;AAC9B,QAAA,MAAM,EAAE,KAAK,EAAE,GAAG,MAAMA,WAAgB,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;AACrD,QAAA,OAAO,KAAK;IACd;AACD;;AChCD;;AAEG;;"}
|
|
1
|
+
{"version":3,"file":"o3r-mobile.mjs","names":["CapacitorStorage"],"sources":["../../src/capacitor/helpers.ts","../../src/capacitor/capacitor-target-service.ts","../../src/capacitor/storage/rehydrater.ts","../../src/capacitor/storage/rehydrater-module.ts","../../src/capacitor/storage/storage.ts"],"sourcesContent":["import {\n Device,\n} from '@capacitor/device';\n\n/**\n * Type for the 3 capacitor platforms\n */\nexport type CapacitorPlatforms = 'ios' | 'android' | 'web';\n\n/**\n * Returns the capacitor platform\n */\nexport async function getCapacitorPlatform(): Promise<CapacitorPlatforms> {\n const info = await Device.getInfo();\n return info.platform;\n}\n\n/**\n * Returns true if in a capacitor context (mobile app) or false for web\n */\nexport async function isCapacitorContext(): Promise<boolean> {\n const platform = await getCapacitorPlatform();\n return (platform === 'ios') || (platform === 'android');\n}\n\n/**\n * Returns the baseUrl that can be used depending on the platform\n */\nexport async function getBaseUrl(): Promise<string> {\n const platform = await getCapacitorPlatform();\n switch (platform) {\n case ('ios'): {\n return 'capacitor://localhost';\n }\n case ('android'): {\n return 'http://localhost';\n }\n default: {\n return window.location.href;\n }\n }\n}\n","import {\n DestroyRef,\n inject,\n Injectable,\n} from '@angular/core';\nimport {\n takeUntilDestroyed,\n} from '@angular/core/rxjs-interop';\nimport {\n Browser,\n} from '@capacitor/browser';\nimport {\n fromEvent,\n} from 'rxjs';\nimport {\n isCapacitorContext,\n} from './helpers';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class CapacitorTargetService {\n private readonly destroyRef = inject(DestroyRef);\n private hijackDone = false;\n\n private async openInCapacitorBrowser(element: EventTarget | null, event: Event) {\n if (await isCapacitorContext() && element instanceof Element) {\n if (element.tagName === 'A') {\n const url = element.getAttribute('href');\n if (element.getAttribute('target') === '_blank' && url) {\n event.preventDefault();\n await Browser.open({ url, presentationStyle: 'popover' });\n }\n } else {\n await this.openInCapacitorBrowser(element.parentElement, event);\n }\n }\n }\n\n /**\n * Method called for 'hijacking' the click event on <a> tags with target _blank attribute.\n * Instead of the default action, it will open the URL using the CapacitorJS Browser plugin.\n */\n public hijackClick(): void {\n if (!this.hijackDone) {\n fromEvent(document, 'click').pipe(takeUntilDestroyed(this.destroyRef)).subscribe(async (event) => {\n const element: EventTarget | null = event.target;\n await this.openInCapacitorBrowser(element, event);\n });\n this.hijackDone = true;\n }\n }\n}\n","import {\n inject,\n Injectable,\n InjectionToken,\n} from '@angular/core';\nimport {\n Store,\n} from '@ngrx/store';\nimport {\n LoggerService,\n} from '@o3r/logger';\nimport {\n dateReviver,\n isLocalStorageConfig,\n isSerializer,\n rehydrateAction,\n StorageSyncOptions,\n} from '@o3r/store-sync';\n\n/**\n * Injection token for the storage sync options\n */\nexport const STORAGE_SYNC_OPTIONS = new InjectionToken<Partial<StorageSyncOptions>>('STORAGE_SYNC_OPTIONS');\n\nconst noopDeserializer = (raw: string) => raw;\n\n@Injectable()\nexport class CapacitorRehydrater {\n private readonly store = inject<Store<any>>(Store);\n private readonly logger = inject(LoggerService);\n\n private readonly options: StorageSyncOptions;\n constructor() {\n const options = inject<Partial<StorageSyncOptions>>(STORAGE_SYNC_OPTIONS);\n\n this.options = { keys: [], ...options };\n }\n\n /**\n * Dispatch an action to rehydrate the store with the data from the storage\n */\n public async rehydrate() {\n if (isLocalStorageConfig(this.options)) {\n this.logger.warn('A non-async storage is used, rehydration is not supported');\n return;\n }\n const storageCalls: Promise<Record<string, any> | undefined>[] = this.options.keys\n .map(async (key) => {\n const storeName = Object.keys(key)[0];\n const storeSynchronizer = (key as any)[storeName];\n let reviver = this.options.restoreDates ? dateReviver : undefined;\n let deserialize = noopDeserializer;\n\n if (isSerializer(storeSynchronizer)) {\n if (storeSynchronizer.reviver) {\n reviver = storeSynchronizer.reviver;\n }\n if (storeSynchronizer.deserialize) {\n deserialize = storeSynchronizer.deserialize;\n }\n }\n\n const stateSlice = await this.options.storage!.getItem(\n this.options.storageKeySerializer\n ? this.options.storageKeySerializer(storeName)\n : storeName\n );\n if (stateSlice) {\n const isObjectRegex = /{|\\[/;\n let raw = stateSlice;\n\n if (stateSlice === 'null' || stateSlice === 'true' || stateSlice === 'false' || isObjectRegex.test(stateSlice.charAt(0))) {\n raw = JSON.parse(stateSlice, reviver);\n }\n\n return {\n [storeName]: deserialize(raw)\n };\n }\n });\n\n const result = await Promise.all(storageCalls);\n\n this.store.dispatch(\n rehydrateAction({\n payload: result.reduce(\n (acc: Record<string, any>, store) => ({ ...acc, ...store }),\n {}\n )\n })\n );\n }\n}\n","import {\n EnvironmentProviders,\n makeEnvironmentProviders,\n ModuleWithProviders,\n NgModule,\n} from '@angular/core';\nimport {\n StoreModule,\n} from '@ngrx/store';\nimport {\n provideLogger,\n} from '@o3r/logger';\nimport type {\n StorageSyncOptions,\n} from '@o3r/store-sync';\nimport {\n CapacitorRehydrater,\n STORAGE_SYNC_OPTIONS,\n} from './rehydrater';\n\n/**\n * @deprecated Will be removed in v16. Use {@link provideCapacitorRehydrater} instead.\n */\n@NgModule({\n imports: [\n StoreModule\n ],\n providers: [\n CapacitorRehydrater\n ]\n})\nexport class CapacitorRehydraterModule {\n public static forRoot(options: StorageSyncOptions): ModuleWithProviders<CapacitorRehydraterModule> {\n return {\n ngModule: CapacitorRehydraterModule,\n providers: [\n provideLogger(),\n { provide: STORAGE_SYNC_OPTIONS, useValue: options }\n ]\n };\n }\n}\n\n/**\n * Provide capacitor rehydrater.\n * @param options Storage sync options\n */\nexport function provideCapacitorRehydrater(options: StorageSyncOptions): EnvironmentProviders {\n return makeEnvironmentProviders([\n provideLogger(),\n { provide: STORAGE_SYNC_OPTIONS, useValue: options },\n CapacitorRehydrater\n ]);\n}\n","import {\n Preferences as CapacitorStorage,\n} from '@capacitor/preferences';\nimport type {\n AsyncStorage,\n} from '@o3r/store-sync';\n\n/**\n * Capacitor storage\n */\nexport class OtterCapacitorStorage implements AsyncStorage {\n /**\n * @inheritdoc\n */\n public removeItem(key: string): void {\n void CapacitorStorage.remove({ key });\n }\n\n /**\n * @inheritdoc\n */\n public setItem(key: string, value: string): void {\n void CapacitorStorage.set({ key, value });\n }\n\n /**\n * @inheritdoc\n */\n public async getItem(key: string): Promise<string | null> {\n const { value } = await CapacitorStorage.get({ key });\n return value;\n }\n}\n"],"mappings":";;;;;;;;;;AAYA,eAAsB,uBAAoB;CAExC,QAAO,MADY,OAAO,QAAO,EAC1B,CAAK;AACd;AAKA,eAAsB,qBAAkB;CACtC,MAAM,WAAW,MAAM,qBAAoB;CAC3C,OAAQ,aAAa,SAAW,aAAa;AAC/C;AAKA,eAAsB,aAAU;CAE9B,QAAQ,MADe,qBAAoB,GAC3C;EACE,KAAM,OACJ,OAAO;EAET,KAAM,WACJ,OAAO;EAET,SACE,OAAO,OAAO,SAAS;CAE3B;AACF;ACpBA,IAAa,yBAAb,MAAa,uBAAsB;CAHnC,cAAA;EAImB,KAAA,aAAa,OAAO,UAAU;EACvC,KAAA,aAAa;CA6BtB;CA3BS,MAAM,uBAAuB,SAA6B,OAAY;EAC5E,IAAI,MAAM,mBAAkB,KAAM,mBAAmB,SAAS;GAC5D,IAAI,QAAQ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+1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/mobile",
|
|
3
|
-
"version": "15.3.0-prerelease.
|
|
3
|
+
"version": "15.3.0-prerelease.17",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"otter-module"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@o3r/schematics": "~15.3.0-prerelease.
|
|
29
|
+
"@o3r/schematics": "~15.3.0-prerelease.17",
|
|
30
30
|
"commander": "^14.0.0",
|
|
31
31
|
"form-data": "^4.0.0",
|
|
32
32
|
"node-fetch": "^3.0.0",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"@capacitor/device": "^8.0.0",
|
|
43
43
|
"@capacitor/preferences": "^8.0.0",
|
|
44
44
|
"@ngrx/store": "^22.0.0",
|
|
45
|
-
"@o3r/core": "~15.3.0-prerelease.
|
|
46
|
-
"@o3r/logger": "~15.3.0-prerelease.
|
|
47
|
-
"@o3r/schematics": "~15.3.0-prerelease.
|
|
48
|
-
"@o3r/store-sync": "~15.3.0-prerelease.
|
|
45
|
+
"@o3r/core": "~15.3.0-prerelease.17",
|
|
46
|
+
"@o3r/logger": "~15.3.0-prerelease.17",
|
|
47
|
+
"@o3r/schematics": "~15.3.0-prerelease.17",
|
|
48
|
+
"@o3r/store-sync": "~15.3.0-prerelease.17",
|
|
49
49
|
"@schematics/angular": "^22.0.0",
|
|
50
50
|
"fast-deep-equal": "^3.1.3",
|
|
51
51
|
"rxjs": "^7.8.1",
|
package/types/o3r-mobile.d.ts
CHANGED
|
@@ -1,88 +1,80 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import { InjectionToken, ModuleWithProviders
|
|
3
|
-
import {
|
|
4
|
-
import * as i1 from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { EnvironmentProviders, InjectionToken, ModuleWithProviders } from "@angular/core";
|
|
3
|
+
import { AsyncStorage, StorageSyncOptions } from "@o3r/store-sync";
|
|
4
|
+
import * as i1 from "@ngrx/store";
|
|
5
|
+
export declare class CapacitorTargetService {
|
|
6
|
+
private readonly destroyRef;
|
|
7
|
+
private hijackDone;
|
|
8
|
+
private openInCapacitorBrowser;
|
|
9
|
+
/**
|
|
10
|
+
* Method called for 'hijacking' the click event on <a> tags with target _blank attribute.
|
|
11
|
+
* Instead of the default action, it will open the URL using the CapacitorJS Browser plugin.
|
|
12
|
+
*/
|
|
13
|
+
hijackClick(): void;
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CapacitorTargetService, never>;
|
|
15
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
/**
|
|
20
18
|
* Type for the 3 capacitor platforms
|
|
21
19
|
*/
|
|
22
|
-
type CapacitorPlatforms = 'ios' | 'android' | 'web';
|
|
20
|
+
export type CapacitorPlatforms = 'ios' | 'android' | 'web';
|
|
23
21
|
/**
|
|
24
22
|
* Returns the capacitor platform
|
|
25
23
|
*/
|
|
26
|
-
declare function getCapacitorPlatform(): Promise<CapacitorPlatforms>;
|
|
24
|
+
export declare function getCapacitorPlatform(): Promise<CapacitorPlatforms>;
|
|
27
25
|
/**
|
|
28
26
|
* Returns true if in a capacitor context (mobile app) or false for web
|
|
29
27
|
*/
|
|
30
|
-
declare function isCapacitorContext(): Promise<boolean>;
|
|
28
|
+
export declare function isCapacitorContext(): Promise<boolean>;
|
|
31
29
|
/**
|
|
32
30
|
* Returns the baseUrl that can be used depending on the platform
|
|
33
31
|
*/
|
|
34
|
-
declare function getBaseUrl(): Promise<string>;
|
|
35
|
-
|
|
32
|
+
export declare function getBaseUrl(): Promise<string>;
|
|
36
33
|
/**
|
|
37
34
|
* Injection token for the storage sync options
|
|
38
35
|
*/
|
|
39
|
-
declare const STORAGE_SYNC_OPTIONS: InjectionToken<Partial<StorageSyncOptions>>;
|
|
40
|
-
declare class CapacitorRehydrater {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
36
|
+
export declare const STORAGE_SYNC_OPTIONS: InjectionToken<Partial<StorageSyncOptions>>;
|
|
37
|
+
export declare class CapacitorRehydrater {
|
|
38
|
+
private readonly store;
|
|
39
|
+
private readonly logger;
|
|
40
|
+
private readonly options;
|
|
41
|
+
constructor();
|
|
42
|
+
/**
|
|
43
|
+
* Dispatch an action to rehydrate the store with the data from the storage
|
|
44
|
+
*/
|
|
45
|
+
rehydrate(): Promise<void>;
|
|
46
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CapacitorRehydrater, never>;
|
|
47
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
51
48
|
}
|
|
52
|
-
|
|
53
49
|
/**
|
|
54
50
|
* @deprecated Will be removed in v16. Use {@link provideCapacitorRehydrater} instead.
|
|
55
51
|
*/
|
|
56
|
-
declare class CapacitorRehydraterModule {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
export declare class CapacitorRehydraterModule {
|
|
53
|
+
static forRoot(options: StorageSyncOptions): ModuleWithProviders<CapacitorRehydraterModule>;
|
|
54
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CapacitorRehydraterModule, never>;
|
|
55
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<CapacitorRehydraterModule, never, [typeof i1.StoreModule], never>;
|
|
56
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<CapacitorRehydraterModule>;
|
|
61
57
|
}
|
|
62
58
|
/**
|
|
63
59
|
* Provide capacitor rehydrater.
|
|
64
60
|
* @param options Storage sync options
|
|
65
61
|
*/
|
|
66
|
-
declare function provideCapacitorRehydrater(options: StorageSyncOptions): EnvironmentProviders;
|
|
67
|
-
|
|
62
|
+
export declare function provideCapacitorRehydrater(options: StorageSyncOptions): EnvironmentProviders;
|
|
68
63
|
/**
|
|
69
64
|
* Capacitor storage
|
|
70
65
|
*/
|
|
71
|
-
declare class OtterCapacitorStorage implements AsyncStorage {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
export declare class OtterCapacitorStorage implements AsyncStorage {
|
|
67
|
+
/**
|
|
68
|
+
* @inheritdoc
|
|
69
|
+
*/
|
|
70
|
+
removeItem(key: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* @inheritdoc
|
|
73
|
+
*/
|
|
74
|
+
setItem(key: string, value: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* @inheritdoc
|
|
77
|
+
*/
|
|
78
|
+
getItem(key: string): Promise<string | null>;
|
|
84
79
|
}
|
|
85
|
-
|
|
86
|
-
export { CapacitorRehydrater, CapacitorRehydraterModule, CapacitorTargetService, OtterCapacitorStorage, STORAGE_SYNC_OPTIONS, getBaseUrl, getCapacitorPlatform, isCapacitorContext, provideCapacitorRehydrater };
|
|
87
|
-
export type { CapacitorPlatforms };
|
|
88
|
-
//# sourceMappingURL=o3r-mobile.d.ts.map
|
|
80
|
+
//# sourceMappingURL=o3r-mobile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o3r-mobile.d.ts","sources":["../../src/capacitor/capacitor-target-service.ts","../../src/capacitor/helpers.ts","../../src/capacitor/storage/rehydrater.ts","../../src/capacitor/storage/rehydrater-module.ts","../../src/capacitor/storage/storage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"o3r-mobile.d.ts","names":[],"sources":["../../src/capacitor/capacitor-target-service.ts","../../src/capacitor/helpers.ts","../../src/capacitor/storage/rehydrater.ts","../../src/capacitor/storage/rehydrater-module.ts","../../src/capacitor/storage/storage.ts"],"mappings":";;;;qBAqBa;mBACM;UACT;UAEM;;;;;EAkBP;SAtBI,MAAA,GAAA,qBAAA;;;;;;YCdD;;;;wBAKU,wBAAwB,QAAQ;;;;wBAQhC,sBAAsB;;;;wBAQtB,cAAc;;;;qBCNvB,sBAAoB,eAAA,QAAA;qBAKpB;mBACM;mBACA;mBAEA;;;;;EAUJ,aAAS;SAdX,MAAA,GAAA,qBAAA;;;;;;qBCIA;SACG,QAAQ,SAAS,qBAAqB,oBAAoB;SAD7D,MAAA,GAAA,qBAAA;SAAA,MAAA,GAAA,sBAAA,0CAAyB,GAAA;SAAzB,MAAA,GAAA,sBAAA;;;;;;wBAgBG,2BAA2B,SAAS,qBAAqB;;;;qBCrC5D,iCAAiC;;;;EAIrC,WAAW;;;;EAOX,QAAQ,aAAa;;;;EAOf,QAAQ,cAAc"}
|