@geastack/compiler 1.0.32 → 1.0.34
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/README.md +1 -1
- package/dist/cli-coverage.js +2 -4
- package/dist/cli-emit.js +1 -1
- package/dist/cli-module-graph.js +1 -1
- package/dist/cli.js +2 -1
- package/dist/compiler.js +35 -28
- package/dist/conversion/array-view.js +9 -0
- package/dist/conversion/build.js +15 -8
- package/dist/conversion/dictionary-view.js +2 -2
- package/dist/conversion/nodes.d.ts +7 -0
- package/dist/conversion/nodes.js +58 -11
- package/dist/identity/ids.d.ts +4 -0
- package/dist/identity/ids.js +4 -0
- package/dist/ir/build.d.ts +4 -3
- package/dist/ir/build.js +14 -5
- package/dist/ir/call-dispatch.js +67 -7
- package/dist/ir/call-entry.js +1 -1
- package/dist/ir/callable-class-flow.d.ts +4 -0
- package/dist/ir/callable-class-flow.js +123 -1
- package/dist/ir/certify/parallel-region.js +698 -20
- package/dist/ir/certify.d.ts +3 -0
- package/dist/ir/certify.js +44 -9
- package/dist/ir/class-allocation-domain.js +2 -2
- package/dist/ir/class-construction-status.d.ts +10 -0
- package/dist/ir/class-construction-status.js +36 -0
- package/dist/ir/convert-carriers.d.ts +10 -1
- package/dist/ir/convert-carriers.js +18 -1
- package/dist/ir/dynamic-constructor-conversions.js +4 -2
- package/dist/ir/finite-iterator-close.d.ts +14 -0
- package/dist/ir/finite-iterator-close.js +50 -0
- package/dist/ir/host-template-conversions.js +9 -0
- package/dist/ir/lower-allocation.js +1 -1
- package/dist/ir/lower-flow.js +24 -3
- package/dist/ir/lower-operands.js +88 -7
- package/dist/ir/lower-protocol.js +1 -1
- package/dist/ir/lower.js +22 -6
- package/dist/ir/model.d.ts +41 -1
- package/dist/ir/native-accessor-definition.d.ts +3 -2
- package/dist/ir/native-accessor-definition.js +29 -10
- package/dist/ir/native-array-transport.js +2 -2
- package/dist/ir/native-field-view-domains.d.ts +23 -0
- package/dist/ir/native-field-view-domains.js +115 -9
- package/dist/ir/native-field-view-facts.d.ts +46 -2
- package/dist/ir/native-field-view-facts.js +159 -4
- package/dist/ir/native-iterable.d.ts +17 -0
- package/dist/ir/native-iterable.js +72 -0
- package/dist/ir/native-key-query.js +1 -1
- package/dist/ir/operation-conversions.js +15 -3
- package/dist/ir/program-conversions.js +2 -2
- package/dist/ir/publish-native-field-view-facts.js +9 -4
- package/dist/ir/pure-conversion-reuse.d.ts +58 -0
- package/dist/ir/pure-conversion-reuse.js +263 -0
- package/dist/ir/queries.js +1 -0
- package/dist/ir/reflection-demand.js +70 -18
- package/dist/ir/shake.js +2 -2
- package/dist/ir/unobserved-callable-inputs.d.ts +37 -0
- package/dist/ir/unobserved-callable-inputs.js +111 -0
- package/dist/native-signatures.d.ts +1 -1
- package/dist/native-signatures.js +27 -2
- package/dist/plugins/gea/component-classes.d.ts +2 -1
- package/dist/plugins/gea/component-classes.js +3 -3
- package/dist/plugins/gea/contract.d.ts +26 -3
- package/dist/plugins/gea/contract.js +42 -43
- package/dist/plugins/gea/host.d.ts +9 -0
- package/dist/plugins/gea/host.js +25 -4
- package/dist/plugins/gea/plugin.js +12 -6
- package/dist/plugins/gea/producer.d.ts +2 -2
- package/dist/plugins/gea/producer.js +2 -2
- package/dist/plugins/load.js +18 -1
- package/dist/plugins/model.d.ts +5 -0
- package/dist/plugins/native-iterable-providers.d.ts +18 -0
- package/dist/plugins/native-iterable-providers.js +51 -0
- package/dist/project-preparation.d.ts +8 -0
- package/dist/project-preparation.js +49 -7
- package/dist/projection/bindings.d.ts +13 -0
- package/dist/projection/bindings.js +20 -1
- package/dist/projection/classes.d.ts +4 -2
- package/dist/projection/classes.js +12 -5
- package/dist/representation/collections.js +2 -0
- package/dist/representation/derive.js +1 -0
- package/dist/representation/model.d.ts +2 -0
- package/dist/representation/model.js +1 -0
- package/dist/representation/policies.d.ts +2 -0
- package/dist/representation/primitive-domain.d.ts +1 -1
- package/dist/representation/primitive-domain.js +1 -1
- package/dist/representation/unassigned-binding-cells.d.ts +4 -3
- package/dist/representation/unassigned-binding-cells.js +19 -2
- package/dist/representation/union.js +6 -6
- package/dist/semantics/frontend.d.ts +2 -0
- package/dist/semantics/frontend.js +34 -5
- package/dist/semantics/host-methods.js +4 -1
- package/dist/semantics/jsx-runtime-provider.d.ts +5 -0
- package/dist/semantics/jsx-runtime-provider.js +16 -0
- package/dist/semantics/model/native-iterable.d.ts +14 -0
- package/dist/semantics/model/native-iterable.js +7 -0
- package/dist/semantics/model/operands.d.ts +30 -0
- package/dist/semantics/model/operations.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.d.ts +15 -0
- package/dist/semantics/model/primitive-domain.js +27 -4
- package/dist/semantics/module-resolution.js +13 -2
- package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
- package/dist/semantics/normalize/callback-parameter-contracts.d.ts +32 -4
- package/dist/semantics/normalize/callback-parameter-contracts.js +66 -6
- package/dist/semantics/normalize/census.d.ts +3 -0
- package/dist/semantics/normalize/census.js +17 -12
- package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +4 -1
- package/dist/semantics/normalize/deferred-intrinsic-protocols.js +29 -9
- package/dist/semantics/normalize/flow/callable-reach.js +94 -3
- package/dist/semantics/normalize/flow/component-solver.js +144 -55
- package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +9 -0
- package/dist/semantics/normalize/flow/member-call-forwarding.js +30 -4
- package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +2 -0
- package/dist/semantics/normalize/flow/proof-hypotheses.js +27 -0
- package/dist/semantics/normalize/flow/source-callable-own-data.js +87 -14
- package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +2 -0
- package/dist/semantics/normalize/flow/source-commonjs-exports.js +2 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +17 -0
- package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +125 -0
- package/dist/semantics/normalize/flow/source-native-origin.d.ts +6 -0
- package/dist/semantics/normalize/flow/source-native-origin.js +38 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +37 -0
- package/dist/semantics/normalize/flow/source-proxy-operation.js +201 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +20 -0
- package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +73 -0
- package/dist/semantics/normalize/flow/source-value-session.d.ts +50 -1
- package/dist/semantics/normalize/flow/source-value-session.js +596 -57
- package/dist/semantics/normalize/flow/value-flow.d.ts +17 -0
- package/dist/semantics/normalize/flow/value-flow.js +84 -0
- package/dist/semantics/normalize/fresh-dictionary-storage.js +2 -2
- package/dist/semantics/normalize/fresh-table-last-use.d.ts +52 -0
- package/dist/semantics/normalize/fresh-table-last-use.js +129 -0
- package/dist/semantics/normalize/gating.js +5 -1
- package/dist/semantics/normalize/global-host-mutations.js +190 -13
- package/dist/semantics/normalize/identities.js +20 -1
- package/dist/semantics/normalize/local-bindings.js +2 -2
- package/dist/semantics/normalize/parameter-bindings.js +10 -1
- package/dist/semantics/normalize/producer-context.d.ts +5 -0
- package/dist/semantics/normalize/producers/binding-kind.js +2 -0
- package/dist/semantics/normalize/producers/cited-value-type.d.ts +2 -2
- package/dist/semantics/normalize/producers/cited-value-type.js +2 -2
- package/dist/semantics/normalize/producers/class-lifecycle.js +39 -9
- package/dist/semantics/normalize/producers/computations.js +36 -5
- package/dist/semantics/normalize/producers/conditional-guard.d.ts +6 -0
- package/dist/semantics/normalize/producers/conditional-guard.js +5 -0
- package/dist/semantics/normalize/producers/control.js +7 -1
- package/dist/semantics/normalize/producers/destructuring.js +8 -9
- package/dist/semantics/normalize/producers/invocations.js +55 -2
- package/dist/semantics/normalize/producers/properties.d.ts +13 -0
- package/dist/semantics/normalize/producers/properties.js +21 -3
- package/dist/semantics/normalize/producers/references.js +8 -4
- package/dist/semantics/normalize/reachability.d.ts +15 -3
- package/dist/semantics/normalize/reachability.js +128 -20
- package/dist/semantics/normalize/return-bindings.js +3 -3
- package/dist/semantics/normalize/source-native-iterable.d.ts +19 -0
- package/dist/semantics/normalize/source-native-iterable.js +74 -0
- package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
- package/dist/semantics/normalize/structural-declarations.js +1 -1
- package/dist/semantics/normalize/structural-indexed-access.js +9 -0
- package/dist/semantics/normalize/structural.js +11 -0
- package/dist/semantics/normalize/unshared-array-result.d.ts +42 -0
- package/dist/semantics/normalize/unshared-array-result.js +269 -0
- package/dist/semantics/package-sources.js +3 -2
- package/dist/semantics/program.d.ts +8 -0
- package/dist/semantics/program.js +55 -0
- package/dist/semantics/source-transform-exports.d.ts +8 -0
- package/dist/semantics/source-transform-exports.js +145 -0
- package/dist/semantics/source-transform-protocol.d.ts +22 -0
- package/dist/semantics/this-constructor-source-transform.js +19 -1
- package/dist/targets/cpp/class-layout.d.ts +2 -0
- package/dist/targets/cpp/class-layout.js +35 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +11 -1
- package/dist/targets/cpp/class-properties/emit-class-properties.js +33 -4
- package/dist/targets/cpp/conversions.js +6 -3
- package/dist/targets/cpp/emit-callable.js +73 -7
- package/dist/targets/cpp/emit-context.d.ts +23 -9
- package/dist/targets/cpp/emit-context.js +19 -8
- package/dist/targets/cpp/emit-equality.js +41 -1
- package/dist/targets/cpp/emit-exceptions.js +29 -11
- package/dist/targets/cpp/emit-iterator-object-view.js +2 -2
- package/dist/targets/cpp/emit-iterator.js +33 -9
- package/dist/targets/cpp/emit-live-field-view.js +6 -1
- package/dist/targets/cpp/emit-narrowing.d.ts +11 -3
- package/dist/targets/cpp/emit-narrowing.js +58 -18
- package/dist/targets/cpp/emit-native-field-view.d.ts +3 -1
- package/dist/targets/cpp/emit-native-field-view.js +84 -8
- package/dist/targets/cpp/emit-properties.d.ts +1 -0
- package/dist/targets/cpp/emit-properties.js +26 -7
- package/dist/targets/cpp/emit-protocol-iterator.js +5 -2
- package/dist/targets/cpp/emit-record-view.js +14 -2
- package/dist/targets/cpp/emit-tostring.js +23 -1
- package/dist/targets/cpp/emit-union-properties.js +1 -1
- package/dist/targets/cpp/emit.d.ts +1 -1
- package/dist/targets/cpp/emit.js +132 -21
- package/dist/targets/cpp/host/emit-host-invoke.js +2 -2
- package/dist/targets/cpp/host/emit-host-object.js +28 -2
- package/dist/targets/cpp/host/emit-host-properties.js +9 -1
- package/dist/targets/cpp/host/emit-host-value.d.ts +1 -1
- package/dist/targets/cpp/host/emit-host-value.js +8 -6
- package/dist/targets/cpp/host/host-members.js +2 -1
- package/dist/targets/cpp/prototype/emit-prototype-array.js +69 -5
- package/dist/targets/cpp/prototype/emit-prototype-invoke.js +9 -9
- package/dist/targets/cpp/prototype/emit-prototype-iterator.js +2 -2
- package/dist/targets/cpp/prototype/emit-prototype-promise.js +7 -7
- package/dist/targets/cpp/records.d.ts +1 -0
- package/dist/targets/cpp/records.js +16 -7
- package/dist/targets/cpp/translation-unit.js +30 -16
- package/package.json +8 -7
- package/src/targets/cpp/runtime/gea_dynamic_proxy.h +42 -3
- package/src/targets/cpp/runtime/gea_eval.h +3 -0
- package/src/targets/cpp/runtime/gea_runtime.h +2407 -684
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
3
5
|
const integerTypes = [
|
|
4
6
|
'char',
|
|
5
7
|
'signed char',
|
|
@@ -284,8 +286,31 @@ ${identityProbeTemplates}enum Identities { ${marks.join(',\n')} };
|
|
|
284
286
|
}
|
|
285
287
|
return { verdicts, probe: identityProbe, ast: inspected.stdout };
|
|
286
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* `clang++` from PATH. The Windows LLVM installer does not put itself on PATH
|
|
291
|
+
* by default, so there LLVM_ROOT and then the standard install location are
|
|
292
|
+
* tried too. Not CXX: inside an ESP-IDF build that is the cross g++, which has
|
|
293
|
+
* no -Xclang AST dump.
|
|
294
|
+
*/
|
|
295
|
+
function defaultClang() {
|
|
296
|
+
if (process.platform !== 'win32')
|
|
297
|
+
return 'clang++';
|
|
298
|
+
const fromRoot = process.env.LLVM_ROOT ? join(process.env.LLVM_ROOT, 'bin', 'clang++.exe') : undefined;
|
|
299
|
+
if (fromRoot && existsSync(fromRoot))
|
|
300
|
+
return fromRoot;
|
|
301
|
+
if (spawnSync('clang++', ['--version'], { stdio: 'ignore' }).error) {
|
|
302
|
+
const installed = join(process.env.ProgramFiles ?? 'C:\\Program Files', 'LLVM', 'bin', 'clang++.exe');
|
|
303
|
+
if (existsSync(installed))
|
|
304
|
+
return installed;
|
|
305
|
+
}
|
|
306
|
+
return 'clang++';
|
|
307
|
+
}
|
|
287
308
|
/** Native facts come from Clang's resolved type graph; callers authenticate their declaration-to-host binding separately. */
|
|
288
|
-
export function inspectNativeFunctionSignature(
|
|
309
|
+
export function inspectNativeFunctionSignature(requested) {
|
|
310
|
+
// A Windows header path arrives as Node spells it, `C:\x\a.h`. An include
|
|
311
|
+
// spelling never carries a backslash (it would escape the closing quote), and
|
|
312
|
+
// clang takes the same path with forward slashes, so that is how it is spelled.
|
|
313
|
+
const input = process.platform === 'win32' ? { ...requested, headers: requested.headers.map((header) => header.split('\\').join('/')) } : requested;
|
|
289
314
|
if (!/^(?:::)?[A-Za-z_]\w*(?:::[A-Za-z_]\w*)*$/.test(input.cppFunction))
|
|
290
315
|
throw new Error('Native function must be a qualified C++ identifier');
|
|
291
316
|
if (!input.headers.length || input.headers.some((header) => /[\r\n"\\]/.test(header)))
|
|
@@ -300,7 +325,7 @@ using Function = decltype(&${input.cppFunction});
|
|
|
300
325
|
enum Bounds { ${widths.join(',\n')} };
|
|
301
326
|
}
|
|
302
327
|
`;
|
|
303
|
-
const compiler = input.compiler ??
|
|
328
|
+
const compiler = input.compiler ?? defaultClang();
|
|
304
329
|
const args = [
|
|
305
330
|
'-std=c++17',
|
|
306
331
|
...(input.compilerArguments ?? []),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeclarationId } from '../../identity/ids.js';
|
|
2
2
|
import type { FamilyProducer } from '../../semantics/normalize/contribution.js';
|
|
3
3
|
import type { ProducerContext } from '../../semantics/normalize/producer-context.js';
|
|
4
|
+
import { type GeaProviderAuthority } from './contract.js';
|
|
4
5
|
/**
|
|
5
6
|
* Every own field of every class that extends one of gea's reactive bases,
|
|
6
7
|
* keyed by the class.
|
|
@@ -22,4 +23,4 @@ import type { ProducerContext } from '../../semantics/normalize/producer-context
|
|
|
22
23
|
* storage, and therefore the only class whose struct may cell it.
|
|
23
24
|
*/
|
|
24
25
|
export type GeaReactiveFields = Map<DeclarationId, Set<string>>;
|
|
25
|
-
export declare const createGeaComponentClassProducer: (context: ProducerContext, componentClasses: Set<DeclarationId>, reactiveFields: GeaReactiveFields) => FamilyProducer;
|
|
26
|
+
export declare const createGeaComponentClassProducer: (context: ProducerContext, componentClasses: Set<DeclarationId>, reactiveFields: GeaReactiveFields, rawAuthority?: GeaProviderAuthority) => FamilyProducer;
|
|
@@ -93,7 +93,7 @@ const mountedElementField = (context, candidate, classDeclaration, reference, in
|
|
|
93
93
|
placement: 'own'
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
|
-
export const createGeaComponentClassProducer = (context, componentClasses, reactiveFields) => {
|
|
96
|
+
export const createGeaComponentClassProducer = (context, componentClasses, reactiveFields, rawAuthority) => {
|
|
97
97
|
const core = createClassLifecycleProducer(context);
|
|
98
98
|
return {
|
|
99
99
|
family: core.family,
|
|
@@ -117,7 +117,7 @@ export const createGeaComponentClassProducer = (context, componentClasses, react
|
|
|
117
117
|
for (const operation of contribution.operations) {
|
|
118
118
|
if (operation.family !== 'class-lifecycle' || operation.event !== 'define-field')
|
|
119
119
|
continue;
|
|
120
|
-
if (!enclosingClassDerives(context, node, derivesFromGeaReactiveBase))
|
|
120
|
+
if (!enclosingClassDerives(context, node, (checker, instance) => derivesFromGeaReactiveBase(checker, instance, rawAuthority)))
|
|
121
121
|
continue;
|
|
122
122
|
const owned = reactiveFields.get(operation.classDeclaration) ?? new Set();
|
|
123
123
|
owned.add(key);
|
|
@@ -149,7 +149,7 @@ export const createGeaComponentClassProducer = (context, componentClasses, react
|
|
|
149
149
|
continue;
|
|
150
150
|
const symbol = context.checker.getSymbolAtLocation(classNode.name);
|
|
151
151
|
const instance = symbol && context.checker.getDeclaredTypeOfSymbol(symbol);
|
|
152
|
-
if (instance && derivesFromGeaComponent(context.checker, instance)) {
|
|
152
|
+
if (instance && derivesFromGeaComponent(context.checker, instance, rawAuthority)) {
|
|
153
153
|
componentClasses.add(operation.classDeclaration);
|
|
154
154
|
const mounted = mountedElementField(context, candidate, operation.classDeclaration, classNode.name, instance);
|
|
155
155
|
if (mounted)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
+
import type { ProducerContext } from '../../semantics/normalize/producer-context.js';
|
|
2
3
|
/**
|
|
3
4
|
* What gea says a JSX element means.
|
|
4
5
|
*
|
|
@@ -128,8 +129,30 @@ export interface GeaElementFacts {
|
|
|
128
129
|
*/
|
|
129
130
|
readonly renderMember: string | null;
|
|
130
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Whether this class is one of gea's, decided by symbol identity.
|
|
134
|
+
*
|
|
135
|
+
* The base may be reached through intermediates the program wrote -- `class
|
|
136
|
+
* View extends Component`, then `class Home extends View` -- so the whole chain
|
|
137
|
+
* is walked. What is compared is the *symbol* the library exported, resolved
|
|
138
|
+
* from the scope the class was declared in: a class extending gea's base must
|
|
139
|
+
* have imported it there, and comparing the resolved symbol rather than the
|
|
140
|
+
* spelling means a program that renames the import on the way in
|
|
141
|
+
* (`import { Component as Base }`) is recognized, while a program that declares
|
|
142
|
+
* its own unrelated `Component` is not.
|
|
143
|
+
* @semanticCategory framework-protocol
|
|
144
|
+
*/
|
|
145
|
+
export interface GeaProviderAuthority {
|
|
146
|
+
readonly nativeDeclarationFileName: string;
|
|
147
|
+
readonly modulesOf: (containingFile: string) => readonly ts.SourceFile[];
|
|
148
|
+
}
|
|
149
|
+
/** The frontend, not package spelling or a class name, selects the Gea provider.
|
|
150
|
+
* This is the Gea class protocol witness, not generic source identity admission.
|
|
151
|
+
* @semanticCategory framework-protocol
|
|
152
|
+
*/
|
|
153
|
+
export declare const createGeaProviderAuthority: (context: Pick<ProducerContext, "runtimeModuleTargetOf" | "sourceFileOf" | "jsxRuntimeModuleOf">, nativeDeclarationFileName: string) => GeaProviderAuthority;
|
|
131
154
|
/** Whether this class is one of gea's components -- `derivesFromGeaBase` asked about gea's component base. */
|
|
132
|
-
export declare const derivesFromGeaComponent: (checker: ts.TypeChecker, instance: ts.Type) => boolean;
|
|
155
|
+
export declare const derivesFromGeaComponent: (checker: ts.TypeChecker, instance: ts.Type, authority?: GeaProviderAuthority) => boolean;
|
|
133
156
|
/**
|
|
134
157
|
* Whether this class holds reactive state -- the same walk, asked about either
|
|
135
158
|
* reactive base.
|
|
@@ -139,7 +162,7 @@ export declare const derivesFromGeaComponent: (checker: ts.TypeChecker, instance
|
|
|
139
162
|
* both. Asking twice is what keeps a `Store` recognised in a program that never
|
|
140
163
|
* imports `ReactiveComponent` at all, and vice versa.
|
|
141
164
|
*/
|
|
142
|
-
export declare const derivesFromGeaReactiveBase: (checker: ts.TypeChecker, instance: ts.Type) => boolean;
|
|
165
|
+
export declare const derivesFromGeaReactiveBase: (checker: ts.TypeChecker, instance: ts.Type, authority?: GeaProviderAuthority) => boolean;
|
|
143
166
|
/**
|
|
144
167
|
* What this element's tag resolves to, or `null` when it resolves neither.
|
|
145
168
|
*
|
|
@@ -147,4 +170,4 @@ export declare const derivesFromGeaReactiveBase: (checker: ts.TypeChecker, insta
|
|
|
147
170
|
* JSX before it is called, and a type carrying both is a class expression whose
|
|
148
171
|
* call half JSX never selects.
|
|
149
172
|
*/
|
|
150
|
-
export declare const elementFactsOf: (checker: ts.TypeChecker, tagName: ts.JsxTagNameExpression) => GeaElementFacts | null;
|
|
173
|
+
export declare const elementFactsOf: (checker: ts.TypeChecker, tagName: ts.JsxTagNameExpression, authority?: GeaProviderAuthority) => GeaElementFacts | null;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { geaCoreDeclarationFileName } from './host.js';
|
|
2
4
|
import { declaredBaseTypesOf } from '../../semantics/ambient.js';
|
|
3
5
|
/**
|
|
4
6
|
* What gea says a JSX element means.
|
|
@@ -113,59 +115,56 @@ export const geaReconcilerAttributeName = 'key';
|
|
|
113
115
|
* name it refuses.
|
|
114
116
|
*/
|
|
115
117
|
export const geaRefAttributeName = 'ref';
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* The base may be reached through intermediates the program wrote -- `class
|
|
120
|
-
* View extends Component`, then `class Home extends View` -- so the whole chain
|
|
121
|
-
* is walked. What is compared is the *symbol* the library exported, resolved
|
|
122
|
-
* from the scope the class was declared in: a class extending gea's base must
|
|
123
|
-
* have imported it there, and comparing the resolved symbol rather than the
|
|
124
|
-
* spelling means a program that renames the import on the way in
|
|
125
|
-
* (`import { Component as Base }`) is recognized, while a program that declares
|
|
126
|
-
* its own unrelated `Component` is not.
|
|
118
|
+
/** The frontend, not package spelling or a class name, selects the Gea provider.
|
|
119
|
+
* This is the Gea class protocol witness, not generic source identity admission.
|
|
120
|
+
* @semanticCategory framework-protocol
|
|
127
121
|
*/
|
|
128
|
-
const
|
|
122
|
+
export const createGeaProviderAuthority = (context, nativeDeclarationFileName) => ({
|
|
123
|
+
nativeDeclarationFileName,
|
|
124
|
+
modulesOf: (containingFile) => {
|
|
125
|
+
const selected = new Set();
|
|
126
|
+
const raw = context.runtimeModuleTargetOf('@geastack/core', containingFile, 'import');
|
|
127
|
+
const implementation = raw === null ? null : context.sourceFileOf(raw);
|
|
128
|
+
if (implementation !== null)
|
|
129
|
+
selected.add(implementation);
|
|
130
|
+
const jsx = context.jsxRuntimeModuleOf?.(containingFile);
|
|
131
|
+
if (jsx)
|
|
132
|
+
selected.add(jsx);
|
|
133
|
+
return [...selected];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
const nativeProviderOnly = () => ({ nativeDeclarationFileName: geaCoreDeclarationFileName(), modulesOf: () => [] });
|
|
137
|
+
const derivesFromGeaBase = (checker, instance, baseName, authority) => {
|
|
129
138
|
const chain = declaredBaseTypesOf(checker, instance);
|
|
130
139
|
const targetOf = (symbol) => (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol) : symbol;
|
|
131
|
-
// The base is resolved from every scope in the chain, not only the leaf's.
|
|
132
|
-
//
|
|
133
|
-
// Resolving it once, where the *derived* class is declared, silently assumed
|
|
134
|
-
// that a gea component names gea's base in its own file. That holds for
|
|
135
|
-
// `class App extends Component`, and fails for every class that reaches the
|
|
136
|
-
// base through another one: the library exports `ReactiveComponent extends
|
|
137
|
-
// Component`, and an app writing `import { ReactiveComponent }` never has
|
|
138
|
-
// `Component` in scope at all -- so the lookup returned nothing and the whole
|
|
139
|
-
// claim was abandoned before the chain that plainly contains gea's base was
|
|
140
|
-
// ever compared. The class went unclaimed, and the element refused to lower.
|
|
141
|
-
//
|
|
142
|
-
// Each link's own declaration site is a scope where the name it extends *is*
|
|
143
|
-
// visible, which is what makes walking them the right question rather than a
|
|
144
|
-
// wider one: this still compares the resolved *symbol* the library exported,
|
|
145
|
-
// never the spelling, so a renamed import is recognized and an unrelated
|
|
146
|
-
// class merely spelled `Component` in some other file is not. What it does
|
|
147
|
-
// not distinguish -- and did not before either -- is a program that declares
|
|
148
|
-
// its own `Component` and genuinely extends it; such a class has gea's
|
|
149
|
-
// linkage name as its real base, and telling the two apart needs a module
|
|
150
|
-
// identity this library does not state anywhere.
|
|
151
140
|
const bases = new Set();
|
|
141
|
+
const providers = new Set();
|
|
152
142
|
for (const type of [instance, ...chain]) {
|
|
153
|
-
const declaration
|
|
154
|
-
|
|
143
|
+
for (const declaration of type.getSymbol()?.declarations ?? []) {
|
|
144
|
+
const file = declaration.getSourceFile();
|
|
145
|
+
for (const provider of authority.modulesOf(file.fileName))
|
|
146
|
+
providers.add(provider);
|
|
147
|
+
// A native-only module has no executable runtime target. Its installed
|
|
148
|
+
// host declaration remains an exact owned witness, never ambient names.
|
|
149
|
+
if (file.isDeclarationFile && resolve(file.fileName) === resolve(authority.nativeDeclarationFileName))
|
|
150
|
+
providers.add(file);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
for (const provider of providers) {
|
|
154
|
+
const module = checker.getSymbolAtLocation(provider);
|
|
155
|
+
if (module === undefined)
|
|
155
156
|
continue;
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
bases.add(targetOf(
|
|
157
|
+
const exported = checker.getExportsOfModule(module).find((symbol) => symbol.getName() === baseName);
|
|
158
|
+
if (exported !== undefined)
|
|
159
|
+
bases.add(targetOf(exported));
|
|
159
160
|
}
|
|
160
|
-
if (bases.size === 0)
|
|
161
|
-
return false;
|
|
162
161
|
return chain.some((candidate) => {
|
|
163
162
|
const symbol = candidate.getSymbol();
|
|
164
163
|
return symbol !== undefined && bases.has(targetOf(symbol));
|
|
165
164
|
});
|
|
166
165
|
};
|
|
167
166
|
/** Whether this class is one of gea's components -- `derivesFromGeaBase` asked about gea's component base. */
|
|
168
|
-
export const derivesFromGeaComponent = (checker, instance) => derivesFromGeaBase(checker, instance, geaComponentBaseName);
|
|
167
|
+
export const derivesFromGeaComponent = (checker, instance, authority = nativeProviderOnly()) => derivesFromGeaBase(checker, instance, geaComponentBaseName, authority);
|
|
169
168
|
/**
|
|
170
169
|
* Whether this class holds reactive state -- the same walk, asked about either
|
|
171
170
|
* reactive base.
|
|
@@ -175,7 +174,7 @@ export const derivesFromGeaComponent = (checker, instance) => derivesFromGeaBase
|
|
|
175
174
|
* both. Asking twice is what keeps a `Store` recognised in a program that never
|
|
176
175
|
* imports `ReactiveComponent` at all, and vice versa.
|
|
177
176
|
*/
|
|
178
|
-
export const derivesFromGeaReactiveBase = (checker, instance) => geaReactiveBaseNames.some((baseName) => derivesFromGeaBase(checker, instance, baseName));
|
|
177
|
+
export const derivesFromGeaReactiveBase = (checker, instance, authority = nativeProviderOnly()) => geaReactiveBaseNames.some((baseName) => derivesFromGeaBase(checker, instance, baseName, authority));
|
|
179
178
|
/**
|
|
180
179
|
* What this element's tag resolves to, or `null` when it resolves neither.
|
|
181
180
|
*
|
|
@@ -183,12 +182,12 @@ export const derivesFromGeaReactiveBase = (checker, instance) => geaReactiveBase
|
|
|
183
182
|
* JSX before it is called, and a type carrying both is a class expression whose
|
|
184
183
|
* call half JSX never selects.
|
|
185
184
|
*/
|
|
186
|
-
export const elementFactsOf = (checker, tagName) => {
|
|
185
|
+
export const elementFactsOf = (checker, tagName, authority = nativeProviderOnly()) => {
|
|
187
186
|
const type = checker.getTypeAtLocation(tagName);
|
|
188
187
|
const constructs = type.getConstructSignatures();
|
|
189
188
|
if (constructs.length > 0) {
|
|
190
189
|
const instance = constructs[0]?.getReturnType();
|
|
191
|
-
const claimed = instance !== undefined && derivesFromGeaComponent(checker, instance);
|
|
190
|
+
const claimed = instance !== undefined && derivesFromGeaComponent(checker, instance, authority);
|
|
192
191
|
return { invocation: 'construct', renderMember: claimed ? geaRenderMemberName : null };
|
|
193
192
|
}
|
|
194
193
|
return type.getCallSignatures().length > 0 ? { invocation: 'call', renderMember: null } : null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NativeIterableProvider } from '../native-iterable-providers.js';
|
|
1
2
|
import type { CommonJsWrapperDeclaration, NativeHostFunctionDeclaration, PluginOptions } from '../model.js';
|
|
2
3
|
import type { HostCallSpelling, HostConstructorTable, HostMemberTable } from '../../targets/cpp/host/host-members.js';
|
|
3
4
|
/**
|
|
@@ -29,6 +30,8 @@ export interface GeaMemberBinding {
|
|
|
29
30
|
interface GeaHostShimSlice {
|
|
30
31
|
readonly commonJsGlobals?: Readonly<Record<string, CommonJsWrapperDeclaration>>;
|
|
31
32
|
readonly nativeTypes: Readonly<Record<string, string>>;
|
|
33
|
+
readonly nativeReferenceIdentities?: readonly string[];
|
|
34
|
+
readonly nativeIterableProviders?: Readonly<Record<string, NativeIterableProvider>>;
|
|
32
35
|
readonly nativeViews?: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
33
36
|
/**
|
|
34
37
|
* `new <AmbientConstructor>(...)` spellings, keyed by the ambient
|
|
@@ -311,6 +314,8 @@ export declare const geaHostNamespaceProperties: () => ReadonlyMap<string, strin
|
|
|
311
314
|
export declare const geaHostNamespacePropertySetters: () => ReadonlyMap<string, string>;
|
|
312
315
|
/** The host's free functions, by the name the program writes. */
|
|
313
316
|
export declare const geaHostFunctions: () => ReadonlyMap<string, string>;
|
|
317
|
+
/** The declaration authority already selected for this host's native signatures. */
|
|
318
|
+
export declare const geaCoreDeclarationFileName: (options?: PluginOptions) => string;
|
|
314
319
|
export declare const geaNativeFunctionDeclarations: (options: PluginOptions) => readonly NativeHostFunctionDeclaration[];
|
|
315
320
|
/**
|
|
316
321
|
* `new <AmbientConstructor>(...)` spellings, transposed from the package's own
|
|
@@ -531,4 +536,8 @@ export declare const geaElementFragment: () => string | null;
|
|
|
531
536
|
* engine's own `Document::createElement` does before it dispatches.
|
|
532
537
|
*/
|
|
533
538
|
export declare const geaElementTextLeafTags: () => readonly string[];
|
|
539
|
+
/** Identity is declared by the native package, never guessed from handle spelling. */
|
|
540
|
+
export declare const geaNativeReferenceIdentities: () => ReadonlySet<string>;
|
|
541
|
+
/** Provider metadata is installed by the owning host package, never inferred from a collection name. */
|
|
542
|
+
export declare const geaNativeIterableProviders: () => ReadonlyMap<string, NativeIterableProvider>;
|
|
534
543
|
export {};
|
package/dist/plugins/gea/host.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readNativeIterableProviders } from '../native-iterable-providers.js';
|
|
1
2
|
import { createHostPackageLoader } from '../host-package.js';
|
|
2
3
|
import { dirname, resolve } from 'node:path';
|
|
3
4
|
import { templateArity } from '../../targets/cpp/host/host-members.js';
|
|
@@ -337,13 +338,15 @@ export const geaHostNamespaceProperties = () => {
|
|
|
337
338
|
export const geaHostNamespacePropertySetters = () => nestedTable(geaShims()?.hostNamespacePropertySetters);
|
|
338
339
|
/** The host's free functions, by the name the program writes. */
|
|
339
340
|
export const geaHostFunctions = () => flatTable(geaShims()?.embeddedHostFunctions);
|
|
341
|
+
/** The declaration authority already selected for this host's native signatures. */
|
|
342
|
+
export const geaCoreDeclarationFileName = (options) => resolve(options?.get('gea.native-signature-core-root') ??
|
|
343
|
+
process.env.GEA_CORE_DIR ??
|
|
344
|
+
dirname(packageLoader.resolve('@geastack/core/package.json')), 'index.d.ts');
|
|
340
345
|
export const geaNativeFunctionDeclarations = (options) => {
|
|
341
346
|
const sources = geaShims()?.nativeFunctionSignatureSources ?? {};
|
|
342
347
|
if (Object.keys(sources).length === 0)
|
|
343
348
|
return [];
|
|
344
|
-
const coreRoot = options
|
|
345
|
-
process.env.GEA_CORE_DIR ??
|
|
346
|
-
dirname(packageLoader.resolve('@geastack/core/package.json'));
|
|
349
|
+
const coreRoot = dirname(geaCoreDeclarationFileName(options));
|
|
347
350
|
const functions = geaHostFunctions();
|
|
348
351
|
return Object.entries(sources).map(([name, source]) => {
|
|
349
352
|
const cppFunction = functions.get(name);
|
|
@@ -359,7 +362,8 @@ export const geaNativeFunctionDeclarations = (options) => {
|
|
|
359
362
|
declarationName: name,
|
|
360
363
|
inspection: {
|
|
361
364
|
cppFunction,
|
|
362
|
-
|
|
365
|
+
// `#include "..."` spelling: Windows separators would read as escapes.
|
|
366
|
+
headers: [resolve(packageRoot, source.header).replaceAll('\\', '/')],
|
|
363
367
|
...(options.get('gea.native-signature-compiler') ? { compiler: options.get('gea.native-signature-compiler') } : {})
|
|
364
368
|
}
|
|
365
369
|
};
|
|
@@ -825,3 +829,20 @@ export const geaElementTextLeafTags = () => {
|
|
|
825
829
|
}
|
|
826
830
|
return [...tags];
|
|
827
831
|
};
|
|
832
|
+
/** Identity is declared by the native package, never guessed from handle spelling. */
|
|
833
|
+
export const geaNativeReferenceIdentities = () => {
|
|
834
|
+
const values = geaShims()?.nativeReferenceIdentities;
|
|
835
|
+
if (values === undefined)
|
|
836
|
+
return new Set();
|
|
837
|
+
if (!Array.isArray(values) || !values.every((value) => typeof value === 'string' && value.length > 0)) {
|
|
838
|
+
throw new Error('gea nativeReferenceIdentities must be a string array');
|
|
839
|
+
}
|
|
840
|
+
return new Set(values);
|
|
841
|
+
};
|
|
842
|
+
/** Provider metadata is installed by the owning host package, never inferred from a collection name. */
|
|
843
|
+
export const geaNativeIterableProviders = () => {
|
|
844
|
+
const values = geaShims()?.nativeIterableProviders;
|
|
845
|
+
if (values === undefined)
|
|
846
|
+
return new Map();
|
|
847
|
+
return readNativeIterableProviders(new Map(Object.entries(values)));
|
|
848
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { geaAfterRenderMemberName, geaRenderBridgeMemberName, geaRenderMemberName } from './contract.js';
|
|
1
|
+
import { createGeaProviderAuthority, geaAfterRenderMemberName, geaRenderBridgeMemberName, geaRenderMemberName } from './contract.js';
|
|
2
2
|
import { createGeaComponentClassProducer } from './component-classes.js';
|
|
3
3
|
import { geaHostConstructors } from './constructors.js';
|
|
4
|
-
import { geaCommonJsGlobals, geaElementFragment, geaElementTextLeafTags, geaHostConstants, geaHostFunctions, geaNativeFunctionDeclarations, geaHostNamespaceMethods, geaHostNamespaceProperties, geaHostNamespacePropertySetters, geaHostNamespaceRoots, geaHostNamespaceRootTypes, geaHostPreambles, geaNativeProtocols, geaNativeViews, geaHostSingletons, geaEmbeddedIncludeGuard, geaProtocolCarriers } from './host.js';
|
|
4
|
+
import { geaCommonJsGlobals, geaCoreDeclarationFileName, geaElementFragment, geaElementTextLeafTags, geaHostConstants, geaHostFunctions, geaNativeFunctionDeclarations, geaHostNamespaceMethods, geaHostNamespaceProperties, geaHostNamespacePropertySetters, geaHostNamespaceRoots, geaHostNamespaceRootTypes, geaHostPreambles, geaNativeProtocols, geaNativeViews, geaHostSingletons, geaEmbeddedIncludeGuard, geaProtocolCarriers, geaNativeReferenceIdentities, geaNativeIterableProviders } from './host.js';
|
|
5
5
|
import { geaHostMemberVoidResults, geaHostMembers } from './members.js';
|
|
6
6
|
import { lowerGeaElement } from './lower.js';
|
|
7
7
|
import { createGeaSlotHook } from './slots.js';
|
|
@@ -34,14 +34,18 @@ import { geaReactiveSlotTransform } from './reactive-slots.js';
|
|
|
34
34
|
export const geaPlugin = {
|
|
35
35
|
name: 'gea',
|
|
36
36
|
instantiate: (options) => {
|
|
37
|
+
const rawDeclarationFileName = geaCoreDeclarationFileName(options);
|
|
37
38
|
const facts = new Map();
|
|
38
39
|
const componentClasses = new Set();
|
|
39
40
|
const reactiveFields = new Map();
|
|
40
41
|
return {
|
|
41
|
-
producers: (context) =>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
producers: (context) => {
|
|
43
|
+
const rawAuthority = createGeaProviderAuthority(context, rawDeclarationFileName);
|
|
44
|
+
return [
|
|
45
|
+
createGeaElementProducer(context, facts, rawAuthority),
|
|
46
|
+
createGeaComponentClassProducer(context, componentClasses, reactiveFields, rawAuthority)
|
|
47
|
+
];
|
|
48
|
+
},
|
|
45
49
|
// Two rewrites, in this order, and the order is the point.
|
|
46
50
|
//
|
|
47
51
|
// A component invocation whose props only ever write PROPERTIES becomes
|
|
@@ -91,6 +95,8 @@ export const geaPlugin = {
|
|
|
91
95
|
// declares), so its row is read off the package's own `Element`
|
|
92
96
|
// spelling -- see `geaProtocolCarriers`.
|
|
93
97
|
nativeTypes: geaProtocolCarriers(),
|
|
98
|
+
nativeReferenceIdentities: geaNativeReferenceIdentities(),
|
|
99
|
+
nativeIterableProviders: geaNativeIterableProviders(),
|
|
94
100
|
// gea's own host types are, like Apple's, ambient declarations with
|
|
95
101
|
// no OTHER, structurally-unrelated ambient name standing in for them
|
|
96
102
|
// -- see `plugins/model.ts`'s `ambientTypeRealizations` and
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OperationId } from '../../identity/ids.js';
|
|
2
2
|
import type { FamilyProducer } from '../../semantics/normalize/contribution.js';
|
|
3
3
|
import type { ProducerContext } from '../../semantics/normalize/producer-context.js';
|
|
4
|
-
import { type GeaElementFacts } from './contract.js';
|
|
5
|
-
export declare const createGeaElementProducer: (context: ProducerContext, facts: Map<OperationId, GeaElementFacts
|
|
4
|
+
import { type GeaElementFacts, type GeaProviderAuthority } from './contract.js';
|
|
5
|
+
export declare const createGeaElementProducer: (context: ProducerContext, facts: Map<OperationId, GeaElementFacts>, rawAuthority?: GeaProviderAuthority) => FamilyProducer;
|
|
@@ -28,7 +28,7 @@ const tagNameOf = (node) => {
|
|
|
28
28
|
return node.tagName;
|
|
29
29
|
return null;
|
|
30
30
|
};
|
|
31
|
-
export const createGeaElementProducer = (context, facts) => {
|
|
31
|
+
export const createGeaElementProducer = (context, facts, rawAuthority) => {
|
|
32
32
|
const core = createElementProducer(context);
|
|
33
33
|
return {
|
|
34
34
|
family: core.family,
|
|
@@ -42,7 +42,7 @@ export const createGeaElementProducer = (context, facts) => {
|
|
|
42
42
|
for (const operation of contribution.operations) {
|
|
43
43
|
if (operation.family !== 'element' || operation.form !== 'value')
|
|
44
44
|
continue;
|
|
45
|
-
const resolved = elementFactsOf(context.checker, tagName);
|
|
45
|
+
const resolved = elementFactsOf(context.checker, tagName, rawAuthority);
|
|
46
46
|
if (resolved)
|
|
47
47
|
facts.set(operation.id, resolved);
|
|
48
48
|
}
|
package/dist/plugins/load.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readNativeIterableProviders } from './native-iterable-providers.js';
|
|
1
2
|
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
2
3
|
import { createRequire } from 'node:module';
|
|
3
4
|
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
@@ -86,6 +87,8 @@ const optionalCapabilities = new Set([
|
|
|
86
87
|
'commonJsBuiltinModules',
|
|
87
88
|
'commonJsBuiltinModuleSources',
|
|
88
89
|
'nativeTypesByDeclaration',
|
|
90
|
+
'nativeReferenceIdentities',
|
|
91
|
+
'nativeIterableProviders',
|
|
89
92
|
'hostSingletonDeclarations',
|
|
90
93
|
'hostInvocations',
|
|
91
94
|
'hostInstanceTests',
|
|
@@ -132,7 +135,13 @@ const validateInstance = (value) => {
|
|
|
132
135
|
if (capabilities[key] !== undefined)
|
|
133
136
|
checkShape(capabilities[key], new Map(), `capabilities.${key}`);
|
|
134
137
|
}
|
|
135
|
-
for (const key of [
|
|
138
|
+
for (const key of [
|
|
139
|
+
'declarationModules',
|
|
140
|
+
'hostArraySnapshotFunctions',
|
|
141
|
+
'hostNativeArrayFunctions',
|
|
142
|
+
'parallelRegionEntries',
|
|
143
|
+
'nativeReferenceIdentities'
|
|
144
|
+
]) {
|
|
136
145
|
if (capabilities[key] !== undefined)
|
|
137
146
|
checkShape(capabilities[key], new Set(), `capabilities.${key}`);
|
|
138
147
|
}
|
|
@@ -142,6 +151,14 @@ const validateInstance = (value) => {
|
|
|
142
151
|
throw new Error(`invalid PluginInstance: capabilities.${key} must map strings to strings`);
|
|
143
152
|
}
|
|
144
153
|
}
|
|
154
|
+
if (capabilities['nativeIterableProviders'] !== undefined)
|
|
155
|
+
readNativeIterableProviders(capabilities['nativeIterableProviders']);
|
|
156
|
+
if (capabilities['nativeReferenceIdentities'] !== undefined) {
|
|
157
|
+
for (const native of capabilities['nativeReferenceIdentities']) {
|
|
158
|
+
if (typeof native !== 'string' || native.length === 0)
|
|
159
|
+
throw new Error('invalid PluginInstance: nativeReferenceIdentities must contain nonempty strings');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
145
162
|
for (const [name, lines] of capabilities['hostPreambles']) {
|
|
146
163
|
if (typeof name !== 'string' || !Array.isArray(lines) || !lines.every((line) => typeof line === 'string')) {
|
|
147
164
|
throw new Error('invalid PluginInstance: capabilities.hostPreambles must map strings to string arrays');
|
package/dist/plugins/model.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NativeIterableProvider } from './native-iterable-providers.js';
|
|
1
2
|
import type { SlotHook } from '../projection/slots.js';
|
|
2
3
|
import type { DeclarationId, SemanticResultId } from '../identity/ids.js';
|
|
3
4
|
import type { FamilyProducer } from '../semantics/normalize/contribution.js';
|
|
@@ -174,6 +175,10 @@ export interface PluginCapabilities {
|
|
|
174
175
|
* matching a name by guesswork.
|
|
175
176
|
*/
|
|
176
177
|
readonly nativeTypes: ReadonlyMap<string, string>;
|
|
178
|
+
/** Native carriers with a stable identity() token retained by carrier copies. */
|
|
179
|
+
readonly nativeReferenceIdentities?: ReadonlySet<string>;
|
|
180
|
+
/** Installed factory metadata; source integrity and IR certification are separate requirements. */
|
|
181
|
+
readonly nativeIterableProviders?: ReadonlyMap<string, NativeIterableProvider>;
|
|
177
182
|
/**
|
|
178
183
|
* Host singleton values authenticated by exact declaration identity.
|
|
179
184
|
*
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type HostMember } from '../targets/cpp/host/host-members.js';
|
|
2
|
+
/** Installed host metadata, not source integrity or an iteration certificate. */
|
|
3
|
+
export interface NativeIterableProvider {
|
|
4
|
+
readonly protocol: 'host-sync-iterable@1';
|
|
5
|
+
readonly receiverNative: string;
|
|
6
|
+
readonly iteratorFactory: Extract<HostMember, {
|
|
7
|
+
readonly kind: 'method';
|
|
8
|
+
}>;
|
|
9
|
+
/** No source override can be admitted merely from a readonly declaration. */
|
|
10
|
+
readonly memberModel: 'native-fixed-member';
|
|
11
|
+
}
|
|
12
|
+
/** Decode only the existing zero-argument native method ABI. A valid provider
|
|
13
|
+
* still needs the exact declared iterator return and an independent source
|
|
14
|
+
* member-integrity proof before normalization may publish an iterable recipe.
|
|
15
|
+
*/
|
|
16
|
+
export declare const readNativeIterableProviders: (input: unknown) => ReadonlyMap<string, NativeIterableProvider>;
|
|
17
|
+
/** A native carrier has one factory authority; conflicting plugin owners refuse. */
|
|
18
|
+
export declare const mergeNativeIterableProviders: (inputs: readonly (ReadonlyMap<string, NativeIterableProvider> | undefined)[]) => ReadonlyMap<string, NativeIterableProvider>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { templateArity } from '../targets/cpp/host/host-members.js';
|
|
2
|
+
const nonempty = (value) => typeof value === 'string' && value.trim().length > 0;
|
|
3
|
+
const record = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
4
|
+
/** Decode only the existing zero-argument native method ABI. A valid provider
|
|
5
|
+
* still needs the exact declared iterator return and an independent source
|
|
6
|
+
* member-integrity proof before normalization may publish an iterable recipe.
|
|
7
|
+
*/
|
|
8
|
+
export const readNativeIterableProviders = (input) => {
|
|
9
|
+
if (!(input instanceof Map))
|
|
10
|
+
throw new Error('nativeIterableProviders must be a Map');
|
|
11
|
+
const result = new Map();
|
|
12
|
+
for (const [key, value] of input) {
|
|
13
|
+
if (!nonempty(key) || !record(value))
|
|
14
|
+
throw new Error('invalid native iterable provider');
|
|
15
|
+
if (value['protocol'] !== 'host-sync-iterable@1' || value['receiverNative'] !== key || value['memberModel'] !== 'native-fixed-member')
|
|
16
|
+
throw new Error('invalid native iterable provider identity');
|
|
17
|
+
const factory = value['iteratorFactory'];
|
|
18
|
+
if (!record(factory) ||
|
|
19
|
+
factory['kind'] !== 'method' ||
|
|
20
|
+
factory['arity'] !== 0 ||
|
|
21
|
+
!nonempty(factory['emit']) ||
|
|
22
|
+
factory['result'] !== undefined ||
|
|
23
|
+
(factory['receiver'] !== undefined && factory['receiver'] !== 'host') ||
|
|
24
|
+
(nonempty(factory['emit']) && templateArity(factory['emit']) !== 0))
|
|
25
|
+
throw new Error('native iterable factory requires the typed zero-argument host method ABI');
|
|
26
|
+
// Preserve only fields whose ABI was validated here. Additional source
|
|
27
|
+
// fields cannot smuggle a dynamic result or a different receiver route.
|
|
28
|
+
result.set(key, {
|
|
29
|
+
protocol: 'host-sync-iterable@1',
|
|
30
|
+
receiverNative: key,
|
|
31
|
+
memberModel: 'native-fixed-member',
|
|
32
|
+
iteratorFactory: { kind: 'method', arity: 0, emit: factory['emit'] }
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
/** A native carrier has one factory authority; conflicting plugin owners refuse. */
|
|
38
|
+
export const mergeNativeIterableProviders = (inputs) => {
|
|
39
|
+
const merged = new Map();
|
|
40
|
+
for (const input of inputs) {
|
|
41
|
+
if (input === undefined)
|
|
42
|
+
continue;
|
|
43
|
+
for (const [key, value] of readNativeIterableProviders(input)) {
|
|
44
|
+
const previous = merged.get(key);
|
|
45
|
+
if (previous && previous.iteratorFactory.emit !== value.iteratorFactory.emit)
|
|
46
|
+
throw new Error('conflicting native iterable factory authorities');
|
|
47
|
+
merged.set(key, value);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return merged;
|
|
51
|
+
};
|
|
@@ -33,5 +33,13 @@ export interface PreparationOptions {
|
|
|
33
33
|
/** Unpack the published tarball of `spec` (`name@range`) so its `package.json` sits at `destination`. */
|
|
34
34
|
readonly fetchPackage?: (spec: string, destination: string) => void;
|
|
35
35
|
}
|
|
36
|
+
export declare const checkout: (identity: SourceIdentity, destination: string) => void;
|
|
37
|
+
/**
|
|
38
|
+
* The manifest `npm view <name>@<version> --json` printed. npm 11 prints the
|
|
39
|
+
* one matching version's manifest as an object; npm 12 prints an array of the
|
|
40
|
+
* matching versions' manifests, which for an exact version holds one. Anything
|
|
41
|
+
* else is no manifest (`{}`), which the version check below refuses.
|
|
42
|
+
*/
|
|
43
|
+
export declare const registryManifest: (json: string) => Manifest;
|
|
36
44
|
/** Acquire missing typed sources at the installed version; plain JS remains usable. */
|
|
37
45
|
export declare const preparePackageSources: (root: string, options?: PreparationOptions) => Promise<readonly PackageSource[]>;
|