@linked.cm/capacitor 0.0.0-stage → 0.2.0
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/.changeset/README.md +20 -0
- package/.changeset/config.json +14 -0
- package/.github/workflows/pr.yml +27 -0
- package/.github/workflows/publish.yml +32 -0
- package/CHANGELOG.md +38 -0
- package/lib/esm/auth/SocialLoginClient.d.ts +40 -0
- package/lib/esm/auth/SocialLoginClient.js +240 -0
- package/lib/esm/auth/SocialLoginClient.js.map +1 -0
- package/lib/esm/backend.d.ts +26 -0
- package/lib/esm/backend.js +302 -0
- package/lib/esm/backend.js.map +1 -0
- package/lib/esm/components/LocationEnabler.d.ts +6 -0
- package/lib/esm/components/LocationEnabler.js +48 -0
- package/lib/esm/components/LocationEnabler.js.map +1 -0
- package/lib/esm/components/LocationEnabler.module.css +6 -0
- package/lib/esm/components/SafeAreaContainer.d.ts +10 -0
- package/lib/esm/components/SafeAreaContainer.js +36 -0
- package/lib/esm/components/SafeAreaContainer.js.map +1 -0
- package/lib/esm/components/SafeAreaContainer.module.css +39 -0
- package/lib/esm/components/SignInWithWhatsapp.d.ts +9 -0
- package/lib/esm/components/SignInWithWhatsapp.js +86 -0
- package/lib/esm/components/SignInWithWhatsapp.js.map +1 -0
- package/lib/esm/components/SignInWithWhatsapp.module.css +92 -0
- package/lib/esm/components/SigninWithAppleButton.d.ts +13 -0
- package/lib/esm/components/SigninWithAppleButton.js +45 -0
- package/lib/esm/components/SigninWithAppleButton.js.map +1 -0
- package/lib/esm/components/SigninWithAppleButton.module.css +22 -0
- package/lib/esm/components/SigninWithFacebookButton.d.ts +13 -0
- package/lib/esm/components/SigninWithFacebookButton.js +46 -0
- package/lib/esm/components/SigninWithFacebookButton.js.map +1 -0
- package/lib/esm/components/SigninWithFacebookButton.module.css +22 -0
- package/lib/esm/components/SigninWithGoogleButton.d.ts +13 -0
- package/lib/esm/components/SigninWithGoogleButton.js +47 -0
- package/lib/esm/components/SigninWithGoogleButton.js.map +1 -0
- package/lib/esm/components/SigninWithGoogleButton.module.css +22 -0
- package/lib/esm/data/lincd-capacitor.json +20 -0
- package/lib/esm/hooks/useAutomaticUpdates.d.ts +22 -0
- package/lib/esm/hooks/useAutomaticUpdates.js +270 -0
- package/lib/esm/hooks/useAutomaticUpdates.js.map +1 -0
- package/lib/esm/hooks/useCapacitor.d.ts +12 -0
- package/lib/esm/hooks/useCapacitor.js +68 -0
- package/lib/esm/hooks/useCapacitor.js.map +1 -0
- package/lib/esm/hooks/useNativeAppUpdate.d.ts +3 -0
- package/lib/esm/hooks/useNativeAppUpdate.js +68 -0
- package/lib/esm/hooks/useNativeAppUpdate.js.map +1 -0
- package/lib/esm/index.d.ts +13 -0
- package/lib/esm/index.js +16 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/ontologies/lincd-capacitor.d.ts +30 -0
- package/lib/esm/ontologies/lincd-capacitor.js +28 -0
- package/lib/esm/ontologies/lincd-capacitor.js.map +1 -0
- package/lib/esm/ontologies/lincd-capacitor.register.d.ts +1 -0
- package/lib/esm/ontologies/lincd-capacitor.register.js +15 -0
- package/lib/esm/ontologies/lincd-capacitor.register.js.map +1 -0
- package/lib/esm/package.d.ts +10 -0
- package/lib/esm/package.js +6 -0
- package/lib/esm/package.js.map +1 -0
- package/lib/esm/shapes/LocationUpdateAction.d.ts +11 -0
- package/lib/esm/shapes/LocationUpdateAction.js +34 -0
- package/lib/esm/shapes/LocationUpdateAction.js.map +1 -0
- package/lib/esm/shapes/index.d.ts +2 -0
- package/lib/esm/shapes/index.js +5 -0
- package/lib/esm/shapes/index.js.map +1 -0
- package/lib/esm/types.d.ts +12 -0
- package/lib/esm/types.js +1 -0
- package/lib/esm/types.js.map +1 -0
- package/lib/esm/utils/helper.d.ts +14 -0
- package/lib/esm/utils/helper.js +39 -0
- package/lib/esm/utils/helper.js.map +1 -0
- package/package.json +103 -4
- package/readme.md +50 -0
- package/renovate.json +4 -0
- package/tests/social-login-client.test.mjs +99 -0
- package/tsconfig-esm.json +9 -0
- package/README.md +0 -3
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAutomaticUpdates
|
|
3
|
+
*
|
|
4
|
+
* Handles OTA (over-the-air) updates and maintenance mode detection for Capacitor apps.
|
|
5
|
+
* Only runs on native platforms (iOS/Android); skips on web.
|
|
6
|
+
*
|
|
7
|
+
* With autoUpdate: false in capacitor.config.ts, we have full manual control:
|
|
8
|
+
* 1. notifyAppReady → confirm current bundle (prevent rollback)
|
|
9
|
+
* 2. Check Capgo channel → switch to production if needed
|
|
10
|
+
* 3. Check native app version → if outdated, show store update and stop
|
|
11
|
+
* 4. Check maintenance (HEAD request to SITE_ROOT) → on start + every 1 min
|
|
12
|
+
* 5. If server up → getLatest() → download with progress → set + reload
|
|
13
|
+
*/
|
|
14
|
+
import { useEffect, useRef, useState, useCallback } from 'react';
|
|
15
|
+
import { CapacitorUpdater } from '@capgo/capacitor-updater';
|
|
16
|
+
import { AppUpdate, AppUpdateAvailability, } from '@capawesome/capacitor-app-update';
|
|
17
|
+
import { Capacitor } from '@capacitor/core';
|
|
18
|
+
const MAINTENANCE_CHECK_INTERVAL_MS = 60 * 1000; // 1 minute
|
|
19
|
+
const getIosAppStoreId = () => { var _a; return ((_a = process.env.IOS_APP_STORE_ID) === null || _a === void 0 ? void 0 : _a.trim()) || ''; };
|
|
20
|
+
const isNoUpdateCondition = (error) => {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
let message = '';
|
|
23
|
+
if (typeof error === 'string') {
|
|
24
|
+
message = error.toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
else if (error && typeof error === 'object') {
|
|
27
|
+
const fields = [
|
|
28
|
+
'message' in error ? String((_a = error.message) !== null && _a !== void 0 ? _a : '') : '',
|
|
29
|
+
'error' in error ? String((_b = error.error) !== null && _b !== void 0 ? _b : '') : '',
|
|
30
|
+
'errorMessage' in error ? String((_c = error.errorMessage) !== null && _c !== void 0 ? _c : '') : '',
|
|
31
|
+
JSON.stringify(error),
|
|
32
|
+
];
|
|
33
|
+
message = fields.join(' ').toLowerCase();
|
|
34
|
+
}
|
|
35
|
+
return (message.includes('no new version available') ||
|
|
36
|
+
message.includes('no_new_version_available') ||
|
|
37
|
+
message.includes('disable_auto_update'));
|
|
38
|
+
};
|
|
39
|
+
export const useAutomaticUpdates = () => {
|
|
40
|
+
const [otaStatus, setOtaStatus] = useState('idle');
|
|
41
|
+
const [otaProgress, setOtaProgress] = useState(0);
|
|
42
|
+
const [maintenanceMode, setMaintenanceMode] = useState(false);
|
|
43
|
+
const maintenanceIntervalRef = useRef(null);
|
|
44
|
+
const otaCheckedRef = useRef(false); // Track whether OTA check has already run
|
|
45
|
+
// --- Maintenance check: HEAD request to SITE_ROOT ---
|
|
46
|
+
const checkMaintenance = useCallback(async () => {
|
|
47
|
+
const siteRoot = process.env.SITE_ROOT;
|
|
48
|
+
if (!siteRoot)
|
|
49
|
+
return true;
|
|
50
|
+
try {
|
|
51
|
+
const res = await fetch(`${siteRoot}/__health`, {
|
|
52
|
+
method: 'HEAD',
|
|
53
|
+
cache: 'no-store',
|
|
54
|
+
});
|
|
55
|
+
const up = res.ok;
|
|
56
|
+
setMaintenanceMode(!up);
|
|
57
|
+
if (up) {
|
|
58
|
+
console.log('✅ [MaintenanceCheck] Server is up');
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
console.log('⚠️ [MaintenanceCheck] Server returned', res.status);
|
|
62
|
+
}
|
|
63
|
+
return up;
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
console.warn('⚠️ [MaintenanceCheck] Server unreachable:', err);
|
|
67
|
+
setMaintenanceMode(true);
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}, []);
|
|
71
|
+
// --- Manual OTA: getLatest → download (with progress) → set → reload ---
|
|
72
|
+
const checkAndDownloadOTA = useCallback(async () => {
|
|
73
|
+
try {
|
|
74
|
+
// getLatest() returns LatestVersion { url, version, error, message, ... }
|
|
75
|
+
const latest = await CapacitorUpdater.getLatest();
|
|
76
|
+
if (latest.error) {
|
|
77
|
+
if (isNoUpdateCondition(latest.error) || isNoUpdateCondition(latest)) {
|
|
78
|
+
console.log('ℹ️ [UpdateCheck] Already on latest OTA bundle');
|
|
79
|
+
setOtaStatus('idle');
|
|
80
|
+
setOtaProgress(0);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
console.warn('⚠️ [UpdateCheck] getLatest error:', latest.error);
|
|
84
|
+
setOtaStatus('error');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (!latest.url) {
|
|
88
|
+
console.log('✅ [UpdateCheck] Already on latest version');
|
|
89
|
+
setOtaStatus('idle');
|
|
90
|
+
setOtaProgress(0);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
console.log(`🔄 [UpdateCheck] OTA update available: ${latest.version}`);
|
|
94
|
+
setOtaStatus('downloading');
|
|
95
|
+
setOtaProgress(0);
|
|
96
|
+
// 'download' event fires during download() with progress percentage
|
|
97
|
+
const progressHandle = await CapacitorUpdater.addListener('download', (event) => {
|
|
98
|
+
var _a;
|
|
99
|
+
setOtaProgress(Math.min(100, Math.max(0, (_a = event.percent) !== null && _a !== void 0 ? _a : 0)));
|
|
100
|
+
});
|
|
101
|
+
try {
|
|
102
|
+
// download() resolves when complete and returns BundleInfo { id, version, ... }
|
|
103
|
+
const bundle = await CapacitorUpdater.download({
|
|
104
|
+
url: latest.url,
|
|
105
|
+
version: latest.version,
|
|
106
|
+
});
|
|
107
|
+
progressHandle.remove();
|
|
108
|
+
// Show "Update ready, restarting..." briefly before reload
|
|
109
|
+
setOtaStatus('complete');
|
|
110
|
+
setOtaProgress(100);
|
|
111
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
112
|
+
// set() takes BundleId { id } — sets bundle and reloads the app
|
|
113
|
+
await CapacitorUpdater.set({ id: bundle.id });
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
progressHandle.remove();
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
if (isNoUpdateCondition(err)) {
|
|
122
|
+
console.log('ℹ️ [UpdateCheck] No OTA update needed');
|
|
123
|
+
setOtaStatus('idle');
|
|
124
|
+
setOtaProgress(0);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
console.error('❌ [UpdateCheck] OTA error:', err);
|
|
128
|
+
setOtaStatus('error');
|
|
129
|
+
}
|
|
130
|
+
}, []);
|
|
131
|
+
const retryOTA = useCallback(() => {
|
|
132
|
+
setOtaStatus('idle');
|
|
133
|
+
setOtaProgress(0);
|
|
134
|
+
checkAndDownloadOTA();
|
|
135
|
+
}, [checkAndDownloadOTA]);
|
|
136
|
+
const retryMaintenanceCheck = useCallback(async () => {
|
|
137
|
+
const serverUp = await checkMaintenance();
|
|
138
|
+
if (serverUp) {
|
|
139
|
+
console.log('✅ [MaintenanceCheck] Server back, checking OTA...');
|
|
140
|
+
otaCheckedRef.current = true;
|
|
141
|
+
await checkAndDownloadOTA();
|
|
142
|
+
}
|
|
143
|
+
}, [checkMaintenance, checkAndDownloadOTA]);
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
if (Capacitor.getPlatform() === 'web')
|
|
146
|
+
return;
|
|
147
|
+
(async () => {
|
|
148
|
+
// Step 1: Confirm current bundle is OK (prevents Capgo rollback)
|
|
149
|
+
try {
|
|
150
|
+
await CapacitorUpdater.notifyAppReady();
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
console.warn('⚠️ [UpdateCheck] notifyAppReady failed:', err);
|
|
154
|
+
}
|
|
155
|
+
// Step 2: Ensure we're on production channel
|
|
156
|
+
try {
|
|
157
|
+
const channelInfo = await CapacitorUpdater.getChannel();
|
|
158
|
+
console.log('📦 Capgo channel:', channelInfo.channel, channelInfo);
|
|
159
|
+
const targetChannel = 'production';
|
|
160
|
+
if (channelInfo.channel &&
|
|
161
|
+
channelInfo.channel !== targetChannel &&
|
|
162
|
+
channelInfo.allowSet) {
|
|
163
|
+
try {
|
|
164
|
+
await CapacitorUpdater.setChannel({
|
|
165
|
+
channel: targetChannel,
|
|
166
|
+
triggerAutoUpdate: false,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
console.warn(`⚠️ Could not switch to ${targetChannel}:`, error);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
console.warn('⚠️ Could not get Capgo channel:', error);
|
|
176
|
+
}
|
|
177
|
+
// Step 3: Check native app version (store update takes priority over OTA)
|
|
178
|
+
if (Capacitor.isNativePlatform()) {
|
|
179
|
+
const nativeUpdateAvailable = await checkNativeVersion();
|
|
180
|
+
if (nativeUpdateAvailable) {
|
|
181
|
+
console.log('🛑 [UpdateCheck] Native update required, stopping OTA');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Step 4: Maintenance check
|
|
186
|
+
const serverUp = await checkMaintenance();
|
|
187
|
+
// Step 5: Poll maintenance every 1 minute; trigger OTA when server recovers
|
|
188
|
+
maintenanceIntervalRef.current = setInterval(async () => {
|
|
189
|
+
const up = await checkMaintenance();
|
|
190
|
+
if (up && !otaCheckedRef.current) {
|
|
191
|
+
console.log('✅ [MaintenanceCheck] Server recovered, checking OTA...');
|
|
192
|
+
otaCheckedRef.current = true;
|
|
193
|
+
await checkAndDownloadOTA();
|
|
194
|
+
}
|
|
195
|
+
}, MAINTENANCE_CHECK_INTERVAL_MS);
|
|
196
|
+
// Step 6: Check OTA only when server is up
|
|
197
|
+
if (serverUp) {
|
|
198
|
+
console.log('✅ [UpdateCheck] Native is up to date, checking OTA...');
|
|
199
|
+
otaCheckedRef.current = true;
|
|
200
|
+
await checkAndDownloadOTA();
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
console.log('⏸️ [UpdateCheck] Server down, skipping OTA check until Retry');
|
|
204
|
+
}
|
|
205
|
+
})();
|
|
206
|
+
return () => {
|
|
207
|
+
if (maintenanceIntervalRef.current) {
|
|
208
|
+
clearInterval(maintenanceIntervalRef.current);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}, [checkMaintenance, checkAndDownloadOTA]);
|
|
212
|
+
// --- Native (store) update: uses @capawesome/capacitor-app-update ---
|
|
213
|
+
const checkNativeVersion = async () => {
|
|
214
|
+
try {
|
|
215
|
+
const nativeUpdateInfo = await AppUpdate.getAppUpdateInfo();
|
|
216
|
+
if (nativeUpdateInfo.updateAvailability ===
|
|
217
|
+
AppUpdateAvailability.UPDATE_AVAILABLE) {
|
|
218
|
+
await showNativeUpdate(nativeUpdateInfo);
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
console.error('❌ [UpdateCheck] Error checking native version:', error);
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
const showNativeUpdate = async (nativeUpdateInfo) => {
|
|
229
|
+
try {
|
|
230
|
+
const { Dialog } = await import('@capacitor/dialog');
|
|
231
|
+
let availableVersion;
|
|
232
|
+
if (nativeUpdateInfo.availableVersionName &&
|
|
233
|
+
nativeUpdateInfo.availableVersionCode) {
|
|
234
|
+
availableVersion = `${nativeUpdateInfo.availableVersionName} (${nativeUpdateInfo.availableVersionCode})`;
|
|
235
|
+
}
|
|
236
|
+
else if (nativeUpdateInfo.availableVersionName) {
|
|
237
|
+
availableVersion = nativeUpdateInfo.availableVersionName;
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
availableVersion = 'latest';
|
|
241
|
+
}
|
|
242
|
+
await Dialog.alert({
|
|
243
|
+
title: 'Update Required',
|
|
244
|
+
message: `A new version (${availableVersion}) is available. Please update now to continue.`,
|
|
245
|
+
buttonTitle: 'Update',
|
|
246
|
+
});
|
|
247
|
+
if (nativeUpdateInfo.immediateUpdateAllowed) {
|
|
248
|
+
await AppUpdate.performImmediateUpdate();
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
await AppUpdate.openAppStore({
|
|
252
|
+
androidPackageName: process.env.APP_ID || '',
|
|
253
|
+
// On iOS the plugin expects the numeric Apple App ID, not a full App Store URL.
|
|
254
|
+
appId: getIosAppStoreId(),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
console.error('❌ [UpdateCheck] Error applying native update:', error);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
return {
|
|
263
|
+
otaStatus,
|
|
264
|
+
otaProgress,
|
|
265
|
+
maintenanceMode,
|
|
266
|
+
retryOTA,
|
|
267
|
+
retryMaintenanceCheck,
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
//# sourceMappingURL=useAutomaticUpdates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutomaticUpdates.js","sourceRoot":"","sources":["../../../src/hooks/useAutomaticUpdates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EACL,SAAS,EACT,qBAAqB,GAEtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAY5C,MAAM,6BAA6B,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,WAAW;AAC5D,MAAM,gBAAgB,GAAG,GAAG,EAAE,WAAC,OAAA,CAAA,MAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB,0CAAE,IAAI,EAAE,KAAI,EAAE,CAAA,EAAA,CAAC;AAE1E,MAAM,mBAAmB,GAAG,CAAC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;oBAC5C,gFAAgF;oBAChF,KAAK,EAAE,gBAAgB,EAAE;iBAC1B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;QACxE,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,SAAS;QACT,WAAW;QACX,eAAe;QACf,QAAQ;QACR,qBAAqB;KACtB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * useAutomaticUpdates\n *\n * Handles OTA (over-the-air) updates and maintenance mode detection for Capacitor apps.\n * Only runs on native platforms (iOS/Android); skips on web.\n *\n * With autoUpdate: false in capacitor.config.ts, we have full manual control:\n * 1. notifyAppReady → confirm current bundle (prevent rollback)\n * 2. Check Capgo channel → switch to production if needed\n * 3. Check native app version → if outdated, show store update and stop\n * 4. Check maintenance (HEAD request to SITE_ROOT) → on start + every 1 min\n * 5. If server up → getLatest() → download with progress → set + reload\n */\n\nimport { useEffect, useRef, useState, useCallback } from 'react';\nimport { CapacitorUpdater } from '@capgo/capacitor-updater';\nimport {\n AppUpdate,\n AppUpdateAvailability,\n AppUpdateInfo,\n} from '@capawesome/capacitor-app-update';\nimport { Capacitor } from '@capacitor/core';\n\nexport type OTAStatus = 'idle' | 'downloading' | 'complete' | 'error';\n\nexport type UseAutomaticUpdatesState = {\n otaStatus: OTAStatus;\n otaProgress: number;\n maintenanceMode: boolean;\n retryOTA: () => void;\n retryMaintenanceCheck: () => void;\n};\n\nconst MAINTENANCE_CHECK_INTERVAL_MS = 60 * 1000; // 1 minute\nconst getIosAppStoreId = () => process.env.IOS_APP_STORE_ID?.trim() || '';\n\nconst isNoUpdateCondition = (error: unknown) => {\n let message = '';\n\n if (typeof error === 'string') {\n message = error.toLowerCase();\n } else if (error && typeof error === 'object') {\n const fields = [\n 'message' in error ? String(error.message ?? '') : '',\n 'error' in error ? String(error.error ?? '') : '',\n 'errorMessage' in error ? String(error.errorMessage ?? '') : '',\n JSON.stringify(error),\n ];\n message = fields.join(' ').toLowerCase();\n }\n\n return (\n message.includes('no new version available') ||\n message.includes('no_new_version_available') ||\n message.includes('disable_auto_update')\n );\n};\n\nexport const useAutomaticUpdates = (): UseAutomaticUpdatesState => {\n const [otaStatus, setOtaStatus] = useState<OTAStatus>('idle');\n const [otaProgress, setOtaProgress] = useState(0);\n const [maintenanceMode, setMaintenanceMode] = useState(false);\n\n const maintenanceIntervalRef = useRef<ReturnType<typeof setInterval> | null>(\n null\n );\n const otaCheckedRef = useRef(false); // Track whether OTA check has already run\n\n // --- Maintenance check: HEAD request to SITE_ROOT ---\n const checkMaintenance = useCallback(async (): Promise<boolean> => {\n const siteRoot = process.env.SITE_ROOT;\n if (!siteRoot) return true;\n\n try {\n const res = await fetch(`${siteRoot}/__health`, {\n method: 'HEAD',\n cache: 'no-store',\n });\n const up = res.ok;\n setMaintenanceMode(!up);\n if (up) {\n console.log('✅ [MaintenanceCheck] Server is up');\n } else {\n console.log('⚠️ [MaintenanceCheck] Server returned', res.status);\n }\n return up;\n } catch (err) {\n console.warn('⚠️ [MaintenanceCheck] Server unreachable:', err);\n setMaintenanceMode(true);\n return false;\n }\n }, []);\n\n // --- Manual OTA: getLatest → download (with progress) → set → reload ---\n const checkAndDownloadOTA = useCallback(async () => {\n try {\n // getLatest() returns LatestVersion { url, version, error, message, ... }\n const latest = await CapacitorUpdater.getLatest();\n if (latest.error) {\n if (isNoUpdateCondition(latest.error) || isNoUpdateCondition(latest)) {\n console.log('ℹ️ [UpdateCheck] Already on latest OTA bundle');\n setOtaStatus('idle');\n setOtaProgress(0);\n return;\n }\n console.warn('⚠️ [UpdateCheck] getLatest error:', latest.error);\n setOtaStatus('error');\n return;\n }\n if (!latest.url) {\n console.log('✅ [UpdateCheck] Already on latest version');\n setOtaStatus('idle');\n setOtaProgress(0);\n return;\n }\n\n console.log(`🔄 [UpdateCheck] OTA update available: ${latest.version}`);\n setOtaStatus('downloading');\n setOtaProgress(0);\n\n // 'download' event fires during download() with progress percentage\n const progressHandle = await CapacitorUpdater.addListener(\n 'download',\n (event: { percent?: number }) => {\n setOtaProgress(Math.min(100, Math.max(0, event.percent ?? 0)));\n }\n );\n\n try {\n // download() resolves when complete and returns BundleInfo { id, version, ... }\n const bundle = await CapacitorUpdater.download({\n url: latest.url,\n version: latest.version,\n });\n\n progressHandle.remove();\n\n // Show \"Update ready, restarting...\" briefly before reload\n setOtaStatus('complete');\n setOtaProgress(100);\n await new Promise((r) => setTimeout(r, 1500));\n // set() takes BundleId { id } — sets bundle and reloads the app\n await CapacitorUpdater.set({ id: bundle.id });\n } catch (err) {\n progressHandle.remove();\n throw err;\n }\n } catch (err: any) {\n if (isNoUpdateCondition(err)) {\n console.log('ℹ️ [UpdateCheck] No OTA update needed');\n setOtaStatus('idle');\n setOtaProgress(0);\n return;\n }\n console.error('❌ [UpdateCheck] OTA error:', err);\n setOtaStatus('error');\n }\n }, []);\n\n const retryOTA = useCallback(() => {\n setOtaStatus('idle');\n setOtaProgress(0);\n checkAndDownloadOTA();\n }, [checkAndDownloadOTA]);\n\n const retryMaintenanceCheck = useCallback(async () => {\n const serverUp = await checkMaintenance();\n if (serverUp) {\n console.log('✅ [MaintenanceCheck] Server back, checking OTA...');\n otaCheckedRef.current = true;\n await checkAndDownloadOTA();\n }\n }, [checkMaintenance, checkAndDownloadOTA]);\n\n useEffect(() => {\n if (Capacitor.getPlatform() === 'web') return;\n\n (async () => {\n // Step 1: Confirm current bundle is OK (prevents Capgo rollback)\n try {\n await CapacitorUpdater.notifyAppReady();\n } catch (err) {\n console.warn('⚠️ [UpdateCheck] notifyAppReady failed:', err);\n }\n\n // Step 2: Ensure we're on production channel\n try {\n const channelInfo = await CapacitorUpdater.getChannel();\n console.log('📦 Capgo channel:', channelInfo.channel, channelInfo);\n\n const targetChannel = 'production';\n if (\n channelInfo.channel &&\n channelInfo.channel !== targetChannel &&\n channelInfo.allowSet\n ) {\n try {\n await CapacitorUpdater.setChannel({\n channel: targetChannel,\n triggerAutoUpdate: false,\n });\n } catch (error) {\n console.warn(`⚠️ Could not switch to ${targetChannel}:`, error);\n }\n }\n } catch (error) {\n console.warn('⚠️ Could not get Capgo channel:', error);\n }\n\n // Step 3: Check native app version (store update takes priority over OTA)\n if (Capacitor.isNativePlatform()) {\n const nativeUpdateAvailable = await checkNativeVersion();\n if (nativeUpdateAvailable) {\n console.log('🛑 [UpdateCheck] Native update required, stopping OTA');\n return;\n }\n }\n\n // Step 4: Maintenance check\n const serverUp = await checkMaintenance();\n\n // Step 5: Poll maintenance every 1 minute; trigger OTA when server recovers\n maintenanceIntervalRef.current = setInterval(async () => {\n const up = await checkMaintenance();\n if (up && !otaCheckedRef.current) {\n console.log(\n '✅ [MaintenanceCheck] Server recovered, checking OTA...'\n );\n otaCheckedRef.current = true;\n await checkAndDownloadOTA();\n }\n }, MAINTENANCE_CHECK_INTERVAL_MS);\n\n // Step 6: Check OTA only when server is up\n if (serverUp) {\n console.log('✅ [UpdateCheck] Native is up to date, checking OTA...');\n otaCheckedRef.current = true;\n await checkAndDownloadOTA();\n } else {\n console.log(\n '⏸️ [UpdateCheck] Server down, skipping OTA check until Retry'\n );\n }\n })();\n\n return () => {\n if (maintenanceIntervalRef.current) {\n clearInterval(maintenanceIntervalRef.current);\n }\n };\n }, [checkMaintenance, checkAndDownloadOTA]);\n\n // --- Native (store) update: uses @capawesome/capacitor-app-update ---\n const checkNativeVersion = async (): Promise<boolean> => {\n try {\n const nativeUpdateInfo = await AppUpdate.getAppUpdateInfo();\n if (\n nativeUpdateInfo.updateAvailability ===\n AppUpdateAvailability.UPDATE_AVAILABLE\n ) {\n await showNativeUpdate(nativeUpdateInfo);\n return true;\n }\n return false;\n } catch (error) {\n console.error('❌ [UpdateCheck] Error checking native version:', error);\n return false;\n }\n };\n\n const showNativeUpdate = async (nativeUpdateInfo: AppUpdateInfo) => {\n try {\n const { Dialog } = await import('@capacitor/dialog');\n let availableVersion: string;\n if (\n nativeUpdateInfo.availableVersionName &&\n nativeUpdateInfo.availableVersionCode\n ) {\n availableVersion = `${nativeUpdateInfo.availableVersionName} (${nativeUpdateInfo.availableVersionCode})`;\n } else if (nativeUpdateInfo.availableVersionName) {\n availableVersion = nativeUpdateInfo.availableVersionName;\n } else {\n availableVersion = 'latest';\n }\n\n await Dialog.alert({\n title: 'Update Required',\n message: `A new version (${availableVersion}) is available. Please update now to continue.`,\n buttonTitle: 'Update',\n });\n\n if (nativeUpdateInfo.immediateUpdateAllowed) {\n await AppUpdate.performImmediateUpdate();\n } else {\n await AppUpdate.openAppStore({\n androidPackageName: process.env.APP_ID || '',\n // On iOS the plugin expects the numeric Apple App ID, not a full App Store URL.\n appId: getIosAppStoreId(),\n });\n }\n } catch (error) {\n console.error('❌ [UpdateCheck] Error applying native update:', error);\n }\n };\n\n return {\n otaStatus,\n otaProgress,\n maintenanceMode,\n retryOTA,\n retryMaintenanceCheck,\n };\n};\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Capacitor } from '@capacitor/core';
|
|
3
|
+
interface CapacitorContext {
|
|
4
|
+
Capacitor: typeof Capacitor;
|
|
5
|
+
}
|
|
6
|
+
export declare const CapacitorContext: React.Context<CapacitorContext>;
|
|
7
|
+
interface CapacitorProviderProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare function CapacitorProvider({ children }: CapacitorProviderProps): React.JSX.Element;
|
|
11
|
+
export declare const useCapacitor: () => CapacitorContext;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { createContext, useContext, useEffect } from 'react';
|
|
2
|
+
import { Capacitor } from '@capacitor/core';
|
|
3
|
+
import { setAuthTokenStorageMethods, } from '@_linked/auth/utils/token';
|
|
4
|
+
import { Preferences } from '@capacitor/preferences';
|
|
5
|
+
import { App } from '@capacitor/app';
|
|
6
|
+
import { useNavigate } from 'react-router-dom';
|
|
7
|
+
export const CapacitorContext = createContext(null);
|
|
8
|
+
function useCapacitorProvider() {
|
|
9
|
+
return {
|
|
10
|
+
Capacitor,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function CapacitorProvider({ children }) {
|
|
14
|
+
const capacitor = useCapacitorProvider();
|
|
15
|
+
const navigate = useNavigate();
|
|
16
|
+
/**
|
|
17
|
+
* AppUrlListener, used to handle deep links
|
|
18
|
+
*/
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
App.addListener('appUrlOpen', (event) => {
|
|
21
|
+
// use URL constructor to parse the URL
|
|
22
|
+
// example:
|
|
23
|
+
// https://example.com/tabs/tab2 --> /tabs/tab2
|
|
24
|
+
const url = new URL(event.url);
|
|
25
|
+
// extract the path from the URL
|
|
26
|
+
const slug = url.pathname;
|
|
27
|
+
// log the deeplink URL
|
|
28
|
+
if (process.env.NODE_ENV === 'staging') {
|
|
29
|
+
console.log('deeplink: ', slug);
|
|
30
|
+
}
|
|
31
|
+
if (slug) {
|
|
32
|
+
navigate(slug);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}, []);
|
|
36
|
+
/**
|
|
37
|
+
* set the storage token methods for Capacitor
|
|
38
|
+
*/
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const getTokenFn = async (key) => {
|
|
41
|
+
const token = await Preferences.get({ key });
|
|
42
|
+
return token === null || token === void 0 ? void 0 : token.value;
|
|
43
|
+
};
|
|
44
|
+
const setTokenFn = async (key, value) => {
|
|
45
|
+
await Preferences.set({
|
|
46
|
+
key: key,
|
|
47
|
+
value: value,
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const removeTokenFn = async (key) => {
|
|
51
|
+
await Preferences.remove({ key: key });
|
|
52
|
+
};
|
|
53
|
+
// set the preferences storage methods only for native platforms
|
|
54
|
+
// and run this effect only once during component mount
|
|
55
|
+
if (Capacitor.isNativePlatform()) {
|
|
56
|
+
setAuthTokenStorageMethods(getTokenFn, setTokenFn, removeTokenFn);
|
|
57
|
+
}
|
|
58
|
+
}, []);
|
|
59
|
+
return (React.createElement(CapacitorContext.Provider, { value: capacitor }, children));
|
|
60
|
+
}
|
|
61
|
+
export const useCapacitor = () => {
|
|
62
|
+
const capacitor = useContext(CapacitorContext);
|
|
63
|
+
if (!capacitor) {
|
|
64
|
+
throw new Error('useCapacitor must be used within a <CapacitorProvider>');
|
|
65
|
+
}
|
|
66
|
+
return capacitor;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=useCapacitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCapacitor.js","sourceRoot":"","sources":["../../../src/hooks/useCapacitor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAEL,0BAA0B,GAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAwB,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAK/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAA0B,IAAI,CAAC,CAAC;AAE7E,SAAS,oBAAoB;IAC3B,OAAO;QACL,SAAS;KACV,CAAC;AACJ,CAAC;AAKD,MAAM,UAAU,iBAAiB,CAAC,EAAE,QAAQ,EAA0B;IACpE,MAAM,SAAS,GAAG,oBAAoB,EAAE,CAAC;IAEzC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE;QACb,GAAG,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,KAA2B,EAAE,EAAE;YAC5D,uCAAuC;YACvC,WAAW;YACX,+CAA+C;YAC/C,MAAM,GAAG,G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C,QAAQ,IAAC,KAAK,EAAE,SAAS,IACxC,QAAQ,CACiB,CAC7B,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,GAAqB,EAAE;IACjD,MAAM,SAAS,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAE/C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import React, { createContext, useContext, useEffect } from 'react';\nimport { Capacitor } from '@capacitor/core';\nimport {\n ACCESS_TOKEN_EXPIRES,\n setAuthTokenStorageMethods,\n} from '@_linked/auth/utils/token';\nimport { Preferences } from '@capacitor/preferences';\nimport { App, URLOpenListenerEvent } from '@capacitor/app';\nimport { useNavigate } from 'react-router-dom';\n\ninterface CapacitorContext {\n Capacitor: typeof Capacitor;\n}\nexport const CapacitorContext = createContext<CapacitorContext | null>(null);\n\nfunction useCapacitorProvider(): CapacitorContext {\n return {\n Capacitor,\n };\n}\n\ninterface CapacitorProviderProps {\n children: React.ReactNode;\n}\nexport function CapacitorProvider({ children }: CapacitorProviderProps) {\n const capacitor = useCapacitorProvider();\n\n const navigate = useNavigate();\n /**\n * AppUrlListener, used to handle deep links\n */\n useEffect(() => {\n App.addListener('appUrlOpen', (event: URLOpenListenerEvent) => {\n // use URL constructor to parse the URL\n // example:\n // https://example.com/tabs/tab2 --> /tabs/tab2\n const url = new URL(event.url);\n\n // extract the path from the URL\n const slug = url.pathname;\n\n // log the deeplink URL\n if (process.env.NODE_ENV === 'staging') {\n console.log('deeplink: ', slug);\n }\n\n if (slug) {\n navigate(slug);\n }\n });\n }, []);\n\n /**\n * set the storage token methods for Capacitor\n */\n useEffect(() => {\n const getTokenFn = async (key: string) => {\n const token = await Preferences.get({ key });\n return token?.value;\n };\n\n const setTokenFn = async (key: string, value: string) => {\n await Preferences.set({\n key: key,\n value: value,\n });\n };\n\n const removeTokenFn = async (key: string) => {\n await Preferences.remove({ key: key });\n };\n\n // set the preferences storage methods only for native platforms\n // and run this effect only once during component mount\n if (Capacitor.isNativePlatform()) {\n setAuthTokenStorageMethods(getTokenFn, setTokenFn, removeTokenFn);\n }\n }, []);\n\n return (\n <CapacitorContext.Provider value={capacitor}>\n {children}\n </CapacitorContext.Provider>\n );\n}\n\nexport const useCapacitor = (): CapacitorContext => {\n const capacitor = useContext(CapacitorContext);\n\n if (!capacitor) {\n throw new Error('useCapacitor must be used within a <CapacitorProvider>');\n }\n\n return capacitor;\n};\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { Capacitor } from '@capacitor/core';
|
|
3
|
+
import { AppUpdate, AppUpdateAvailability, } from '@capawesome/capacitor-app-update';
|
|
4
|
+
import { Dialog } from '@capacitor/dialog';
|
|
5
|
+
const getIosAppStoreId = () => { var _a; return ((_a = process.env.IOS_APP_STORE_ID) === null || _a === void 0 ? void 0 : _a.trim()) || ''; };
|
|
6
|
+
export const useNativeAppUpdate = () => {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
// only check on mobile platforms (Android and iOS)
|
|
9
|
+
if (Capacitor.getPlatform() === 'android' ||
|
|
10
|
+
Capacitor.getPlatform() === 'ios') {
|
|
11
|
+
// Delay native update check to allow OTA updates to check first
|
|
12
|
+
// OTA updates handle web bundle changes (most common)
|
|
13
|
+
// Native updates are for breaking changes requiring native code updates
|
|
14
|
+
setTimeout(checkForUpdate, 5000); // Increased delay to prioritize OTA
|
|
15
|
+
}
|
|
16
|
+
}, []);
|
|
17
|
+
const checkForUpdate = async () => {
|
|
18
|
+
try {
|
|
19
|
+
const result = await AppUpdate.getAppUpdateInfo();
|
|
20
|
+
// check if update is available
|
|
21
|
+
if (result.updateAvailability === AppUpdateAvailability.UPDATE_AVAILABLE) {
|
|
22
|
+
// format: versionName (versionCode) - e.g., "4.0.5 (77)"
|
|
23
|
+
// handle cases where either versionName or versionCode might be undefined
|
|
24
|
+
let availableVersion;
|
|
25
|
+
if (result.availableVersionName && result.availableVersionCode) {
|
|
26
|
+
availableVersion = `${result.availableVersionName} (${result.availableVersionCode})`;
|
|
27
|
+
}
|
|
28
|
+
else if (result.availableVersionName) {
|
|
29
|
+
availableVersion = result.availableVersionName;
|
|
30
|
+
}
|
|
31
|
+
else if (result.availableVersionCode) {
|
|
32
|
+
availableVersion = `${result.availableVersionCode}`;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
availableVersion = 'latest';
|
|
36
|
+
}
|
|
37
|
+
// show update dialog with only "Update" option.
|
|
38
|
+
await Dialog.alert({
|
|
39
|
+
title: 'Update Required',
|
|
40
|
+
message: `A new version (${availableVersion}) is available. Please update now to continue.`,
|
|
41
|
+
buttonTitle: 'Update',
|
|
42
|
+
});
|
|
43
|
+
// open app store immediately after user acknowledges
|
|
44
|
+
doUpdate(result);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error('Error checking for app update:', error);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const doUpdate = async (result) => {
|
|
52
|
+
// perform immediate update if allowed, otherwise open app store
|
|
53
|
+
// immediate update is only available on Android
|
|
54
|
+
// https://github.com/capawesome-team/capacitor-plugins/tree/main/packages/app-update#interfaces
|
|
55
|
+
if (result.immediateUpdateAllowed) {
|
|
56
|
+
await AppUpdate.performImmediateUpdate();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
await AppUpdate.openAppStore({
|
|
60
|
+
androidPackageName: process.env.APP_ID || '', // for Android, this is the package name. find on `android/app/build.gradle`
|
|
61
|
+
// On iOS the plugin expects the numeric Apple App ID, not a full App Store URL.
|
|
62
|
+
appId: getIosAppStoreId(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return { checkForUpdate };
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=useNativeA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capacitor/core';\nimport {\n AppUpdate,\n AppUpdateAvailability,\n AppUpdateInfo,\n} from '@capawesome/capacitor-app-update';\nimport { Dialog } from '@capacitor/dialog';\n\nconst getIosAppStoreId = () => process.env.IOS_APP_STORE_ID?.trim() || '';\n\nexport const useNativeAppUpdate = () => {\n useEffect(() => {\n // only check on mobile platforms (Android and iOS)\n if (\n Capacitor.getPlatform() === 'android' ||\n Capacitor.getPlatform() === 'ios'\n ) {\n // Delay native update check to allow OTA updates to check first\n // OTA updates handle web bundle changes (most common)\n // Native updates are for breaking changes requiring native code updates\n setTimeout(checkForUpdate, 5000); // Increased delay to prioritize OTA\n }\n }, []);\n\n const checkForUpdate = async () => {\n try {\n const result = await AppUpdate.getAppUpdateInfo();\n\n // check if update is available\n if (\n result.updateAvailability === AppUpdateAvailability.UPDATE_AVAILABLE\n ) {\n // format: versionName (versionCode) - e.g., \"4.0.5 (77)\"\n // handle cases where either versionName or versionCode might be undefined\n let availableVersion: string;\n if (result.availableVersionName && result.availableVersionCode) {\n availableVersion = `${result.availableVersionName} (${result.availableVersionCode})`;\n } else if (result.availableVersionName) {\n availableVersion = result.availableVersionName;\n } else if (result.availableVersionCode) {\n availableVersion = `${result.availableVersionCode}`;\n } else {\n availableVersion = 'latest';\n }\n\n // show update dialog with only \"Update\" option.\n await Dialog.alert({\n title: 'Update Required',\n message: `A new version (${availableVersion}) is available. Please update now to continue.`,\n buttonTitle: 'Update',\n });\n\n // open app store immediately after user acknowledges\n doUpdate(result);\n }\n } catch (error) {\n console.error('Error checking for app update:', error);\n }\n };\n\n const doUpdate = async (result: AppUpdateInfo) => {\n // perform immediate update if allowed, otherwise open app store\n // immediate update is only available on Android\n // https://github.com/capawesome-team/capacitor-plugins/tree/main/packages/app-update#interfaces\n if (result.immediateUpdateAllowed) {\n await AppUpdate.performImmediateUpdate();\n } else {\n await AppUpdate.openAppStore({\n androidPackageName: process.env.APP_ID || '', // for Android, this is the package name. find on `android/app/build.gradle`\n // On iOS the plugin expects the numeric Apple App ID, not a full App Store URL.\n appId: getIosAppStoreId(),\n });\n }\n };\n\n return { checkForUpdate };\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import './types.js';
|
|
2
|
+
export * from './auth/SocialLoginClient.js';
|
|
3
|
+
import './ontologies/lincd-capacitor.register.js';
|
|
4
|
+
import './shapes/index.js';
|
|
5
|
+
import './components/LocationEnabler.js';
|
|
6
|
+
import './components/SigninWithFacebookButton.js';
|
|
7
|
+
import './components/SigninWithAppleButton.js';
|
|
8
|
+
import './components/SigninWithGoogleButton.js';
|
|
9
|
+
import './components/SafeAreaContainer.js';
|
|
10
|
+
import './components/SignInWithWhatsapp.js';
|
|
11
|
+
import './hooks/useCapacitor.js';
|
|
12
|
+
import './hooks/useAutomaticUpdates.js';
|
|
13
|
+
import './hooks/useNativeAppUpdate.js';
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import './types.js';
|
|
2
|
+
export * from './auth/SocialLoginClient.js';
|
|
3
|
+
import './ontologies/lincd-capacitor.register.js';
|
|
4
|
+
//SHAPES FIRST
|
|
5
|
+
import './shapes/index.js';
|
|
6
|
+
//THEN COMPONENTS
|
|
7
|
+
import './components/LocationEnabler.js';
|
|
8
|
+
import './components/SigninWithFacebookButton.js';
|
|
9
|
+
import './components/SigninWithAppleButton.js';
|
|
10
|
+
import './components/SigninWithGoogleButton.js';
|
|
11
|
+
import './components/SafeAreaContainer.js';
|
|
12
|
+
import './components/SignInWithWhatsapp.js';
|
|
13
|
+
import './hooks/useCapacitor.js';
|
|
14
|
+
import './hooks/useAutomaticUpdates.js';
|
|
15
|
+
import './hooks/useNativeAppUpdate.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,cAAc,6BAA6B,CAAC;AAC5C,OAAO,0CAA0C,CAAC;AAElD,cAAc;AACd,OAAO,mBAAmB,CAAC;AAE3B,iBAAiB;AACjB,OAAO,iCAAiC,CAAC;AACzC,OAAO,0CAA0C,CAAC;AAClD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,wCAAwC,CAAC;AAChD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,oCAAoC,CAAC;AAC5C,OAAO,yBAAyB,CAAC;AACjC,OAAO,gCAAgC,CAAC;AACxC,OAAO,+BAA+B,CAAC","sourcesContent":["import './types.js';\nexport * from './auth/SocialLoginClient.js';\nimport './ontologies/lincd-capacitor.register.js';\n\n//SHAPES FIRST\nimport './shapes/index.js';\n\n//THEN COMPONENTS\nimport './components/LocationEnabler.js';\nimport './components/SigninWithFacebookButton.js';\nimport './components/SigninWithAppleButton.js';\nimport './components/SigninWithGoogleButton.js';\nimport './components/SafeAreaContainer.js';\nimport './components/SignInWithWhatsapp.js';\nimport './hooks/useCapacitor.js';\nimport './hooks/useAutomaticUpdates.js';\nimport './hooks/useNativeAppUpdate.js';\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load the data of this ontology into memory
|
|
3
|
+
*/
|
|
4
|
+
export declare var loadData: () => Promise<{
|
|
5
|
+
"@context": {
|
|
6
|
+
dc: string;
|
|
7
|
+
owl: string;
|
|
8
|
+
rdf: string;
|
|
9
|
+
rdfs: string;
|
|
10
|
+
"lincd-capacitor": string;
|
|
11
|
+
};
|
|
12
|
+
"@graph": {
|
|
13
|
+
"@id": string;
|
|
14
|
+
"@type": string;
|
|
15
|
+
"rdfs:comment": string;
|
|
16
|
+
"rdfs:isDefinedBy": {
|
|
17
|
+
"@id": string;
|
|
18
|
+
};
|
|
19
|
+
"rdfs:label": string;
|
|
20
|
+
}[];
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* The namespace of this ontology
|
|
24
|
+
*/
|
|
25
|
+
export declare var ns: (term: string) => import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
|
|
26
|
+
export declare var _self: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
|
|
27
|
+
export declare var LocationUpdateAction: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
|
|
28
|
+
export declare const lincdCapacitor: {
|
|
29
|
+
LocationUpdateAction: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
|
|
30
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createNameSpace } from '@_linked/core/utils/NameSpace';
|
|
2
|
+
/**
|
|
3
|
+
* Load the data of this ontology into memory
|
|
4
|
+
*/
|
|
5
|
+
export var loadData = () => {
|
|
6
|
+
if (typeof module !== 'undefined' && typeof exports !== 'undefined') {
|
|
7
|
+
// CommonJS import
|
|
8
|
+
return import('../data/lincd-capacitor.json');
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
// ESM import
|
|
12
|
+
//@ts-ignore
|
|
13
|
+
return import('../data/lincd-capacitor.json', {
|
|
14
|
+
with: { type: 'json' },
|
|
15
|
+
}).then((data) => data.default);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The namespace of this ontology
|
|
20
|
+
*/
|
|
21
|
+
export var ns = createNameSpace('http://lincd.org/ont/lincd-capacitor/');
|
|
22
|
+
export var _self = ns('');
|
|
23
|
+
export var LocationUpdateAction = ns('LocationUpdateAction');
|
|
24
|
+
//An extra grouping object so all the entities can be accessed from the prefix/name
|
|
25
|
+
export const lincdCapacitor = {
|
|
26
|
+
LocationUpdateAction,
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=lincd-capacitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lincd-capacitor.js","sourceRoot":"","sources":["../../../src/ontologies/lincd-capacitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,IAAI,QAAQ,GAAG,GAAG,EAAE;IACzB,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QACpE,kBAAkB;QAClB,OAAO,MAAM,CAAC,8BAA8B,CAAC,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,aAAa;QACb,YAAY;QACZ,OAAO,MAAM,CAAC,8BAA8B,EAAE;YAC5C,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;SACvB,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;AACH,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,IAAI,EAAE,GAAG,eAAe,CAAC,uCAAuC,CAAC,CAAC;AAEzE,MAAM,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAE1B,MAAM,CAAC,IAAI,oBAAoB,GAAG,EAAE,CAAC,sBAAsB,CAAC,CAAC;AAE7D,mFAAmF;AACnF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,oBAAoB;CACrB,CAAC","sourcesContent":["import { createNameSpace } from '@_linked/core/utils/NameSpace';\n\n/**\n * Load the data of this ontology into memory\n */\nexport var loadData = () => {\n if (typeof module !== 'undefined' && typeof exports !== 'undefined') {\n // CommonJS import\n return import('../data/lincd-capacitor.json');\n } else {\n // ESM import\n //@ts-ignore\n return import('../data/lincd-capacitor.json', {\n with: { type: 'json' },\n }).then((data) => data.default);\n }\n};\n\n/**\n * The namespace of this ontology\n */\nexport var ns = createNameSpace('http://lincd.org/ont/lincd-capacitor/');\n\nexport var _self = ns('');\n\nexport var LocationUpdateAction = ns('LocationUpdateAction');\n\n//An extra grouping object so all the entities can be accessed from the prefix/name\nexport const lincdCapacitor = {\n LocationUpdateAction,\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers this ontology.
|
|
3
|
+
*
|
|
4
|
+
* Kept out of `lincd-capacitor.ts` because registration needs that module's whole export
|
|
5
|
+
* namespace, and a module cannot import itself once a bundler is involved: Rollup treats
|
|
6
|
+
* a static self-reference as a circular import and elides it, so the binding is undefined
|
|
7
|
+
* at runtime and the app dies at boot with `_this is not defined`. `tsc` preserves it,
|
|
8
|
+
* which is why the pattern worked for as long as packages were only built with `tsc`.
|
|
9
|
+
*
|
|
10
|
+
* From a sibling module the same import is ordinary and survives.
|
|
11
|
+
*/
|
|
12
|
+
import * as terms from './lincd-capacitor.js';
|
|
13
|
+
import { linkedOntology } from '../package.js';
|
|
14
|
+
linkedOntology(terms, terms.ns, 'lincd-capacitor', terms.loadData, '../data/lincd-capacitor.json');
|
|
15
|
+
//# sourceMappingURL=lincd-capacitor.register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lincd-capacitor.register.js","sourceRoot":"","sources":["../../../src/ontologies/lincd-capacitor.register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,cAAc,CACZ,KAAK,EACL,KAAK,CAAC,EAAE,EACR,iBAAiB,EACjB,KAAK,CAAC,QAAQ,EACd,8BAA8B,CAC/B,CAAC","sourcesContent":["/**\n * Registers this ontology.\n *\n * Kept out of `lincd-capacitor.ts` because registration needs that module's whole export\n * namespace, and a module cannot import itself once a bundler is involved: Rollup treats\n * a static self-reference as a circular import and elides it, so the binding is undefined\n * at runtime and the app dies at boot with `_this is not defined`. `tsc` preserves it,\n * which is why the pattern worked for as long as packages were only built with `tsc`.\n *\n * From a sibling module the same import is ordinary and survives.\n */\nimport * as terms from './lincd-capacitor.js';\nimport { linkedOntology } from '../package.js';\n\nlinkedOntology(\n terms,\n terms.ns,\n 'lincd-capacitor',\n terms.loadData,\n '../data/lincd-capacitor.json'\n);\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const linkedShape: {
|
|
2
|
+
<T extends typeof import("@_linked/core/shapes/Shape.js").Shape>(constructor: T): void;
|
|
3
|
+
<T extends typeof import("@_linked/core/shapes/Shape.js").Shape>(config?: import("@_linked/core/utils/Package").ShapeConfig): (constructor: T) => void;
|
|
4
|
+
}, linkedUtil: (constructor: any) => any, linkedOntology: (allFileExports: any, nameSpace: (term: string) => import("@_linked/core/utils/NodeReference.js").NodeReferenceValue, suggestedPrefixAndFileName: string, loadDataFunction?: () => Promise<any>, dataSource?: string | string[]) => void, registerPackageExport: (exportedObject: any) => void, registerPackageModule: (_module: any) => void, getPackageShape: (name: string) => import("@_linked/core/shapes/Shape.js").ShapeConstructor | undefined, packageExports: any, packageName: string;
|
|
5
|
+
declare const linkedComponent: {
|
|
6
|
+
<QueryType extends import("@_linked/core/queries/QueryBuilder.js").SelectBuilder<any> = null, CustomProps = {}, ShapeType extends import("@_linked/core/shapes/Shape.js").Shape = QueryType extends import("@_linked/core/queries/QueryBuilder.js").SelectBuilder<infer S extends import("@_linked/core/shapes/Shape.js").Shape, any, any> ? S : never, Res = QueryType extends import("@_linked/core/queries/QueryBuilder.js").SelectBuilder<any, infer R, any> ? R : QueryType extends import("@_linked/core/queries/FieldSet.js").FieldSet<infer R_1, any> ? R_1 : QueryType>(query: QueryType, functionalComponent: import("@_linked/react/utils/LinkedComponent").LinkableComponent<CustomProps & import("@_linked/core/queries/SelectQuery.js").QueryResponseToResultType<Res, ShapeType>, ShapeType>): import("@_linked/react/utils/LinkedComponent").LinkedComponent<CustomProps, ShapeType, Res>;
|
|
7
|
+
<QueryType extends import("@_linked/core/queries/QueryBuilder.js").SelectBuilder<any> = null, CustomProps = {}, ShapeType extends import("@_linked/core/shapes/Shape.js").Shape = QueryType extends import("@_linked/core/queries/QueryBuilder.js").SelectBuilder<infer S extends import("@_linked/core/shapes/Shape.js").Shape, any, any> ? S : never, Res = QueryType extends import("@_linked/core/queries/QueryBuilder.js").SelectBuilder<any, infer R, any> ? R : QueryType extends import("@_linked/core/queries/FieldSet.js").FieldSet<infer R_1, any> ? R_1 : QueryType>(query: QueryType, functionalComponent: import("@_linked/react/utils/LinkedComponent").LinkableComponent<CustomProps & import("@_linked/core/queries/SelectQuery.js").QueryResponseToResultType<Res, ShapeType>, ShapeType>, options: import("@_linked/react/utils/LinkedComponent").LinkedComponentOptions): import("@_linked/react/utils/LinkedComponent").LinkedComponent<CustomProps, ShapeType, Res>;
|
|
8
|
+
<QueryType extends import("@_linked/core/queries/QueryBuilder.js").SelectBuilder<any> = null, CustomProps = {}, ShapeType extends import("@_linked/core/shapes/Shape.js").Shape = QueryType extends import("@_linked/core/queries/QueryBuilder.js").SelectBuilder<infer S extends import("@_linked/core/shapes/Shape.js").Shape, any, any> ? S : never, Res = QueryType extends import("@_linked/core/queries/QueryBuilder.js").SelectBuilder<any, infer R, any> ? R : QueryType extends import("@_linked/core/queries/FieldSet.js").FieldSet<infer R_1, any> ? R_1 : QueryType>(config: import("@_linked/react/utils/LinkedComponent").LinkedComponentConfig<QueryType, CustomProps & import("@_linked/core/queries/SelectQuery.js").QueryResponseToResultType<Res, ShapeType>, ShapeType>): import("@_linked/react/utils/LinkedComponent").LinkedComponent<CustomProps, ShapeType, Res>;
|
|
9
|
+
};
|
|
10
|
+
export { linkedComponent, linkedShape, linkedUtil, linkedOntology, registerPackageExport, registerPackageModule, getPackageShape, packageExports, packageName, };
|