@bendyline/squisq 0.1.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.
- package/dist/Types-sh2VRxfo.d.ts +15 -0
- package/dist/chunk-7UDSRZKG.js +103 -0
- package/dist/chunk-7UDSRZKG.js.map +1 -0
- package/dist/chunk-O5HCIUAD.js +577 -0
- package/dist/chunk-O5HCIUAD.js.map +1 -0
- package/dist/chunk-PJ7AODIM.js +3040 -0
- package/dist/chunk-PJ7AODIM.js.map +1 -0
- package/dist/chunk-QWVRN6I4.js +81 -0
- package/dist/chunk-QWVRN6I4.js.map +1 -0
- package/dist/chunk-S4F2RY37.js +92 -0
- package/dist/chunk-S4F2RY37.js.map +1 -0
- package/dist/chunk-URU6QMLY.js +888 -0
- package/dist/chunk-URU6QMLY.js.map +1 -0
- package/dist/chunk-VJN7UB2Z.js +145 -0
- package/dist/chunk-VJN7UB2Z.js.map +1 -0
- package/dist/doc/index.d.ts +3 -0
- package/dist/doc/index.js +126 -0
- package/dist/doc/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +217 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown/index.d.ts +237 -0
- package/dist/markdown/index.js +33 -0
- package/dist/markdown/index.js.map +1 -0
- package/dist/schemas/index.d.ts +70 -0
- package/dist/schemas/index.js +61 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/spatial/index.d.ts +111 -0
- package/dist/spatial/index.js +25 -0
- package/dist/spatial/index.js.map +1 -0
- package/dist/storage/index.d.ts +91 -0
- package/dist/storage/index.js +11 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/story/index.d.ts +691 -0
- package/dist/story/index.js +126 -0
- package/dist/story/index.js.map +1 -0
- package/dist/themeLibrary-DySHPcgj.d.ts +1352 -0
- package/dist/types-DHiv_Pnm.d.ts +496 -0
- package/package.json +91 -0
- package/src/__tests__/animationUtils.test.ts +77 -0
- package/src/__tests__/geohash.test.ts +109 -0
- package/src/__tests__/getLayers.test.ts +200 -0
- package/src/__tests__/haversine.test.ts +63 -0
- package/src/__tests__/localForageAdapter.test.ts +155 -0
- package/src/__tests__/markdown.test.ts +806 -0
- package/src/__tests__/markdownToDoc.test.ts +374 -0
- package/src/__tests__/storage.test.ts +60 -0
- package/src/__tests__/templates.test.ts +247 -0
- package/src/doc/docToMarkdown.ts +98 -0
- package/src/doc/getLayers.ts +152 -0
- package/src/doc/index.ts +8 -0
- package/src/doc/markdownToDoc.ts +277 -0
- package/src/doc/templates/accentImage.ts +338 -0
- package/src/doc/templates/captionUtils.ts +33 -0
- package/src/doc/templates/comparisonBar.ts +140 -0
- package/src/doc/templates/coverBlock.ts +156 -0
- package/src/doc/templates/dateEvent.ts +122 -0
- package/src/doc/templates/definitionCard.ts +129 -0
- package/src/doc/templates/factCard.ts +114 -0
- package/src/doc/templates/fullBleedQuote.ts +59 -0
- package/src/doc/templates/imageWithCaption.ts +167 -0
- package/src/doc/templates/index.ts +571 -0
- package/src/doc/templates/listBlock.ts +101 -0
- package/src/doc/templates/mapBlock.ts +132 -0
- package/src/doc/templates/persistentLayers.ts +522 -0
- package/src/doc/templates/photoGrid.ts +199 -0
- package/src/doc/templates/pullQuote.ts +119 -0
- package/src/doc/templates/quoteBlock.ts +112 -0
- package/src/doc/templates/sectionHeader.ts +105 -0
- package/src/doc/templates/statHighlight.ts +113 -0
- package/src/doc/templates/titleBlock.ts +100 -0
- package/src/doc/templates/twoColumn.ts +239 -0
- package/src/doc/templates/videoPullQuote.ts +128 -0
- package/src/doc/templates/videoWithCaption.ts +126 -0
- package/src/doc/utils/animationUtils.ts +135 -0
- package/src/doc/utils/themeUtils.ts +139 -0
- package/src/index.ts +5 -0
- package/src/markdown/convert.ts +897 -0
- package/src/markdown/htmlParse.ts +212 -0
- package/src/markdown/index.ts +110 -0
- package/src/markdown/parse.ts +103 -0
- package/src/markdown/stringify.ts +122 -0
- package/src/markdown/types.ts +605 -0
- package/src/markdown/utils.ts +165 -0
- package/src/ngeohash.d.ts +11 -0
- package/src/schemas/BlockTemplates.ts +706 -0
- package/src/schemas/Doc.ts +565 -0
- package/src/schemas/LayoutStrategy.ts +178 -0
- package/src/schemas/MediaProvider.ts +70 -0
- package/src/schemas/Theme.ts +235 -0
- package/src/schemas/Types.ts +15 -0
- package/src/schemas/Viewport.ts +91 -0
- package/src/schemas/index.ts +14 -0
- package/src/schemas/themeLibrary.ts +492 -0
- package/src/spatial/Geohash.ts +168 -0
- package/src/spatial/Haversine.ts +59 -0
- package/src/spatial/index.ts +2 -0
- package/src/storage/LocalForageAdapter.ts +103 -0
- package/src/storage/LocalStorageAdapter.ts +57 -0
- package/src/storage/MemoryStorageAdapter.ts +37 -0
- package/src/storage/Storage.ts +28 -0
- package/src/storage/index.ts +5 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import {
|
|
2
|
+
calculateDuration,
|
|
3
|
+
createTheme,
|
|
4
|
+
getBlockAtTime,
|
|
5
|
+
getCaptionAtTime,
|
|
6
|
+
getSegmentAtTime,
|
|
7
|
+
validateDoc
|
|
8
|
+
} from "./chunk-S4F2RY37.js";
|
|
9
|
+
import {
|
|
10
|
+
calculateBearing,
|
|
11
|
+
decodeGeohash,
|
|
12
|
+
encodeGeohash,
|
|
13
|
+
geohashOverlapsBounds,
|
|
14
|
+
geohashToHierarchicalPath,
|
|
15
|
+
getGeohash4Neighbors,
|
|
16
|
+
getGeohashPath,
|
|
17
|
+
getGeohashPrefix,
|
|
18
|
+
getNeighbors,
|
|
19
|
+
haversineDistance
|
|
20
|
+
} from "./chunk-7UDSRZKG.js";
|
|
21
|
+
import {
|
|
22
|
+
DEFAULT_LAYOUT,
|
|
23
|
+
adjustY,
|
|
24
|
+
comparisonBar,
|
|
25
|
+
countBlocks,
|
|
26
|
+
coverBlock,
|
|
27
|
+
createAccentLayers,
|
|
28
|
+
dateEvent,
|
|
29
|
+
definitionCard,
|
|
30
|
+
docToMarkdown,
|
|
31
|
+
expandCoverBlock,
|
|
32
|
+
expandDocBlocks,
|
|
33
|
+
expandPersistentLayers,
|
|
34
|
+
expandTemplateBlock,
|
|
35
|
+
factCard,
|
|
36
|
+
flattenBlocks,
|
|
37
|
+
fullBleedQuote,
|
|
38
|
+
getAccentLayout,
|
|
39
|
+
getAnimationProgress,
|
|
40
|
+
getAnimationStyle,
|
|
41
|
+
getAvailableTemplates,
|
|
42
|
+
getBlockDepth,
|
|
43
|
+
getDefaultAnimation,
|
|
44
|
+
getDefaultAnimationDuration,
|
|
45
|
+
getDocStyleConfig,
|
|
46
|
+
getLayers,
|
|
47
|
+
getOverlayOpacity,
|
|
48
|
+
getTemplateHint,
|
|
49
|
+
getTransitionClass,
|
|
50
|
+
hasTemplate,
|
|
51
|
+
imageWithCaption,
|
|
52
|
+
listBlock,
|
|
53
|
+
mapBlock,
|
|
54
|
+
markdownToDoc,
|
|
55
|
+
photoGrid,
|
|
56
|
+
pullQuote,
|
|
57
|
+
quoteBlock,
|
|
58
|
+
resolveColorScheme,
|
|
59
|
+
scaleAnimationDuration,
|
|
60
|
+
sectionHeader,
|
|
61
|
+
shouldUseShadow,
|
|
62
|
+
statHighlight,
|
|
63
|
+
templateRegistry,
|
|
64
|
+
themedFontSize,
|
|
65
|
+
titleBlock,
|
|
66
|
+
twoColumn,
|
|
67
|
+
videoPullQuote,
|
|
68
|
+
videoWithCaption
|
|
69
|
+
} from "./chunk-PJ7AODIM.js";
|
|
70
|
+
import {
|
|
71
|
+
DEFAULT_DOC_FONT,
|
|
72
|
+
DEFAULT_THEME,
|
|
73
|
+
DEFAULT_THEME_ID,
|
|
74
|
+
DEFAULT_TITLE_FONT,
|
|
75
|
+
THEMES,
|
|
76
|
+
VIEWPORT_PRESETS,
|
|
77
|
+
calculateFontScale,
|
|
78
|
+
createTemplateContext,
|
|
79
|
+
getAspectRatioString,
|
|
80
|
+
getAvailableThemes,
|
|
81
|
+
getLayoutHints,
|
|
82
|
+
getSafeTextBounds,
|
|
83
|
+
getThemeSummaries,
|
|
84
|
+
getTwoColumnPositions,
|
|
85
|
+
getViewport,
|
|
86
|
+
getViewportOrientation,
|
|
87
|
+
isPersistentLayerTemplate,
|
|
88
|
+
isTemplateBlock,
|
|
89
|
+
resolveTheme,
|
|
90
|
+
scaledFontSize,
|
|
91
|
+
scaledFontSize2
|
|
92
|
+
} from "./chunk-O5HCIUAD.js";
|
|
93
|
+
import {
|
|
94
|
+
LocalForageAdapter,
|
|
95
|
+
LocalStorageAdapter,
|
|
96
|
+
MemoryStorageAdapter
|
|
97
|
+
} from "./chunk-VJN7UB2Z.js";
|
|
98
|
+
import {
|
|
99
|
+
fromMdast,
|
|
100
|
+
parseHtmlToNodes,
|
|
101
|
+
parseMarkdown,
|
|
102
|
+
stringifyHtmlNodes,
|
|
103
|
+
stringifyMarkdown,
|
|
104
|
+
toMdast
|
|
105
|
+
} from "./chunk-URU6QMLY.js";
|
|
106
|
+
import {
|
|
107
|
+
countNodes,
|
|
108
|
+
createDocument,
|
|
109
|
+
extractPlainText,
|
|
110
|
+
findNodesByType,
|
|
111
|
+
getChildren,
|
|
112
|
+
parseFrontmatter,
|
|
113
|
+
walkMarkdownTree
|
|
114
|
+
} from "./chunk-QWVRN6I4.js";
|
|
115
|
+
export {
|
|
116
|
+
DEFAULT_DOC_FONT,
|
|
117
|
+
DEFAULT_LAYOUT,
|
|
118
|
+
DEFAULT_THEME,
|
|
119
|
+
DEFAULT_THEME_ID,
|
|
120
|
+
DEFAULT_TITLE_FONT,
|
|
121
|
+
LocalForageAdapter,
|
|
122
|
+
LocalStorageAdapter,
|
|
123
|
+
MemoryStorageAdapter,
|
|
124
|
+
THEMES,
|
|
125
|
+
VIEWPORT_PRESETS,
|
|
126
|
+
adjustY,
|
|
127
|
+
calculateBearing,
|
|
128
|
+
calculateDuration,
|
|
129
|
+
calculateFontScale,
|
|
130
|
+
comparisonBar,
|
|
131
|
+
countBlocks,
|
|
132
|
+
countNodes,
|
|
133
|
+
coverBlock,
|
|
134
|
+
createAccentLayers,
|
|
135
|
+
createDocument,
|
|
136
|
+
createTemplateContext,
|
|
137
|
+
createTheme,
|
|
138
|
+
dateEvent,
|
|
139
|
+
decodeGeohash,
|
|
140
|
+
definitionCard,
|
|
141
|
+
docToMarkdown,
|
|
142
|
+
encodeGeohash,
|
|
143
|
+
expandCoverBlock,
|
|
144
|
+
expandDocBlocks,
|
|
145
|
+
expandPersistentLayers,
|
|
146
|
+
expandTemplateBlock,
|
|
147
|
+
extractPlainText,
|
|
148
|
+
factCard,
|
|
149
|
+
findNodesByType,
|
|
150
|
+
flattenBlocks,
|
|
151
|
+
fromMdast,
|
|
152
|
+
fullBleedQuote,
|
|
153
|
+
geohashOverlapsBounds,
|
|
154
|
+
geohashToHierarchicalPath,
|
|
155
|
+
getAccentLayout,
|
|
156
|
+
getAnimationProgress,
|
|
157
|
+
getAnimationStyle,
|
|
158
|
+
getAspectRatioString,
|
|
159
|
+
getAvailableTemplates,
|
|
160
|
+
getAvailableThemes,
|
|
161
|
+
getBlockAtTime,
|
|
162
|
+
getBlockDepth,
|
|
163
|
+
getCaptionAtTime,
|
|
164
|
+
getChildren,
|
|
165
|
+
getDefaultAnimation,
|
|
166
|
+
getDefaultAnimationDuration,
|
|
167
|
+
getDocStyleConfig,
|
|
168
|
+
getGeohash4Neighbors,
|
|
169
|
+
getGeohashPath,
|
|
170
|
+
getGeohashPrefix,
|
|
171
|
+
getLayers,
|
|
172
|
+
getLayoutHints,
|
|
173
|
+
getNeighbors,
|
|
174
|
+
getOverlayOpacity,
|
|
175
|
+
getSafeTextBounds,
|
|
176
|
+
getSegmentAtTime,
|
|
177
|
+
getTemplateHint,
|
|
178
|
+
getThemeSummaries,
|
|
179
|
+
getTransitionClass,
|
|
180
|
+
getTwoColumnPositions,
|
|
181
|
+
getViewport,
|
|
182
|
+
getViewportOrientation,
|
|
183
|
+
hasTemplate,
|
|
184
|
+
haversineDistance,
|
|
185
|
+
imageWithCaption,
|
|
186
|
+
isPersistentLayerTemplate,
|
|
187
|
+
isTemplateBlock,
|
|
188
|
+
scaledFontSize as layoutScaledFontSize,
|
|
189
|
+
listBlock,
|
|
190
|
+
mapBlock,
|
|
191
|
+
markdownToDoc,
|
|
192
|
+
parseFrontmatter,
|
|
193
|
+
parseHtmlToNodes,
|
|
194
|
+
parseMarkdown,
|
|
195
|
+
photoGrid,
|
|
196
|
+
pullQuote,
|
|
197
|
+
quoteBlock,
|
|
198
|
+
resolveColorScheme,
|
|
199
|
+
resolveTheme,
|
|
200
|
+
scaleAnimationDuration,
|
|
201
|
+
scaledFontSize2 as scaledFontSize,
|
|
202
|
+
sectionHeader,
|
|
203
|
+
shouldUseShadow,
|
|
204
|
+
statHighlight,
|
|
205
|
+
stringifyHtmlNodes,
|
|
206
|
+
stringifyMarkdown,
|
|
207
|
+
templateRegistry,
|
|
208
|
+
themedFontSize,
|
|
209
|
+
titleBlock,
|
|
210
|
+
toMdast,
|
|
211
|
+
twoColumn,
|
|
212
|
+
validateDoc,
|
|
213
|
+
videoPullQuote,
|
|
214
|
+
videoWithCaption,
|
|
215
|
+
walkMarkdownTree
|
|
216
|
+
};
|
|
217
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { S as ParseOptions, l as MarkdownDocument, T as StringifyOptions, c as HtmlNode, E as MarkdownNode } from '../types-DHiv_Pnm.js';
|
|
2
|
+
export { H as HeadingTemplateAnnotation, a as HtmlComment, b as HtmlElement, d as HtmlText, M as MarkdownBlockNode, e as MarkdownBlockquote, f as MarkdownBreak, g as MarkdownCodeBlock, h as MarkdownContainerDirective, i as MarkdownDefinitionDescription, j as MarkdownDefinitionList, k as MarkdownDefinitionTerm, m as MarkdownEmphasis, n as MarkdownFootnoteDefinition, o as MarkdownFootnoteReference, p as MarkdownHeading, q as MarkdownHtmlBlock, r as MarkdownImage, s as MarkdownImageReference, t as MarkdownInlineCode, u as MarkdownInlineHtml, v as MarkdownInlineMath, w as MarkdownInlineNode, x as MarkdownLeafDirective, y as MarkdownLink, z as MarkdownLinkDefinition, A as MarkdownLinkReference, B as MarkdownList, C as MarkdownListItem, D as MarkdownMathBlock, F as MarkdownParagraph, G as MarkdownPoint, I as MarkdownSourcePosition, J as MarkdownStrikethrough, K as MarkdownStrong, L as MarkdownTable, N as MarkdownTableCell, O as MarkdownTableRow, P as MarkdownText, Q as MarkdownTextDirective, R as MarkdownThematicBreak } from '../types-DHiv_Pnm.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Markdown → JSON Parser
|
|
6
|
+
*
|
|
7
|
+
* Parses a markdown string into a MarkdownDocument JSON structure
|
|
8
|
+
* using the unified/remark ecosystem with GFM, math, and directive extensions.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Parse a markdown string into a MarkdownDocument.
|
|
13
|
+
*
|
|
14
|
+
* All extensions (GFM, math, directives) are enabled by default.
|
|
15
|
+
* Use the `options` parameter to disable specific extensions.
|
|
16
|
+
*
|
|
17
|
+
* @param markdown - The markdown source text
|
|
18
|
+
* @param options - Parser options (extensions, HTML parsing)
|
|
19
|
+
* @returns A MarkdownDocument representing the parsed markdown
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const doc = parseMarkdown('# Hello\n\nWorld **bold** and *italic*');
|
|
24
|
+
* // doc.type === 'document'
|
|
25
|
+
* // doc.children[0].type === 'heading'
|
|
26
|
+
* // doc.children[1].type === 'paragraph'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare function parseMarkdown(markdown: string, options?: ParseOptions): MarkdownDocument;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* JSON → Markdown Serializer
|
|
33
|
+
*
|
|
34
|
+
* Converts a MarkdownDocument JSON structure back to a markdown string
|
|
35
|
+
* using the unified/remark ecosystem with GFM, math, and directive extensions.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Serialize a MarkdownDocument back to a markdown string.
|
|
40
|
+
*
|
|
41
|
+
* All extensions (GFM, math, directives) are enabled by default.
|
|
42
|
+
* Use the `options` parameter to control formatting and disable extensions.
|
|
43
|
+
*
|
|
44
|
+
* @param doc - The MarkdownDocument to serialize
|
|
45
|
+
* @param options - Serialization options (formatting, extensions)
|
|
46
|
+
* @returns A markdown string
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const doc: MarkdownDocument = {
|
|
51
|
+
* type: 'document',
|
|
52
|
+
* children: [
|
|
53
|
+
* { type: 'heading', depth: 1, children: [{ type: 'text', value: 'Hello' }] },
|
|
54
|
+
* { type: 'paragraph', children: [{ type: 'text', value: 'World' }] },
|
|
55
|
+
* ],
|
|
56
|
+
* };
|
|
57
|
+
* const md = stringifyMarkdown(doc);
|
|
58
|
+
* // '# Hello\n\nWorld\n'
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare function stringifyMarkdown(doc: MarkdownDocument, options?: StringifyOptions): string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* mdast ↔ Squisq Markdown Node Conversion
|
|
65
|
+
*
|
|
66
|
+
* Converts between the remark/mdast AST format and the squisq
|
|
67
|
+
* MarkdownDocument JSON format. This is the bridge layer that allows
|
|
68
|
+
* us to use the battle-tested unified/remark ecosystem for parsing
|
|
69
|
+
* and serialization while exposing our own clean, well-typed interfaces.
|
|
70
|
+
*
|
|
71
|
+
* The conversion is designed for perfect round-tripping:
|
|
72
|
+
* toMdast(fromMdast(tree)) should produce an equivalent mdast tree.
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Minimal interface for mdast/unist nodes.
|
|
77
|
+
* Using a generic shape avoids hard dependency on @types/mdast
|
|
78
|
+
* and handles extension nodes (GFM, math, directive) uniformly.
|
|
79
|
+
*/
|
|
80
|
+
interface MdastPosition {
|
|
81
|
+
start: {
|
|
82
|
+
line: number;
|
|
83
|
+
column: number;
|
|
84
|
+
offset?: number;
|
|
85
|
+
};
|
|
86
|
+
end: {
|
|
87
|
+
line: number;
|
|
88
|
+
column: number;
|
|
89
|
+
offset?: number;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
interface MdastNode {
|
|
93
|
+
type: string;
|
|
94
|
+
position?: MdastPosition;
|
|
95
|
+
children?: MdastNode[];
|
|
96
|
+
value?: string;
|
|
97
|
+
depth?: number;
|
|
98
|
+
ordered?: boolean | null;
|
|
99
|
+
start?: number | null;
|
|
100
|
+
spread?: boolean | null;
|
|
101
|
+
checked?: boolean | null;
|
|
102
|
+
lang?: string | null;
|
|
103
|
+
meta?: string | null;
|
|
104
|
+
url?: string;
|
|
105
|
+
title?: string | null;
|
|
106
|
+
alt?: string;
|
|
107
|
+
identifier?: string;
|
|
108
|
+
label?: string;
|
|
109
|
+
referenceType?: string;
|
|
110
|
+
align?: (string | null)[];
|
|
111
|
+
name?: string;
|
|
112
|
+
attributes?: Record<string, string>;
|
|
113
|
+
data?: Record<string, unknown>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Convert an mdast Root node to a MarkdownDocument.
|
|
117
|
+
*
|
|
118
|
+
* @param root - The mdast root node (from remark-parse)
|
|
119
|
+
* @param options - Conversion options
|
|
120
|
+
* @returns A MarkdownDocument
|
|
121
|
+
*/
|
|
122
|
+
declare function fromMdast(root: MdastNode, options?: {
|
|
123
|
+
parseHtml?: boolean;
|
|
124
|
+
}): MarkdownDocument;
|
|
125
|
+
/**
|
|
126
|
+
* Convert a MarkdownDocument back to an mdast Root node.
|
|
127
|
+
*
|
|
128
|
+
* @param doc - A MarkdownDocument
|
|
129
|
+
* @returns An mdast Root node suitable for remark-stringify
|
|
130
|
+
*/
|
|
131
|
+
declare function toMdast(doc: MarkdownDocument): MdastNode;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* HTML ↔ HtmlNode Conversion
|
|
135
|
+
*
|
|
136
|
+
* Parses raw HTML strings into the squisq HtmlNode tree representation
|
|
137
|
+
* using hast-util-from-html (parse5-backed), and serializes HtmlNode trees
|
|
138
|
+
* back to HTML strings with a lightweight custom serializer.
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Parse a raw HTML string into an HtmlNode[] tree.
|
|
143
|
+
*
|
|
144
|
+
* Uses the HTML5 parsing algorithm (via parse5) for correct handling of
|
|
145
|
+
* self-closing tags, optional end tags, entity decoding, etc.
|
|
146
|
+
*
|
|
147
|
+
* @param html - Raw HTML string to parse
|
|
148
|
+
* @returns Array of top-level HtmlNode elements
|
|
149
|
+
*/
|
|
150
|
+
declare function parseHtmlToNodes(html: string): HtmlNode[];
|
|
151
|
+
/**
|
|
152
|
+
* Serialize an HtmlNode[] tree back to an HTML string.
|
|
153
|
+
*
|
|
154
|
+
* @param nodes - Array of HtmlNode elements to serialize
|
|
155
|
+
* @returns HTML string
|
|
156
|
+
*/
|
|
157
|
+
declare function stringifyHtmlNodes(nodes: HtmlNode[]): string;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Markdown Tree Utilities
|
|
161
|
+
*
|
|
162
|
+
* Helper functions for traversing and querying the MarkdownDocument tree.
|
|
163
|
+
* All functions are pure and operate on the JSON node interfaces.
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Get the children of any markdown node, if it has children.
|
|
168
|
+
* Returns an empty array for leaf nodes (text, code, break, etc.).
|
|
169
|
+
*
|
|
170
|
+
* This is useful for generic tree walking where you don't want to
|
|
171
|
+
* check the specific node type.
|
|
172
|
+
*/
|
|
173
|
+
declare function getChildren(node: MarkdownNode): MarkdownNode[];
|
|
174
|
+
/**
|
|
175
|
+
* Walk the markdown tree depth-first, calling the visitor for each node.
|
|
176
|
+
*
|
|
177
|
+
* The visitor receives the current node and its parent. Return `true`
|
|
178
|
+
* from the visitor to skip the node's children (prune).
|
|
179
|
+
*
|
|
180
|
+
* @param node - The root node to start walking from
|
|
181
|
+
* @param visitor - Called for each node; return true to skip children
|
|
182
|
+
* @param parent - (internal) Parent node
|
|
183
|
+
*/
|
|
184
|
+
declare function walkMarkdownTree(node: MarkdownNode, visitor: (node: MarkdownNode, parent?: MarkdownNode) => void | boolean, parent?: MarkdownNode): void;
|
|
185
|
+
/**
|
|
186
|
+
* Find all nodes of a specific type in the tree.
|
|
187
|
+
*
|
|
188
|
+
* @param root - The document or node to search within
|
|
189
|
+
* @param type - The node type to find (e.g., 'heading', 'link', 'text')
|
|
190
|
+
* @returns Array of matching nodes
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* const headings = findNodesByType(doc, 'heading');
|
|
195
|
+
* const links = findNodesByType(doc, 'link');
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare function findNodesByType<T extends MarkdownNode>(root: MarkdownNode, type: T['type']): T[];
|
|
199
|
+
/**
|
|
200
|
+
* Extract all plain text content from a node and its descendants.
|
|
201
|
+
* Concatenates text values, ignoring formatting, links, etc.
|
|
202
|
+
*
|
|
203
|
+
* @param node - The node to extract text from
|
|
204
|
+
* @returns Plain text content
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* const heading = doc.children[0]; // { type: 'heading', children: [{ type: 'text', value: 'Hello' }] }
|
|
209
|
+
* extractPlainText(heading); // 'Hello'
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
declare function extractPlainText(node: MarkdownNode): string;
|
|
213
|
+
/**
|
|
214
|
+
* Count the total number of nodes in the tree.
|
|
215
|
+
*
|
|
216
|
+
* @param node - The root node
|
|
217
|
+
* @returns Total node count (including the root)
|
|
218
|
+
*/
|
|
219
|
+
declare function countNodes(node: MarkdownNode): number;
|
|
220
|
+
/**
|
|
221
|
+
* Parse a YAML frontmatter string into a key-value record.
|
|
222
|
+
*
|
|
223
|
+
* Handles simple `key: value` pairs common in markdown frontmatter.
|
|
224
|
+
* Values are trimmed; quoted strings have their quotes removed.
|
|
225
|
+
* Returns `null` if parsing fails or the input is empty.
|
|
226
|
+
*
|
|
227
|
+
* @param yaml - The raw YAML string (without the `---` delimiters)
|
|
228
|
+
* @returns A record of string keys to parsed values, or null
|
|
229
|
+
*/
|
|
230
|
+
declare function parseFrontmatter(yaml: string): Record<string, unknown> | null;
|
|
231
|
+
/**
|
|
232
|
+
* Create a minimal MarkdownDocument from a list of block nodes.
|
|
233
|
+
* Convenience function for programmatic document construction.
|
|
234
|
+
*/
|
|
235
|
+
declare function createDocument(...children: MarkdownDocument['children']): MarkdownDocument;
|
|
236
|
+
|
|
237
|
+
export { HtmlNode, MarkdownDocument, MarkdownNode, ParseOptions, StringifyOptions, countNodes, createDocument, extractPlainText, findNodesByType, fromMdast, getChildren, parseFrontmatter, parseHtmlToNodes, parseMarkdown, stringifyHtmlNodes, stringifyMarkdown, toMdast, walkMarkdownTree };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fromMdast,
|
|
3
|
+
parseHtmlToNodes,
|
|
4
|
+
parseMarkdown,
|
|
5
|
+
stringifyHtmlNodes,
|
|
6
|
+
stringifyMarkdown,
|
|
7
|
+
toMdast
|
|
8
|
+
} from "../chunk-URU6QMLY.js";
|
|
9
|
+
import {
|
|
10
|
+
countNodes,
|
|
11
|
+
createDocument,
|
|
12
|
+
extractPlainText,
|
|
13
|
+
findNodesByType,
|
|
14
|
+
getChildren,
|
|
15
|
+
parseFrontmatter,
|
|
16
|
+
walkMarkdownTree
|
|
17
|
+
} from "../chunk-QWVRN6I4.js";
|
|
18
|
+
export {
|
|
19
|
+
countNodes,
|
|
20
|
+
createDocument,
|
|
21
|
+
extractPlainText,
|
|
22
|
+
findNodesByType,
|
|
23
|
+
fromMdast,
|
|
24
|
+
getChildren,
|
|
25
|
+
parseFrontmatter,
|
|
26
|
+
parseHtmlToNodes,
|
|
27
|
+
parseMarkdown,
|
|
28
|
+
stringifyHtmlNodes,
|
|
29
|
+
stringifyMarkdown,
|
|
30
|
+
toMdast,
|
|
31
|
+
walkMarkdownTree
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export { B as BoundingBox, C as Coordinates } from '../Types-sh2VRxfo.js';
|
|
2
|
+
export { A as AccentImage, a as AccentPosition, b as Animation, c as AnimationType, d as AudioSegment, e as AudioTrack, B as Block, C as CaptionPhrase, f as CaptionTrack, g as ColorScheme, h as ComparisonBarInput, i as CornerBrandingConfig, D as DEFAULT_DOC_FONT, j as DEFAULT_THEME, k as DEFAULT_THEME_ID, l as DEFAULT_TITLE_FONT, m as DateEventInput, n as DeepPartial, o as DefinitionCardInput, p as Doc, q as DocBlock, F as FactCardInput, r as FullBleedQuoteInput, G as GradientBackgroundConfig, I as ImageBackgroundConfig, s as ImageLayer, t as ImageWithCaptionInput, L as Layer, u as LayoutHints, v as ListBlockInput, M as MapBlockInput, w as MapLayer, x as MapMarker, y as MapTileStyle, P as PatternBackgroundConfig, z as PersistentLayer, E as PersistentLayerConfig, H as PersistentLayerTemplate, J as PersistentLayerTemplateConfig, K as PersistentLayerTemplateType, N as PhotoGridInput, O as Position, Q as ProgressIndicatorConfig, R as PullQuoteInput, S as QuoteBlockInput, T as RenderStyle, U as SectionHeaderInput, V as ShapeLayer, W as SolidBackgroundConfig, X as StartBlockConfig, Y as StatHighlightInput, Z as THEMES, _ as TemplateBlock, $ as TemplateContext, a0 as TemplateFunction, a1 as TemplateRegistry, a2 as TextLayer, a3 as TextStyle, a4 as Theme, a5 as ThemeColorPalette, a6 as ThemeColorScheme, a7 as ThemeStyle, a8 as ThemeTypography, a9 as TitleBlockInput, aa as TitleCaptionConfig, ab as Transition, ac as TransitionType, ad as TwoColumnInput, ae as VIEWPORT_PRESETS, af as VideoLayer, ag as VideoPullQuoteInput, ah as VideoWithCaptionInput, ai as ViewportConfig, aj as ViewportOrientation, ak as ViewportPreset, al as calculateDuration, am as calculateFontScale, an as createTemplateContext, ao as createTheme, ap as getAspectRatioString, aq as getAvailableThemes, ar as getBlockAtTime, as as getCaptionAtTime, at as getLayoutHints, au as getSafeTextBounds, av as getSegmentAtTime, aw as getThemeSummaries, ax as getTwoColumnPositions, ay as getViewport, az as getViewportOrientation, aA as isPersistentLayerTemplate, aB as isTemplateBlock, aC as layoutScaledFontSize, aD as resolveTheme, aE as scaledFontSize, aF as validateDoc } from '../themeLibrary-DySHPcgj.js';
|
|
3
|
+
import '../types-DHiv_Pnm.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* MediaProvider — abstract interface for resolving and managing media assets.
|
|
7
|
+
*
|
|
8
|
+
* Components (ImageLayer, VideoLayer, editor preview) use a MediaProvider to
|
|
9
|
+
* resolve relative media paths to displayable URLs and to manage media storage.
|
|
10
|
+
*
|
|
11
|
+
* This decouples the rendering layer from the storage backend:
|
|
12
|
+
* - In the dev site, a SlotStorage-backed provider serves blob URLs from IndexedDB
|
|
13
|
+
* - In production, a simple basePath provider constructs CDN URLs
|
|
14
|
+
* - In tests, a memory-backed provider returns data URIs
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Metadata about a stored media asset.
|
|
18
|
+
*/
|
|
19
|
+
interface MediaEntry {
|
|
20
|
+
/** Filename (e.g., 'hero.jpg') */
|
|
21
|
+
name: string;
|
|
22
|
+
/** MIME type (e.g., 'image/jpeg') */
|
|
23
|
+
mimeType: string;
|
|
24
|
+
/** File size in bytes */
|
|
25
|
+
size: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Interface for resolving and managing media assets.
|
|
29
|
+
*
|
|
30
|
+
* All methods are async to support IndexedDB and other async storage backends.
|
|
31
|
+
* The `resolveUrl` method is the primary integration point for rendering
|
|
32
|
+
* components — it converts a relative media path into a displayable URL.
|
|
33
|
+
*/
|
|
34
|
+
interface MediaProvider {
|
|
35
|
+
/**
|
|
36
|
+
* Resolve a relative media path to a displayable URL.
|
|
37
|
+
*
|
|
38
|
+
* Returns a URL that can be used in <img src>, <video src>, etc.
|
|
39
|
+
* This may be a blob: URL, data: URL, or absolute HTTP URL depending
|
|
40
|
+
* on the provider implementation.
|
|
41
|
+
*
|
|
42
|
+
* @param relativePath - Relative path as stored in the document (e.g., 'hero.jpg')
|
|
43
|
+
* @returns Displayable URL, or the original path if resolution fails
|
|
44
|
+
*/
|
|
45
|
+
resolveUrl(relativePath: string): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* List all media assets available in this provider's scope.
|
|
48
|
+
*/
|
|
49
|
+
listMedia(): Promise<MediaEntry[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Add a media asset. Returns the relative path to reference in documents.
|
|
52
|
+
*
|
|
53
|
+
* @param name - Filename for the asset (e.g., 'photo.jpg')
|
|
54
|
+
* @param data - Binary content (ArrayBuffer, Blob, or Uint8Array)
|
|
55
|
+
* @param mimeType - MIME type of the data
|
|
56
|
+
* @returns The relative path to use in document references
|
|
57
|
+
*/
|
|
58
|
+
addMedia(name: string, data: ArrayBuffer | Blob | Uint8Array, mimeType: string): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Remove a media asset by its relative path.
|
|
61
|
+
*/
|
|
62
|
+
removeMedia(relativePath: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Dispose of any held resources (e.g., revoke blob URLs).
|
|
65
|
+
* Call this when the provider is no longer needed.
|
|
66
|
+
*/
|
|
67
|
+
dispose(): void;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type { MediaEntry, MediaProvider };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
calculateDuration,
|
|
3
|
+
createTheme,
|
|
4
|
+
getBlockAtTime,
|
|
5
|
+
getCaptionAtTime,
|
|
6
|
+
getSegmentAtTime,
|
|
7
|
+
validateDoc
|
|
8
|
+
} from "../chunk-S4F2RY37.js";
|
|
9
|
+
import {
|
|
10
|
+
DEFAULT_DOC_FONT,
|
|
11
|
+
DEFAULT_THEME,
|
|
12
|
+
DEFAULT_THEME_ID,
|
|
13
|
+
DEFAULT_TITLE_FONT,
|
|
14
|
+
THEMES,
|
|
15
|
+
VIEWPORT_PRESETS,
|
|
16
|
+
calculateFontScale,
|
|
17
|
+
createTemplateContext,
|
|
18
|
+
getAspectRatioString,
|
|
19
|
+
getAvailableThemes,
|
|
20
|
+
getLayoutHints,
|
|
21
|
+
getSafeTextBounds,
|
|
22
|
+
getThemeSummaries,
|
|
23
|
+
getTwoColumnPositions,
|
|
24
|
+
getViewport,
|
|
25
|
+
getViewportOrientation,
|
|
26
|
+
isPersistentLayerTemplate,
|
|
27
|
+
isTemplateBlock,
|
|
28
|
+
resolveTheme,
|
|
29
|
+
scaledFontSize,
|
|
30
|
+
scaledFontSize2
|
|
31
|
+
} from "../chunk-O5HCIUAD.js";
|
|
32
|
+
export {
|
|
33
|
+
DEFAULT_DOC_FONT,
|
|
34
|
+
DEFAULT_THEME,
|
|
35
|
+
DEFAULT_THEME_ID,
|
|
36
|
+
DEFAULT_TITLE_FONT,
|
|
37
|
+
THEMES,
|
|
38
|
+
VIEWPORT_PRESETS,
|
|
39
|
+
calculateDuration,
|
|
40
|
+
calculateFontScale,
|
|
41
|
+
createTemplateContext,
|
|
42
|
+
createTheme,
|
|
43
|
+
getAspectRatioString,
|
|
44
|
+
getAvailableThemes,
|
|
45
|
+
getBlockAtTime,
|
|
46
|
+
getCaptionAtTime,
|
|
47
|
+
getLayoutHints,
|
|
48
|
+
getSafeTextBounds,
|
|
49
|
+
getSegmentAtTime,
|
|
50
|
+
getThemeSummaries,
|
|
51
|
+
getTwoColumnPositions,
|
|
52
|
+
getViewport,
|
|
53
|
+
getViewportOrientation,
|
|
54
|
+
isPersistentLayerTemplate,
|
|
55
|
+
isTemplateBlock,
|
|
56
|
+
scaledFontSize as layoutScaledFontSize,
|
|
57
|
+
resolveTheme,
|
|
58
|
+
scaledFontSize2 as scaledFontSize,
|
|
59
|
+
validateDoc
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|