@shadow-shard-tools/docs-core 1.0.17 → 1.0.18

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.
Files changed (171) hide show
  1. package/README.md +28 -5
  2. package/dist/cjs/configs/clientConfig.js +162 -0
  3. package/dist/cjs/configs/codeLanguagesConfig.js +36 -0
  4. package/dist/cjs/configs/index.js +20 -0
  5. package/dist/cjs/configs/sstDocsConfig.browser.js +27 -0
  6. package/dist/cjs/configs/sstDocsConfig.js +88 -0
  7. package/dist/cjs/configs/sstDocsConfigShared.js +174 -0
  8. package/dist/cjs/constants/alignmentClasses.js +17 -0
  9. package/dist/cjs/constants/index.js +7 -0
  10. package/dist/cjs/constants/spacingClasses.js +9 -0
  11. package/dist/cjs/data/buildTree.js +93 -0
  12. package/dist/cjs/data/fsDataProvider.js +23 -0
  13. package/dist/cjs/data/httpDataProvider.js +25 -0
  14. package/dist/cjs/data/index.js +19 -0
  15. package/dist/cjs/data/loadAllCategories.js +20 -0
  16. package/dist/cjs/data/loadAllItems.js +14 -0
  17. package/dist/cjs/data/loadVersionData.js +16 -0
  18. package/dist/cjs/data/loadVersions.js +6 -0
  19. package/dist/cjs/index.js +22 -0
  20. package/dist/cjs/themes/index.js +11 -0
  21. package/dist/cjs/themes/presets/default.js +121 -0
  22. package/dist/cjs/themes/themeRegistry.js +22 -0
  23. package/dist/cjs/types/AudioData.js +2 -0
  24. package/dist/cjs/types/BaseImage.js +2 -0
  25. package/dist/cjs/types/Category.js +2 -0
  26. package/dist/cjs/types/CategoryTitleData.js +2 -0
  27. package/dist/cjs/types/ChartData.js +2 -0
  28. package/dist/cjs/types/ClientVisibleSstDocsConfig.js +2 -0
  29. package/dist/cjs/types/CodeData.js +2 -0
  30. package/dist/cjs/types/Content.js +2 -0
  31. package/dist/cjs/types/DataProvider.js +2 -0
  32. package/dist/cjs/types/DividerData.js +2 -0
  33. package/dist/cjs/types/DocItem.js +2 -0
  34. package/dist/cjs/types/HeaderBranding.js +2 -0
  35. package/dist/cjs/types/HtmlGeneratorSettings.js +2 -0
  36. package/dist/cjs/types/ImageCarouselData.js +2 -0
  37. package/dist/cjs/types/ImageCompareData.js +2 -0
  38. package/dist/cjs/types/ImageData.js +2 -0
  39. package/dist/cjs/types/ImageGridData.js +2 -0
  40. package/dist/cjs/types/IndexJson.js +2 -0
  41. package/dist/cjs/types/ListData.js +2 -0
  42. package/dist/cjs/types/Logger.js +2 -0
  43. package/dist/cjs/types/MathData.js +2 -0
  44. package/dist/cjs/types/MessageBoxData.js +2 -0
  45. package/dist/cjs/types/RawCategory.js +2 -0
  46. package/dist/cjs/types/SstDocsConfig.js +2 -0
  47. package/dist/cjs/types/StyleTheme.js +2 -0
  48. package/dist/cjs/types/TableData.js +2 -0
  49. package/dist/cjs/types/TextData.js +2 -0
  50. package/dist/cjs/types/TitleData.js +2 -0
  51. package/dist/cjs/types/Version.js +2 -0
  52. package/dist/cjs/types/YoutubeData.js +2 -0
  53. package/dist/cjs/types/index.js +2 -0
  54. package/dist/cjs/utilities/dom/copyToClipboard.js +40 -0
  55. package/dist/cjs/utilities/dom/downloadTextFile.js +23 -0
  56. package/dist/cjs/utilities/dom/getResponsiveWidth.js +11 -0
  57. package/dist/cjs/utilities/file/getFileExtension.js +9 -0
  58. package/dist/cjs/utilities/index.js +53 -0
  59. package/dist/cjs/utilities/path/pathExists.js +16 -0
  60. package/dist/cjs/utilities/path/resolveAgainstProjectRoot.js +13 -0
  61. package/dist/cjs/utilities/path/resolveDataPath.js +18 -0
  62. package/dist/cjs/utilities/string/extractYouTubeId.js +18 -0
  63. package/dist/cjs/utilities/string/normalizeBaseUrlPath.js +11 -0
  64. package/dist/cjs/utilities/string/normalizeSystemPath.js +14 -0
  65. package/dist/cjs/utilities/string/processListItems.js +10 -0
  66. package/dist/cjs/utilities/string/sanitizeFilename.js +13 -0
  67. package/dist/cjs/utilities/string/slugify.js +12 -0
  68. package/dist/cjs/utilities/string/withBasePath.js +45 -0
  69. package/dist/cjs/utilities/system/createTimeout.js +11 -0
  70. package/dist/cjs/utilities/system/formatTime.js +12 -0
  71. package/dist/cjs/utilities/system/logger.js +40 -0
  72. package/dist/cjs/utilities/validation/isMobileDevice.js +8 -0
  73. package/dist/cjs/utilities/validation/isValidColor.js +182 -0
  74. package/dist/cjs/utilities/validation/isValidImageUrl.js +42 -0
  75. package/dist/cjs/utilities/validation/isValidYouTubeId.js +9 -0
  76. package/dist/cjs/utilities/validation/validateScale.js +8 -0
  77. package/dist/configs/clientConfig.d.ts.map +1 -1
  78. package/dist/configs/clientConfig.js +115 -17
  79. package/dist/configs/clientConfig.js.map +1 -1
  80. package/dist/configs/index.d.ts +1 -3
  81. package/dist/configs/index.d.ts.map +1 -1
  82. package/dist/configs/index.js +1 -3
  83. package/dist/configs/index.js.map +1 -1
  84. package/dist/configs/sstDocsConfig.browser.d.ts +8 -0
  85. package/dist/configs/sstDocsConfig.browser.d.ts.map +1 -0
  86. package/dist/configs/sstDocsConfig.browser.js +18 -0
  87. package/dist/configs/sstDocsConfig.browser.js.map +1 -0
  88. package/dist/configs/sstDocsConfig.d.ts +2 -2
  89. package/dist/configs/sstDocsConfig.d.ts.map +1 -1
  90. package/dist/configs/sstDocsConfig.js +18 -183
  91. package/dist/configs/sstDocsConfig.js.map +1 -1
  92. package/dist/configs/{sstDocsConfig.shared.d.ts → sstDocsConfigShared.d.ts} +3 -2
  93. package/dist/configs/sstDocsConfigShared.d.ts.map +1 -0
  94. package/dist/configs/sstDocsConfigShared.js +165 -0
  95. package/dist/configs/sstDocsConfigShared.js.map +1 -0
  96. package/dist/data/buildTree.d.ts +2 -14
  97. package/dist/data/buildTree.d.ts.map +1 -1
  98. package/dist/data/buildTree.js +79 -162
  99. package/dist/data/buildTree.js.map +1 -1
  100. package/dist/data/fsDataProvider.d.ts +2 -1
  101. package/dist/data/fsDataProvider.d.ts.map +1 -1
  102. package/dist/data/fsDataProvider.js +15 -3
  103. package/dist/data/fsDataProvider.js.map +1 -1
  104. package/dist/data/httpDataProvider.d.ts +2 -1
  105. package/dist/data/httpDataProvider.d.ts.map +1 -1
  106. package/dist/data/httpDataProvider.js +17 -4
  107. package/dist/data/httpDataProvider.js.map +1 -1
  108. package/dist/data/index.d.ts +2 -2
  109. package/dist/data/index.d.ts.map +1 -1
  110. package/dist/data/index.js +2 -2
  111. package/dist/data/index.js.map +1 -1
  112. package/dist/themes/index.d.ts +1 -2
  113. package/dist/themes/index.d.ts.map +1 -1
  114. package/dist/themes/index.js +1 -2
  115. package/dist/themes/index.js.map +1 -1
  116. package/dist/themes/presets/default.d.ts +3 -0
  117. package/dist/themes/presets/default.d.ts.map +1 -0
  118. package/dist/themes/presets/default.js +119 -0
  119. package/dist/themes/presets/default.js.map +1 -0
  120. package/dist/themes/themeRegistry.d.ts +3 -4
  121. package/dist/themes/themeRegistry.d.ts.map +1 -1
  122. package/dist/themes/themeRegistry.js +11 -11
  123. package/dist/themes/themeRegistry.js.map +1 -1
  124. package/dist/types/Content.d.ts +35 -18
  125. package/dist/types/Content.d.ts.map +1 -1
  126. package/dist/types/HtmlGeneratorSettings.d.ts +3 -11
  127. package/dist/types/HtmlGeneratorSettings.d.ts.map +1 -1
  128. package/dist/types/StyleTheme.d.ts +115 -131
  129. package/dist/types/StyleTheme.d.ts.map +1 -1
  130. package/dist/types/index.d.ts +1 -2
  131. package/dist/types/index.d.ts.map +1 -1
  132. package/dist/utilities/string/normalizeSystemPath.d.ts.map +1 -1
  133. package/dist/utilities/string/normalizeSystemPath.js +9 -1
  134. package/dist/utilities/string/normalizeSystemPath.js.map +1 -1
  135. package/dist/utilities/string/withBasePath.d.ts.map +1 -1
  136. package/dist/utilities/string/withBasePath.js +35 -6
  137. package/dist/utilities/string/withBasePath.js.map +1 -1
  138. package/package.json +141 -160
  139. package/dist/browser/serverOnly.d.ts +0 -15
  140. package/dist/browser/serverOnly.d.ts.map +0 -1
  141. package/dist/browser/serverOnly.js +0 -33
  142. package/dist/browser/serverOnly.js.map +0 -1
  143. package/dist/browser.d.ts +0 -38
  144. package/dist/browser.d.ts.map +0 -1
  145. package/dist/browser.js +0 -45
  146. package/dist/browser.js.map +0 -1
  147. package/dist/configs/sstDocsConfig.shared.d.ts.map +0 -1
  148. package/dist/configs/sstDocsConfig.shared.js +0 -86
  149. package/dist/configs/sstDocsConfig.shared.js.map +0 -1
  150. package/dist/configs/stylesConfig.d.ts +0 -3
  151. package/dist/configs/stylesConfig.d.ts.map +0 -1
  152. package/dist/configs/stylesConfig.js +0 -8
  153. package/dist/configs/stylesConfig.js.map +0 -1
  154. package/dist/styles/themes.css +0 -1
  155. package/dist/styles/themes.css.map +0 -1
  156. package/dist/themes/baseThemeClasses.d.ts +0 -106
  157. package/dist/themes/baseThemeClasses.d.ts.map +0 -1
  158. package/dist/themes/baseThemeClasses.js +0 -106
  159. package/dist/themes/baseThemeClasses.js.map +0 -1
  160. package/dist/themes/darkTheme.d.ts +0 -3
  161. package/dist/themes/darkTheme.d.ts.map +0 -1
  162. package/dist/themes/darkTheme.js +0 -42
  163. package/dist/themes/darkTheme.js.map +0 -1
  164. package/dist/themes/lightTheme.d.ts +0 -3
  165. package/dist/themes/lightTheme.d.ts.map +0 -1
  166. package/dist/themes/lightTheme.js +0 -42
  167. package/dist/themes/lightTheme.js.map +0 -1
  168. package/dist/types/StylesConfig.d.ts +0 -8
  169. package/dist/types/StylesConfig.d.ts.map +0 -1
  170. package/dist/types/StylesConfig.js +0 -2
  171. package/dist/types/StylesConfig.js.map +0 -1
