@flighthq/registry-codegen 0.3.1-next.616.aa7ae7f
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/dist/contract.d.ts +2 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +2 -0
- package/dist/contract.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/registryCodegen.d.ts +3 -0
- package/dist/registryCodegen.d.ts.map +1 -0
- package/dist/registryCodegen.js +26 -0
- package/dist/registryCodegen.js.map +1 -0
- package/package.json +49 -0
- package/src/registryCodegen.test.ts +63 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
package/dist/contract.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RegistryCatalog, RegistryCodegenPlan, RequirementSet } from '@flighthq/types/contract';
|
|
2
|
+
export declare function createRegistryCodegenPlan(catalog: Readonly<RegistryCatalog>, requirements: Readonly<RequirementSet>, backend: string): RegistryCodegenPlan;
|
|
3
|
+
//# sourceMappingURL=registryCodegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registryCodegen.d.ts","sourceRoot":"","sources":["../src/registryCodegen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EAEf,mBAAmB,EAEnB,cAAc,EACf,MAAM,0BAA0B,CAAC;AAIlC,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,QAAQ,CAAC,eAAe,CAAC,EAClC,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,EACtC,OAAO,EAAE,MAAM,GACd,mBAAmB,CAmBrB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { findRegistryCatalogEntries } from '@flighthq/registry-catalog/contract';
|
|
2
|
+
// Resolve only facts here. A later emitter may choose how a row becomes source after the ownership lane
|
|
3
|
+
// is ruled; this kernel cannot encode that decision accidentally because it returns no source text.
|
|
4
|
+
export function createRegistryCodegenPlan(catalog, requirements, backend) {
|
|
5
|
+
const entries = [];
|
|
6
|
+
const unresolved = [];
|
|
7
|
+
const seen = new Set();
|
|
8
|
+
for (const requirement of requirements.requirements) {
|
|
9
|
+
const identity = requirementIdentity(requirement);
|
|
10
|
+
if (seen.has(identity))
|
|
11
|
+
continue;
|
|
12
|
+
seen.add(identity);
|
|
13
|
+
const matches = findRegistryCatalogEntries(catalog, backend, requirement.facet, requirement.key);
|
|
14
|
+
if (matches.length === 0) {
|
|
15
|
+
unresolved.push({ facet: requirement.facet, key: requirement.key });
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
entries.push(...matches);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return { backend, entries, unresolved };
|
|
22
|
+
}
|
|
23
|
+
function requirementIdentity(requirement) {
|
|
24
|
+
return `${requirement.facet}\0${requirement.key}`;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=registryCodegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registryCodegen.js","sourceRoot":"","sources":["../src/registryCodegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AASjF,wGAAwG;AACxG,oGAAoG;AACpG,MAAM,UAAU,yBAAyB,CACvC,OAAkC,EAClC,YAAsC,EACtC,OAAe;IAEf,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,UAAU,GAAkB,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,KAAK,MAAM,WAAW,IAAI,YAAY,CAAC,YAAY,EAAE,CAAC;QACpD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,SAAS;QACjC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAEnB,MAAM,OAAO,GAAG,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;QACjG,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,UAAU,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;QACtE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AAC1C,CAAC;AAED,SAAS,mBAAmB,CAAC,WAAkC;IAC7D,OAAO,GAAG,WAAW,CAAC,KAAK,KAAK,WAAW,CAAC,GAAG,EAAE,CAAC;AACpD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flighthq/registry-codegen",
|
|
3
|
+
"version": "0.3.1-next.616.aa7ae7f",
|
|
4
|
+
"author": "Joshua Granick and other contributors",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/flighthq/flight.git",
|
|
9
|
+
"directory": "packages/registry-codegen"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./contract": {
|
|
20
|
+
"types": "./dist/contract.d.ts",
|
|
21
|
+
"default": "./dist/contract.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"src/**/*.test.ts",
|
|
27
|
+
"!dist/**/*.test.js",
|
|
28
|
+
"!dist/**/*.test.d.ts",
|
|
29
|
+
"!dist/**/*.test.js.map",
|
|
30
|
+
"!dist/**/*.test.d.ts.map"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc -b",
|
|
34
|
+
"clean": "tsc -b --clean",
|
|
35
|
+
"test": "vitest run --config vitest.config.ts",
|
|
36
|
+
"test:watch": "vitest --watch --config vitest.config.ts",
|
|
37
|
+
"prepack": "npm run clean && npm run clean:dist && npm run build",
|
|
38
|
+
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@flighthq/registry-catalog": "0.3.1-next.616.aa7ae7f",
|
|
42
|
+
"@flighthq/types": "0.3.1-next.616.aa7ae7f"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"typescript": "^5.3.0"
|
|
46
|
+
},
|
|
47
|
+
"description": "Emission-neutral planning kernel for selective registry generation",
|
|
48
|
+
"sideEffects": false
|
|
49
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createRegistryCatalog } from '@flighthq/registry-catalog/contract';
|
|
2
|
+
import type { RegistryCatalogEntry, RequirementSet } from '@flighthq/types/contract';
|
|
3
|
+
import { RequirementFacet } from '@flighthq/types/contract';
|
|
4
|
+
|
|
5
|
+
import { createRegistryCodegenPlan } from './registryCodegen';
|
|
6
|
+
|
|
7
|
+
const shapeRenderer: RegistryCatalogEntry = {
|
|
8
|
+
backend: 'webgl',
|
|
9
|
+
facet: RequirementFacet.SceneNodeKind,
|
|
10
|
+
implementationImport: '@flighthq/scene2d-gl',
|
|
11
|
+
implementationSymbol: 'defaultGlShapeRenderer',
|
|
12
|
+
kind: 'Shape',
|
|
13
|
+
registrarImport: '@flighthq/render',
|
|
14
|
+
registrarSymbol: 'registerRenderer',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const shapeCommands: RegistryCatalogEntry = {
|
|
18
|
+
...shapeRenderer,
|
|
19
|
+
registrarImport: '@flighthq/scene2d-gl',
|
|
20
|
+
registrarSymbol: 'registerGlShapeCommands',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe('createRegistryCodegenPlan', () => {
|
|
24
|
+
it('selects the matching backend rows in requirement and catalog order', () => {
|
|
25
|
+
const catalog = createRegistryCatalog([shapeRenderer, shapeCommands, { ...shapeRenderer, backend: 'webgpu' }]);
|
|
26
|
+
const requirements: RequirementSet = {
|
|
27
|
+
covers: [RequirementFacet.SceneNodeKind],
|
|
28
|
+
requirements: [
|
|
29
|
+
{ facet: RequirementFacet.SceneNodeKind, key: 'Shape' },
|
|
30
|
+
{ facet: RequirementFacet.SceneNodeKind, key: 'Sprite' },
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
expect(createRegistryCodegenPlan(catalog, requirements, 'webgl')).toEqual({
|
|
35
|
+
backend: 'webgl',
|
|
36
|
+
entries: [shapeRenderer, shapeCommands],
|
|
37
|
+
unresolved: [{ facet: RequirementFacet.SceneNodeKind, key: 'Sprite' }],
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('deduplicates repeated positive requirements without treating covers as requests', () => {
|
|
42
|
+
const catalog = createRegistryCatalog([shapeRenderer]);
|
|
43
|
+
const requirement = { facet: RequirementFacet.SceneNodeKind, key: 'Shape' } as const;
|
|
44
|
+
const requirements: RequirementSet = {
|
|
45
|
+
covers: [RequirementFacet.SceneNodeKind, RequirementFacet.SceneShapeCommand],
|
|
46
|
+
requirements: [requirement, requirement],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
expect(createRegistryCodegenPlan(catalog, requirements, 'webgl')).toEqual({
|
|
50
|
+
backend: 'webgl',
|
|
51
|
+
entries: [shapeRenderer],
|
|
52
|
+
unresolved: [],
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('returns an empty plan for empty catalog contents and requirements', () => {
|
|
57
|
+
expect(createRegistryCodegenPlan(createRegistryCatalog(), { covers: [], requirements: [] }, 'webgl')).toEqual({
|
|
58
|
+
backend: 'webgl',
|
|
59
|
+
entries: [],
|
|
60
|
+
unresolved: [],
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|