@dogsbay/serialize-core 0.2.0-beta.117 → 0.2.0-beta.119

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.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * How a page that carries OpenAPI operations (`endpoint` nodes) is laid out.
3
+ * One rule for both pipelines: format-astro passes it to DocsLayout and
4
+ * ApiLayout, dogsbay-ssg to its layout and to @dogsbay/render-html.
5
+ */
6
+ import type { TreeNode } from "@dogsbay/types";
7
+ export interface ApiPageLayout {
8
+ /**
9
+ * The page drops the reading-width column and the table of contents: an
10
+ * operation composes its own two columns (description, code), and the
11
+ * prose cap and the TOC rail would only take width from it.
12
+ */
13
+ wide: boolean;
14
+ /**
15
+ * Endpoints sit inline among prose (natural height, no sticky code rail)
16
+ * rather than as a full-viewport operation page. True when the page has
17
+ * endpoints and also content other than endpoints, headings and rules.
18
+ */
19
+ embeddedEndpoints: boolean;
20
+ }
21
+ /** The layout for a page's top-level nodes. */
22
+ export declare function apiPageLayout(tree: readonly TreeNode[] | undefined): ApiPageLayout;
23
+ /**
24
+ * The heading level of each autodoc symbol (`api-class` / `api-member`) on a
25
+ * page: an outermost symbol is one level below the last heading before it
26
+ * (h2 when there is none), a nested one one level below its parent symbol,
27
+ * at most h6. Keyed by node.
28
+ *
29
+ * By type (class h2, member h3) a module-level function was an h3 under the
30
+ * page's h1, a class nested in a class an h2, and `## Helpers` followed by
31
+ * a function made the function its sibling. format-astro renders by this,
32
+ * the CLI builds the TOC by it, and @dogsbay/render-html applies the same
33
+ * rule as it renders (headings before the symbol, then nesting).
34
+ */
35
+ export declare function apiSymbolLevels(tree: readonly TreeNode[] | undefined): Map<TreeNode, number>;
36
+ //# sourceMappingURL=api-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-layout.d.ts","sourceRoot":"","sources":["../src/api-layout.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;;;OAIG;IACH,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED,+CAA+C;AAC/C,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,GAAG,SAAS,GAAG,aAAa,CAOlF;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,GAAG,SAAS,GAAG,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAqB5F"}
@@ -0,0 +1,47 @@
1
+ /** The layout for a page's top-level nodes. */
2
+ export function apiPageLayout(tree) {
3
+ const nodes = (tree ?? []).filter(Boolean);
4
+ const hasEndpoint = nodes.some((n) => n.type === "endpoint");
5
+ return {
6
+ wide: hasEndpoint,
7
+ embeddedEndpoints: hasEndpoint && nodes.some((n) => n.type !== "endpoint" && n.type !== "heading" && n.type !== "hr"),
8
+ };
9
+ }
10
+ const isSymbol = (n) => n.type === "api-class" || n.type === "api-member";
11
+ /**
12
+ * The heading level of each autodoc symbol (`api-class` / `api-member`) on a
13
+ * page: an outermost symbol is one level below the last heading before it
14
+ * (h2 when there is none), a nested one one level below its parent symbol,
15
+ * at most h6. Keyed by node.
16
+ *
17
+ * By type (class h2, member h3) a module-level function was an h3 under the
18
+ * page's h1, a class nested in a class an h2, and `## Helpers` followed by
19
+ * a function made the function its sibling. format-astro renders by this,
20
+ * the CLI builds the TOC by it, and @dogsbay/render-html applies the same
21
+ * rule as it renders (headings before the symbol, then nesting).
22
+ */
23
+ export function apiSymbolLevels(tree) {
24
+ const levels = new Map();
25
+ let lastHeading = 1;
26
+ const walk = (nodes, parentLevel) => {
27
+ for (const n of nodes ?? []) {
28
+ if (!n)
29
+ continue;
30
+ if (isSymbol(n)) {
31
+ const level = Math.min(6, (parentLevel ?? lastHeading) + 1);
32
+ levels.set(n, level);
33
+ walk(n.children, level);
34
+ continue;
35
+ }
36
+ if (n.type === "heading" && parentLevel === undefined) {
37
+ const l = Number(n.props?.level);
38
+ if (l >= 1 && l <= 6)
39
+ lastHeading = l;
40
+ }
41
+ walk(n.children, parentLevel);
42
+ }
43
+ };
44
+ walk(tree, undefined);
45
+ return levels;
46
+ }
47
+ //# sourceMappingURL=api-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-layout.js","sourceRoot":"","sources":["../src/api-layout.ts"],"names":[],"mappings":"AAsBA,+CAA+C;AAC/C,MAAM,UAAU,aAAa,CAAC,IAAqC;IACjE,MAAM,KAAK,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;IAC7D,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,iBAAiB,EAAE,WAAW,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;KACtH,CAAC;AACJ,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,CAAW,EAAW,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC;AAE7F;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,IAAqC;IACnE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC3C,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,MAAM,IAAI,GAAG,CAAC,KAAsC,EAAE,WAA+B,EAAQ,EAAE;QAC7F,KAAK,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;YAC5B,IAAI,CAAC,CAAC;gBAAE,SAAS;YACjB,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,WAAW,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC5D,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;gBACrB,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACxB,SAAS;YACX,CAAC;YACD,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBACtD,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBACjC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;oBAAE,WAAW,GAAG,CAAC,CAAC;YACxC,CAAC;YACD,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAChC,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -25,4 +25,5 @@ export { realizeIncludes, hasIncludes, type RealizeResult, type RealizeOptions,
25
25
  export { realizeChildLinks, hasChildLinks, directoryChildren, navKey, type ChildLinksContext, type ChildLinksResult, } from "./child-links.js";
