Support checked closed generic portable bindings
This commit is contained in:
@@ -210,11 +210,10 @@ export function generatePortableTypeScriptBindings(
|
||||
adapters: string[] = [],
|
||||
descriptors: unknown[] = [];
|
||||
for (const entry of entries) {
|
||||
if (entry.application || entry.kind === "constructor")
|
||||
throw new PortableBindingError(
|
||||
entry.id,
|
||||
"Portable generic adapters/legacy constructors are not implemented; declare an ordinary factory",
|
||||
);
|
||||
// The checked binding schema already contains concrete generic applications.
|
||||
// Each has its own identity, value codecs and specialized dependency ports.
|
||||
if (entry.kind === "constructor")
|
||||
throw new PortableBindingError(entry.id, "Legacy constructors are not supported; declare an ordinary factory");
|
||||
if (names.has(entry.displayName)) throw new PortableBindingError(entry.id, "Duplicate handler name");
|
||||
names.add(entry.displayName);
|
||||
const portNames = new Set<string>();
|
||||
|
||||
@@ -103,3 +103,13 @@ against both generated targets without casts. The root
|
||||
`camino-portable-bindings` qualification compares Node, Window, Worker and
|
||||
serialized-port behavior. Its simulated channel tests adapters, not installed
|
||||
operation acquisition or process isolation; those require the coordinator.
|
||||
|
||||
Closed generic package applications use the same portable adapters. The checked
|
||||
workspace specializes their input/output types and dependency ports before code
|
||||
generation. Each application has its own export ID and generated handler name
|
||||
(`name$<specialization digest>`); handlers are concrete, so a string application
|
||||
and a list-of-int64 application cannot accidentally share an untyped codec.
|
||||
Common implementation helpers can still be ordinary generic TypeScript functions.
|
||||
This does not implement universal runtime type application or legacy constructors.
|
||||
The `camino-portable-bindings` check compiles positive/negative typed consumers and
|
||||
executes both specializations in Node, Chromium Window, and Worker hosts.
|
||||
|
||||
Reference in New Issue
Block a user