@expofp/wayfinding

中文文档
3.49.2发布于 2026/11/14MITTypeScriptES Module近 30 天下载 8410

ExpoFP SDK internal: framework-neutral wayfinding (routing, snapping, scene rendering)

原始使用文档
文档目录4 节
  1. Install
  2. Layers
  3. Ports (host implements)
  4. Usage

@expofp/wayfinding

Framework-neutral wayfinding for the ExpoFP SDK: a routing/snapping engine, an imperative runtime orchestrator, and a scene renderer — with no coupling to efp stores or MobX. core and runtime are environment-agnostic; the scene renderer assumes a browser-like environment (requestAnimationFrame, document), so the package is not suitable for Node/SSR as-is. All three layers sit behind two entry points: initWayfindingLayers, which builds the layer block for the host to mount, and createWayfinding, which finds it in the scene and fills it.

Install

pnpm add @expofp/wayfinding @expofp/renderer

@expofp/renderer is a peer dependency and must be installed by the consumer: the package's public types (e.g. RenderableDef on Wayfinding/RendererPort) reference it, so its types must resolve for @expofp/wayfinding's .d.ts to compile.

Layers

LayerWhat it is
coreGraph build + A* pathfinding, route geometry, snapping, transition points. Pure functions.
runtimeImperative orchestrator (setRoute / setPosition / notifyFloorChanged) over the engine.
rendererScene mutator (icons, trails, route lines) against an injected RendererPort.

These layers are internal. The package exports only the createWayfinding facade, initWayfindingLayers (the layer block it draws into, for the host to mount) with resolveWayfindingLayers (which finds that block in a scene again), the port interfaces the host implements, the boundary data types, the CURRENT_POSITION_POINT_ID protocol sentinel, and the optimizeWaypointOrder helper.

Ports (host implements)

The package knows nothing concrete about the host renderer, graph data, or app state. The host supplies four ports via WayfindingConfig:

  • dataSource (GraphDataSource) — graph lines + line ends for pathfinding.
  • renderer (RendererPort) — the host's cardinal-snap rule and commit.
  • iconProvider (IconProvider) — canvases for icon names.
  • floorContext (FloorContext) — active floor / visibility predicates.

@expofp/renderer is a type-only peer (its types appear in the public API; the concrete renderer is injected through RendererPort). @expofp/geometry is a regular runtime dependency (Rect, Box, geometry helpers).

Usage

import { createWayfinding } from '@expofp/wayfinding';

const wayfinding = createWayfinding({
  dataSource, // GraphDataSource
  renderer, // RendererPort
  iconProvider, // IconProvider
  floorContext, // FloorContext
  layers, // WayfindingLayers, from resolveWayfindingLayers(scene.rootLayer)
  gpsConfig, // optional GPS calibration + snap/reroute thresholds
  onTransitionClick: (point) => {
    /* switch active floor */
  },
  onRouteUpdate: (lines, bounds) => {
    /* fit camera, update UI */
  },
  onRouteDistance: (distance) => {
    /* show remaining distance */
  },
});

// Drive it with route/position/floor updates:
wayfinding.setRoute({ from, to, accessible: false });
wayfinding.setPosition(position); // or null to hide
wayfinding.notifyFloorChanged();

// Forward pointer events:
wayfinding.handleClick(pickedDefs);

wayfinding.destroy();

optimizeWaypointOrder is exported separately to order booth waypoints before a createWayfinding instance exists (it backs the SDK's getOptimizedRoutes).

版本与发布记录

@expofp/wayfinding 共发布 117 个版本,首次发布于 2026/07/15;过去 12 个月发布了 117 个版本。

版本发布日期距今
3.49.2latest2026/11/14今天
0.0.0-experimental.3b0db16feat/wayfinding-compiler2026/11/13今天
3.49.12026/11/121 天前
3.49.02026/11/112 天前
3.48.02026/11/112 天前
3.47.22026/11/103 天前

其他发布通道:multi-venue → 0.0.0-experimental.cf063fc,stable → 3.47.0,eurotier → 0.0.0-experimental.6dabc65,feat/wayfinding-compiler → 0.0.0-experimental.3b0db16。

关于 @expofp/wayfinding 的常见问题

@expofp/wayfinding 是什么?

ExpoFP SDK internal: framework-neutral wayfinding (routing, snapping, scene rendering)

如何安装 @expofp/wayfinding?

在项目目录运行 npm install @expofp/wayfinding,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@expofp/renderer(3.49.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@expofp/wayfinding 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@expofp/wayfinding 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@expofp/wayfinding 可以商用吗?

@expofp/wayfinding 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@expofp/wayfinding 的下载量有多少?

根据 npm 官方下载统计,@expofp/wayfinding 在 2026/10/14 – 2026/11/12 这 30 天内被下载 8,410 次,日均约 280 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@expofp/wayfinding 还在维护吗?

最新版本 3.49.2 发布于 2026/11/14(今天);至今共发布 117 个版本,其中过去 12 个月发布了 117 个;首次发布于 2026/07/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。