@classic-homes/maps-core 0.4.0 → 0.5.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/route/index.cjs +15 -5
- package/dist/route/index.d.cts +10 -6
- package/dist/route/index.d.ts +10 -6
- package/dist/route/index.js +15 -5
- package/package.json +1 -1
- package/src/styles/bundled.css +6 -6
- package/src/styles/utilities.css +2 -2
package/dist/route/index.cjs
CHANGED
|
@@ -179,15 +179,25 @@ function googleDirectionsUrl(stops, origin, travelmode) {
|
|
|
179
179
|
if (travelmode) url += `&travelmode=${encodeURIComponent(travelmode)}`;
|
|
180
180
|
return url;
|
|
181
181
|
}
|
|
182
|
+
var APPLE_MODES = { d: "driving", w: "walking", r: "transit" };
|
|
182
183
|
function appleDirectionsUrl(stops, origin, dirflg = "d") {
|
|
183
184
|
const encoded = usableTargets(stops);
|
|
184
185
|
if (encoded.length === 0) return "";
|
|
185
186
|
const encodedOrigin = origin ? encodeTarget(origin) : null;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
if (encoded.length === 1) {
|
|
188
|
+
let url = `${APPLE_BASE}?`;
|
|
189
|
+
if (encodedOrigin) url += `saddr=${encodedOrigin}&`;
|
|
190
|
+
url += `daddr=${encoded[0]}&dirflg=${encodeURIComponent(dirflg)}`;
|
|
191
|
+
return url;
|
|
192
|
+
}
|
|
193
|
+
const destination = encoded[encoded.length - 1];
|
|
194
|
+
const waypoints = encoded.slice(0, -1);
|
|
195
|
+
const mode = APPLE_MODES[dirflg] ?? APPLE_MODES.d;
|
|
196
|
+
const params = [];
|
|
197
|
+
if (encodedOrigin) params.push(`source=${encodedOrigin}`);
|
|
198
|
+
for (const waypoint of waypoints) params.push(`waypoint=${waypoint}`);
|
|
199
|
+
params.push(`destination=${destination}`, `mode=${mode}`);
|
|
200
|
+
return `${APPLE_BASE}directions?${params.join("&")}`;
|
|
191
201
|
}
|
|
192
202
|
function googleSearchUrl(query) {
|
|
193
203
|
return `${GOOGLE_SEARCH_BASE}&query=${encodeURIComponent(query)}`;
|
package/dist/route/index.d.cts
CHANGED
|
@@ -112,13 +112,17 @@ declare const GOOGLE_MAX_LEG_STOPS: number;
|
|
|
112
112
|
*/
|
|
113
113
|
declare function googleDirectionsUrl(stops: DirectionsTarget[], origin?: DirectionsTarget | null, travelmode?: TravelMode): string;
|
|
114
114
|
/**
|
|
115
|
-
* An Apple Maps URL.
|
|
115
|
+
* An Apple Maps directions URL.
|
|
116
116
|
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
117
|
+
* With one stop this returns the legacy `saddr`/`daddr` form, exactly
|
|
118
|
+
* `https://maps.apple.com/?daddr=<lat>,<lng>&dirflg=d` with no origin - the
|
|
119
|
+
* form consumer apps already link to, and one every iOS version opens.
|
|
120
|
+
*
|
|
121
|
+
* With several stops it returns Apple's unified Maps URL (iOS 18.4, macOS 15.4
|
|
122
|
+
* and later): `/directions` with the last stop as `destination` and the rest as
|
|
123
|
+
* repeated `waypoint` parameters, in order. Apple documents no waypoint limit.
|
|
124
|
+
* Older OS versions predate the unified scheme, so what they do with a
|
|
125
|
+
* multi-stop link is not guaranteed. Returns '' when no target is usable.
|
|
122
126
|
*/
|
|
123
127
|
declare function appleDirectionsUrl(stops: DirectionsTarget[], origin?: DirectionsTarget | null, dirflg?: 'd' | 'w' | 'r'): string;
|
|
124
128
|
/** A Google Maps search URL - the fallback for a stop with no coordinate */
|
package/dist/route/index.d.ts
CHANGED
|
@@ -112,13 +112,17 @@ declare const GOOGLE_MAX_LEG_STOPS: number;
|
|
|
112
112
|
*/
|
|
113
113
|
declare function googleDirectionsUrl(stops: DirectionsTarget[], origin?: DirectionsTarget | null, travelmode?: TravelMode): string;
|
|
114
114
|
/**
|
|
115
|
-
* An Apple Maps URL.
|
|
115
|
+
* An Apple Maps directions URL.
|
|
116
116
|
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
117
|
+
* With one stop this returns the legacy `saddr`/`daddr` form, exactly
|
|
118
|
+
* `https://maps.apple.com/?daddr=<lat>,<lng>&dirflg=d` with no origin - the
|
|
119
|
+
* form consumer apps already link to, and one every iOS version opens.
|
|
120
|
+
*
|
|
121
|
+
* With several stops it returns Apple's unified Maps URL (iOS 18.4, macOS 15.4
|
|
122
|
+
* and later): `/directions` with the last stop as `destination` and the rest as
|
|
123
|
+
* repeated `waypoint` parameters, in order. Apple documents no waypoint limit.
|
|
124
|
+
* Older OS versions predate the unified scheme, so what they do with a
|
|
125
|
+
* multi-stop link is not guaranteed. Returns '' when no target is usable.
|
|
122
126
|
*/
|
|
123
127
|
declare function appleDirectionsUrl(stops: DirectionsTarget[], origin?: DirectionsTarget | null, dirflg?: 'd' | 'w' | 'r'): string;
|
|
124
128
|
/** A Google Maps search URL - the fallback for a stop with no coordinate */
|
package/dist/route/index.js
CHANGED
|
@@ -164,15 +164,25 @@ function googleDirectionsUrl(stops, origin, travelmode) {
|
|
|
164
164
|
if (travelmode) url += `&travelmode=${encodeURIComponent(travelmode)}`;
|
|
165
165
|
return url;
|
|
166
166
|
}
|
|
167
|
+
var APPLE_MODES = { d: "driving", w: "walking", r: "transit" };
|
|
167
168
|
function appleDirectionsUrl(stops, origin, dirflg = "d") {
|
|
168
169
|
const encoded = usableTargets(stops);
|
|
169
170
|
if (encoded.length === 0) return "";
|
|
170
171
|
const encodedOrigin = origin ? encodeTarget(origin) : null;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
if (encoded.length === 1) {
|
|
173
|
+
let url = `${APPLE_BASE}?`;
|
|
174
|
+
if (encodedOrigin) url += `saddr=${encodedOrigin}&`;
|
|
175
|
+
url += `daddr=${encoded[0]}&dirflg=${encodeURIComponent(dirflg)}`;
|
|
176
|
+
return url;
|
|
177
|
+
}
|
|
178
|
+
const destination = encoded[encoded.length - 1];
|
|
179
|
+
const waypoints = encoded.slice(0, -1);
|
|
180
|
+
const mode = APPLE_MODES[dirflg] ?? APPLE_MODES.d;
|
|
181
|
+
const params = [];
|
|
182
|
+
if (encodedOrigin) params.push(`source=${encodedOrigin}`);
|
|
183
|
+
for (const waypoint of waypoints) params.push(`waypoint=${waypoint}`);
|
|
184
|
+
params.push(`destination=${destination}`, `mode=${mode}`);
|
|
185
|
+
return `${APPLE_BASE}directions?${params.join("&")}`;
|
|
176
186
|
}
|
|
177
187
|
function googleSearchUrl(query) {
|
|
178
188
|
return `${GOOGLE_SEARCH_BASE}&query=${encodeURIComponent(query)}`;
|
package/package.json
CHANGED
package/src/styles/bundled.css
CHANGED
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
--primary-foreground: 0 0% 100%;
|
|
50
50
|
--primary-hover: 357 71% 32%;
|
|
51
51
|
|
|
52
|
-
--secondary:
|
|
53
|
-
--secondary-foreground: 0 0%
|
|
54
|
-
--secondary-hover: 72
|
|
52
|
+
--secondary: 71 10% 40%;
|
|
53
|
+
--secondary-foreground: 0 0% 100%;
|
|
54
|
+
--secondary-hover: 357 72% 39%;
|
|
55
55
|
|
|
56
56
|
--muted: 72 11% 91%;
|
|
57
57
|
--muted-foreground: 0 0% 48%;
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
|
|
108
108
|
--secondary: 80 5% 32%;
|
|
109
109
|
--secondary-foreground: 220 14% 96%;
|
|
110
|
-
--secondary-hover:
|
|
110
|
+
--secondary-hover: 357 72% 39%;
|
|
111
111
|
|
|
112
112
|
--muted: 0 0% 30%;
|
|
113
113
|
--muted-foreground: 218 11% 65%;
|
|
@@ -531,7 +531,7 @@
|
|
|
531
531
|
background-color: hsl(var(--primary, 357 72% 39%));
|
|
532
532
|
}
|
|
533
533
|
.bg-secondary {
|
|
534
|
-
background-color: hsl(var(--secondary,
|
|
534
|
+
background-color: hsl(var(--secondary, 71 10% 40%));
|
|
535
535
|
}
|
|
536
536
|
.bg-success {
|
|
537
537
|
background-color: hsl(var(--success, 160 84% 39%));
|
|
@@ -572,7 +572,7 @@
|
|
|
572
572
|
color: hsl(var(--primary-foreground, 0 0% 100%));
|
|
573
573
|
}
|
|
574
574
|
.text-secondary-foreground {
|
|
575
|
-
color: hsl(var(--secondary-foreground, 0 0%
|
|
575
|
+
color: hsl(var(--secondary-foreground, 0 0% 100%));
|
|
576
576
|
}
|
|
577
577
|
.text-success-foreground {
|
|
578
578
|
color: hsl(var(--success-foreground, 0 0% 100%));
|
package/src/styles/utilities.css
CHANGED
|
@@ -373,7 +373,7 @@
|
|
|
373
373
|
background-color: hsl(var(--primary, 357 72% 39%));
|
|
374
374
|
}
|
|
375
375
|
.bg-secondary {
|
|
376
|
-
background-color: hsl(var(--secondary,
|
|
376
|
+
background-color: hsl(var(--secondary, 71 10% 40%));
|
|
377
377
|
}
|
|
378
378
|
.bg-success {
|
|
379
379
|
background-color: hsl(var(--success, 160 84% 39%));
|
|
@@ -419,7 +419,7 @@
|
|
|
419
419
|
color: hsl(var(--primary-foreground, 0 0% 100%));
|
|
420
420
|
}
|
|
421
421
|
.text-secondary-foreground {
|
|
422
|
-
color: hsl(var(--secondary-foreground, 0 0%
|
|
422
|
+
color: hsl(var(--secondary-foreground, 0 0% 100%));
|
|
423
423
|
}
|
|
424
424
|
.text-success-foreground {
|
|
425
425
|
color: hsl(var(--success-foreground, 0 0% 100%));
|