@equinor/fusion-framework-app

中文文档
13.3.0发布于 2026/11/12ISCTypeScriptES Module近 30 天下载 8498
原始使用文档
文档目录13 节
  1. Documentation
  2. Installation
  3. Quick Start
  4. Key Concepts
  5. Portal authentication is inherited by default
  6. API Surface
  7. configureModules(cb?)
  8. Sub-path Exports
  9. Configure HTTP Clients
  10. Enable Bookmarks
  11. Testing
  12. Types
  13. Further Reading

title: "@equinor/fusion-framework-app" description: "Application foundation package for the Fusion Framework" category: "Application" tag:

  • app
  • core
  • foundation
  • modules
  • framework
  • typescript

Configuration and initialization layer for Fusion applications.

Use this package to set up application modules, configure HTTP clients, integrate with service discovery, enable bookmarks, and wire up telemetry — all with a single configureModules call.

Most Fusion apps should use @equinor/fusion-framework-react-app instead. This lower-level package is for framework-agnostic or advanced scenarios.

Documentation

TopicDescription
Configure HTTP ClientsNamed clients from app config, service discovery, and explicit registration, plus resolution priority
Enable BookmarksRegistering the bookmark module via enableBookmark
TestingThe /mock entry point: mockAppModules, AppMockConfigurator, and enableAppManifestMock

Installation

pnpm add @equinor/fusion-framework-app

Quick Start

import type { AppModuleInitiator } from '@equinor/fusion-framework-app';
import { enableState } from '@equinor/fusion-framework-app/enable-state';

const configure: AppModuleInitiator = (configurator) => {
    enableState(configurator);
};

[!CAUTION] The state management module is a powerful tool, but it's important to know the potential pitfalls and limitations when using it in your application. The state management is global and can lead to unexpected behavior if not used carefully.

example 1: If you have multiple components that rely on the same state, updating the state in one component can cause re-renders in all components that use that state, potentially leading to performance issues.

example 2: The user has open multiple tabs of the application, and each tab is modifying the same state. This can lead to unexpected behavior, as changes made in one tab will be reflected to all tabs. (like storing user preferences for selected columns)

Bookmarks

The bookmark module provides a way to save and restore the state of the application. This is useful for saving the state of the application when the user navigates away from the application and then returns to the application.

# Install the bookmark module
pnpm add @equinor/fusion-framework-module-bookmark
import { configureModules } from '@equinor/fusion-framework-app';

// Create an initializer with custom configuration
const initialize = configureModules((configurator, { fusion, env }) => {
  // Register a named HTTP client
  configurator.configureHttpClient('myApi', {
    baseUri: 'https://api.example.com',
    defaultScopes: ['api://client-id/.default'],
  });
});

// Bootstrap the application
const modules = await initialize({ fusion, env });

Key Concepts

Portal authentication is inherited by default

configureModules creates an AppConfigurator that registers auth alongside event and http before the app's configuration callback runs. It initializes these modules with fusion.modules as the parent reference. MSAL then reuses the portal auth provider through its version-compatible createProxyProvider path, sharing the existing client and live account without another login. The React app bootstrap uses this same path.

Ordinary hosted apps do not need enableMSAL to use Roles V2. Register enableRoles normally; the real Roles client reads the inherited account before each account-scoped operation, so parent account changes and sign-out are reflected in subsequent requests. An unavailable account produces RequiredAccessRolesError, not a new login flow.

For deliberate custom authentication, use enableMSAL with builder.setProvider(customAuthProvider). The explicitly supplied provider remains authoritative, even when signed out. A bare enableMSAL call is redundant here, and client settings alone do not override a parent provider. This default registration is independent of telemetry and does not apply to bare ModulesConfigurator bootstraps. See the Roles authentication boundary.

ConceptDescription
configureModulesFactory function that creates an async initializer for application modules.
AppConfiguratorInternal configurator created by configureModules; registers default modules (event, http, msal) and reads endpoint config.
IAppConfiguratorPublic interface for the configurator, used when typing configuration callbacks.
AppModuleInitiatorCallback signature accepted by configureModules for user-supplied setup.
AppEnvEnvironment descriptor containing the app manifest, config, and optional basename.
enableBookmarkHelper to enable the bookmark module (import from @equinor/fusion-framework-app/enable-bookmark).
mockAppModulesRuns the real module pipeline against deterministic fakes for tests (import from @equinor/fusion-framework-app/mock).

API Surface

