routess 1.123.1 → 1.124.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.js +223 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2183,8 +2183,90 @@ var require_history = __commonJS((exports) => {
|
|
|
2183
2183
|
}
|
|
2184
2184
|
});
|
|
2185
2185
|
|
|
2186
|
-
// ../../packages/core/dist/types
|
|
2186
|
+
// ../../packages/core/dist/routing/types.js
|
|
2187
2187
|
var require_types = __commonJS((exports) => {
|
|
2188
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2189
|
+
exports.PROVENANCES = exports.SURFACE_BUCKETS = exports.SURFACE_TYPES = undefined;
|
|
2190
|
+
exports.isSurfaceType = isSurfaceType;
|
|
2191
|
+
exports.isSurfaceBucket = isSurfaceBucket;
|
|
2192
|
+
exports.isProvenance = isProvenance;
|
|
2193
|
+
exports.SURFACE_TYPES = ["paved", "mixed", "unpaved"];
|
|
2194
|
+
exports.SURFACE_BUCKETS = ["paved", "compacted", "unpaved", "path"];
|
|
2195
|
+
exports.PROVENANCES = ["valhalla", "mapbox-legacy", "gpx-import", "generation"];
|
|
2196
|
+
function isSurfaceType(value) {
|
|
2197
|
+
return exports.SURFACE_TYPES.includes(value);
|
|
2198
|
+
}
|
|
2199
|
+
function isSurfaceBucket(value) {
|
|
2200
|
+
return exports.SURFACE_BUCKETS.includes(value);
|
|
2201
|
+
}
|
|
2202
|
+
function isProvenance(value) {
|
|
2203
|
+
return exports.PROVENANCES.includes(value);
|
|
2204
|
+
}
|
|
2205
|
+
});
|
|
2206
|
+
|
|
2207
|
+
// ../../packages/core/dist/routing/preferences.js
|
|
2208
|
+
var require_preferences = __commonJS((exports) => {
|
|
2209
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2210
|
+
exports.DEFAULT_ROUTING_DEFAULTS = exports.DEFAULT_WALK_PREFERENCES = exports.DEFAULT_RUN_PREFERENCES = exports.DEFAULT_CYCLE_PREFERENCES = undefined;
|
|
2211
|
+
exports.defaultPreferencesForActivity = defaultPreferencesForActivity;
|
|
2212
|
+
exports.normalizeRoutingPreferences = normalizeRoutingPreferences;
|
|
2213
|
+
exports.normalizeRoutingDefaults = normalizeRoutingDefaults;
|
|
2214
|
+
exports.mergeRoutingDefaults = mergeRoutingDefaults;
|
|
2215
|
+
var types_1 = require_types();
|
|
2216
|
+
exports.DEFAULT_CYCLE_PREFERENCES = {
|
|
2217
|
+
surfacePreference: "mixed",
|
|
2218
|
+
avoidFerries: true,
|
|
2219
|
+
avoidHighways: true
|
|
2220
|
+
};
|
|
2221
|
+
exports.DEFAULT_RUN_PREFERENCES = {
|
|
2222
|
+
surfacePreference: "mixed",
|
|
2223
|
+
avoidFerries: true,
|
|
2224
|
+
avoidHighways: true
|
|
2225
|
+
};
|
|
2226
|
+
exports.DEFAULT_WALK_PREFERENCES = {
|
|
2227
|
+
surfacePreference: "mixed",
|
|
2228
|
+
avoidFerries: true,
|
|
2229
|
+
avoidHighways: true
|
|
2230
|
+
};
|
|
2231
|
+
exports.DEFAULT_ROUTING_DEFAULTS = {
|
|
2232
|
+
cycle: exports.DEFAULT_CYCLE_PREFERENCES,
|
|
2233
|
+
run: exports.DEFAULT_RUN_PREFERENCES,
|
|
2234
|
+
walk: exports.DEFAULT_WALK_PREFERENCES
|
|
2235
|
+
};
|
|
2236
|
+
function defaultPreferencesForActivity(activity) {
|
|
2237
|
+
return { ...exports.DEFAULT_ROUTING_DEFAULTS[activity] };
|
|
2238
|
+
}
|
|
2239
|
+
function normalizeRoutingPreferences(activity, input) {
|
|
2240
|
+
const base = defaultPreferencesForActivity(activity);
|
|
2241
|
+
if (!input)
|
|
2242
|
+
return base;
|
|
2243
|
+
return {
|
|
2244
|
+
surfacePreference: (0, types_1.isSurfaceType)(input.surfacePreference) ? input.surfacePreference : base.surfacePreference,
|
|
2245
|
+
avoidFerries: typeof input.avoidFerries === "boolean" ? input.avoidFerries : base.avoidFerries,
|
|
2246
|
+
avoidHighways: typeof input.avoidHighways === "boolean" ? input.avoidHighways : base.avoidHighways
|
|
2247
|
+
};
|
|
2248
|
+
}
|
|
2249
|
+
function normalizeRoutingDefaults(input) {
|
|
2250
|
+
return {
|
|
2251
|
+
cycle: normalizeRoutingPreferences("cycle", input?.cycle),
|
|
2252
|
+
run: normalizeRoutingPreferences("run", input?.run),
|
|
2253
|
+
walk: normalizeRoutingPreferences("walk", input?.walk)
|
|
2254
|
+
};
|
|
2255
|
+
}
|
|
2256
|
+
function mergeRoutingDefaults(current, update) {
|
|
2257
|
+
const base = normalizeRoutingDefaults(current);
|
|
2258
|
+
if (!update)
|
|
2259
|
+
return base;
|
|
2260
|
+
return {
|
|
2261
|
+
cycle: normalizeRoutingPreferences("cycle", { ...base.cycle, ...update.cycle }),
|
|
2262
|
+
run: normalizeRoutingPreferences("run", { ...base.run, ...update.run }),
|
|
2263
|
+
walk: normalizeRoutingPreferences("walk", { ...base.walk, ...update.walk })
|
|
2264
|
+
};
|
|
2265
|
+
}
|
|
2266
|
+
});
|
|
2267
|
+
|
|
2268
|
+
// ../../packages/core/dist/types/index.js
|
|
2269
|
+
var require_types2 = __commonJS((exports) => {
|
|
2188
2270
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2189
2271
|
exports.ROUTE_VISIBILITIES = exports.ROUTE_ACTIVITIES = undefined;
|
|
2190
2272
|
exports.ROUTE_ACTIVITIES = ["run", "cycle", "walk"];
|
|
@@ -2201,10 +2283,11 @@ var require_user_preferences = __commonJS((exports) => {
|
|
|
2201
2283
|
exports.isRouteVisibility = isRouteVisibility;
|
|
2202
2284
|
exports.normalizeUserPreferences = normalizeUserPreferences;
|
|
2203
2285
|
exports.mergeUserPreferences = mergeUserPreferences;
|
|
2286
|
+
var preferences_1 = require_preferences();
|
|
2204
2287
|
exports.ACTIVITIES = ["run", "cycle", "walk"];
|
|
2205
2288
|
exports.UNITS = ["km", "mi"];
|
|
2206
2289
|
exports.MAP_STYLES = ["streets", "outdoors", "satellite"];
|
|
2207
|
-
var types_1 =
|
|
2290
|
+
var types_1 = require_types2();
|
|
2208
2291
|
Object.defineProperty(exports, "ROUTE_VISIBILITIES", { enumerable: true, get: function() {
|
|
2209
2292
|
return types_1.ROUTE_VISIBILITIES;
|
|
2210
2293
|
} });
|
|
@@ -2235,7 +2318,8 @@ var require_user_preferences = __commonJS((exports) => {
|
|
|
2235
2318
|
surface: false,
|
|
2236
2319
|
wind: false
|
|
2237
2320
|
},
|
|
2238
|
-
defaultRouteVisibility: "private"
|
|
2321
|
+
defaultRouteVisibility: "private",
|
|
2322
|
+
routingDefaults: (0, preferences_1.normalizeRoutingDefaults)(null)
|
|
2239
2323
|
};
|
|
2240
2324
|
function isActivity(value) {
|
|
2241
2325
|
return exports.ACTIVITIES.includes(value);
|
|
@@ -2317,7 +2401,8 @@ var require_user_preferences = __commonJS((exports) => {
|
|
|
2317
2401
|
sportSpeeds: normalizeSportSpeeds(input?.sportSpeeds),
|
|
2318
2402
|
mapStyle: isMapStyle(input?.mapStyle) ? input.mapStyle : exports.DEFAULT_USER_PREFERENCES.mapStyle,
|
|
2319
2403
|
overlays: normalizeOverlays(input?.overlays),
|
|
2320
|
-
defaultRouteVisibility: isRouteVisibility(input?.defaultRouteVisibility) ? input.defaultRouteVisibility : exports.DEFAULT_USER_PREFERENCES.defaultRouteVisibility
|
|
2404
|
+
defaultRouteVisibility: isRouteVisibility(input?.defaultRouteVisibility) ? input.defaultRouteVisibility : exports.DEFAULT_USER_PREFERENCES.defaultRouteVisibility,
|
|
2405
|
+
routingDefaults: (0, preferences_1.normalizeRoutingDefaults)(input?.routingDefaults)
|
|
2321
2406
|
};
|
|
2322
2407
|
}
|
|
2323
2408
|
function mergeUserPreferences(current, update) {
|
|
@@ -2332,11 +2417,134 @@ var require_user_preferences = __commonJS((exports) => {
|
|
|
2332
2417
|
overlays: {
|
|
2333
2418
|
...base.overlays,
|
|
2334
2419
|
...update.overlays ?? {}
|
|
2335
|
-
}
|
|
2420
|
+
},
|
|
2421
|
+
routingDefaults: (0, preferences_1.mergeRoutingDefaults)(base.routingDefaults, update.routingDefaults)
|
|
2336
2422
|
});
|
|
2337
2423
|
}
|
|
2338
2424
|
});
|
|
2339
2425
|
|
|
2426
|
+
// ../../packages/core/dist/routing/surface.js
|
|
2427
|
+
var require_surface = __commonJS((exports) => {
|
|
2428
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2429
|
+
exports.SURFACE_MISMATCH_THRESHOLD = undefined;
|
|
2430
|
+
exports.bucketSurfaceType = bucketSurfaceType;
|
|
2431
|
+
exports.bucketMatchesPreference = bucketMatchesPreference;
|
|
2432
|
+
exports.surfaceMismatchFraction = surfaceMismatchFraction;
|
|
2433
|
+
exports.isSurfaceMismatch = isSurfaceMismatch;
|
|
2434
|
+
var BUCKET_TO_TYPE = {
|
|
2435
|
+
paved: "paved",
|
|
2436
|
+
compacted: "mixed",
|
|
2437
|
+
unpaved: "unpaved",
|
|
2438
|
+
path: "unpaved"
|
|
2439
|
+
};
|
|
2440
|
+
function bucketSurfaceType(bucket) {
|
|
2441
|
+
return BUCKET_TO_TYPE[bucket];
|
|
2442
|
+
}
|
|
2443
|
+
function bucketMatchesPreference(bucket, pref) {
|
|
2444
|
+
if (pref === "mixed")
|
|
2445
|
+
return true;
|
|
2446
|
+
return BUCKET_TO_TYPE[bucket] === pref;
|
|
2447
|
+
}
|
|
2448
|
+
function surfaceMismatchFraction(metersByBucket, pref) {
|
|
2449
|
+
if (pref === "mixed")
|
|
2450
|
+
return 0;
|
|
2451
|
+
let total = 0;
|
|
2452
|
+
let violating = 0;
|
|
2453
|
+
for (const bucket of Object.keys(metersByBucket)) {
|
|
2454
|
+
const m = metersByBucket[bucket];
|
|
2455
|
+
total += m;
|
|
2456
|
+
if (!bucketMatchesPreference(bucket, pref))
|
|
2457
|
+
violating += m;
|
|
2458
|
+
}
|
|
2459
|
+
if (total <= 0)
|
|
2460
|
+
return 0;
|
|
2461
|
+
return violating / total;
|
|
2462
|
+
}
|
|
2463
|
+
exports.SURFACE_MISMATCH_THRESHOLD = 0.05;
|
|
2464
|
+
function isSurfaceMismatch(metersByBucket, pref) {
|
|
2465
|
+
return surfaceMismatchFraction(metersByBucket, pref) > exports.SURFACE_MISMATCH_THRESHOLD;
|
|
2466
|
+
}
|
|
2467
|
+
});
|
|
2468
|
+
|
|
2469
|
+
// ../../packages/core/dist/routing/valhalla-costing.js
|
|
2470
|
+
var require_valhalla_costing = __commonJS((exports) => {
|
|
2471
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2472
|
+
exports.valhallaCostingModelForActivity = valhallaCostingModelForActivity;
|
|
2473
|
+
exports.valhallaCostingFromPreferences = valhallaCostingFromPreferences;
|
|
2474
|
+
function valhallaCostingModelForActivity(activity) {
|
|
2475
|
+
return activity === "cycle" ? "bicycle" : "pedestrian";
|
|
2476
|
+
}
|
|
2477
|
+
var SURFACE_USE_TRACKS_BIKE = {
|
|
2478
|
+
paved: 0,
|
|
2479
|
+
mixed: 0.3,
|
|
2480
|
+
unpaved: 0.8
|
|
2481
|
+
};
|
|
2482
|
+
var SURFACE_AVOID_BAD_BIKE = {
|
|
2483
|
+
paved: 1,
|
|
2484
|
+
mixed: 0.25,
|
|
2485
|
+
unpaved: 0
|
|
2486
|
+
};
|
|
2487
|
+
var SURFACE_USE_TRACKS_PED = {
|
|
2488
|
+
paved: 0,
|
|
2489
|
+
mixed: 0.5,
|
|
2490
|
+
unpaved: 1
|
|
2491
|
+
};
|
|
2492
|
+
function valhallaCostingFromPreferences(activity, prefs, options) {
|
|
2493
|
+
if (activity === "cycle") {
|
|
2494
|
+
const bicycle = {
|
|
2495
|
+
use_ferry: prefs.avoidFerries ? 0 : 0.5,
|
|
2496
|
+
use_roads: prefs.avoidHighways ? 0.2 : 0.5,
|
|
2497
|
+
use_tracks: SURFACE_USE_TRACKS_BIKE[prefs.surfacePreference],
|
|
2498
|
+
avoid_bad_surfaces: SURFACE_AVOID_BAD_BIKE[prefs.surfacePreference]
|
|
2499
|
+
};
|
|
2500
|
+
return {
|
|
2501
|
+
costing: "bicycle",
|
|
2502
|
+
costing_options: { bicycle }
|
|
2503
|
+
};
|
|
2504
|
+
}
|
|
2505
|
+
const pedestrian = {
|
|
2506
|
+
use_ferry: prefs.avoidFerries ? 0 : 0.5,
|
|
2507
|
+
use_tracks: SURFACE_USE_TRACKS_PED[prefs.surfacePreference]
|
|
2508
|
+
};
|
|
2509
|
+
if (typeof options?.walkingSpeedMps === "number" && options.walkingSpeedMps > 0) {
|
|
2510
|
+
pedestrian.walking_speed = options.walkingSpeedMps;
|
|
2511
|
+
}
|
|
2512
|
+
return {
|
|
2513
|
+
costing: "pedestrian",
|
|
2514
|
+
costing_options: { pedestrian }
|
|
2515
|
+
};
|
|
2516
|
+
}
|
|
2517
|
+
});
|
|
2518
|
+
|
|
2519
|
+
// ../../packages/core/dist/routing/index.js
|
|
2520
|
+
var require_routing = __commonJS((exports) => {
|
|
2521
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
2522
|
+
if (k2 === undefined)
|
|
2523
|
+
k2 = k;
|
|
2524
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2525
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2526
|
+
desc = { enumerable: true, get: function() {
|
|
2527
|
+
return m[k];
|
|
2528
|
+
} };
|
|
2529
|
+
}
|
|
2530
|
+
Object.defineProperty(o, k2, desc);
|
|
2531
|
+
} : function(o, m, k, k2) {
|
|
2532
|
+
if (k2 === undefined)
|
|
2533
|
+
k2 = k;
|
|
2534
|
+
o[k2] = m[k];
|
|
2535
|
+
});
|
|
2536
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
2537
|
+
for (var p in m)
|
|
2538
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
2539
|
+
__createBinding(exports2, m, p);
|
|
2540
|
+
};
|
|
2541
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2542
|
+
__exportStar(require_preferences(), exports);
|
|
2543
|
+
__exportStar(require_surface(), exports);
|
|
2544
|
+
__exportStar(require_types(), exports);
|
|
2545
|
+
__exportStar(require_valhalla_costing(), exports);
|
|
2546
|
+
});
|
|
2547
|
+
|
|
2340
2548
|
// ../../node_modules/.bun/zustand@5.0.13+e55371ec98c955e9/node_modules/zustand/vanilla.js
|
|
2341
2549
|
var require_vanilla = __commonJS((exports) => {
|
|
2342
2550
|
var createStoreImpl = (createState) => {
|
|
@@ -3698,7 +3906,7 @@ var require_middleware = __commonJS((exports) => {
|
|
|
3698
3906
|
});
|
|
3699
3907
|
|
|
3700
3908
|
// ../../packages/core/dist/stores/routing.js
|
|
3701
|
-
var
|
|
3909
|
+
var require_routing2 = __commonJS((exports) => {
|
|
3702
3910
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3703
3911
|
exports.createRoutingStore = createRoutingStore;
|
|
3704
3912
|
var zustand_1 = require_zustand();
|
|
@@ -3718,6 +3926,7 @@ var require_routing = __commonJS((exports) => {
|
|
|
3718
3926
|
isMapLocked: false,
|
|
3719
3927
|
mode: { kind: "unsaved" },
|
|
3720
3928
|
activity: undefined,
|
|
3929
|
+
routingPreferences: null,
|
|
3721
3930
|
history: (0, history_1.emptyHistory)(),
|
|
3722
3931
|
canUndo: false,
|
|
3723
3932
|
canRedo: false
|
|
@@ -3774,7 +3983,7 @@ var require_routing = __commonJS((exports) => {
|
|
|
3774
3983
|
function createRoutingStore(logger) {
|
|
3775
3984
|
const persistConfig = {
|
|
3776
3985
|
name: "routing-store",
|
|
3777
|
-
version:
|
|
3986
|
+
version: 4,
|
|
3778
3987
|
storage: (0, middleware_1.createJSONStorage)(() => createQuotaSafeStorage(logger)),
|
|
3779
3988
|
migrate: (persisted, version) => {
|
|
3780
3989
|
let next = persisted ?? {};
|
|
@@ -3799,6 +4008,7 @@ var require_routing = __commonJS((exports) => {
|
|
|
3799
4008
|
isMapLocked: state.isMapLocked,
|
|
3800
4009
|
mode: state.mode,
|
|
3801
4010
|
activity: state.activity,
|
|
4011
|
+
routingPreferences: state.routingPreferences,
|
|
3802
4012
|
history: state.history,
|
|
3803
4013
|
canUndo: state.canUndo,
|
|
3804
4014
|
canRedo: state.canRedo
|
|
@@ -3909,6 +4119,9 @@ var require_routing = __commonJS((exports) => {
|
|
|
3909
4119
|
setActivity: (activity) => {
|
|
3910
4120
|
set({ activity });
|
|
3911
4121
|
},
|
|
4122
|
+
setRoutingPreferences: (prefs) => {
|
|
4123
|
+
set({ routingPreferences: prefs });
|
|
4124
|
+
},
|
|
3912
4125
|
saveSnapshot: () => {
|
|
3913
4126
|
set((state) => {
|
|
3914
4127
|
const snapshot = state.waypoints.map((wp) => ({ ...wp }));
|
|
@@ -3986,7 +4199,7 @@ var require_stores = __commonJS((exports) => {
|
|
|
3986
4199
|
__createBinding(exports2, m, p);
|
|
3987
4200
|
};
|
|
3988
4201
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3989
|
-
__exportStar(
|
|
4202
|
+
__exportStar(require_routing2(), exports);
|
|
3990
4203
|
});
|
|
3991
4204
|
|
|
3992
4205
|
// ../../packages/core/dist/utils/formatting.js
|
|
@@ -4336,8 +4549,9 @@ var require_dist = __commonJS((exports) => {
|
|
|
4336
4549
|
__exportStar(require_errors(), exports);
|
|
4337
4550
|
__exportStar(require_history(), exports);
|
|
4338
4551
|
__exportStar(require_user_preferences(), exports);
|
|
4552
|
+
__exportStar(require_routing(), exports);
|
|
4339
4553
|
__exportStar(require_stores(), exports);
|
|
4340
|
-
__exportStar(
|
|
4554
|
+
__exportStar(require_types2(), exports);
|
|
4341
4555
|
__exportStar(require_utils(), exports);
|
|
4342
4556
|
});
|
|
4343
4557
|
|