@xyo-network/location-plugin 2.75.0 → 2.75.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.
- package/dist/browser/Config.d.cts +11 -0
- package/dist/browser/Config.d.cts.map +1 -0
- package/dist/browser/Config.js +1 -2
- package/dist/browser/Config.js.map +1 -1
- package/dist/browser/CurrentLocationPayloadSet.d.cts +3 -0
- package/dist/browser/CurrentLocationPayloadSet.d.cts.map +1 -0
- package/dist/browser/CurrentLocationPayloadSet.js +1 -2
- package/dist/browser/CurrentLocationPayloadSet.js.map +1 -1
- package/dist/browser/CurrentLocationWitness.d.cts +10 -0
- package/dist/browser/CurrentLocationWitness.d.cts.map +1 -0
- package/dist/browser/CurrentLocationWitness.js +3 -8
- package/dist/browser/CurrentLocationWitness.js.map +1 -1
- package/dist/browser/Plugin.d.cts +56 -0
- package/dist/browser/Plugin.d.cts.map +1 -0
- package/dist/browser/Plugin.js +4 -52
- package/dist/browser/Plugin.js.map +1 -1
- package/dist/browser/index.d.cts +7 -0
- package/dist/browser/index.d.cts.map +1 -0
- package/dist/browser/index.js +4 -78
- package/dist/browser/index.js.map +1 -1
- package/dist/docs.json +22629 -0
- package/dist/node/Config.d.cts +11 -0
- package/dist/node/Config.d.cts.map +1 -0
- package/dist/node/Config.js +3 -1
- package/dist/node/Config.js.map +1 -1
- package/dist/node/Config.mjs +2 -1
- package/dist/node/Config.mjs.map +1 -1
- package/dist/node/CurrentLocationPayloadSet.d.cts +3 -0
- package/dist/node/CurrentLocationPayloadSet.d.cts.map +1 -0
- package/dist/node/CurrentLocationPayloadSet.js +3 -1
- package/dist/node/CurrentLocationPayloadSet.js.map +1 -1
- package/dist/node/CurrentLocationPayloadSet.mjs +2 -1
- package/dist/node/CurrentLocationPayloadSet.mjs.map +1 -1
- package/dist/node/CurrentLocationWitness.d.cts +10 -0
- package/dist/node/CurrentLocationWitness.d.cts.map +1 -0
- package/dist/node/CurrentLocationWitness.js +12 -5
- package/dist/node/CurrentLocationWitness.js.map +1 -1
- package/dist/node/CurrentLocationWitness.mjs +10 -4
- package/dist/node/CurrentLocationWitness.mjs.map +1 -1
- package/dist/node/Plugin.d.cts +56 -0
- package/dist/node/Plugin.d.cts.map +1 -0
- package/dist/node/Plugin.js +55 -5
- package/dist/node/Plugin.js.map +1 -1
- package/dist/node/Plugin.mjs +53 -4
- package/dist/node/Plugin.mjs.map +1 -1
- package/dist/node/index.d.cts +7 -0
- package/dist/node/index.d.cts.map +1 -0
- package/dist/node/index.js +88 -11
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +79 -4
- package/dist/node/index.mjs.map +1 -1
- package/package.json +11 -11
package/dist/node/index.mjs
CHANGED
|
@@ -1,9 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// src/Plugin.ts
|
|
2
|
+
import { LocationSchema as LocationSchema2 } from "@xyo-network/location-payload-plugin";
|
|
3
|
+
import { PayloadSetSchema } from "@xyo-network/payload-model";
|
|
4
|
+
import { createPayloadSetWitnessPlugin } from "@xyo-network/payloadset-plugin";
|
|
5
|
+
|
|
6
|
+
// src/CurrentLocationWitness.ts
|
|
7
|
+
import { assertEx } from "@xylabs/assert";
|
|
8
|
+
import { LocationHeadingSchema, LocationSchema } from "@xyo-network/location-payload-plugin";
|
|
9
|
+
import { AbstractWitness } from "@xyo-network/witness";
|
|
10
|
+
|
|
11
|
+
// src/Config.ts
|
|
12
|
+
var CurrentLocationWitnessConfigSchema = "network.xyo.location.current.config";
|
|
13
|
+
|
|
14
|
+
// src/CurrentLocationWitness.ts
|
|
15
|
+
var CurrentLocationWitness = class extends AbstractWitness {
|
|
16
|
+
static configSchemas = [CurrentLocationWitnessConfigSchema];
|
|
17
|
+
get geolocation() {
|
|
18
|
+
return assertEx(this.params.geolocation, "No geolocation provided");
|
|
19
|
+
}
|
|
20
|
+
getCurrentPosition() {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var _a;
|
|
23
|
+
(_a = this.geolocation) == null ? void 0 : _a.getCurrentPosition(
|
|
24
|
+
(position) => {
|
|
25
|
+
resolve(position);
|
|
26
|
+
},
|
|
27
|
+
(error) => {
|
|
28
|
+
reject(error);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async observeHandler() {
|
|
34
|
+
const location = await this.getCurrentPosition();
|
|
35
|
+
const locationPayload = {
|
|
36
|
+
altitude: location.coords.altitude ?? void 0,
|
|
37
|
+
altitudeAccuracy: location.coords.altitudeAccuracy ?? void 0,
|
|
38
|
+
latitude: location.coords.latitude,
|
|
39
|
+
longitude: location.coords.longitude,
|
|
40
|
+
schema: LocationSchema
|
|
41
|
+
};
|
|
42
|
+
const heading = location.coords.heading ? [
|
|
43
|
+
{
|
|
44
|
+
heading: location.coords.heading ?? void 0,
|
|
45
|
+
schema: LocationHeadingSchema,
|
|
46
|
+
speed: location.coords.speed ?? void 0
|
|
47
|
+
}
|
|
48
|
+
] : [];
|
|
49
|
+
return [locationPayload, ...heading];
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/Plugin.ts
|
|
54
|
+
var LocationPlugin = () => createPayloadSetWitnessPlugin(
|
|
55
|
+
{ required: { [LocationSchema2]: 1 }, schema: PayloadSetSchema },
|
|
56
|
+
{
|
|
57
|
+
witness: async (params) => {
|
|
58
|
+
return await CurrentLocationWitness.create(params);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// src/CurrentLocationPayloadSet.ts
|
|
64
|
+
import { LocationHeadingSchema as LocationHeadingSchema2, LocationSchema as LocationSchema3 } from "@xyo-network/location-payload-plugin";
|
|
65
|
+
import { PayloadSetSchema as PayloadSetSchema2 } from "@xyo-network/payload-model";
|
|
66
|
+
var CurrentLocationPayloadSet = {
|
|
67
|
+
optional: {
|
|
68
|
+
[LocationHeadingSchema2]: 1
|
|
69
|
+
},
|
|
70
|
+
required: {
|
|
71
|
+
[LocationSchema3]: 1
|
|
72
|
+
},
|
|
73
|
+
schema: PayloadSetSchema2
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/index.ts
|
|
5
77
|
var src_default = LocationPlugin;
|
|
6
78
|
export {
|
|
79
|
+
CurrentLocationPayloadSet,
|
|
80
|
+
CurrentLocationWitness,
|
|
81
|
+
CurrentLocationWitnessConfigSchema,
|
|
7
82
|
LocationPlugin,
|
|
8
83
|
src_default as default
|
|
9
84
|
};
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { LocationPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './CurrentLocationPayloadSet'\nexport * from './CurrentLocationWitness'\n\nexport { LocationPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default LocationPlugin\n"],"mappings":"AAAA,SAAS,sBAAsB;AAE/
|
|
1
|
+
{"version":3,"sources":["../../src/Plugin.ts","../../src/CurrentLocationWitness.ts","../../src/Config.ts","../../src/CurrentLocationPayloadSet.ts","../../src/index.ts"],"sourcesContent":["import { LocationSchema } from '@xyo-network/location-payload-plugin'\nimport { PayloadSetSchema } from '@xyo-network/payload-model'\nimport { createPayloadSetWitnessPlugin } from '@xyo-network/payloadset-plugin'\n\nimport { CurrentLocationWitness } from './CurrentLocationWitness'\n\nexport const LocationPlugin = () =>\n createPayloadSetWitnessPlugin<CurrentLocationWitness>(\n { required: { [LocationSchema]: 1 }, schema: PayloadSetSchema },\n {\n witness: async (params) => {\n return await CurrentLocationWitness.create(params)\n },\n },\n )\n","import { assertEx } from '@xylabs/assert'\nimport { LocationHeadingPayload, LocationHeadingSchema, LocationPayload, LocationSchema } from '@xyo-network/location-payload-plugin'\nimport { Payload } from '@xyo-network/payload-model'\nimport { AbstractWitness } from '@xyo-network/witness'\n\nimport { CurrentLocationWitnessConfigSchema, CurrentLocationWitnessParams } from './Config'\n\nexport class CurrentLocationWitness<TParams extends CurrentLocationWitnessParams = CurrentLocationWitnessParams> extends AbstractWitness<TParams> {\n static override configSchemas = [CurrentLocationWitnessConfigSchema]\n\n get geolocation(): Geolocation {\n return assertEx(this.params.geolocation, 'No geolocation provided')\n }\n\n getCurrentPosition() {\n return new Promise<GeolocationPosition>((resolve, reject) => {\n this.geolocation?.getCurrentPosition(\n (position: GeolocationPosition) => {\n resolve(position)\n },\n (error: GeolocationPositionError) => {\n reject(error)\n },\n )\n })\n }\n\n protected override async observeHandler(): Promise<Payload[]> {\n const location = await this.getCurrentPosition()\n const locationPayload: LocationPayload = {\n altitude: location.coords.altitude ?? undefined,\n altitudeAccuracy: location.coords.altitudeAccuracy ?? undefined,\n latitude: location.coords.latitude,\n longitude: location.coords.longitude,\n schema: LocationSchema,\n }\n const heading: LocationHeadingPayload[] = location.coords.heading\n ? [\n {\n heading: location.coords.heading ?? undefined,\n schema: LocationHeadingSchema,\n speed: location.coords.speed ?? undefined,\n },\n ]\n : []\n return [locationPayload, ...heading]\n }\n}\n","import { AnyConfigSchema, ModuleParams } from '@xyo-network/module'\nimport { WitnessConfig } from '@xyo-network/witness'\n\nexport type CurrentLocationWitnessConfigSchema = 'network.xyo.location.current.config'\nexport const CurrentLocationWitnessConfigSchema: CurrentLocationWitnessConfigSchema = 'network.xyo.location.current.config'\n\nexport type CurrentLocationWitnessConfig = WitnessConfig<{\n schema: CurrentLocationWitnessConfigSchema\n}>\n\nexport type CurrentLocationWitnessParams = ModuleParams<AnyConfigSchema<CurrentLocationWitnessConfig>, { geolocation?: Geolocation }>\n","import { LocationHeadingSchema, LocationSchema } from '@xyo-network/location-payload-plugin'\nimport { PayloadSetPayload, PayloadSetSchema } from '@xyo-network/payload-model'\n\nexport const CurrentLocationPayloadSet: PayloadSetPayload = {\n optional: {\n [LocationHeadingSchema]: 1,\n },\n required: {\n [LocationSchema]: 1,\n },\n schema: PayloadSetSchema,\n}\n","import { LocationPlugin } from './Plugin'\n\nexport * from './Config'\nexport * from './CurrentLocationPayloadSet'\nexport * from './CurrentLocationWitness'\n\nexport { LocationPlugin }\n\n// eslint-disable-next-line import/no-default-export\nexport default LocationPlugin\n"],"mappings":";AAAA,SAAS,kBAAAA,uBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,qCAAqC;;;ACF9C,SAAS,gBAAgB;AACzB,SAAiC,uBAAwC,sBAAsB;AAE/F,SAAS,uBAAuB;;;ACCzB,IAAM,qCAAyE;;;ADG/E,IAAM,yBAAN,cAAkH,gBAAyB;AAAA,EAChJ,OAAgB,gBAAgB,CAAC,kCAAkC;AAAA,EAEnE,IAAI,cAA2B;AAC7B,WAAO,SAAS,KAAK,OAAO,aAAa,yBAAyB;AAAA,EACpE;AAAA,EAEA,qBAAqB;AACnB,WAAO,IAAI,QAA6B,CAAC,SAAS,WAAW;AAfjE;AAgBM,iBAAK,gBAAL,mBAAkB;AAAA,QAChB,CAAC,aAAkC;AACjC,kBAAQ,QAAQ;AAAA,QAClB;AAAA,QACA,CAAC,UAAoC;AACnC,iBAAO,KAAK;AAAA,QACd;AAAA;AAAA,IAEJ,CAAC;AAAA,EACH;AAAA,EAEA,MAAyB,iBAAqC;AAC5D,UAAM,WAAW,MAAM,KAAK,mBAAmB;AAC/C,UAAM,kBAAmC;AAAA,MACvC,UAAU,SAAS,OAAO,YAAY;AAAA,MACtC,kBAAkB,SAAS,OAAO,oBAAoB;AAAA,MACtD,UAAU,SAAS,OAAO;AAAA,MAC1B,WAAW,SAAS,OAAO;AAAA,MAC3B,QAAQ;AAAA,IACV;AACA,UAAM,UAAoC,SAAS,OAAO,UACtD;AAAA,MACE;AAAA,QACE,SAAS,SAAS,OAAO,WAAW;AAAA,QACpC,QAAQ;AAAA,QACR,OAAO,SAAS,OAAO,SAAS;AAAA,MAClC;AAAA,IACF,IACA,CAAC;AACL,WAAO,CAAC,iBAAiB,GAAG,OAAO;AAAA,EACrC;AACF;;;ADzCO,IAAM,iBAAiB,MAC5B;AAAA,EACE,EAAE,UAAU,EAAE,CAACC,eAAc,GAAG,EAAE,GAAG,QAAQ,iBAAiB;AAAA,EAC9D;AAAA,IACE,SAAS,OAAO,WAAW;AACzB,aAAO,MAAM,uBAAuB,OAAO,MAAM;AAAA,IACnD;AAAA,EACF;AACF;;;AGdF,SAAS,yBAAAC,wBAAuB,kBAAAC,uBAAsB;AACtD,SAA4B,oBAAAC,yBAAwB;AAE7C,IAAM,4BAA+C;AAAA,EAC1D,UAAU;AAAA,IACR,CAACF,sBAAqB,GAAG;AAAA,EAC3B;AAAA,EACA,UAAU;AAAA,IACR,CAACC,eAAc,GAAG;AAAA,EACpB;AAAA,EACA,QAAQC;AACV;;;ACFA,IAAO,cAAQ;","names":["LocationSchema","LocationSchema","LocationHeadingSchema","LocationSchema","PayloadSetSchema"]}
|
package/package.json
CHANGED
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^2.
|
|
14
|
-
"@xyo-network/location-payload-plugin": "~2.75.
|
|
15
|
-
"@xyo-network/module": "~2.75.
|
|
16
|
-
"@xyo-network/payload-model": "~2.75.
|
|
17
|
-
"@xyo-network/payloadset-plugin": "~2.75.
|
|
18
|
-
"@xyo-network/witness": "~2.75.
|
|
13
|
+
"@xylabs/assert": "^2.12.10",
|
|
14
|
+
"@xyo-network/location-payload-plugin": "~2.75.3",
|
|
15
|
+
"@xyo-network/module": "~2.75.3",
|
|
16
|
+
"@xyo-network/payload-model": "~2.75.3",
|
|
17
|
+
"@xyo-network/payloadset-plugin": "~2.75.3",
|
|
18
|
+
"@xyo-network/witness": "~2.75.3"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@xylabs/ts-scripts-yarn3": "^3.0.
|
|
22
|
-
"@xylabs/tsconfig-dom": "^3.0.
|
|
23
|
-
"@xylabs/tsconfig-dom-jest": "^3.0.
|
|
21
|
+
"@xylabs/ts-scripts-yarn3": "^3.0.77",
|
|
22
|
+
"@xylabs/tsconfig-dom": "^3.0.77",
|
|
23
|
+
"@xylabs/tsconfig-dom-jest": "^3.0.77",
|
|
24
24
|
"typescript": "^5.2.2"
|
|
25
25
|
},
|
|
26
26
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
".": {
|
|
31
31
|
"browser": {
|
|
32
32
|
"require": {
|
|
33
|
-
"types": "./dist/browser/index.d.
|
|
33
|
+
"types": "./dist/browser/index.d.cts",
|
|
34
34
|
"default": "./dist/browser/index.cjs"
|
|
35
35
|
},
|
|
36
36
|
"import": {
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
67
67
|
},
|
|
68
68
|
"sideEffects": false,
|
|
69
|
-
"version": "2.75.
|
|
69
|
+
"version": "2.75.3"
|
|
70
70
|
}
|