@xyo-network/location-plugin 2.99.6 → 3.0.1

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 (103) hide show
  1. package/dist/neutral/index.d.ts +50 -5
  2. package/package.json +15 -34
  3. package/src/index.ts +1 -1
  4. package/xy.config.ts +4 -5
  5. package/dist/browser/Config.d.cts +0 -11
  6. package/dist/browser/Config.d.cts.map +0 -1
  7. package/dist/browser/Config.d.mts +0 -11
  8. package/dist/browser/Config.d.mts.map +0 -1
  9. package/dist/browser/Config.d.ts +0 -11
  10. package/dist/browser/Config.d.ts.map +0 -1
  11. package/dist/browser/CurrentLocationPayloadSet.d.cts +0 -3
  12. package/dist/browser/CurrentLocationPayloadSet.d.cts.map +0 -1
  13. package/dist/browser/CurrentLocationPayloadSet.d.mts +0 -3
  14. package/dist/browser/CurrentLocationPayloadSet.d.mts.map +0 -1
  15. package/dist/browser/CurrentLocationPayloadSet.d.ts +0 -3
  16. package/dist/browser/CurrentLocationPayloadSet.d.ts.map +0 -1
  17. package/dist/browser/CurrentLocationWitness.d.cts +0 -11
  18. package/dist/browser/CurrentLocationWitness.d.cts.map +0 -1
  19. package/dist/browser/CurrentLocationWitness.d.mts +0 -11
  20. package/dist/browser/CurrentLocationWitness.d.mts.map +0 -1
  21. package/dist/browser/CurrentLocationWitness.d.ts +0 -11
  22. package/dist/browser/CurrentLocationWitness.d.ts.map +0 -1
  23. package/dist/browser/Plugin.d.cts +0 -21
  24. package/dist/browser/Plugin.d.cts.map +0 -1
  25. package/dist/browser/Plugin.d.mts +0 -21
  26. package/dist/browser/Plugin.d.mts.map +0 -1
  27. package/dist/browser/Plugin.d.ts +0 -21
  28. package/dist/browser/Plugin.d.ts.map +0 -1
  29. package/dist/browser/index.cjs +0 -101
  30. package/dist/browser/index.cjs.map +0 -1
  31. package/dist/browser/index.d.cts +0 -5
  32. package/dist/browser/index.d.cts.map +0 -1
  33. package/dist/browser/index.d.mts +0 -5
  34. package/dist/browser/index.d.mts.map +0 -1
  35. package/dist/browser/index.d.ts +0 -5
  36. package/dist/browser/index.d.ts.map +0 -1
  37. package/dist/browser/index.mjs +0 -78
  38. package/dist/browser/index.mjs.map +0 -1
  39. package/dist/neutral/Config.d.cts +0 -11
  40. package/dist/neutral/Config.d.cts.map +0 -1
  41. package/dist/neutral/Config.d.mts +0 -11
  42. package/dist/neutral/Config.d.mts.map +0 -1
  43. package/dist/neutral/Config.d.ts +0 -11
  44. package/dist/neutral/Config.d.ts.map +0 -1
  45. package/dist/neutral/CurrentLocationPayloadSet.d.cts +0 -3
  46. package/dist/neutral/CurrentLocationPayloadSet.d.cts.map +0 -1
  47. package/dist/neutral/CurrentLocationPayloadSet.d.mts +0 -3
  48. package/dist/neutral/CurrentLocationPayloadSet.d.mts.map +0 -1
  49. package/dist/neutral/CurrentLocationPayloadSet.d.ts +0 -3
  50. package/dist/neutral/CurrentLocationPayloadSet.d.ts.map +0 -1
  51. package/dist/neutral/CurrentLocationWitness.d.cts +0 -11
  52. package/dist/neutral/CurrentLocationWitness.d.cts.map +0 -1
  53. package/dist/neutral/CurrentLocationWitness.d.mts +0 -11
  54. package/dist/neutral/CurrentLocationWitness.d.mts.map +0 -1
  55. package/dist/neutral/CurrentLocationWitness.d.ts +0 -11
  56. package/dist/neutral/CurrentLocationWitness.d.ts.map +0 -1
  57. package/dist/neutral/Plugin.d.cts +0 -21
  58. package/dist/neutral/Plugin.d.cts.map +0 -1
  59. package/dist/neutral/Plugin.d.mts +0 -21
  60. package/dist/neutral/Plugin.d.mts.map +0 -1
  61. package/dist/neutral/Plugin.d.ts +0 -21
  62. package/dist/neutral/Plugin.d.ts.map +0 -1
  63. package/dist/neutral/index.cjs +0 -101
  64. package/dist/neutral/index.cjs.map +0 -1
  65. package/dist/neutral/index.d.cts +0 -5
  66. package/dist/neutral/index.d.cts.map +0 -1
  67. package/dist/neutral/index.d.mts +0 -5
  68. package/dist/neutral/index.d.mts.map +0 -1
  69. package/dist/neutral/index.d.ts.map +0 -1
  70. package/dist/node/Config.d.cts +0 -11
  71. package/dist/node/Config.d.cts.map +0 -1
  72. package/dist/node/Config.d.mts +0 -11
  73. package/dist/node/Config.d.mts.map +0 -1
  74. package/dist/node/Config.d.ts +0 -11
  75. package/dist/node/Config.d.ts.map +0 -1
  76. package/dist/node/CurrentLocationPayloadSet.d.cts +0 -3
  77. package/dist/node/CurrentLocationPayloadSet.d.cts.map +0 -1
  78. package/dist/node/CurrentLocationPayloadSet.d.mts +0 -3
  79. package/dist/node/CurrentLocationPayloadSet.d.mts.map +0 -1
  80. package/dist/node/CurrentLocationPayloadSet.d.ts +0 -3
  81. package/dist/node/CurrentLocationPayloadSet.d.ts.map +0 -1
  82. package/dist/node/CurrentLocationWitness.d.cts +0 -11
  83. package/dist/node/CurrentLocationWitness.d.cts.map +0 -1
  84. package/dist/node/CurrentLocationWitness.d.mts +0 -11
  85. package/dist/node/CurrentLocationWitness.d.mts.map +0 -1
  86. package/dist/node/CurrentLocationWitness.d.ts +0 -11
  87. package/dist/node/CurrentLocationWitness.d.ts.map +0 -1
  88. package/dist/node/Plugin.d.cts +0 -21
  89. package/dist/node/Plugin.d.cts.map +0 -1
  90. package/dist/node/Plugin.d.mts +0 -21
  91. package/dist/node/Plugin.d.mts.map +0 -1
  92. package/dist/node/Plugin.d.ts +0 -21
  93. package/dist/node/Plugin.d.ts.map +0 -1
  94. package/dist/node/index.cjs +0 -109
  95. package/dist/node/index.cjs.map +0 -1
  96. package/dist/node/index.d.cts +0 -5
  97. package/dist/node/index.d.cts.map +0 -1
  98. package/dist/node/index.d.mts +0 -5
  99. package/dist/node/index.d.mts.map +0 -1
  100. package/dist/node/index.d.ts +0 -5
  101. package/dist/node/index.d.ts.map +0 -1
  102. package/dist/node/index.mjs +0 -79
  103. package/dist/node/index.mjs.map +0 -1
@@ -1,109 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- CurrentLocationPayloadSet: () => CurrentLocationPayloadSet,
24
- CurrentLocationWitness: () => CurrentLocationWitness,
25
- CurrentLocationWitnessConfigSchema: () => CurrentLocationWitnessConfigSchema,
26
- LocationPlugin: () => LocationPlugin,
27
- default: () => LocationPlugin
28
- });
29
- module.exports = __toCommonJS(src_exports);
30
-
31
- // src/Config.ts
32
- var CurrentLocationWitnessConfigSchema = "network.xyo.location.current.config";
33
-
34
- // src/CurrentLocationPayloadSet.ts
35
- var import_location_payload_plugin = require("@xyo-network/location-payload-plugin");
36
- var import_payload_model = require("@xyo-network/payload-model");
37
- var CurrentLocationPayloadSet = {
38
- optional: {
39
- [import_location_payload_plugin.LocationHeadingSchema]: 1
40
- },
41
- required: {
42
- [import_location_payload_plugin.LocationSchema]: 1
43
- },
44
- schema: import_payload_model.PayloadSetSchema
45
- };
46
-
47
- // src/CurrentLocationWitness.ts
48
- var import_assert = require("@xylabs/assert");
49
- var import_abstract_witness = require("@xyo-network/abstract-witness");
50
- var import_location_payload_plugin2 = require("@xyo-network/location-payload-plugin");
51
- var CurrentLocationWitness = class extends import_abstract_witness.AbstractWitness {
52
- static configSchemas = [...super.configSchemas, CurrentLocationWitnessConfigSchema];
53
- static defaultConfigSchema = CurrentLocationWitnessConfigSchema;
54
- get geolocation() {
55
- return (0, import_assert.assertEx)(this.params.geolocation, () => "No geolocation provided");
56
- }
57
- getCurrentPosition() {
58
- return new Promise((resolve, reject) => {
59
- var _a;
60
- (_a = this.geolocation) == null ? void 0 : _a.getCurrentPosition(
61
- (position) => {
62
- resolve(position);
63
- },
64
- (error) => {
65
- reject(error);
66
- }
67
- );
68
- });
69
- }
70
- async observeHandler() {
71
- const location = await this.getCurrentPosition();
72
- const locationPayload = {
73
- altitude: location.coords.altitude ?? void 0,
74
- altitudeAccuracy: location.coords.altitudeAccuracy ?? void 0,
75
- latitude: location.coords.latitude,
76
- longitude: location.coords.longitude,
77
- schema: import_location_payload_plugin2.LocationSchema
78
- };
79
- const heading = location.coords.heading ? [
80
- {
81
- heading: location.coords.heading ?? void 0,
82
- schema: import_location_payload_plugin2.LocationHeadingSchema,
83
- speed: location.coords.speed ?? void 0
84
- }
85
- ] : [];
86
- return [locationPayload, ...heading];
87
- }
88
- };
89
-
90
- // src/Plugin.ts
91
- var import_location_payload_plugin3 = require("@xyo-network/location-payload-plugin");
92
- var import_payload_model2 = require("@xyo-network/payload-model");
93
- var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
94
- var LocationPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
95
- { required: { [import_location_payload_plugin3.LocationSchema]: 1 }, schema: import_payload_model2.PayloadSetSchema },
96
- {
97
- witness: async (params) => {
98
- return await CurrentLocationWitness.create(params);
99
- }
100
- }
101
- );
102
- // Annotate the CommonJS export names for ESM import in node:
103
- 0 && (module.exports = {
104
- CurrentLocationPayloadSet,
105
- CurrentLocationWitness,
106
- CurrentLocationWitnessConfigSchema,
107
- LocationPlugin
108
- });
109
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/Config.ts","../../src/CurrentLocationPayloadSet.ts","../../src/CurrentLocationWitness.ts","../../src/Plugin.ts"],"sourcesContent":["export * from './Config.ts'\nexport * from './CurrentLocationPayloadSet.ts'\nexport * from './CurrentLocationWitness.ts'\n// eslint-disable-next-line import/no-default-export\nexport { LocationPlugin as default, LocationPlugin } from './Plugin.ts'\n","import { AnyConfigSchema, ModuleParams } from '@xyo-network/module-model'\nimport { WitnessConfig } from '@xyo-network/witness-model'\n\nexport type CurrentLocationWitnessConfigSchema = 'network.xyo.location.current.config'\nexport const CurrentLocationWitnessConfigSchema: CurrentLocationWitnessConfigSchema = 'network.xyo.location.current.config'\n\nexport type CurrentLocationWitnessConfig = WitnessConfig<{\n schema: CurrentLocationWitnessConfigSchema\n}>\n\nexport type CurrentLocationWitnessParams = ModuleParams<AnyConfigSchema<CurrentLocationWitnessConfig>, { geolocation?: Geolocation }>\n","import { LocationHeadingSchema, LocationSchema } from '@xyo-network/location-payload-plugin'\nimport { PayloadSetPayload, PayloadSetSchema } from '@xyo-network/payload-model'\n\nexport const CurrentLocationPayloadSet: PayloadSetPayload = {\n optional: {\n [LocationHeadingSchema]: 1,\n },\n required: {\n [LocationSchema]: 1,\n },\n schema: PayloadSetSchema,\n}\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { LocationHeadingPayload, LocationHeadingSchema, LocationPayload, LocationSchema } from '@xyo-network/location-payload-plugin'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { CurrentLocationWitnessConfigSchema, CurrentLocationWitnessParams } from './Config.ts'\n\nexport class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CurrentLocationWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = CurrentLocationWitnessConfigSchema\n\n get geolocation(): Geolocation {\n return assertEx(this.params.geolocation, () => 'No geolocation provided')\n }\n\n getCurrentPosition() {\n return new Promise<GeolocationPosition>((resolve, reject) => {\n this.geolocation?.getCurrentPosition(\n (position: GeolocationPosition) => {\n resolve(position)\n },\n (error: GeolocationPositionError) => {\n reject(error)\n },\n )\n })\n }\n\n protected override async observeHandler(): Promise<Payload[]> {\n const location = await this.getCurrentPosition()\n const locationPayload: LocationPayload = {\n altitude: location.coords.altitude ?? undefined,\n altitudeAccuracy: location.coords.altitudeAccuracy ?? undefined,\n latitude: location.coords.latitude,\n longitude: location.coords.longitude,\n schema: LocationSchema,\n }\n const heading: LocationHeadingPayload[]\n = location.coords.heading\n ? [\n {\n heading: location.coords.heading ?? undefined,\n schema: LocationHeadingSchema,\n speed: location.coords.speed ?? undefined,\n },\n ]\n : []\n return [locationPayload, ...heading]\n }\n}\n","import { LocationSchema } from '@xyo-network/location-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CurrentLocationWitness } from './CurrentLocationWitness.ts'\n\nexport const LocationPlugin = () =>\n createPayloadSetWitnessPlugin<CurrentLocationWitness>(\n { required: { [LocationSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await CurrentLocationWitness.create(params)\n },\n },\n )\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,qCAAyE;;;ACJtF,qCAAsD;AACtD,2BAAoD;AAE7C,IAAM,4BAA+C;AAAA,EAC1D,UAAU;AAAA,IACR,CAAC,oDAAqB,GAAG;AAAA,EAC3B;AAAA,EACA,UAAU;AAAA,IACR,CAAC,6CAAc,GAAG;AAAA,EACpB;AAAA,EACA,QAAQ;AACV;;;ACXA,oBAAyB;AACzB,8BAAgC;AAChC,IAAAA,kCAA+F;AAKxF,IAAM,yBAAN,cAAkH,wCAAyB;AAAA,EAChJ,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,kCAAkC;AAAA,EAC9G,OAAyB,sBAA8B;AAAA,EAEvD,IAAI,cAA2B;AAC7B,eAAO,wBAAS,KAAK,OAAO,aAAa,MAAM,yBAAyB;AAAA,EAC1E;AAAA,EAEA,qBAAqB;AACnB,WAAO,IAAI,QAA6B,CAAC,SAAS,WAAW;AAhBjE;AAiBM,iBAAK,gBAAL,mBAAkB;AAAA,QAChB,CAAC,aAAkC;AACjC,kBAAQ,QAAQ;AAAA,QAClB;AAAA,QACA,CAAC,UAAoC;AACnC,iBAAO,KAAK;AAAA,QACd;AAAA;AAAA,IAEJ,CAAC;AAAA,EACH;AAAA,EAEA,MAAyB,iBAAqC;AAC5D,UAAM,WAAW,MAAM,KAAK,mBAAmB;AAC/C,UAAM,kBAAmC;AAAA,MACvC,UAAU,SAAS,OAAO,YAAY;AAAA,MACtC,kBAAkB,SAAS,OAAO,oBAAoB;AAAA,MACtD,UAAU,SAAS,OAAO;AAAA,MAC1B,WAAW,SAAS,OAAO;AAAA,MAC3B,QAAQ;AAAA,IACV;AACA,UAAM,UACF,SAAS,OAAO,UACd;AAAA,MACE;AAAA,QACE,SAAS,SAAS,OAAO,WAAW;AAAA,QACpC,QAAQ;AAAA,QACR,OAAO,SAAS,OAAO,SAAS;AAAA,MAClC;AAAA,IACF,IACA,CAAC;AACP,WAAO,CAAC,iBAAiB,GAAG,OAAO;AAAA,EACrC;AACF;;;ACjDA,IAAAC,kCAA+B;AAC/B,IAAAC,wBAAiC;AACjC,+BAA8C;AAIvC,IAAM,iBAAiB,UAC5B;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,8CAAc,GAAG,EAAE,GAAG,QAAQ,uCAAiB;AAAA,EAC9D;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,uBAAuB,OAAO,MAAM;AAAA,IACnD;AAAA,EACF;AACF;","names":["import_location_payload_plugin","import_location_payload_plugin","import_payload_model"]}
@@ -1,5 +0,0 @@
1
- export * from './Config.ts';
2
- export * from './CurrentLocationPayloadSet.ts';
3
- export * from './CurrentLocationWitness.ts';
4
- export { LocationPlugin as default, LocationPlugin } from './Plugin.ts';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,gCAAgC,CAAA;AAC9C,cAAc,6BAA6B,CAAA;AAE3C,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
@@ -1,5 +0,0 @@
1
- export * from './Config.ts';
2
- export * from './CurrentLocationPayloadSet.ts';
3
- export * from './CurrentLocationWitness.ts';
4
- export { LocationPlugin as default, LocationPlugin } from './Plugin.ts';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,gCAAgC,CAAA;AAC9C,cAAc,6BAA6B,CAAA;AAE3C,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
@@ -1,5 +0,0 @@
1
- export * from './Config.ts';
2
- export * from './CurrentLocationPayloadSet.ts';
3
- export * from './CurrentLocationWitness.ts';
4
- export { LocationPlugin as default, LocationPlugin } from './Plugin.ts';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,gCAAgC,CAAA;AAC9C,cAAc,6BAA6B,CAAA;AAE3C,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
@@ -1,79 +0,0 @@
1
- // src/Config.ts
2
- var CurrentLocationWitnessConfigSchema = "network.xyo.location.current.config";
3
-
4
- // src/CurrentLocationPayloadSet.ts
5
- import { LocationHeadingSchema, LocationSchema } from "@xyo-network/location-payload-plugin";
6
- import { PayloadSetSchema } from "@xyo-network/payload-model";
7
- var CurrentLocationPayloadSet = {
8
- optional: {
9
- [LocationHeadingSchema]: 1
10
- },
11
- required: {
12
- [LocationSchema]: 1
13
- },
14
- schema: PayloadSetSchema
15
- };
16
-
17
- // src/CurrentLocationWitness.ts
18
- import { assertEx } from "@xylabs/assert";
19
- import { AbstractWitness } from "@xyo-network/abstract-witness";
20
- import { LocationHeadingSchema as LocationHeadingSchema2, LocationSchema as LocationSchema2 } from "@xyo-network/location-payload-plugin";
21
- var CurrentLocationWitness = class extends AbstractWitness {
22
- static configSchemas = [...super.configSchemas, CurrentLocationWitnessConfigSchema];
23
- static defaultConfigSchema = CurrentLocationWitnessConfigSchema;
24
- get geolocation() {
25
- return assertEx(this.params.geolocation, () => "No geolocation provided");
26
- }
27
- getCurrentPosition() {
28
- return new Promise((resolve, reject) => {
29
- var _a;
30
- (_a = this.geolocation) == null ? void 0 : _a.getCurrentPosition(
31
- (position) => {
32
- resolve(position);
33
- },
34
- (error) => {
35
- reject(error);
36
- }
37
- );
38
- });
39
- }
40
- async observeHandler() {
41
- const location = await this.getCurrentPosition();
42
- const locationPayload = {
43
- altitude: location.coords.altitude ?? void 0,
44
- altitudeAccuracy: location.coords.altitudeAccuracy ?? void 0,
45
- latitude: location.coords.latitude,
46
- longitude: location.coords.longitude,
47
- schema: LocationSchema2
48
- };
49
- const heading = location.coords.heading ? [
50
- {
51
- heading: location.coords.heading ?? void 0,
52
- schema: LocationHeadingSchema2,
53
- speed: location.coords.speed ?? void 0
54
- }
55
- ] : [];
56
- return [locationPayload, ...heading];
57
- }
58
- };
59
-
60
- // src/Plugin.ts
61
- import { LocationSchema as LocationSchema3 } from "@xyo-network/location-payload-plugin";
62
- import { PayloadSetSchema as PayloadSetSchema2 } from "@xyo-network/payload-model";
63
- import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
64
- var LocationPlugin = () => createPayloadSetWitnessPlugin(
65
- { required: { [LocationSchema3]: 1 }, schema: PayloadSetSchema2 },
66
- {
67
- witness: async (params) => {
68
- return await CurrentLocationWitness.create(params);
69
- }
70
- }
71
- );
72
- export {
73
- CurrentLocationPayloadSet,
74
- CurrentLocationWitness,
75
- CurrentLocationWitnessConfigSchema,
76
- LocationPlugin,
77
- LocationPlugin as default
78
- };
79
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Config.ts","../../src/CurrentLocationPayloadSet.ts","../../src/CurrentLocationWitness.ts","../../src/Plugin.ts"],"sourcesContent":["import { AnyConfigSchema, ModuleParams } from '@xyo-network/module-model'\nimport { WitnessConfig } from '@xyo-network/witness-model'\n\nexport type CurrentLocationWitnessConfigSchema = 'network.xyo.location.current.config'\nexport const CurrentLocationWitnessConfigSchema: CurrentLocationWitnessConfigSchema = 'network.xyo.location.current.config'\n\nexport type CurrentLocationWitnessConfig = WitnessConfig<{\n schema: CurrentLocationWitnessConfigSchema\n}>\n\nexport type CurrentLocationWitnessParams = ModuleParams<AnyConfigSchema<CurrentLocationWitnessConfig>, { geolocation?: Geolocation }>\n","import { LocationHeadingSchema, LocationSchema } from '@xyo-network/location-payload-plugin'\nimport { PayloadSetPayload, PayloadSetSchema } from '@xyo-network/payload-model'\n\nexport const CurrentLocationPayloadSet: PayloadSetPayload = {\n optional: {\n [LocationHeadingSchema]: 1,\n },\n required: {\n [LocationSchema]: 1,\n },\n schema: PayloadSetSchema,\n}\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport { LocationHeadingPayload, LocationHeadingSchema, LocationPayload, LocationSchema } from '@xyo-network/location-payload-plugin'\nimport { Payload, Schema } from '@xyo-network/payload-model'\n\nimport { CurrentLocationWitnessConfigSchema, CurrentLocationWitnessParams } from './Config.ts'\n\nexport class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, CurrentLocationWitnessConfigSchema]\n static override readonly defaultConfigSchema: Schema = CurrentLocationWitnessConfigSchema\n\n get geolocation(): Geolocation {\n return assertEx(this.params.geolocation, () => 'No geolocation provided')\n }\n\n getCurrentPosition() {\n return new Promise<GeolocationPosition>((resolve, reject) => {\n this.geolocation?.getCurrentPosition(\n (position: GeolocationPosition) => {\n resolve(position)\n },\n (error: GeolocationPositionError) => {\n reject(error)\n },\n )\n })\n }\n\n protected override async observeHandler(): Promise<Payload[]> {\n const location = await this.getCurrentPosition()\n const locationPayload: LocationPayload = {\n altitude: location.coords.altitude ?? undefined,\n altitudeAccuracy: location.coords.altitudeAccuracy ?? undefined,\n latitude: location.coords.latitude,\n longitude: location.coords.longitude,\n schema: LocationSchema,\n }\n const heading: LocationHeadingPayload[]\n = location.coords.heading\n ? [\n {\n heading: location.coords.heading ?? undefined,\n schema: LocationHeadingSchema,\n speed: location.coords.speed ?? undefined,\n },\n ]\n : []\n return [locationPayload, ...heading]\n }\n}\n","import { LocationSchema } from '@xyo-network/location-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CurrentLocationWitness } from './CurrentLocationWitness.ts'\n\nexport const LocationPlugin = () =>\n createPayloadSetWitnessPlugin<CurrentLocationWitness>(\n { required: { [LocationSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await CurrentLocationWitness.create(params)\n },\n },\n )\n"],"mappings":";AAIO,IAAM,qCAAyE;;;ACJtF,SAAS,uBAAuB,sBAAsB;AACtD,SAA4B,wBAAwB;AAE7C,IAAM,4BAA+C;AAAA,EAC1D,UAAU;AAAA,IACR,CAAC,qBAAqB,GAAG;AAAA,EAC3B;AAAA,EACA,UAAU;AAAA,IACR,CAAC,cAAc,GAAG;AAAA,EACpB;AAAA,EACA,QAAQ;AACV;;;ACXA,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAiC,yBAAAA,wBAAwC,kBAAAC,uBAAsB;AAKxF,IAAM,yBAAN,cAAkH,gBAAyB;AAAA,EAChJ,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,kCAAkC;AAAA,EAC9G,OAAyB,sBAA8B;AAAA,EAEvD,IAAI,cAA2B;AAC7B,WAAO,SAAS,KAAK,OAAO,aAAa,MAAM,yBAAyB;AAAA,EAC1E;AAAA,EAEA,qBAAqB;AACnB,WAAO,IAAI,QAA6B,CAAC,SAAS,WAAW;AAhBjE;AAiBM,iBAAK,gBAAL,mBAAkB;AAAA,QAChB,CAAC,aAAkC;AACjC,kBAAQ,QAAQ;AAAA,QAClB;AAAA,QACA,CAAC,UAAoC;AACnC,iBAAO,KAAK;AAAA,QACd;AAAA;AAAA,IAEJ,CAAC;AAAA,EACH;AAAA,EAEA,MAAyB,iBAAqC;AAC5D,UAAM,WAAW,MAAM,KAAK,mBAAmB;AAC/C,UAAM,kBAAmC;AAAA,MACvC,UAAU,SAAS,OAAO,YAAY;AAAA,MACtC,kBAAkB,SAAS,OAAO,oBAAoB;AAAA,MACtD,UAAU,SAAS,OAAO;AAAA,MAC1B,WAAW,SAAS,OAAO;AAAA,MAC3B,QAAQC;AAAA,IACV;AACA,UAAM,UACF,SAAS,OAAO,UACd;AAAA,MACE;AAAA,QACE,SAAS,SAAS,OAAO,WAAW;AAAA,QACpC,QAAQC;AAAA,QACR,OAAO,SAAS,OAAO,SAAS;AAAA,MAClC;AAAA,IACF,IACA,CAAC;AACP,WAAO,CAAC,iBAAiB,GAAG,OAAO;AAAA,EACrC;AACF;;;ACjDA,SAAS,kBAAAC,uBAAsB;AAC/B,SAAS,oBAAAC,yBAAwB;AACjC,SAAS,qCAAqC;AAIvC,IAAM,iBAAiB,MAC5B;AAAA,EACE,EAAE,UAAU,EAAE,CAACC,eAAc,GAAG,EAAE,GAAG,QAAQC,kBAAiB;AAAA,EAC9D;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,uBAAuB,OAAO,MAAM;AAAA,IACnD;AAAA,EACF;AACF;","names":["LocationHeadingSchema","LocationSchema","LocationSchema","LocationHeadingSchema","LocationSchema","PayloadSetSchema","LocationSchema","PayloadSetSchema"]}