@impetik/xeer-mcp 0.2.18 → 0.2.20

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.
@@ -16,6 +16,28 @@
16
16
  */
17
17
  /** The two module graphs the compiler walks. Test files have their own surface and are not a zone. */
18
18
  export type ImportZone = 'client' | 'server';
19
+ /**
20
+ * The UI providers the platform implements, in the spelling `client.runtime.provider` uses.
21
+ *
22
+ * A provider is a whole renderer family — packages, entrypoint classification, JSX runtimes, and
23
+ * the compat aliases the family does or does not offer — and the client zone's policy is a pure
24
+ * function of which one the manifest declares ({@link clientImportPolicy}). Adding a provider is
25
+ * adding a family and a case, never a flag threaded through the consumers: what a specifier means
26
+ * on the client has exactly one answer per provider, stated here.
27
+ */
28
+ export declare const CLIENT_RUNTIME_PROVIDERS: readonly ["preact", "react"];
29
+ export type ClientRuntimeProvider = (typeof CLIENT_RUNTIME_PROVIDERS)[number];
30
+ /**
31
+ * Where the renderer comes from. `platform` is the only implemented source: the platform packages
32
+ * declare and install the renderer, and applications never do. A future application-owned renderer
33
+ * would be `application`, which is a different resolution story rather than a different default.
34
+ */
35
+ export type ClientRuntimeSource = 'platform';
36
+ /** The normalized `client.runtime` block: a provider and where its packages come from. */
37
+ export interface ClientRuntime {
38
+ readonly provider: ClientRuntimeProvider;
39
+ readonly source: ClientRuntimeSource;
40
+ }
19
41
  /**
20
42
  * What one public entrypoint of the managed renderer package is *for*. Admission derives from this:
21
43
  * `runtime` and `development` entrypoints may be imported by client application code; `test` and
@@ -27,23 +49,80 @@ export type RendererEntrypointClassification =
27
49
  'runtime'
28
50
  /** Supported, but exists for development tooling; mutates the renderer's shared options. */
29
51
  | 'development'
52
+ /**
53
+ * A published entrypoint whose bytes are built for a host runtime the client zone is not — React's
54
+ * Node, Bun, and edge server renderers. Supported by the package and genuinely useful elsewhere,
55
+ * which is what separates it from an entrypoint that does not exist: refused with its own reason
56
+ * so the diagnostic can say *why* rather than claim the renderer publishes no such thing.
57
+ */
58
+ | 'other-runtime'
30
59
  /** Test-only surface. Never a production-client import. */
31
60
  | 'test'
32
61
  /** A `package.json` subpath: metadata, not code. Pinned during bundling, rejected as an import. */
33
62
  | 'metadata';