package/README.md CHANGED
@@ -2,18 +2,16 @@
2
2
  Core runtime for the Shadow Shard Tools documentation stack. It gathers the shared themes, configuration objects, navigation helpers, typed content models, and browser-friendly utilities relied on by the site and generator projects.
3
3
 
4
4
  ## Contents
5
- - `configs`: Tailwind-friendly theme wiring plus code-language metadata (`CODE_LANGUAGE_CONFIG`, `stylesConfig`).
5
+ - `configs`: Tailwind-friendly theme wiring plus code-language metadata (`CODE_LANGUAGE_CONFIG`).
6
6
  - `data`: File-system drivers for loading doc versions, category trees, and item payloads (`loadVersions`, `loadVersionData`, `buildTree`, etc.).
7
- - `themes`: Prebuilt light/dark `StyleTheme` definitions used by the Tailwind bridge.
7
+ - `themes`: Prebuilt `StyleTheme` presets (currently `default`) used by the Tailwind bridge.
8
8
  - `types`: Source-of-truth TypeScript contracts for doc content, theme structures, and provider interfaces.
9
9
  - `utilities`: DOM, validation, string, and file helpers that the site and exporters share (e.g. `slugify`, `withBasePath`, `isValidImageUrl`).
10
10
 
11
11
  ## Usage
