@brandon_m_behring/book-scaffold-astro 3.0.0-alpha.9 → 3.0.1

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.
@@ -12,7 +12,7 @@
12
12
  * pedagogy of Appendix D — the archive is intentionally sparse in the
13
13
  * early book, and the gap is visible by design.
14
14
  */
15
- import { sourceTiers } from '../content.config';
15
+ import { sourceTiers } from '@brandon_m_behring/book-scaffold-astro';
16
16
  import {
17
17
  getSourcesByTier,
18
18
  TIER_LABELS,
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AstroUserConfig, AstroIntegration } from 'astro';
2
- import { b as BookConfigOptions, d as BookScaffoldIntegrationOptions } from './types-Cz-pwE1N.js';
3
- export { B as BOOK_PROFILES, a as BookConfigError, c as BookProfile, e as BookSchemasOptions, r as resolveProfile } from './types-Cz-pwE1N.js';
2
+ import { b as BookConfigOptions, d as BookScaffoldIntegrationOptions } from './types-BoCXCvBy.js';
3
+ export { B as BOOK_PROFILES, a as BookConfigError, c as BookProfile, e as BookSchemasOptions, r as resolveProfile } from './types-BoCXCvBy.js';
4
4
  import { z } from 'astro/zod';
5
5
 
6
6
  declare function defineBookConfig(opts: BookConfigOptions): Promise<AstroUserConfig>;
package/dist/index.mjs CHANGED
@@ -119,6 +119,7 @@ import mdx from "@astrojs/mdx";
119
119
  import preact from "@astrojs/preact";
120
120
 
121
121
  // src/types.ts
122
+ import { existsSync, readFileSync } from "fs";
122
123
  var BOOK_PROFILES = ["academic", "tools", "minimal"];
