@ham2k/extension-sdk 0.11.0 → 0.12.0
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/index.d.ts +5 -1
- package/dist/referenceActivity.js +9 -1
- package/docs/hooks.md +19 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @ham2k/extension-sdk 0.
|
|
1
|
+
// @ham2k/extension-sdk 0.12.0
|
|
2
2
|
/** Experimental v1 panel scene contract. All coordinates are in the scene's viewBox. */
|
|
3
3
|
export interface PanelScene {
|
|
4
4
|
version: 1;
|
|
@@ -490,6 +490,8 @@ export interface Ref {
|
|
|
490
490
|
lon?: number;
|
|
491
491
|
location?: string;
|
|
492
492
|
program?: string;
|
|
493
|
+
activationRadiusInMeters?: number;
|
|
494
|
+
activationRadiusInFeet?: number;
|
|
493
495
|
retired?: boolean;
|
|
494
496
|
for?: "operation" | "qso";
|
|
495
497
|
[key: string]: JSONValue | undefined;
|
|
@@ -1874,7 +1876,9 @@ export interface ReferenceActivityConfig {
|
|
|
1874
1876
|
linkUrl?: (reference: string) => string;
|
|
1875
1877
|
transforms?: RefTransform[];
|
|
1876
1878
|
refInput?: (args: RefInputArgs, ctx: HookContext) => Promise<RefInputExtras> | RefInputExtras;
|
|
1879
|
+
activationRadius?: ActivationRadius | ((row: LookupRow) => ActivationRadius | undefined);
|
|
1877
1880
|
}
|
|
1881
|
+
export type ActivationRadius = Pick<Ref, "activationRadiusInMeters" | "activationRadiusInFeet">;
|
|
1878
1882
|
export interface RefInputArgs {
|
|
1879
1883
|
operation: Record<string, JSONValue>;
|
|
1880
1884
|
qso?: Record<string, JSONValue>;
|
|
@@ -58,6 +58,10 @@ function referenceActivity(config) {
|
|
|
58
58
|
const category = config.category ?? config.key;
|
|
59
59
|
const program = config.adifProgram ?? config.label;
|
|
60
60
|
const allowsMultiple = config.allowsMultiple ?? false;
|
|
61
|
+
function radiusFor(row) {
|
|
62
|
+
const radius = row ? typeof config.activationRadius === "function" ? config.activationRadius(row) : config.activationRadius : void 0;
|
|
63
|
+
return { activationRadiusInMeters: radius?.activationRadiusInMeters, activationRadiusInFeet: radius?.activationRadiusInFeet };
|
|
64
|
+
}
|
|
61
65
|
async function lookupReference(ref) {
|
|
62
66
|
const host = await hostApi();
|
|
63
67
|
try {
|
|
@@ -78,7 +82,8 @@ function referenceActivity(config) {
|
|
|
78
82
|
grid: void 0,
|
|
79
83
|
lat: void 0,
|
|
80
84
|
lon: void 0,
|
|
81
|
-
location: void 0
|
|
85
|
+
location: void 0,
|
|
86
|
+
...radiusFor(null)
|
|
82
87
|
};
|
|
83
88
|
}
|
|
84
89
|
function decorate(ref, reference, row, unknown) {
|
|
@@ -91,6 +96,7 @@ function referenceActivity(config) {
|
|
|
91
96
|
grid: data.grid,
|
|
92
97
|
lat: row.lat,
|
|
93
98
|
lon: row.lon,
|
|
99
|
+
...radiusFor(row),
|
|
94
100
|
location: data.location,
|
|
95
101
|
program,
|
|
96
102
|
label: `${config.label} ${reference}: ${row.name}`,
|
|
@@ -206,6 +212,7 @@ function referenceActivity(config) {
|
|
|
206
212
|
grid: data.grid,
|
|
207
213
|
lat: row.lat,
|
|
208
214
|
lon: row.lon,
|
|
215
|
+
...radiusFor(row),
|
|
209
216
|
location: data.location,
|
|
210
217
|
program,
|
|
211
218
|
label: `${config.label} ${row.key}: ${row.name ?? ""}`,
|
|
@@ -230,6 +237,7 @@ function referenceActivity(config) {
|
|
|
230
237
|
grid: data.grid,
|
|
231
238
|
lat: row?.lat,
|
|
232
239
|
lon: row?.lon,
|
|
240
|
+
...radiusFor(row),
|
|
233
241
|
location: data.location,
|
|
234
242
|
program,
|
|
235
243
|
label: `${config.label} ${typed}: ${name}`,
|
package/docs/hooks.md
CHANGED
|
@@ -429,7 +429,8 @@ interface RefHandlerHook {
|
|
|
429
429
|
linkForRef?(args: { ref: Ref }, ctx): Promise<RefLink | null> // {url, label?}
|
|
430
430
|
geojsonUrlForRef?(args: { ref: Ref }, ctx): Promise<RefGeojson | null>
|
|
431
431
|
}
|
|
432
|
-
// Ref: {type, ref?, name?, label?, shortLabel?, grid?, location?, program?,
|
|
432
|
+
// Ref: {type, ref?, name?, label?, shortLabel?, grid?, lat?, lon?, location?, program?,
|
|
433
|
+
// activationRadiusInMeters?, activationRadiusInFeet?, ...}
|
|
433
434
|
// TitleSuggestion: {title?, for?, at?, subtitle?, priority?} — a fragment of
|
|
434
435
|
// the operation's title/subtitle sentence (ham2k/halo-dist#174). Only
|
|
435
436
|
// return one for the ref type that means "this operation is happening AT/FOR
|
|
@@ -517,6 +518,23 @@ SOTLAS's `az.sotl.as`, used with the operators' permission) and `pota` (both
|
|
|
517
518
|
types, via `services.ham2k.net/lookups/outlines/pota/`, which links parks to
|
|
518
519
|
OpenStreetMap shapes; a park not yet linked answers 404).
|
|
519
520
|
|
|
521
|
+
**An activation radius is a circle, drawn the same way.** A reference that
|
|
522
|
+
carries `activationRadiusInMeters` or `activationRadiusInFeet` — how far from
|
|
523
|
+
its point the program lets an activator be — is circled on both maps, in the
|
|
524
|
+
same color and under the same rules as an outline: solid for the operation's
|
|
525
|
+
own references and the open card, dashed for the other suggestions once
|
|
526
|
+
zoomed in. It is set on the reference itself, by `suggest` and `decorateRef`,
|
|
527
|
+
because some programs set different distances by region or by kind of
|
|
528
|
+
reference; a suggestion is stored on the operation verbatim, so the Map tab
|
|
529
|
+
draws it too. Give whichever unit the rules are written in; meters win when
|
|
530
|
+
both are set. It is drawn only around `lat`/`lon`, never around a `grid`,
|
|
531
|
+
whose centre can sit further from the reference than the whole radius
|
|
532
|
+
(docs/design/locations.md). A reference with an outline AND a radius draws
|
|
533
|
+
both. A circle has no source, so it adds nothing to the map's outline credits
|
|
534
|
+
and is not offered for an outline report. Programs built on the SDK's
|
|
535
|
+
`referenceActivity` factory get this from one `activationRadius` config line —
|
|
536
|
+
a value, or a function of the list row for rules that vary.
|
|
537
|
+
|
|
520
538
|
`suggestOperationTitle` lets an activity build a natural-language operation
|
|
521
539
|
title/subtitle from its refs — "at Yosemite NP" (POTA), "for Field Day"
|
|
522
540
|
(contest programs, when ported) — mirroring app-polo's
|