@flighthq/requirement-codegen 0.5.1-next.1669.c9827a8

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/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2013-2026 Joshua Granick and other contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # @flighthq/requirement-codegen
2
+
3
+ Emission-neutral planning kernel for selective registry generation
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install @flighthq/requirement-codegen
9
+ ```
10
+
11
+ Import the supported application-facing API from `@flighthq/requirement-codegen`. The `@flighthq/requirement-codegen/contract` export is the wider package-to-package contract used to compose Flight itself.
12
+
13
+ This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
14
+
15
+ - [Flight project](https://github.com/flighthq/flight)
16
+ - [Source for @flighthq/requirement-codegen@0.5.1-next.1669.c9827a8](https://github.com/flighthq/flight/tree/c9827a8363ff130c75c633b9455fecfcf27c36bb/packages/requirement-codegen)
17
+ - [License](https://github.com/flighthq/flight/blob/c9827a8363ff130c75c633b9455fecfcf27c36bb/LICENSE.md)
@@ -0,0 +1,3 @@
1
+ export * from './requirementCodegen';
2
+ export { initializeRequirementCodegenPlan } from './requirementCodegen';
3
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './requirementCodegen';
2
+ export { initializeRequirementCodegenPlan } from './requirementCodegen';
3
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { createRequirementCodegenPlan } from './requirementCodegen';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { createRequirementCodegenPlan } from './requirementCodegen';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Entity, EntityConstruction, RequirementCatalog, RequirementCodegenPlan, RequirementSet } from '@flighthq/types/contract';
2
+ export declare function createRequirementCodegenPlan(catalog: Readonly<RequirementCatalog>, requirements: Readonly<RequirementSet>, backend: string): RequirementCodegenPlan & Entity;
3
+ export declare function initializeRequirementCodegenPlan(out: EntityConstruction<RequirementCodegenPlan & Entity>, catalog: Readonly<RequirementCatalog>, requirements: Readonly<RequirementSet>, backend: string): void;
4
+ //# sourceMappingURL=requirementCodegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requirementCodegen.d.ts","sourceRoot":"","sources":["../src/requirementCodegen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EACN,kBAAkB,EAClB,kBAAkB,EAElB,sBAAsB,EAEtB,cAAc,EACf,MAAM,0BAA0B,CAAC;AAElC,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACrC,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,EACtC,OAAO,EAAE,MAAM,GACd,sBAAsB,GAAG,MAAM,CAIjC;AAID,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,kBAAkB,CAAC,sBAAsB,GAAG,MAAM,CAAC,EACxD,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACrC,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,EACtC,OAAO,EAAE,MAAM,GACd,IAAI,CAkBN"}
@@ -0,0 +1,34 @@
1
+ import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
2
+ import { findRequirementCatalogEntries } from '@flighthq/requirement-catalog/contract';
3
+ export function createRequirementCodegenPlan(catalog, requirements, backend) {
4
+ const out = allocateEntity();
5
+ initializeRequirementCodegenPlan(out, catalog, requirements, backend);
6
+ return finishEntity(out);
7
+ }
8
+ // Resolve only facts here. A later emitter may choose how a row becomes source after the ownership lane
9
+ // is ruled; this kernel cannot encode that decision accidentally because it returns no source text.
10
+ export function initializeRequirementCodegenPlan(out, catalog, requirements, backend) {
11
+ const entries = [];
12
+ const unresolved = [];
13
+ const seen = new Set();
14
+ for (const requirement of requirements.requirements) {
15
+ const identity = requirementIdentity(requirement);
16
+ if (seen.has(identity))
17
+ continue;
18
+ seen.add(identity);
19
+ const matches = findRequirementCatalogEntries(catalog, backend, requirement.facet, requirement.key);
20
+ if (matches.length === 0) {
21
+ unresolved.push({ facet: requirement.facet, key: requirement.key });
22
+ }
23
+ else {
24
+ entries.push(...matches);
25
+ }
26
+ }
27
+ out.backend = backend;
28
+ out.entries = entries;
29
+ out.unresolved = unresolved;
30
+ }
31
+ function requirementIdentity(requirement) {
32
+ return `${requirement.facet}\0${requirement.key}`;
33
+ }
34
+ //# sourceMappingURL=requirementCodegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requirementCodegen.js","sourceRoot":"","sources":["../src/requirementCodegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAWvF,MAAM,UAAU,4BAA4B,CAC1C,OAAqC,EACrC,YAAsC,EACtC,OAAe;IAEf,MAAM,GAAG,GAAG,cAAc,EAAmC,CAAC;IAC9D,gCAAgC,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IACtE,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,wGAAwG;AACxG,oGAAoG;AACpG,MAAM,UAAU,gCAAgC,CAC9C,GAAwD,EACxD,OAAqC,EACrC,YAAsC,EACtC,OAAe;IAEf,MAAM,OAAO,GAA8B,EAAE,CAAC;IAC9C,MAAM,UAAU,GAAkB,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/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;QACnB,MAAM,OAAO,GAAG,6BAA6B,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;QACpG,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;IACD,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;AAC9B,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,50 @@
1
+ {
2
+ "name": "@flighthq/requirement-codegen",
3
+ "version": "0.5.1-next.1669.c9827a8",
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/requirement-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/entity": "0.5.1-next.1669.c9827a8",
42
+ "@flighthq/requirement-catalog": "0.5.1-next.1669.c9827a8",
43
+ "@flighthq/types": "0.5.1-next.1669.c9827a8"
44
+ },
45
+ "devDependencies": {
46
+ "typescript": "^5.3.0"
47
+ },
48
+ "description": "Emission-neutral planning kernel for selective registry generation",
49
+ "sideEffects": false
50
+ }
@@ -0,0 +1,86 @@
1
+ import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
2
+ import { createRequirementCatalog } from '@flighthq/requirement-catalog/contract';
3
+ import type { RequirementCatalogEntry, RequirementSet } from '@flighthq/types/contract';
4
+ import { EntityRuntimeKey, RequirementFacet } from '@flighthq/types/contract';
5
+
6
+ import { createRequirementCodegenPlan, initializeRequirementCodegenPlan } from './requirementCodegen';
7
+
8
+ const shapeRenderer: RequirementCatalogEntry = {
9
+ backend: 'webgl',
10
+ facet: RequirementFacet.SceneNodeKind,
11
+ implementationImport: '@flighthq/scene2d-gl',
12
+ implementationSymbol: 'glShapeRenderer',
13
+ kind: 'Shape',
14
+ registrarImport: '@flighthq/render',
15
+ registrarSymbol: 'registerNodeRenderer',
16
+ };
17
+
18
+ const shapeCommands: RequirementCatalogEntry = {
19
+ ...shapeRenderer,
20
+ registrarImport: '@flighthq/scene2d-gl',
21
+ registrarSymbol: 'registerGlShapeCommands',
22
+ };
23
+
24
+ describe('createRequirementCodegenPlan', () => {
25
+ it('selects the matching backend rows in requirement and catalog order', () => {
26
+ const catalog = createRequirementCatalog([shapeRenderer, shapeCommands, { ...shapeRenderer, backend: 'webgpu' }]);
27
+ const requirements = (() => {
28
+ const out = allocateEntity<RequirementSet>();
29
+ out.covers = [RequirementFacet.SceneNodeKind];
30
+ out.requirements = [
31
+ { facet: RequirementFacet.SceneNodeKind, key: 'Shape' },
32
+ { facet: RequirementFacet.SceneNodeKind, key: 'Sprite' },
33
+ ];
34
+ return finishEntity(out);
35
+ })();
36
+
37
+ const plan = createRequirementCodegenPlan(catalog, requirements, 'webgl');
38
+ expect(EntityRuntimeKey in plan).toBe(true);
39
+ expect(plan).toMatchObject({
40
+ backend: 'webgl',
41
+ entries: [shapeRenderer, shapeCommands],
42
+ unresolved: [{ facet: RequirementFacet.SceneNodeKind, key: 'Sprite' }],
43
+ });
44
+ });
45
+
46
+ it('deduplicates repeated positive requirements without treating covers as requests', () => {
47
+ const catalog = createRequirementCatalog([shapeRenderer]);
48
+ const requirement = { facet: RequirementFacet.SceneNodeKind, key: 'Shape' } as const;
49
+ const requirements = (() => {
50
+ const out = allocateEntity<RequirementSet>();
51
+ out.covers = [RequirementFacet.SceneNodeKind, RequirementFacet.SceneShapeCommand];
52
+ out.requirements = [requirement, requirement];
53
+ return finishEntity(out);
54
+ })();
55
+
56
+ expect(createRequirementCodegenPlan(catalog, requirements, 'webgl')).toMatchObject({
57
+ backend: 'webgl',
58
+ entries: [shapeRenderer],
59
+ unresolved: [],
60
+ });
61
+ });
62
+
63
+ it('returns an empty plan for empty catalog contents and requirements', () => {
64
+ expect(
65
+ createRequirementCodegenPlan(
66
+ createRequirementCatalog(),
67
+ (() => {
68
+ const out = allocateEntity<any>();
69
+ out.covers = [];
70
+ out.requirements = [];
71
+ return finishEntity(out);
72
+ })(),
73
+ 'webgl',
74
+ ),
75
+ ).toMatchObject({
76
+ backend: 'webgl',
77
+ entries: [],
78
+ unresolved: [],
79
+ });
80
+ });
81
+ });
82
+ describe('initializeRequirementCodegenPlan', () => {
83
+ it('is the construction initializer of createRequirementCodegenPlan', () => {
84
+ expect(typeof initializeRequirementCodegenPlan).toBe('function');
85
+ });
86
+ });