@inglorious/web 6.27.1 → 6.29.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.
Files changed (47) hide show
  1. package/README.md +263 -203
  2. package/package.json +68 -56
  3. package/src/device/biometrics/index.js +86 -0
  4. package/src/device/compass/handlers.js +163 -0
  5. package/src/{sensors → device}/element-size/handlers.js +2 -2
  6. package/src/device/geolocation/index.js +120 -0
  7. package/src/{haptics → device/haptics}/index.js +1 -1
  8. package/src/device/local-notifications/index.js +133 -0
  9. package/src/{sensors → device}/media-query/handlers.js +2 -2
  10. package/src/{sensors → device}/network-status/handlers.js +1 -1
  11. package/src/{sensors → device}/page-visibility/handlers.js +1 -1
  12. package/src/{share → device/share}/index.js +1 -1
  13. package/src/{mobile → device/storage}/index.js +29 -17
  14. package/src/mount.js +1 -1
  15. package/src/{app-links → native/app-links}/index.js +1 -1
  16. package/src/{back-button → native/back-button}/index.js +1 -1
  17. package/src/native/index.js +17 -0
  18. package/src/{live-update → native/live-update}/index.js +1 -1
  19. package/src/{system-bars → native/system-bars}/index.js +1 -1
  20. package/src/{native-update → native/update}/index.js +1 -1
  21. package/types/device/biometrics.d.ts +51 -0
  22. package/types/{sensors → device}/compass.d.ts +0 -2
  23. package/types/{sensors → device}/geolocation.d.ts +25 -7
  24. package/types/device/local-notifications.d.ts +76 -0
  25. package/types/{mobile.d.ts → device/storage.d.ts} +12 -2
  26. package/types/{app-links.d.ts → native/app-links.d.ts} +1 -1
  27. package/types/native/index.d.ts +1 -0
  28. package/types/{live-update.d.ts → native/live-update.d.ts} +1 -1
  29. package/types/{native-update.d.ts → native/update.d.ts} +1 -1
  30. package/src/sensors/compass/handlers.js +0 -209
  31. package/src/sensors/geolocation/handlers.js +0 -168
  32. package/src/sensors/geolocation/index.js +0 -3
  33. /package/src/{sensors → device}/compass/index.js +0 -0
  34. /package/src/{sensors → device}/element-size/index.js +0 -0
  35. /package/src/{keyboard → device/keyboard}/index.js +0 -0
  36. /package/src/{sensors → device}/media-query/index.js +0 -0
  37. /package/src/{sensors → device}/network-status/index.js +0 -0
  38. /package/src/{sensors → device}/page-visibility/index.js +0 -0
  39. /package/types/{sensors → device}/element-size.d.ts +0 -0
  40. /package/types/{haptics.d.ts → device/haptics.d.ts} +0 -0
  41. /package/types/{keyboard.d.ts → device/keyboard.d.ts} +0 -0
  42. /package/types/{sensors → device}/media-query.d.ts +0 -0
  43. /package/types/{sensors → device}/network-status.d.ts +0 -0
  44. /package/types/{sensors → device}/page-visibility.d.ts +0 -0
  45. /package/types/{share.d.ts → device/share.d.ts} +0 -0
  46. /package/types/{back-button.d.ts → native/back-button.d.ts} +0 -0
  47. /package/types/{system-bars.d.ts → native/system-bars.d.ts} +0 -0
