@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.
Files changed (102) hide show
  1. package/dist/Types-sh2VRxfo.d.ts +15 -0
  2. package/dist/chunk-7UDSRZKG.js +103 -0
  3. package/dist/chunk-7UDSRZKG.js.map +1 -0
  4. package/dist/chunk-O5HCIUAD.js +577 -0
  5. package/dist/chunk-O5HCIUAD.js.map +1 -0
  6. package/dist/chunk-PJ7AODIM.js +3040 -0
  7. package/dist/chunk-PJ7AODIM.js.map +1 -0
  8. package/dist/chunk-QWVRN6I4.js +81 -0
  9. package/dist/chunk-QWVRN6I4.js.map +1 -0
  10. package/dist/chunk-S4F2RY37.js +92 -0
  11. package/dist/chunk-S4F2RY37.js.map +1 -0
  12. package/dist/chunk-URU6QMLY.js +888 -0
  13. package/dist/chunk-URU6QMLY.js.map +1 -0
  14. package/dist/chunk-VJN7UB2Z.js +145 -0
  15. package/dist/chunk-VJN7UB2Z.js.map +1 -0
  16. package/dist/doc/index.d.ts +3 -0
  17. package/dist/doc/index.js +126 -0
  18. package/dist/doc/index.js.map +1 -0
  19. package/dist/index.d.ts +8 -0
  20. package/dist/index.js +217 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/markdown/index.d.ts +237 -0
  23. package/dist/markdown/index.js +33 -0
  24. package/dist/markdown/index.js.map +1 -0
  25. package/dist/schemas/index.d.ts +70 -0
  26. package/dist/schemas/index.js +61 -0
  27. package/dist/schemas/index.js.map +1 -0
  28. package/dist/spatial/index.d.ts +111 -0
  29. package/dist/spatial/index.js +25 -0
  30. package/dist/spatial/index.js.map +1 -0
  31. package/dist/storage/index.d.ts +91 -0
  32. package/dist/storage/index.js +11 -0
  33. package/dist/storage/index.js.map +1 -0
  34. package/dist/story/index.d.ts +691 -0
  35. package/dist/story/index.js +126 -0
  36. package/dist/story/index.js.map +1 -0
  37. package/dist/themeLibrary-DySHPcgj.d.ts +1352 -0
  38. package/dist/types-DHiv_Pnm.d.ts +496 -0
  39. package/package.json +91 -0
  40. package/src/__tests__/animationUtils.test.ts +77 -0
  41. package/src/__tests__/geohash.test.ts +109 -0
  42. package/src/__tests__/getLayers.test.ts +200 -0
  43. package/src/__tests__/haversine.test.ts +63 -0
  44. package/src/__tests__/localForageAdapter.test.ts +155 -0
  45. package/src/__tests__/markdown.test.ts +806 -0
  46. package/src/__tests__/markdownToDoc.test.ts +374 -0
  47. package/src/__tests__/storage.test.ts +60 -0
  48. package/src/__tests__/templates.test.ts +247 -0
  49. package/src/doc/docToMarkdown.ts +98 -0
  50. package/src/doc/getLayers.ts +152 -0
  51. package/src/doc/index.ts +8 -0
  52. package/src/doc/markdownToDoc.ts +277 -0
  53. package/src/doc/templates/accentImage.ts +338 -0
  54. package/src/doc/templates/captionUtils.ts +33 -0
  55. package/src/doc/templates/comparisonBar.ts +140 -0
  56. package/src/doc/templates/coverBlock.ts +156 -0
  57. package/src/doc/templates/dateEvent.ts +122 -0
  58. package/src/doc/templates/definitionCard.ts +129 -0
  59. package/src/doc/templates/factCard.ts +114 -0
  60. package/src/doc/templates/fullBleedQuote.ts +59 -0
  61. package/src/doc/templates/imageWithCaption.ts +167 -0
  62. package/src/doc/templates/index.ts +571 -0
  63. package/src/doc/templates/listBlock.ts +101 -0
  64. package/src/doc/templates/mapBlock.ts +132 -0
  65. package/src/doc/templates/persistentLayers.ts +522 -0
  66. package/src/doc/templates/photoGrid.ts +199 -0
  67. package/src/doc/templates/pullQuote.ts +119 -0
  68. package/src/doc/templates/quoteBlock.ts +112 -0
  69. package/src/doc/templates/sectionHeader.ts +105 -0
  70. package/src/doc/templates/statHighlight.ts +113 -0
  71. package/src/doc/templates/titleBlock.ts +100 -0
  72. package/src/doc/templates/twoColumn.ts +239 -0
  73. package/src/doc/templates/videoPullQuote.ts +128 -0
  74. package/src/doc/templates/videoWithCaption.ts +126 -0
  75. package/src/doc/utils/animationUtils.ts +135 -0
  76. package/src/doc/utils/themeUtils.ts +139 -0
  77. package/src/index.ts +5 -0
  78. package/src/markdown/convert.ts +897 -0
  79. package/src/markdown/htmlParse.ts +212 -0
  80. package/src/markdown/index.ts +110 -0
  81. package/src/markdown/parse.ts +103 -0
  82. package/src/markdown/stringify.ts +122 -0
  83. package/src/markdown/types.ts +605 -0
  84. package/src/markdown/utils.ts +165 -0
  85. package/src/ngeohash.d.ts +11 -0
  86. package/src/schemas/BlockTemplates.ts +706 -0
  87. package/src/schemas/Doc.ts +565 -0
  88. package/src/schemas/LayoutStrategy.ts +178 -0
  89. package/src/schemas/MediaProvider.ts +70 -0
  90. package/src/schemas/Theme.ts +235 -0
  91. package/src/schemas/Types.ts +15 -0
  92. package/src/schemas/Viewport.ts +91 -0
  93. package/src/schemas/index.ts +14 -0
  94. package/src/schemas/themeLibrary.ts +492 -0
  95. package/src/spatial/Geohash.ts +168 -0
  96. package/src/spatial/Haversine.ts +59 -0
  97. package/src/spatial/index.ts +2 -0
  98. package/src/storage/LocalForageAdapter.ts +103 -0
  99. package/src/storage/LocalStorageAdapter.ts +57 -0
  100. package/src/storage/MemoryStorageAdapter.ts +37 -0
  101. package/src/storage/Storage.ts +28 -0
  102. package/src/storage/index.ts +5 -0
