@vizejs/marquette

中文文档
0.650.0发布于 2026/11/03MITTypeScriptES Module零依赖构建来源已验证

Typed application marquettes for every Vize target

原始使用文档
文档目录5 节
  1. Author a marquette
  2. Runtime validation
  3. Adapter capability negotiation
  4. Test-run evidence
  5. Guarantees

@vizejs/marquette

Typed application marquettes for every Vize target.

Experimental: serialized contracts are versioned, but the TypeScript API may evolve while target adapters are being validated.

Marquette is the small, language-neutral description shared by web, native, desktop, terminal, backend, transport, testing, and gallery tooling. This package provides literal-preserving TypeScript authoring. Runtime validation is available through a separate entry, while canonicalization and compatibility analysis remain focused layers.

Author a marquette

import { defineApplicationMarquette } from "@vizejs/marquette";

export default defineApplicationMarquette({
  application: "shop",
  targets: ["web", "native"],
  environments: [
    {
      id: "web",
      target: "web",
      consumer: "client",
      runtime: "browser",
    },
    {
      id: "native",
      target: "native",
      consumer: "client",
      runtime: "native",
    },
    {
      id: "server",
      target: "web",
      consumer: "server",
      runtime: "rust",
    },
  ],
  backends: [
    {
      id: "api",
      family: "rust",
      environment: "server",
    },
  ],
  protocols: [
    {
      id: "api.query",
      family: "schema-query",
      backend: "api",
    },
  ],
  routes: [
    {
      id: "home",
      path: "/",
      environment: "web",
      rendering: "hybrid",
      backend: "api",
      protocol: "api.query",
    },
  ],
});

Environment dependencies, backend owners, protocol owners, and route references are checked against identifiers declared in the same object. A misspelled reference is therefore an authoring error rather than a runtime surprise.

Runtime validation

Use the dedicated validation entry when contracts cross file, process, or language boundaries:

import { validateApplicationMarquette } from "@vizejs/marquette/validate";

const diagnostics = validateApplicationMarquette(shop);
for (const diagnostic of diagnostics) {
  console.error(diagnostic.code, diagnostic.path, diagnostic.message);
}

Validation is deterministic, does not mutate the authored object, and reports stable codes shared with the native contract implementation. Keeping it in a separate entry means authoring-only applications do not include validation code.

Adapter capability negotiation

Adapters publish inclusive capability-version ranges independently from the application marquette. Application capability definitions are the authority for requirements; an undeclared requirement fails closed even when an adapter offers a capability with the same identifier. Adapter-only capabilities are allowed and remain additive until an application requires them.

import {
  negotiateAdapterCapabilities,
  type AdapterCapabilityManifest,
} from "@vizejs/marquette/adapter";

const adapter = {
  adapter: "terminal.fresco",
  capabilities: [{ id: "terminal.color", minVersion: 1, maxVersion: 3 }],
} satisfies AdapterCapabilityManifest;

const result = negotiateAdapterCapabilities(
  marquette,
  marquette.environments?.[0]?.capabilities ?? [],
  adapter,
);
if (!result.compatible) {
  console.error(result.diagnostics, result.mismatches);
}

Exact and inclusive-bound matches are compatible. Missing support, requirements below an adapter's minimum, and requirements above its maximum use the stable missing-capability, version-below-minimum, and version-above-maximum codes. Each mismatch also carries a deterministic path and message, so native adapter diagnostics can be rendered without target-specific string formatting. Adding a support range or widening either bound is additive; removing support or narrowing either bound is breaking. Both negotiation and compatibility reports are sorted deterministically and do not mutate their inputs. Compatibility reports expose validation diagnostics for both manifests and omit changes when either input is invalid. The published manifest schema is available from @vizejs/marquette/adapter/schema.

Native rendering adapters share one closed version-one baseline for rendering, events, layout, text, images, animation, accessibility, and lifecycle:

import { nativeEngineCapabilityProfile } from "@vizejs/marquette/adapter";

const nativeAdapter = {
  adapter: "native.example",
  capabilities: nativeEngineCapabilityProfile(),
};

