@xyo-network/location-plugin 5.3.2 → 5.3.3

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,13 @@
1
+ import type { AnyConfigSchema, ModuleParams } from '@xyo-network/module-model';
2
+ import type { WitnessConfig } from '@xyo-network/witness-model';
3
+ export type CurrentLocationWitnessConfigSchema = typeof CurrentLocationWitnessConfigSchema;
4
+ export declare const CurrentLocationWitnessConfigSchema: "network.xyo.location.current.config" & {
5
+ readonly __schema: true;
6
+ };
7
+ export type CurrentLocationWitnessConfig = WitnessConfig<{
8
+ schema: CurrentLocationWitnessConfigSchema;
9
+ }>;
10
+ export interface CurrentLocationWitnessParams extends ModuleParams<AnyConfigSchema<CurrentLocationWitnessConfig>> {
11
+ geolocation?: Geolocation;
12
+ }
13
+ //# sourceMappingURL=Config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE/D,MAAM,MAAM,kCAAkC,GAAG,OAAO,kCAAkC,CAAA;AAC1F,eAAO,MAAM,kCAAkC;;CAAwD,CAAA;AAEvG,MAAM,MAAM,4BAA4B,GAAG,aAAa,CAAC;IACvD,MAAM,EAAE,kCAAkC,CAAA;CAC3C,CAAC,CAAA;AAEF,MAAM,WAAW,4BAA6B,SAAQ,YAAY,CAAC,eAAe,CAAC,4BAA4B,CAAC,CAAC;IAAG,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE"}
@@ -0,0 +1,3 @@
1
+ import type { PayloadSetPayload } from '@xyo-network/payload-model';
2
+ export declare const CurrentLocationPayloadSet: PayloadSetPayload;
3
+ //# sourceMappingURL=CurrentLocationPayloadSet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CurrentLocationPayloadSet.d.ts","sourceRoot":"","sources":["../../src/CurrentLocationPayloadSet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAGnE,eAAO,MAAM,yBAAyB,EAAE,iBAIvC,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { AbstractWitness } from '@xyo-network/abstract-witness';
2
+ import type { Payload, Schema } from '@xyo-network/payload-model';
3
+ import type { CurrentLocationWitnessParams } from './Config.ts';
4
+ export declare class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {
5
+ static readonly configSchemas: Schema[];
6
+ static readonly defaultConfigSchema: Schema;
7
+ get geolocation(): Geolocation;
8
+ getCurrentPosition(): Promise<GeolocationPosition>;
9
+ protected observeHandler(): Promise<Payload[]>;
10
+ }
11
+ //# sourceMappingURL=CurrentLocationWitness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CurrentLocationWitness.d.ts","sourceRoot":"","sources":["../../src/CurrentLocationWitness.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAG/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAG/D,qBAAa,sBAAsB,CAAC,OAAO,SAAS,4BAA4B,GAAG,4BAA4B,CAAE,SAAQ,eAAe,CAAC,OAAO,CAAC;IAC/I,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA+D;IAC/G,gBAAyB,mBAAmB,EAAE,MAAM,CAAqC;IAEzF,IAAI,WAAW,IAAI,WAAW,CAE7B;IAED,kBAAkB;cAaO,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAqB9D"}
@@ -0,0 +1,3 @@
1
+ import { CurrentLocationWitness } from './CurrentLocationWitness.ts';
2
+ export declare const LocationPlugin: () => import("@xyo-network/payloadset-plugin").PayloadSetWitnessPlugin<CurrentLocationWitness<import("./Config.ts").CurrentLocationWitnessParams>>;
3
+ //# sourceMappingURL=Plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/Plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE,eAAO,MAAM,cAAc,oJAQxB,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from './Config.ts';
2
+ export * from './CurrentLocationPayloadSet.ts';
3
+ export * from './CurrentLocationWitness.ts';
4
+ export { LocationPlugin as default, LocationPlugin } from './Plugin.ts';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,gCAAgC,CAAA;AAC9C,cAAc,6BAA6B,CAAA;AAC3C,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,75 @@
1
+ // src/Config.ts
2
+ import { asSchema } from "@xyo-network/payload-model";
3
+ var CurrentLocationWitnessConfigSchema = asSchema("network.xyo.location.current.config", true);
4
+
5
+ // src/CurrentLocationPayloadSet.ts
6
+ import { LocationHeadingSchema, LocationSchema } from "@xyo-network/location-payload-plugin";
7
+ import { PayloadSetSchema } from "@xyo-network/payload-model";
8
+ var CurrentLocationPayloadSet = {
9
+ optional: { [LocationHeadingSchema]: 1 },
10
+ required: { [LocationSchema]: 1 },
11
+ schema: PayloadSetSchema
12
+ };
13
+
14
+ // src/CurrentLocationWitness.ts
15
+ import { assertEx } from "@xylabs/sdk-js";
16
+ import { AbstractWitness } from "@xyo-network/abstract-witness";
17
+ import { LocationHeadingSchema as LocationHeadingSchema2, LocationSchema as LocationSchema2 } from "@xyo-network/location-payload-plugin";
18
+ var CurrentLocationWitness = class extends AbstractWitness {
19
+ static configSchemas = [...super.configSchemas, CurrentLocationWitnessConfigSchema];
20
+ static defaultConfigSchema = CurrentLocationWitnessConfigSchema;
21
+ get geolocation() {
22
+ return assertEx(this.params.geolocation, () => "No geolocation provided");
23
+ }
24
+ getCurrentPosition() {
25
+ return new Promise((resolve, reject) => {
26
+ this.geolocation?.getCurrentPosition(
27
+ (position) => {
28
+ resolve(position);
29
+ },
30
+ (error) => {
31
+ reject(error);
32
+ }
33
+ );
34
+ });
35
+ }
36
+ async observeHandler() {
37
+ const location = await this.getCurrentPosition();
38
+ const locationPayload = {
39
+ altitude: location.coords.altitude ?? void 0,
40
+ altitudeAccuracy: location.coords.altitudeAccuracy ?? void 0,
41
+ latitude: location.coords.latitude,
42
+ longitude: location.coords.longitude,
43
+ schema: LocationSchema2
44
+ };
45
+ const heading = location.coords.heading ? [
46
+ {
47
+ heading: location.coords.heading ?? void 0,
48
+ schema: LocationHeadingSchema2,
49
+ speed: location.coords.speed ?? void 0
50
+ }
51
+ ] : [];
52
+ return [locationPayload, ...heading];
53
+ }
54
+ };
55
+
56
+ // src/Plugin.ts
57
+ import { LocationSchema as LocationSchema3 } from "@xyo-network/location-payload-plugin";
58
+ import { PayloadSetSchema as PayloadSetSchema2 } from "@xyo-network/payload-model";
59
+ import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
60
+ var LocationPlugin = () => createPayloadSetWitnessPlugin(
61
+ { required: { [LocationSchema3]: 1 }, schema: PayloadSetSchema2 },
62
+ {
63
+ witness: async (params) => {
64
+ return await CurrentLocationWitness.create(params);
65
+ }
66
+ }
67
+ );
68
+ export {
69
+ CurrentLocationPayloadSet,
70
+ CurrentLocationWitness,
71
+ CurrentLocationWitnessConfigSchema,
72
+ LocationPlugin,
73
+ LocationPlugin as default
74
+ };
75
+ //# 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 type { AnyConfigSchema, ModuleParams } from '@xyo-network/module-model'\nimport { asSchema } from '@xyo-network/payload-model'\nimport type { WitnessConfig } from '@xyo-network/witness-model'\n\nexport type CurrentLocationWitnessConfigSchema = typeof CurrentLocationWitnessConfigSchema\nexport const CurrentLocationWitnessConfigSchema = asSchema('network.xyo.location.current.config', true)\n\nexport type CurrentLocationWitnessConfig = WitnessConfig<{\n schema: CurrentLocationWitnessConfigSchema\n}>\n\nexport interface CurrentLocationWitnessParams extends ModuleParams<AnyConfigSchema<CurrentLocationWitnessConfig>> { geolocation?: Geolocation }\n","import { LocationHeadingSchema, LocationSchema } from '@xyo-network/location-payload-plugin'\nimport type { PayloadSetPayload } from '@xyo-network/payload-model'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\n\nexport const CurrentLocationPayloadSet: PayloadSetPayload = {\n optional: { [LocationHeadingSchema]: 1 },\n required: { [LocationSchema]: 1 },\n schema: PayloadSetSchema,\n}\n","import { assertEx } from '@xylabs/sdk-js'\nimport { AbstractWitness } from '@xyo-network/abstract-witness'\nimport type { LocationHeadingPayload, LocationPayload } from '@xyo-network/location-payload-plugin'\nimport { LocationHeadingSchema, LocationSchema } from '@xyo-network/location-payload-plugin'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\n\nimport type { CurrentLocationWitnessParams } from './Config.ts'\nimport { CurrentLocationWitnessConfigSchema } 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":";AACA,SAAS,gBAAgB;AAIlB,IAAM,qCAAqC,SAAS,uCAAuC,IAAI;;;ACLtG,SAAS,uBAAuB,sBAAsB;AAEtD,SAAS,wBAAwB;AAE1B,IAAM,4BAA+C;AAAA,EAC1D,UAAU,EAAE,CAAC,qBAAqB,GAAG,EAAE;AAAA,EACvC,UAAU,EAAE,CAAC,cAAc,GAAG,EAAE;AAAA,EAChC,QAAQ;AACV;;;ACRA,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAEhC,SAAS,yBAAAA,wBAAuB,kBAAAC,uBAAsB;AAM/C,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,UACF,SAAS,OAAO,UACd;AAAA,MACE;AAAA,QACE,SAAS,SAAS,OAAO,WAAW;AAAA,QACpC,QAAQC;AAAA,QACR,OAAO,SAAS,OAAO,SAAS;AAAA,MAClC;AAAA,IACF,IACA,CAAC;AACP,WAAO,CAAC,iBAAiB,GAAG,OAAO;AAAA,EACrC;AACF;;;ACnDA,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/location-plugin",
3
- "version": "5.3.2",
3
+ "version": "5.3.3",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,18 +30,19 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src",
34
- "!**/*.bench.*",
35
- "!**/*.spec.*",
36
- "!**/*.test.*"
33
+ "README.md"
37
34
  ],