12
12
  ```ts
13
13
  import {
14
- darkTheme,
15
- lightTheme,
16
- stylesConfig,
14
+ defaultTheme,
17
15
  loadVersions,
18
16
  loadVersionData,
19
17
  slugify,
@@ -25,6 +23,31 @@ import {
25
23
  import { CODE_LANGUAGE_CONFIG } from "@shadow-shard-tools/docs-core/configs/index.js";
26
24
  ```
27
25
  Everything ships as native ESM with TypeScript declarations in `dist/`. Install with `npm install @shadow-shard-tools/docs-core` (or link locally) and cherry-pick the helpers and contracts you need.
26
+ CommonJS consumers can `require` the same subpaths via the conditional exports (built into `dist/cjs`).
27
+
28
+ ### Config example
29
+ Create `sst-docs.config.json` in your project root:
30
+ ```json
31
+ {
32
+ "FS_DATA_PATH": "./public/SST-Docs/data",
33
+ "HEADER_BRANDING": {
34
+ "logoText": "SST Docs"
35
+ },
36
+ "HTML_GENERATOR_SETTINGS": {
37
+ "OUTPUT_DIRECTORY": "./dist/html",
38
+ "THEME": "default",
39
+ "SEPARATE_BUILD_FOR_HTML_GENERATOR": false
40
+ }
41
+ }
42
+ ```
43
+ Load and expose a browser-friendly subset:
44
+ ```ts
45
+ import { loadSstDocsConfig, buildClientVisibleConfig, serializeClientConfigForBrowser } from "@shadow-shard-tools/docs-core/configs";
46
+
47
+ const config = await loadSstDocsConfig();
48
+ const clientConfig = buildClientVisibleConfig(config);
49
+ const script = serializeClientConfigForBrowser(clientConfig); // inject into HTML to populate window.__SST_DOCS_CONFIG__
50
+ ```
28
51
 
29
52
  ## Development