The canonical identifiers use the native.* namespace and are emitted in a stable order. The helper returns fresh values so an adapter may add private capabilities without changing the baseline used by another consumer.

Test-run evidence

Release-bound test-run evidence records live in their own lazy entries so deployment tooling can bind a tests check to retained, immutable facts:

import { defineTestRunEvidence } from "@vizejs/marquette/test-run";
import { validateTestRunEvidence } from "@vizejs/marquette/test-run/validate";
import { testRunAdmissionId } from "@vizejs/marquette/test-run/canonical";
import { admitTestRun, decideTestRunAdmission } from "@vizejs/marquette/test-run/admission";
import { verifyTestRunCheck } from "@vizejs/marquette/test-run/check";
import { verifyTestRunTransition } from "@vizejs/marquette/test-run/transition";

const diagnostics = validateTestRunEvidence(evidence);
const admissionId = await testRunAdmissionId(evidence); // test-run:<sha256>
const rejections = await admitTestRun(evidence, candidate, admissionId, now);
const decision = await decideTestRunAdmission(evidence, candidate, admissionId, now);
if (!decision.allowed) {
  console.error(decision.denialCodes); // e.g. ["record-expired"]
}
const release = await verifyTestRunCheck(retainedCheck, candidate, evidence, now);
const journal = await verifyTestRunTransition(nextTransition, chainTip);

Validation shares its VIZE_MARQUETTE_1xx codes, paths, and ordering with the native implementation, and the canonical entry produces byte-identical serialization and SHA-256 fingerprints, proven by the shared fixtures in tests/fixtures/test-run-evidence/. Admission decisions carry the stable, append-only denial-code vocabulary shared by every backend family; the same fixtures pin every decision so a JavaScript, Rust, Go, or JVM gate denies for identical machine-readable causes. The check entry replaces every generic test-result reference in release evidence: a retained vize.test-run.check record may only name the exact test-run:<sha256> admission id, bind the six candidate facts, and record an observer independent from the runner. The transition entry makes each release decision and the complete accepted anti-replay state one durable atomic record, chained by canonical SHA-256 fingerprints; hosts persist it with a write-then-atomic-rename and verify the recovered tip before deciding anything new. The published record schema is available from @vizejs/marquette/test-run/schema, the decision contract from @vizejs/marquette/test-run/admission/schema, the tests-check contract from @vizejs/marquette/test-run/check/schema, and the transition contract from @vizejs/marquette/test-run/transition/schema.

Guarantees

  • Exact identifiers remain available as EnvironmentId, BackendId, ProtocolId, and RouteId unions.
  • defineApplicationMarquette returns its input without allocation or normalization.
  • The published application-contract schema is available from @vizejs/marquette/schema.
  • The published adapter manifest schema is available from @vizejs/marquette/adapter/schema.
  • Every optional contract field documents its default in JSDoc.
  • Package builds enforce a 1 KiB gzip budget for authoring entries and 3 KiB or 4 KiB budgets for the validation entries.

Marquette describes components and environments; it does not author UI components. Public Vize UI components use real .vue SFC files as their canonical source, never authored h() calls or handwritten render functions.

版本与发布记录

@vizejs/marquette 共发布 309 个版本,首次发布于 2026/07/22;过去 12 个月发布了 309 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.650.0latest2026/11/03今天
0.649.02026/11/03今天
0.648.02026/11/02今天
0.647.02026/11/021 天前
0.646.02026/11/021 天前
0.645.02026/11/021 天前

关于 @vizejs/marquette 的常见问题

@vizejs/marquette 是什么?

每个Vize目标的键入应用程序市场

如何安装 @vizejs/marquette?

在项目目录运行 npm install @vizejs/marquette,或使用 pnpm add / yarn add / bun add。

@vizejs/marquette 支持 TypeScript 吗?

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

@vizejs/marquette 支持 ESM 还是 CommonJS?

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

@vizejs/marquette 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@vizejs/marquette 可以商用吗?

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

@vizejs/marquette 还在维护吗?

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