34
63
  /**
35
- * A package family whose members must resolve to one physical package root regardless of importer —
36
- * the renderer, on the client. `entrypoints` classifies every public export of the anchor package;
37
- * `compatAliases` maps the React-ecosystem specifiers onto their `preact/compat` targets, which is
38
- * React-library compatibility under the Preact provider, not BYO React (#214 owns a real adapter).
64
+ * Where one entrypoint's TypeScript declarations live — a fact about the published packages, stated
65
+ * beside the classification that decides whether an application may import them.
66
+ *
67
+ * The vocabulary is exactly the cases the two renderers present, and no more. React ships no types
68
+ * at all and DefinitelyTyped publishes them under a second package name, one subpath per entrypoint;
69
+ * Preact ships its own inside the package the runtime bytes come from, named by its `exports` map's
70
+ * `types` condition; and a handful of entrypoints under both providers have declarations *nowhere* —
71
+ * `scheduler`, `react-dom/profiling`, `preact/compat/scheduler`. That third case is a fact worth
72
+ * declaring rather than an omission worth tolerating: it is what makes both tools refuse the same
73
+ * specifier by construction instead of by two people separately deciding not to add a row.
74
+ *
75
+ * Declarative on purpose, like the rest of this module. `types-package` carries the specifier
76
+ * because that name is a published fact; neither case carries a file path, because turning either
77
+ * into a file is resolution, and resolution happens against the platform's own install on the
78
+ * compiler side of this seam.
79
+ */
80
+ export type EntrypointTypesSource =
81
+ /**
82
+ * A separate `@types/*` package publishes them, at `specifier`. Also the escape hatch the editor
83
+ * shims need: a second name for the same declarations, which no `paths` row maps.
84
+ */
85
+ {
86
+ readonly kind: 'types-package';
87
+ readonly specifier: string;
88
+ }
89
+ /** The anchor package ships them itself, named by the `types` condition of its own `exports` map. */
90
+ | {
91
+ readonly kind: 'anchor';
92
+ }
93
+ /** Nothing publishes them. Every tool refuses the specifier, and all of them are right. */
94
+ | {
95
+ readonly kind: 'none';
96
+ };
97
+ /** One public entrypoint of a managed package: what it is for, and where its declarations live. */
98
+ export interface RendererEntrypoint {
99
+ readonly classification: RendererEntrypointClassification;
100
+ readonly types: EntrypointTypesSource;
101
+ }
102
+ /**
103
+ * A package family whose members must resolve to one physical package root per package, regardless
104
+ * of importer — the renderer, on the client.
105
+ *
106
+ * `anchorPackages` is plural because a renderer family is not always one npm package: Preact ships
107
+ * its whole surface in `preact`, while React spans `react`, `react-dom`, and `scheduler`, each with
108
+ * its own installed root and its own `exports` map. Every classified entrypoint belongs to exactly
109
+ * one of them, derived from the specifier rather than declared twice, and single-root verification
110
+ * is *per package* — one react root and one react-dom root, not one root for the family.
111
+ *
112
+ * `packages` is the wider set: the names the family owns for admission purposes, including the ones
113
+ * it only owns in order to alias them. `compatAliases` maps the React-ecosystem specifiers onto
114
+ * their `preact/compat` targets, which is React-library compatibility under the Preact provider and
115
+ * has no analogue under React, where those specifiers are the renderer itself.
39
116
  */
