@openpresentation/opf 0.26.3 → 0.26.4
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/README.md +1 -1
- package/dist/browser.js +13 -11
- package/dist/{chunk-34LIUOT7.js → chunk-6IXSHIAL.js} +6 -6
- package/dist/{chunk-PXOXTJTN.js → chunk-6NBTZYYD.js} +1 -1
- package/dist/{chunk-FXNUM2PN.js → chunk-EDCRBTJF.js} +4 -4
- package/dist/chunk-GWJBZ4LC.js +639 -0
- package/dist/{chunk-YVNFACTC.js → chunk-H5QC3X3K.js} +1 -1
- package/dist/{chunk-WASENX2R.js → chunk-MN7DRK57.js} +40 -648
- package/dist/{chunk-GLLR3AQ5.js → chunk-NZLW6FBQ.js} +1 -1
- package/dist/{chunk-7RY7QWWJ.js → chunk-O6BY3AU2.js} +1 -1
- package/dist/{chunk-PB5X2VSV.js → chunk-PIO73BQ6.js} +4 -3
- package/dist/{chunk-DEI2M2H6.js → chunk-QAEBYDKY.js} +2 -4
- package/dist/{chunk-54OV2WQC.js → chunk-QH2W6HIM.js} +1 -1
- package/dist/chunk-RYZPBJLB.js +4 -0
- package/dist/{chunk-NJWI6MPT.js → chunk-XFOOKVRI.js} +16 -1
- package/dist/{chunk-2ZQBMZTZ.js → chunk-ZSZDVIDV.js} +2 -2
- package/dist/{conversion-BjsKgxBZ.d.ts → conversion-DSafOGzh.d.ts} +2 -2
- package/dist/conversion-QIAJM6DQ.js +20 -0
- package/dist/convert.js +5 -5
- package/dist/deck.js +9 -7
- package/dist/diff.js +2 -2
- package/dist/docs.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +17 -15
- package/dist/markdown.js +7 -5
- package/dist/node-engine.d.ts +2 -2
- package/dist/node-engine.js +17 -15
- package/dist/pagination.js +2 -2
- package/dist/patch.js +1 -1
- package/dist/schema.js +1 -1
- package/dist/source.d.ts +102 -4
- package/dist/source.js +388 -9
- package/dist/validator.js +1 -1
- package/dist/yaml.js +5 -4
- package/package.json +5 -5
- package/dist/conversion-F4UCOGR7.js +0 -18
package/dist/markdown.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export { fromMarkdown, toMarkdown } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
|
|
4
|
-
import './chunk-
|
|
5
|
-
|
|
1
|
+
export { fromMarkdown, toMarkdown } from './chunk-GWJBZ4LC.js';
|
|
2
|
+
import './chunk-RYZPBJLB.js';
|
|
3
|
+
import './chunk-MN7DRK57.js';
|
|
4
|
+
import './chunk-O6BY3AU2.js';
|
|
5
|
+
export { OPFMarkdownError } from './chunk-QAEBYDKY.js';
|
|
6
|
+
import './chunk-6NBTZYYD.js';
|
|
7
|
+
import './chunk-XFOOKVRI.js';
|
|
6
8
|
import './chunk-XRMV2GMB.js';
|
|
7
9
|
import './chunk-F4HFDP6I.js';
|
package/dist/node-engine.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { b as DeckReport, c as DeckReportOptions, r as readDeckReport } from './deck-report-5vwMGcQz.js';
|
|
2
|
-
import { F as FontsHandle, j as EmbeddedFace, R as Renderer, k as Reporter, P as Peer, l as PptxModule, f as OPFApiError } from './conversion-
|
|
3
|
-
export { m as ConversionPlan, D as Diagnostic, n as EXPORT_FORMATS, o as EXPORT_TEXT, q as ExportContext, r as ExportFile, s as ExportFontSummary, E as ExportFormat, t as ExportOptions, u as ExportResult, v as ExportRun, w as ExportText, I as ImportOptions, x as ImportResult, g as OPFExportError, h as OPFImportError, y as PEER_RANGES, z as PPTX_PACKAGE, A as PreparedExport, B as RENDER_EXTRAS, G as RENDER_PACKAGE, H as ReportFinding, J as ResolvedExportOptions, i as SlideSelection, K as Source, V as VERSIONS, L as asApiError, M as assetRoot, N as checkDate, Q as checkOptions, T as checkRenamedOptions, U as checkScale, W as deckFileFormat, X as exportFormatOf, Y as finishReport, Z as importPresentation, _ as loadPptx, $ as loadRenderer, a0 as locatePackage, a1 as missingPeerFrom, p as parseSlideSelection, a2 as planConversion, a3 as prepareExport, a4 as reaches, a5 as readInput, a6 as reportThrown, a7 as resolveExportOptions, a8 as runExport, a9 as runPreparedExport, aa as writePlanned } from './conversion-
|
|
2
|
+
import { F as FontsHandle, j as EmbeddedFace, R as Renderer, k as Reporter, P as Peer, l as PptxModule, f as OPFApiError } from './conversion-DSafOGzh.js';
|
|
3
|
+
export { m as ConversionPlan, D as Diagnostic, n as EXPORT_FORMATS, o as EXPORT_TEXT, q as ExportContext, r as ExportFile, s as ExportFontSummary, E as ExportFormat, t as ExportOptions, u as ExportResult, v as ExportRun, w as ExportText, I as ImportOptions, x as ImportResult, g as OPFExportError, h as OPFImportError, y as PEER_RANGES, z as PPTX_PACKAGE, A as PreparedExport, B as RENDER_EXTRAS, G as RENDER_PACKAGE, H as ReportFinding, J as ResolvedExportOptions, i as SlideSelection, K as Source, V as VERSIONS, L as asApiError, M as assetRoot, N as checkDate, Q as checkOptions, T as checkRenamedOptions, U as checkScale, W as deckFileFormat, X as exportFormatOf, Y as finishReport, Z as importPresentation, _ as loadPptx, $ as loadRenderer, a0 as locatePackage, a1 as missingPeerFrom, p as parseSlideSelection, a2 as planConversion, a3 as prepareExport, a4 as reaches, a5 as readInput, a6 as reportThrown, a7 as resolveExportOptions, a8 as runExport, a9 as runPreparedExport, aa as writePlanned } from './conversion-DSafOGzh.js';
|
|
4
4
|
import { a as Catalog } from './catalog-refs-BSfGELpt.js';
|
|
5
5
|
import { e as PresentationPaginationResult } from './pagination-D_kJe4jH.js';
|
|
6
6
|
import './presentation-Bwo8Ko6D.js';
|
package/dist/node-engine.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { loadRenderer, listFontDirectories, leaseSharedFonts, prepareFonts } from './chunk-
|
|
2
|
-
export { EXPORT_FORMATS, EXPORT_TEXT, PEER_RANGES, PPTX_PACKAGE, RENDER_EXTRAS, RENDER_PACKAGE, Reporter, VERSIONS, assetRoot, checkDate, checkDestinations, checkOptions, checkOutputPattern, checkRenamedOptions, checkScale, createZip, deckFileFormat, deckStem, embeddedFor, exportFormatOf, finishReport, importPresentation, leaseSharedFonts, listFontDirectories, loadPptx, loadRenderer, localAssetProblems, locatePackage, missingPeerFrom, padNumber, planConversion, pointerOf, prepareExport, prepareFonts, publishNew, reaches, readInput, reportThrown, resolveExportOptions, runExport, runImport, runPreparedExport, stemOf, writeFiles, writePlanned } from './chunk-
|
|
3
|
-
import { defaultCatalogs } from './chunk-
|
|
4
|
-
export { defaultCatalogs, galleryMismatch } from './chunk-
|
|
5
|
-
import { OPFApiError } from './chunk-
|
|
6
|
-
export { OPFApiError, OPFExportError, OPFImportError, asApiError, parseSlideSelection } from './chunk-
|
|
1
|
+
import { loadRenderer, listFontDirectories, leaseSharedFonts, prepareFonts } from './chunk-6IXSHIAL.js';
|
|
2
|
+
export { EXPORT_FORMATS, EXPORT_TEXT, PEER_RANGES, PPTX_PACKAGE, RENDER_EXTRAS, RENDER_PACKAGE, Reporter, VERSIONS, assetRoot, checkDate, checkDestinations, checkOptions, checkOutputPattern, checkRenamedOptions, checkScale, createZip, deckFileFormat, deckStem, embeddedFor, exportFormatOf, finishReport, importPresentation, leaseSharedFonts, listFontDirectories, loadPptx, loadRenderer, localAssetProblems, locatePackage, missingPeerFrom, padNumber, planConversion, pointerOf, prepareExport, prepareFonts, publishNew, reaches, readInput, reportThrown, resolveExportOptions, runExport, runImport, runPreparedExport, stemOf, writeFiles, writePlanned } from './chunk-6IXSHIAL.js';
|
|
3
|
+
import { defaultCatalogs } from './chunk-ZSZDVIDV.js';
|
|
4
|
+
export { defaultCatalogs, galleryMismatch } from './chunk-ZSZDVIDV.js';
|
|
5
|
+
import { OPFApiError } from './chunk-NZLW6FBQ.js';
|
|
6
|
+
export { OPFApiError, OPFExportError, OPFImportError, asApiError, parseSlideSelection } from './chunk-NZLW6FBQ.js';
|
|
7
7
|
import './chunk-UJSAR6GF.js';
|
|
8
8
|
import './chunk-PJSPHHRK.js';
|
|
9
9
|
import './chunk-TKQ2VFV5.js';
|
|
10
|
-
import { paginate } from './chunk-
|
|
11
|
-
export { readDeckReport } from './chunk-
|
|
12
|
-
import './chunk-
|
|
13
|
-
import './chunk-
|
|
14
|
-
import './chunk-
|
|
15
|
-
import './chunk-
|
|
16
|
-
import './chunk-
|
|
17
|
-
import './chunk-
|
|
18
|
-
import './chunk-
|
|
10
|
+
import { paginate } from './chunk-QH2W6HIM.js';
|
|
11
|
+
export { readDeckReport } from './chunk-EDCRBTJF.js';
|
|
12
|
+
import './chunk-GWJBZ4LC.js';
|
|
13
|
+
import './chunk-PIO73BQ6.js';
|
|
14
|
+
import './chunk-RYZPBJLB.js';
|
|
15
|
+
import './chunk-MN7DRK57.js';
|
|
16
|
+
import './chunk-O6BY3AU2.js';
|
|
17
|
+
import './chunk-QAEBYDKY.js';
|
|
18
|
+
import './chunk-6NBTZYYD.js';
|
|
19
|
+
import './chunk-H5QC3X3K.js';
|
|
20
|
+
import './chunk-XFOOKVRI.js';
|
|
19
21
|
import './chunk-XRMV2GMB.js';
|
|
20
22
|
import './chunk-EQ6S5SEZ.js';
|
|
21
23
|
import './chunk-F4HFDP6I.js';
|
package/dist/pagination.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { OPFPaginationError, paginate, paginateSlide } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { OPFPaginationError, paginate, paginateSlide } from './chunk-QH2W6HIM.js';
|
|
2
|
+
import './chunk-XFOOKVRI.js';
|
|
3
3
|
import './chunk-XRMV2GMB.js';
|
|
4
4
|
import './chunk-F4HFDP6I.js';
|
package/dist/patch.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { OPFPatchError, OPFPatchValidationError, applyPatch, applyPatchWithInverse, escapePointerToken, formatPointer, getAtPointer, hasPointer, invertPatch, jsonEqual, normalizePatch, parsePointer, pointerFromPath, readPointer, splitPointer, unescapePointerToken } from './chunk-
|
|
1
|
+
export { OPFPatchError, OPFPatchValidationError, applyPatch, applyPatchWithInverse, escapePointerToken, formatPointer, getAtPointer, hasPointer, invertPatch, jsonEqual, normalizePatch, parsePointer, pointerFromPath, readPointer, splitPointer, unescapePointerToken } from './chunk-XFOOKVRI.js';
|
|
2
2
|
import './chunk-XRMV2GMB.js';
|
|
3
3
|
import './chunk-F4HFDP6I.js';
|
package/dist/schema.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { COMMON_KEYS, UNRANKED_PRIORITY, activeSchema, catalogKindAt, createSchemaValue, describeField, isPromotedRegionKey, listSchemaFields, resolveSchema, schemaAtPath, schemaCatalogKinds, schemaLabel, schemaType, schemaVariants, splitOpfPath } from './chunk-
|
|
1
|
+
export { COMMON_KEYS, UNRANKED_PRIORITY, activeSchema, catalogKindAt, createSchemaValue, describeField, isPromotedRegionKey, listSchemaFields, resolveSchema, schemaAtPath, schemaCatalogKinds, schemaLabel, schemaType, schemaVariants, splitOpfPath } from './chunk-XFOOKVRI.js';
|
|
2
2
|
import './chunk-XRMV2GMB.js';
|
|
3
3
|
import './chunk-F4HFDP6I.js';
|
package/dist/source.d.ts
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
import { b as FindingLocation } from './finding-l9dlQ2NF.js';
|
|
2
2
|
|
|
3
|
+
/** Keys of `<!-- slide: ... -->`. */
|
|
4
|
+
declare const SLIDE_OPTION_KEYS: readonly ["id", "type", "layout", "section", "tag", "hidden", "beat"];
|
|
5
|
+
/** Keys of `<!-- block: ... -->`. */
|
|
6
|
+
declare const BLOCK_OPTION_KEYS: readonly ["id", "type", "as", "region"];
|
|
7
|
+
/** Values of `as=` in a block options comment. */
|
|
8
|
+
declare const BLOCK_AS_VALUES: readonly ["bullets", "video"];
|
|
9
|
+
/** The first word of a fence info string that is not code: `chart`, `metric`, `timeline` and the two YAML escape hatches. */
|
|
10
|
+
declare const FENCE_KINDS: readonly ["chart", "metric", "timeline", "opf-block", "opf-slide"];
|
|
11
|
+
/** Lines of a ```metric fence: `key: value`. */
|
|
12
|
+
declare const METRIC_KEYS: readonly ["value", "label", "description", "unit", "delta", "trend", "sentiment"];
|
|
13
|
+
/** Attributes after the info word: `chart` takes `alt`, `timeline` `name` and `description`, a code fence `title`. */
|
|
14
|
+
declare const FENCE_ATTRIBUTES: {
|
|
15
|
+
readonly chart: readonly ["alt"];
|
|
16
|
+
readonly timeline: readonly ["name", "description"];
|
|
17
|
+
readonly code: readonly ["title"];
|
|
18
|
+
};
|
|
19
|
+
/** Flags of an inline span `[text]{bold italic}` (the converter also reads `strikethrough`, `superscript` and `subscript`). */
|
|
20
|
+
declare const SPAN_FLAGS: readonly ["bold", "italic", "underline", "strike", "sup", "sub"];
|
|
21
|
+
/** Attributes of an inline span that take a value: `[text]{color=#B42318 size=24 font="Open Sans" lang=fr}`. */
|
|
22
|
+
declare const SPAN_VALUES: readonly ["color", "size", "font", "lang"];
|
|
23
|
+
/** Keywords a line of a slide can start with. */
|
|
24
|
+
declare const LINE_KEYWORDS: readonly ["Note:", "Notes:"];
|
|
25
|
+
type FenceKind = (typeof FENCE_KINDS)[number];
|
|
26
|
+
|
|
3
27
|
/**
|
|
4
28
|
* A range of source text in the `Finding.location` convention: UTF-16 offset and length, 1-based line and column (a line break is
|
|
5
29
|
* `\r\n`, `\r` or `\n`). `exact: false` marks a range that is the nearest ancestor of a node the text does not have.
|
|
@@ -85,13 +109,87 @@ interface PathAtResult {
|
|
|
85
109
|
* underlined in the source. Tolerant: it reads text with syntax errors, comments and trailing commas as far as it can be read.
|
|
86
110
|
* When the node does not exist, the range is that of the nearest ancestor that does, with `exact: false`.
|
|
87
111
|
*
|
|
88
|
-
*
|
|
112
|
+
* JSON, YAML and Markdown. YAML is read with the `yaml` library's tolerant parse, so a text with syntax errors is located as far as it
|
|
113
|
+
* can be read. Markdown uses the ranges the converter records for every part it reads (the ones its findings are located by): a
|
|
114
|
+
* slide, its title, a list item, a block, the `layout=` of an options comment, the keys of the front matter and of the YAML in
|
|
115
|
+
* `opf-slide` and `opf-block` fences. A slide field the Markdown writes as a line (`# Title`, `- item`) has `value` = the text after
|
|
116
|
+
* the marker, `key` = the marker and `entry` = the line.
|
|
89
117
|
*/
|
|
90
118
|
declare function locate(text: string, format: SourceFormat, pointer: string | readonly (string | number)[], options?: LocateOptions): TextRange | undefined;
|
|
91
119
|
/**
|
|
92
|
-
* The document path and the kind of position at a character offset (a caret between characters)
|
|
93
|
-
*
|
|
120
|
+
* The document path and the kind of position at a character offset (a caret between characters), in JSON, YAML or Markdown.
|
|
121
|
+
* Tolerant of broken text. In YAML a position on the whitespace of a blank line is `none` after the last node and `between` inside
|
|
122
|
+
* a collection; in Markdown a position outside the front matter and the slides is `none`.
|
|
94
123
|
*/
|
|
95
124
|
declare function pathAt(text: string, format: SourceFormat, offset: number): PathAtResult | undefined;
|
|
96
125
|
|
|
97
|
-
|
|
126
|
+
/** A range of the text: UTF-16 offsets, `from` inclusive and `to` exclusive, and the one-based line `from` is on. */
|
|
127
|
+
interface ScanRange {
|
|
128
|
+
from: number;
|
|
129
|
+
to: number;
|
|
130
|
+
line: number;
|
|
131
|
+
}
|
|
132
|
+
interface MarkdownFrontMatter extends ScanRange {
|
|
133
|
+
/** The YAML between the two `---` lines: from the end of the opening line to the start of the closing line. */
|
|
134
|
+
yamlFrom: number;
|
|
135
|
+
yamlTo: number;
|
|
136
|
+
/** False when the closing `---` (or `...`) line is missing: then the YAML runs to the end of the text. */
|
|
137
|
+
closed: boolean;
|
|
138
|
+
}
|
|
139
|
+
interface MarkdownSlideScan extends ScanRange {
|
|
140
|
+
/** The slide's number in the converted deck (empty segments between `---` lines are not slides). */
|
|
141
|
+
index: number;
|
|
142
|
+
}
|
|
143
|
+
interface MarkdownCommentScan extends ScanRange {
|
|
144
|
+
/** `slide` and `block` are options comments (`<!-- slide: ... -->`), `comment` any other. */
|
|
145
|
+
kind: "slide" | "block" | "comment";
|
|
146
|
+
/** The text between `<!--` and `-->` (for an unclosed comment, to the end of its last line). */
|
|
147
|
+
innerFrom: number;
|
|
148
|
+
innerTo: number;
|
|
149
|
+
closed: boolean;
|
|
150
|
+
/** The slide it is in. */
|
|
151
|
+
slide: number;
|
|
152
|
+
}
|
|
153
|
+
interface MarkdownFenceScan extends ScanRange {
|
|
154
|
+
/** The opening fence characters (```` ``` ````, `~~~~`). */
|
|
155
|
+
marker: string;
|
|
156
|
+
/** The info string after the fence characters, trimmed; `infoFrom` and `infoTo` are its offsets. */
|
|
157
|
+
info: string;
|
|
158
|
+
infoFrom: number;
|
|
159
|
+
infoTo: number;
|
|
160
|
+
/** The first word of the info string. */
|
|
161
|
+
word: string;
|
|
162
|
+
/** `chart`, `metric`, `timeline`, `opf-block`, `opf-slide`, or `code` for any other fence. */
|
|
163
|
+
kind: FenceKind | "code";
|
|
164
|
+
/** The lines between the fences: `bodyFrom` is the start of the first line, `bodyTo` the end of the last (equal when the body is empty). */
|
|
165
|
+
bodyFrom: number;
|
|
166
|
+
bodyTo: number;
|
|
167
|
+
closed: boolean;
|
|
168
|
+
slide: number;
|
|
169
|
+
}
|
|
170
|
+
interface MarkdownNotesScan extends ScanRange {
|
|
171
|
+
slide: number;
|
|
172
|
+
}
|
|
173
|
+
interface MarkdownScan {
|
|
174
|
+
frontMatter?: MarkdownFrontMatter;
|
|
175
|
+
/** The slides, in order; each runs from its first to its last non-blank line. */
|
|
176
|
+
slides: MarkdownSlideScan[];
|
|
177
|
+
/** Offsets of the `---` lines that separate slides. */
|
|
178
|
+
separators: number[];
|
|
179
|
+
comments: MarkdownCommentScan[];
|
|
180
|
+
fences: MarkdownFenceScan[];
|
|
181
|
+
/** Speaker notes: from the `Note:` or `Notes:` line to the end of the slide. */
|
|
182
|
+
notes: MarkdownNotesScan[];
|
|
183
|
+
}
|
|
184
|
+
interface ScanMarkdownOptions {
|
|
185
|
+
/** How the text is cut into slides, as for `fromMarkdown`. */
|
|
186
|
+
split?: "auto" | "rules" | "headings";
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The structure of a Markdown deck, found with the converter's line rules: front matter, slides, option comments, fences and notes, as
|
|
190
|
+
* offset ranges. Tolerant: an unclosed front matter, comment or fence is reported with `closed: false` and runs to the end of its slide.
|
|
191
|
+
* It is the one place an editor learns the dialect's regions from.
|
|
192
|
+
*/
|
|
193
|
+
declare function scanMarkdown(source: string, options?: ScanMarkdownOptions): MarkdownScan;
|
|
194
|
+
|
|
195
|
+
export { type AnalyzeOptions, BLOCK_AS_VALUES, BLOCK_OPTION_KEYS, FENCE_ATTRIBUTES, FENCE_KINDS, LINE_KEYWORDS, type LocateOptions, type LocatePart, METRIC_KEYS, type MarkdownCommentScan, type MarkdownFenceScan, type MarkdownFrontMatter, type MarkdownNotesScan, type MarkdownScan, type MarkdownSlideScan, type PathAtResult, SLIDE_OPTION_KEYS, SPAN_FLAGS, SPAN_VALUES, type ScanMarkdownOptions, type ScanRange, type SourceFormat, type SyntaxFix, type SyntaxProblem, type SyntaxProblemCode, type TextEdit, type TextRange, analyzeJsonSyntax, applyTextEdits, locate, pathAt, scanMarkdown };
|
package/dist/source.js
CHANGED
|
@@ -1,10 +1,376 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { readMarkdown, frontMatter, splitSegments, isOutline, NOTES, fenceStart, fenceClose, COMMENT, SLIDE_OPTION_KEYS, FENCE_KINDS } from './chunk-MN7DRK57.js';
|
|
2
|
+
export { BLOCK_AS_VALUES, BLOCK_OPTION_KEYS, FENCE_ATTRIBUTES, FENCE_KINDS, LINE_KEYWORDS, METRIC_KEYS, SLIDE_OPTION_KEYS, SPAN_FLAGS, SPAN_VALUES } from './chunk-MN7DRK57.js';
|
|
3
|
+
import './chunk-O6BY3AU2.js';
|
|
4
|
+
import { splitLines } from './chunk-QAEBYDKY.js';
|
|
5
|
+
import './chunk-6NBTZYYD.js';
|
|
6
|
+
import { rememberByText, createLocator, parsePointer } from './chunk-XFOOKVRI.js';
|
|
7
|
+
export { analyzeJsonSyntax, applyTextEdits } from './chunk-XFOOKVRI.js';
|
|
3
8
|
import './chunk-XRMV2GMB.js';
|
|
4
9
|
import './chunk-F4HFDP6I.js';
|
|
5
10
|
import { findNodeAtOffset, getNodePath, parseTree } from 'jsonc-parser';
|
|
11
|
+
import { parseDocument, isMap, isSeq, isScalar, isAlias } from 'yaml';
|
|
6
12
|
|
|
13
|
+
var read = rememberByText(readText);
|
|
14
|
+
function readText(text) {
|
|
15
|
+
const bom = text.startsWith("\uFEFF") ? 1 : 0;
|
|
16
|
+
const body = bom ? text.slice(1) : text;
|
|
17
|
+
const document = parseDocument(body, { prettyErrors: false, uniqueKeys: false, merge: false, strict: false });
|
|
18
|
+
return { text: body, root: document.contents ?? null, shift: bom };
|
|
19
|
+
}
|
|
20
|
+
var isBlank = (char) => char === " " || char === " " || char === "\n" || char === "\r";
|
|
21
|
+
function endOf(text, node) {
|
|
22
|
+
let end = node.range[1];
|
|
23
|
+
const start = node.range[0];
|
|
24
|
+
while (end > start && isBlank(text[end - 1])) end--;
|
|
25
|
+
return end;
|
|
26
|
+
}
|
|
27
|
+
var startOf = (node) => node.range[0];
|
|
28
|
+
var keyName = (key) => isScalar(key) ? String(key.value) : isAlias(key) ? void 0 : key !== null && typeof key === "object" && "toString" in key ? String(key.toString()) : void 0;
|
|
29
|
+
var hasText = (text, node) => !!node && node.range[0] < endOf(text, node);
|
|
30
|
+
var pairKey = (pair) => pair.key ?? null;
|
|
31
|
+
var pairValue = (pair) => pair.value ?? null;
|
|
32
|
+
function colonEnd(text, key) {
|
|
33
|
+
let at = key.range[1];
|
|
34
|
+
while (text[at] === " " || text[at] === " ") at++;
|
|
35
|
+
return text[at] === ":" ? at + 1 : key.range[1];
|
|
36
|
+
}
|
|
37
|
+
function member(node, segment) {
|
|
38
|
+
if (isMap(node)) {
|
|
39
|
+
const pair = node.items.find((item) => keyName(item.key) === segment);
|
|
40
|
+
return pair ? { pair, value: pairValue(pair) } : void 0;
|
|
41
|
+
}
|
|
42
|
+
if (isSeq(node)) {
|
|
43
|
+
if (!/^(?:0|[1-9][0-9]*)$/.test(segment)) return void 0;
|
|
44
|
+
const item = node.items[Number(segment)];
|
|
45
|
+
return item === void 0 ? void 0 : { value: item };
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
function openOf(text, value) {
|
|
50
|
+
const start = startOf(value);
|
|
51
|
+
if (isMap(value) && !value.flow) {
|
|
52
|
+
const first = value.items[0];
|
|
53
|
+
const key = first ? pairKey(first) : null;
|
|
54
|
+
if (key) return { offset: startOf(key), length: key.range[1] - startOf(key) };
|
|
55
|
+
}
|
|
56
|
+
return { offset: start, length: Math.min(1, endOf(text, value) - start) };
|
|
57
|
+
}
|
|
58
|
+
function locateYaml(text, segments, part) {
|
|
59
|
+
const { text: body, root, shift } = read(text);
|
|
60
|
+
if (!root || !hasText(body, root)) return void 0;
|
|
61
|
+
let value = root;
|
|
62
|
+
let pair;
|
|
63
|
+
let depth = 0;
|
|
64
|
+
for (const segment of segments) {
|
|
65
|
+
const next = value ? member(value, segment) : void 0;
|
|
66
|
+
if (!value || !next) break;
|
|
67
|
+
pair = next.pair;
|
|
68
|
+
value = next.value;
|
|
69
|
+
depth++;
|
|
70
|
+
}
|
|
71
|
+
const exact = depth === segments.length;
|
|
72
|
+
const key = pair ? pairKey(pair) : null;
|
|
73
|
+
const keySpan = key ? { offset: startOf(key), length: key.range[1] - startOf(key) } : void 0;
|
|
74
|
+
const keyAndColon = key ? { offset: startOf(key), length: colonEnd(body, key) - startOf(key) } : void 0;
|
|
75
|
+
const valueSpan = hasText(body, value) ? { offset: startOf(value), length: endOf(body, value) - startOf(value) } : void 0;
|
|
76
|
+
const choose = (wanted) => {
|
|
77
|
+
switch (wanted) {
|
|
78
|
+
case "value":
|
|
79
|
+
return valueSpan ?? keyAndColon;
|
|
80
|
+
case "open":
|
|
81
|
+
return hasText(body, value) ? openOf(body, value) : keyAndColon;
|
|
82
|
+
case "key":
|
|
83
|
+
return keySpan;
|
|
84
|
+
case "colon":
|
|
85
|
+
return keyAndColon;
|
|
86
|
+
case "entry":
|
|
87
|
+
return keySpan ? { offset: keySpan.offset, length: (valueSpan ? valueSpan.offset + valueSpan.length : (keyAndColon?.offset ?? 0) + (keyAndColon?.length ?? 0)) - keySpan.offset } : void 0;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const found = choose(part) ?? choose("value") ?? (depth === 0 ? { offset: startOf(root), length: endOf(body, root) - startOf(root) } : void 0);
|
|
91
|
+
return found ? { offset: found.offset + shift, length: found.length, exact } : void 0;
|
|
92
|
+
}
|
|
93
|
+
function pathAtYaml(text, offset) {
|
|
94
|
+
const { text: body, root, shift } = read(text);
|
|
95
|
+
const at = offset - shift;
|
|
96
|
+
const none = { path: [], part: "none" };
|
|
97
|
+
if (!root || !hasText(body, root) || at < startOf(root) || at > endOf(body, root)) return none;
|
|
98
|
+
const span = (node) => ({ offset: startOf(node) + shift, length: endOf(body, node) - startOf(node) });
|
|
99
|
+
const inside = (node) => hasText(body, node) && at >= startOf(node) && at <= endOf(body, node);
|
|
100
|
+
const walk = (node, path) => {
|
|
101
|
+
if (isMap(node)) {
|
|
102
|
+
for (const pair of node.items) {
|
|
103
|
+
const key = pairKey(pair);
|
|
104
|
+
const value = pairValue(pair);
|
|
105
|
+
const name = keyName(pair.key);
|
|
106
|
+
if (name === void 0) continue;
|
|
107
|
+
if (key && at >= startOf(key) && at <= key.range[1]) return { path: [...path, name], part: "key", range: span(key) };
|
|
108
|
+
if (inside(value)) return walk(value, [...path, name]);
|
|
109
|
+
if (key && at > key.range[1] && at <= (hasText(body, value) ? startOf(value) : colonEnd(body, key))) {
|
|
110
|
+
const end = hasText(body, value) ? startOf(value) : colonEnd(body, key);
|
|
111
|
+
return { path: [...path, name], part: "between", range: { offset: startOf(key) + shift, length: end - startOf(key) } };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return { path, part: "between", range: span(node) };
|
|
115
|
+
}
|
|
116
|
+
if (isSeq(node)) {
|
|
117
|
+
for (const [index, item] of node.items.entries()) if (inside(item)) return walk(item, [...path, String(index)]);
|
|
118
|
+
return { path, part: "between", range: span(node) };
|
|
119
|
+
}
|
|
120
|
+
return { path, part: "value", range: span(node) };
|
|
121
|
+
};
|
|
122
|
+
return walk(root, []);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/source-markdown.ts
|
|
126
|
+
var BLANK = /^\s*$/;
|
|
127
|
+
var readMarkdown2 = rememberByText((text) => readMarkdown(text));
|
|
128
|
+
var scanMemo = rememberByText((text) => scanUncached(text));
|
|
129
|
+
var isFenceKind = (word) => FENCE_KINDS.includes(word);
|
|
130
|
+
function scanMarkdown(source2, options = {}) {
|
|
131
|
+
return options.split === void 0 ? scanMemo(source2) : scanUncached(source2, options);
|
|
132
|
+
}
|
|
133
|
+
function scanUncached(source2, options = {}) {
|
|
134
|
+
let lines = splitLines(source2);
|
|
135
|
+
if (lines[0]?.text.startsWith("\uFEFF")) lines = [{ ...lines[0], text: lines[0].text.slice(1), start: lines[0].start + 1 }, ...lines.slice(1)];
|
|
136
|
+
const scan = { slides: [], separators: [], comments: [], fences: [], notes: [] };
|
|
137
|
+
const matter = frontMatter(lines);
|
|
138
|
+
let body = lines;
|
|
139
|
+
if (matter === "unterminated") {
|
|
140
|
+
const first = lines[0];
|
|
141
|
+
scan.frontMatter = { from: first.start, to: source2.length, line: 1, yamlFrom: first.end, yamlTo: source2.length, closed: false };
|
|
142
|
+
body = lines.slice(1);
|
|
143
|
+
} else if (matter) {
|
|
144
|
+
const closing = lines[matter.end - 1];
|
|
145
|
+
scan.frontMatter = { from: lines[0].start, to: closing.end, line: 1, yamlFrom: matter.yaml.start, yamlTo: matter.yaml.end, closed: true };
|
|
146
|
+
body = lines.slice(matter.end);
|
|
147
|
+
}
|
|
148
|
+
const split = options.split ?? "auto";
|
|
149
|
+
const segments = splitSegments(body, split === "headings" || split === "auto" && isOutline(body) ? "headings" : "rules");
|
|
150
|
+
const inSegment = new Set(segments.flat());
|
|
151
|
+
for (const line of body) if (!inSegment.has(line) && !BLANK.test(line.text)) scan.separators.push(line.start);
|
|
152
|
+
let index = 0;
|
|
153
|
+
for (const segment of segments) {
|
|
154
|
+
const first = segment.find((line) => !BLANK.test(line.text));
|
|
155
|
+
if (!first) continue;
|
|
156
|
+
const last = [...segment].reverse().find((line) => !BLANK.test(line.text));
|
|
157
|
+
scan.slides.push({ index, from: first.start, to: last.end, line: first.no });
|
|
158
|
+
scanSegment(segment, index, scan);
|
|
159
|
+
index++;
|
|
160
|
+
}
|
|
161
|
+
return scan;
|
|
162
|
+
}
|
|
163
|
+
function scanSegment(lines, slide, scan) {
|
|
164
|
+
let i = 0;
|
|
165
|
+
while (i < lines.length) {
|
|
166
|
+
const line = lines[i];
|
|
167
|
+
const text = line.text;
|
|
168
|
+
if (BLANK.test(text)) {
|
|
169
|
+
i++;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (NOTES.test(text)) {
|
|
173
|
+
scan.notes.push({ from: line.start, to: lines.at(-1).end, line: line.no, slide });
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const open = fenceStart(text);
|
|
177
|
+
if (open) {
|
|
178
|
+
const close = fenceClose(open.fence);
|
|
179
|
+
let end = i + 1;
|
|
180
|
+
while (end < lines.length && !close.test(lines[end].text)) end++;
|
|
181
|
+
const closed = end < lines.length;
|
|
182
|
+
const last = closed ? lines[end] : lines.at(-1);
|
|
183
|
+
const indent = /^ */.exec(text)[0].length;
|
|
184
|
+
const marker = open.fence;
|
|
185
|
+
const infoFrom = line.start + indent + marker.length + /^[ \t]*/.exec(text.slice(indent + marker.length))[0].length;
|
|
186
|
+
const word = /^[^\s{]*/.exec(open.info)[0];
|
|
187
|
+
const bodyLines = lines.slice(i + 1, closed ? end : lines.length);
|
|
188
|
+
scan.fences.push({
|
|
189
|
+
from: line.start,
|
|
190
|
+
to: last.end,
|
|
191
|
+
line: line.no,
|
|
192
|
+
marker,
|
|
193
|
+
info: open.info,
|
|
194
|
+
infoFrom,
|
|
195
|
+
infoTo: infoFrom + open.info.length,
|
|
196
|
+
word,
|
|
197
|
+
kind: isFenceKind(word) ? word : "code",
|
|
198
|
+
bodyFrom: bodyLines[0]?.start ?? line.end,
|
|
199
|
+
bodyTo: bodyLines.at(-1)?.end ?? line.end,
|
|
200
|
+
closed,
|
|
201
|
+
slide
|
|
202
|
+
});
|
|
203
|
+
i = closed ? end + 1 : lines.length;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (COMMENT.test(text)) {
|
|
207
|
+
let end = i;
|
|
208
|
+
while (end < lines.length && !lines[end].text.includes("-->", end === i ? lines[end].text.indexOf("<!--") + 4 : 0)) end++;
|
|
209
|
+
const closed = end < lines.length;
|
|
210
|
+
const last = closed ? lines[end] : lines.at(-1);
|
|
211
|
+
const open2 = text.indexOf("<!--");
|
|
212
|
+
const innerFrom = line.start + open2 + 4;
|
|
213
|
+
const closeAt = closed ? last.start + last.text.indexOf("-->", end === i ? open2 + 4 : 0) : last.end;
|
|
214
|
+
const inner = source(lines, i, closed ? end : lines.length - 1).slice(open2 + 4);
|
|
215
|
+
const kind = /^\s*(slide|block)(?::|(?=\s*(?:-->|$)))/.exec(inner);
|
|
216
|
+
scan.comments.push({ from: line.start, to: closed ? closeAt + 3 : last.end, line: line.no, kind: kind?.[1] ?? "comment", innerFrom, innerTo: closeAt, closed, slide });
|
|
217
|
+
i = closed ? end + 1 : lines.length;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
i++;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function source(lines, first, last) {
|
|
224
|
+
return lines.slice(first, last + 1).map((line) => line.text).join(" ");
|
|
225
|
+
}
|
|
226
|
+
var segmentsOfPointer = (path) => path.map((segment) => `/${segment.replaceAll("~", "~0").replaceAll("/", "~1")}`).join("");
|
|
227
|
+
var SLIDE_OPTIONS = new Set(SLIDE_OPTION_KEYS);
|
|
228
|
+
var OPTIONS_COMMENT = /^\s*<!--/;
|
|
229
|
+
function firstLine(text, range) {
|
|
230
|
+
const end = text.slice(range.start, range.end).search(/[\r\n]/);
|
|
231
|
+
return { offset: range.start, length: end < 0 ? range.end - range.start : end };
|
|
232
|
+
}
|
|
233
|
+
function optionToken(text, comment, key, nth = 0) {
|
|
234
|
+
const inner = text.slice(comment.start, comment.end);
|
|
235
|
+
const open = inner.indexOf("<!--");
|
|
236
|
+
const colon = inner.indexOf(":", open);
|
|
237
|
+
const from = colon < 0 ? open + 4 : colon + 1;
|
|
238
|
+
const pattern = /(?:^|[\s,])([A-Za-z][\w-]*)(=("(?:[^"\\]|\\.)*"|[^\s,"]+))?/g;
|
|
239
|
+
const tail = inner.slice(from);
|
|
240
|
+
let seen = 0;
|
|
241
|
+
for (const match of tail.matchAll(pattern)) {
|
|
242
|
+
if (match[1] !== key) continue;
|
|
243
|
+
if (seen++ !== nth) continue;
|
|
244
|
+
const keyStart = comment.start + from + match.index + match[0].indexOf(match[1]);
|
|
245
|
+
const keySpan = { offset: keyStart, length: key.length };
|
|
246
|
+
const value = match[3] === void 0 ? void 0 : { offset: keyStart + key.length + 1, length: match[3].length };
|
|
247
|
+
return { key: keySpan, ...value ? { value } : {}, entry: { offset: keyStart, length: (value ? value.offset + value.length : keyStart + key.length) - keyStart } };
|
|
248
|
+
}
|
|
249
|
+
return void 0;
|
|
250
|
+
}
|
|
251
|
+
var MARKER = /^( {0,3}(?:#{1,6}|[-+*]|\d{1,9}[.)])[ \t]+)/;
|
|
252
|
+
function afterMarker(text, range) {
|
|
253
|
+
const line = firstLine(text, range);
|
|
254
|
+
const lineText = text.slice(line.offset, line.offset + line.length);
|
|
255
|
+
const match = MARKER.exec(lineText);
|
|
256
|
+
if (!match) return void 0;
|
|
257
|
+
const lead = match[1];
|
|
258
|
+
const markerLength = lead.trimEnd().length;
|
|
259
|
+
const content = lineText.slice(lead.length);
|
|
260
|
+
const trimmed = content.replace(/(?:^|[ \t]+)#+[ \t]*$/, "").trimEnd();
|
|
261
|
+
return { marker: { offset: line.offset + lead.length - lead.trimStart().length, length: markerLength - (lead.length - lead.trimStart().length) }, content: { offset: line.offset + lead.length, length: trimmed.length } };
|
|
262
|
+
}
|
|
263
|
+
function embeddedFenceAt(scan, offset) {
|
|
264
|
+
return scan.fences.find((fence) => (fence.kind === "opf-block" || fence.kind === "opf-slide") && offset >= fence.from && offset <= fence.to);
|
|
265
|
+
}
|
|
266
|
+
function locateMarkdown(text, segments, part) {
|
|
267
|
+
const { ctx, front } = readMarkdown2(text);
|
|
268
|
+
if (segments.length === 0) {
|
|
269
|
+
const trimmed = text.replace(/\s+$/, "").length;
|
|
270
|
+
return trimmed > 0 ? { offset: 0, length: trimmed, exact: true } : void 0;
|
|
271
|
+
}
|
|
272
|
+
if (segments[0] !== "slides") {
|
|
273
|
+
if (!front) return void 0;
|
|
274
|
+
const found = locateYaml(text.slice(front.start, front.end), segments, part);
|
|
275
|
+
if (found) return { offset: found.offset + front.start, length: found.length, exact: found.exact };
|
|
276
|
+
return { offset: front.start, length: Math.max(0, front.end - front.start), exact: false };
|
|
277
|
+
}
|
|
278
|
+
const slidesSpan = () => {
|
|
279
|
+
const first = ctx.ranges.get("/slides/0");
|
|
280
|
+
let last;
|
|
281
|
+
for (let index = 0; ctx.ranges.get(`/slides/${index}`); index++) last = ctx.ranges.get(`/slides/${index}`);
|
|
282
|
+
return first && last ? { start: first.start, end: last.end } : void 0;
|
|
283
|
+
};
|
|
284
|
+
let consumed = segments.length;
|
|
285
|
+
let range;
|
|
286
|
+
for (; consumed > 1; consumed--) {
|
|
287
|
+
range = ctx.ranges.get(segmentsOfPointer(segments.slice(0, consumed)));
|
|
288
|
+
if (range) break;
|
|
289
|
+
}
|
|
290
|
+
if (!range) {
|
|
291
|
+
const whole = slidesSpan();
|
|
292
|
+
return whole ? { offset: whole.start, length: whole.end - whole.start, exact: segments.length === 1 } : void 0;
|
|
293
|
+
}
|
|
294
|
+
const exact = consumed === segments.length;
|
|
295
|
+
const field = segments[2];
|
|
296
|
+
if (consumed >= 3 && field !== void 0 && SLIDE_OPTIONS.has(field) && OPTIONS_COMMENT.test(text.slice(range.start, range.end))) {
|
|
297
|
+
const beatIndex = field === "beat" && consumed === 3 && segments[3] !== void 0 && /^\d+$/.test(segments[3]) ? Number(segments[3]) : 0;
|
|
298
|
+
const token = optionToken(text, range, field, beatIndex);
|
|
299
|
+
if (token) {
|
|
300
|
+
const span = part === "key" ? token.key : part === "entry" || part === "colon" ? token.entry : token.value ?? token.key;
|
|
301
|
+
return { ...span, exact: exact || field === "beat" && consumed === 3 && segments.length === 4 };
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (!exact) {
|
|
305
|
+
const fence = embeddedFenceAt(scanMarkdown(text), range.start);
|
|
306
|
+
if (fence) {
|
|
307
|
+
const rest = consumed >= 4 && segments[2] === "blocks" ? segments.slice(4) : consumed === 3 ? segments.slice(2) : void 0;
|
|
308
|
+
const inside = rest?.length ? locateYaml(text.slice(fence.bodyFrom, fence.bodyTo), rest, part) : void 0;
|
|
309
|
+
if (inside) return { offset: inside.offset + fence.bodyFrom, length: inside.length, exact: inside.exact };
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const title = consumed === 3 && (field === "title" || field === "subtitle");
|
|
313
|
+
const item = exact && segments.length >= 4 && /^\d+$/.test(segments[segments.length - 1]) && segments[segments.length - 2] !== "blocks";
|
|
314
|
+
if (exact && (title || item)) {
|
|
315
|
+
const marked = afterMarker(text, range);
|
|
316
|
+
if (marked) {
|
|
317
|
+
const span = part === "key" ? marked.marker : part === "entry" ? firstLine(text, range) : marked.content;
|
|
318
|
+
if (span.length > 0) return { ...span, exact: true };
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (part === "open") return { ...firstLine(text, range), exact };
|
|
322
|
+
return { offset: range.start, length: Math.max(0, range.end - range.start), exact };
|
|
323
|
+
}
|
|
324
|
+
var unescapeSegment = (segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
325
|
+
var spanOf = (range) => ({ offset: range.start, length: range.end - range.start });
|
|
326
|
+
function pathAtMarkdown(text, offset) {
|
|
327
|
+
const { ctx, front } = readMarkdown2(text);
|
|
328
|
+
if (front && offset >= front.start && offset <= front.end) {
|
|
329
|
+
const inside = pathAtYaml(text.slice(front.start, front.end), offset - front.start);
|
|
330
|
+
return { path: inside.path, part: inside.part === "none" ? "between" : inside.part, ...inside.range ? { range: { offset: inside.range.offset + front.start, length: inside.range.length } } : {} };
|
|
331
|
+
}
|
|
332
|
+
const scan = scanMarkdown(text);
|
|
333
|
+
const fence = embeddedFenceAt(scan, offset);
|
|
334
|
+
if (fence && offset >= fence.bodyFrom && offset <= fence.bodyTo) {
|
|
335
|
+
const inside = pathAtYaml(text.slice(fence.bodyFrom, fence.bodyTo), offset - fence.bodyFrom);
|
|
336
|
+
if (inside.part !== "none" && inside.path.length) {
|
|
337
|
+
const block = fence.kind === "opf-block" ? blockIndex(ctx.ranges, fence.slide, fence.from) : -1;
|
|
338
|
+
const prefix = block >= 0 ? ["slides", String(fence.slide), "blocks", String(block)] : ["slides", String(fence.slide)];
|
|
339
|
+
return { path: [...prefix, ...inside.path], part: inside.part, ...inside.range ? { range: { offset: inside.range.offset + fence.bodyFrom, length: inside.range.length } } : {} };
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
let best;
|
|
343
|
+
for (const [pointer, range] of ctx.ranges) {
|
|
344
|
+
if (!pointer.startsWith("/slides/") || offset < range.start || offset > range.end) continue;
|
|
345
|
+
const depth = pointer.split("/").length;
|
|
346
|
+
if (!best || depth > best.depth || depth === best.depth && range.end - range.start < best.range.end - best.range.start) best = { pointer, range, depth };
|
|
347
|
+
}
|
|
348
|
+
if (!best) return { path: [], part: "none" };
|
|
349
|
+
const path = best.pointer.split("/").slice(1).map(unescapeSegment);
|
|
350
|
+
const field = path[2];
|
|
351
|
+
if (path.length === 3 && field && SLIDE_OPTIONS.has(field) && OPTIONS_COMMENT.test(text.slice(best.range.start, best.range.end))) {
|
|
352
|
+
for (const key of SLIDE_OPTIONS) {
|
|
353
|
+
for (let nth = 0; ; nth++) {
|
|
354
|
+
const token = optionToken(text, best.range, key, nth);
|
|
355
|
+
if (!token) break;
|
|
356
|
+
const at = key === "beat" ? [path[0], path[1], key, String(nth)] : [path[0], path[1], key];
|
|
357
|
+
if (offset >= token.key.offset && offset <= token.key.offset + token.key.length) return { path: at, part: "key", range: token.key };
|
|
358
|
+
if (token.value && offset >= token.value.offset && offset <= token.value.offset + token.value.length) return { path: at, part: "value", range: token.value };
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return { path: path.slice(0, 2), part: "between", range: spanOf(best.range) };
|
|
362
|
+
}
|
|
363
|
+
return { path, part: "value", range: spanOf(best.range) };
|
|
364
|
+
}
|
|
365
|
+
function blockIndex(ranges, slide, start) {
|
|
366
|
+
for (let index = 0; ranges.has(`/slides/${slide}/blocks/${index}`); index++) if (ranges.get(`/slides/${slide}/blocks/${index}`).start === start) return index;
|
|
367
|
+
return -1;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// src/source-locate.ts
|
|
371
|
+
var indexOrKey = (segment) => /^(?:0|[1-9][0-9]*)$/.test(segment) ? Number(segment) : segment;
|
|
7
372
|
var isJson = (format) => format === "json";
|
|
373
|
+
var isMarkdown = (format) => format === "md" || format === "markdown";
|
|
8
374
|
var parseText = (text) => parseTree(text.startsWith("\uFEFF") ? ` ${text.slice(1)}` : text, [], { allowTrailingComma: true, allowEmptyContent: true, disallowComments: false });
|
|
9
375
|
function segmentsOf(pointer) {
|
|
10
376
|
if (Array.isArray(pointer)) return pointer.map(String);
|
|
@@ -15,7 +381,7 @@ function segmentsOf(pointer) {
|
|
|
15
381
|
return void 0;
|
|
16
382
|
}
|
|
17
383
|
}
|
|
18
|
-
function
|
|
384
|
+
function member2(node, segment) {
|
|
19
385
|
if (node.type === "array") return /^(?:0|[1-9][0-9]*)$/.test(segment) ? node.children?.[Number(segment)] : void 0;
|
|
20
386
|
if (node.type === "object") return node.children?.find((property) => property.children?.[0]?.value === segment);
|
|
21
387
|
return void 0;
|
|
@@ -37,17 +403,26 @@ function partOf(value, property, part) {
|
|
|
37
403
|
}
|
|
38
404
|
}
|
|
39
405
|
function locate(text, format, pointer, options = {}) {
|
|
40
|
-
if (!isJson(format)) return void 0;
|
|
41
406
|
const segments = segmentsOf(pointer);
|
|
42
|
-
|
|
43
|
-
if (!segments || !root) return void 0;
|
|
407
|
+
if (!segments) return void 0;
|
|
44
408
|
const part = options.part ?? "value";
|
|
45
409
|
const place = createLocator(text);
|
|
410
|
+
if (format === "yaml") {
|
|
411
|
+
const found2 = locateYaml(text, segments, part);
|
|
412
|
+
return found2 ? { ...place(found2.offset, found2.length), ...found2.exact ? {} : { exact: false } } : void 0;
|
|
413
|
+
}
|
|
414
|
+
if (isMarkdown(format)) {
|
|
415
|
+
const found2 = locateMarkdown(text, segments, part);
|
|
416
|
+
return found2 ? { ...place(found2.offset, found2.length), ...found2.exact ? {} : { exact: false } } : void 0;
|
|
417
|
+
}
|
|
418
|
+
if (!isJson(format)) return void 0;
|
|
419
|
+
const root = parseText(text);
|
|
420
|
+
if (!root) return void 0;
|
|
46
421
|
let value = root;
|
|
47
422
|
let property;
|
|
48
423
|
let depth = 0;
|
|
49
424
|
for (const segment of segments) {
|
|
50
|
-
const next = value ?
|
|
425
|
+
const next = value ? member2(value, segment) : void 0;
|
|
51
426
|
if (!value || !next) break;
|
|
52
427
|
if (value.type === "object") {
|
|
53
428
|
property = next;
|
|
@@ -64,9 +439,13 @@ function locate(text, format, pointer, options = {}) {
|
|
|
64
439
|
return { ...place(found.offset, found.length), ...exact ? {} : { exact: false } };
|
|
65
440
|
}
|
|
66
441
|
function pathAt(text, format, offset) {
|
|
442
|
+
const place = createLocator(text);
|
|
443
|
+
if (format === "yaml" || isMarkdown(format)) {
|
|
444
|
+
const found = format === "yaml" ? pathAtYaml(text, offset) : pathAtMarkdown(text, offset);
|
|
445
|
+
return { path: found.path.map(indexOrKey), part: found.part, ...found.range ? { range: place(found.range.offset, found.range.length) } : {} };
|
|
446
|
+
}
|
|
67
447
|
if (!isJson(format)) return void 0;
|
|
68
448
|
const root = parseText(text);
|
|
69
|
-
const place = createLocator(text);
|
|
70
449
|
const none = { path: [], part: "none" };
|
|
71
450
|
if (!root || offset < root.offset || offset > root.offset + root.length) return none;
|
|
72
451
|
const node = findNodeAtOffset(root, offset, true);
|
|
@@ -87,4 +466,4 @@ function pathAt(text, format, offset) {
|
|
|
87
466
|
return { path: getNodePath(node), part: "value", range: range(node) };
|
|
88
467
|
}
|
|
89
468
|
|
|
90
|
-
export { locate, pathAt };
|
|
469
|
+
export { locate, pathAt, scanMarkdown };
|