@xyo-network/location-plugin 2.99.3 → 2.99.5
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/dist/browser/CurrentLocationWitness.d.cts +1 -1
- package/dist/browser/CurrentLocationWitness.d.mts +1 -1
- package/dist/browser/CurrentLocationWitness.d.ts +1 -1
- package/dist/browser/Plugin.d.cts +2 -2
- package/dist/browser/Plugin.d.mts +2 -2
- package/dist/browser/Plugin.d.ts +2 -2
- package/dist/browser/index.cjs +27 -18
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +4 -4
- package/dist/browser/index.d.mts +4 -4
- package/dist/browser/index.d.ts +4 -4
- package/dist/browser/{index.js → index.mjs} +30 -19
- package/dist/browser/index.mjs.map +1 -0
- package/dist/neutral/CurrentLocationWitness.d.cts +1 -1
- package/dist/neutral/CurrentLocationWitness.d.mts +1 -1
- package/dist/neutral/CurrentLocationWitness.d.ts +1 -1
- package/dist/neutral/Plugin.d.cts +2 -2
- package/dist/neutral/Plugin.d.mts +2 -2
- package/dist/neutral/Plugin.d.ts +2 -2
- package/dist/neutral/index.cjs +27 -18
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.d.cts +4 -4
- package/dist/neutral/index.d.mts +4 -4
- package/dist/neutral/index.d.ts +4 -4
- package/dist/{node/index.js → neutral/index.mjs} +30 -20
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/node/CurrentLocationWitness.d.cts +1 -1
- package/dist/node/CurrentLocationWitness.d.mts +1 -1
- package/dist/node/CurrentLocationWitness.d.ts +1 -1
- package/dist/node/Plugin.d.cts +2 -2
- package/dist/node/Plugin.d.mts +2 -2
- package/dist/node/Plugin.d.ts +2 -2
- package/dist/node/index.cjs +33 -20
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +4 -4
- package/dist/node/index.d.mts +4 -4
- package/dist/node/index.d.ts +4 -4
- package/dist/{neutral/index.js → node/index.mjs} +37 -21
- package/dist/node/index.mjs.map +1 -0
- package/package.json +15 -15
- package/src/CurrentLocationWitness.ts +11 -11
- package/src/Plugin.ts +1 -1
- package/src/index.ts +4 -4
- package/dist/browser/index.js.map +0 -1
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/index.js.map +0 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/Config.ts
|
|
2
5
|
var CurrentLocationWitnessConfigSchema = "network.xyo.location.current.config";
|
|
3
6
|
|
|
@@ -19,22 +22,24 @@ import { assertEx } from "@xylabs/assert";
|
|
|
19
22
|
import { AbstractWitness } from "@xyo-network/abstract-witness";
|
|
20
23
|
import { LocationHeadingSchema as LocationHeadingSchema2, LocationSchema as LocationSchema2 } from "@xyo-network/location-payload-plugin";
|
|
21
24
|
var CurrentLocationWitness = class extends AbstractWitness {
|
|
22
|
-
static
|
|
25
|
+
static {
|
|
26
|
+
__name(this, "CurrentLocationWitness");
|
|
27
|
+
}
|
|
28
|
+
static configSchemas = [
|
|
29
|
+
...super.configSchemas,
|
|
30
|
+
CurrentLocationWitnessConfigSchema
|
|
31
|
+
];
|
|
23
32
|
static defaultConfigSchema = CurrentLocationWitnessConfigSchema;
|
|
24
33
|
get geolocation() {
|
|
25
34
|
return assertEx(this.params.geolocation, () => "No geolocation provided");
|
|
26
35
|
}
|
|
27
36
|
getCurrentPosition() {
|
|
28
37
|
return new Promise((resolve, reject) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(error) => {
|
|
35
|
-
reject(error);
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
+
this.geolocation?.getCurrentPosition((position) => {
|
|
39
|
+
resolve(position);
|
|
40
|
+
}, (error) => {
|
|
41
|
+
reject(error);
|
|
42
|
+
});
|
|
38
43
|
});
|
|
39
44
|
}
|
|
40
45
|
async observeHandler() {
|
|
@@ -53,7 +58,10 @@ var CurrentLocationWitness = class extends AbstractWitness {
|
|
|
53
58
|
speed: location.coords.speed ?? void 0
|
|
54
59
|
}
|
|
55
60
|
] : [];
|
|
56
|
-
return [
|
|
61
|
+
return [
|
|
62
|
+
locationPayload,
|
|
63
|
+
...heading
|
|
64
|
+
];
|
|
57
65
|
}
|
|
58
66
|
};
|
|
59
67
|
|
|
@@ -61,14 +69,16 @@ var CurrentLocationWitness = class extends AbstractWitness {
|
|
|
61
69
|
import { LocationSchema as LocationSchema3 } from "@xyo-network/location-payload-plugin";
|
|
62
70
|
import { PayloadSetSchema as PayloadSetSchema2 } from "@xyo-network/payload-model";
|
|
63
71
|
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
64
|
-
var LocationPlugin = () => createPayloadSetWitnessPlugin(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
);
|
|
72
|
+
var LocationPlugin = /* @__PURE__ */ __name(() => createPayloadSetWitnessPlugin({
|
|
73
|
+
required: {
|
|
74
|
+
[LocationSchema3]: 1
|
|
75
|
+
},
|
|
76
|
+
schema: PayloadSetSchema2
|
|
77
|
+
}, {
|
|
78
|
+
witness: /* @__PURE__ */ __name(async (params) => {
|
|
79
|
+
return await CurrentLocationWitness.create(params);
|
|
80
|
+
}, "witness")
|
|
81
|
+
}), "LocationPlugin");
|
|
72
82
|
export {
|
|
73
83
|
CurrentLocationPayloadSet,
|
|
74
84
|
CurrentLocationWitness,
|
|
@@ -76,4 +86,4 @@ export {
|
|
|
76
86
|
LocationPlugin,
|
|
77
87
|
LocationPlugin as default
|
|
78
88
|
};
|
|
79
|
-
//# sourceMappingURL=index.
|
|
89
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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,IAAMA,qCAAyE;;;ACJtF,SAASC,uBAAuBC,sBAAsB;AACtD,SAA4BC,wBAAwB;AAE7C,IAAMC,4BAA+C;EAC1DC,UAAU;IACR,CAACJ,qBAAAA,GAAwB;EAC3B;EACAK,UAAU;IACR,CAACJ,cAAAA,GAAiB;EACpB;EACAK,QAAQJ;AACV;;;ACXA,SAASK,gBAAgB;AACzB,SAASC,uBAAuB;AAChC,SAAiCC,yBAAAA,wBAAwCC,kBAAAA,uBAAsB;AAKxF,IAAMC,yBAAN,cAAkHC,gBAAAA;EAPzH,OAOyHA;;;EACvH,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeC;;EAC5E,OAAyBC,sBAA8BD;EAEvD,IAAIE,cAA2B;AAC7B,WAAOC,SAAS,KAAKC,OAAOF,aAAa,MAAM,yBAAA;EACjD;EAEAG,qBAAqB;AACnB,WAAO,IAAIC,QAA6B,CAACC,SAASC,WAAAA;AAChD,WAAKN,aAAaG,mBAChB,CAACI,aAAAA;AACCF,gBAAQE,QAAAA;MACV,GACA,CAACC,UAAAA;AACCF,eAAOE,KAAAA;MACT,CAAA;IAEJ,CAAA;EACF;EAEA,MAAyBC,iBAAqC;AAC5D,UAAMC,WAAW,MAAM,KAAKP,mBAAkB;AAC9C,UAAMQ,kBAAmC;MACvCC,UAAUF,SAASG,OAAOD,YAAYE;MACtCC,kBAAkBL,SAASG,OAAOE,oBAAoBD;MACtDE,UAAUN,SAASG,OAAOG;MAC1BC,WAAWP,SAASG,OAAOI;MAC3BC,QAAQC;IACV;AACA,UAAMC,UACFV,SAASG,OAAOO,UACd;MACE;QACEA,SAASV,SAASG,OAAOO,WAAWN;QACpCI,QAAQG;QACRC,OAAOZ,SAASG,OAAOS,SAASR;MAClC;QAEF,CAAA;AACN,WAAO;MAACH;SAAoBS;;EAC9B;AACF;;;ACjDA,SAASG,kBAAAA,uBAAsB;AAC/B,SAASC,oBAAAA,yBAAwB;AACjC,SAASC,qCAAqC;AAIvC,IAAMC,iBAAiB,6BAC5BC,8BACE;EAAEC,UAAU;IAAE,CAACC,eAAAA,GAAiB;EAAE;EAAGC,QAAQC;AAAiB,GAC9D;EACEC,SAAS,8BAAOC,WAAAA;AACd,WAAO,MAAMC,uBAAuBC,OAAOF,MAAAA;EAC7C,GAFS;AAGX,CAAA,GAP0B;","names":["CurrentLocationWitnessConfigSchema","LocationHeadingSchema","LocationSchema","PayloadSetSchema","CurrentLocationPayloadSet","optional","required","schema","assertEx","AbstractWitness","LocationHeadingSchema","LocationSchema","CurrentLocationWitness","AbstractWitness","configSchemas","CurrentLocationWitnessConfigSchema","defaultConfigSchema","geolocation","assertEx","params","getCurrentPosition","Promise","resolve","reject","position","error","observeHandler","location","locationPayload","altitude","coords","undefined","altitudeAccuracy","latitude","longitude","schema","LocationSchema","heading","LocationHeadingSchema","speed","LocationSchema","PayloadSetSchema","createPayloadSetWitnessPlugin","LocationPlugin","createPayloadSetWitnessPlugin","required","LocationSchema","schema","PayloadSetSchema","witness","params","CurrentLocationWitness","create"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractWitness } from '@xyo-network/abstract-witness';
|
|
2
2
|
import { Payload, Schema } from '@xyo-network/payload-model';
|
|
3
|
-
import { CurrentLocationWitnessParams } from './Config.
|
|
3
|
+
import { CurrentLocationWitnessParams } from './Config.ts';
|
|
4
4
|
export declare class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {
|
|
5
5
|
static readonly configSchemas: Schema[];
|
|
6
6
|
static readonly defaultConfigSchema: Schema;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractWitness } from '@xyo-network/abstract-witness';
|
|
2
2
|
import { Payload, Schema } from '@xyo-network/payload-model';
|
|
3
|
-
import { CurrentLocationWitnessParams } from './Config.
|
|
3
|
+
import { CurrentLocationWitnessParams } from './Config.ts';
|
|
4
4
|
export declare class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {
|
|
5
5
|
static readonly configSchemas: Schema[];
|
|
6
6
|
static readonly defaultConfigSchema: Schema;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractWitness } from '@xyo-network/abstract-witness';
|
|
2
2
|
import { Payload, Schema } from '@xyo-network/payload-model';
|
|
3
|
-
import { CurrentLocationWitnessParams } from './Config.
|
|
3
|
+
import { CurrentLocationWitnessParams } from './Config.ts';
|
|
4
4
|
export declare class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {
|
|
5
5
|
static readonly configSchemas: Schema[];
|
|
6
6
|
static readonly defaultConfigSchema: Schema;
|
package/dist/node/Plugin.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurrentLocationWitness } from './CurrentLocationWitness.
|
|
1
|
+
import { CurrentLocationWitness } from './CurrentLocationWitness.ts';
|
|
2
2
|
export declare const LocationPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<CurrentLocationWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -7,7 +7,7 @@ export declare const LocationPlugin: () => import("@xyo-network/payloadset-plugi
|
|
|
7
7
|
config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & {
|
|
8
8
|
schema: "network.xyo.location.current.config";
|
|
9
9
|
} & {
|
|
10
|
-
schema: import("./Config.
|
|
10
|
+
schema: import("./Config.ts").CurrentLocationWitnessConfigSchema;
|
|
11
11
|
}, "schema"> & {
|
|
12
12
|
schema: "network.xyo.location.current.config";
|
|
13
13
|
}, "schema"> & {
|
package/dist/node/Plugin.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurrentLocationWitness } from './CurrentLocationWitness.
|
|
1
|
+
import { CurrentLocationWitness } from './CurrentLocationWitness.ts';
|
|
2
2
|
export declare const LocationPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<CurrentLocationWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -7,7 +7,7 @@ export declare const LocationPlugin: () => import("@xyo-network/payloadset-plugi
|
|
|
7
7
|
config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & {
|
|
8
8
|
schema: "network.xyo.location.current.config";
|
|
9
9
|
} & {
|
|
10
|
-
schema: import("./Config.
|
|
10
|
+
schema: import("./Config.ts").CurrentLocationWitnessConfigSchema;
|
|
11
11
|
}, "schema"> & {
|
|
12
12
|
schema: "network.xyo.location.current.config";
|
|
13
13
|
}, "schema"> & {
|
package/dist/node/Plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurrentLocationWitness } from './CurrentLocationWitness.
|
|
1
|
+
import { CurrentLocationWitness } from './CurrentLocationWitness.ts';
|
|
2
2
|
export declare const LocationPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<CurrentLocationWitness<import("@xylabs/object").BaseParamsFields & {
|
|
3
3
|
account?: import("@xyo-network/account-model").AccountInstance | "random";
|
|
4
4
|
addToResolvers?: boolean;
|
|
@@ -7,7 +7,7 @@ export declare const LocationPlugin: () => import("@xyo-network/payloadset-plugi
|
|
|
7
7
|
config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & {
|
|
8
8
|
schema: "network.xyo.location.current.config";
|
|
9
9
|
} & {
|
|
10
|
-
schema: import("./Config.
|
|
10
|
+
schema: import("./Config.ts").CurrentLocationWitnessConfigSchema;
|
|
11
11
|
}, "schema"> & {
|
|
12
12
|
schema: "network.xyo.location.current.config";
|
|
13
13
|
}, "schema"> & {
|
package/dist/node/index.cjs
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __reflectGet = Reflect.get;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
10
|
var __export = (target, all) => {
|
|
7
11
|
for (var name in all)
|
|
8
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,6 +20,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
20
|
return to;
|
|
17
21
|
};
|
|
18
22
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
19
25
|
|
|
20
26
|
// src/index.ts
|
|
21
27
|
var src_exports = {};
|
|
@@ -48,23 +54,18 @@ var CurrentLocationPayloadSet = {
|
|
|
48
54
|
var import_assert = require("@xylabs/assert");
|
|
49
55
|
var import_abstract_witness = require("@xyo-network/abstract-witness");
|
|
50
56
|
var import_location_payload_plugin2 = require("@xyo-network/location-payload-plugin");
|
|
51
|
-
var
|
|
52
|
-
static configSchemas = [...super.configSchemas, CurrentLocationWitnessConfigSchema];
|
|
53
|
-
static defaultConfigSchema = CurrentLocationWitnessConfigSchema;
|
|
57
|
+
var _CurrentLocationWitness = class _CurrentLocationWitness extends import_abstract_witness.AbstractWitness {
|
|
54
58
|
get geolocation() {
|
|
55
59
|
return (0, import_assert.assertEx)(this.params.geolocation, () => "No geolocation provided");
|
|
56
60
|
}
|
|
57
61
|
getCurrentPosition() {
|
|
58
62
|
return new Promise((resolve, reject) => {
|
|
59
63
|
var _a;
|
|
60
|
-
(_a = this.geolocation) == null ? void 0 : _a.getCurrentPosition(
|
|
61
|
-
(position)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
reject(error);
|
|
66
|
-
}
|
|
67
|
-
);
|
|
64
|
+
(_a = this.geolocation) == null ? void 0 : _a.getCurrentPosition((position) => {
|
|
65
|
+
resolve(position);
|
|
66
|
+
}, (error) => {
|
|
67
|
+
reject(error);
|
|
68
|
+
});
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
async observeHandler() {
|
|
@@ -83,22 +84,34 @@ var CurrentLocationWitness = class extends import_abstract_witness.AbstractWitne
|
|
|
83
84
|
speed: location.coords.speed ?? void 0
|
|
84
85
|
}
|
|
85
86
|
] : [];
|
|
86
|
-
return [
|
|
87
|
+
return [
|
|
88
|
+
locationPayload,
|
|
89
|
+
...heading
|
|
90
|
+
];
|
|
87
91
|
}
|
|
88
92
|
};
|
|
93
|
+
__name(_CurrentLocationWitness, "CurrentLocationWitness");
|
|
94
|
+
__publicField(_CurrentLocationWitness, "configSchemas", [
|
|
95
|
+
...__superGet(_CurrentLocationWitness, _CurrentLocationWitness, "configSchemas"),
|
|
96
|
+
CurrentLocationWitnessConfigSchema
|
|
97
|
+
]);
|
|
98
|
+
__publicField(_CurrentLocationWitness, "defaultConfigSchema", CurrentLocationWitnessConfigSchema);
|
|
99
|
+
var CurrentLocationWitness = _CurrentLocationWitness;
|
|
89
100
|
|
|
90
101
|
// src/Plugin.ts
|
|
91
102
|
var import_location_payload_plugin3 = require("@xyo-network/location-payload-plugin");
|
|
92
103
|
var import_payload_model2 = require("@xyo-network/payload-model");
|
|
93
104
|
var import_payloadset_plugin = require("@xyo-network/payloadset-plugin");
|
|
94
|
-
var LocationPlugin = () => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
);
|
|
105
|
+
var LocationPlugin = /* @__PURE__ */ __name(() => (0, import_payloadset_plugin.createPayloadSetWitnessPlugin)({
|
|
106
|
+
required: {
|
|
107
|
+
[import_location_payload_plugin3.LocationSchema]: 1
|
|
108
|
+
},
|
|
109
|
+
schema: import_payload_model2.PayloadSetSchema
|
|
110
|
+
}, {
|
|
111
|
+
witness: /* @__PURE__ */ __name(async (params) => {
|
|
112
|
+
return await CurrentLocationWitness.create(params);
|
|
113
|
+
}, "witness")
|
|
114
|
+
}), "LocationPlugin");
|
|
102
115
|
// Annotate the CommonJS export names for ESM import in node:
|
|
103
116
|
0 && (module.exports = {
|
|
104
117
|
CurrentLocationPayloadSet,
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Config.ts","../../src/CurrentLocationPayloadSet.ts","../../src/CurrentLocationWitness.ts","../../src/Plugin.ts"],"sourcesContent":["export * from './Config.
|
|
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;;;;;;;;;;;ACIO,IAAMA,qCAAyE;;;ACJtF,qCAAsD;AACtD,2BAAoD;AAE7C,IAAMC,4BAA+C;EAC1DC,UAAU;IACR,CAACC,oDAAAA,GAAwB;EAC3B;EACAC,UAAU;IACR,CAACC,6CAAAA,GAAiB;EACpB;EACAC,QAAQC;AACV;;;ACXA,oBAAyB;AACzB,8BAAgC;AAChC,IAAAC,kCAA+F;AAKxF,IAAMC,0BAAN,MAAMA,gCAA4GC,wCAAAA;EAIvH,IAAIC,cAA2B;AAC7B,eAAOC,wBAAS,KAAKC,OAAOF,aAAa,MAAM,yBAAA;EACjD;EAEAG,qBAAqB;AACnB,WAAO,IAAIC,QAA6B,CAACC,SAASC,WAAAA;AAhBtD;AAiBM,iBAAKN,gBAAL,mBAAkBG,mBAChB,CAACI,aAAAA;AACCF,gBAAQE,QAAAA;MACV,GACA,CAACC,UAAAA;AACCF,eAAOE,KAAAA;MACT;IAEJ,CAAA;EACF;EAEA,MAAyBC,iBAAqC;AAC5D,UAAMC,WAAW,MAAM,KAAKP,mBAAkB;AAC9C,UAAMQ,kBAAmC;MACvCC,UAAUF,SAASG,OAAOD,YAAYE;MACtCC,kBAAkBL,SAASG,OAAOE,oBAAoBD;MACtDE,UAAUN,SAASG,OAAOG;MAC1BC,WAAWP,SAASG,OAAOI;MAC3BC,QAAQC;IACV;AACA,UAAMC,UACFV,SAASG,OAAOO,UACd;MACE;QACEA,SAASV,SAASG,OAAOO,WAAWN;QACpCI,QAAQG;QACRC,OAAOZ,SAASG,OAAOS,SAASR;MAClC;QAEF,CAAA;AACN,WAAO;MAACH;SAAoBS;;EAC9B;AACF;AA1CyHrB;AACvH,cADWD,yBACcyB,iBAA0B;KAAI,6DAAMA;EAAeC;;AAC5E,cAFW1B,yBAEc2B,uBAA8BD;AAFlD,IAAM1B,yBAAN;;;ACPP,IAAA4B,kCAA+B;AAC/B,IAAAC,wBAAiC;AACjC,+BAA8C;AAIvC,IAAMC,iBAAiB,iCAC5BC,wDACE;EAAEC,UAAU;IAAE,CAACC,8CAAAA,GAAiB;EAAE;EAAGC,QAAQC;AAAiB,GAC9D;EACEC,SAAS,8BAAOC,WAAAA;AACd,WAAO,MAAMC,uBAAuBC,OAAOF,MAAAA;EAC7C,GAFS;AAGX,CAAA,GAP0B;","names":["CurrentLocationWitnessConfigSchema","CurrentLocationPayloadSet","optional","LocationHeadingSchema","required","LocationSchema","schema","PayloadSetSchema","import_location_payload_plugin","CurrentLocationWitness","AbstractWitness","geolocation","assertEx","params","getCurrentPosition","Promise","resolve","reject","position","error","observeHandler","location","locationPayload","altitude","coords","undefined","altitudeAccuracy","latitude","longitude","schema","LocationSchema","heading","LocationHeadingSchema","speed","configSchemas","CurrentLocationWitnessConfigSchema","defaultConfigSchema","import_location_payload_plugin","import_payload_model","LocationPlugin","createPayloadSetWitnessPlugin","required","LocationSchema","schema","PayloadSetSchema","witness","params","CurrentLocationWitness","create"]}
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './Config.
|
|
2
|
-
export * from './CurrentLocationPayloadSet.
|
|
3
|
-
export * from './CurrentLocationWitness.
|
|
4
|
-
export { LocationPlugin as default, LocationPlugin } from './Plugin.
|
|
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
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './Config.
|
|
2
|
-
export * from './CurrentLocationPayloadSet.
|
|
3
|
-
export * from './CurrentLocationWitness.
|
|
4
|
-
export { LocationPlugin as default, LocationPlugin } from './Plugin.
|
|
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
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './Config.
|
|
2
|
-
export * from './CurrentLocationPayloadSet.
|
|
3
|
-
export * from './CurrentLocationWitness.
|
|
4
|
-
export { LocationPlugin as default, LocationPlugin } from './Plugin.
|
|
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
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
3
|
+
var __reflectGet = Reflect.get;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
8
|
+
|
|
1
9
|
// src/Config.ts
|
|
2
10
|
var CurrentLocationWitnessConfigSchema = "network.xyo.location.current.config";
|
|
3
11
|
|
|
@@ -18,22 +26,18 @@ var CurrentLocationPayloadSet = {
|
|
|
18
26
|
import { assertEx } from "@xylabs/assert";
|
|
19
27
|
import { AbstractWitness } from "@xyo-network/abstract-witness";
|
|
20
28
|
import { LocationHeadingSchema as LocationHeadingSchema2, LocationSchema as LocationSchema2 } from "@xyo-network/location-payload-plugin";
|
|
21
|
-
var
|
|
22
|
-
static configSchemas = [...super.configSchemas, CurrentLocationWitnessConfigSchema];
|
|
23
|
-
static defaultConfigSchema = CurrentLocationWitnessConfigSchema;
|
|
29
|
+
var _CurrentLocationWitness = class _CurrentLocationWitness extends AbstractWitness {
|
|
24
30
|
get geolocation() {
|
|
25
31
|
return assertEx(this.params.geolocation, () => "No geolocation provided");
|
|
26
32
|
}
|
|
27
33
|
getCurrentPosition() {
|
|
28
34
|
return new Promise((resolve, reject) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(error)
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
);
|
|
35
|
+
var _a;
|
|
36
|
+
(_a = this.geolocation) == null ? void 0 : _a.getCurrentPosition((position) => {
|
|
37
|
+
resolve(position);
|
|
38
|
+
}, (error) => {
|
|
39
|
+
reject(error);
|
|
40
|
+
});
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
43
|
async observeHandler() {
|
|
@@ -52,22 +56,34 @@ var CurrentLocationWitness = class extends AbstractWitness {
|
|
|
52
56
|
speed: location.coords.speed ?? void 0
|
|
53
57
|
}
|
|
54
58
|
] : [];
|
|
55
|
-
return [
|
|
59
|
+
return [
|
|
60
|
+
locationPayload,
|
|
61
|
+
...heading
|
|
62
|
+
];
|
|
56
63
|
}
|
|
57
64
|
};
|
|
65
|
+
__name(_CurrentLocationWitness, "CurrentLocationWitness");
|
|
66
|
+
__publicField(_CurrentLocationWitness, "configSchemas", [
|
|
67
|
+
...__superGet(_CurrentLocationWitness, _CurrentLocationWitness, "configSchemas"),
|
|
68
|
+
CurrentLocationWitnessConfigSchema
|
|
69
|
+
]);
|
|
70
|
+
__publicField(_CurrentLocationWitness, "defaultConfigSchema", CurrentLocationWitnessConfigSchema);
|
|
71
|
+
var CurrentLocationWitness = _CurrentLocationWitness;
|
|
58
72
|
|
|
59
73
|
// src/Plugin.ts
|
|
60
74
|
import { LocationSchema as LocationSchema3 } from "@xyo-network/location-payload-plugin";
|
|
61
75
|
import { PayloadSetSchema as PayloadSetSchema2 } from "@xyo-network/payload-model";
|
|
62
76
|
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
63
|
-
var LocationPlugin = () => createPayloadSetWitnessPlugin(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
);
|
|
77
|
+
var LocationPlugin = /* @__PURE__ */ __name(() => createPayloadSetWitnessPlugin({
|
|
78
|
+
required: {
|
|
79
|
+
[LocationSchema3]: 1
|
|
80
|
+
},
|
|
81
|
+
schema: PayloadSetSchema2
|
|
82
|
+
}, {
|
|
83
|
+
witness: /* @__PURE__ */ __name(async (params) => {
|
|
84
|
+
return await CurrentLocationWitness.create(params);
|
|
85
|
+
}, "witness")
|
|
86
|
+
}), "LocationPlugin");
|
|
71
87
|
export {
|
|
72
88
|
CurrentLocationPayloadSet,
|
|
73
89
|
CurrentLocationWitness,
|
|
@@ -75,4 +91,4 @@ export {
|
|
|
75
91
|
LocationPlugin,
|
|
76
92
|
LocationPlugin as default
|
|
77
93
|
};
|
|
78
|
-
//# sourceMappingURL=index.
|
|
94
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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,IAAMA,qCAAyE;;;ACJtF,SAASC,uBAAuBC,sBAAsB;AACtD,SAA4BC,wBAAwB;AAE7C,IAAMC,4BAA+C;EAC1DC,UAAU;IACR,CAACJ,qBAAAA,GAAwB;EAC3B;EACAK,UAAU;IACR,CAACJ,cAAAA,GAAiB;EACpB;EACAK,QAAQJ;AACV;;;ACXA,SAASK,gBAAgB;AACzB,SAASC,uBAAuB;AAChC,SAAiCC,yBAAAA,wBAAwCC,kBAAAA,uBAAsB;AAKxF,IAAMC,0BAAN,MAAMA,gCAA4GC,gBAAAA;EAIvH,IAAIC,cAA2B;AAC7B,WAAOC,SAAS,KAAKC,OAAOF,aAAa,MAAM,yBAAA;EACjD;EAEAG,qBAAqB;AACnB,WAAO,IAAIC,QAA6B,CAACC,SAASC,WAAAA;AAhBtD;AAiBM,iBAAKN,gBAAL,mBAAkBG,mBAChB,CAACI,aAAAA;AACCF,gBAAQE,QAAAA;MACV,GACA,CAACC,UAAAA;AACCF,eAAOE,KAAAA;MACT;IAEJ,CAAA;EACF;EAEA,MAAyBC,iBAAqC;AAC5D,UAAMC,WAAW,MAAM,KAAKP,mBAAkB;AAC9C,UAAMQ,kBAAmC;MACvCC,UAAUF,SAASG,OAAOD,YAAYE;MACtCC,kBAAkBL,SAASG,OAAOE,oBAAoBD;MACtDE,UAAUN,SAASG,OAAOG;MAC1BC,WAAWP,SAASG,OAAOI;MAC3BC,QAAQC;IACV;AACA,UAAMC,UACFV,SAASG,OAAOO,UACd;MACE;QACEA,SAASV,SAASG,OAAOO,WAAWN;QACpCI,QAAQG;QACRC,OAAOZ,SAASG,OAAOS,SAASR;MAClC;QAEF,CAAA;AACN,WAAO;MAACH;SAAoBS;;EAC9B;AACF;AA1CyHrB;AACvH,cADWD,yBACcyB,iBAA0B;KAAI,6DAAMA;EAAeC;;AAC5E,cAFW1B,yBAEc2B,uBAA8BD;AAFlD,IAAM1B,yBAAN;;;ACPP,SAAS4B,kBAAAA,uBAAsB;AAC/B,SAASC,oBAAAA,yBAAwB;AACjC,SAASC,qCAAqC;AAIvC,IAAMC,iBAAiB,6BAC5BC,8BACE;EAAEC,UAAU;IAAE,CAACC,eAAAA,GAAiB;EAAE;EAAGC,QAAQC;AAAiB,GAC9D;EACEC,SAAS,8BAAOC,WAAAA;AACd,WAAO,MAAMC,uBAAuBC,OAAOF,MAAAA;EAC7C,GAFS;AAGX,CAAA,GAP0B;","names":["CurrentLocationWitnessConfigSchema","LocationHeadingSchema","LocationSchema","PayloadSetSchema","CurrentLocationPayloadSet","optional","required","schema","assertEx","AbstractWitness","LocationHeadingSchema","LocationSchema","CurrentLocationWitness","AbstractWitness","geolocation","assertEx","params","getCurrentPosition","Promise","resolve","reject","position","error","observeHandler","location","locationPayload","altitude","coords","undefined","altitudeAccuracy","latitude","longitude","schema","LocationSchema","heading","LocationHeadingSchema","speed","configSchemas","CurrentLocationWitnessConfigSchema","defaultConfigSchema","LocationSchema","PayloadSetSchema","createPayloadSetWitnessPlugin","LocationPlugin","createPayloadSetWitnessPlugin","required","LocationSchema","schema","PayloadSetSchema","witness","params","CurrentLocationWitness","create"]}
|
package/package.json
CHANGED
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/plugins/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^3.6.
|
|
14
|
-
"@xyo-network/abstract-witness": "^2.
|
|
15
|
-
"@xyo-network/location-payload-plugin": "^2.99.
|
|
16
|
-
"@xyo-network/module-model": "^2.
|
|
17
|
-
"@xyo-network/payload-model": "^2.
|
|
18
|
-
"@xyo-network/payloadset-plugin": "^2.
|
|
19
|
-
"@xyo-network/witness-model": "^2.
|
|
13
|
+
"@xylabs/assert": "^3.6.8",
|
|
14
|
+
"@xyo-network/abstract-witness": "^2.111.2",
|
|
15
|
+
"@xyo-network/location-payload-plugin": "^2.99.5",
|
|
16
|
+
"@xyo-network/module-model": "^2.111.2",
|
|
17
|
+
"@xyo-network/payload-model": "^2.111.2",
|
|
18
|
+
"@xyo-network/payloadset-plugin": "^2.111.2",
|
|
19
|
+
"@xyo-network/witness-model": "^2.111.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@xylabs/ts-scripts-yarn3": "^3.
|
|
23
|
-
"@xylabs/tsconfig-dom": "^3.
|
|
24
|
-
"@xylabs/tsconfig-dom-jest": "^3.
|
|
25
|
-
"typescript": "^5.5.
|
|
22
|
+
"@xylabs/ts-scripts-yarn3": "^3.15.13",
|
|
23
|
+
"@xylabs/tsconfig-dom": "^3.15.13",
|
|
24
|
+
"@xylabs/tsconfig-dom-jest": "^3.15.13",
|
|
25
|
+
"typescript": "^5.5.4"
|
|
26
26
|
},
|
|
27
27
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
28
28
|
"types": "dist/node/index.d.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"import": {
|
|
37
37
|
"types": "./dist/browser/index.d.mts",
|
|
38
|
-
"default": "./dist/browser/index.
|
|
38
|
+
"default": "./dist/browser/index.mjs"
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"node": {
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
},
|
|
46
46
|
"import": {
|
|
47
47
|
"types": "./dist/node/index.d.mts",
|
|
48
|
-
"default": "./dist/node/index.
|
|
48
|
+
"default": "./dist/node/index.mjs"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"./package.json": "./package.json"
|
|
53
53
|
},
|
|
54
54
|
"main": "dist/node/index.cjs",
|
|
55
|
-
"module": "dist/node/index.
|
|
55
|
+
"module": "dist/node/index.mjs",
|
|
56
56
|
"homepage": "https://xyo.network",
|
|
57
57
|
"license": "LGPL-3.0-only",
|
|
58
58
|
"publishConfig": {
|
|
@@ -63,6 +63,6 @@
|
|
|
63
63
|
"url": "https://github.com/XYOracleNetwork/plugins.git"
|
|
64
64
|
},
|
|
65
65
|
"sideEffects": false,
|
|
66
|
-
"version": "2.99.
|
|
66
|
+
"version": "2.99.5",
|
|
67
67
|
"type": "module"
|
|
68
68
|
}
|
|
@@ -3,7 +3,7 @@ import { AbstractWitness } from '@xyo-network/abstract-witness'
|
|
|
3
3
|
import { LocationHeadingPayload, LocationHeadingSchema, LocationPayload, LocationSchema } from '@xyo-network/location-payload-plugin'
|
|
4
4
|
import { Payload, Schema } from '@xyo-network/payload-model'
|
|
5
5
|
|
|
6
|
-
import { CurrentLocationWitnessConfigSchema, CurrentLocationWitnessParams } from './Config.
|
|
6
|
+
import { CurrentLocationWitnessConfigSchema, CurrentLocationWitnessParams } from './Config.ts'
|
|
7
7
|
|
|
8
8
|
export class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {
|
|
9
9
|
static override readonly configSchemas: Schema[] = [...super.configSchemas, CurrentLocationWitnessConfigSchema]
|
|
@@ -35,16 +35,16 @@ export class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams
|
|
|
35
35
|
longitude: location.coords.longitude,
|
|
36
36
|
schema: LocationSchema,
|
|
37
37
|
}
|
|
38
|
-
const heading: LocationHeadingPayload[]
|
|
39
|
-
location.coords.heading
|
|
40
|
-
[
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
const heading: LocationHeadingPayload[]
|
|
39
|
+
= location.coords.heading
|
|
40
|
+
? [
|
|
41
|
+
{
|
|
42
|
+
heading: location.coords.heading ?? undefined,
|
|
43
|
+
schema: LocationHeadingSchema,
|
|
44
|
+
speed: location.coords.speed ?? undefined,
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
: []
|
|
48
48
|
return [locationPayload, ...heading]
|
|
49
49
|
}
|
|
50
50
|
}
|
package/src/Plugin.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LocationSchema } from '@xyo-network/location-payload-plugin'
|
|
|
2
2
|
import { PayloadSetSchema } from '@xyo-network/payload-model'
|
|
3
3
|
import { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'
|
|
4
4
|
|
|
5
|
-
import { CurrentLocationWitness } from './CurrentLocationWitness.
|
|
5
|
+
import { CurrentLocationWitness } from './CurrentLocationWitness.ts'
|
|
6
6
|
|
|
7
7
|
export const LocationPlugin = () =>
|
|
8
8
|
createPayloadSetWitnessPlugin<CurrentLocationWitness>(
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './Config.
|
|
2
|
-
export * from './CurrentLocationPayloadSet.
|
|
3
|
-
export * from './CurrentLocationWitness.
|
|
1
|
+
export * from './Config.ts'
|
|
2
|
+
export * from './CurrentLocationPayloadSet.ts'
|
|
3
|
+
export * from './CurrentLocationWitness.ts'
|
|
4
4
|
// eslint-disable-next-line import/no-default-export
|
|
5
|
-
export { LocationPlugin as default, LocationPlugin } from './Plugin.
|
|
5
|
+
export { LocationPlugin as default, LocationPlugin } from './Plugin.ts'
|
|
@@ -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.js'\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.js'\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;AAC3D,WAAK,aAAa;AAAA,QAChB,CAAC,aAAkC;AACjC,kBAAQ,QAAQ;AAAA,QAClB;AAAA,QACA,CAAC,UAAoC;AACnC,iBAAO,KAAK;AAAA,QACd;AAAA,MACF;AAAA,IACF,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,UACJ,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;AACL,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"]}
|
|
@@ -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.js'\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.js'\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;AAC3D,WAAK,aAAa;AAAA,QAChB,CAAC,aAAkC;AACjC,kBAAQ,QAAQ;AAAA,QAClB;AAAA,QACA,CAAC,UAAoC;AACnC,iBAAO,KAAK;AAAA,QACd;AAAA,MACF;AAAA,IACF,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,UACJ,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;AACL,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"]}
|
package/dist/node/index.js.map
DELETED
|
@@ -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.js'\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.js'\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,UACJ,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;AACL,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"]}
|