40
117
  export interface ManagedPackageFamily {
41
- /** The one package whose installed copy anchors every member of the family. */
42
- readonly anchorPackage: string;
118
+ /** The UI provider whose renderer this family is. */
119
+ readonly provider: ClientRuntimeProvider;
120
+ /** The packages whose installed copies anchor the family. Each classified entrypoint is in one. */
121
+ readonly anchorPackages: readonly string[];
43
122
  /** Bare package names the family owns; any subpath of these is family territory. */
44
123
  readonly packages: readonly string[];
45
- /** Every public entrypoint of the anchor package, classified. Keys are full specifiers. */
46
- readonly entrypoints: ReadonlyMap<string, RendererEntrypointClassification>;
124
+ /** Every public entrypoint of every anchored package, described. Keys are full specifiers. */
125
+ readonly entrypoints: ReadonlyMap<string, RendererEntrypoint>;
47
126
  /** Per-subpath React-family aliases onto anchor entrypoints. Keys are full specifiers. */
48
127
  readonly compatAliases: ReadonlyMap<string, string>;
49
128
  readonly jsx: {
@@ -54,6 +133,13 @@ export interface ManagedPackageFamily {
54
133
  }
55
134
  export interface ZoneImportPolicy {
56
135
  readonly zone: ImportZone;
136
+ /**
137
+ * The UI provider this policy was resolved for, or null for a zone that selects no renderer. It
138
+ * travels with the policy rather than beside it because every consumer that needs the provider
139
+ * already holds the policy — the bundler's plugins, the type-check host, the dev server's aliases
140
+ * — and a second parameter threaded alongside is a second thing that can disagree with the first.
141
+ */
142
+ readonly provider: ClientRuntimeProvider | null;
57
143
  /**
58
144
  * `@impetik/xeer/*` subpaths this zone admits. What each one resolves to is the compiler's
59
145
  * knowledge — the SDK module targets live beside its resolver, not in this declarative layer.
@@ -84,15 +170,21 @@ export interface ZoneImportPolicy {
84
170
  };
85
171
  }
86
172
  /**
87
- * The normalized client runtime: the only implemented provider/source combination. `client.runtime`
88
- * in the manifest is optional and omission normalizes to exactly this value, so declaring it is a
89
- * statement of the default rather than a choice.
173
+ * The default client runtime. `client.runtime` in the manifest is optional and omission normalizes
174
+ * to exactly this value, so an application that says nothing gets the Preact provider it always
175
+ * had — byte-for-byte, down to the artifact identity.
176
+ *
177
+ * The *normalized* runtime of a given application is whatever its manifest declares; this is only
178
+ * the value omission means. Provenance and compiler facts must derive from the manifest's own
179
+ * runtime through {@link clientRuntimeId}, never from this constant.
90
180
  */
91
181
  export declare const NORMALIZED_CLIENT_RUNTIME: Readonly<{
92
182
  readonly provider: "preact";
93
183
  readonly source: "platform";
94
184
  }>;
95
- /** The normalized client runtime as compiler facts and artifact provenance spell it. */
185
+ /** How a client runtime is spelled in compiler facts and artifact provenance. */
186
+ export declare function clientRuntimeId(runtime: ClientRuntime): string;
187
+ /** The default client runtime as compiler facts and artifact provenance spell it. */
96
188
  export declare const CLIENT_RUNTIME_ID: "preact/platform";
97
189
  /**
98
190
  * Default and advisory budgets for the open client bundle, minified pre-gzip bytes of the single
@@ -104,7 +196,22 @@ export declare const CLIENT_BUNDLE_ERROR_BUDGET_BYTES: number;
104
196
  export declare const CLIENT_BUNDLE_ADVISORY_BUDGET_BYTES: number;
105
197
  /** The client renderer family under the Preact provider. */
106
198
  export declare const PREACT_RENDERER_FAMILY: ManagedPackageFamily;
199
+ /**
200
+ * The client renderer family under the React provider: React itself, not a compatibility layer.
201
+ *
202
+ * No `compatAliases`, and the omission is the point. Under Preact the React-ecosystem specifiers are
203
+ * aliases onto `preact/compat` so a React library and the renderer stay one instance; under React
204
+ * they *are* the renderer, and an alias table would be a second name for the same file.
205
+ */
206
+ export declare const REACT_RENDERER_FAMILY: ManagedPackageFamily;
107
207
  export declare const CLIENT_IMPORT_POLICY: ZoneImportPolicy;
208
+ /**
209
+ * The client zone's policy under one UI provider — a pure function of the normalized manifest's
210
+ * `client.runtime.provider`, with no state and no first-caller latching. The Preact instance is
211
+ * returned by identity so consumers that still read {@link CLIENT_IMPORT_POLICY} and consumers that
212
+ * ask for the default share one object, and so the resolver caches keyed on it stay shared.
213
+ */
214
+ export declare function clientImportPolicy(provider: ClientRuntimeProvider): ZoneImportPolicy;
108
215
  /**
109
216
  * The server zone, open to application dependencies since ADR 0005 was accepted (#244).
110
217
  *
@@ -124,9 +231,31 @@ export declare const CLIENT_IMPORT_POLICY: ZoneImportPolicy;
124
231
  * defensible number for. A per-zone budget is a product decision, not a gap this change may fill.
125
232
  */
126
233
  export declare const SERVER_IMPORT_POLICY: ZoneImportPolicy;
127
- export declare function zoneImportPolicy(zone: ImportZone): ZoneImportPolicy;
234
+ /**
235
+ * One zone's policy. The provider only reaches the client zone — the server has no renderer to
236
+ * choose — and defaults to the manifest default so a caller with no manifest in hand (documentation,
237
+ * the server zone) reads exactly what it read before.
238
+ */
239
+ export declare function zoneImportPolicy(zone: ImportZone, provider?: ClientRuntimeProvider): ZoneImportPolicy;
128
240
  /** The bare package name of a specifier: the first segment, or the first two for a scope. */
129
241
  export declare function packageNameOfSpecifier(specifier: string): string;
242
+ /**
243
+ * DefinitelyTyped's name for a package's declarations.
244
+ *
245
+ * A naming rule rather than a lookup, and one nobody guesses correctly for a scoped package: the
246
+ * scope is *flattened into* the name rather than kept, so `@acme/widget` publishes as
247
+ * `@types/acme__widget`. Computed here, beside the specifier-naming rule it is a sibling of, so the
248
+ * two places that need it — the repair for a package with no declarations, and the check for whether
249
+ * an acknowledgment is still true — cannot disagree.
250
+ *
251
+ * Computed rather than read out of TypeScript's own TS7016 message, which carries the same name in
252
+ * English prose. That prose is not contract and has been reworded across releases; a rule this short
253
+ * is cheaper to state than to parse.
254
+ *
255
+ * Whether the package actually exists on the registry is unknowable offline, and nothing in the
256
+ * compiler contacts one at check time — so a caller quoting this must say it as the convention it is.
257
+ */
258
+ export declare function definitelyTypedPackage(packageName: string): string;
130
259
  /** How a zone's policy answers one authored bare specifier. */
131
260
  export type BareImportAdmission =
132
261
  /** An `@impetik/xeer/*` subpath this zone admits. */
@@ -142,7 +271,7 @@ export type BareImportAdmission =
142
271
  /** A managed-family specifier this zone deliberately rejects. */
143
272
  | {
144
273
  kind: 'managed-rejected';
145
- reason: 'test-only' | 'metadata' | 'unknown-entrypoint';
274
+ reason: 'test-only' | 'metadata' | 'other-runtime' | 'unknown-entrypoint';
146
275
  }
147
276
  /** An application dependency, admitted subject to the declaration invariant. */
148
277
  | {
@@ -150,13 +279,14 @@ export type BareImportAdmission =
150
279
  }
151
280
  /**
152
281
  * Rejected on a zone rule rather than on the declaration invariant: a subpath of the platform
153
- * package this zone does not admit, a package family another zone owns, or a zone that admits no
154
- * application dependencies at all. Every one of these is *zone-exclusive* — the same specifier is
155
- * legal somewhere — which is why they are attribution evidence and Node builtins are not.
282
+ * package this zone does not admit, the provider-specific target of a facade the zone *does*
283
+ * admit, a package family another zone owns, or a zone that admits no application dependencies at
284
+ * all. Every one of these is *zone-exclusive* — the same specifier is legal somewhere — which is
285
+ * why they are attribution evidence and Node builtins are not.
156
286
  */
157
287
  | {
158
288
  kind: 'rejected';
159
- reason: 'platform-subpath' | 'foreign-family' | 'closed';
289
+ reason: 'platform-subpath' | 'provider-facade' | 'foreign-family' | 'closed';
160
290
  };
161
291
  /**
162
292
  * Classifies one bare specifier under a zone's policy. Node builtins and native addons are the
@@ -165,8 +295,28 @@ export type BareImportAdmission =
165
295
  * consumer keeps a private copy of the rules.
166
296
  */
167
297
  export declare function admitBareImport(policy: ZoneImportPolicy, specifier: string): BareImportAdmission;
298
+ /** The managed family that owns a bare package name in a zone, or null. */
299
+ export declare function managedPackageFamily(policy: ZoneImportPolicy, packageName: string): ManagedPackageFamily | null;
300
+ /**
301
+ * The foreign family that refuses a bare package name in a zone, or null.
302
+ *
303
+ * Managed ownership wins, and that precedence is the whole reason this is a function rather than a
304
+ * lookup each caller writes: under the React provider the foreign Preact family names `react`,
305
+ * `react-dom`, and `scheduler` among its own compat-alias territory, and those are precisely the
306
+ * packages the managed React family *is*. Asking managed-first is what lets the two descriptors stay
307
+ * complete statements about themselves instead of being trimmed to avoid each other.
308
+ */
309
+ export declare function foreignPackageFamily(policy: ZoneImportPolicy, packageName: string): ManagedPackageFamily | null;
310
+ /**
311
+ * The package whose installed root one classified entrypoint resolves from. Derived from the
312
+ * specifier rather than declared a second time, so a family cannot claim an entrypoint it does not
313
+ * anchor — which is what keeps `entrypoints` and `anchorPackages` from drifting apart.
314
+ */
315
+ export declare function entrypointAnchorPackage(family: ManagedPackageFamily, specifier: string): string;
168
316
  /**
169
317
  * The admitted managed-family surface of a zone, alias keys included — what bundling and the dev
170
318
  * server must pin to the anchor, and what documentation lists as the renderer surface.
171
319
  */
172
320
  export declare function managedImportSpecifiers(policy: ZoneImportPolicy): ReadonlyMap<string, string>;
321
+ /** Whether client application code may import an entrypoint with this classification. */
322
+ export declare function isImportableClassification(classification: RendererEntrypointClassification): boolean;