@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.
@@ -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
- const daddr = encoded[0];
187
- let url = `${APPLE_BASE}?`;
188
- if (encodedOrigin) url += `saddr=${encodedOrigin}&`;
189
- url += `daddr=${daddr}&dirflg=${encodeURIComponent(dirflg)}`;
190
- return url;
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)}`;
@@ -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
- * The maps.apple.com scheme has NO waypoint parameter - `saddr` and `daddr`
118
- * only. For a multi-stop input this deliberately returns the leg to the FIRST
119
- * stop rather than silently dropping the rest, and callers must label the
120
- * affordance accordingly ("Apple Maps (first stop)"). Returns '' when no
121
- * target is usable.
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 */
@@ -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
- * The maps.apple.com scheme has NO waypoint parameter - `saddr` and `daddr`
118
- * only. For a multi-stop input this deliberately returns the leg to the FIRST
119
- * stop rather than silently dropping the rest, and callers must label the
120
- * affordance accordingly ("Apple Maps (first stop)"). Returns '' when no
121
- * target is usable.
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 */
@@ -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
- const daddr = encoded[0];
172
- let url = `${APPLE_BASE}?`;
173
- if (encodedOrigin) url += `saddr=${encodedOrigin}&`;
174
- url += `daddr=${daddr}&dirflg=${encodeURIComponent(dirflg)}`;
175
- return url;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/maps-core",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Core utilities and theme for Classic Theme maps",
5
5
  "keywords": [
6
6
  "maps",
@@ -49,9 +49,9 @@
49
49
  --primary-foreground: 0 0% 100%;
50
50
  --primary-hover: 357 71% 32%;
51
51
 
52
- --secondary: 72 11% 91%;
53
- --secondary-foreground: 0 0% 31%;
54
- --secondary-hover: 72 11% 82%;
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: 87 6% 36%;
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, 72 11% 91%));
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% 31%));
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%));
@@ -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, 72 11% 91%));
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% 31%));
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%));