configureModules(cb?)

Returns an async initializer (args: { fusion, env }) => Promise<AppModulesInstance>.

The optional callback receives an IAppConfigurator and the Fusion/env args, giving you access to:

  • configurator.configureHttpClient(name, options) — register a named HTTP client with explicit base URI and scopes.
  • configurator.configureHttp(...) — low-level HTTP module configuration.
  • configurator.useFrameworkServiceClient(serviceName, options?) — register a client resolved via Fusion service discovery.
  • configurator.configureAppIdentification(options) — control the x-fusion-app* headers that identify the app to backend telemetry. See App Identification Headers.

Sub-path Exports

Export pathWhat it provides
@equinor/fusion-framework-appconfigureModules, AppConfigurator, IAppConfigurator, all type aliases
@equinor/fusion-framework-app/enable-bookmarkenableBookmark function
@equinor/fusion-framework-app/mockmockAppModules, AppMockConfigurator, enableAppManifestMock

Configure HTTP Clients

The AppConfigurator can register named HTTP clients from several sources — application config endpoints, service discovery, or explicit registration — and you retrieve one at runtime with framework.modules.http.createClient(name).

const initialize = configureModules((configurator) => {
  configurator.useFrameworkServiceClient('people');
});

See Configure HTTP Clients for auto-registration from app.config.ts, explicit registration, and resolution priority when a client is configured in more than one place.

Enable Bookmarks

The bookmark module allows applications to save and restore application state.

Important: Import enableBookmark from the app-level package, not from @equinor/fusion-framework-module-bookmark directly.

import { enableBookmark } from '@equinor/fusion-framework-app/enable-bookmark';

const initialize = configureModules((configurator) => {
  enableBookmark(configurator);
});

See Enable Bookmarks for payload generator cleanup behavior.

Testing

Import from @equinor/fusion-framework-app/mock to run an application's real module pipeline in tests — the real event/http/msal modules, the real AppConfigurator configuration pipeline, and real lifecycle — while only the boundaries that reach outside the process are substituted with deterministic fakes. This entry point has no dependency on Vitest or any other test runner.

import { mockAppModules } from '@equinor/fusion-framework-app/mock';

const manifest = { appKey: 'my-app', displayName: 'My App', description: 'My app', type: 'standalone' } as const;
const modules = await mockAppModules(undefined, { manifest });

See Testing for AppMockConfigurator, enableAppManifestMock, and customizing the mocked parent's service discovery.

Types

TypePurpose
AppEnvEnvironment descriptor (manifest, config, basename, props)
AppModuleInitiatorConfiguration callback signature for configureModules
AppModuleInitFull factory type wrapping AppModuleInitiator
AppModuleInitArgsArguments passed to the returned initializer
AppRenderFnRender function for mounting an app into a DOM element
AppManifestApplication manifest metadata (re-export)
AppConfigEnvironment-specific config (re-export)
AppModulesUnion of default application modules (re-export)
AppModulesInstanceResolved module instances after initialization (re-export)

Further Reading

版本与发布记录

@equinor/fusion-framework-app 共发布 329 个版本,首次发布于 2022/08/22;过去 12 个月发布了 61 个版本。

版本发布日期距今
13.3.0latest2026/11/121 天前
13.3.0-next.3next2026/11/112 天前
13.2.22026/11/112 天前
13.3.0-next.22026/10/2915 天前
13.3.0-next.12026/10/2816 天前
13.3.0-next.02026/10/2816 天前

其他发布通道:apploader → 9.3.15-apploader-be21a6b60eb13eee8bf869e75002d8634e9c50a9,cli-search-index → 10.1.3-cli-search-index.0,msal-v5 → 10.2.2-msal-v5.1,trusted-publishing-20261015 → 13.1.11-trusted-publishing-20261015-9dfe7602cd2a49a8a9df00d62c26e7304a82a85a,next → 13.3.0-next.3。

关于 @equinor/fusion-framework-app 的常见问题

如何安装 @equinor/fusion-framework-app?

在项目目录运行 npm install @equinor/fusion-framework-app,或使用 pnpm add / yarn add / bun add。

@equinor/fusion-framework-app 支持 TypeScript 吗?

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

@equinor/fusion-framework-app 支持 ESM 还是 CommonJS?

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

@equinor/fusion-framework-app 可以商用吗?

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

@equinor/fusion-framework-app 的下载量有多少?

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

@equinor/fusion-framework-app 还在维护吗?

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