@linked.cm/capacitor 0.3.6 → 1.0.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/CHANGELOG.md +33 -0
- package/docs/reports/003-ota-download-metadata.md +69 -0
- package/lib/esm/backend.d.ts +1 -0
- package/lib/esm/data/capacitor.ttl +15 -0
- package/lib/esm/data/shapes.ttl +10 -0
- package/lib/esm/hooks/useAutomaticUpdates.d.ts +4 -0
- package/lib/esm/hooks/useAutomaticUpdates.js +9 -5
- package/lib/esm/hooks/useAutomaticUpdates.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/ontologies/capacitor.d.ts +2 -0
- package/lib/esm/ontologies/capacitor.data.d.ts +8 -0
- package/lib/esm/ontologies/capacitor.data.js +15 -0
- package/lib/esm/ontologies/capacitor.data.js.map +1 -0
- package/lib/esm/ontologies/capacitor.js +6 -0
- package/lib/esm/ontologies/capacitor.js.map +1 -0
- package/lib/esm/ontologies/capacitor.register.js +15 -0
- package/lib/esm/ontologies/capacitor.register.js.map +1 -0
- package/lib/esm/package.d.ts +1 -1
- package/lib/esm/shapes/LocationUpdateAction.js +2 -2
- package/lib/esm/shapes/LocationUpdateAction.js.map +1 -1
- package/lib/esm/shapes/index.d.ts +1 -1
- package/lib/esm/shapes/index.js +1 -1
- package/lib/esm/shapes/index.js.map +1 -1
- package/package.json +22 -16
- package/readme.md +1 -1
- package/tests/automatic-updates.test.mjs +47 -0
- package/tests/ontology.test.mjs +39 -0
- package/lib/esm/data/lincd-capacitor.json +0 -20
- package/lib/esm/ontologies/lincd-capacitor.d.ts +0 -30
- package/lib/esm/ontologies/lincd-capacitor.js +0 -28
- package/lib/esm/ontologies/lincd-capacitor.js.map +0 -1
- package/lib/esm/ontologies/lincd-capacitor.register.js +0 -15
- package/lib/esm/ontologies/lincd-capacitor.register.js.map +0 -1
- /package/lib/esm/ontologies/{lincd-capacitor.register.d.ts → capacitor.register.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @linked.cm/capacitor
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#26](https://github.com/linked-cm/capacitor/pull/26) [`35b571e`](https://github.com/linked-cm/capacitor/commit/35b571e4711faff440c0e11b31f2a21ded2d6fff) Thanks [@flyon](https://github.com/flyon)! - The ontology moves to `https://linked.cm/ont/capacitor/` and ships as Turtle with generated
|
|
8
|
+
accessor modules.
|
|
9
|
+
|
|
10
|
+
- **New namespace.** `LocationUpdateAction` moves from
|
|
11
|
+
`http://lincd.org/ont/lincd-capacitor/LocationUpdateAction` to
|
|
12
|
+
`https://linked.cm/ont/capacitor/LocationUpdateAction` (prefix `capacitor`), declared
|
|
13
|
+
`rdfs:subClassOf schema:UpdateAction`. Stored nodes typed with the old class are invisible to
|
|
14
|
+
this release until the app rewrites the namespace.
|
|
15
|
+
- **Generated accessor modules.** `src/data/capacitor.ttl` is the only source of terms;
|
|
16
|
+
`linked generate-ontology` writes `ontologies/capacitor` (one named export per term),
|
|
17
|
+
`ontologies/capacitor.data` (`ns`, `dataFiles`, `loadData`, `_ontologyResource`) and
|
|
18
|
+
`ontologies/capacitor.register`. Import the terms as a namespace:
|
|
19
|
+
`import * as capacitor from '@linked.cm/capacitor/ontologies/capacitor'`.
|
|
20
|
+
- **Removed:** the aggregated `capacitor` and `lincdCapacitor` objects, `_self` (now
|
|
21
|
+
`_ontologyResource` in `ontologies/capacitor.data`), `legacyNs`, `ns`/`dataFiles`/`loadData`
|
|
22
|
+
from `ontologies/capacitor` (now in `ontologies/capacitor.data`), the module
|
|
23
|
+
`ontologies/lincd-capacitor`, and the JSON-LD data `lincd-capacitor.json`.
|
|
24
|
+
- The package is built with `linked build`, which ships `lib/esm/data/capacitor.ttl` and
|
|
25
|
+
`shapes.ttl`. `react` is a declared peer dependency (`^18.2.0 || ^19.0.0`).
|
|
26
|
+
- Requires `@_linked/core` ^2.46.0, `@_linked/schema` ^1.9.2, `@_linked/sioc` ^1.6.2,
|
|
27
|
+
`@_linked/react` ^2.1.0, `@_linked/server-utils` ^1.17.0, `@_linked/auth` ^3.21.0 and
|
|
28
|
+
`@_linked/primitives` ^1.10.0; built with `@_linked/cli` ^1.61.0.
|
|
29
|
+
|
|
30
|
+
## 0.3.7
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [#24](https://github.com/linked-cm/capacitor/pull/24) [`c975917`](https://github.com/linked-cm/capacitor/commit/c975917de2b4d53822a2e6ea751960e2b183b21a) Thanks [@abdipramana](https://github.com/abdipramana)! - Fix manual Capgo OTA downloads by forwarding the checksum returned by `getLatest()` to the native downloader. Encrypted and delta updates now also receive the returned session key and manifest.
|
|
35
|
+
|
|
3
36
|
## 0.3.6
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: Fixed manual Capgo OTA downloads so integrity, encryption, and delta metadata returned by the update service reaches the native downloader.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# OTA download metadata forwarding
|
|
6
|
+
|
|
7
|
+
## Outcome
|
|
8
|
+
|
|
9
|
+
The automatic-update hook now passes all download-specific metadata returned by
|
|
10
|
+
`CapacitorUpdater.getLatest()` into `CapacitorUpdater.download()`. Previously it
|
|
11
|
+
passed only the bundle URL and version, which caused native installations that
|
|
12
|
+
require integrity verification to reject an otherwise valid update with
|
|
13
|
+
`Checksum required`.
|
|
14
|
+
|
|
15
|
+
The forwarded fields are:
|
|
16
|
+
|
|
17
|
+
- `checksum`, for native bundle integrity verification;
|
|
18
|
+
- `sessionKey`, for encrypted bundles; and
|
|
19
|
+
- `manifest`, for multi-file delta updates.
|
|
20
|
+
|
|
21
|
+
URL and version forwarding is unchanged.
|
|
22
|
+
|
|
23
|
+
## Implementation
|
|
24
|
+
|
|
25
|
+
`src/hooks/useAutomaticUpdates.ts` owns the manual update sequence. Its new
|
|
26
|
+
`getDownloadOptions()` mapping keeps the boundary between the update-service
|
|
27
|
+
response and the native download call explicit and independently testable. The
|
|
28
|
+
hook uses that mapping only after confirming that `getLatest()` returned a URL.
|
|
29
|
+
|
|
30
|
+
The helper is exported from the existing hook subpath. This keeps the mapping
|
|
31
|
+
available to package consumers that need to construct the same native download
|
|
32
|
+
options without duplicating the security-sensitive field list.
|
|
33
|
+
|
|
34
|
+
## Decisions
|
|
35
|
+
|
|
36
|
+
The hook forwards the complete set of fields accepted by Capgo's
|
|
37
|
+
`DownloadOptions`, instead of fixing only the observed checksum omission. This
|
|
38
|
+
avoids equivalent failures when encrypted or delta delivery is enabled.
|
|
39
|
+
|
|
40
|
+
Optional fields remain optional. Unencrypted full-ZIP updates therefore retain
|
|
41
|
+
their existing behavior while checksum-bearing responses preserve their
|
|
42
|
+
integrity contract.
|
|
43
|
+
|
|
44
|
+
No architecture document changed. The update flow and package boundary remain
|
|
45
|
+
the same; this corrects metadata propagation inside the existing flow.
|
|
46
|
+
|
|
47
|
+
## Verification
|
|
48
|
+
|
|
49
|
+
`tests/automatic-updates.test.mjs` covers complete metadata forwarding and the
|
|
50
|
+
absence of optional metadata. The package test suite builds the ESM output
|
|
51
|
+
before executing tests, so the assertions exercise the same compiled helper
|
|
52
|
+
that consumers import.
|
|
53
|
+
|
|
54
|
+
Validation completed successfully:
|
|
55
|
+
|
|
56
|
+
- package test suite: 28 tests passed;
|
|
57
|
+
- full package build: passed; and
|
|
58
|
+
- whitespace/error check with `git diff --check`: passed.
|
|
59
|
+
|
|
60
|
+
## Release and operational notes
|
|
61
|
+
|
|
62
|
+
The change has a patch changeset because it fixes published behavior without
|
|
63
|
+
changing the existing hook API. Applications whose currently installed native
|
|
64
|
+
bundle contains the broken downloader still require a native store release to
|
|
65
|
+
receive this fix; that broken downloader cannot install its own corrective OTA.
|
|
66
|
+
Once a native build containing the corrected package is installed, subsequent
|
|
67
|
+
checksum-protected OTA updates can use the normal channel flow.
|
|
68
|
+
|
|
69
|
+
No remaining code or documentation gaps were found in this scope.
|
package/lib/esm/backend.d.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@prefix capacitor: <https://linked.cm/ont/capacitor/> .
|
|
2
|
+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
|
3
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
|
4
|
+
@prefix dcterms: <http://purl.org/dc/terms/> .
|
|
5
|
+
@prefix schema: <http://schema.org/> .
|
|
6
|
+
|
|
7
|
+
capacitor:
|
|
8
|
+
a owl:Ontology ;
|
|
9
|
+
dcterms:description "Native app helpers for sign-in, safe area, location, and updates."@en ;
|
|
10
|
+
dcterms:title "Linked capacitor"@en .
|
|
11
|
+
|
|
12
|
+
capacitor:LocationUpdateAction
|
|
13
|
+
a owl:Class ;
|
|
14
|
+
rdfs:comment "An update of a user's location, sent from the device."@en ;
|
|
15
|
+
rdfs:subClassOf schema:UpdateAction .
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
@prefix core: <https://linked.cm/ont/core/> .
|
|
2
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
3
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
|
4
|
+
@prefix sh: <http://www.w3.org/ns/shacl#> .
|
|
5
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
|
6
|
+
|
|
7
|
+
<https://linked.cm/shape/capacitor/LocationUpdateAction>
|
|
8
|
+
a sh:NodeShape ;
|
|
9
|
+
sh:targetClass <https://linked.cm/ont/capacitor/LocationUpdateAction> ;
|
|
10
|
+
core:isExtending <https://linked.cm/shape/schema/UpdateAction> .
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* 4. Check maintenance (HEAD request to SITE_ROOT) → on start + every 1 min
|
|
12
12
|
* 5. If server up → getLatest() → download with progress → set + reload
|
|
13
13
|
*/
|
|
14
|
+
import { type DownloadOptions, type LatestVersion } from '@capgo/capacitor-updater';
|
|
14
15
|
export type OTAStatus = 'idle' | 'downloading' | 'complete' | 'error';
|
|
15
16
|
export type UseAutomaticUpdatesState = {
|
|
16
17
|
otaStatus: OTAStatus;
|
|
@@ -19,4 +20,7 @@ export type UseAutomaticUpdatesState = {
|
|
|
19
20
|
retryOTA: () => void;
|
|
20
21
|
retryMaintenanceCheck: () => void;
|
|
21
22
|
};
|
|
23
|
+
export declare const getDownloadOptions: (latest: LatestVersion & {
|
|
24
|
+
url: string;
|
|
25
|
+
}) => DownloadOptions;
|
|
22
26
|
export declare const useAutomaticUpdates: () => UseAutomaticUpdatesState;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* 5. If server up → getLatest() → download with progress → set + reload
|
|
13
13
|
*/
|
|
14
14
|
import { useEffect, useRef, useState, useCallback } from 'react';
|
|
15
|
-
import { CapacitorUpdater } from '@capgo/capacitor-updater';
|
|
15
|
+
import { CapacitorUpdater, } from '@capgo/capacitor-updater';
|
|
16
16
|
import { AppUpdate, AppUpdateAvailability, } from '@capawesome/capacitor-app-update';
|
|
17
17
|
import { Capacitor } from '@capacitor/core';
|
|
18
18
|
const MAINTENANCE_CHECK_INTERVAL_MS = 60 * 1000; // 1 minute
|
|
@@ -36,6 +36,13 @@ const isNoUpdateCondition = (error) => {
|
|
|
36
36
|
message.includes('no_new_version_available') ||
|
|
37
37
|
message.includes('disable_auto_update'));
|
|
38
38
|
};
|
|
39
|
+
export const getDownloadOptions = (latest) => ({
|
|
40
|
+
url: latest.url,
|
|
41
|
+
version: latest.version,
|
|
42
|
+
checksum: latest.checksum,
|
|
43
|
+
sessionKey: latest.sessionKey,
|
|
44
|
+
manifest: latest.manifest,
|
|
45
|
+
});
|
|
39
46
|
export const useAutomaticUpdates = () => {
|
|
40
47
|
const [otaStatus, setOtaStatus] = useState('idle');
|
|
41
48
|
const [otaProgress, setOtaProgress] = useState(0);
|
|
@@ -100,10 +107,7 @@ export const useAutomaticUpdates = () => {
|
|
|
100
107
|
});
|
|
101
108
|
try {
|
|
102
109
|
// download() resolves when complete and returns BundleInfo { id, version, ... }
|
|
103
|
-
const bundle = await CapacitorUpdater.download({
|
|
104
|
-
url: latest.url,
|
|
105
|
-
version: latest.version,
|
|
106
|
-
});
|
|
110
|
+
const bundle = await CapacitorUpdater.download(getDownloadOptions({ ...latest, url: latest.url }));
|
|
107
111
|
progressHandle.remove();
|
|
108
112
|
// Show "Update ready, restarting..." briefly before reload
|
|
109
113
|
setOtaStatus('complete');
|
|
@@ -1 +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,KAAc,EAAE,EAAE;;IAC7C,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC;SAAM,IAAI,KAAK,I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E,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"]}
|
|
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,EACL,gBAAgB,GAGjB,MAAM,0BAA0B,CAAC;AAClC,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,KAAc,EAAE,EAAE;;IAC7C,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC;SAAM,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QA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C;oBAC3B,kBAAkB,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE;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 {\n CapacitorUpdater,\n type DownloadOptions,\n type LatestVersion,\n} 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 getDownloadOptions = (\n latest: LatestVersion & { url: string }\n): DownloadOptions => ({\n url: latest.url,\n version: latest.version,\n checksum: latest.checksum,\n sessionKey: latest.sessionKey,\n manifest: latest.manifest,\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 getDownloadOptions({ ...latest, url: latest.url })\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"]}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './types.js';
|
|
2
2
|
export * from './auth/SocialLoginClient.js';
|
|
3
|
-
import './ontologies/
|
|
3
|
+
import './ontologies/capacitor.register.js';
|
|
4
4
|
import './shapes/index.js';
|
|
5
5
|
import './components/LocationEnabler.js';
|
|
6
6
|
import './components/SigninWithFacebookButton.js';
|
package/lib/esm/index.js
CHANGED
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,cAAc,6BAA6B,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,cAAc,6BAA6B,CAAC;AAC5C,OAAO,oCAAoC,CAAC;AAE5C,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/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,8 @@
|
|
|
1
|
+
/** The ontology data, relative to this module (Turtle, copied into `lib/` by the build). */
|
|
2
|
+
export declare const dataFiles: string[];
|
|
3
|
+
/** Reads the ontology data (server only). */
|
|
4
|
+
export declare const loadData: () => Promise<string[]>;
|
|
5
|
+
/** The namespace: `ns('Term')` is the `{id}` reference of any term, listed or not. */
|
|
6
|
+
export declare const ns: (term: string) => import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
|
|
7
|
+
/** The ontology itself (its namespace IRI). */
|
|
8
|
+
export declare const _ontologyResource: import("@_linked/core/utils/NodeReference.js").NodeReferenceValue;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Generated by `linked generate-ontology`. Do not edit: change the data and run it again.
|
|
2
|
+
// Data: src/data/capacitor.ttl
|
|
3
|
+
import { Prefix } from '@_linked/core/utils/Prefix';
|
|
4
|
+
import { createNameSpace } from '@_linked/core/utils/NameSpace';
|
|
5
|
+
import { loadOntologyFiles } from '@_linked/core/ontology/loadOntologyFiles';
|
|
6
|
+
/** The ontology data, relative to this module (Turtle, copied into `lib/` by the build). */
|
|
7
|
+
export const dataFiles = ['../data/capacitor.ttl'];
|
|
8
|
+
/** Reads the ontology data (server only). */
|
|
9
|
+
export const loadData = () => loadOntologyFiles(import.meta.url, dataFiles);
|
|
10
|
+
/** The namespace: `ns('Term')` is the `{id}` reference of any term, listed or not. */
|
|
11
|
+
export const ns = createNameSpace('https://linked.cm/ont/capacitor/');
|
|
12
|
+
Prefix.add('capacitor', 'https://linked.cm/ont/capacitor/');
|
|
13
|
+
/** The ontology itself (its namespace IRI). */
|
|
14
|
+
export const _ontologyResource = ns('');
|
|
15
|
+
//# sourceMappingURL=capacitor.data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capacitor.data.js","sourceRoot":"","sources":["../../../src/ontologies/capacitor.data.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,+BAA+B;AAC/B,OAAO,EAAC,MAAM,EAAC,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,0CAA0C,CAAC;AAE3E,4FAA4F;AAC5F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAEnD,6CAA6C;AAC7C,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;AAE5E,sFAAsF;AACtF,MAAM,CAAC,MAAM,EAAE,GAAG,eAAe,CAAC,kCAAkC,CAAC,CAAC;AACtE,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,kCAAkC,CAAC,CAAC;AAE5D,+CAA+C;AAC/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC","sourcesContent":["// Generated by `linked generate-ontology`. Do not edit: change the data and run it again.\n// Data: src/data/capacitor.ttl\nimport {Prefix} from '@_linked/core/utils/Prefix';\nimport {createNameSpace} from '@_linked/core/utils/NameSpace';\nimport {loadOntologyFiles} from '@_linked/core/ontology/loadOntologyFiles';\n\n/** The ontology data, relative to this module (Turtle, copied into `lib/` by the build). */\nexport const dataFiles = ['../data/capacitor.ttl'];\n\n/** Reads the ontology data (server only). */\nexport const loadData = () => loadOntologyFiles(import.meta.url, dataFiles);\n\n/** The namespace: `ns('Term')` is the `{id}` reference of any term, listed or not. */\nexport const ns = createNameSpace('https://linked.cm/ont/capacitor/');\nPrefix.add('capacitor', 'https://linked.cm/ont/capacitor/');\n\n/** The ontology itself (its namespace IRI). */\nexport const _ontologyResource = ns('');\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Generated by `linked generate-ontology`. Do not edit: change the data and run it again.
|
|
2
|
+
// Data: src/data/capacitor.ttl
|
|
3
|
+
import { ns } from './capacitor.data.js';
|
|
4
|
+
/** An update of a user's location, sent from the device. */
|
|
5
|
+
export const LocationUpdateAction = /*#__PURE__*/ ns('LocationUpdateAction');
|
|
6
|
+
//# sourceMappingURL=capacitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capacitor.js","sourceRoot":"","sources":["../../../src/ontologies/capacitor.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,+BAA+B;AAC/B,OAAO,EAAC,EAAE,EAAC,MAAM,qBAAqB,CAAC;AAEvC,4DAA4D;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC","sourcesContent":["// Generated by `linked generate-ontology`. Do not edit: change the data and run it again.\n// Data: src/data/capacitor.ttl\nimport {ns} from './capacitor.data.js';\n\n/** An update of a user's location, sent from the device. */\nexport const LocationUpdateAction = /*#__PURE__*/ ns('LocationUpdateAction');\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Generated by `linked generate-ontology`. Do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* Registers this ontology.
|
|
4
|
+
*
|
|
5
|
+
* Kept out of `capacitor.ts` because registration needs that module's whole export namespace, and
|
|
6
|
+
* a module cannot import itself once a bundler is involved: Rollup treats a static
|
|
7
|
+
* self-reference as a circular import and elides it, so the binding is undefined at runtime
|
|
8
|
+
* and the app dies at boot with `_this is not defined`. From a sibling module the same import
|
|
9
|
+
* is ordinary and survives.
|
|
10
|
+
*/
|
|
11
|
+
import * as terms from './capacitor.js';
|
|
12
|
+
import { dataFiles, loadData, ns } from './capacitor.data.js';
|
|
13
|
+
import { linkedOntology } from '../package.js';
|
|
14
|
+
linkedOntology(terms, ns, 'capacitor', loadData, dataFiles);
|
|
15
|
+
//# sourceMappingURL=capacitor.register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capacitor.register.js","sourceRoot":"","sources":["../../../src/ontologies/capacitor.register.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD;;;;;;;;GAQG;AACH,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAC,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAE7C,cAAc,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC","sourcesContent":["// Generated by `linked generate-ontology`. Do not edit.\n/**\n * Registers this ontology.\n *\n * Kept out of `capacitor.ts` because registration needs that module's whole export namespace, and\n * a module cannot import itself once a bundler is involved: Rollup treats a static\n * self-reference as a circular import and elides it, so the binding is undefined at runtime\n * and the app dies at boot with `_this is not defined`. From a sibling module the same import\n * is ordinary and survives.\n */\nimport * as terms from './capacitor.js';\nimport {dataFiles, loadData, ns} from './capacitor.data.js';\nimport {linkedOntology} from '../package.js';\n\nlinkedOntology(terms, ns, 'capacitor', loadData, dataFiles);\n"]}
|
package/lib/esm/package.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const linkedShape: {
|
|
2
2
|
<T extends typeof import("@_linked/core/shapes/Shape.js").Shape>(constructor: T): void;
|
|
3
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<
|
|
4
|
+
}, linkedUtil: (constructor: any) => any, linkedOntology: (allFileExports: any, nameSpace: (term: string) => import("@_linked/core/utils/NodeReference.js").NodeReferenceValue, suggestedPrefixAndFileName: string, loadDataFunction?: () => Promise<unknown>, 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
5
|
declare const linkedComponent: {
|
|
6
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
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>;
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Server } from '@_linked/server-utils/utils/Server';
|
|
8
8
|
import { linkedShape, packageName } from '../package.js';
|
|
9
9
|
import { UpdateAction } from '@_linked/schema/shapes/UpdateAction';
|
|
10
|
-
import
|
|
10
|
+
import * as capacitor from '../ontologies/capacitor.js';
|
|
11
11
|
let LocationUpdateAction = class LocationUpdateAction extends UpdateAction {
|
|
12
12
|
/**
|
|
13
13
|
* update user location
|
|
@@ -26,7 +26,7 @@ let LocationUpdateAction = class LocationUpdateAction extends UpdateAction {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
LocationUpdateAction.targetClass =
|
|
29
|
+
LocationUpdateAction.targetClass = capacitor.LocationUpdateAction;
|
|
30
30
|
LocationUpdateAction = __decorate([
|
|
31
31
|
linkedShape
|
|
32
32
|
], LocationUpdateAction);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocationUpdateAction.js","sourceRoot":"","sources":["../../../src/shapes/LocationUpdateAction.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"LocationUpdateAction.js","sourceRoot":"","sources":["../../../src/shapes/LocationUpdateAction.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAC;AAGjD,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,YAAY;IAGpD;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,QAAgB,EAAE,SAAiB;QACjE,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,SAAS,CAAC;aACvE,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACP,CAAC;;AAjBM,gCAAW,GAAG,SAAS,CAAC,oBAAoB,AAAjC,CAAkC;AADzC,oBAAoB;IADhC,WAAW;GACC,oBAAoB,CAmBhC","sourcesContent":["import { Server } from '@_linked/server-utils/utils/Server';\nimport { linkedShape, packageName } from '../package.js';\nimport { UpdateAction } from '@_linked/schema/shapes/UpdateAction';\nimport * as capacitor from '../ontologies/capacitor.js';\n\n@linkedShape\nexport class LocationUpdateAction extends UpdateAction {\n static targetClass = capacitor.LocationUpdateAction;\n\n /**\n * update user location\n *\n * @param latitude\n * @param longitude\n */\n static async updateUserLocation(latitude: number, longitude: number) {\n return Server.call(packageName, 'updateUserLocation', latitude, longitude)\n .then((result) => {\n return result;\n })\n .catch((err) => {\n console.log('Update user location failed', err);\n throw new Error(err);\n });\n }\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import '../ontologies/
|
|
1
|
+
import '../ontologies/capacitor.register.js';
|
|
2
2
|
import './LocationUpdateAction.js';
|
package/lib/esm/shapes/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Side-effect imports only. Apps register every shape with import '@linked.cm/capacitor/shapes/index'.
|
|
2
2
|
// The register import stays here so that path registers the ontology without loading the components.
|
|
3
|
-
import '../ontologies/
|
|
3
|
+
import '../ontologies/capacitor.register.js';
|
|
4
4
|
import './LocationUpdateAction.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shapes/index.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,qGAAqG;AACrG,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shapes/index.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,qGAAqG;AACrG,OAAO,qCAAqC,CAAC;AAC7C,OAAO,2BAA2B,CAAC","sourcesContent":["// Side-effect imports only. Apps register every shape with import '@linked.cm/capacitor/shapes/index'.\n// The register import stays here so that path registers the ontology without loading the components.\nimport '../ontologies/capacitor.register.js';\nimport './LocationUpdateAction.js';\n"]}
|
package/package.json
CHANGED
|
@@ -10,8 +10,15 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+ssh://git@github.com/linked-cm/capacitor.git"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.
|
|
14
|
-
"
|
|
13
|
+
"version": "1.0.0",
|
|
14
|
+
"linked": {
|
|
15
|
+
"kind": "library"
|
|
16
|
+
},
|
|
17
|
+
"linkedOntologies": {
|
|
18
|
+
"capacitor": {
|
|
19
|
+
"namespace": "https://linked.cm/ont/capacitor/"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
15
22
|
"type": "module",
|
|
16
23
|
"main": "lib/esm/index.js",
|
|
17
24
|
"module": "lib/esm/index.js",
|
|
@@ -20,10 +27,8 @@
|
|
|
20
27
|
"license": "ISC",
|
|
21
28
|
"scripts": {
|
|
22
29
|
"start": "linked dev",
|
|
23
|
-
"test": "npm run build
|
|
24
|
-
"build": "
|
|
25
|
-
"build-esm": "echo \"compiling ESM\" && rimraf ./lib/esm && tsc -p tsconfig-esm.json",
|
|
26
|
-
"copy-to-lib": "echo 'copying CSS + JSON assets to lib folder' && copyfiles -u 1 'src/**/*.css' 'src/**/*.json' lib/esm"
|
|
30
|
+
"test": "npm run build && node --test tests/*.test.mjs",
|
|
31
|
+
"build": "linked build"
|
|
27
32
|
},
|
|
28
33
|
"keywords": [
|
|
29
34
|
"linked",
|
|
@@ -53,19 +58,19 @@
|
|
|
53
58
|
}
|
|
54
59
|
},
|
|
55
60
|
"dependencies": {
|
|
56
|
-
"@_linked/auth": "^3.
|
|
57
|
-
"@_linked/core": "^2.
|
|
58
|
-
"@_linked/primitives": "^1.
|
|
59
|
-
"@_linked/react": "^2.
|
|
60
|
-
"@_linked/schema": "^1.
|
|
61
|
-
"@_linked/server-utils": "^1.
|
|
62
|
-
"@_linked/sioc": "^1.
|
|
61
|
+
"@_linked/auth": "^3.21.0",
|
|
62
|
+
"@_linked/core": "^2.46.0",
|
|
63
|
+
"@_linked/primitives": "^1.10.0",
|
|
64
|
+
"@_linked/react": "^2.1.0",
|
|
65
|
+
"@_linked/schema": "^1.9.2",
|
|
66
|
+
"@_linked/server-utils": "^1.17.0",
|
|
67
|
+
"@_linked/sioc": "^1.6.2",
|
|
63
68
|
"google-libphonenumber": "3.2.33",
|
|
64
69
|
"react-international-phone": "4.0.4",
|
|
65
70
|
"react-router-dom": "^6.22.3"
|
|
66
71
|
},
|
|
67
72
|
"devDependencies": {
|
|
68
|
-
"@_linked/cli": "^1.
|
|
73
|
+
"@_linked/cli": "^1.61.0",
|
|
69
74
|
"@capacitor/app": "^7.0.0",
|
|
70
75
|
"@capacitor/core": "^7.0.0",
|
|
71
76
|
"@capacitor/dialog": "^7.0.0",
|
|
@@ -81,12 +86,13 @@
|
|
|
81
86
|
"@types/react": "^19.3.0",
|
|
82
87
|
"@types/react-dom": "^19.3.0",
|
|
83
88
|
"capacitor-plugin-safe-area": "^4.0.3",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
89
|
+
"react": "^19.3.1",
|
|
90
|
+
"react-dom": "^19.3.1",
|
|
86
91
|
"typescript": "^5.7.3",
|
|
87
92
|
"typescript-plugin-css-modules": "^5.1.0"
|
|
88
93
|
},
|
|
89
94
|
"peerDependencies": {
|
|
95
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
90
96
|
"@capacitor/app": ">=7 <8",
|
|
91
97
|
"@capacitor/core": ">=7 <8",
|
|
92
98
|
"@capacitor/dialog": ">=7 <8",
|
package/readme.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Native app helpers for social sign-in, WhatsApp one-time codes, safe area, location, and store or bundle updates.
|
|
4
4
|
|
|
5
|
-
The location term
|
|
5
|
+
The location term `LocationUpdateAction` (a `schema:UpdateAction`) lives at `https://linked.cm/ont/capacitor/` (prefix `capacitor`), declared in `src/data/capacitor.ttl`, the only source of terms. `linked generate-ontology` writes the accessor modules from it (`package.json` `"linkedOntologies"`), and `linked build` fails when they are stale. Import the terms as a namespace: `import * as capacitor from '@linked.cm/capacitor/ontologies/capacitor'` (`capacitor.LocationUpdateAction`), and `ns`/`loadData` from `@linked.cm/capacitor/ontologies/capacitor.data`. Shape registration uses `@linked.cm/capacitor`.
|
|
6
6
|
|
|
7
7
|
## Public entry points
|
|
8
8
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
|
|
4
|
+
import { getDownloadOptions } from '../lib/esm/hooks/useAutomaticUpdates.js';
|
|
5
|
+
|
|
6
|
+
test('forwards integrity and delivery metadata from getLatest to download', () => {
|
|
7
|
+
const manifest = [
|
|
8
|
+
{
|
|
9
|
+
file_name: 'assets/index.js',
|
|
10
|
+
file_hash: 'file-checksum',
|
|
11
|
+
download_url: 'https://updates.example/assets/index.js',
|
|
12
|
+
},
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
assert.deepEqual(
|
|
16
|
+
getDownloadOptions({
|
|
17
|
+
url: 'https://updates.example/bundle.zip',
|
|
18
|
+
version: '4.3.2',
|
|
19
|
+
checksum: 'bundle-checksum',
|
|
20
|
+
sessionKey: 'encrypted-session-key',
|
|
21
|
+
manifest,
|
|
22
|
+
}),
|
|
23
|
+
{
|
|
24
|
+
url: 'https://updates.example/bundle.zip',
|
|
25
|
+
version: '4.3.2',
|
|
26
|
+
checksum: 'bundle-checksum',
|
|
27
|
+
sessionKey: 'encrypted-session-key',
|
|
28
|
+
manifest,
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('keeps optional download metadata optional', () => {
|
|
34
|
+
assert.deepEqual(
|
|
35
|
+
getDownloadOptions({
|
|
36
|
+
url: 'https://updates.example/bundle.zip',
|
|
37
|
+
version: '4.3.2',
|
|
38
|
+
}),
|
|
39
|
+
{
|
|
40
|
+
url: 'https://updates.example/bundle.zip',
|
|
41
|
+
version: '4.3.2',
|
|
42
|
+
checksum: undefined,
|
|
43
|
+
sessionKey: undefined,
|
|
44
|
+
manifest: undefined,
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// The capacitor ontology lives at https://linked.cm/ont/capacitor/, ships as Turtle, and the
|
|
2
|
+
// package's shapes agree with it under the shape check `linked build` runs.
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import test from 'node:test';
|
|
5
|
+
|
|
6
|
+
import { Prefix } from '@_linked/core/utils/Prefix';
|
|
7
|
+
import { definedTermsFromTurtle } from '@_linked/core/ontology/hierarchy';
|
|
8
|
+
import { checkShapeHierarchy } from '@_linked/core/shapes/checkShapeHierarchy';
|
|
9
|
+
import '@_linked/schema/shapes/index';
|
|
10
|
+
import * as capacitor from '../lib/esm/ontologies/capacitor.js';
|
|
11
|
+
import { _ontologyResource, loadData } from '../lib/esm/ontologies/capacitor.data.js';
|
|
12
|
+
import '../lib/esm/shapes/index.js';
|
|
13
|
+
import { packageName } from '../lib/esm/package.js';
|
|
14
|
+
|
|
15
|
+
const NAMESPACE = 'https://linked.cm/ont/capacitor/';
|
|
16
|
+
|
|
17
|
+
test('mints terms under https://linked.cm/ont/capacitor/ and exports only terms', () => {
|
|
18
|
+
assert.equal(_ontologyResource.id, NAMESPACE);
|
|
19
|
+
assert.equal(capacitor.LocationUpdateAction.id, `${NAMESPACE}LocationUpdateAction`);
|
|
20
|
+
assert.deepEqual(Object.keys(capacitor), ['LocationUpdateAction']);
|
|
21
|
+
assert.equal(Prefix.getFullURI('capacitor'), NAMESPACE);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('declares LocationUpdateAction, a schema:UpdateAction, in its Turtle data', async () => {
|
|
25
|
+
const defined = await definedTermsFromTurtle(await loadData());
|
|
26
|
+
assert.ok(defined.has(capacitor.LocationUpdateAction.id));
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('passes the shape check', async () => {
|
|
30
|
+
const findings = await checkShapeHierarchy({
|
|
31
|
+
dependencies: { [packageName]: ['@_linked/core', '@_linked/schema'] },
|
|
32
|
+
});
|
|
33
|
+
assert.deepEqual(
|
|
34
|
+
findings
|
|
35
|
+
.filter((f) => f.shape?.includes('/shape/capacitor/'))
|
|
36
|
+
.map((f) => `${f.severity} ${f.kind}: ${f.message}`),
|
|
37
|
+
[]
|
|
38
|
+
);
|
|
39
|
+
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"@context": {
|
|
3
|
-
"dc": "http://purl.org/dc/elements/1.1/",
|
|
4
|
-
"owl": "http://www.w3.org/2002/07/owl#",
|
|
5
|
-
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
|
6
|
-
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
|
|
7
|
-
"lincd-capacitor": "http://lincd.org/ont/lincd-capacitor/"
|
|
8
|
-
},
|
|
9
|
-
"@graph": [
|
|
10
|
-
{
|
|
11
|
-
"@id": "lincd-capacitor:ExampleClass",
|
|
12
|
-
"@type": "rdfs:Class",
|
|
13
|
-
"rdfs:comment": "This is an example class. You can remove or rename it",
|
|
14
|
-
"rdfs:isDefinedBy": {
|
|
15
|
-
"@id": "lincd-capacitor:"
|
|
16
|
-
},
|
|
17
|
-
"rdfs:label": "Example Class"
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
File without changes
|