@flighthq/requirement 0.5.1-edge.1685.dc0e23a

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
2
+
3
+ Plain requirement collection and set algebra for content-to-registration resolution
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install @flighthq/requirement
9
+ ```
10
+
11
+ Import the supported application-facing API from `@flighthq/requirement`. The `@flighthq/requirement/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@0.5.1-edge.1685.dc0e23a](https://github.com/flighthq/flight/tree/dc0e23a17453ec75c20ccbf07058a57b5ef10c4c/packages/requirement)
17
+ - [License](https://github.com/flighthq/flight/blob/dc0e23a17453ec75c20ccbf07058a57b5ef10c4c/LICENSE.md)
@@ -0,0 +1,4 @@
1
+ export * from './requirementCollector';
2
+ export * from './requirementSet';
3
+ export { initializeRequirementSet } from './requirementSet';
4
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './requirementCollector';
2
+ export * from './requirementSet';
3
+ export { initializeRequirementSet } from './requirementSet';
4
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { collectScene2DRequirements, reportRequirement } from './requirementCollector';
2
+ export { createRequirementSet, diffRequirementSets, mergeRequirementSets } from './requirementSet';
3
+ //# 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,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { collectScene2DRequirements, reportRequirement } from './requirementCollector';
2
+ export { createRequirementSet, diffRequirementSets, mergeRequirementSets } from './requirementSet';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Kind, Requirement, RequirementFacet, RequirementSet } from '@flighthq/types/contract';
2
+ export declare function collectScene2DRequirements(run: (sink: Requirement[]) => void): RequirementSet;
3
+ export declare function reportRequirement(sink: Requirement[] | undefined, facet: RequirementFacet, key: Kind): void;
4
+ //# sourceMappingURL=requirementCollector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requirementCollector.d.ts","sourceRoot":"","sources":["../src/requirementCollector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAOpG,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,IAAI,GAAG,cAAc,CAO7F;AAID,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI,CAG3G"}
@@ -0,0 +1,17 @@
1
+ import { RequirementFacet as Facet } from '@flighthq/types/contract';
2
+ import { createRequirementSet } from './requirementSet';
3
+ // Engages requirement recording for one Scene2D import. Parsers receive the same optional-array sink
4
+ // shape as import diagnostics; an unengaged parse receives `undefined` and allocates no requirement.
5
+ export function collectScene2DRequirements(run) {
6
+ const requirements = [];
7
+ run(requirements);
8
+ return createRequirementSet([Facet.SceneBlendMode, Facet.SceneMaterialKind, Facet.SceneNodeKind, Facet.SceneShapeCommand], requirements);
9
+ }
10
+ // The colocated importer seam. Call it only where a parser has established the content fact; when no
11
+ // collector is engaged the default parse pays one undefined check and records nothing.
12
+ export function reportRequirement(sink, facet, key) {
13
+ if (sink === undefined)
14
+ return;
15
+ sink.push({ facet, key });
16
+ }
17
+ //# sourceMappingURL=requirementCollector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requirementCollector.js","sourceRoot":"","sources":["../src/requirementCollector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,IAAI,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,qGAAqG;AACrG,qGAAqG;AACrG,MAAM,UAAU,0BAA0B,CAAC,GAAkC;IAC3E,MAAM,YAAY,GAAkB,EAAE,CAAC;IACvC,GAAG,CAAC,YAAY,CAAC,CAAC;IAClB,OAAO,oBAAoB,CACzB,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC,EAC7F,YAAY,CACb,CAAC;AACJ,CAAC;AAED,qGAAqG;AACrG,uFAAuF;AACvF,MAAM,UAAU,iBAAiB,CAAC,IAA+B,EAAE,KAAuB,EAAE,GAAS;IACnG,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO;IAC/B,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { EntityConstruction, Requirement, RequirementFacet, RequirementSet } from '@flighthq/types/contract';
2
+ export declare function createRequirementSet(covers: readonly RequirementFacet[], requirements: readonly Readonly<Requirement>[]): RequirementSet;
3
+ export declare function diffRequirementSets(requirements: Readonly<RequirementSet>, baseline: Readonly<RequirementSet>): RequirementSet;
4
+ export declare function initializeRequirementSet(out: EntityConstruction<RequirementSet>, covers: readonly RequirementFacet[], requirements: readonly Readonly<Requirement>[]): void;
5
+ export declare function mergeRequirementSets(requirementSets: readonly Readonly<RequirementSet>[]): RequirementSet;
6
+ //# sourceMappingURL=requirementSet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requirementSet.d.ts","sourceRoot":"","sources":["../src/requirementSet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAElH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,gBAAgB,EAAE,EACnC,YAAY,EAAE,SAAS,QAAQ,CAAC,WAAW,CAAC,EAAE,GAC7C,cAAc,CAIhB;AAID,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,EACtC,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,GACjC,cAAc,CAahB;AAED,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,kBAAkB,CAAC,cAAc,CAAC,EACvC,MAAM,EAAE,SAAS,gBAAgB,EAAE,EACnC,YAAY,EAAE,SAAS,QAAQ,CAAC,WAAW,CAAC,EAAE,GAC7C,IAAI,CAGN;AAID,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,SAAS,QAAQ,CAAC,cAAc,CAAC,EAAE,GAAG,cAAc,CASzG"}
@@ -0,0 +1,52 @@
1
+ import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
2
+ export function createRequirementSet(covers, requirements) {
3
+ const out = allocateEntity();
4
+ initializeRequirementSet(out, covers, requirements);
5
+ return finishEntity(out);
6
+ }
7
+ // A difference can claim completeness only where both operands inspected the facet. Requirements from
8
+ // an unshared facet are therefore unknown, not absent, and do not enter the result.
9
+ export function diffRequirementSets(requirements, baseline) {
10
+ const covers = intersectSorted(requirements.covers, baseline.covers);
11
+ const baselineKeys = new Set(baseline.requirements.map((requirement) => requirementIdentity(requirement.facet, requirement.key)));
12
+ return createRequirementSet(covers, requirements.requirements.filter((requirement) => covers.includes(requirement.facet) &&
13
+ !baselineKeys.has(requirementIdentity(requirement.facet, requirement.key))));
14
+ }
15
+ export function initializeRequirementSet(out, covers, requirements) {
16
+ out.covers = distinctSorted(covers);
17
+ out.requirements = distinctSortedRequirements(requirements);
18
+ }
19
+ // A merged set is complete for a facet only when every input inspected it. Requirements themselves are
20
+ // unioned, because a partial producer can still contribute a positive fact without proving negatives.
21
+ export function mergeRequirementSets(requirementSets) {
22
+ if (requirementSets.length === 0)
23
+ return createRequirementSet([], []);
24
+ let covers = distinctSorted(requirementSets[0].covers);
25
+ const requirements = [];
26
+ for (const requirementSet of requirementSets) {
27
+ covers = intersectSorted(covers, requirementSet.covers);
28
+ requirements.push(...requirementSet.requirements);
29
+ }
30
+ return createRequirementSet(covers, requirements);
31
+ }
32
+ function distinctSorted(values) {
33
+ return [...new Set(values)].sort();
34
+ }
35
+ function distinctSortedRequirements(requirements) {
36
+ const byIdentity = new Map();
37
+ for (const requirement of requirements) {
38
+ byIdentity.set(requirementIdentity(requirement.facet, requirement.key), {
39
+ facet: requirement.facet,
40
+ key: requirement.key,
41
+ });
42
+ }
43
+ return [...byIdentity.values()].sort((a, b) => a.facet.localeCompare(b.facet) || a.key.localeCompare(b.key));
44
+ }
45
+ function intersectSorted(first, second) {
46
+ const secondValues = new Set(second);
47
+ return distinctSorted(first.filter((value) => secondValues.has(value)));
48
+ }
49
+ function requirementIdentity(facet, key) {
50
+ return `${facet}\0${key}`;
51
+ }
52
+ //# sourceMappingURL=requirementSet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requirementSet.js","sourceRoot":"","sources":["../src/requirementSet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzE,MAAM,UAAU,oBAAoB,CAClC,MAAmC,EACnC,YAA8C;IAE9C,MAAM,GAAG,GAAG,cAAc,EAAkB,CAAC;IAC7C,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACp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AE,GAAW;IAC/D,OAAO,GAAG,KAAK,KAAK,GAAG,EAAE,CAAC;AAC5B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@flighthq/requirement",
3
+ "version": "0.5.1-edge.1685.dc0e23a",
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"
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-edge.1685.dc0e23a",
42
+ "@flighthq/types": "0.5.1-edge.1685.dc0e23a"
43
+ },
44
+ "devDependencies": {
45
+ "typescript": "^5.3.0"
46
+ },
47
+ "description": "Plain requirement collection and set algebra for content-to-registration resolution",
48
+ "sideEffects": false
49
+ }
@@ -0,0 +1,36 @@
1
+ import type { Requirement } from '@flighthq/types/contract';
2
+ import { RequirementFacet } from '@flighthq/types/contract';
3
+
4
+ import { collectScene2DRequirements, reportRequirement } from './requirementCollector';
5
+
6
+ describe('collectScene2DRequirements', () => {
7
+ it('returns deterministic distinct requirements and the facets inspected by the collector', () => {
8
+ const result = collectScene2DRequirements((sink) => {
9
+ reportRequirement(sink, RequirementFacet.SceneNodeKind, 'Shape');
10
+ reportRequirement(sink, RequirementFacet.SceneBlendMode, 'Multiply');
11
+ reportRequirement(sink, RequirementFacet.SceneNodeKind, 'Shape');
12
+ });
13
+
14
+ expect(result).toMatchObject({
15
+ covers: [
16
+ RequirementFacet.SceneBlendMode,
17
+ RequirementFacet.SceneMaterialKind,
18
+ RequirementFacet.SceneNodeKind,
19
+ RequirementFacet.SceneShapeCommand,
20
+ ],
21
+ requirements: [
22
+ { facet: RequirementFacet.SceneBlendMode, key: 'Multiply' },
23
+ { facet: RequirementFacet.SceneNodeKind, key: 'Shape' },
24
+ ],
25
+ });
26
+ });
27
+ });
28
+
29
+ describe('reportRequirement', () => {
30
+ it('records only when a collector is engaged', () => {
31
+ const sink: Requirement[] = [];
32
+ reportRequirement(undefined, RequirementFacet.SceneNodeKind, 'Shape');
33
+ reportRequirement(sink, RequirementFacet.SceneNodeKind, 'Shape');
34
+ expect(sink).toEqual([{ facet: RequirementFacet.SceneNodeKind, key: 'Shape' }]);
35
+ });
36
+ });
@@ -0,0 +1,81 @@
1
+ import { RequirementFacet } from '@flighthq/types/contract';
2
+
3
+ import {
4
+ createRequirementSet,
5
+ diffRequirementSets,
6
+ initializeRequirementSet,
7
+ mergeRequirementSets,
8
+ } from './requirementSet';
9
+
10
+ describe('createRequirementSet', () => {
11
+ it('copies, sorts, and deduplicates both dimensions', () => {
12
+ const covers = [RequirementFacet.SceneNodeKind, RequirementFacet.SceneBlendMode];
13
+ const requirements = [
14
+ { facet: RequirementFacet.SceneNodeKind, key: 'Shape' },
15
+ { facet: RequirementFacet.SceneBlendMode, key: 'Multiply' },
16
+ { facet: RequirementFacet.SceneNodeKind, key: 'Shape' },
17
+ ];
18
+ const result = createRequirementSet(covers, requirements);
19
+ covers.length = 0;
20
+ requirements.length = 0;
21
+
22
+ expect(result).toMatchObject({
23
+ covers: [RequirementFacet.SceneBlendMode, RequirementFacet.SceneNodeKind],
24
+ requirements: [
25
+ { facet: RequirementFacet.SceneBlendMode, key: 'Multiply' },
26
+ { facet: RequirementFacet.SceneNodeKind, key: 'Shape' },
27
+ ],
28
+ });
29
+ });
30
+ });
31
+
32
+ describe('diffRequirementSets', () => {
33
+ it('subtracts facts only for facets both operands cover', () => {
34
+ const result = diffRequirementSets(
35
+ createRequirementSet(
36
+ [RequirementFacet.SceneBlendMode, RequirementFacet.SceneNodeKind],
37
+ [
38
+ { facet: RequirementFacet.SceneBlendMode, key: 'Multiply' },
39
+ { facet: RequirementFacet.SceneNodeKind, key: 'Shape' },
40
+ ],
41
+ ),
42
+ createRequirementSet(
43
+ [RequirementFacet.SceneNodeKind],
44
+ [{ facet: RequirementFacet.SceneNodeKind, key: 'Sprite' }],
45
+ ),
46
+ );
47
+
48
+ expect(result).toMatchObject({
49
+ covers: [RequirementFacet.SceneNodeKind],
50
+ requirements: [{ facet: RequirementFacet.SceneNodeKind, key: 'Shape' }],
51
+ });
52
+ });
53
+ });
54
+
55
+ describe('initializeRequirementSet', () => {
56
+ it('is the construction initializer of createRequirementSet', () => {
57
+ expect(typeof initializeRequirementSet).toBe('function');
58
+ });
59
+ });
60
+ describe('mergeRequirementSets', () => {
61
+ it('unions facts while intersecting completeness', () => {
62
+ const result = mergeRequirementSets([
63
+ createRequirementSet(
64
+ [RequirementFacet.SceneBlendMode, RequirementFacet.SceneNodeKind],
65
+ [{ facet: RequirementFacet.SceneNodeKind, key: 'Shape' }],
66
+ ),
67
+ createRequirementSet(
68
+ [RequirementFacet.SceneNodeKind],
69
+ [{ facet: RequirementFacet.SceneNodeKind, key: 'Sprite' }],
70
+ ),
71
+ ]);
72
+
73
+ expect(result).toMatchObject({
74
+ covers: [RequirementFacet.SceneNodeKind],
75
+ requirements: [
76
+ { facet: RequirementFacet.SceneNodeKind, key: 'Shape' },
77
+ { facet: RequirementFacet.SceneNodeKind, key: 'Sprite' },
78
+ ],
79
+ });
80
+ });
81
+ });