@@ -1,168 +0,0 @@
1
- /**
2
- * @typedef {import("../../../types/sensors/geolocation.js").GeolocationEntity} GeolocationEntity
3
- * @typedef {import("../../../types/sensors/geolocation.js").GeolocationOptions} GeolocationOptions
4
- * @typedef {import("../../../types/sensors/geolocation.js").GeolocationPosition} GeolocationPosition
5
- */
6
-
7
- const NO_WATCH_ID = null
8
-
9
- /**
10
- * Initializes the geolocation entity with default state.
11
- * @param {GeolocationEntity} entity - The geolocation entity.
12
- */
13
- export function create(entity) {
14
- entity.error ??= null
15
- entity.isLoading ??= false
16
- entity.isSupported = Boolean(getGeolocation())
17
- entity.isWatching ??= false
18
- entity.position ??= null
19
- entity.watchId ??= NO_WATCH_ID
20
- }
21
-
22
- /**
23
- * Clears the geolocation watch before the entity is destroyed.
24
- * @param {GeolocationEntity} entity - The geolocation entity.
25
- */
26
- export function destroy(entity) {
27
- geolocationUnwatch(entity)
28
- }
29
-
30
- /**
31
- * Stores a normalized geolocation error.
32
- * @param {GeolocationEntity} entity - The geolocation entity.
33
- * @param {GeolocationPositionError} error - The geolocation error.
34
- */
35
- export function geolocationError(entity, error) {
36
- entity.error = normalizeError(error)
37
- entity.isLoading = false
38
- }
39
-
40
- /**
41
- * Requests the current geolocation position.
42
- * @param {GeolocationEntity} entity - The geolocation entity.
43
- * @param {GeolocationOptions} options - Position options.
44
- * @param {{ notify: Function }} api - The store API.
45
- */
46
- export function geolocationRequest(entity, options = {}, api) {
47
- const geolocation = getGeolocation()
48
-
49
- entity.isSupported = Boolean(geolocation)
50
- entity.error = null
51
-
52
- if (!geolocation) {
53
- entity.isLoading = false
54
- api.notify("geolocationError", createUnsupportedError())
55
- return
56
- }
57
-
58
- entity.isLoading = true
59
-
60
- geolocation.getCurrentPosition(
61
- (position) => {
62
- api.notify("geolocationSuccess", normalizePosition(position))
63
- },
64
- (error) => {
65
- api.notify("geolocationError", error)
66
- },
67
- options,
68
- )
69
- }
70
-
71
- /**
72
- * Stores a normalized geolocation position.
73
- * @param {GeolocationEntity} entity - The geolocation entity.
74
- * @param {GeolocationPosition} position - The geolocation position.
75
- */
76
- export function geolocationSuccess(entity, position) {
77
- entity.error = null
78
- entity.isLoading = false
79
- entity.position = position
80
- }
81
-
82
- /**
83
- * Stops an active geolocation watch.
84
- * @param {GeolocationEntity} entity - The geolocation entity.
85
- */
86
- export function geolocationUnwatch(entity) {
87
- const geolocation = getGeolocation()
88
-
89
- if (entity.watchId !== NO_WATCH_ID && geolocation) {
90
- geolocation.clearWatch(entity.watchId)
91
- }
92
-
93
- entity.isLoading = false
94
- entity.isWatching = false
95
- entity.watchId = NO_WATCH_ID
96
- }
97
-
98
- /**
99
- * Starts watching geolocation changes.
100
- * @param {GeolocationEntity} entity - The geolocation entity.
101
- * @param {GeolocationOptions} options - Watch options.
102
- * @param {{ notify: Function }} api - The store API.
103
- */
104
- export function geolocationWatch(entity, options = {}, api) {
105
- const geolocation = getGeolocation()
106
-
107
- entity.isSupported = Boolean(geolocation)
108
- entity.error = null
109
-
110
- if (!geolocation) {
111
- entity.isLoading = false
112
- api.notify("geolocationError", createUnsupportedError())
113
- return
114
- }
115
-
116
- if (entity.watchId !== NO_WATCH_ID) {
117
- return
118
- }
119
-
120
- entity.isLoading = true
121
- entity.isWatching = true
122
- entity.watchId = geolocation.watchPosition(
123
- (position) => {
124
- api.notify("geolocationSuccess", normalizePosition(position))
125
- },
126
- (error) => {
127
- api.notify("geolocationError", error)
128
- },
129
- options,
130
- )
131
- }
132
-
133
- function createUnsupportedError() {
134
- return {
135
- code: 0,
136
- message: "Geolocation is not supported by this environment.",
137
- }
138
- }
139
-
140
- function getGeolocation() {
141
- return globalThis.navigator?.geolocation
142
- }
143
-
144
- function normalizeCoords(coords) {
145
- return {
146
- accuracy: coords.accuracy,
147
- altitude: coords.altitude,
148
- altitudeAccuracy: coords.altitudeAccuracy,
149
- heading: coords.heading,
150
- latitude: coords.latitude,
151
- longitude: coords.longitude,
152
- speed: coords.speed,
153
- }
154
- }
155
-
156
- function normalizeError(error) {
157
- return {
158
- code: error.code,
159
- message: error.message,
160
- }
161
- }
162
-
163
- function normalizePosition(position) {
164
- return {
165
- coords: normalizeCoords(position.coords),
166
- timestamp: position.timestamp,
167
- }
168
- }
@@ -1,3 +0,0 @@
1
- import * as handlers from "./handlers.js"
2
-
3
- export const Geolocation = { ...handlers }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes