@xyo-network/location-plugin 2.84.0 → 2.84.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.
@@ -0,0 +1,115 @@
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: () => src_default
28
+ });
29
+ module.exports = __toCommonJS(src_exports);
30
+
31
+ // src/Plugin.ts
32
+ var import_location_payload_plugin2 = require("@xyo-network/location-payload-plugin");
33
+ var import_payload_model = require("@xyo-network/payload-model");
34
+ var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
35
+
36
+ // src/CurrentLocationWitness.ts
37
+ var import_assert = require("@xylabs/assert");
38
+ var import_abstract_witness = require("@xyo-network/abstract-witness");
39
+ var import_location_payload_plugin = require("@xyo-network/location-payload-plugin");
40
+
41
+ // src/Config.ts
42
+ var CurrentLocationWitnessConfigSchema = "network.xyo.location.current.config";
43
+
44
+ // src/CurrentLocationWitness.ts
45
+ var CurrentLocationWitness = class extends import_abstract_witness.AbstractWitness {
46
+ static configSchemas = [CurrentLocationWitnessConfigSchema];
47
+ get geolocation() {
48
+ return (0, import_assert.assertEx)(this.params.geolocation, "No geolocation provided");
49
+ }
50
+ getCurrentPosition() {
51
+ return new Promise((resolve, reject) => {
52
+ var _a;
53
+ (_a = this.geolocation) == null ? void 0 : _a.getCurrentPosition(
54
+ (position) => {
55
+ resolve(position);
56
+ },
57
+ (error) => {
58
+ reject(error);
59
+ }
60
+ );
61
+ });
62
+ }
63
+ async observeHandler() {
64
+ const location = await this.getCurrentPosition();
65
+ const locationPayload = {
66
+ altitude: location.coords.altitude ?? void 0,
67
+ altitudeAccuracy: location.coords.altitudeAccuracy ?? void 0,
68
+ latitude: location.coords.latitude,
69
+ longitude: location.coords.longitude,
70
+ schema: import_location_payload_plugin.LocationSchema
71
+ };
72
+ const heading = location.coords.heading ? [
73
+ {
74
+ heading: location.coords.heading ?? void 0,
75
+ schema: import_location_payload_plugin.LocationHeadingSchema,
76
+ speed: location.coords.speed ?? void 0
77
+ }
78
+ ] : [];
79
+ return [locationPayload, ...heading];
80
+ }
81
+ };
82
+
83
+ // src/Plugin.ts
84
+ var LocationPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
85
+ { required: { [import_location_payload_plugin2.LocationSchema]: 1 }, schema: import_payload_model.PayloadSetSchema },
86
+ {
87
+ witness: async (params) => {
88
+ return await CurrentLocationWitness.create(params);
89
+ }
90
+ }
91
+ );
92
+
93
+ // src/CurrentLocationPayloadSet.ts
94
+ var import_location_payload_plugin3 = require("@xyo-network/location-payload-plugin");
95
+ var import_payload_model2 = require("@xyo-network/payload-model");
96
+ var CurrentLocationPayloadSet = {
97
+ optional: {
98
+ [import_location_payload_plugin3.LocationHeadingSchema]: 1
99
+ },
100
+ required: {
101
+ [import_location_payload_plugin3.LocationSchema]: 1
102
+ },
103
+ schema: import_payload_model2.PayloadSetSchema
104
+ };
105
+
106
+ // src/index.ts
107
+ var src_default = LocationPlugin;
108
+ // Annotate the CommonJS export names for ESM import in node:
109
+ 0 && (module.exports = {
110
+ CurrentLocationPayloadSet,
111
+ CurrentLocationWitness,
112
+ CurrentLocationWitnessConfigSchema,
113
+ LocationPlugin
114
+ });
115
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/CurrentLocationWitness.ts","../../src/Config.ts","../../src/CurrentLocationPayloadSet.ts"],"sourcesContent":["import { LocationPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './CurrentLocationPayloadSet'\nexport * from './CurrentLocationWitness'\n\nexport { LocationPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default LocationPlugin\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'\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","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 } from '@xyo-network/payload-model'\n\nimport { CurrentLocationWitnessConfigSchema, CurrentLocationWitnessParams } from './Config'\n\nexport class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {\n static override configSchemas = [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[] = 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 { 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,kCAA+B;AAC/B,2BAAiC;AACjC,+BAA8C;;;ACF9C,oBAAyB;AACzB,8BAAgC;AAChC,qCAA+F;;;ACExF,IAAM,qCAAyE;;;ADG/E,IAAM,yBAAN,cAAkH,wC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AAA,IACR,CAAC,8CAAc,GAAG;AAAA,EACpB;AAAA,EACA,QAAQ;AACV;;;AJFA,IAAO,cAAQ;","names":["import_location_payload_plugin","import_location_payload_plugin","import_payload_model"]}
@@ -1,51 +1,21 @@
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: () => src_default
28
- });
29
- module.exports = __toCommonJS(src_exports);
30
-
31
1
  // src/Plugin.ts
32
- var import_location_payload_plugin2 = require("@xyo-network/location-payload-plugin");
33
- var import_payload_model = require("@xyo-network/payload-model");
34
- var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
2
+ import { LocationSchema as LocationSchema2 } from "@xyo-network/location-payload-plugin";
3
+ import { PayloadSetSchema } from "@xyo-network/payload-model";
4
+ import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
35
5
 
36
6
  // src/CurrentLocationWitness.ts
37
- var import_assert = require("@xylabs/assert");
38
- var import_abstract_witness = require("@xyo-network/abstract-witness");
39
- var import_location_payload_plugin = require("@xyo-network/location-payload-plugin");
7
+ import { assertEx } from "@xylabs/assert";
8
+ import { AbstractWitness } from "@xyo-network/abstract-witness";
9
+ import { LocationHeadingSchema, LocationSchema } from "@xyo-network/location-payload-plugin";
40
10
 
41
11
  // src/Config.ts
42
12
  var CurrentLocationWitnessConfigSchema = "network.xyo.location.current.config";
43
13
 
44
14
  // src/CurrentLocationWitness.ts
45
- var CurrentLocationWitness = class extends import_abstract_witness.AbstractWitness {
15
+ var CurrentLocationWitness = class extends AbstractWitness {
46
16
  static configSchemas = [CurrentLocationWitnessConfigSchema];
47
17
  get geolocation() {
48
- return (0, import_assert.assertEx)(this.params.geolocation, "No geolocation provided");
18
+ return assertEx(this.params.geolocation, "No geolocation provided");
49
19
  }
50
20
  getCurrentPosition() {
51
21
  return new Promise((resolve, reject) => {
@@ -67,12 +37,12 @@ var CurrentLocationWitness = class extends import_abstract_witness.AbstractWitne
67
37
  altitudeAccuracy: location.coords.altitudeAccuracy ?? void 0,
68
38
  latitude: location.coords.latitude,
69
39
  longitude: location.coords.longitude,
70
- schema: import_location_payload_plugin.LocationSchema
40
+ schema: LocationSchema
71
41
  };
72
42
  const heading = location.coords.heading ? [
73
43
  {
74
44
  heading: location.coords.heading ?? void 0,
75
- schema: import_location_payload_plugin.LocationHeadingSchema,
45
+ schema: LocationHeadingSchema,
76
46
  speed: location.coords.speed ?? void 0
77
47
  }
78
48
  ] : [];
@@ -81,8 +51,8 @@ var CurrentLocationWitness = class extends import_abstract_witness.AbstractWitne
81
51
  };
82
52
 
83
53
  // src/Plugin.ts
84
- var LocationPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
85
- { required: { [import_location_payload_plugin2.LocationSchema]: 1 }, schema: import_payload_model.PayloadSetSchema },
54
+ var LocationPlugin = () => createPayloadSetWitnessPlugin(
55
+ { required: { [LocationSchema2]: 1 }, schema: PayloadSetSchema },
86
56
  {
87
57
  witness: async (params) => {
88
58
  return await CurrentLocationWitness.create(params);
@@ -91,25 +61,25 @@ var LocationPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessP
91
61
  );
92
62
 
93
63
  // src/CurrentLocationPayloadSet.ts
94
- var import_location_payload_plugin3 = require("@xyo-network/location-payload-plugin");
95
- var import_payload_model2 = require("@xyo-network/payload-model");
64
+ import { LocationHeadingSchema as LocationHeadingSchema2, LocationSchema as LocationSchema3 } from "@xyo-network/location-payload-plugin";
65
+ import { PayloadSetSchema as PayloadSetSchema2 } from "@xyo-network/payload-model";
96
66
  var CurrentLocationPayloadSet = {
97
67
  optional: {
98
- [import_location_payload_plugin3.LocationHeadingSchema]: 1
68
+ [LocationHeadingSchema2]: 1
99
69
  },
100
70
  required: {
101
- [import_location_payload_plugin3.LocationSchema]: 1
71
+ [LocationSchema3]: 1
102
72
  },
103
- schema: import_payload_model2.PayloadSetSchema
73
+ schema: PayloadSetSchema2
104
74
  };
105
75
 
106
76
  // src/index.ts
107
77
  var src_default = LocationPlugin;
108
- // Annotate the CommonJS export names for ESM import in node:
109
- 0 && (module.exports = {
78
+ export {
110
79
  CurrentLocationPayloadSet,
111
80
  CurrentLocationWitness,
112
81
  CurrentLocationWitnessConfigSchema,
113
- LocationPlugin
114
- });
82
+ LocationPlugin,
83
+ src_default as default
84
+ };
115
85
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/Plugin.ts","../../src/CurrentLocationWitness.ts","../../src/Config.ts","../../src/CurrentLocationPayloadSet.ts"],"sourcesContent":["import { LocationPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './CurrentLocationPayloadSet'\nexport * from './CurrentLocationWitness'\n\nexport { LocationPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default LocationPlugin\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'\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","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 } from '@xyo-network/payload-model'\n\nimport { CurrentLocationWitnessConfigSchema, CurrentLocationWitnessParams } from './Config'\n\nexport class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {\n static override configSchemas = [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[] = 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 { 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,kCAA+B;AAC/B,2BAAiC;AACjC,+BAA8C;;;ACF9C,oBAAyB;AACzB,8BAAgC;AAChC,qCAA+F;;;ACExF,IAAM,qCAAyE;;;ADG/E,IAAM,yBAAN,cAAkH,wCAAyB;AAAA,EAChJ,OAAgB,gBAAgB,CAAC,kCAAkC;AAAA,EAEnE,IAAI,cAA2B;AAC7B,eAAO,wBAAS,KAAK,OAAO,aAAa,yBAAyB;AAAA,EACpE;AAAA,EAEA,qBAAqB;AACnB,WAAO,IAAI,QAA6B,CAAC,SAAS,WAAW;AAfjE;AAgBM,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,UAAoC,SAAS,OAAO,UACtD;AAAA,MACE;AAAA,QACE,SAAS,SAAS,OAAO,WAAW;AAAA,QACpC,QAAQ;AAAA,QACR,OAAO,SAAS,OAAO,SAAS;AAAA,MAClC;AAAA,IACF,IACA,CAAC;AACL,WAAO,CAAC,iBAAiB,GAAG,OAAO;AAAA,EACrC;AACF;;;ADzCO,IAAM,iBAAiB,UAC5B;AAAA,EACE,EAAE,UAAU,EAAE,CAAC,8CAAc,GAAG,EAAE,GAAG,QAAQ,sCAAiB;AAAA,EAC9D;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,uBAAuB,OAAO,MAAM;AAAA,IACnD;AAAA,EACF;AACF;;;AGdF,IAAAC,kCAAsD;AACtD,IAAAC,wBAAoD;AAE7C,IAAM,4BAA+C;AAAA,EAC1D,UAAU;AAAA,IACR,CAAC,qDAAqB,GAAG;AAAA,EAC3B;AAAA,EACA,UAAU;AAAA,IACR,CAAC,8CAAc,GAAG;AAAA,EACpB;AAAA,EACA,QAAQ;AACV;;;AJFA,IAAO,cAAQ;","names":["import_location_payload_plugin","import_location_payload_plugin","import_payload_model"]}
1
+ {"version":3,"sources":["../../src/Plugin.ts","../../src/CurrentLocationWitness.ts","../../src/Config.ts","../../src/CurrentLocationPayloadSet.ts","../../src/index.ts"],"sourcesContent":["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'\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","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 } from '@xyo-network/payload-model'\n\nimport { CurrentLocationWitnessConfigSchema, CurrentLocationWitnessParams } from './Config'\n\nexport class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {\n static override configSchemas = [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[] = 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 { 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 { LocationPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './CurrentLocationPayloadSet'\nexport * from './CurrentLocationWitness'\n\nexport { LocationPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default LocationPlugin\n"],"mappings":";AAAA,SAAS,kBAAAA,uBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACF9C,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAiC,uBAAwC,sBAAsB;;;ACExF,IAAM,qCAAyE;;;ADG/E,IAAM,yBAAN,cAAkH,gBAAyB;AAAA,EAChJ,OAAgB,gBAAgB,CAAC,kCAAkC;AAAA,EAEnE,IAAI,cAA2B;AAC7B,WAAO,SAAS,KAAK,OAAO,aAAa,yBAAyB;AAAA,EACpE;AAAA,EAEA,qBAAqB;AACnB,WAAO,IAAI,QAA6B,CAAC,SAAS,WAAW;AAfjE;AAgBM,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,UAAoC,SAAS,OAAO,UACtD;AAAA,MACE;AAAA,QACE,SAAS,SAAS,OAAO,WAAW;AAAA,QACpC,QAAQ;AAAA,QACR,OAAO,SAAS,OAAO,SAAS;AAAA,MAClC;AAAA,IACF,IACA,CAAC;AACL,WAAO,CAAC,iBAAiB,GAAG,OAAO;AAAA,EACrC;AACF;;;ADzCO,IAAM,iBAAiB,MAC5B;AAAA,EACE,EAAE,UAAU,EAAE,CAACC,eAAc,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EAC9D;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,uBAAuB,OAAO,MAAM;AAAA,IACnD;AAAA,EACF;AACF;;;AGdF,SAAS,yBAAAC,wBAAuB,kBAAAC,uBAAsB;AACtD,SAA4B,oBAAAC,yBAAwB;AAE7C,IAAM,4BAA+C;AAAA,EAC1D,UAAU;AAAA,IACR,CAACF,sBAAqB,GAAG;AAAA,EAC3B;AAAA,EACA,UAAU;AAAA,IACR,CAACC,eAAc,GAAG;AAAA,EACpB;AAAA,EACA,QAAQC;AACV;;;ACFA,IAAO,cAAQ;","names":["LocationSchema","LocationSchema","LocationHeadingSchema","LocationSchema","PayloadSetSchema"]}
package/package.json CHANGED
@@ -11,21 +11,20 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@xylabs/assert": "^2.13.20",
14
- "@xyo-network/abstract-witness": "^2.84.0",
15
- "@xyo-network/location-payload-plugin": "~2.84.0",
16
- "@xyo-network/module-model": "^2.84.0",
17
- "@xyo-network/payload-model": "^2.84.0",
18
- "@xyo-network/payloadset-plugin": "^2.84.0",
19
- "@xyo-network/witness-model": "^2.84.0"
14
+ "@xyo-network/abstract-witness": "^2.84.3",
15
+ "@xyo-network/location-payload-plugin": "~2.84.1",
16
+ "@xyo-network/module-model": "^2.84.3",
17
+ "@xyo-network/payload-model": "^2.84.3",
18
+ "@xyo-network/payloadset-plugin": "^2.84.3",
19
+ "@xyo-network/witness-model": "^2.84.3"
20
20
  },
21
21
  "devDependencies": {
22
- "@xylabs/ts-scripts-yarn3": "^3.2.10",
23
- "@xylabs/tsconfig-dom": "^3.2.10",
24
- "@xylabs/tsconfig-dom-jest": "^3.2.10",
22
+ "@xylabs/ts-scripts-yarn3": "^3.2.19",
23
+ "@xylabs/tsconfig-dom": "^3.2.19",
24
+ "@xylabs/tsconfig-dom-jest": "^3.2.19",
25
25
  "typescript": "^5.3.3"
26
26
  },
27
27
  "description": "Typescript/Javascript Plugins for XYO Platform",
28
- "docs": "dist/docs.json",
29
28
  "types": "dist/node/index.d.ts",
30
29
  "exports": {
31
30
  ".": {
@@ -41,19 +40,19 @@
41
40
  },
42
41
  "node": {
43
42
  "require": {
44
- "types": "./dist/node/index.d.ts",
45
- "default": "./dist/node/index.js"
43
+ "types": "./dist/node/index.d.cts",
44
+ "default": "./dist/node/index.cjs"
46
45
  },
47
46
  "import": {
48
47
  "types": "./dist/node/index.d.mts",
49
- "default": "./dist/node/index.mjs"
48
+ "default": "./dist/node/index.js"
50
49
  }
51
50
  }
52
51
  },
53
52
  "./package.json": "./package.json"
54
53
  },
55
- "main": "dist/node/index.js",
56
- "module": "dist/node/index.mjs",
54
+ "main": "dist/node/index.cjs",
55
+ "module": "dist/node/index.js",
57
56
  "homepage": "https://xyo.network",
58
57
  "license": "LGPL-3.0-only",
59
58
  "publishConfig": {
@@ -64,5 +63,6 @@
64
63
  "url": "https://github.com/XYOracleNetwork/plugins.git"
65
64
  },
66
65
  "sideEffects": false,
67
- "version": "2.84.0"
66
+ "version": "2.84.1",
67
+ "type": "module"
68
68
  }
@@ -1,85 +0,0 @@
1
- // src/Plugin.ts
2
- import { LocationSchema as LocationSchema2 } from "@xyo-network/location-payload-plugin";
3
- import { PayloadSetSchema } from "@xyo-network/payload-model";
4
- import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
5
-
6
- // src/CurrentLocationWitness.ts
7
- import { assertEx } from "@xylabs/assert";
8
- import { AbstractWitness } from "@xyo-network/abstract-witness";
9
- import { LocationHeadingSchema, LocationSchema } from "@xyo-network/location-payload-plugin";
10
-
11
- // src/Config.ts
12
- var CurrentLocationWitnessConfigSchema = "network.xyo.location.current.config";
13
-
14
- // src/CurrentLocationWitness.ts
15
- var CurrentLocationWitness = class extends AbstractWitness {
16
- static configSchemas = [CurrentLocationWitnessConfigSchema];
17
- get geolocation() {
18
- return assertEx(this.params.geolocation, "No geolocation provided");
19
- }
20
- getCurrentPosition() {
21
- return new Promise((resolve, reject) => {
22
- var _a;
23
- (_a = this.geolocation) == null ? void 0 : _a.getCurrentPosition(
24
- (position) => {
25
- resolve(position);
26
- },
27
- (error) => {
28
- reject(error);
29
- }
30
- );
31
- });
32
- }
33
- async observeHandler() {
34
- const location = await this.getCurrentPosition();
35
- const locationPayload = {
36
- altitude: location.coords.altitude ?? void 0,
37
- altitudeAccuracy: location.coords.altitudeAccuracy ?? void 0,
38
- latitude: location.coords.latitude,
39
- longitude: location.coords.longitude,
40
- schema: LocationSchema
41
- };
42
- const heading = location.coords.heading ? [
43
- {
44
- heading: location.coords.heading ?? void 0,
45
- schema: LocationHeadingSchema,
46
- speed: location.coords.speed ?? void 0
47
- }
48
- ] : [];
49
- return [locationPayload, ...heading];
50
- }
51
- };
52
-
53
- // src/Plugin.ts
54
- var LocationPlugin = () => createPayloadSetWitnessPlugin(
55
- { required: { [LocationSchema2]: 1 }, schema: PayloadSetSchema },
56
- {
57
- witness: async (params) => {
58
- return await CurrentLocationWitness.create(params);
59
- }
60
- }
61
- );
62
-
63
- // src/CurrentLocationPayloadSet.ts
64
- import { LocationHeadingSchema as LocationHeadingSchema2, LocationSchema as LocationSchema3 } from "@xyo-network/location-payload-plugin";
65
- import { PayloadSetSchema as PayloadSetSchema2 } from "@xyo-network/payload-model";
66
- var CurrentLocationPayloadSet = {
67
- optional: {
68
- [LocationHeadingSchema2]: 1
69
- },
70
- required: {
71
- [LocationSchema3]: 1
72
- },
73
- schema: PayloadSetSchema2
74
- };
75
-
76
- // src/index.ts
77
- var src_default = LocationPlugin;
78
- export {
79
- CurrentLocationPayloadSet,
80
- CurrentLocationWitness,
81
- CurrentLocationWitnessConfigSchema,
82
- LocationPlugin,
83
- src_default as default
84
- };
85
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Plugin.ts","../../src/CurrentLocationWitness.ts","../../src/Config.ts","../../src/CurrentLocationPayloadSet.ts","../../src/index.ts"],"sourcesContent":["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'\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","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 } from '@xyo-network/payload-model'\n\nimport { CurrentLocationWitnessConfigSchema, CurrentLocationWitnessParams } from './Config'\n\nexport class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {\n static override configSchemas = [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[] = 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 { 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 { LocationPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './CurrentLocationPayloadSet'\nexport * from './CurrentLocationWitness'\n\nexport { LocationPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default LocationPlugin\n"],"mappings":";AAAA,SAAS,kBAAAA,uBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACF9C,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAiC,uBAAwC,sBAAsB;;;ACExF,IAAM,qCAAyE;;;ADG/E,IAAM,yBAAN,cAAkH,gBAAyB;AAAA,EAChJ,OAAgB,gBAAgB,CAAC,kCAAkC;AAAA,EAEnE,IAAI,cAA2B;AAC7B,WAAO,SAAS,KAAK,OAAO,aAAa,yBAAyB;AAAA,EACpE;AAAA,EAEA,qBAAqB;AACnB,WAAO,IAAI,QAA6B,CAAC,SAAS,WAAW;AAfjE;AAgBM,iBAAK,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