@xyo-network/location-plugin 5.3.1 → 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.
@@ -12,7 +12,7 @@ var CurrentLocationPayloadSet = {
12
12
  };
13
13
 
14
14
  // src/CurrentLocationWitness.ts
15
- import { assertEx } from "@xylabs/assert";
15
+ import { assertEx } from "@xylabs/sdk-js";
16
16
  import { AbstractWitness } from "@xyo-network/abstract-witness";
17
17
  import { LocationHeadingSchema as LocationHeadingSchema2, LocationSchema as LocationSchema2 } from "@xyo-network/location-payload-plugin";
18
18
  var CurrentLocationWitness = class extends AbstractWitness {
@@ -1 +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/assert'\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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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"]}
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,IA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A,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.1",
3
+ "version": "5.3.3",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,26 +30,35 @@
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
  ],
38
35
  "dependencies": {
39
- "@xylabs/assert": "~5.0.64",
40
- "@xyo-network/abstract-witness": "~5.3.2",
41
- "@xyo-network/location-payload-plugin": "5.3.1",
42
- "@xyo-network/module-model": "~5.3.2",
43
- "@xyo-network/payload-model": "~5.3.2",
44
- "@xyo-network/payloadset-plugin": "~5.3.2",
45
- "@xyo-network/witness-model": "~5.3.2"
36
+ "@xyo-network/location-payload-plugin": "workspace:^"
46
37
  },
47
38
  "devDependencies": {
48
- "@xylabs/ts-scripts-yarn3": "~7.3.2",
49
- "@xylabs/tsconfig-dom": "~7.3.2",
50
- "@xylabs/vitest-extended": "~5.0.64",
39
+ "@xylabs/sdk-js": "^5.0.90",
40
+ "@xylabs/ts-scripts-common": "~7.5.10",
41
+ "@xylabs/ts-scripts-yarn3": "~7.5.10",
42
+ "@xylabs/tsconfig": "~7.5.10",
43
+ "@xylabs/tsconfig-dom": "~7.5.10",
44
+ "@xylabs/vitest-extended": "~5.0.90",
45
+ "@xyo-network/abstract-witness": "~5.3.5",
46
+ "@xyo-network/module-model": "~5.3.5",
47
+ "@xyo-network/payload-model": "~5.3.5",
48
+ "@xyo-network/payloadset-plugin": "~5.3.5",
49
+ "@xyo-network/witness-model": "~5.3.5",
51
50
  "typescript": "~5.9.3",
52
- "vitest": "~4.0.18"
51
+ "vitest": "~4.1.2",
52
+ "zod": "^4.3.6"
53
+ },
54
+ "peerDependencies": {
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",
61
+ "zod": "^4"
53
62
  },
54
63
  "publishConfig": {
55
64
  "access": "public"
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/assert'
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'