35
+ "dependencies": {
36
+ "@xyo-network/location-payload-plugin": "workspace:^"
37
+ },
38
38
  "devDependencies": {
39
39
  "@xylabs/sdk-js": "^5.0.90",
40
+ "@xylabs/ts-scripts-common": "~7.5.10",
40
41
  "@xylabs/ts-scripts-yarn3": "~7.5.10",
42
+ "@xylabs/tsconfig": "~7.5.10",
41
43
  "@xylabs/tsconfig-dom": "~7.5.10",
42
44
  "@xylabs/vitest-extended": "~5.0.90",
43
45
  "@xyo-network/abstract-witness": "~5.3.5",
44
- "@xyo-network/location-payload-plugin": "5.3.2",
45
46
  "@xyo-network/module-model": "~5.3.5",
46
47
  "@xyo-network/payload-model": "~5.3.5",
47
48
  "@xyo-network/payloadset-plugin": "~5.3.5",
@@ -52,6 +53,11 @@
52
53
  },
53
54
  "peerDependencies": {
54
55
  "@xylabs/sdk-js": "^5",
56
+ "@xyo-network/abstract-witness": "^5",
57
+ "@xyo-network/module-model": "^5",
58
+ "@xyo-network/payload-model": "^5",
59
+ "@xyo-network/payloadset-plugin": "^5",
60
+ "@xyo-network/witness-model": "^5",
55
61
  "zod": "^4"
56
62
  },