30
53
  ```bash
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CLIENT_CONFIG_GLOBAL = void 0;
4
+ exports.buildClientVisibleConfig = buildClientVisibleConfig;
5
+ exports.serializeClientConfigForBrowser = serializeClientConfigForBrowser;
6
+ exports.exposeClientConfig = exposeClientConfig;
7
+ exports.readClientConfig = readClientConfig;
8
+ exports.DEFAULT_CLIENT_CONFIG_GLOBAL = "__SST_DOCS_CONFIG__";
9
+ function buildClientVisibleConfig(config) {
10
+ return {
11
+ PUBLIC_DATA_PATH: config.PUBLIC_DATA_PATH,
12
+ HEADER_BRANDING: config.HEADER_BRANDING,
13
+ HTML_GENERATOR_THEME: config.HTML_GENERATOR_SETTINGS?.THEME,
14
+ };
15
+ }
16
+ function serializeClientConfigForBrowser(source, options) {
17
+ const payload = normalizeAndValidateClientConfigSource(source);
18
+ const globalName = options?.globalName ?? exports.DEFAULT_CLIENT_CONFIG_GLOBAL;
19
+ const spacing = options?.pretty ? 2 : undefined;
20
+ return `window.${globalName} = ${JSON.stringify(payload, null, spacing)};`;
21
+ }
22
+ function exposeClientConfig(source, options) {
23
+ const payload = normalizeAndValidateClientConfigSource(source);
24
+ const target = options?.target ??
25
+ globalThis;
26
+ if (!target) {
27
+ throw new Error("Unable to expose client config: no target global object was provided.");
28
+ }
29
+ const globalName = options?.globalName ?? exports.DEFAULT_CLIENT_CONFIG_GLOBAL;
30
+ target[globalName] = payload;
31
+ return payload;
32
+ }
33
+ function readClientConfig(globalName = exports.DEFAULT_CLIENT_CONFIG_GLOBAL) {
34
+ const globalObject = globalThis;
35
+ if (!globalObject) {
36
+ throw new Error("globalThis is not available in the current environment.");
37
+ }
38
+ const value = globalObject[globalName];
39
+ return assertClientConfig(value, globalName);
40
+ }
41
+ function normalizeAndValidateClientConfigSource(source) {
42
+ const normalized = isClientConfig(source)
43
+ ? source
44
+ : buildClientVisibleConfig(source);
45
+ return assertClientConfig(normalized);
46
+ }
47
+ function assertClientConfig(value, globalName = exports.DEFAULT_CLIENT_CONFIG_GLOBAL) {
48
+ if (!isClientConfig(value)) {
49
+ throw new Error(`Client config "${globalName}" is missing or malformed on globalThis.`);
50
+ }
51
+ return value;
52
+ }
53
+ function isClientConfig(value) {
54
+ if (!value || typeof value !== "object") {
55
+ return false;
56
+ }
57
+ const candidate = value;
58
+ const hasPublicPath = typeof candidate.PUBLIC_DATA_PATH === "string";
59
+ const hasBranding = isHeaderBranding(candidate.HEADER_BRANDING);
60
+ const hasTheme = candidate.HTML_GENERATOR_THEME === undefined ||
61
+ isStyleTheme(candidate.HTML_GENERATOR_THEME);
62
+ return hasPublicPath && hasBranding && hasTheme;
63
+ }
64
+ function isHeaderBranding(value) {
65
+ if (value === undefined)
66
+ return true;
67
+ if (!value || typeof value !== "object")
68
+ return false;
69
+ const record = value;
70
+ return (["logoSrc", "logoAlt", "logoText"].every((key) => key in record ? typeof record[key] === "string" || record[key] === undefined : true));
71
+ }
72
+ function isStyleTheme(value) {
73
+ if (!value || typeof value !== "object")
74
+ return false;
75
+ const theme = value;
76
+ const stringProps = (obj, keys) => !!obj &&
77
+ typeof obj === "object" &&
78
+ keys.every((k) => typeof obj[k] === "string");
79
+ return (typeof theme.input === "string" &&
80
+ stringProps(theme.text, [
81
+ "logoText",
82
+ "documentTitle",
83
+ "breadcrumb",
84
+ "titleLevel1",
85
+ "titleLevel2",
86
+ "titleLevel3",
87
+ "titleAnchor",
88
+ "general",
89
+ "alternative",
90
+ "list",
91
+ "math",
92
+ ]) &&
93
+ stringProps(theme.hints, ["text", "key"]) &&
94
+ stringProps(theme.divider, ["border", "gradient", "text"]) &&
95
+ stringProps(theme.buttons, ["common", "small", "tabSmall", "tabSmallActive"]) &&
96
+ stringProps(theme.dropdown, ["container", "item", "itemActive"]) &&
97
+ stringProps(theme.messageBox, [
98
+ "info",
99
+ "warning",
100
+ "error",
101
+ "success",
102
+ "neutral",
103
+ "quote",
104
+ ]) &&
105
+ stringProps(theme.table, ["cornerCell", "headers", "rows", "border", "empty"]) &&
106
+ stringProps(theme.code, ["header", "language", "lines", "empty"]) &&
107
+ stringProps(theme.audioPlayer, [
108
+ "container",
109
+ "playButton",
110
+ "time",
111
+ "slider",
112
+ "sliderThumb",
113
+ "sliderTrackColor",
114
+ "sliderFillColor",
115
+ ]) &&
116
+ stringProps(theme.chart, [
117
+ "legendLabelColor",
118
+ "tooltipBg",
119
+ "tooltipTitleColor",
120
+ "tooltipBodyColor",
121
+ "tooltipBorderColor",
122
+ "axisTickColor",
123
+ "gridLineColor",
124
+ ]) &&
125
+ stringProps(theme.graph, ["background", "defaultCurve"]) &&
126
+ stringProps(theme.searchModal, [
127
+ "resultBackground",
128
+ "resultEmptyInputText",
129
+ "resultNoResultText",
130
+ "header",
131
+ "footer",
132
+ "borders",
133
+ "item",
134
+ "selectedItem",
135
+ "itemHeaderText",
136
+ "itemFoundSectionText",
137
+ "itemTags",
138
+ ]) &&
139
+ stringProps(theme.navigation, [
140
+ "row",
141
+ "rowActive",
142
+ "rowFocused",
143
+ "rowHover",
144
+ "hideOrShowHintsText",
145
+ ]) &&
146
+ stringProps(theme.category, [
147
+ "empty",
148
+ "cardBody",
149
+ "cardHeaderText",
150
+ "cardDescriptionText",
151
+ ]) &&
152
+ stringProps(theme.sections, [
153
+ "siteBackground",
154
+ "siteBorders",
155
+ "headerBackground",
156
+ "headerMobileBackground",
157
+ "sidebarBackground",
158
+ "documentHeaderBackground",
159
+ "contentBackground",
160
+ ]) &&
161
+ stringProps(theme.header, ["mobileNavigationToggle", "mobileMenuToggle"]));
162
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CODE_LANGUAGE_CONFIG = void 0;
4
+ exports.CODE_LANGUAGE_CONFIG = {
5
+ javascript: { name: "JavaScript", ext: "js" },
6
+ typescript: { name: "TypeScript", ext: "ts" },
7
+ python: { name: "Python", ext: "py" },
8
+ java: { name: "Java", ext: "java" },
9
+ csharp: { name: "C#", ext: "cs" },
10
+ cpp: { name: "C++", ext: "cpp" },
11
+ c: { name: "C", ext: "c" },
12
+ php: { name: "PHP", ext: "php" },
13
+ ruby: { name: "Ruby", ext: "rb" },
14
+ go: { name: "Go", ext: "go" },
15
+ rust: { name: "Rust", ext: "rs" },
16
+ swift: { name: "Swift", ext: "swift" },
17
+ kotlin: { name: "Kotlin", ext: "kt" },
18
+ scala: { name: "Scala", ext: "scala" },
19
+ html: { name: "HTML", ext: "html" },
20
+ css: { name: "CSS", ext: "css" },
21
+ scss: { name: "SCSS", ext: "scss" },
22
+ sass: { name: "Sass", ext: "sass" },
23
+ less: { name: "Less", ext: "less" },
24
+ json: { name: "JSON", ext: "json" },
25
+ xml: { name: "XML", ext: "xml" },
26
+ yaml: { name: "YAML", ext: "yml" },
27
+ toml: { name: "TOML", ext: "toml" },
28
+ sql: { name: "SQL", ext: "sql" },
29
+ bash: { name: "Bash", ext: "sh" },
30
+ powershell: { name: "PowerShell", ext: "ps1" },
31
+ dockerfile: { name: "Dockerfile", ext: "dockerfile" },
32
+ markdown: { name: "Markdown", ext: "md" },
33
+ latex: { name: "LaTeX", ext: "tex" },
34
+ plaintext: { name: "Plain Text", ext: "txt" },
35
+ text: { name: "Text", ext: "txt" },
36
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeClientConfigForBrowser = exports.readClientConfig = exports.exposeClientConfig = exports.DEFAULT_CLIENT_CONFIG_GLOBAL = exports.buildClientVisibleConfig = exports.SST_DOCS_CONFIG_FILENAME = exports.SstDocsConfigError = exports.resolvePublicDataPath = exports.derivePublicDataPath = exports.loadSstDocsConfigFromSync = exports.loadSstDocsConfigSync = exports.loadSstDocsConfigFrom = exports.loadSstDocsConfig = exports.CODE_LANGUAGE_CONFIG = void 0;
4
+ var codeLanguagesConfig_js_1 = require("./codeLanguagesConfig.js");
5
+ Object.defineProperty(exports, "CODE_LANGUAGE_CONFIG", { enumerable: true, get: function () { return codeLanguagesConfig_js_1.CODE_LANGUAGE_CONFIG; } });
6
+ var sstDocsConfig_js_1 = require("./sstDocsConfig.js");
7
+ Object.defineProperty(exports, "loadSstDocsConfig", { enumerable: true, get: function () { return sstDocsConfig_js_1.loadSstDocsConfig; } });
8
+ Object.defineProperty(exports, "loadSstDocsConfigFrom", { enumerable: true, get: function () { return sstDocsConfig_js_1.loadSstDocsConfigFrom; } });
9
+ Object.defineProperty(exports, "loadSstDocsConfigSync", { enumerable: true, get: function () { return sstDocsConfig_js_1.loadSstDocsConfigSync; } });
10
+ Object.defineProperty(exports, "loadSstDocsConfigFromSync", { enumerable: true, get: function () { return sstDocsConfig_js_1.loadSstDocsConfigFromSync; } });
11
+ Object.defineProperty(exports, "derivePublicDataPath", { enumerable: true, get: function () { return sstDocsConfig_js_1.derivePublicDataPath; } });
12
+ Object.defineProperty(exports, "resolvePublicDataPath", { enumerable: true, get: function () { return sstDocsConfig_js_1.resolvePublicDataPath; } });
13
+ Object.defineProperty(exports, "SstDocsConfigError", { enumerable: true, get: function () { return sstDocsConfig_js_1.SstDocsConfigError; } });
14
+ Object.defineProperty(exports, "SST_DOCS_CONFIG_FILENAME", { enumerable: true, get: function () { return sstDocsConfig_js_1.SST_DOCS_CONFIG_FILENAME; } });
15
+ var clientConfig_js_1 = require("./clientConfig.js");
16
+ Object.defineProperty(exports, "buildClientVisibleConfig", { enumerable: true, get: function () { return clientConfig_js_1.buildClientVisibleConfig; } });
17
+ Object.defineProperty(exports, "DEFAULT_CLIENT_CONFIG_GLOBAL", { enumerable: true, get: function () { return clientConfig_js_1.DEFAULT_CLIENT_CONFIG_GLOBAL; } });
18
+ Object.defineProperty(exports, "exposeClientConfig", { enumerable: true, get: function () { return clientConfig_js_1.exposeClientConfig; } });
19
+ Object.defineProperty(exports, "readClientConfig", { enumerable: true, get: function () { return clientConfig_js_1.readClientConfig; } });
20
+ Object.defineProperty(exports, "serializeClientConfigForBrowser", { enumerable: true, get: function () { return clientConfig_js_1.serializeClientConfigForBrowser; } });
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SstDocsConfigError = exports.SST_DOCS_CONFIG_FILENAME = exports.resolvePublicDataPath = exports.derivePublicDataPath = void 0;
4
+ exports.loadSstDocsConfig = loadSstDocsConfig;
5
+ exports.loadSstDocsConfigSync = loadSstDocsConfigSync;
6
+ exports.loadSstDocsConfigFrom = loadSstDocsConfigFrom;
7
+ exports.loadSstDocsConfigFromSync = loadSstDocsConfigFromSync;
8
+ const sstDocsConfigShared_js_1 = require("./sstDocsConfigShared.js");
9
+ Object.defineProperty(exports, "derivePublicDataPath", { enumerable: true, get: function () { return sstDocsConfigShared_js_1.derivePublicDataPath; } });
10
+ Object.defineProperty(exports, "resolvePublicDataPath", { enumerable: true, get: function () { return sstDocsConfigShared_js_1.resolvePublicDataPath; } });
11
+ Object.defineProperty(exports, "SST_DOCS_CONFIG_FILENAME", { enumerable: true, get: function () { return sstDocsConfigShared_js_1.SST_DOCS_CONFIG_FILENAME; } });
12
+ Object.defineProperty(exports, "SstDocsConfigError", { enumerable: true, get: function () { return sstDocsConfigShared_js_1.SstDocsConfigError; } });
13
+ function unsupported(method) {
14
+ throw new sstDocsConfigShared_js_1.SstDocsConfigError(`${method} is only available in a Node.js environment where the file system can be read.`);
15
+ }
16
+ async function loadSstDocsConfig(_configPath) {
17
+ return unsupported("loadSstDocsConfig");
18
+ }
19
+ function loadSstDocsConfigSync(_configPath) {
20
+ return unsupported("loadSstDocsConfigSync");
21
+ }
22
+ async function loadSstDocsConfigFrom(_configDir) {
23
+ return unsupported("loadSstDocsConfigFrom");
24
+ }
25
+ function loadSstDocsConfigFromSync(_configDir) {
26
+ return unsupported("loadSstDocsConfigFromSync");
27
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SstDocsConfigError = exports.SST_DOCS_CONFIG_FILENAME = exports.resolvePublicDataPath = exports.derivePublicDataPath = void 0;
7
+ exports.loadSstDocsConfig = loadSstDocsConfig;
8
+ exports.loadSstDocsConfigSync = loadSstDocsConfigSync;
9
+ exports.loadSstDocsConfigFrom = loadSstDocsConfigFrom;
10
+ exports.loadSstDocsConfigFromSync = loadSstDocsConfigFromSync;
11
+ const node_fs_1 = require("node:fs");
12
+ const promises_1 = require("node:fs/promises");
13
+ const node_path_1 = require("node:path");
14
+ const app_root_path_1 = __importDefault(require("app-root-path"));
15
+ const sstDocsConfigShared_js_1 = require("./sstDocsConfigShared.js");
16
+ Object.defineProperty(exports, "derivePublicDataPath", { enumerable: true, get: function () { return sstDocsConfigShared_js_1.derivePublicDataPath; } });
17
+ Object.defineProperty(exports, "resolvePublicDataPath", { enumerable: true, get: function () { return sstDocsConfigShared_js_1.resolvePublicDataPath; } });
18
+ Object.defineProperty(exports, "SST_DOCS_CONFIG_FILENAME", { enumerable: true, get: function () { return sstDocsConfigShared_js_1.SST_DOCS_CONFIG_FILENAME; } });
19
+ Object.defineProperty(exports, "SstDocsConfigError", { enumerable: true, get: function () { return sstDocsConfigShared_js_1.SstDocsConfigError; } });
20
+ const APP_ROOT = app_root_path_1.default.path;
21
+ async function loadSstDocsConfig(configPath) {
22
+ const { path: finalPath, contents } = await readConfigFile(configPath);
23
+ return (0, sstDocsConfigShared_js_1.parseConfigContents)(contents, finalPath);
24
+ }
25
+ function loadSstDocsConfigSync(configPath) {
26
+ const { path: finalPath, contents } = readConfigFileSync(configPath);
27
+ return (0, sstDocsConfigShared_js_1.parseConfigContents)(contents, finalPath);
28
+ }
29
+ async function loadSstDocsConfigFrom(configDir) {
30
+ const fullPath = (0, node_path_1.resolve)(configDir, sstDocsConfigShared_js_1.SST_DOCS_CONFIG_FILENAME);
31
+ return loadSstDocsConfig(fullPath);
32
+ }
33
+ function loadSstDocsConfigFromSync(configDir) {
34
+ const fullPath = (0, node_path_1.resolve)(configDir, sstDocsConfigShared_js_1.SST_DOCS_CONFIG_FILENAME);
35
+ return loadSstDocsConfigSync(fullPath);
36
+ }
37
+ async function readConfigFile(configPath) {
38
+ const searchPaths = getConfigSearchPaths(configPath);
39
+ const attempted = [];
40
+ for (const candidate of searchPaths) {
41
+ attempted.push(candidate);
42
+ try {
43
+ const contents = await (0, promises_1.readFile)(candidate, "utf-8");
44
+ return { path: candidate, contents };
45
+ }
46
+ catch (error) {
47
+ const err = error;
48
+ if (err.code === "ENOENT" || err.code === "EISDIR") {
49
+ continue;
50
+ }
51
+ throw new sstDocsConfigShared_js_1.SstDocsConfigError(`Failed to read ${sstDocsConfigShared_js_1.SST_DOCS_CONFIG_FILENAME} at ${candidate}: ${err.message}`);
52
+ }
53
+ }
54
+ throw new sstDocsConfigShared_js_1.SstDocsConfigError(`Unable to locate ${sstDocsConfigShared_js_1.SST_DOCS_CONFIG_FILENAME}. Tried: ${attempted.join(", ")}`);
55
+ }
56
+ function readConfigFileSync(configPath) {
57
+ const searchPaths = getConfigSearchPaths(configPath);
58
+ const attempted = [];
59
+ for (const candidate of searchPaths) {
60
+ attempted.push(candidate);
61
+ try {
62
+ const contents = (0, node_fs_1.readFileSync)(candidate, "utf-8");
63
+ return { path: candidate, contents };
64
+ }
65
+ catch (error) {
66
+ const err = error;
67
+ if (err.code === "ENOENT" || err.code === "EISDIR") {
68
+ continue;
69
+ }
70
+ throw new sstDocsConfigShared_js_1.SstDocsConfigError(`Failed to read ${sstDocsConfigShared_js_1.SST_DOCS_CONFIG_FILENAME} at ${candidate}: ${err.message}`);
71
+ }
72
+ }
73
+ throw new sstDocsConfigShared_js_1.SstDocsConfigError(`Unable to locate ${sstDocsConfigShared_js_1.SST_DOCS_CONFIG_FILENAME}. Tried: ${attempted.join(", ")}`);
74
+ }
75
+ function getConfigSearchPaths(configPath) {
76
+ const searchPaths = [];
77
+ if (configPath) {
78
+ const explicit = (0, node_path_1.resolve)(APP_ROOT, configPath);
79
+ searchPaths.push(explicit);
80
+ if (!explicit.endsWith(".json")) {
81
+ searchPaths.push((0, node_path_1.resolve)(explicit, sstDocsConfigShared_js_1.SST_DOCS_CONFIG_FILENAME));
82
+ }
83
+ }
84
+ else {
85
+ searchPaths.push((0, node_path_1.resolve)(APP_ROOT, sstDocsConfigShared_js_1.SST_DOCS_CONFIG_FILENAME));
86
+ }
87
+ return searchPaths;
88
+ }
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SstDocsConfigError = exports.SST_DOCS_CONFIG_FILENAME = void 0;
7
+ exports.parseConfigContents = parseConfigContents;
8
+ exports.derivePublicDataPath = derivePublicDataPath;
9
+ exports.resolvePublicDataPath = resolvePublicDataPath;
10
+ const themeRegistry_js_1 = require("../themes/themeRegistry.js");
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const normalizeSystemPath_js_1 = require("../utilities/string/normalizeSystemPath.js");
13
+ exports.SST_DOCS_CONFIG_FILENAME = "sst-docs.config.json";
14
+ class SstDocsConfigError extends Error {
15
+ constructor(message) {
16
+ super(message);
17
+ this.name = "SstDocsConfigError";
18
+ }
19
+ }
20
+ exports.SstDocsConfigError = SstDocsConfigError;
21
+ function parseConfigContents(contents, sourcePath) {
22
+ let parsed;
23
+ try {
24
+ parsed = JSON.parse(contents);
25
+ }
26
+ catch (error) {
27
+ throw new SstDocsConfigError(`Failed to parse ${exports.SST_DOCS_CONFIG_FILENAME}: ${error.message}`);
28
+ }
29
+ return normalizeConfig(parsed, sourcePath);
30
+ }
31
+ function derivePublicDataPath(fsDataPath) {
32
+ const normalizedFsPath = (0, normalizeSystemPath_js_1.normalizeSystemPath)(fsDataPath.trim());
33
+ const posixPath = node_path_1.default.posix.normalize(normalizedFsPath || "/");
34
+ const segments = posixPath.split("/").filter(Boolean);
35
+ const publicIndex = segments.indexOf("public");
36
+ const publicSegments = publicIndex >= 0 ? segments.slice(publicIndex + 1) : segments;
37
+ if (publicSegments.length === 0) {
38
+ return "/";
39
+ }
40
+ const joined = `/${publicSegments.join("/")}`;
41
+ return joined.endsWith("/") ? joined : `${joined}/`;
42
+ }
43
+ function resolvePublicDataPath(baseUrl, config) {
44
+ const publicPath = typeof config === "string" ? config : config.PUBLIC_DATA_PATH;
45
+ const normalizedPublicPath = normalizePublicPath(publicPath);
46
+ if (!baseUrl || baseUrl.trim().length === 0) {
47
+ return normalizedPublicPath;
48
+ }
49
+ if (isAbsoluteUrl(baseUrl)) {
50
+ const url = new URL(baseUrl);
51
+ url.pathname = joinUrlPaths(url.pathname || "/", normalizedPublicPath);
52
+ return url.toString();
53
+ }
54
+ const parsedBase = new URL(baseUrl, "http://local.placeholder");
55
+ const joinedPath = joinUrlPaths(parsedBase.pathname || "/", normalizedPublicPath);
56
+ return `${joinedPath}${parsedBase.search}${parsedBase.hash}`;
57
+ }
58
+ function normalizePublicPath(value) {
59
+ const normalized = (0, normalizeSystemPath_js_1.normalizeSystemPath)(value.trim());
60
+ const posixPath = node_path_1.default.posix.normalize(normalized || "/");
61
+ const withLeading = posixPath.startsWith("/") ? posixPath : `/${posixPath}`;
62
+ return withLeading.endsWith("/") ? withLeading : `${withLeading}/`;
63
+ }
64
+ function joinUrlPaths(base, child) {
65
+ const normalizedBase = normalizePublicPath(base);
66
+ const normalizedChild = normalizePublicPath(child).replace(/^\/+/, "");
67
+ const joined = node_path_1.default.posix.join(normalizedBase, normalizedChild);
68
+ return joined.endsWith("/") ? joined : `${joined}/`;
69
+ }
70
+ function isAbsoluteUrl(value) {
71
+ try {
72
+ new URL(value);
73
+ return true;
74
+ }
75
+ catch {
76
+ return false;
77
+ }
78
+ }
79
+ function normalizeConfig(value, sourcePath) {
80
+ if (!value || typeof value !== "object") {
81
+ throw new SstDocsConfigError(`Invalid configuration in ${sourcePath}: expected an object`);
82
+ }
83
+ const raw = value;
84
+ if (typeof raw.FS_DATA_PATH !== "string") {
85
+ throw new SstDocsConfigError(`Missing or invalid FS_DATA_PATH in ${sourcePath}`);
86
+ }
87
+ const fsDataPath = (0, normalizeSystemPath_js_1.normalizeSystemPath)(raw.FS_DATA_PATH.trim());
88
+ if (fsDataPath.length === 0) {
89
+ throw new SstDocsConfigError(`FS_DATA_PATH cannot be empty in ${sourcePath}`);
90
+ }
91
+ return {
92
+ FS_DATA_PATH: fsDataPath,
93
+ PUBLIC_DATA_PATH: derivePublicDataPath(fsDataPath),
94
+ HEADER_BRANDING: normalizeHeaderBranding(raw.HEADER_BRANDING, sourcePath),
95
+ HTML_GENERATOR_SETTINGS: normalizeHtmlGeneratorSettings(raw.HTML_GENERATOR_SETTINGS, sourcePath),
96
+ };
97
+ }
98
+ function normalizeHeaderBranding(value, sourcePath) {
99
+ if (value === undefined) {
100
+ return {};
101
+ }
102
+ if (!value || typeof value !== "object") {
103
+ throw new SstDocsConfigError(`HEADER_BRANDING must be an object in ${sourcePath}`);
104
+ }
105
+ const { logoSrc, logoAlt, logoText } = value;
106
+ return {
107
+ logoSrc: normalizeOptionalString(logoSrc, "logoSrc", sourcePath),
108
+ logoAlt: normalizeOptionalString(logoAlt, "logoAlt", sourcePath),
109
+ logoText: normalizeOptionalString(logoText, "logoText", sourcePath),
110
+ };
111
+ }
112
+ function normalizeOptionalString(value, key, sourcePath) {
113
+ if (value === undefined || value === null)
114
+ return undefined;
115
+ if (typeof value !== "string") {
116
+ throw new SstDocsConfigError(`HEADER_BRANDING.${key} must be a string in ${sourcePath}`);
117
+ }
118
+ const trimmed = value.trim();
119
+ return trimmed.length > 0 ? trimmed : undefined;
120
+ }
121
+ function normalizeHtmlGeneratorSettings(value, sourcePath) {
122
+ if (value === undefined) {
123
+ return undefined;
124
+ }
125
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
126
+ throw new SstDocsConfigError(`HTML_GENERATOR_SETTINGS must be an object in ${sourcePath}`);
127
+ }
128
+ const { OUTPUT_DIRECTORY, THEME, SEPARATE_BUILD_FOR_HTML_GENERATOR, } = value;
129
+ if (typeof OUTPUT_DIRECTORY !== "string") {
130
+ throw new SstDocsConfigError(`HTML_GENERATOR_SETTINGS.OUTPUT_DIRECTORY must be a string in ${sourcePath}`);
131
+ }
132
+ const outputDirectory = (0, normalizeSystemPath_js_1.normalizeSystemPath)(OUTPUT_DIRECTORY.trim());
133
+ if (outputDirectory.length === 0) {
134
+ throw new SstDocsConfigError(`HTML_GENERATOR_SETTINGS.OUTPUT_DIRECTORY cannot be empty in ${sourcePath}`);
135
+ }
136
+ if (THEME === undefined) {
137
+ throw new SstDocsConfigError(`HTML_GENERATOR_SETTINGS.THEME must be provided in ${sourcePath}`);
138
+ }
139
+ if (SEPARATE_BUILD_FOR_HTML_GENERATOR !== undefined &&
140
+ typeof SEPARATE_BUILD_FOR_HTML_GENERATOR !== "boolean") {
141
+ throw new SstDocsConfigError(`HTML_GENERATOR_SETTINGS.SEPARATE_BUILD_FOR_HTML_GENERATOR must be a boolean in ${sourcePath}`);
142
+ }
143
+ const resolvedTheme = resolveThemeConfiguration(THEME, sourcePath);
144
+ return {
145
+ OUTPUT_DIRECTORY: outputDirectory,
146
+ THEME: resolvedTheme,
147
+ SEPARATE_BUILD_FOR_HTML_GENERATOR: SEPARATE_BUILD_FOR_HTML_GENERATOR ?? false,
148
+ };
149
+ }
150
+ function resolveThemeConfiguration(value, sourcePath) {
151
+ if (typeof value !== "string") {
152
+ throw new SstDocsConfigError(`HTML_GENERATOR_SETTINGS.THEME must be a string preset in ${sourcePath}`);
153
+ }
154
+ const themeName = ensureThemePresetName(value, sourcePath, "HTML_GENERATOR_SETTINGS.THEME");
155
+ return cloneTheme((0, themeRegistry_js_1.getThemePreset)(themeName));
156
+ }
157
+ function ensureThemePresetName(raw, sourcePath, propertyPath) {
158
+ if (raw === undefined || raw === null) {
159
+ return themeRegistry_js_1.DEFAULT_THEME_PRESET;
160
+ }
161
+ if (typeof raw !== "string") {
162
+ const options = themeRegistry_js_1.AVAILABLE_THEME_PRESET_NAMES.join(", ");
163
+ throw new SstDocsConfigError(`${propertyPath} must be one of: ${options} in ${sourcePath}`);
164
+ }
165
+ const normalized = raw.trim().toLowerCase();
166
+ if (!(0, themeRegistry_js_1.isThemePresetName)(normalized)) {
167
+ const options = themeRegistry_js_1.AVAILABLE_THEME_PRESET_NAMES.join(", ");
168
+ throw new SstDocsConfigError(`Unknown ${propertyPath} "${raw}" in ${sourcePath}. Supported presets: ${options}`);
169
+ }
170
+ return normalized;
171
+ }
172
+ function cloneTheme(theme) {
173
+ return JSON.parse(JSON.stringify(theme));
174
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ALIGNMENT_CLASSES = void 0;
4
+ exports.ALIGNMENT_CLASSES = {
5
+ left: {
6
+ text: "text-left",
7
+ container: "mr-auto",
8
+ },
9
+ center: {
10
+ text: "text-center",
11
+ container: "mx-auto",
12
+ },
13
+ right: {
14
+ text: "text-right",
15
+ container: "ml-auto",
16
+ },
17
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SPACING_CLASSES = exports.ALIGNMENT_CLASSES = void 0;
4
+ var alignmentClasses_js_1 = require("./alignmentClasses.js");
5
+ Object.defineProperty(exports, "ALIGNMENT_CLASSES", { enumerable: true, get: function () { return alignmentClasses_js_1.ALIGNMENT_CLASSES; } });
6
+ var spacingClasses_js_1 = require("./spacingClasses.js");
7
+ Object.defineProperty(exports, "SPACING_CLASSES", { enumerable: true, get: function () { return spacingClasses_js_1.SPACING_CLASSES; } });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SPACING_CLASSES = void 0;
4
+ exports.SPACING_CLASSES = {
5
+ none: "",
6
+ small: "mb-4",
7
+ medium: "mb-6",
8
+ large: "mb-8",
9
+ };