@@ -0,0 +1,496 @@
1
+ /**
2
+ * Markdown DOM Types
3
+ *
4
+ * A complete hierarchical JSON representation of a Markdown document.
5
+ * Supports perfect-fidelity round-trip conversion between Markdown text
6
+ * and this JSON format: parseMarkdown(stringifyMarkdown(doc)) ≡ doc.
7
+ *
8
+ * Coverage:
9
+ * - CommonMark (headings, paragraphs, lists, code, blockquotes, etc.)
10
+ * - GFM (tables, strikethrough, task lists, autolinks, footnotes)
11
+ * - Math (inline $...$ and display $$...$$)
12
+ * - Directives (:::container, ::leaf, :text — used for admonitions, etc.)
13
+ * - Raw HTML (parsed into an HtmlNode sub-DOM for programmatic access)
14
+ * - Definition lists (type only — for programmatic construction)
15
+ */
16
+ /**
17
+ * A specific point in the source markdown text.
18
+ */
19
+ interface MarkdownPoint {
20
+ /** 1-based line number */
21
+ line: number;
22
+ /** 1-based column number */
23
+ column: number;
24
+ /** 0-based byte offset from start of document */
25
+ offset?: number;
26
+ }
27
+ /**
28
+ * Source position range for a node (start inclusive, end exclusive).
29
+ * Present when parsed from markdown, absent when constructed programmatically.
30
+ */
31
+ interface MarkdownSourcePosition {
32
+ start: MarkdownPoint;
33
+ end: MarkdownPoint;
34
+ }
35
+ /**
36
+ * An HTML element with tag name, attributes, and children.
37
+ */
38
+ interface HtmlElement {
39
+ type: 'htmlElement';
40
+ /** HTML tag name (lowercase, e.g., 'div', 'span', 'br') */
41
+ tagName: string;
42
+ /** HTML attributes as name→value pairs (uses HTML attribute names, e.g., 'class' not 'className') */
43
+ attributes: Record<string, string>;
44
+ /** Child nodes */
45
+ children: HtmlNode[];
46
+ /** Whether this is a void/self-closing element (br, hr, img, etc.) */
47
+ selfClosing: boolean;
48
+ }
49
+ /**
50
+ * A raw text node inside HTML.
51
+ */
52
+ interface HtmlText {
53
+ type: 'htmlText';
54
+ value: string;
55
+ }
56
+ /**
57
+ * An HTML comment (<!-- ... -->).
58
+ */
59
+ interface HtmlComment {
60
+ type: 'htmlComment';
61
+ value: string;
62
+ }
63
+ /** Any node in the HTML sub-DOM tree. */
64
+ type HtmlNode = HtmlElement | HtmlText | HtmlComment;
65
+ /**
66
+ * Root node of a parsed markdown document.
67
+ */
68
+ interface MarkdownDocument {
69
+ type: 'document';
70
+ /** Top-level block content */
71
+ children: MarkdownBlockNode[];
72
+ /** Source position (present when parsed from markdown) */
73
+ position?: MarkdownSourcePosition;
74
+ /**
75
+ * YAML frontmatter key-value pairs extracted from the `---` block
76
+ * at the top of the document. Present only when the source contains
77
+ * frontmatter and `frontmatter` parsing is enabled (default: true).
78
+ */
79
+ frontmatter?: Record<string, unknown>;
80
+ }
81
+ /** Base properties shared by all markdown nodes. */
82
+ interface MarkdownNodeBase {
83
+ /** Source position (present when parsed from markdown, absent when programmatically constructed) */
84
+ position?: MarkdownSourcePosition;
85
+ }
86
+ /**
87
+ * Template annotation extracted from a heading's trailing `{[templateName key=value …]}` syntax.
88
+ *
89
+ * @example
90
+ * ```markdown
91
+ * ### Report Data {[chart colorScheme=blue]}
92
+ * ```
93
+ * → `{ template: 'chart', params: { colorScheme: 'blue' } }`
94
+ */
95
+ interface HeadingTemplateAnnotation {
96
+ /** Template name (first token inside `{[…]}`) */
97
+ template: string;
98
+ /** Optional key-value parameters (remaining `key=value` tokens) */
99
+ params?: Record<string, string>;
100
+ }
101
+ /**
102
+ * ATX or setext heading (# Heading).
103
+ */
104
+ interface MarkdownHeading extends MarkdownNodeBase {
105
+ type: 'heading';
106
+ /** Heading level (1–6) */
107
+ depth: 1 | 2 | 3 | 4 | 5 | 6;
108
+ /** Inline content */
109
+ children: MarkdownInlineNode[];
110
+ /**
111
+ * Template annotation parsed from trailing `{[templateName …]}` syntax.
112
+ * Present only when the heading text ends with `{[…]}`. The annotation
113
+ * is stripped from `children` during parsing and re-injected during
114
+ * stringification, so it round-trips transparently.
115
+ */
116
+ templateAnnotation?: HeadingTemplateAnnotation;
117
+ }
118
+ /**
119
+ * A paragraph of inline content.
120
+ */
121
+ interface MarkdownParagraph extends MarkdownNodeBase {
122
+ type: 'paragraph';
123
+ children: MarkdownInlineNode[];
124
+ }
125
+ /**
126
+ * A blockquote (> ...).
127
+ */
128
+ interface MarkdownBlockquote extends MarkdownNodeBase {
129
+ type: 'blockquote';
130
+ children: MarkdownBlockNode[];
131
+ }
132
+ /**
133
+ * An ordered or unordered list.
134
+ */
135
+ interface MarkdownList extends MarkdownNodeBase {
136
+ type: 'list';
137
+ /** Whether the list is ordered (numbered) or unordered (bulleted) */
138
+ ordered: boolean;
139
+ /** Starting number for ordered lists (default: 1) */
140
+ start?: number | null;
141
+ /** Whether items are separated by blank lines (loose list) */
142
+ spread?: boolean | null;
143
+ children: MarkdownListItem[];
144
+ }
145
+ /**
146
+ * A single item in a list. May be a task list item if `checked` is non-null.
147
+ */
148
+ interface MarkdownListItem extends MarkdownNodeBase {
149
+ type: 'listItem';
150
+ /** null = not a task item, true = checked [x], false = unchecked [ ] */
151
+ checked?: boolean | null;
152
+ /** Whether this item contains blank lines (loose) */
153
+ spread?: boolean | null;
154
+ /** Block content (typically paragraphs, but can contain nested lists, etc.) */
155
+ children: MarkdownBlockNode[];
156
+ }
157
+ /**
158
+ * A fenced or indented code block.
159
+ */
160
+ interface MarkdownCodeBlock extends MarkdownNodeBase {
161
+ type: 'code';
162
+ /** Language identifier (e.g., 'typescript', 'python') */
163
+ lang?: string | null;
164
+ /** Additional metadata after the language on the fence line */
165
+ meta?: string | null;
166
+ /** The code content (no trailing newline) */
167
+ value: string;
168
+ }
169
+ /**
170
+ * A thematic break (---, ***, or ___).
171
+ */
172
+ interface MarkdownThematicBreak extends MarkdownNodeBase {
173
+ type: 'thematicBreak';
174
+ }
175
+ /**
176
+ * A GFM table.
177
+ */
178
+ interface MarkdownTable extends MarkdownNodeBase {
179
+ type: 'table';
180
+ /** Column alignment: null = default, 'left', 'center', 'right' */
181
+ align?: (('left' | 'right' | 'center') | null)[];
182
+ /** First row is always the header row */
183
+ children: MarkdownTableRow[];
184
+ }
185
+ /**
186
+ * A row in a table.
187
+ */
188
+ interface MarkdownTableRow extends MarkdownNodeBase {
189
+ type: 'tableRow';
190
+ children: MarkdownTableCell[];
191
+ }
192
+ /**
193
+ * A cell in a table row.
194
+ */
195
+ interface MarkdownTableCell extends MarkdownNodeBase {
196
+ type: 'tableCell';
197
+ /** Whether this cell is in the header row */
198
+ isHeader?: boolean;
199
+ children: MarkdownInlineNode[];
200
+ }
201
+ /**
202
+ * A block of raw HTML.
203
+ *
204
+ * The `rawHtml` field contains the original HTML string and is used for
205
+ * serialization (round-tripping). The `htmlChildren` field contains a
206
+ * parsed HTML DOM tree for programmatic traversal.
207
+ *
208
+ * Note: For partial HTML tags (e.g., just `<div>` without `</div>`),
209
+ * `htmlChildren` may not fully represent the structure. The `rawHtml`
210
+ * field always preserves the exact original text.
211
+ */
212
+ interface MarkdownHtmlBlock extends MarkdownNodeBase {
213
+ type: 'htmlBlock';
214
+ /** The original raw HTML string (source of truth for serialization) */
215
+ rawHtml: string;
216
+ /** Parsed HTML DOM tree (for programmatic access) */
217
+ htmlChildren: HtmlNode[];
218
+ }
219
+ /**
220
+ * A display math block ($$...$$).
221
+ */
222
+ interface MarkdownMathBlock extends MarkdownNodeBase {
223
+ type: 'math';
224
+ /** The math content (without $$ delimiters) */
225
+ value: string;
226
+ /** Optional metadata after the opening $$ */
227
+ meta?: string | null;
228
+ }
229
+ /**
230
+ * A link reference definition: [id]: url "title"
231
+ * These are typically not rendered but define targets for reference links.
232
+ */
233
+ interface MarkdownLinkDefinition extends MarkdownNodeBase {
234
+ type: 'definition';
235
+ /** Reference identifier (lowercase, normalized) */
236
+ identifier: string;
237
+ /** Original label text */
238
+ label?: string;
239
+ /** URL target */
240
+ url: string;
241
+ /** Optional title */
242
+ title?: string | null;
243
+ }
244
+ /**
245
+ * A footnote definition: [^id]: content
246
+ */
247
+ interface MarkdownFootnoteDefinition extends MarkdownNodeBase {
248
+ type: 'footnoteDefinition';
249
+ /** Footnote identifier */
250
+ identifier: string;
251
+ /** Original label text */
252
+ label?: string;
253
+ /** Footnote content (block-level) */
254
+ children: MarkdownBlockNode[];
255
+ }
256
+ /**
257
+ * A container directive (:::name[label]{attrs}\ncontent\n:::).
258
+ * Used for admonitions, callouts, and other structural extensions.
259
+ */
260
+ interface MarkdownContainerDirective extends MarkdownNodeBase {
261
+ type: 'containerDirective';
262
+ /** Directive name (e.g., 'note', 'warning', 'tip') */
263
+ name: string;
264
+ /** Key-value attributes from {attr=value} */
265
+ attributes?: Record<string, string>;
266
+ /** Label text from [label] (extracted from children for clean round-tripping) */
267
+ label?: string;
268
+ /** Block content inside the directive */
269
+ children: MarkdownBlockNode[];
270
+ }
271
+ /**
272
+ * A leaf directive (::name[label]{attrs}).
273
+ * Self-contained block-level directive with no content body.
274
+ */
275
+ interface MarkdownLeafDirective extends MarkdownNodeBase {
276
+ type: 'leafDirective';
277
+ /** Directive name */
278
+ name: string;
279
+ /** Key-value attributes */
280
+ attributes?: Record<string, string>;
281
+ /** Inline content from [label] */
282
+ children: MarkdownInlineNode[];
283
+ }
284
+ /**
285
+ * A definition list (<dl>).
286
+ * This type is for programmatic construction — no standard remark parser
287
+ * produces these nodes, but they can be built and rendered.
288
+ */
289
+ interface MarkdownDefinitionList extends MarkdownNodeBase {
290
+ type: 'definitionList';
291
+ children: (MarkdownDefinitionTerm | MarkdownDefinitionDescription)[];
292
+ }
293
+ /**
294
+ * A term in a definition list (<dt>).
295
+ */
296
+ interface MarkdownDefinitionTerm extends MarkdownNodeBase {
297
+ type: 'definitionTerm';
298
+ children: MarkdownInlineNode[];
299
+ }
300
+ /**
301
+ * A description in a definition list (<dd>).
302
+ */
303
+ interface MarkdownDefinitionDescription extends MarkdownNodeBase {
304
+ type: 'definitionDescription';
305
+ children: MarkdownBlockNode[];
306
+ }
307
+ /**
308
+ * Plain text content.
309
+ */
310
+ interface MarkdownText extends MarkdownNodeBase {
311
+ type: 'text';
312
+ value: string;
313
+ }
314
+ /**
315
+ * Emphasized text (*text* or _text_).
316
+ */
317
+ interface MarkdownEmphasis extends MarkdownNodeBase {
318
+ type: 'emphasis';
319
+ children: MarkdownInlineNode[];
320
+ }
321
+ /**
322
+ * Strong emphasis (**text** or __text__).
323
+ */
324
+ interface MarkdownStrong extends MarkdownNodeBase {
325
+ type: 'strong';
326
+ children: MarkdownInlineNode[];
327
+ }
328
+ /**
329
+ * Strikethrough text (~~text~~). GFM extension.
330
+ */
331
+ interface MarkdownStrikethrough extends MarkdownNodeBase {
332
+ type: 'delete';
333
+ children: MarkdownInlineNode[];
334
+ }
335
+ /**
336
+ * Inline code (`code`).
337
+ */
338
+ interface MarkdownInlineCode extends MarkdownNodeBase {
339
+ type: 'inlineCode';
340
+ value: string;
341
+ }
342
+ /**
343
+ * A hyperlink [text](url "title").
344
+ */
345
+ interface MarkdownLink extends MarkdownNodeBase {
346
+ type: 'link';
347
+ /** URL target */
348
+ url: string;
349
+ /** Optional title (shown on hover) */
350
+ title?: string | null;
351
+ /** Link text (inline content) */
352
+ children: MarkdownInlineNode[];
353
+ }
354
+ /**
355
+ * An image ![alt](url "title").
356
+ */
357
+ interface MarkdownImage extends MarkdownNodeBase {
358
+ type: 'image';
359
+ /** Image URL */
360
+ url: string;
361
+ /** Alt text */
362
+ alt?: string;
363
+ /** Optional title */
364
+ title?: string | null;
365
+ }
366
+ /**
367
+ * A hard line break (two trailing spaces or backslash before newline).
368
+ */
369
+ interface MarkdownBreak extends MarkdownNodeBase {
370
+ type: 'break';
371
+ }
372
+ /**
373
+ * Inline raw HTML.
374
+ *
375
+ * In markdown, individual HTML tags like `<em>` or `</em>` appear as
376
+ * separate inline nodes. The `rawHtml` preserves the exact tag text.
377
+ * The `htmlChildren` is a best-effort parse (partial tags may not
378
+ * produce meaningful trees).
379
+ */
380
+ interface MarkdownInlineHtml extends MarkdownNodeBase {
381
+ type: 'htmlInline';
382
+ /** The original raw HTML string */
383
+ rawHtml: string;
384
+ /** Parsed HTML DOM tree (best-effort for partial tags) */
385
+ htmlChildren: HtmlNode[];
386
+ }
387
+ /**
388
+ * Inline math ($...$).
389
+ */
390
+ interface MarkdownInlineMath extends MarkdownNodeBase {
391
+ type: 'inlineMath';
392
+ /** Math content (without $ delimiters) */
393
+ value: string;
394
+ }
395
+ /**
396
+ * A footnote reference [^id]. GFM extension.
397
+ */
398
+ interface MarkdownFootnoteReference extends MarkdownNodeBase {
399
+ type: 'footnoteReference';
400
+ /** Footnote identifier */
401
+ identifier: string;
402
+ /** Original label text */
403
+ label?: string;
404
+ }
405
+ /**
406
+ * A link via reference [text][id] or [text][] or [text].
407
+ */
408
+ interface MarkdownLinkReference extends MarkdownNodeBase {
409
+ type: 'linkReference';
410
+ /** Reference identifier (normalized) */
411
+ identifier: string;
412
+ /** Original label text */
413
+ label?: string;
414
+ /** How the reference is written */
415
+ referenceType: 'full' | 'collapsed' | 'shortcut';
416
+ /** Link text (inline content) */
417
+ children: MarkdownInlineNode[];
418
+ }
419
+ /**
420
+ * An image via reference ![alt][id].
421
+ */
422
+ interface MarkdownImageReference extends MarkdownNodeBase {
423
+ type: 'imageReference';
424
+ /** Reference identifier (normalized) */
425
+ identifier: string;
426
+ /** Original label text */
427
+ label?: string;
428
+ /** How the reference is written */
429
+ referenceType: 'full' | 'collapsed' | 'shortcut';
430
+ /** Alt text */
431
+ alt?: string;
432
+ }
433
+ /**
434
+ * An inline text directive (:name[label]{attrs}).
435
+ */
436
+ interface MarkdownTextDirective extends MarkdownNodeBase {
437
+ type: 'textDirective';
438
+ /** Directive name */
439
+ name: string;
440
+ /** Key-value attributes */
441
+ attributes?: Record<string, string>;
442
+ /** Inline content from [label] */
443
+ children: MarkdownInlineNode[];
444
+ }
445
+ /** Block-level content that can appear as direct children of the document root, blockquotes, list items, etc. */
446
+ type MarkdownBlockNode = MarkdownHeading | MarkdownParagraph | MarkdownBlockquote | MarkdownList | MarkdownCodeBlock | MarkdownThematicBreak | MarkdownTable | MarkdownHtmlBlock | MarkdownMathBlock | MarkdownLinkDefinition | MarkdownFootnoteDefinition | MarkdownContainerDirective | MarkdownLeafDirective | MarkdownDefinitionList;
447
+ /** Inline/phrasing content that appears inside paragraphs, headings, links, etc. */
448
+ type MarkdownInlineNode = MarkdownText | MarkdownEmphasis | MarkdownStrong | MarkdownStrikethrough | MarkdownInlineCode | MarkdownLink | MarkdownImage | MarkdownBreak | MarkdownInlineHtml | MarkdownInlineMath | MarkdownFootnoteReference | MarkdownLinkReference | MarkdownImageReference | MarkdownTextDirective;
449
+ /**
450
+ * Any node in the markdown tree. Includes structural nodes (listItem,
451
+ * tableRow, tableCell, etc.) that only appear as children of specific parents.
452
+ * Useful for generic tree-walking functions.
453
+ */
454
+ type MarkdownNode = MarkdownDocument | MarkdownBlockNode | MarkdownInlineNode | MarkdownListItem | MarkdownTableRow | MarkdownTableCell | MarkdownDefinitionTerm | MarkdownDefinitionDescription;
455
+ /**
456
+ * Options for parseMarkdown().
457
+ */
458
+ interface ParseOptions {
459
+ /** Enable GFM extensions (tables, strikethrough, task lists, autolinks, footnotes). Default: true */
460
+ gfm?: boolean;
461
+ /** Enable math extensions ($...$ and $$...$$). Default: true */
462
+ math?: boolean;
463
+ /** Enable directive extensions (:::container, ::leaf, :text). Default: true */
464
+ directive?: boolean;
465
+ /** Parse raw HTML into HtmlNode sub-DOM trees. Default: true */
466
+ parseHtml?: boolean;
467
+ /** Enable YAML frontmatter parsing (--- blocks at top of document). Default: true */
468
+ frontmatter?: boolean;
469
+ }
470
+ /**
471
+ * Options for stringifyMarkdown().
472
+ */
473
+ interface StringifyOptions {
474
+ /** Enable GFM extensions in output. Default: true */
475
+ gfm?: boolean;
476
+ /** Enable math extensions in output. Default: true */
477
+ math?: boolean;
478
+ /** Enable directive extensions in output. Default: true */
479
+ directive?: boolean;
480
+ /** Bullet character for unordered lists. Default: '-' */
481
+ bullet?: '-' | '*' | '+';
482
+ /** Ordered list delimiter. Default: '.' */
483
+ bulletOrdered?: '.' | ')';
484
+ /** Emphasis marker character. Default: '*' */
485
+ emphasis?: '*' | '_';
486
+ /** Strong emphasis marker character. Default: '*' */
487
+ strong?: '*' | '_';
488
+ /** Thematic break character. Default: '-' */
489
+ rule?: '-' | '*' | '_';
490
+ /** Code fence character. Default: '`' */
491
+ fence?: '`' | '~';
492
+ /** Use setext-style headings (underlined) for depth 1-2. Default: false */
493
+ setext?: boolean;
494
+ }
495
+
496
+ export type { MarkdownLinkReference as A, MarkdownList as B, MarkdownListItem as C, MarkdownMathBlock as D, MarkdownNode as E, MarkdownParagraph as F, MarkdownPoint as G, HeadingTemplateAnnotation as H, MarkdownSourcePosition as I, MarkdownStrikethrough as J, MarkdownStrong as K, MarkdownTable as L, MarkdownBlockNode as M, MarkdownTableCell as N, MarkdownTableRow as O, MarkdownText as P, MarkdownTextDirective as Q, MarkdownThematicBreak as R, ParseOptions as S, StringifyOptions as T, HtmlComment as a, HtmlElement as b, HtmlNode as c, HtmlText as d, MarkdownBlockquote as e, MarkdownBreak as f, MarkdownCodeBlock as g, MarkdownContainerDirective as h, MarkdownDefinitionDescription as i, MarkdownDefinitionList as j, MarkdownDefinitionTerm as k, MarkdownDocument as l, MarkdownEmphasis as m, MarkdownFootnoteDefinition as n, MarkdownFootnoteReference as o, MarkdownHeading as p, MarkdownHtmlBlock as q, MarkdownImage as r, MarkdownImageReference as s, MarkdownInlineCode as t, MarkdownInlineHtml as u, MarkdownInlineMath as v, MarkdownInlineNode as w, MarkdownLeafDirective as x, MarkdownLink as y, MarkdownLinkDefinition as z };
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "@bendyline/squisq",
3
+ "version": "0.1.1",
4
+ "description": "Headless utilities for doc/block rendering, spatial math, Markdown, and storage",
5
+ "license": "MIT",
6
+ "author": "Bendyline",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/nicknisi/squisq.git",
10
+ "directory": "packages/core"
11
+ },
12
+ "homepage": "https://github.com/nicknisi/squisq",
13
+ "keywords": [
14
+ "doc",
15
+ "block",
16
+ "template",
17
+ "spatial",
18
+ "geohash",
19
+ "markdown",
20
+ "storage"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "type": "module",
26
+ "main": "./dist/index.js",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "files": [
30
+ "dist",
31
+ "src"
32
+ ],
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.js",
37
+ "default": "./dist/index.js"
38
+ },
39
+ "./schemas": {
40
+ "types": "./dist/schemas/index.d.ts",
41
+ "import": "./dist/schemas/index.js",
42
+ "default": "./dist/schemas/index.js"
43
+ },
44
+ "./spatial": {
45
+ "types": "./dist/spatial/index.d.ts",
46
+ "import": "./dist/spatial/index.js",
47
+ "default": "./dist/spatial/index.js"
48
+ },
49
+ "./story": {
50
+ "types": "./dist/story/index.d.ts",
51
+ "import": "./dist/story/index.js",
52
+ "default": "./dist/story/index.js"
53
+ },
54
+ "./doc": {
55
+ "types": "./dist/doc/index.d.ts",
56
+ "import": "./dist/doc/index.js",
57
+ "default": "./dist/doc/index.js"
58
+ },
59
+ "./storage": {
60
+ "types": "./dist/storage/index.d.ts",
61
+ "import": "./dist/storage/index.js",
62
+ "default": "./dist/storage/index.js"
63
+ },
64
+ "./markdown": {
65
+ "types": "./dist/markdown/index.d.ts",
66
+ "import": "./dist/markdown/index.js",
67
+ "default": "./dist/markdown/index.js"
68
+ }
69
+ },
70
+ "scripts": {
71
+ "build": "tsup",
72
+ "typecheck": "tsc --noEmit",
73
+ "prepublishOnly": "npm run build"
74
+ },
75
+ "dependencies": {
76
+ "hast-util-from-html": "^2.0.0",
77
+ "localforage": "^1.10.0",
78
+ "ngeohash": "^0.6.3",
79
+ "remark-directive": "^3.0.0",
80
+ "remark-frontmatter": "^5.0.0",
81
+ "remark-gfm": "^4.0.0",
82
+ "remark-math": "^6.0.0",
83
+ "remark-parse": "^11.0.0",
84
+ "remark-stringify": "^11.0.0",
85
+ "unified": "^11.0.0"
86
+ },
87
+ "devDependencies": {
88
+ "tsup": "^8.0.0",
89
+ "typescript": "^5.3.0"
90
+ }
91
+ }
@@ -0,0 +1,77 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import {
3
+ getAnimationStyle,
4
+ getDefaultAnimationDuration,
5
+ getTransitionClass,
6
+ getAnimationProgress,
7
+ } from '../doc/utils/animationUtils';
8
+
9
+ describe('getAnimationStyle', () => {
10
+ it('returns empty for undefined animation', () => {
11
+ const result = getAnimationStyle(undefined);
12
+ expect(result.className).toBe('');
13
+ expect(result.style).toEqual({});
14
+ });
15
+
16
+ it('returns empty for type "none"', () => {
17
+ const result = getAnimationStyle({ type: 'none' });
18
+ expect(result.className).toBe('');
19
+ });
20
+
21
+ it('returns correct class for fadeIn', () => {
22
+ const result = getAnimationStyle({ type: 'fadeIn' });
23
+ expect(result.className).toBe('anim-fadeIn');
24
+ });
25
+
26
+ it('returns correct class for slowZoom with pan', () => {
27
+ const result = getAnimationStyle({ type: 'slowZoom', panDirection: 'left' });
28
+ expect(result.className).toBe('anim-slowZoom-panLeft');
29
+ });
30
+
31
+ it('includes CSS custom properties for duration and delay', () => {
32
+ const result = getAnimationStyle({ type: 'fadeIn', duration: 2, delay: 0.5 });
33
+ expect(result.style['--anim-duration']).toBe('2s');
34
+ expect(result.style['--anim-delay']).toBe('0.5s');
35
+ });
36
+ });
37
+
38
+ describe('getDefaultAnimationDuration', () => {
39
+ it('returns 8 for slowZoom', () => {
40
+ expect(getDefaultAnimationDuration('slowZoom')).toBe(8);
41
+ });
42
+
43
+ it('returns 1 for fadeIn', () => {
44
+ expect(getDefaultAnimationDuration('fadeIn')).toBe(1);
45
+ });
46
+
47
+ it('returns 0.5 for zoomIn', () => {
48
+ expect(getDefaultAnimationDuration('zoomIn')).toBe(0.5);
49
+ });
50
+ });
51
+
52
+ describe('getTransitionClass', () => {
53
+ it('returns enter class', () => {
54
+ expect(getTransitionClass('fade', true)).toBe('transition-fade-enter');
55
+ });
56
+
57
+ it('returns exit class', () => {
58
+ expect(getTransitionClass('dissolve', false)).toBe('transition-dissolve-exit');
59
+ });
60
+ });
61
+
62
+ describe('getAnimationProgress', () => {
63
+ it('returns 0 before delay', () => {
64
+ const progress = getAnimationProgress({ type: 'fadeIn', delay: 1, duration: 2 }, 0.5, 5);
65
+ expect(progress).toBe(0);
66
+ });
67
+
68
+ it('returns 1 after completion', () => {
69
+ const progress = getAnimationProgress({ type: 'fadeIn', delay: 0, duration: 2 }, 3, 5);
70
+ expect(progress).toBe(1);
71
+ });
72
+
73
+ it('returns 0.5 at midpoint', () => {
74
+ const progress = getAnimationProgress({ type: 'fadeIn', delay: 0, duration: 2 }, 1, 5);
75
+ expect(progress).toBeCloseTo(0.5);
76
+ });
77
+ });