57
63
  "publishConfig": {
package/src/Config.ts DELETED
@@ -1,12 +0,0 @@
1
- import type { AnyConfigSchema, ModuleParams } from '@xyo-network/module-model'
2
- import { asSchema } from '@xyo-network/payload-model'
3
- import type { WitnessConfig } from '@xyo-network/witness-model'
4
-
5
- export type CurrentLocationWitnessConfigSchema = typeof CurrentLocationWitnessConfigSchema
6
- export const CurrentLocationWitnessConfigSchema = asSchema('network.xyo.location.current.config', true)
7
-
8
- export type CurrentLocationWitnessConfig = WitnessConfig<{
9
- schema: CurrentLocationWitnessConfigSchema
10
- }>
11
-
12
- export interface CurrentLocationWitnessParams extends ModuleParams<AnyConfigSchema<CurrentLocationWitnessConfig>> { geolocation?: Geolocation }
@@ -1,9 +0,0 @@
1
- import { LocationHeadingSchema, LocationSchema } from '@xyo-network/location-payload-plugin'
2
- import type { PayloadSetPayload } from '@xyo-network/payload-model'
3
- import { PayloadSetSchema } from '@xyo-network/payload-model'
4
-
5
- export const CurrentLocationPayloadSet: PayloadSetPayload = {
6
- optional: { [LocationHeadingSchema]: 1 },
7
- required: { [LocationSchema]: 1 },
8
- schema: PayloadSetSchema,
9
- }
@@ -1,52 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import { AbstractWitness } from '@xyo-network/abstract-witness'
3
- import type { LocationHeadingPayload, LocationPayload } from '@xyo-network/location-payload-plugin'
4
- import { LocationHeadingSchema, LocationSchema } from '@xyo-network/location-payload-plugin'
5
- import type { Payload, Schema } from '@xyo-network/payload-model'
6
-
7
- import type { CurrentLocationWitnessParams } from './Config.ts'
8
- import { CurrentLocationWitnessConfigSchema } from './Config.ts'
9
-
10
- export class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {
11
- static override readonly configSchemas: Schema[] = [...super.configSchemas, CurrentLocationWitnessConfigSchema]
12
- static override readonly defaultConfigSchema: Schema = CurrentLocationWitnessConfigSchema
13
-
14
- get geolocation(): Geolocation {
15
- return assertEx(this.params.geolocation, () => 'No geolocation provided')
16
- }
17
-
18
- getCurrentPosition() {
19
- return new Promise<GeolocationPosition>((resolve, reject) => {
20
- this.geolocation?.getCurrentPosition(
21
- (position: GeolocationPosition) => {
22
- resolve(position)
23
- },
24
- (error: GeolocationPositionError) => {
25
- reject(error)
26
- },
27
- )
28
- })
29
- }
30
-
31
- protected override async observeHandler(): Promise<Payload[]> {
32
- const location = await this.getCurrentPosition()
33
- const locationPayload: LocationPayload = {
34
- altitude: location.coords.altitude ?? undefined,
35
- altitudeAccuracy: location.coords.altitudeAccuracy ?? undefined,
36
- latitude: location.coords.latitude,
37
- longitude: location.coords.longitude,
38
- schema: LocationSchema,
39
- }
40
- const heading: LocationHeadingPayload[]
41
- = location.coords.heading
42
- ? [
43
- {
44
- heading: location.coords.heading ?? undefined,
45
- schema: LocationHeadingSchema,
46
- speed: location.coords.speed ?? undefined,
47
- },
48
- ]
49
- : []
50
- return [locationPayload, ...heading]
51
- }
52
- }
package/src/Plugin.ts DELETED
@@ -1,15 +0,0 @@
1
- import { LocationSchema } from '@xyo-network/location-payload-plugin'
2
- import { PayloadSetSchema } from '@xyo-network/payload-model'
3
- import { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'
4
-
5
- import { CurrentLocationWitness } from './CurrentLocationWitness.ts'
6
-
7
- export const LocationPlugin = () =>
8
- createPayloadSetWitnessPlugin<CurrentLocationWitness>(
9
- { required: { [LocationSchema]: 1 }, schema: PayloadSetSchema },
10
- {
11
- witness: async (params) => {
12
- return await CurrentLocationWitness.create(params)
13
- },
14
- },
15
- )
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './Config.ts'
2
- export * from './CurrentLocationPayloadSet.ts'
3
- export * from './CurrentLocationWitness.ts'
4
- export { LocationPlugin as default, LocationPlugin } from './Plugin.ts'