@inglorious/web 6.27.0 → 6.28.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/README.md +20 -17
- package/package.json +26 -26
- package/src/mount.js +1 -1
- package/src/{app-links → native/app-links}/index.js +1 -1
- package/src/{back-button → native/back-button}/index.js +1 -1
- package/src/{haptics → native/haptics}/index.js +1 -1
- package/src/{mobile → native}/index.js +8 -2
- package/src/{live-update → native/live-update}/index.js +1 -1
- package/src/{share → native/share}/index.js +1 -1
- package/src/{system-bars → native/system-bars}/index.js +1 -1
- package/src/{native-update → native/update}/index.js +1 -1
- package/types/{app-links.d.ts → native/app-links.d.ts} +1 -1
- package/types/{mobile.d.ts → native/index.d.ts} +2 -2
- package/types/{live-update.d.ts → native/live-update.d.ts} +1 -1
- package/types/{native-update.d.ts → native/update.d.ts} +1 -1
- /package/types/{back-button.d.ts → native/back-button.d.ts} +0 -0
- /package/types/{haptics.d.ts → native/haptics.d.ts} +0 -0
- /package/types/{share.d.ts → native/share.d.ts} +0 -0
- /package/types/{system-bars.d.ts → native/system-bars.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1465,7 +1465,7 @@ Updates are not optional. A new version downloads in the background, and is appl
|
|
|
1465
1465
|
It also checks for a new version every hour and on every return to the foreground: a phone suspends an installed PWA rather than closing it, so the browser's own check may never come.
|
|
1466
1466
|
|
|
1467
1467
|
```javascript
|
|
1468
|
-
import { isNative } from "@inglorious/web/
|
|
1468
|
+
import { isNative } from "@inglorious/web/native"
|
|
1469
1469
|
import { watchPwaUpdate } from "@inglorious/web/pwa"
|
|
1470
1470
|
import { registerSW } from "virtual:pwa-register"
|
|
1471
1471
|
|
|
@@ -1518,14 +1518,14 @@ Inglorious UI's `Snackbar` is the usual place for it. `watchPwaUpdate` takes `{
|
|
|
1518
1518
|
|
|
1519
1519
|
## Native App Updates
|
|
1520
1520
|
|
|
1521
|
-
A Capacitor app carries its web code inside the binary, so only the stores update it. `@inglorious/web/native
|
|
1521
|
+
A Capacitor app carries its web code inside the binary, so only the stores update it. `@inglorious/web/native/update` makes an update mandatory: the app reads a minimum build per platform, and a build below it is blocked until the user updates. `@inglorious/create-app --mobile --push` sets it up with Supabase.
|
|
1522
1522
|
|
|
1523
1523
|
```javascript
|
|
1524
1524
|
import { App } from "@capacitor/app"
|
|
1525
1525
|
import {
|
|
1526
1526
|
createNativeUpdate,
|
|
1527
1527
|
watchNativeUpdate,
|
|
1528
|
-
} from "@inglorious/web/native
|
|
1528
|
+
} from "@inglorious/web/native/update"
|
|
1529
1529
|
|
|
1530
1530
|
const types = { NativeUpdate: [createNativeUpdate({ adapter }), template] }
|
|
1531
1531
|
const entities = { nativeUpdate: { type: "NativeUpdate" } }
|
|
@@ -1553,12 +1553,15 @@ A failed check keeps the last answer, so nobody is blocked by being offline. Ren
|
|
|
1553
1553
|
|
|
1554
1554
|
## Live Updates
|
|
1555
1555
|
|
|
1556
|
-
A store release is only needed for native changes. `@inglorious/web/live-update` replaces the web code inside a Capacitor app with a newer published bundle, through [`@capawesome/capacitor-live-update`](https://capawesome.io/plugins/live-update/), whose open source plugin downloads from any URL. `publishLiveUpdate` from `@inglorious/supabase/live-update` publishes one.
|
|
1556
|
+
A store release is only needed for native changes. `@inglorious/web/native/live-update` replaces the web code inside a Capacitor app with a newer published bundle, through [`@capawesome/capacitor-live-update`](https://capawesome.io/plugins/live-update/), whose open source plugin downloads from any URL. `publishLiveUpdate` from `@inglorious/supabase/live-update` publishes one.
|
|
1557
1557
|
|
|
1558
1558
|
```javascript
|
|
1559
1559
|
import { App } from "@capacitor/app"
|
|
1560
1560
|
import { LiveUpdate } from "@capawesome/capacitor-live-update"
|
|
1561
|
-
import {
|
|
1561
|
+
import {
|
|
1562
|
+
createLiveUpdate,
|
|
1563
|
+
watchLiveUpdate,
|
|
1564
|
+
} from "@inglorious/web/native/live-update"
|
|
1562
1565
|
|
|
1563
1566
|
const types = { LiveUpdate: createLiveUpdate({ plugin: LiveUpdate }) }
|
|
1564
1567
|
const entities = { liveUpdate: { type: "LiveUpdate" } }
|
|
@@ -1628,11 +1631,11 @@ The adapter talks to the backend. `supabaseAuth` from `@inglorious/supabase` is
|
|
|
1628
1631
|
|
|
1629
1632
|
## App Links
|
|
1630
1633
|
|
|
1631
|
-
With Universal Links (iOS) and App Links (Android), a link to the app's domain opens the installed app instead of the browser. `@inglorious/web/app-links` sends the router to that link's path, both for the link that started the app and for links that arrive while it runs. It does nothing outside a native app.
|
|
1634
|
+
With Universal Links (iOS) and App Links (Android), a link to the app's domain opens the installed app instead of the browser. `@inglorious/web/native/app-links` sends the router to that link's path, both for the link that started the app and for links that arrive while it runs. It does nothing outside a native app.
|
|
1632
1635
|
|
|
1633
1636
|
```javascript
|
|
1634
1637
|
import { App } from "@capacitor/app"
|
|
1635
|
-
import { watchAppLinks } from "@inglorious/web/app-links"
|
|
1638
|
+
import { watchAppLinks } from "@inglorious/web/native/app-links"
|
|
1636
1639
|
|
|
1637
1640
|
watchAppLinks(App, store)
|
|
1638
1641
|
```
|
|
@@ -1645,11 +1648,11 @@ The operating system opens the app only when the domain vouches for it: iOS read
|
|
|
1645
1648
|
|
|
1646
1649
|
## Back Button
|
|
1647
1650
|
|
|
1648
|
-
On Android, the back button and the back gesture go back in history. `@inglorious/web/back-button` closes the app instead on a root path, a top-level page like a tab bar's, and when there is no history left, as other Android apps do. It does nothing outside a native app, and iOS has no back button.
|
|
1651
|
+
On Android, the back button and the back gesture go back in history. `@inglorious/web/native/back-button` closes the app instead on a root path, a top-level page like a tab bar's, and when there is no history left, as other Android apps do. It does nothing outside a native app, and iOS has no back button.
|
|
1649
1652
|
|
|
1650
1653
|
```javascript
|
|
1651
1654
|
import { App } from "@capacitor/app"
|
|
1652
|
-
import { watchBackButton } from "@inglorious/web/back-button"
|
|
1655
|
+
import { watchBackButton } from "@inglorious/web/native/back-button"
|
|
1653
1656
|
|
|
1654
1657
|
watchBackButton(App, { rootPaths: ["/", "/search", "/profile"] })
|
|
1655
1658
|
```
|
|
@@ -1660,11 +1663,11 @@ watchBackButton(App, { rootPaths: ["/", "/search", "/profile"] })
|
|
|
1660
1663
|
|
|
1661
1664
|
## System Bars
|
|
1662
1665
|
|
|
1663
|
-
The status bar and Android's navigation bar follow the device's light or dark mode, so a light app on a phone in dark mode gets white icons on a white page. `@inglorious/web/system-bars` sets them from the app's own `color-scheme`, which every Inglorious UI theme sets, and follows it when the theme class changes. An app whose `color-scheme` is `light dark` keeps the device's style. It does nothing outside a native app.
|
|
1666
|
+
The status bar and Android's navigation bar follow the device's light or dark mode, so a light app on a phone in dark mode gets white icons on a white page. `@inglorious/web/native/system-bars` sets them from the app's own `color-scheme`, which every Inglorious UI theme sets, and follows it when the theme class changes. An app whose `color-scheme` is `light dark` keeps the device's style. It does nothing outside a native app.
|
|
1664
1667
|
|
|
1665
1668
|
```javascript
|
|
1666
1669
|
import { SystemBars } from "@capacitor/core"
|
|
1667
|
-
import { watchSystemBars } from "@inglorious/web/system-bars"
|
|
1670
|
+
import { watchSystemBars } from "@inglorious/web/native/system-bars"
|
|
1668
1671
|
|
|
1669
1672
|
watchSystemBars(SystemBars)
|
|
1670
1673
|
```
|
|
@@ -1698,7 +1701,7 @@ It returns a function that stops following.
|
|
|
1698
1701
|
|
|
1699
1702
|
## Share
|
|
1700
1703
|
|
|
1701
|
-
`@inglorious/web/share` is the type behind a share button. `share` hands a title, a text, a link or a file to whatever the device does best, and the entity says what happened:
|
|
1704
|
+
`@inglorious/web/native/share` is the type behind a share button. `share` hands a title, a text, a link or a file to whatever the device does best, and the entity says what happened:
|
|
1702
1705
|
|
|
1703
1706
|
- in a native app, the system's share sheet, through [`@capacitor/share`](https://capacitorjs.com/docs/apis/share) when you hand it over;
|
|
1704
1707
|
- in a browser, a file (a `url` with a `fileName`) downloads, since a browser has nowhere better to put it;
|
|
@@ -1706,7 +1709,7 @@ It returns a function that stops following.
|
|
|
1706
1709
|
|
|
1707
1710
|
```javascript
|
|
1708
1711
|
import { Share } from "@capacitor/share"
|
|
1709
|
-
import { createShare } from "@inglorious/web/share"
|
|
1712
|
+
import { createShare } from "@inglorious/web/native/share"
|
|
1710
1713
|
|
|
1711
1714
|
const types = { Share: createShare({ plugin: Share }) }
|
|
1712
1715
|
|
|
@@ -1732,7 +1735,7 @@ iOS and Android can clear a WebView's `localStorage` when the device runs low on
|
|
|
1732
1735
|
```javascript
|
|
1733
1736
|
import { Preferences } from "@capacitor/preferences"
|
|
1734
1737
|
import { withStorage } from "@inglorious/store/storage"
|
|
1735
|
-
import { createNativeStorage } from "@inglorious/web/
|
|
1738
|
+
import { createNativeStorage } from "@inglorious/web/native"
|
|
1736
1739
|
|
|
1737
1740
|
const preferences = createNativeStorage({ plugin: Preferences })
|
|
1738
1741
|
|
|
@@ -1741,7 +1744,7 @@ const types = {
|
|
|
1741
1744
|
}
|
|
1742
1745
|
```
|
|
1743
1746
|
|
|
1744
|
-
Preferences answers with promises, so in the native app the entity starts with its defaults and gets the stored fields back a moment later, through `storageRestore`. In a browser it
|
|
1747
|
+
Preferences answers with promises, so in the native app the entity starts with its defaults and gets the stored fields back a moment later, through `storageRestore`. In a browser it uses `localStorage`.
|
|
1745
1748
|
|
|
1746
1749
|
It works as Supabase's session storage too, so signing in survives the same clean-ups:
|
|
1747
1750
|
|
|
@@ -1751,11 +1754,11 @@ createClient(url, key, { auth: { storage: preferences } })
|
|
|
1751
1754
|
|
|
1752
1755
|
## Haptics
|
|
1753
1756
|
|
|
1754
|
-
`@inglorious/web/haptics` plays taps the user can feel. In a native app it uses the system's haptics through [`@capacitor/haptics`](https://capacitorjs.com/docs/apis/haptics), once you hand the plugin over. Elsewhere it vibrates where the browser can (Chrome on Android), once the user has tapped the page; iOS browsers stay silent. Every call returns whether it played.
|
|
1757
|
+
`@inglorious/web/native/haptics` plays taps the user can feel. In a native app it uses the system's haptics through [`@capacitor/haptics`](https://capacitorjs.com/docs/apis/haptics), once you hand the plugin over. Elsewhere it vibrates where the browser can (Chrome on Android), once the user has tapped the page; iOS browsers stay silent. Every call returns whether it played.
|
|
1755
1758
|
|
|
1756
1759
|
```javascript
|
|
1757
1760
|
import { Haptics } from "@capacitor/haptics"
|
|
1758
|
-
import { haptics } from "@inglorious/web/haptics"
|
|
1761
|
+
import { haptics } from "@inglorious/web/native/haptics"
|
|
1759
1762
|
|
|
1760
1763
|
haptics.use(Haptics)
|
|
1761
1764
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inglorious/web",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.28.0",
|
|
4
4
|
"description": "A new web framework that leverages the power of the Inglorious Store combined with the performance and simplicity of lit-html.",
|
|
5
5
|
"author": "Matteo Antony Mistretta <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
|
|
6
6
|
"contributors": [
|
|
@@ -37,33 +37,33 @@
|
|
|
37
37
|
"types": "./types/analytics.d.ts",
|
|
38
38
|
"import": "./src/analytics/index.js"
|
|
39
39
|
},
|
|
40
|
-
"./app-links": {
|
|
41
|
-
"types": "./types/app-links.d.ts",
|
|
42
|
-
"import": "./src/app-links/index.js"
|
|
40
|
+
"./native/app-links": {
|
|
41
|
+
"types": "./types/native/app-links.d.ts",
|
|
42
|
+
"import": "./src/native/app-links/index.js"
|
|
43
43
|
},
|
|
44
44
|
"./auth": {
|
|
45
45
|
"types": "./types/auth.d.ts",
|
|
46
46
|
"import": "./src/auth/index.js"
|
|
47
47
|
},
|
|
48
|
-
"./back-button": {
|
|
49
|
-
"types": "./types/back-button.d.ts",
|
|
50
|
-
"import": "./src/back-button/index.js"
|
|
48
|
+
"./native/back-button": {
|
|
49
|
+
"types": "./types/native/back-button.d.ts",
|
|
50
|
+
"import": "./src/native/back-button/index.js"
|
|
51
51
|
},
|
|
52
|
-
"./system-bars": {
|
|
53
|
-
"types": "./types/system-bars.d.ts",
|
|
54
|
-
"import": "./src/system-bars/index.js"
|
|
52
|
+
"./native/system-bars": {
|
|
53
|
+
"types": "./types/native/system-bars.d.ts",
|
|
54
|
+
"import": "./src/native/system-bars/index.js"
|
|
55
55
|
},
|
|
56
56
|
"./keyboard": {
|
|
57
57
|
"types": "./types/keyboard.d.ts",
|
|
58
58
|
"import": "./src/keyboard/index.js"
|
|
59
59
|
},
|
|
60
|
-
"./haptics": {
|
|
61
|
-
"types": "./types/haptics.d.ts",
|
|
62
|
-
"import": "./src/haptics/index.js"
|
|
60
|
+
"./native/haptics": {
|
|
61
|
+
"types": "./types/native/haptics.d.ts",
|
|
62
|
+
"import": "./src/native/haptics/index.js"
|
|
63
63
|
},
|
|
64
|
-
"./share": {
|
|
65
|
-
"types": "./types/share.d.ts",
|
|
66
|
-
"import": "./src/share/index.js"
|
|
64
|
+
"./native/share": {
|
|
65
|
+
"types": "./types/native/share.d.ts",
|
|
66
|
+
"import": "./src/native/share/index.js"
|
|
67
67
|
},
|
|
68
68
|
"./decorators/with-debounce": {
|
|
69
69
|
"types": "./types/decorators/with-debounce.d.ts",
|
|
@@ -90,17 +90,17 @@
|
|
|
90
90
|
"import": "./src/form/index.js"
|
|
91
91
|
},
|
|
92
92
|
"./hydrate": "./src/hydrate.js",
|
|
93
|
-
"./live-update": {
|
|
94
|
-
"types": "./types/live-update.d.ts",
|
|
95
|
-
"import": "./src/live-update/index.js"
|
|
93
|
+
"./native/live-update": {
|
|
94
|
+
"types": "./types/native/live-update.d.ts",
|
|
95
|
+
"import": "./src/native/live-update/index.js"
|
|
96
96
|
},
|
|
97
|
-
"./
|
|
98
|
-
"types": "./types/
|
|
99
|
-
"import": "./src/
|
|
97
|
+
"./native": {
|
|
98
|
+
"types": "./types/native/index.d.ts",
|
|
99
|
+
"import": "./src/native/index.js"
|
|
100
100
|
},
|
|
101
|
-
"./native
|
|
102
|
-
"types": "./types/native
|
|
103
|
-
"import": "./src/native
|
|
101
|
+
"./native/update": {
|
|
102
|
+
"types": "./types/native/update.d.ts",
|
|
103
|
+
"import": "./src/native/update/index.js"
|
|
104
104
|
},
|
|
105
105
|
"./pwa": {
|
|
106
106
|
"types": "./types/pwa.d.ts",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"lit-html": "^3.3.3"
|
|
163
163
|
},
|
|
164
164
|
"peerDependencies": {
|
|
165
|
-
"@inglorious/store": "^12.6.
|
|
165
|
+
"@inglorious/store": "^12.6.2"
|
|
166
166
|
},
|
|
167
167
|
"devDependencies": {
|
|
168
168
|
"@inglorious/eslint-config": "1.2.0",
|
package/src/mount.js
CHANGED
|
@@ -26,7 +26,7 @@ let plugin = null
|
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
28
|
* import { Haptics } from "@capacitor/haptics"
|
|
29
|
-
* import { haptics } from "@inglorious/web/haptics"
|
|
29
|
+
* import { haptics } from "@inglorious/web/native/haptics"
|
|
30
30
|
*
|
|
31
31
|
* haptics.use(Haptics)
|
|
32
32
|
* haptics.notification("success")
|
|
@@ -20,7 +20,7 @@ export function isNative() {
|
|
|
20
20
|
* A storage for `withStorage` that survives the operating system clearing the
|
|
21
21
|
* WebView's data: in a native app, Capacitor Preferences (`Preferences` from
|
|
22
22
|
* `@capacitor/preferences`, given as `plugin`), answering with promises; in a
|
|
23
|
-
* browser, `localStorage
|
|
23
|
+
* browser, `localStorage`, looked up at each call. It also serves as Supabase's `auth.storage`,
|
|
24
24
|
* keeping the session there too.
|
|
25
25
|
*
|
|
26
26
|
* @param {{ plugin?: { get(options: { key: string }): Promise<{ value: string | null }>, set(options: { key: string, value: string }): Promise<void>, remove(options: { key: string }): Promise<void> } }} [config]
|
|
@@ -33,7 +33,13 @@ export function isNative() {
|
|
|
33
33
|
* }
|
|
34
34
|
*/
|
|
35
35
|
export function createNativeStorage({ plugin } = {}) {
|
|
36
|
-
if (!plugin || !isNative())
|
|
36
|
+
if (!plugin || !isNative()) {
|
|
37
|
+
return {
|
|
38
|
+
getItem: (key) => globalThis.localStorage?.getItem(key) ?? null,
|
|
39
|
+
setItem: (key, value) => globalThis.localStorage?.setItem(key, value),
|
|
40
|
+
removeItem: (key) => globalThis.localStorage?.removeItem(key),
|
|
41
|
+
}
|
|
42
|
+
}
|
|
37
43
|
|
|
38
44
|
return {
|
|
39
45
|
getItem: async (key) => (await plugin.get({ key })).value,
|
|
@@ -14,7 +14,7 @@ export interface NativeStorage {
|
|
|
14
14
|
removeItem(key: string): void | Promise<void>
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
/** Capacitor Preferences in a native app, `localStorage`
|
|
17
|
+
/** Capacitor Preferences in a native app, `localStorage` in a browser. */
|
|
18
18
|
export declare function createNativeStorage(config?: {
|
|
19
19
|
plugin?: PreferencesPlugin
|
|
20
|
-
}): NativeStorage
|
|
20
|
+
}): NativeStorage
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|