@flighthq/registry-catalog 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/builtInRegistryCatalogEntries.d.ts +3 -0
- package/dist/builtInRegistryCatalogEntries.d.ts.map +1 -0
- package/dist/builtInRegistryCatalogEntries.js +4 -0
- package/dist/builtInRegistryCatalogEntries.js.map +1 -0
- package/dist/contract.d.ts +3 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +3 -0
- package/dist/contract.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/registryCatalog.d.ts +7 -0
- package/dist/registryCatalog.d.ts.map +1 -0
- package/dist/registryCatalog.js +44 -0
- package/dist/registryCatalog.js.map +1 -0
- package/package.json +48 -0
- package/src/registryCatalog.test.ts +86 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtInRegistryCatalogEntries.d.ts","sourceRoot":"","sources":["../src/builtInRegistryCatalogEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAIrE,eAAO,MAAM,iCAAiC,EAAE,SAAS,oBAAoB,EAAO,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// GENERATED by `npm run catalog` from scripts/catalog.ts. DO NOT EDIT BY HAND.
|
|
2
|
+
// Stage 4 builds the mechanism only; built-in ownership rows remain deliberately unpopulated.
|
|
3
|
+
export const BUILT_IN_REGISTRY_CATALOG_ENTRIES = [];
|
|
4
|
+
//# sourceMappingURL=builtInRegistryCatalogEntries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtInRegistryCatalogEntries.js","sourceRoot":"","sources":["../src/builtInRegistryCatalogEntries.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,8FAA8F;AAC9F,MAAM,CAAC,MAAM,iCAAiC,GAAoC,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iCAAiC,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;AAClC,cAAc,iCAAiC,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"}
|
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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Kind, RegistryCatalog, RegistryCatalogEntry, RequirementFacet } from '@flighthq/types/contract';
|
|
2
|
+
export declare function createRegistryCatalog(entries?: readonly Readonly<RegistryCatalogEntry>[]): RegistryCatalog;
|
|
3
|
+
export declare function findRegistryCatalogEntries(catalog: Readonly<RegistryCatalog>, backend: string, facet: RequirementFacet, kind: Kind): readonly RegistryCatalogEntry[];
|
|
4
|
+
export declare function getRegistryCatalogEntries(catalog: Readonly<RegistryCatalog>): readonly RegistryCatalogEntry[];
|
|
5
|
+
export declare function registerRegistryCatalogEntry(catalog: RegistryCatalog, entry: Readonly<RegistryCatalogEntry>): void;
|
|
6
|
+
export declare function unregisterRegistryCatalogEntry(catalog: RegistryCatalog, entry: Readonly<RegistryCatalogEntry>): boolean;
|
|
7
|
+
//# sourceMappingURL=registryCatalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registryCatalog.d.ts","sourceRoot":"","sources":["../src/registryCatalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE9G,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,SAAS,QAAQ,CAAC,oBAAoB,CAAC,EAAO,GAAG,eAAe,CAE9G;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,QAAQ,CAAC,eAAe,CAAC,EAClC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,IAAI,GACT,SAAS,oBAAoB,EAAE,CAIjC;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,SAAS,oBAAoB,EAAE,CAE7G;AAID,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAOlH;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GACpC,OAAO,CAMT"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function createRegistryCatalog(entries = []) {
|
|
2
|
+
return { entries: entries.map(copyCatalogEntry) };
|
|
3
|
+
}
|
|
4
|
+
export function findRegistryCatalogEntries(catalog, backend, facet, kind) {
|
|
5
|
+
return catalog.entries
|
|
6
|
+
.filter((entry) => entry.backend === backend && entry.facet === facet && entry.kind === kind)
|
|
7
|
+
.map(copyCatalogEntry);
|
|
8
|
+
}
|
|
9
|
+
export function getRegistryCatalogEntries(catalog) {
|
|
10
|
+
return catalog.entries.map(copyCatalogEntry);
|
|
11
|
+
}
|
|
12
|
+
// The row identity includes the registrar. One requirement may need multiple registrations, so adding a
|
|
13
|
+
// distinct registrar appends instead of replacing another call for the same backend/facet/kind.
|
|
14
|
+
export function registerRegistryCatalogEntry(catalog, entry) {
|
|
15
|
+
const index = catalog.entries.findIndex((candidate) => registryCatalogEntryIdentity(candidate) === registryCatalogEntryIdentity(entry));
|
|
16
|
+
const copy = copyCatalogEntry(entry);
|
|
17
|
+
if (index === -1)
|
|
18
|
+
catalog.entries.push(copy);
|
|
19
|
+
else
|
|
20
|
+
catalog.entries[index] = copy;
|
|
21
|
+
}
|
|
22
|
+
export function unregisterRegistryCatalogEntry(catalog, entry) {
|
|
23
|
+
const identity = registryCatalogEntryIdentity(entry);
|
|
24
|
+
const index = catalog.entries.findIndex((candidate) => registryCatalogEntryIdentity(candidate) === identity);
|
|
25
|
+
if (index === -1)
|
|
26
|
+
return false;
|
|
27
|
+
catalog.entries.splice(index, 1);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
function copyCatalogEntry(entry) {
|
|
31
|
+
return {
|
|
32
|
+
backend: entry.backend,
|
|
33
|
+
facet: entry.facet,
|
|
34
|
+
implementationImport: entry.implementationImport,
|
|
35
|
+
implementationSymbol: entry.implementationSymbol,
|
|
36
|
+
kind: entry.kind,
|
|
37
|
+
registrarImport: entry.registrarImport,
|
|
38
|
+
registrarSymbol: entry.registrarSymbol,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function registryCatalogEntryIdentity(entry) {
|
|
42
|
+
return [entry.backend, entry.facet, entry.kind, entry.registrarImport, entry.registrarSymbol].join('\0');
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=registryCatalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registryCatalog.js","sourceRoot":"","sources":["../src/registryCatalog.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,qBAAqB,CAAC,UAAqD,EAAE;IAC3F,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,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,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAqC;IAC7D,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;QAChD,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;QAChD,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,eAAe,EAAE,KAAK,CAAC,eAAe;KACvC,CAAC;AACJ,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAqC;IACzE,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3G,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flighthq/registry-catalog",
|
|
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-catalog"
|
|
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/types": "0.3.1-next.616.aa7ae7f"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"typescript": "^5.3.0"
|
|
45
|
+
},
|
|
46
|
+
"description": "Caller-owned open registry of backend-specific registration remedies",
|
|
47
|
+
"sideEffects": false
|
|
48
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { RegistryCatalogEntry } from '@flighthq/types/contract';
|
|
2
|
+
import { RequirementFacet } from '@flighthq/types/contract';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
createRegistryCatalog,
|
|
6
|
+
findRegistryCatalogEntries,
|
|
7
|
+
getRegistryCatalogEntries,
|
|
8
|
+
registerRegistryCatalogEntry,
|
|
9
|
+
unregisterRegistryCatalogEntry,
|
|
10
|
+
} from './registryCatalog';
|
|
11
|
+
|
|
12
|
+
const first: RegistryCatalogEntry = {
|
|
13
|
+
backend: 'webgl',
|
|
14
|
+
facet: RequirementFacet.SceneNodeKind,
|
|
15
|
+
implementationImport: '@flighthq/scene2d-gl',
|
|
16
|
+
implementationSymbol: 'defaultGlShapeRenderer',
|
|
17
|
+
kind: 'Shape',
|
|
18
|
+
registrarImport: '@flighthq/render',
|
|
19
|
+
registrarSymbol: 'registerRenderer',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('createRegistryCatalog', () => {
|
|
23
|
+
it('creates an isolated empty catalog and copies supplied entries', () => {
|
|
24
|
+
const source = [first];
|
|
25
|
+
const catalog = createRegistryCatalog(source);
|
|
26
|
+
source.length = 0;
|
|
27
|
+
|
|
28
|
+
expect(catalog.entries).toEqual([first]);
|
|
29
|
+
expect(createRegistryCatalog().entries).toEqual([]);
|
|
30
|
+
expect(createRegistryCatalog().entries).not.toBe(createRegistryCatalog().entries);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('findRegistryCatalogEntries', () => {
|
|
35
|
+
it('looks up every row by backend, facet, and kind and returns detached values', () => {
|
|
36
|
+
const catalog = createRegistryCatalog([first]);
|
|
37
|
+
const entries = findRegistryCatalogEntries(catalog, 'webgl', RequirementFacet.SceneNodeKind, 'Shape');
|
|
38
|
+
expect(entries).toEqual([first]);
|
|
39
|
+
expect(entries[0]).not.toBe(catalog.entries[0]);
|
|
40
|
+
expect(findRegistryCatalogEntries(catalog, 'webgpu', RequirementFacet.SceneNodeKind, 'Shape')).toEqual([]);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('getRegistryCatalogEntries', () => {
|
|
45
|
+
it('returns a detached ordered snapshot', () => {
|
|
46
|
+
const catalog = createRegistryCatalog([first]);
|
|
47
|
+
const snapshot = getRegistryCatalogEntries(catalog);
|
|
48
|
+
expect(getRegistryCatalogEntries(catalog)).toEqual([first]);
|
|
49
|
+
expect(snapshot).not.toBe(catalog.entries);
|
|
50
|
+
expect(snapshot[0]).not.toBe(catalog.entries[0]);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('registerRegistryCatalogEntry', () => {
|
|
55
|
+
it('replaces a matching key in place and copies caller data', () => {
|
|
56
|
+
const catalog = createRegistryCatalog([first]);
|
|
57
|
+
const replacement: RegistryCatalogEntry = {
|
|
58
|
+
...first,
|
|
59
|
+
implementationImport: '@acme/gl',
|
|
60
|
+
implementationSymbol: 'defaultAcmeShapeRenderer',
|
|
61
|
+
};
|
|
62
|
+
registerRegistryCatalogEntry(catalog, replacement);
|
|
63
|
+
|
|
64
|
+
expect(catalog.entries).toEqual([replacement]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('preserves multiple registrar rows for one requirement', () => {
|
|
68
|
+
const catalog = createRegistryCatalog([first]);
|
|
69
|
+
const commands = {
|
|
70
|
+
...first,
|
|
71
|
+
registrarImport: '@flighthq/scene2d-gl',
|
|
72
|
+
registrarSymbol: 'registerGlShapeCommands',
|
|
73
|
+
};
|
|
74
|
+
registerRegistryCatalogEntry(catalog, commands);
|
|
75
|
+
expect(catalog.entries).toEqual([first, commands]);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('unregisterRegistryCatalogEntry', () => {
|
|
80
|
+
it('removes only the requested kind and registry', () => {
|
|
81
|
+
const catalog = createRegistryCatalog([first]);
|
|
82
|
+
expect(unregisterRegistryCatalogEntry(catalog, { ...first, registrarSymbol: 'unknown' })).toBe(false);
|
|
83
|
+
expect(unregisterRegistryCatalogEntry(catalog, first)).toBe(true);
|
|
84
|
+
expect(catalog.entries).toEqual([]);
|
|
85
|
+
});
|
|
86
|
+
});
|