123
124
  var BookConfigError = class extends Error {
124
125
  constructor(message) {
@@ -126,14 +127,43 @@ var BookConfigError = class extends Error {
126
127
  this.name = "BookConfigError";
127
128
  }
128
129
  };
130
+ function readEnvFile(path = ".env") {
131
+ try {
132
+ if (!existsSync(path)) return {};
133
+ const out = {};
134
+ for (const line of readFileSync(path, "utf8").split(/\r?\n/)) {
135
+ const m = line.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*?)\s*$/);
136
+ if (!m) continue;
137
+ let val = m[2] ?? "";
138
+ if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
139
+ val = val.slice(1, -1);
140
+ }
141
+ out[m[1]] = val;
142
+ }
143
+ return out;
144
+ } catch {
145
+ return {};
146
+ }
147
+ }
129
148
  function resolveProfile(explicit) {
130
- const candidate = explicit ?? process.env.BOOK_PROFILE ?? "minimal";
149
+ let candidate = explicit ?? process.env.BOOK_PROFILE;
150
+ let source = "default";
151
+ if (explicit) source = "param";
152
+ else if (process.env.BOOK_PROFILE) source = "env";
153
+ if (!candidate) {
154
+ const fromFile = readEnvFile().BOOK_PROFILE;
155
+ if (fromFile) {
156
+ candidate = fromFile;
157
+ source = "dotenv";
158
+ }
159
+ }
160
+ candidate = candidate ?? "minimal";
131
161
  if (!BOOK_PROFILES.includes(candidate)) {
132
162
  throw new BookConfigError(
133
163
  `profile must be one of ${BOOK_PROFILES.join(" | ")} (got ${JSON.stringify(candidate)})`
134
164
  );
135
165
  }
136
- if (!explicit && !process.env.BOOK_PROFILE) {
166
+ if (source === "default") {
137
167
  console.warn("book-scaffold-astro: BOOK_PROFILE not set; falling back to 'minimal'.");
138
168
  }
139
169
  return candidate;
@@ -194,8 +224,14 @@ async function defineBookConfig(opts) {
194
224
  const remarkPlugins = [];
195
225
  const rehypePlugins = [];
196
226
  if (profile === "academic") {
197
- const { default: remarkMath } = await import("remark-math");
198
- const { default: rehypeKatex } = await import("rehype-katex");
227
+ const { default: remarkMath } = await import(
228
+ /* @vite-ignore */
229
+ "remark-math"
230
+ );
231
+ const { default: rehypeKatex } = await import(
232
+ /* @vite-ignore */
233
+ "rehype-katex"
234
+ );
199
235
  const { ssmMacros: ssmMacros2 } = await Promise.resolve().then(() => (init_katex_macros(), katex_macros_exports));
200
236
  remarkPlugins.push(remarkMath);
201
237
  rehypePlugins.push([
@@ -240,10 +276,19 @@ async function defineBookConfig(opts) {
240
276
  void _extraIntegrations;
241
277
  void _extraStyles;
242
278
  void _markdown;
279
+ const katexExternals = profile === "academic" ? [] : ["remark-math", "rehype-katex", "katex"];
243
280
  const config = {
244
281
  ...rest,
245
282
  integrations,
246
- markdown
283
+ markdown,
284
+ vite: {
285
+ build: {
286
+ rollupOptions: {
287
+ external: katexExternals
288
+ }
289
+ },
290
+ ...rest.vite ?? {}
291
+ }
247
292
  };
248
293
  return config;
249
294
  }
package/dist/schemas.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { e as BookSchemasOptions } from './types-Cz-pwE1N.js';
1
+ import { e as BookSchemasOptions } from './types-BoCXCvBy.js';
2
2
  import 'astro';
3
3
 
4
4
  /**
package/dist/schemas.mjs CHANGED
@@ -1,9 +1,10 @@
1
1
  // src/schemas-entry.ts
2
- import { existsSync } from "fs";
2
+ import { existsSync as existsSync2 } from "fs";
3
3
  import { defineCollection } from "astro:content";
4
4
  import { glob, file } from "astro/loaders";
5
5
 
6
6
  // src/types.ts
7
+ import { existsSync, readFileSync } from "fs";
7
8
  var BOOK_PROFILES = ["academic", "tools", "minimal"];
8
9
  var BookConfigError = class extends Error {
9
10
  constructor(message) {
@@ -11,14 +12,43 @@ var BookConfigError = class extends Error {
11
12
  this.name = "BookConfigError";
12
13
  }
13
14
  };
15
+ function readEnvFile(path = ".env") {
16
+ try {
17
+ if (!existsSync(path)) return {};
18
+ const out = {};
19
+ for (const line of readFileSync(path, "utf8").split(/\r?\n/)) {
20
+ const m = line.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*?)\s*$/);
21
+ if (!m) continue;
22
+ let val = m[2] ?? "";
23
+ if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
24
+ val = val.slice(1, -1);
25
+ }
26
+ out[m[1]] = val;
27
+ }
28
+ return out;
29
+ } catch {
30
+ return {};
31
+ }
32
+ }
14
33
  function resolveProfile(explicit) {
15
- const candidate = explicit ?? process.env.BOOK_PROFILE ?? "minimal";
34
+ let candidate = explicit ?? process.env.BOOK_PROFILE;
35
+ let source = "default";
36
+ if (explicit) source = "param";
37
+ else if (process.env.BOOK_PROFILE) source = "env";
38
+ if (!candidate) {
39
+ const fromFile = readEnvFile().BOOK_PROFILE;
40
+ if (fromFile) {
41
+ candidate = fromFile;
42
+ source = "dotenv";
43
+ }
44
+ }
45
+ candidate = candidate ?? "minimal";
16
46
  if (!BOOK_PROFILES.includes(candidate)) {
17
47
  throw new BookConfigError(
18
48
  `profile must be one of ${BOOK_PROFILES.join(" | ")} (got ${JSON.stringify(candidate)})`
19
49
  );
20
50
  }
21
- if (!explicit && !process.env.BOOK_PROFILE) {
51
+ if (source === "default") {
22
52
  console.warn("book-scaffold-astro: BOOK_PROFILE not set; falling back to 'minimal'.");
23
53
  }
24
54
  return candidate;
@@ -143,19 +173,19 @@ function defineBookSchemas(opts = {}) {
143
173
  const collections = {
144
174
  chapters
145
175
  };
146
- if (existsSync("./sources/manifest.yaml")) {
176
+ if (existsSync2("./sources/manifest.yaml")) {
147
177
  collections.sources = defineCollection({
148
178
  loader: file("sources/manifest.yaml"),
149
179
  schema: sourcesSchema
150
180
  });
151
181
  }
152
- if (existsSync("./changelog/tools")) {
182
+ if (existsSync2("./changelog/tools")) {
153
183
  collections.changelog = defineCollection({
154
184
  loader: glob({ pattern: "*.yaml", base: "./changelog/tools" }),
155
185
  schema: changelogSchema
156
186
  });
157
187
  }
158
- if (existsSync("./changelog/patterns.yaml")) {
188
+ if (existsSync2("./changelog/patterns.yaml")) {
159
189
  collections.patterns = defineCollection({
160
190
  loader: file("changelog/patterns.yaml"),
161
191
  schema: patternsSchema
@@ -42,8 +42,13 @@ import '../styles/chapter.css';
42
42
  import '../styles/tool-filter.css';
43
43
  import '../styles/convergence.css';
44
44
  import '../styles/print.css';
45
- import VersionSelector from '../components/VersionSelector';
46
- import ToolFilter from '../components/ToolFilter';
45
+ // Use package-path imports for the .tsx islands so Vite resolves them
46
+ // via the exports map (→ pre-compiled dist/components/*.mjs with proper
47
+ // preact JSX). The raw .tsx files are also shipped so consumers can
48
+ // import them directly, but relative imports from inside the package
49
+ // must route through the exports map, not the raw source.
50
+ import VersionSelector from '@brandon_m_behring/book-scaffold-astro/components/VersionSelector';
51
+ import ToolFilter from '@brandon_m_behring/book-scaffold-astro/components/ToolFilter';
47
52
  import Sidebar from '../components/Sidebar.astro';
48
53
 
49
54
  const profile = import.meta.env.BOOK_PROFILE ?? 'minimal';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@brandon_m_behring/book-scaffold-astro",
3
3
  "description": "Astro 6 + MDX toolkit for long-form technical books. Profile-aware (academic / tools / minimal); ships Tufte typography, KaTeX, BibTeX citations, Pagefind, Cloudflare Workers deploy. See PACKAGE_DESIGN.md for the API contract.",
4
- "version": "3.0.0-alpha.9",
4
+ "version": "3.0.1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Brandon Behring",
@@ -117,7 +117,8 @@
117
117
  ],
118
118
  "scripts": {
119
119
  "build": "tsup && rm -f dist/types-*.d.ts",
120
- "prepublishOnly": "npm run build"
120
+ "prepublishOnly": "npm run build",
121
+ "test": "node --test tests/*.test.mjs"
121
122
  },
122
123
  "peerDependencies": {
123
124
  "astro": "^6.1.7",
@@ -16,7 +16,7 @@ import {
16
16
  getPatternsByCategory,
17
17
  CATEGORY_LABELS,
18
18
  } from '../src/lib/patterns';
19
- import { patternCategories } from '../content.config';
19
+ import { patternCategories } from '@brandon_m_behring/book-scaffold-astro';
20
20
 
21
21
  const grouped = await getPatternsByCategory();
22
22
  const totalPatterns = Object.values(grouped).reduce(
@@ -37,7 +37,7 @@ import { Cite } from '@citation-js/core';
37
37
  import '@citation-js/plugin-bibtex';
38
38
 
39
39
  const __dirname = dirname(fileURLToPath(import.meta.url));
40
- const PROJECT_ROOT = resolve(__dirname, '..');
40
+ const PROJECT_ROOT = process.cwd();
41
41
 
42
42
  // Default: bibliography.bib at scaffold root.
43
43
  // Override via BOOK_BIB_PATH=path/to/your.bib (absolute or relative to cwd).
@@ -31,7 +31,7 @@ import { fileURLToPath } from 'node:url';
31
31
  import { spawnSync } from 'node:child_process';
32
32
 
33
33
  const __dirname = dirname(fileURLToPath(import.meta.url));
34
- const PROJECT_ROOT = resolve(__dirname, '..');
34
+ const PROJECT_ROOT = process.cwd();
35
35
 
36
36
  // Default: figures/ at scaffold root.
37
37
  // Override via BOOK_FIGURES_PATH=path/to/figures (absolute or relative to
@@ -36,7 +36,7 @@ import { fileURLToPath } from 'node:url';
36
36
  import { spawnSync } from 'node:child_process';
37
37
 
38
38
  const __dirname = dirname(fileURLToPath(import.meta.url));
39
- const PROJECT_ROOT = resolve(__dirname, '..');
39
+ const PROJECT_ROOT = process.cwd();
40
40
 
41
41
  // Default: notebooks/ at scaffold root.
42
42
  // Override via BOOK_NOTEBOOKS_PATH (absolute or relative to scaffold root)
@@ -17,7 +17,7 @@ import {
17
17
  toolSlugs,
18
18
  patternCategories,
19
19
  changeKinds,
20
- } from '../schemas.js';
20
+ } from '@brandon_m_behring/book-scaffold-astro';
21
21
 
22
22
  export type PatternEntry = CollectionEntry<'patterns'>;
23
23
  export type ToolSlug = (typeof toolSlugs)[number];
@@ -6,7 +6,7 @@
6
6
  * component and any future dashboards share a single source of truth.
7
7
  */
8
8
  import { getCollection, type CollectionEntry } from 'astro:content';
9
- import { sourceTiers } from '../schemas.js';
9
+ import { sourceTiers } from '@brandon_m_behring/book-scaffold-astro';
10
10
 
11
11
  export type SourceEntry = CollectionEntry<'sources'>;
12
12
  export type SourceTier = (typeof sourceTiers)[number];