@bendyline/squisq 1.2.1 → 1.2.2
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/{Doc-Dwn5aHFC.d.ts → Doc-BfBhiCNr.d.ts} +2 -2
- package/dist/__tests__/coverBlock.test.d.ts +2 -0
- package/dist/__tests__/coverBlock.test.d.ts.map +1 -0
- package/dist/__tests__/coverBlock.test.js +197 -0
- package/dist/__tests__/coverBlock.test.js.map +1 -0
- package/dist/__tests__/markdown.test.js +21 -0
- package/dist/__tests__/markdown.test.js.map +1 -1
- package/dist/__tests__/markdownToDoc.test.js +59 -0
- package/dist/__tests__/markdownToDoc.test.js.map +1 -1
- package/dist/{chunk-TVPKD76V.js → chunk-53TZ2UTL.js} +2 -3
- package/dist/chunk-53TZ2UTL.js.map +1 -0
- package/dist/{chunk-QWVRN6I4.js → chunk-7GF6RDED.js} +3 -2
- package/dist/chunk-7GF6RDED.js.map +1 -0
- package/dist/{chunk-4CRBS35L.js → chunk-CYQHG27J.js} +7 -2
- package/dist/chunk-CYQHG27J.js.map +1 -0
- package/dist/{chunk-T6WBC3ND.js → chunk-GAQLMORN.js} +105 -49
- package/dist/chunk-GAQLMORN.js.map +1 -0
- package/dist/{chunk-NJLL5XYC.js → chunk-LAZELBON.js} +2 -2
- package/dist/{chunk-KEFWM2VC.js → chunk-XM4WSOHB.js} +1 -1
- package/dist/chunk-XM4WSOHB.js.map +1 -0
- package/dist/doc/markdownToDoc.d.ts +7 -0
- package/dist/doc/markdownToDoc.d.ts.map +1 -1
- package/dist/doc/markdownToDoc.js +49 -1
- package/dist/doc/markdownToDoc.js.map +1 -1
- package/dist/doc/templates/coverBlock.d.ts +2 -2
- package/dist/doc/templates/coverBlock.d.ts.map +1 -1
- package/dist/doc/templates/coverBlock.js +58 -33
- package/dist/doc/templates/coverBlock.js.map +1 -1
- package/dist/markdown/utils.d.ts.map +1 -1
- package/dist/markdown/utils.js +5 -1
- package/dist/markdown/utils.js.map +1 -1
- package/dist/schemas/Doc.d.ts +2 -2
- package/dist/schemas/Doc.d.ts.map +1 -1
- package/dist/schemas/themeLibrary.d.ts.map +1 -1
- package/dist/schemas/themeLibrary.js +1 -2
- package/dist/schemas/themeLibrary.js.map +1 -1
- package/dist/storage/ContentContainer.d.ts.map +1 -1
- package/dist/storage/ContentContainer.js +10 -1
- package/dist/storage/ContentContainer.js.map +1 -1
- package/dist/story/index.d.ts +12 -5
- package/dist/story/index.js +3 -3
- package/dist/{themeLibrary-DLJtGh8-.d.ts → themeLibrary-IP7EdyRq.d.ts} +1 -1
- package/package.json +1 -1
- package/src/__tests__/coverBlock.test.ts +234 -0
- package/src/__tests__/markdown.test.ts +22 -0
- package/src/__tests__/markdownToDoc.test.ts +80 -0
- package/src/doc/markdownToDoc.ts +74 -3
- package/src/doc/templates/coverBlock.ts +77 -47
- package/src/markdown/utils.ts +5 -1
- package/src/schemas/Doc.ts +2 -2
- package/src/schemas/themeLibrary.ts +1 -2
- package/src/storage/ContentContainer.ts +9 -1
- package/dist/chunk-4CRBS35L.js.map +0 -1
- package/dist/chunk-KEFWM2VC.js.map +0 -1
- package/dist/chunk-QWVRN6I4.js.map +0 -1
- package/dist/chunk-T6WBC3ND.js.map +0 -1
- package/dist/chunk-TVPKD76V.js.map +0 -1
- /package/dist/{chunk-NJLL5XYC.js.map → chunk-LAZELBON.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/themeLibrary.ts"],"sourcesContent":["/**\n * Built-in Theme Library\n *\n * Ships 8 curated themes covering documentary, editorial, minimal, and\n * cinematic styles. Each theme is fully JSON-serializable.\n *\n * Usage:\n * ```ts\n * import { THEMES, resolveTheme } from '@bendyline/squisq/schemas';\n *\n * const theme = resolveTheme('minimalist'); // look up by id\n * const theme = THEMES.documentary; // direct access\n * ```\n */\n\nimport type { Theme, ThemeColorScheme } from './Theme.js';\n\n// ============================================\n// Shared constants\n// ============================================\n\n// ── Font stacks ──────────────────────────────────────────────────\n// Each stack lists the recommended Google Font first (works when the\n// wrapping site loads it), then degrades to safe system fonts.\n// Squisq itself does NOT load Google Fonts.\n\n/** System fonts only — no external dependencies. */\nconst SYSTEM_SANS = 'system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif';\nconst SYSTEM_SERIF = 'Georgia, \"Times New Roman\", serif';\nconst SYSTEM_MONO = 'Consolas, \"Courier New\", monospace';\n\n/** Theme-specific stacks with Google Font leads. */\nconst PLAYFAIR = '\"Playfair Display\", Georgia, serif';\nconst SOURCE_SERIF = '\"Source Serif 4\", \"PT Serif\", Georgia, serif';\nconst INTER = '\"Inter\", \"Segoe UI\", Roboto, sans-serif';\nconst OSWALD = '\"Oswald\", Impact, \"Arial Black\", sans-serif';\nconst ROBOTO = '\"Roboto\", \"Segoe UI\", Arial, sans-serif';\nconst MERRIWEATHER = '\"Merriweather\", Georgia, serif';\nconst LORA = '\"Lora\", \"Merriweather\", Georgia, serif';\nconst JETBRAINS_MONO = '\"JetBrains Mono\", \"Fira Code\", Consolas, monospace';\nconst IBM_PLEX_SANS = '\"IBM Plex Sans\", \"Segoe UI\", Roboto, sans-serif';\nconst DM_SERIF = '\"DM Serif Display\", Georgia, serif';\nconst DM_SANS = '\"DM Sans\", \"Segoe UI\", Roboto, sans-serif';\nconst CORMORANT = '\"Cormorant Garamond\", Garamond, Georgia, serif';\nconst CRIMSON = '\"Crimson Text\", Georgia, serif';\nconst PT_SERIF = '\"PT Serif\", Georgia, serif';\n\n/** Standard 6-scheme set used by the documentary theme (migrated from old COLOR_SCHEMES). */\nconst CLASSIC_COLOR_SCHEMES: Record<string, ThemeColorScheme> = {\n blue: { bg: '#1a365d', text: '#63b3ed', accent: '#90cdf4' },\n green: { bg: '#22543d', text: '#9ae6b4', accent: '#68d391' },\n purple: { bg: '#44337a', text: '#d6bcfa', accent: '#b794f4' },\n red: { bg: '#742a2a', text: '#fc8181', accent: '#feb2b2' },\n orange: { bg: '#744210', text: '#fbd38d', accent: '#f6ad55' },\n teal: { bg: '#234e52', text: '#81e6d9', accent: '#4fd1c5' },\n};\n\n// ============================================\n// 1. Standard (default — safe system fonts, no external dependencies)\n// ============================================\n\nconst standard: Theme = {\n id: 'standard',\n name: 'Standard',\n description: 'Clean and safe. System fonts only — no external font dependencies.',\n colors: {\n primary: '#3182ce',\n secondary: '#4a5568',\n background: '#1a202c',\n backgroundLight: '#2d3748',\n text: '#f7fafc',\n textMuted: '#a0aec0',\n highlight: '#4299e1',\n warning: '#fc8181',\n },\n typography: {\n bodyFontFamily: SYSTEM_SANS,\n titleFontFamily: SYSTEM_SERIF,\n monoFontFamily: SYSTEM_MONO,\n titleWeight: 'bold',\n },\n style: {\n textShadow: true,\n overlayOpacity: 0.45,\n animationSpeed: 1.0,\n },\n renderStyle: {\n name: 'standard',\n defaultTextAnimation: 'fadeIn',\n defaultImageAnimation: 'slowZoom',\n ambientMotion: true,\n defaultTransition: { type: 'fade', duration: 0.7 },\n },\n colorSchemes: CLASSIC_COLOR_SCHEMES,\n persistentLayers: {\n bottomLayers: [\n {\n template: 'gradientBackground',\n config: { type: 'gradientBackground', preset: 'dark-vignette' },\n },\n ],\n },\n};\n\n// ============================================\n// 2. Documentary\n// ============================================\n\nconst documentary: Theme = {\n id: 'documentary',\n name: 'Documentary',\n description: 'Classic dark cinematic look with elegant serif typography.',\n colors: {\n primary: '#3d5a80',\n secondary: '#63b3ed',\n background: '#1a202c',\n backgroundLight: '#2d3748',\n text: '#ffffff',\n textMuted: '#a0aec0',\n highlight: '#63b3ed',\n warning: '#fc8181',\n },\n typography: {\n bodyFontFamily: SOURCE_SERIF,\n titleFontFamily: PLAYFAIR,\n titleWeight: 'bold',\n },\n style: {\n textShadow: true,\n overlayOpacity: 0.5,\n animationSpeed: 1.0,\n },\n renderStyle: {\n name: 'documentary',\n defaultTextAnimation: 'fadeIn',\n defaultImageAnimation: 'slowZoom',\n ambientMotion: true,\n defaultTransition: { type: 'fade', duration: 0.8 },\n },\n colorSchemes: CLASSIC_COLOR_SCHEMES,\n persistentLayers: {\n bottomLayers: [\n {\n template: 'gradientBackground',\n config: { type: 'gradientBackground', preset: 'dark-vignette' },\n },\n ],\n },\n};\n\n// ============================================\n// 2. Minimalist\n// ============================================\n\nconst minimalist: Theme = {\n id: 'minimalist',\n name: 'Minimalist',\n description: 'Clean near-white background with sans-serif type and minimal animation.',\n colors: {\n primary: '#2d3748',\n secondary: '#4a5568',\n background: '#f7fafc',\n backgroundLight: '#edf2f7',\n text: '#1a202c',\n textMuted: '#718096',\n highlight: '#3182ce',\n warning: '#e53e3e',\n },\n typography: {\n bodyFontFamily: INTER,\n titleFontFamily: INTER,\n titleWeight: 'bold',\n lineHeight: 1.6,\n },\n style: {\n textShadow: false,\n overlayOpacity: 0.3,\n animationSpeed: 1.2,\n borderRadius: 8,\n },\n renderStyle: {\n name: 'minimalist',\n defaultTextAnimation: 'fadeIn',\n ambientMotion: false,\n defaultTransition: { type: 'fade', duration: 0.6 },\n templateHints: {\n titleBlock: { showAccentLine: false },\n },\n },\n colorSchemes: {\n blue: { bg: '#ebf8ff', text: '#2b6cb0', accent: '#3182ce' },\n green: { bg: '#f0fff4', text: '#276749', accent: '#38a169' },\n purple: { bg: '#faf5ff', text: '#553c9a', accent: '#805ad5' },\n red: { bg: '#fff5f5', text: '#c53030', accent: '#e53e3e' },\n orange: { bg: '#fffaf0', text: '#c05621', accent: '#dd6b20' },\n teal: { bg: '#e6fffa', text: '#285e61', accent: '#319795' },\n },\n};\n\n// ============================================\n// 3. Bold\n// ============================================\n\nconst bold: Theme = {\n id: 'bold',\n name: 'Bold',\n description: 'High-contrast black with vivid accents and dramatic animations.',\n colors: {\n primary: '#e53e3e',\n secondary: '#ed8936',\n background: '#000000',\n backgroundLight: '#1a1a1a',\n text: '#ffffff',\n textMuted: '#cbd5e0',\n highlight: '#f6e05e',\n warning: '#fc8181',\n },\n typography: {\n bodyFontFamily: ROBOTO,\n titleFontFamily: OSWALD,\n titleWeight: 'bold',\n titleScale: 1.15,\n bodyScale: 1.0,\n titleLineHeight: 1.1,\n },\n style: {\n textShadow: true,\n overlayOpacity: 0.6,\n animationSpeed: 0.8,\n },\n renderStyle: {\n name: 'bold',\n defaultTextAnimation: 'zoomIn',\n defaultImageAnimation: 'slowZoom',\n ambientMotion: true,\n defaultTransition: { type: 'dissolve', duration: 0.5 },\n templateHints: {\n statHighlight: { entrance: 'dramatic' },\n fullBleedQuote: { entrance: 'dramatic' },\n },\n },\n colorSchemes: {\n blue: { bg: '#1a202c', text: '#63b3ed', accent: '#90cdf4' },\n green: { bg: '#1a202c', text: '#48bb78', accent: '#68d391' },\n purple: { bg: '#1a202c', text: '#b794f4', accent: '#d6bcfa' },\n red: { bg: '#1a202c', text: '#fc8181', accent: '#feb2b2' },\n orange: { bg: '#1a202c', text: '#f6ad55', accent: '#fbd38d' },\n teal: { bg: '#1a202c', text: '#4fd1c5', accent: '#81e6d9' },\n },\n};\n\n// ============================================\n// 4. Morning Light\n// ============================================\n\nconst morningLight: Theme = {\n id: 'morning-light',\n name: 'Morning Light',\n description: 'Warm light background with dark text and gentle serif typography.',\n colors: {\n primary: '#744210',\n secondary: '#975a16',\n background: '#faf8f5',\n backgroundLight: '#f5f0eb',\n text: '#2d3748',\n textMuted: '#718096',\n highlight: '#dd6b20',\n warning: '#c53030',\n },\n typography: {\n bodyFontFamily: LORA,\n titleFontFamily: MERRIWEATHER,\n titleWeight: 'bold',\n lineHeight: 1.7,\n },\n style: {\n textShadow: false,\n overlayOpacity: 0.35,\n animationSpeed: 1.1,\n borderRadius: 4,\n },\n renderStyle: {\n name: 'morning-light',\n defaultTextAnimation: 'fadeIn',\n ambientMotion: false,\n defaultTransition: { type: 'fade', duration: 1.0 },\n },\n colorSchemes: {\n blue: { bg: '#ebf8ff', text: '#2c5282', accent: '#4299e1' },\n green: { bg: '#f0fff4', text: '#22543d', accent: '#48bb78' },\n purple: { bg: '#faf5ff', text: '#44337a', accent: '#9f7aea' },\n red: { bg: '#fff5f5', text: '#9b2c2c', accent: '#fc8181' },\n orange: { bg: '#fffaf0', text: '#744210', accent: '#ed8936' },\n teal: { bg: '#e6fffa', text: '#234e52', accent: '#38b2ac' },\n },\n};\n\n// ============================================\n// 5. Tech Dark\n// ============================================\n\nconst techDark: Theme = {\n id: 'tech-dark',\n name: 'Tech Dark',\n description: 'True black with neon cyan/green accents and monospace titles.',\n colors: {\n primary: '#00e5ff',\n secondary: '#00e676',\n background: '#0a0a0a',\n backgroundLight: '#1a1a2e',\n text: '#e0e0e0',\n textMuted: '#9e9e9e',\n highlight: '#00e5ff',\n warning: '#ff5252',\n },\n typography: {\n bodyFontFamily: IBM_PLEX_SANS,\n titleFontFamily: JETBRAINS_MONO,\n monoFontFamily: JETBRAINS_MONO,\n titleWeight: 'bold',\n titleScale: 0.9,\n lineHeight: 1.5,\n },\n style: {\n textShadow: true,\n overlayOpacity: 0.55,\n animationSpeed: 0.9,\n borderRadius: 2,\n },\n renderStyle: {\n name: 'tech-dark',\n defaultTextAnimation: 'typewriter',\n defaultImageAnimation: 'slowZoom',\n ambientMotion: true,\n defaultTransition: { type: 'dissolve', duration: 0.4 },\n templateHints: {\n statHighlight: { entrance: 'dramatic' },\n },\n },\n colorSchemes: {\n blue: { bg: '#0d1b2a', text: '#00b0ff', accent: '#40c4ff' },\n green: { bg: '#0d1b0d', text: '#00e676', accent: '#69f0ae' },\n purple: { bg: '#1a0d2e', text: '#d500f9', accent: '#ea80fc' },\n red: { bg: '#2e0d0d', text: '#ff5252', accent: '#ff8a80' },\n orange: { bg: '#2e1a0d', text: '#ff9100', accent: '#ffab40' },\n teal: { bg: '#0d2e2e', text: '#1de9b6', accent: '#64ffda' },\n },\n};\n\n// ============================================\n// 6. Magazine\n// ============================================\n\nconst magazine: Theme = {\n id: 'magazine',\n name: 'Magazine',\n description: 'Rich editorial palette with mixed serif/sans typography and slide transitions.',\n colors: {\n primary: '#c53030',\n secondary: '#2b6cb0',\n background: '#1a202c',\n backgroundLight: '#2d3748',\n text: '#f7fafc',\n textMuted: '#cbd5e0',\n highlight: '#ed8936',\n warning: '#fc8181',\n },\n typography: {\n bodyFontFamily: DM_SANS,\n titleFontFamily: DM_SERIF,\n titleWeight: 'bold',\n titleScale: 1.05,\n lineHeight: 1.5,\n },\n style: {\n textShadow: true,\n overlayOpacity: 0.45,\n animationSpeed: 1.0,\n borderRadius: 6,\n },\n renderStyle: {\n name: 'magazine',\n defaultTextAnimation: 'fadeIn',\n defaultImageAnimation: 'slowZoom',\n ambientMotion: true,\n defaultTransition: { type: 'slideLeft', duration: 0.7 },\n },\n colorSchemes: {\n blue: { bg: '#1a365d', text: '#90cdf4', accent: '#63b3ed' },\n green: { bg: '#1c4532', text: '#9ae6b4', accent: '#68d391' },\n purple: { bg: '#322659', text: '#d6bcfa', accent: '#b794f4' },\n red: { bg: '#63171b', text: '#feb2b2', accent: '#fc8181' },\n orange: { bg: '#652b19', text: '#fbd38d', accent: '#f6ad55' },\n teal: { bg: '#1d4044', text: '#81e6d9', accent: '#4fd1c5' },\n },\n};\n\n// ============================================\n// 7. Cinematic\n// ============================================\n\nconst cinematic: Theme = {\n id: 'cinematic',\n name: 'Cinematic',\n description: 'Ultra-dark with moody gradients, gold accents, and slow dissolve transitions.',\n colors: {\n primary: '#d69e2e',\n secondary: '#b7791f',\n background: '#0a0f1a',\n backgroundLight: '#1a202c',\n text: '#f7fafc',\n textMuted: '#a0aec0',\n highlight: '#ecc94b',\n warning: '#fc8181',\n },\n typography: {\n bodyFontFamily: CRIMSON,\n titleFontFamily: CORMORANT,\n titleWeight: 'bold',\n lineHeight: 1.5,\n titleLineHeight: 1.2,\n },\n style: {\n textShadow: true,\n overlayOpacity: 0.55,\n animationSpeed: 1.2,\n },\n renderStyle: {\n name: 'cinematic',\n defaultTextAnimation: 'fadeIn',\n defaultImageAnimation: 'slowZoom',\n ambientMotion: true,\n defaultTransition: { type: 'dissolve', duration: 1.2 },\n templateHints: {\n titleBlock: { showAccentLine: true },\n },\n },\n colorSchemes: {\n blue: { bg: '#0d1b2a', text: '#90cdf4', accent: '#63b3ed' },\n green: { bg: '#0d1b14', text: '#9ae6b4', accent: '#68d391' },\n purple: { bg: '#1a0d2e', text: '#d6bcfa', accent: '#b794f4' },\n red: { bg: '#2a0d0d', text: '#fc8181', accent: '#feb2b2' },\n orange: { bg: '#2a1a0d', text: '#fbd38d', accent: '#f6ad55' },\n teal: { bg: '#0d2a2a', text: '#81e6d9', accent: '#4fd1c5' },\n },\n persistentLayers: {\n bottomLayers: [\n {\n template: 'gradientBackground',\n config: { type: 'gradientBackground', preset: 'radial-dark' },\n },\n ],\n },\n};\n\n// ============================================\n// 8. Warm Earth\n// ============================================\n\nconst warmEarth: Theme = {\n id: 'warm-earth',\n name: 'Warm Earth',\n description: 'Natural warm tones with earthy browns and terracotta accents.',\n colors: {\n primary: '#9c4221',\n secondary: '#c05621',\n background: '#1c1410',\n backgroundLight: '#2d241e',\n text: '#faf5f0',\n textMuted: '#c4a882',\n highlight: '#dd6b20',\n warning: '#e53e3e',\n },\n typography: {\n bodyFontFamily: PT_SERIF,\n titleFontFamily: PT_SERIF,\n titleWeight: 'bold',\n lineHeight: 1.6,\n },\n style: {\n textShadow: true,\n overlayOpacity: 0.5,\n animationSpeed: 1.1,\n },\n renderStyle: {\n name: 'warm-earth',\n defaultTextAnimation: 'fadeIn',\n defaultImageAnimation: 'panLeft',\n ambientMotion: true,\n defaultTransition: { type: 'fade', duration: 0.9 },\n },\n colorSchemes: {\n blue: { bg: '#2a1f14', text: '#90cdf4', accent: '#63b3ed' },\n green: { bg: '#1e2a14', text: '#9ae6b4', accent: '#68d391' },\n purple: { bg: '#2a142a', text: '#d6bcfa', accent: '#b794f4' },\n red: { bg: '#2a1414', text: '#fc8181', accent: '#feb2b2' },\n orange: { bg: '#2a1e0a', text: '#fbd38d', accent: '#f6ad55' },\n teal: { bg: '#142a28', text: '#81e6d9', accent: '#4fd1c5' },\n },\n persistentLayers: {\n bottomLayers: [\n {\n template: 'gradientBackground',\n config: { type: 'gradientBackground', preset: 'earth-tones' },\n },\n ],\n },\n};\n\n// ============================================\n// Theme Library\n// ============================================\n\n/**\n * All built-in themes, keyed by id.\n */\nexport const THEMES: Record<string, Theme> = {\n standard,\n documentary,\n minimalist,\n bold,\n 'morning-light': morningLight,\n 'tech-dark': techDark,\n magazine,\n cinematic,\n 'warm-earth': warmEarth,\n};\n\n/** The default theme id. */\nexport const DEFAULT_THEME_ID = 'standard';\n\n/** The default theme (standard — safe system fonts, no external dependencies). */\nexport const DEFAULT_THEME: Theme = standard;\n\n/**\n * Resolve a theme by id. Returns the default theme when `id` is\n * undefined or not found in the library.\n */\nexport function resolveTheme(id: string | undefined): Theme {\n if (id && id in THEMES) return THEMES[id];\n return DEFAULT_THEME;\n}\n\n/**\n * Get all available theme ids.\n */\nexport function getAvailableThemes(): string[] {\n return Object.keys(THEMES);\n}\n\n/**\n * Get a summary of all themes (id + name + description) for theme pickers.\n */\nexport function getThemeSummaries(): Array<{ id: string; name: string; description?: string }> {\n return Object.values(THEMES).map((t) => ({\n id: t.id,\n name: t.name,\n description: t.description,\n }));\n}\n"],"mappings":";AA2BA,IAAM,cAAc;AACpB,IAAM,eAAe;AACrB,IAAM,cAAc;AAGpB,IAAM,WAAW;AACjB,IAAM,eAAe;AACrB,IAAM,QAAQ;AACd,IAAM,SAAS;AACf,IAAM,SAAS;AACf,IAAM,eAAe;AACrB,IAAM,OAAO;AACb,IAAM,iBAAiB;AACvB,IAAM,gBAAgB;AACtB,IAAM,WAAW;AACjB,IAAM,UAAU;AAChB,IAAM,YAAY;AAClB,IAAM,UAAU;AAChB,IAAM,WAAW;AAGjB,IAAM,wBAA0D;AAAA,EAC9D,MAAM,EAAE,IAAI,WAAW,MAAM,WAAW,QAAQ,UAAU;AAAA,EAC1D,OAAO,EAAE,IAAI,WAAW,MAAM,WAAW,QAAQ,UAAU;AAAA,EAC3D,QAAQ,EAAE,IAAI,WAAW,MAAM,WAAW,QAAQ,UAAU;AAAA,EAC5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AAAA,IACR,aAAa,EAAE;AAAA,EACjB,EAAE;AACJ;","names":[]}
|
|
@@ -27,7 +27,8 @@ function extractPlainText(node) {
|
|
|
27
27
|
return node.value;
|
|
28
28
|
}
|
|
29
29
|
const children = getChildren(node);
|
|
30
|
-
|
|
30
|
+
const separator = node.type === "list" || node.type === "listItem" ? "\n" : "";
|
|
31
|
+
return children.map(extractPlainText).join(separator);
|
|
31
32
|
}
|
|
32
33
|
function countNodes(node) {
|
|
33
34
|
let count = 1;
|
|
@@ -78,4 +79,4 @@ export {
|
|
|
78
79
|
parseFrontmatter,
|
|
79
80
|
createDocument
|
|
80
81
|
};
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
82
|
+
//# sourceMappingURL=chunk-7GF6RDED.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/markdown/utils.ts"],"sourcesContent":["/**\n * Markdown Tree Utilities\n *\n * Helper functions for traversing and querying the MarkdownDocument tree.\n * All functions are pure and operate on the JSON node interfaces.\n */\n\nimport type { MarkdownNode, MarkdownDocument } from './types.js';\n\n/**\n * Get the children of any markdown node, if it has children.\n * Returns an empty array for leaf nodes (text, code, break, etc.).\n *\n * This is useful for generic tree walking where you don't want to\n * check the specific node type.\n */\nexport function getChildren(node: MarkdownNode): MarkdownNode[] {\n if ('children' in node && Array.isArray(node.children)) {\n return node.children as MarkdownNode[];\n }\n return [];\n}\n\n/**\n * Walk the markdown tree depth-first, calling the visitor for each node.\n *\n * The visitor receives the current node and its parent. Return `true`\n * from the visitor to skip the node's children (prune).\n *\n * @param node - The root node to start walking from\n * @param visitor - Called for each node; return true to skip children\n * @param parent - (internal) Parent node\n */\nexport function walkMarkdownTree(\n node: MarkdownNode,\n visitor: (node: MarkdownNode, parent?: MarkdownNode) => void | boolean,\n parent?: MarkdownNode,\n): void {\n const skip = visitor(node, parent);\n if (skip === true) return;\n\n const children = getChildren(node);\n for (const child of children) {\n walkMarkdownTree(child, visitor, node);\n }\n}\n\n/**\n * Find all nodes of a specific type in the tree.\n *\n * @param root - The document or node to search within\n * @param type - The node type to find (e.g., 'heading', 'link', 'text')\n * @returns Array of matching nodes\n *\n * @example\n * ```ts\n * const headings = findNodesByType(doc, 'heading');\n * const links = findNodesByType(doc, 'link');\n * ```\n */\nexport function findNodesByType<T extends MarkdownNode>(root: MarkdownNode, type: T['type']): T[] {\n const results: T[] = [];\n walkMarkdownTree(root, (node) => {\n if (node.type === type) {\n results.push(node as T);\n }\n });\n return results;\n}\n\n/**\n * Extract all plain text content from a node and its descendants.\n * Concatenates text values, ignoring formatting, links, etc.\n *\n * @param node - The node to extract text from\n * @returns Plain text content\n *\n * @example\n * ```ts\n * const heading = doc.children[0]; // { type: 'heading', children: [{ type: 'text', value: 'Hello' }] }\n * extractPlainText(heading); // 'Hello'\n * ```\n */\nexport function extractPlainText(node: MarkdownNode): string {\n if ('value' in node && typeof node.value === 'string') {\n return node.value;\n }\n\n const children = getChildren(node);\n // Preserve boundaries between block-level elements (list items, paragraphs\n // inside list items, blockquotes) so downstream consumers like caption\n // splitting can treat each item as a separate phrase.\n const separator = node.type === 'list' || node.type === 'listItem' ? '\\n' : '';\n return children.map(extractPlainText).join(separator);\n}\n\n/**\n * Count the total number of nodes in the tree.\n *\n * @param node - The root node\n * @returns Total node count (including the root)\n */\nexport function countNodes(node: MarkdownNode): number {\n let count = 1;\n const children = getChildren(node);\n for (const child of children) {\n count += countNodes(child);\n }\n return count;\n}\n\n/**\n * Parse a YAML frontmatter string into a key-value record.\n *\n * Handles simple `key: value` pairs common in markdown frontmatter.\n * Values are trimmed; quoted strings have their quotes removed.\n * Returns `null` if parsing fails or the input is empty.\n *\n * @param yaml - The raw YAML string (without the `---` delimiters)\n * @returns A record of string keys to parsed values, or null\n */\nexport function parseFrontmatter(yaml: string): Record<string, unknown> | null {\n if (!yaml || !yaml.trim()) return null;\n\n const result: Record<string, unknown> = {};\n\n for (const line of yaml.split('\\n')) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) continue;\n\n const colonIdx = trimmed.indexOf(':');\n if (colonIdx < 1) continue;\n\n const key = trimmed.slice(0, colonIdx).trim();\n let value: string | boolean | number = trimmed.slice(colonIdx + 1).trim();\n\n // Remove surrounding quotes\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n\n // Parse booleans and numbers\n if (value === 'true') {\n result[key] = true;\n } else if (value === 'false') {\n result[key] = false;\n } else if (value !== '' && !isNaN(Number(value))) {\n result[key] = Number(value);\n } else {\n result[key] = value;\n }\n }\n\n return Object.keys(result).length > 0 ? result : null;\n}\n\n/**\n * Create a minimal MarkdownDocument from a list of block nodes.\n * Convenience function for programmatic document construction.\n */\nexport function createDocument(...children: MarkdownDocument['children']): MarkdownDocument {\n return {\n type: 'document',\n children,\n };\n}\n"],"mappings":";AAgBO,SAAS,YAAY,MAAoC;AAC9D,MAAI,cAAc,QAAQ,MAAM,QAAQ,KAAK,QAAQ,GAAG;AACtD,WAAO,KAAK;AAAA,EACd;AACA,SAAO,CAAC;AACV;AAYO,SAAS,iBACd,MACA,SACA,QACM;AACN,QAAM,OAAO,QAAQ,MAAM,MAAM;AACjC,MAAI,SAAS,KAAM;AAEnB,QAAM,WAAW,YAAY,IAAI;AACjC,aAAW,SAAS,UAAU;AAC5B,qBAAiB,OAAO,SAAS,IAAI;AAAA,EACvC;AACF;AAeO,SAAS,gBAAwC,MAAoB,MAAsB;AAChG,QAAM,UAAe,CAAC;AACtB,mBAAiB,MAAM,CAAC,SAAS;AAC/B,QAAI,KAAK,SAAS,MAAM;AACtB,cAAQ,KAAK,IAAS;AAAA,IACxB;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAeO,SAAS,iBAAiB,MAA4B;AAC3D,MAAI,WAAW,QAAQ,OAAO,KAAK,UAAU,UAAU;AACrD,WAAO,KAAK;AAAA,EACd;AAEA,QAAM,WAAW,YAAY,IAAI;AAI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AAA,IACN;AAAA,EACF;AACF;","names":[]}
|
|
@@ -157,7 +157,12 @@ var MemoryContentContainer = class {
|
|
|
157
157
|
return this.files.get(path)?.data ?? null;
|
|
158
158
|
}
|
|
159
159
|
async writeFile(path, data, mimeType) {
|
|
160
|
-
|
|
160
|
+
let buffer;
|
|
161
|
+
if (data instanceof ArrayBuffer) {
|
|
162
|
+
buffer = data;
|
|
163
|
+
} else {
|
|
164
|
+
buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
165
|
+
}
|
|
161
166
|
this.files.set(path, {
|
|
162
167
|
data: buffer,
|
|
163
168
|
mimeType: mimeType ?? guessMimeType(path)
|
|
@@ -289,4 +294,4 @@ export {
|
|
|
289
294
|
MemoryContentContainer,
|
|
290
295
|
createMediaProviderFromContainer
|
|
291
296
|
};
|
|
292
|
-
//# sourceMappingURL=chunk-
|
|
297
|
+
//# sourceMappingURL=chunk-CYQHG27J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/storage/MemoryStorageAdapter.ts","../src/storage/LocalStorageAdapter.ts","../src/storage/LocalForageAdapter.ts","../src/storage/ContentContainer.ts","../src/storage/MediaProviderFromContainer.ts"],"sourcesContent":["/**\n * In-memory storage adapter for testing and SSR environments.\n * Data does not persist across page reloads.\n */\n\nimport type { StorageAdapter } from './Storage.js';\n\nexport class MemoryStorageAdapter implements StorageAdapter {\n readonly supportsEnumeration = true;\n private store = new Map<string, string>();\n\n async get<T>(key: string): Promise<T | null> {\n const val = this.store.get(key);\n if (val === undefined) return null;\n try {\n return JSON.parse(val) as T;\n } catch {\n return null;\n }\n }\n\n async set<T>(key: string, value: T): Promise<void> {\n this.store.set(key, JSON.stringify(value));\n }\n\n async remove(key: string): Promise<void> {\n this.store.delete(key);\n }\n\n async clear(): Promise<void> {\n this.store.clear();\n }\n\n async keys(): Promise<string[]> {\n return Array.from(this.store.keys());\n }\n}\n","/**\n * localStorage adapter for web browsers.\n * Supports a configurable key prefix to namespace stored data.\n */\n\nimport type { StorageAdapter } from './Storage.js';\n\nexport class LocalStorageAdapter implements StorageAdapter {\n readonly supportsEnumeration = true;\n private prefix: string;\n\n constructor(prefix = '') {\n this.prefix = prefix;\n }\n\n async get<T>(key: string): Promise<T | null> {\n try {\n const raw = localStorage.getItem(this.prefix + key);\n if (raw === null) return null;\n return JSON.parse(raw) as T;\n } catch {\n return null;\n }\n }\n\n async set<T>(key: string, value: T): Promise<void> {\n localStorage.setItem(this.prefix + key, JSON.stringify(value));\n }\n\n async remove(key: string): Promise<void> {\n localStorage.removeItem(this.prefix + key);\n }\n\n async clear(): Promise<void> {\n const keysToRemove: string[] = [];\n for (let i = 0; i < localStorage.length; i++) {\n const k = localStorage.key(i);\n if (k && k.startsWith(this.prefix)) {\n keysToRemove.push(k);\n }\n }\n for (const k of keysToRemove) {\n localStorage.removeItem(k);\n }\n }\n\n async keys(): Promise<string[]> {\n const result: string[] = [];\n for (let i = 0; i < localStorage.length; i++) {\n const k = localStorage.key(i);\n if (k && k.startsWith(this.prefix)) {\n result.push(k.slice(this.prefix.length));\n }\n }\n return result;\n }\n}\n","/**\n * LocalForage adapter - IndexedDB storage with automatic fallbacks.\n *\n * Uses localforage which provides IndexedDB storage with automatic\n * fallbacks to WebSQL and localStorage. This allows storing much more\n * data than raw localStorage (which is limited to ~5MB).\n *\n * Unlike LocalStorageAdapter, this adapter can store binary data\n * (ArrayBuffer, Blob, Uint8Array) natively without JSON serialization.\n *\n * Ported from qualla-internal/shared/services/StorageAdapters.ts with\n * configurable store name and key prefix.\n */\n\nimport localforage from 'localforage';\nimport type { StorageAdapter } from './Storage.js';\n\nexport interface LocalForageAdapterOptions {\n /** IndexedDB database name (default: 'squisq') */\n name?: string;\n /** IndexedDB object store name (default: 'data') */\n storeName?: string;\n /** Key prefix for namespacing (default: '') */\n prefix?: string;\n /** Human-readable description (default: 'Squisq storage') */\n description?: string;\n}\n\nexport class LocalForageAdapter implements StorageAdapter {\n readonly supportsEnumeration = true;\n private store: LocalForage;\n private prefix: string;\n\n constructor(options: LocalForageAdapterOptions = {}) {\n const {\n name = 'squisq',\n storeName = 'data',\n prefix = '',\n description = 'Squisq storage',\n } = options;\n\n this.prefix = prefix;\n this.store = localforage.createInstance({ name, storeName, description });\n }\n\n async get<T>(key: string): Promise<T | null> {\n try {\n const value = await this.store.getItem<T>(this.prefix + key);\n return value;\n } catch (e: unknown) {\n console.warn('[Storage] get (IndexedDB) failed:', key, e);\n return null;\n }\n }\n\n async set<T>(key: string, value: T): Promise<void> {\n try {\n await this.store.setItem(this.prefix + key, value);\n } catch (e: unknown) {\n console.error('[Storage] set (IndexedDB) failed:', key, e);\n throw e;\n }\n }\n\n async remove(key: string): Promise<void> {\n try {\n await this.store.removeItem(this.prefix + key);\n } catch (e: unknown) {\n console.warn('[Storage] remove (IndexedDB) failed:', key, e);\n }\n }\n\n async clear(): Promise<void> {\n try {\n if (this.prefix) {\n // Only remove keys with our prefix\n const keys = await this.store.keys();\n const keysToRemove = keys.filter((k) => k.startsWith(this.prefix));\n await Promise.all(keysToRemove.map((k) => this.store.removeItem(k)));\n } else {\n // No prefix — clear the entire store\n await this.store.clear();\n }\n } catch (e: unknown) {\n console.error('[Storage] clear (IndexedDB) failed:', e);\n }\n }\n\n async keys(): Promise<string[]> {\n try {\n const allKeys = await this.store.keys();\n if (this.prefix) {\n return allKeys\n .filter((k) => k.startsWith(this.prefix))\n .map((k) => k.slice(this.prefix.length));\n }\n return allKeys;\n } catch (e: unknown) {\n console.warn('[Storage] keys (IndexedDB) failed:', e);\n return [];\n }\n }\n}\n","/**\n * ContentContainer — virtual file system for document containers.\n *\n * A Squisq document is more than just markdown: it's a container of files\n * including the primary markdown document, images, audio, timing data, and\n * other media. ContentContainer provides an abstract async file system\n * interface for reading, writing, and listing these files.\n *\n * Paths are forward-slash separated strings relative to the container root\n * (e.g., 'images/hero.jpg', 'index.md'). No leading slash.\n *\n * Implementations:\n * - MemoryContentContainer — in-memory Map (for zip import, tests, transient use)\n * - SlotContentContainer — backed by IndexedDB slot storage (in the site package)\n */\n\n/**\n * Metadata about a file in a ContentContainer.\n */\nexport interface ContentEntry {\n /** Relative path within the container (e.g., 'images/hero.jpg') */\n path: string;\n /** MIME type (e.g., 'image/jpeg') */\n mimeType: string;\n /** File size in bytes */\n size: number;\n}\n\n/**\n * Abstract async file system for document containers.\n *\n * All paths are forward-slash separated, relative to the container root,\n * with no leading slash. Example: 'images/hero.jpg', 'index.md'.\n */\nexport interface ContentContainer {\n /** Read a file's binary content. Returns null if the file does not exist. */\n readFile(path: string): Promise<ArrayBuffer | null>;\n\n /** Write a file. Creates or overwrites. */\n writeFile(path: string, data: ArrayBuffer | Uint8Array, mimeType?: string): Promise<void>;\n\n /** Remove a file. No-op if the file does not exist. */\n removeFile(path: string): Promise<void>;\n\n /**\n * List files in the container.\n * @param prefix — Optional path prefix to filter by (e.g., 'images/')\n */\n listFiles(prefix?: string): Promise<ContentEntry[]>;\n\n /** Check whether a file exists. */\n exists(path: string): Promise<boolean>;\n\n /**\n * Find the primary markdown document path.\n *\n * Discovery order: index.md → doc.md → document.md → first *.md at root.\n * Returns null if no markdown file is found at the root level.\n */\n getDocumentPath(): Promise<string | null>;\n\n /**\n * Convenience: read the primary markdown document as a UTF-8 string.\n * Returns null if no markdown file is found.\n */\n readDocument(): Promise<string | null>;\n\n /**\n * Convenience: write a markdown document.\n * @param markdown — The markdown content\n * @param filename — Filename to use (defaults to 'index.md')\n */\n writeDocument(markdown: string, filename?: string): Promise<void>;\n}\n\n// ============================================\n// Well-known markdown filenames in priority order\n// ============================================\n\nconst MARKDOWN_PRIORITY = ['index.md', 'doc.md', 'document.md'];\n\n/**\n * Find the primary markdown path from a list of file entries.\n * Exported for reuse by other ContentContainer implementations.\n */\nexport function findDocumentPath(entries: ContentEntry[]): string | null {\n // Only consider root-level files (no '/' in path)\n const rootFiles = entries.filter((e) => !e.path.includes('/'));\n\n for (const name of MARKDOWN_PRIORITY) {\n if (rootFiles.some((e) => e.path.toLowerCase() === name)) {\n return name;\n }\n }\n\n // Fallback: first .md file at root\n const firstMd = rootFiles.find((e) => e.path.toLowerCase().endsWith('.md'));\n return firstMd?.path ?? null;\n}\n\n// ============================================\n// MemoryContentContainer\n// ============================================\n\ninterface MemoryFile {\n data: ArrayBuffer;\n mimeType: string;\n}\n\n/**\n * In-memory ContentContainer backed by a Map.\n *\n * Used for zip import (deserialize into memory), tests, and transient operations.\n */\nexport class MemoryContentContainer implements ContentContainer {\n private files = new Map<string, MemoryFile>();\n\n async readFile(path: string): Promise<ArrayBuffer | null> {\n return this.files.get(path)?.data ?? null;\n }\n\n async writeFile(path: string, data: ArrayBuffer | Uint8Array, mimeType?: string): Promise<void> {\n // Copy to a standalone ArrayBuffer. Uint8Array/Buffer may share a larger\n // backing buffer (e.g., Node's buffer pool), so we must slice to the\n // exact byte range to avoid storing stale pool data.\n let buffer: ArrayBuffer;\n if (data instanceof ArrayBuffer) {\n buffer = data;\n } else {\n buffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) as ArrayBuffer;\n }\n this.files.set(path, {\n data: buffer,\n mimeType: mimeType ?? guessMimeType(path),\n });\n }\n\n async removeFile(path: string): Promise<void> {\n this.files.delete(path);\n }\n\n async listFiles(prefix?: string): Promise<ContentEntry[]> {\n const entries: ContentEntry[] = [];\n for (const [path, file] of this.files) {\n if (prefix && !path.startsWith(prefix)) continue;\n entries.push({\n path,\n mimeType: file.mimeType,\n size: file.data.byteLength,\n });\n }\n return entries;\n }\n\n async exists(path: string): Promise<boolean> {\n return this.files.has(path);\n }\n\n async getDocumentPath(): Promise<string | null> {\n return findDocumentPath(await this.listFiles());\n }\n\n async readDocument(): Promise<string | null> {\n const docPath = await this.getDocumentPath();\n if (!docPath) return null;\n const data = await this.readFile(docPath);\n if (!data) return null;\n return new TextDecoder().decode(data);\n }\n\n async writeDocument(markdown: string, filename?: string): Promise<void> {\n const name = filename ?? 'index.md';\n const data = new TextEncoder().encode(markdown);\n await this.writeFile(name, data, 'text/markdown');\n }\n}\n\n// ============================================\n// MIME type guessing\n// ============================================\n\nconst EXTENSION_MIME_MAP: Record<string, string> = {\n '.md': 'text/markdown',\n '.txt': 'text/plain',\n '.json': 'application/json',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.png': 'image/png',\n '.gif': 'image/gif',\n '.svg': 'image/svg+xml',\n '.webp': 'image/webp',\n '.avif': 'image/avif',\n '.mp4': 'video/mp4',\n '.webm': 'video/webm',\n '.mp3': 'audio/mpeg',\n '.wav': 'audio/wav',\n '.ogg': 'audio/ogg',\n '.css': 'text/css',\n '.html': 'text/html',\n '.js': 'application/javascript',\n};\n\nfunction guessMimeType(path: string): string {\n const dot = path.lastIndexOf('.');\n if (dot === -1) return 'application/octet-stream';\n const ext = path.slice(dot).toLowerCase();\n return EXTENSION_MIME_MAP[ext] ?? 'application/octet-stream';\n}\n","/**\n * MediaProviderFromContainer — bridges ContentContainer to MediaProvider.\n *\n * Creates a MediaProvider that resolves relative paths by reading binary data\n * from a ContentContainer and generating blob URLs. Blob URLs are cached and\n * revoked on dispose().\n *\n * This allows any ContentContainer (memory, slot-backed, zip-loaded) to be\n * used with existing rendering components (DocPlayer, ImageLayer, VideoLayer)\n * that consume MediaProvider.\n */\n\nimport type { MediaProvider, MediaEntry } from '../schemas/MediaProvider.js';\nimport type { ContentContainer } from './ContentContainer.js';\n\n/**\n * Create a MediaProvider backed by a ContentContainer.\n *\n * @param container — The ContentContainer to read/write media from\n * @returns A MediaProvider that resolves paths to blob URLs\n */\nexport function createMediaProviderFromContainer(container: ContentContainer): MediaProvider {\n const blobUrlCache = new Map<string, string>();\n\n return {\n async resolveUrl(relativePath: string): Promise<string> {\n const cached = blobUrlCache.get(relativePath);\n if (cached) return cached;\n\n const data = await container.readFile(relativePath);\n if (!data) return relativePath;\n\n const entries = await container.listFiles();\n const entry = entries.find((e) => e.path === relativePath);\n const mimeType = entry?.mimeType ?? 'application/octet-stream';\n\n const blob = new Blob([data], { type: mimeType });\n const url = URL.createObjectURL(blob);\n blobUrlCache.set(relativePath, url);\n return url;\n },\n\n async listMedia(): Promise<MediaEntry[]> {\n const entries = await container.listFiles();\n return entries\n .filter((e) => !e.path.toLowerCase().endsWith('.md'))\n .map((e) => ({\n name: e.path,\n mimeType: e.mimeType,\n size: e.size,\n }));\n },\n\n async addMedia(\n name: string,\n data: ArrayBuffer | Blob | Uint8Array,\n mimeType: string,\n ): Promise<string> {\n // Invalidate any cached blob URL for this path before overwriting\n const cached = blobUrlCache.get(name);\n if (cached) {\n URL.revokeObjectURL(cached);\n blobUrlCache.delete(name);\n }\n\n let buffer: ArrayBuffer | Uint8Array;\n if (data instanceof Blob) {\n buffer = await data.arrayBuffer();\n } else {\n buffer = data;\n }\n await container.writeFile(name, buffer, mimeType);\n return name;\n },\n\n async removeMedia(relativePath: string): Promise<void> {\n const cached = blobUrlCache.get(relativePath);\n if (cached) {\n URL.revokeObjectURL(cached);\n blobUrlCache.delete(relativePath);\n }\n await container.removeFile(relativePath);\n },\n\n dispose(): void {\n for (const url of blobUrlCache.values()) {\n URL.revokeObjectURL(url);\n }\n blobUrlCache.clear();\n },\n };\n}\n"],"mappings":";AAOO,IAAM,uBAAN,MAAqD;AAAA,EAArD;AACL,SAAS,sBAAsB;AAC/B,SAAQ,QAAQ,oBAAI,IAAoB;AAAA;AAAA,EAExC,MAAM,IAAO,KAAgC;AAC3C,UAAM,MAAM,KAAK,MAAM,IAAI,GAAG;AAC9B,QAAI,QAAQ,OAAW,QAAO;AAC9B,QAAI;AACF,aAAO,KAAK,MAAM,GAAG;AAAA,IACvB,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,IAAO,KAAa,OAAyB;AACjD,SAAK,MAAM,IAAI,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EAC3C;AAAA,EAEA,MAAM,OAAO,KAA4B;AACvC,SAAK,MAAM,OAAO,GAAG;AAAA,EACvB;AAAA,EAEA,MAA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BAAgB,MAAM;AAC1B,qBAAa,OAAO,IAAI;AAAA,MAC1B;AAEA,UAAI;AACJ,UAAI,gBAAgB,MAAM;AACxB,iBAAS,MAAM,KAAK,YAAY;AAAA,MAClC,OAAO;AACL,iBAAS;AAAA,MACX;AACA,YAAM,UAAU,UAAU,MAAM,QAAQ,QAAQ;AAChD,aAAO;AAAA,IACT;AAAA,IAEA,MAAM,YAAY,cAAqC;AACrD,YAAM,SAAS,aAAa,IAAI,YAAY;AAC5C,UAAI,QAAQ;AACV,YAAI,gBAAgB,MAAM;AAC1B,qBAAa,OAAO,YAAY;AAAA,MAClC;AACA,YAAM,UAAU,WAAW,YAAY;AAAA,IACzC;AAAA,IAEA,UAAgB;AACd,iBAAW,OAAO,aAAa,OAAO,GAAG;AACvC,YAAI,gBAAgB,GAAG;AAAA,MACzB;AACA,mBAAa,MAAM;AAAA,IACrB;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_THEME
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-53TZ2UTL.js";
|
|
4
4
|
import {
|
|
5
5
|
VIEWPORT_PRESETS,
|
|
6
6
|
createTemplateContext,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunk-QM5PKNPW.js";
|
|
12
12
|
import {
|
|
13
13
|
extractPlainText
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-7GF6RDED.js";
|
|
15
15
|
import {
|
|
16
16
|
estimateReadingTime
|
|
17
17
|
} from "./chunk-4X3JQXNM.js";
|
|
@@ -2459,59 +2459,83 @@ function dataTable(input, context) {
|
|
|
2459
2459
|
function coverBlock(input, context) {
|
|
2460
2460
|
const { heroSrc, heroAlt, title, subtitle, ambientMotion, heroCredit, heroLicense } = input;
|
|
2461
2461
|
const { theme, layout } = context;
|
|
2462
|
-
const titleFontSize = scaledFontSize(
|
|
2463
|
-
const subtitleFontSize = scaledFontSize(
|
|
2464
|
-
const
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2462
|
+
const titleFontSize = scaledFontSize(120, context, true);
|
|
2463
|
+
const subtitleFontSize = scaledFontSize(40, context, false);
|
|
2464
|
+
const layers = [];
|
|
2465
|
+
if (heroSrc) {
|
|
2466
|
+
const imageAnimation = mapAmbientMotion(ambientMotion);
|
|
2467
|
+
layers.push(
|
|
2468
|
+
{
|
|
2469
|
+
type: "image",
|
|
2470
|
+
id: "cover-hero",
|
|
2471
|
+
content: {
|
|
2472
|
+
src: heroSrc,
|
|
2473
|
+
alt: heroAlt || title,
|
|
2474
|
+
fit: "cover",
|
|
2475
|
+
credit: heroCredit,
|
|
2476
|
+
license: heroLicense
|
|
2477
|
+
},
|
|
2478
|
+
position: { x: 0, y: 0, width: "100%", height: "100%" },
|
|
2479
|
+
animation: imageAnimation
|
|
2476
2480
|
},
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2481
|
+
{
|
|
2482
|
+
type: "shape",
|
|
2483
|
+
id: "cover-gradient",
|
|
2484
|
+
content: {
|
|
2485
|
+
shape: "rect",
|
|
2486
|
+
fill: "linear-gradient(0deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 40%, rgba(0,0,0,0.1) 70%, transparent 100%)"
|
|
2487
|
+
},
|
|
2488
|
+
position: { x: 0, y: 0, width: "100%", height: "100%" }
|
|
2489
|
+
}
|
|
2490
|
+
);
|
|
2491
|
+
} else {
|
|
2492
|
+
layers.push({
|
|
2482
2493
|
type: "shape",
|
|
2483
|
-
id: "cover-
|
|
2494
|
+
id: "cover-bg",
|
|
2484
2495
|
content: {
|
|
2485
2496
|
shape: "rect",
|
|
2486
|
-
fill:
|
|
2497
|
+
fill: `radial-gradient(ellipse at 50% 40%, ${theme.colors.primary} 0%, ${theme.colors.background} 100%)`
|
|
2487
2498
|
},
|
|
2488
2499
|
position: { x: 0, y: 0, width: "100%", height: "100%" }
|
|
2489
|
-
}
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
id: "cover-title",
|
|
2500
|
+
});
|
|
2501
|
+
layers.push({
|
|
2502
|
+
type: "shape",
|
|
2503
|
+
id: "cover-accent",
|
|
2494
2504
|
content: {
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
fontSize: titleFontSize,
|
|
2498
|
-
fontFamily: getThemeFont(context, "title"),
|
|
2499
|
-
fontWeight: "bold",
|
|
2500
|
-
color: theme.colors.text,
|
|
2501
|
-
textAlign: "center",
|
|
2502
|
-
shadow: true
|
|
2503
|
-
}
|
|
2505
|
+
shape: "rect",
|
|
2506
|
+
fill: "rgba(255, 255, 255, 0.2)"
|
|
2504
2507
|
},
|
|
2505
2508
|
position: {
|
|
2506
|
-
x: "
|
|
2507
|
-
y: subtitle ? "
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
}
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2509
|
+
x: "35%",
|
|
2510
|
+
y: subtitle ? "42%" : "58%",
|
|
2511
|
+
width: "30%",
|
|
2512
|
+
height: "2px"
|
|
2513
|
+
}
|
|
2514
|
+
});
|
|
2515
|
+
}
|
|
2516
|
+
layers.push({
|
|
2517
|
+
type: "text",
|
|
2518
|
+
id: "cover-title",
|
|
2519
|
+
content: {
|
|
2520
|
+
text: title,
|
|
2521
|
+
style: {
|
|
2522
|
+
fontSize: titleFontSize,
|
|
2523
|
+
fontFamily: getThemeFont(context, "title"),
|
|
2524
|
+
fontWeight: "bold",
|
|
2525
|
+
color: theme.colors.text,
|
|
2526
|
+
textAlign: "center",
|
|
2527
|
+
shadow: true
|
|
2528
|
+
}
|
|
2529
|
+
},
|
|
2530
|
+
position: {
|
|
2531
|
+
x: "50%",
|
|
2532
|
+
y: heroSrc ? subtitle ? "70%" : "75%" : subtitle ? layout.primaryY : "50%",
|
|
2533
|
+
anchor: "center",
|
|
2534
|
+
width: layout.maxTextWidth
|
|
2535
|
+
},
|
|
2536
|
+
// No animation delay - shown immediately at rest
|
|
2537
|
+
animation: { type: "fadeIn", duration: 0.8 }
|
|
2538
|
+
});
|
|
2515
2539
|
if (subtitle) {
|
|
2516
2540
|
layers.push({
|
|
2517
2541
|
type: "text",
|
|
@@ -2528,7 +2552,7 @@ function coverBlock(input, context) {
|
|
|
2528
2552
|
},
|
|
2529
2553
|
position: {
|
|
2530
2554
|
x: "50%",
|
|
2531
|
-
y: "82%",
|
|
2555
|
+
y: heroSrc ? "82%" : layout.secondaryY,
|
|
2532
2556
|
anchor: "center",
|
|
2533
2557
|
width: layout.maxTextWidth
|
|
2534
2558
|
},
|
|
@@ -3046,7 +3070,7 @@ function markdownToDoc(markdownDoc, options) {
|
|
|
3046
3070
|
currentTime += block.duration;
|
|
3047
3071
|
}
|
|
3048
3072
|
const captions = phrases.length > 0 ? { phrases, generatedAt: (/* @__PURE__ */ new Date()).toISOString(), version: 1 } : void 0;
|
|
3049
|
-
|
|
3073
|
+
const doc = {
|
|
3050
3074
|
articleId,
|
|
3051
3075
|
duration: currentTime,
|
|
3052
3076
|
blocks: rootBlocks,
|
|
@@ -3056,6 +3080,13 @@ function markdownToDoc(markdownDoc, options) {
|
|
|
3056
3080
|
...captions ? { captions } : {},
|
|
3057
3081
|
...markdownDoc.frontmatter ? { frontmatter: markdownDoc.frontmatter } : {}
|
|
3058
3082
|
};
|
|
3083
|
+
if (options?.generateCoverBlock ?? true) {
|
|
3084
|
+
const coverConfig = buildStartBlock(markdownDoc, rootBlocks);
|
|
3085
|
+
if (coverConfig) {
|
|
3086
|
+
doc.startBlock = coverConfig;
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
return doc;
|
|
3059
3090
|
}
|
|
3060
3091
|
function flattenBlocks(blocks) {
|
|
3061
3092
|
const result = [];
|
|
@@ -3130,6 +3161,31 @@ function splitIntoSentences(text) {
|
|
|
3130
3161
|
}
|
|
3131
3162
|
return merged;
|
|
3132
3163
|
}
|
|
3164
|
+
function findFirstImage(node) {
|
|
3165
|
+
if (node.type === "image") return node;
|
|
3166
|
+
if ("children" in node && Array.isArray(node.children)) {
|
|
3167
|
+
for (const child of node.children) {
|
|
3168
|
+
const found = findFirstImage(child);
|
|
3169
|
+
if (found) return found;
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
return void 0;
|
|
3173
|
+
}
|
|
3174
|
+
function buildStartBlock(markdownDoc, rootBlocks) {
|
|
3175
|
+
const firstH1 = rootBlocks.find((b) => b.sourceHeading?.depth === 1);
|
|
3176
|
+
if (!firstH1) return void 0;
|
|
3177
|
+
const title = firstH1.title ?? extractPlainText(firstH1.sourceHeading);
|
|
3178
|
+
if (!title) return void 0;
|
|
3179
|
+
const subtitle = firstH1.contents?.[0]?.type === "paragraph" ? extractPlainText(firstH1.contents[0]) : void 0;
|
|
3180
|
+
const firstImage = findFirstImage(markdownDoc);
|
|
3181
|
+
const config = {
|
|
3182
|
+
title,
|
|
3183
|
+
...subtitle ? { subtitle } : {},
|
|
3184
|
+
...firstImage ? { heroSrc: firstImage.url, heroAlt: firstImage.alt ?? title } : {},
|
|
3185
|
+
ambientMotion: "zoomIn"
|
|
3186
|
+
};
|
|
3187
|
+
return config;
|
|
3188
|
+
}
|
|
3133
3189
|
|
|
3134
3190
|
// src/doc/docToMarkdown.ts
|
|
3135
3191
|
function docToMarkdown(doc) {
|
|
@@ -3443,4 +3499,4 @@ export {
|
|
|
3443
3499
|
scoreTextSimilarity,
|
|
3444
3500
|
resolveAudioMapping
|
|
3445
3501
|
};
|
|
3446
|
-
//# sourceMappingURL=chunk-
|
|
3502
|
+
//# sourceMappingURL=chunk-GAQLMORN.js.map
|