@coffer-org/core 1.2.4 → 1.4.0
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/compose.d.ts +9 -9
- package/dist/compose.js +19 -19
- package/package.json +2 -2
package/dist/compose.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ShelfDef } from '@coffer-org/sdk/shelf';
|
|
2
2
|
import type { OptionItem } from '@coffer-org/sdk/fields';
|
|
3
|
-
import type {
|
|
3
|
+
import type { LibraryBundle } from '@coffer-org/sdk/library';
|
|
4
4
|
import type { ExtendDef } from '@coffer-org/sdk/extend';
|
|
5
5
|
import { type PluginManifest } from '@coffer-org/sdk/plugin';
|
|
6
6
|
export interface Registry {
|
|
7
7
|
order: PluginManifest[];
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
libraries: LibraryBundle[];
|
|
9
|
+
shelves: ShelfDef[];
|
|
10
10
|
extends_: ExtendDef[];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
getExtendsFor(
|
|
14
|
-
getFieldOptions(
|
|
11
|
+
getShelf(library: string, shelf: string): ShelfDef | undefined;
|
|
12
|
+
getLibrary(id: string): LibraryBundle | undefined;
|
|
13
|
+
getExtendsFor(library: string, shelf: string): ExtendDef[];
|
|
14
|
+
getFieldOptions(library: string, shelf: string, field: string): OptionItem[];
|
|
15
15
|
getOptionList(name: string): OptionItem[];
|
|
16
|
-
|
|
16
|
+
getShelfOwner(library: string, shelf: string): string | undefined;
|
|
17
17
|
}
|
|
18
18
|
export declare function composeRegistry(plugins: PluginManifest[], opts?: {
|
|
19
19
|
disabled?: Set<string>;
|
package/dist/compose.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { fieldEntries } from '@coffer-org/sdk/
|
|
1
|
+
import { fieldEntries } from '@coffer-org/sdk/shelf';
|
|
2
2
|
import { bindSelectSourceZod } from '@coffer-org/sdk/fields';
|
|
3
3
|
import { extendMatches } from '@coffer-org/sdk/extend';
|
|
4
4
|
import { assemblePlugins } from '@coffer-org/sdk/plugin';
|
|
5
5
|
export function composeRegistry(plugins, opts = {}) {
|
|
6
6
|
const disabled = opts.disabled ?? new Set();
|
|
7
7
|
const enabled = plugins.filter((p) => !disabled.has(p.id));
|
|
8
|
-
const
|
|
8
|
+
const shelfOwner = new Map();
|
|
9
9
|
for (const p of enabled) {
|
|
10
|
-
for (const v of p.
|
|
11
|
-
for (const m of v.
|
|
12
|
-
|
|
13
|
-
for (const m of p.
|
|
14
|
-
|
|
10
|
+
for (const v of p.libraries ?? [])
|
|
11
|
+
for (const m of v.shelves)
|
|
12
|
+
shelfOwner.set(`${m.library}/${m.shelf}`, p.id);
|
|
13
|
+
for (const m of p.libraryShelves ?? [])
|
|
14
|
+
shelfOwner.set(`${m.library}/${m.shelf}`, p.id);
|
|
15
15
|
}
|
|
16
|
-
const
|
|
16
|
+
const getShelfOwner = (library, shelf) => shelfOwner.get(`${library}/${shelf}`);
|
|
17
17
|
for (const p of enabled) {
|
|
18
18
|
for (const d of p.dependsOn) {
|
|
19
19
|
if (disabled.has(d)) {
|
|
@@ -22,11 +22,11 @@ export function composeRegistry(plugins, opts = {}) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
const assembled = assemblePlugins(enabled);
|
|
25
|
-
const { order,
|
|
25
|
+
const { order, libraries, shelves, extends_ } = assembled;
|
|
26
26
|
const contribMap = new Map();
|
|
27
27
|
for (const p of enabled) {
|
|
28
28
|
for (const contrib of p.fieldContribs ?? []) {
|
|
29
|
-
const key = `${contrib.
|
|
29
|
+
const key = `${contrib.library}/${contrib.shelf}/${contrib.field}`;
|
|
30
30
|
const acc = contribMap.get(key) ?? { options: [], suggestions: [] };
|
|
31
31
|
if (contrib.options)
|
|
32
32
|
acc.options.push(...contrib.options);
|
|
@@ -42,9 +42,9 @@ export function composeRegistry(plugins, opts = {}) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
const getOptionList = (name) => optionListMap.get(name) ?? [];
|
|
45
|
-
for (const m of
|
|
45
|
+
for (const m of shelves) {
|
|
46
46
|
for (const [key, f] of fieldEntries(m.fields)) {
|
|
47
|
-
const c = contribMap.get(`${m.
|
|
47
|
+
const c = contribMap.get(`${m.library}/${m.shelf}/${key}`);
|
|
48
48
|
if (!c)
|
|
49
49
|
continue;
|
|
50
50
|
if (c.options.length) {
|
|
@@ -59,7 +59,7 @@ export function composeRegistry(plugins, opts = {}) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
const fieldOptionsMap = new Map();
|
|
62
|
-
for (const m of
|
|
62
|
+
for (const m of shelves) {
|
|
63
63
|
for (const [key, f] of fieldEntries(m.fields)) {
|
|
64
64
|
const src = f.hints['source'];
|
|
65
65
|
const base = f.options ?? [];
|
|
@@ -71,13 +71,13 @@ export function composeRegistry(plugins, opts = {}) {
|
|
|
71
71
|
}
|
|
72
72
|
if (resolved.length) {
|
|
73
73
|
f.options = resolved;
|
|
74
|
-
fieldOptionsMap.set(`${m.
|
|
74
|
+
fieldOptionsMap.set(`${m.library}/${m.shelf}/${key}`, resolved);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const getExtendsFor = (
|
|
81
|
-
const getFieldOptions = (
|
|
82
|
-
return { order,
|
|
78
|
+
const getShelf = (library, shelf) => shelves.find((m) => m.library === library && m.shelf === shelf);
|
|
79
|
+
const getLibrary = (id) => libraries.find((v) => v.meta.id === id);
|
|
80
|
+
const getExtendsFor = (library, shelf) => extends_.filter((e) => extendMatches(e, library, shelf));
|
|
81
|
+
const getFieldOptions = (library, shelf, field) => fieldOptionsMap.get(`${library}/${shelf}/${field}`) ?? [];
|
|
82
|
+
return { order, libraries, shelves, extends_, getShelf, getLibrary, getExtendsFor, getFieldOptions, getOptionList, getShelfOwner };
|
|
83
83
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffer-org/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24"
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"postpack": "node ../../scripts/swap-exports.mjs src"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@coffer-org/sdk": "^1.
|
|
27
|
+
"@coffer-org/sdk": "^1.5.0"
|
|
28
28
|
}
|
|
29
29
|
}
|