26
26
  export { renderUnknownNode, type UnknownNodePolicy, type UnknownNodeOptions, } from "./unknown.js";
27
27
  export { detectLeadingNodes, deriveDescription, extractFirstParagraph, type LeadingNodeInfo, } from "./lead.js";
28
+ export { apiPageLayout, apiSymbolLevels, type ApiPageLayout } from "./api-layout.js";
28
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts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K,cAAc,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,MAAM,EACN,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,eAAe,EACf,YAAY,EACZ,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,UAAU,EACV,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,EACV,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,iCAAiC,EACjC,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,MAAM,EACN,WAAW,EACX,2BAA2B,EAC3B,SAAS,EACT,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,eAAe,EACf,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,MAAM,EACN,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -26,4 +26,5 @@ export { realizeChildLinks, hasChildLinks, directoryChildren, navKey, } from "./
26
26
  export { renderUnknownNode, } from "./unknown.js";
27
27
  // Page-lead reads shared by format-astro and @dogsbay/site-check
28
28
  export { detectLeadingNodes, deriveDescription, extractFirstParagraph, } from "./lead.js";
29
+ export { apiPageLayout, apiSymbolLevels } from "./api-layout.js";
29
30
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,eAAe,EACf,YAAY,EACZ,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,UAAU,GAEX,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,EACV,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,QAAQ,GAIT,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,iCAAiC,GAMlC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,MAAM,EACN,WAAW,EACX,2BAA2B,EAC3B,SAAS,EACT,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,qBAAqB,GAMtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,eAAe,EACf,WAAW,GAGZ,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,MAAM,GAGP,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,iBAAiB,GAGlB,MAAM,cAAc,CAAC;AAEtB,iEAAiE;AACjE,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GAEtB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;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,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dogsbay/serialize-core",
3
- "version": "0.2.0-beta.117",
3
+ "version": "0.2.0-beta.119",
4
4
  "description": "Shared serializer core — shape-tolerant TreeNode reads, a generic inline walker, fence/indent utilities, and the export capability ledger every format exporter builds on",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@dogsbay/types": "0.2.0-beta.117"
25
+ "@dogsbay/types": "0.2.0-beta.119"
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",