shelving 1.245.0 → 1.246.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.
|
@@ -32,6 +32,7 @@ export interface PackageExtractorOptions {
|
|
|
32
32
|
* - Static export keys (e.g. `"./api"`, `"./firestore/client"`) become one module each.
|
|
33
33
|
* - Wildcard export keys (e.g. `"./util/*"`) expand against the source tree — one module per matching child file or subdirectory.
|
|
34
34
|
* - Each export's *target* extension (e.g. the `.js` in `"./util/*.js"`) is mapped to source extensions via `extensions`, so built `.js` paths resolve to their `.ts` sources.
|
|
35
|
+
* - Each module's `title` is prefixed with the package `name` (e.g. `ui` → `shelving/ui`) so listings read as package subpaths.
|
|
35
36
|
* - The `"."` root export is skipped — its content is the root tree element itself.
|
|
36
37
|
* - Throws if a static export key has no matching source element in the tree.
|
|
37
38
|
*
|
|
@@ -16,6 +16,7 @@ const DEFAULT_EXTENSIONS = {
|
|
|
16
16
|
* - Static export keys (e.g. `"./api"`, `"./firestore/client"`) become one module each.
|
|
17
17
|
* - Wildcard export keys (e.g. `"./util/*"`) expand against the source tree — one module per matching child file or subdirectory.
|
|
18
18
|
* - Each export's *target* extension (e.g. the `.js` in `"./util/*.js"`) is mapped to source extensions via `extensions`, so built `.js` paths resolve to their `.ts` sources.
|
|
19
|
+
* - Each module's `title` is prefixed with the package `name` (e.g. `ui` → `shelving/ui`) so listings read as package subpaths.
|
|
19
20
|
* - The `"."` root export is skipped — its content is the root tree element itself.
|
|
20
21
|
* - Throws if a static export key has no matching source element in the tree.
|
|
21
22
|
*
|
|
@@ -56,7 +57,9 @@ export class PackageExtractor extends Extractor {
|
|
|
56
57
|
async extract(packageJson) {
|
|
57
58
|
const pkgPath = requirePath(packageJson, this._base, this.extract);
|
|
58
59
|
const pkg = (await Bun.file(pkgPath).json());
|
|
59
|
-
const
|
|
60
|
+
const tree = this._tree;
|
|
61
|
+
// Read the package name alongside its exports — the name prefixes each module title (e.g. `ui` → `shelving/ui`).
|
|
62
|
+
const { name, exports = {} } = pkg;
|
|
60
63
|
const modules = [];
|
|
61
64
|
for (const [key, value] of Object.entries(exports)) {
|
|
62
65
|
if (key === ".")
|
|
@@ -76,18 +79,21 @@ export class PackageExtractor extends Extractor {
|
|
|
76
79
|
modules.push(this._module.extract({ name: subpath, source }));
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
|
-
|
|
82
|
+
// Prefix the package name onto each module's title so listings read `shelving/ui` rather than a bare `ui`, making modules glanceable as package subpaths.
|
|
83
|
+
const children = name
|
|
84
|
+
? modules.map(module => ({ ...module, props: { ...module.props, title: `${name}/${module.props.title ?? module.props.name}` } }))
|
|
85
|
+
: modules;
|
|
80
86
|
// Canonical URL `path`s aren't stamped here — they're derived from tree structure when the tree is flattened (`flattenTree()`) in the UI layer.
|
|
81
87
|
return {
|
|
82
88
|
type: "tree-element",
|
|
83
|
-
key:
|
|
89
|
+
key: name ?? tree.key,
|
|
84
90
|
props: {
|
|
85
91
|
source: tree.props.source,
|
|
86
|
-
name:
|
|
87
|
-
title:
|
|
92
|
+
name: name ?? tree.props.name,
|
|
93
|
+
title: name ?? tree.props.title,
|
|
88
94
|
description: pkg.description ?? tree.props.description,
|
|
89
95
|
content: tree.props.content,
|
|
90
|
-
children
|
|
96
|
+
children,
|
|
91
97
|
},
|
|
92
98
|
};
|
|
93
99
|
}
|