@peisar/peisar-wasm32-wasi 0.3.0 → 0.3.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/package.json +1 -1
- package/peisar.wasi-browser.js +2 -3
- package/peisar.wasi.cjs +3 -4
- package/peisar.wasi.d.cts +73 -104
- package/peisar.wasm32-wasi.wasm +0 -0
package/package.json
CHANGED
package/peisar.wasi-browser.js
CHANGED
|
@@ -1442,6 +1442,5 @@ try {
|
|
|
1442
1442
|
export default __napiModule.exports
|
|
1443
1443
|
export const Peisar = __napiModule.exports.Peisar
|
|
1444
1444
|
export const PeisarCache = __napiModule.exports.PeisarCache
|
|
1445
|
-
export const
|
|
1446
|
-
export const
|
|
1447
|
-
export const TaskState = __napiModule.exports.TaskState
|
|
1445
|
+
export const frontmatter = __napiModule.exports.frontmatter
|
|
1446
|
+
export const yamlParser = __napiModule.exports.yamlParser
|
package/peisar.wasi.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// napi-rs-artifact-metadata:{"version":2,"rootEntry":"index.
|
|
1
|
+
// napi-rs-artifact-metadata:{"version":2,"rootEntry":"index.cjs","exports":["Peisar","PeisarCache","frontmatter","yamlParser"],"managedRootEntries":["browser.js","index.cjs","peisar.wasm","peisar.debug.wasm"]}
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/* auto-generated by NAPI-RS */
|
|
4
4
|
|
|
@@ -2299,6 +2299,5 @@ try {
|
|
|
2299
2299
|
module.exports = __napiModule.exports
|
|
2300
2300
|
module.exports.Peisar = __napiModule.exports.Peisar
|
|
2301
2301
|
module.exports.PeisarCache = __napiModule.exports.PeisarCache
|
|
2302
|
-
module.exports.
|
|
2303
|
-
module.exports.
|
|
2304
|
-
module.exports.TaskState = __napiModule.exports.TaskState
|
|
2302
|
+
module.exports.frontmatter = __napiModule.exports.frontmatter
|
|
2303
|
+
module.exports.yamlParser = __napiModule.exports.yamlParser
|
package/peisar.wasi.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export type PeisarEmphasisLevel = "Italic" | "Bold";
|
|
2
|
+
export type PeisarTableCellAlignment = "Default" | "Left" | "Center" | "Right";
|
|
3
|
+
export type PeisarTableCellAlignments = PeisarTableCellAlignment[];
|
|
4
|
+
export type PeisarTaskState = "Unchecked" | "Checked";
|
|
3
5
|
|
|
4
6
|
/** The WASI flavor this loader instantiates. */
|
|
5
7
|
export declare const __napiBindingTarget: 'wasm32-wasi'
|
|
@@ -66,8 +68,16 @@ export declare class Peisar {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
/**
|
|
69
|
-
* In-memory cache of
|
|
70
|
-
*
|
|
71
|
+
* In-memory cache of the Markdown and asset files under a directory tree.
|
|
72
|
+
*
|
|
73
|
+
* The cache maps absolute source paths to [`CachedContent`] entries, is
|
|
74
|
+
* mirrored to a `.peisar_cache` directory on disk, and — after
|
|
75
|
+
* [`PeisarCache::start_watching`] — tracks the source directories with a
|
|
76
|
+
* recursive file watcher.
|
|
77
|
+
*
|
|
78
|
+
* Rust consumers read the cache with [`PeisarCache::get`] and
|
|
79
|
+
* [`PeisarCache::all`]; JavaScript consumers use the N-API methods below
|
|
80
|
+
* (`getText`, `getBinary`, `listFiles`, `markdownFiles`, `assetFiles`, …).
|
|
71
81
|
*/
|
|
72
82
|
export declare class PeisarCache {
|
|
73
83
|
/**
|
|
@@ -82,14 +92,8 @@ export declare class PeisarCache {
|
|
|
82
92
|
*/
|
|
83
93
|
static withConfigJs(entryDir: string, assetsDir?: string | undefined | null): PeisarCache
|
|
84
94
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* assets, and persist updates to disk.
|
|
88
|
-
*
|
|
89
|
-
* The returned Result is only for watcher setup errors; runtime errors are
|
|
90
|
-
* printed to stderr by the watch callback.
|
|
91
|
-
*
|
|
92
|
-
* JS: `cache.startWatchingJs()` — errors surface as JS exceptions.
|
|
95
|
+
* JS: `cache.startWatchingJs()` — start watching the entry (and
|
|
96
|
+
* assets) directories recursively; errors surface as JS exceptions.
|
|
93
97
|
*/
|
|
94
98
|
startWatchingJs(): void
|
|
95
99
|
/**
|
|
@@ -123,6 +127,9 @@ export declare class PeisarCache {
|
|
|
123
127
|
/**
|
|
124
128
|
* JS: `cache.dispose()` — stop the watcher and drop JS change callbacks.
|
|
125
129
|
* Safe to call more than once.
|
|
130
|
+
*
|
|
131
|
+
* Rust consumers do not need this: dropping the [`PeisarCache`] stops
|
|
132
|
+
* the watcher, closes the persistence channel, and joins the worker.
|
|
126
133
|
*/
|
|
127
134
|
dispose(): void
|
|
128
135
|
}
|
|
@@ -211,13 +218,13 @@ export type Block =
|
|
|
211
218
|
* Synchronous block-visitor callback. Receives a `Block`, returns
|
|
212
219
|
* `VisitControlJs` (or `undefined` for no changes).
|
|
213
220
|
*/
|
|
214
|
-
export type BlockCallback = (arg: [Block]) =>
|
|
221
|
+
export type BlockCallback = (arg: [Block]) => VisitorControl | null
|
|
215
222
|
|
|
216
223
|
/**
|
|
217
224
|
* Synchronous block parser hook. Receives a [`BlockParseContext`], returns
|
|
218
225
|
* a [`BlockParseResultJs`] (or `undefined` to decline).
|
|
219
226
|
*/
|
|
220
|
-
export type BlockParseCallback = (arg: [BlockParseContext]) =>
|
|
227
|
+
export type BlockParseCallback = (arg: [BlockParseContext]) => BlockParseResult | null
|
|
221
228
|
|
|
222
229
|
/**
|
|
223
230
|
* Context passed to block parser hooks.
|
|
@@ -240,14 +247,17 @@ export interface BlockParseContext {
|
|
|
240
247
|
* All fields are optional; omitting `block` (or returning `undefined`)
|
|
241
248
|
* declines the position so the next hook / built-in parser handles it.
|
|
242
249
|
*/
|
|
243
|
-
export interface
|
|
250
|
+
export interface BlockParseResult {
|
|
244
251
|
/** The parsed block node. */
|
|
245
252
|
block?: Block
|
|
246
253
|
/** Number of source lines consumed (must be at least `1`). */
|
|
247
254
|
consumed?: number
|
|
248
255
|
}
|
|
249
256
|
|
|
250
|
-
/**
|
|
257
|
+
/**
|
|
258
|
+
* A file-change event delivered to change callbacks
|
|
259
|
+
* (see [`PeisarCache::on_change`]).
|
|
260
|
+
*/
|
|
251
261
|
export interface CacheChangeEvent {
|
|
252
262
|
/** Absolute path of the changed file. */
|
|
253
263
|
path: string
|
|
@@ -258,9 +268,9 @@ export interface CacheChangeEvent {
|
|
|
258
268
|
}
|
|
259
269
|
|
|
260
270
|
/**
|
|
261
|
-
* An entry stored in the cache: raw UTF-8 text (markdown
|
|
262
|
-
* (binary assets).
|
|
263
|
-
* the variant.
|
|
271
|
+
* An entry stored in the cache: raw UTF-8 text (markdown and textual
|
|
272
|
+
* assets) or raw bytes (binary assets). Exposed to JavaScript so JS
|
|
273
|
+
* consumers can branch on the variant.
|
|
264
274
|
*/
|
|
265
275
|
export type CachedContent =
|
|
266
276
|
| { type: 'Text'; field0: string }
|
|
@@ -285,12 +295,14 @@ export interface Document {
|
|
|
285
295
|
linkReferences: Array<LinkReferenceDefinition>
|
|
286
296
|
}
|
|
287
297
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
|
|
298
|
+
export declare function frontmatter(content: string): FrontmatterResult
|
|
299
|
+
|
|
300
|
+
/** The Markdown body and YAML metadata parsed from a front-matter document. */
|
|
301
|
+
export interface FrontmatterResult {
|
|
302
|
+
/** Markdown source after the leading YAML front matter is removed. */
|
|
303
|
+
pureMarkdownContent: string
|
|
304
|
+
/** Deserialized YAML front matter, or `null` when no front matter exists. */
|
|
305
|
+
yamlData?: Record<string, any>
|
|
294
306
|
}
|
|
295
307
|
|
|
296
308
|
/** Inline-level nodes. */
|
|
@@ -299,7 +311,7 @@ export type Inline =
|
|
|
299
311
|
value: string; /** Source span. */
|
|
300
312
|
pos: Span }
|
|
301
313
|
| { type: 'Emphasis'; /** Emphasis level (italic or bold). */
|
|
302
|
-
level:
|
|
314
|
+
level: PeisarEmphasisLevel; /** Nested inline content. */
|
|
303
315
|
children: Array<Inline>; /** Source span. */
|
|
304
316
|
pos: Span }
|
|
305
317
|
| { type: 'Code'; /** The code text. */
|
|
@@ -337,13 +349,13 @@ export type Inline =
|
|
|
337
349
|
* Synchronous inline-visitor callback. Receives an `Inline`, returns
|
|
338
350
|
* `InlineVisitControlJs` (or `undefined` for no changes).
|
|
339
351
|
*/
|
|
340
|
-
export type InlineCallback = (arg: [Inline]) =>
|
|
352
|
+
export type InlineCallback = (arg: [Inline]) => InlineVisitorControl | null
|
|
341
353
|
|
|
342
354
|
/**
|
|
343
355
|
* Synchronous inline parser hook. Receives an [`InlineParseContext`],
|
|
344
356
|
* returns an [`InlineParseResultJs`] (or `undefined` to decline).
|
|
345
357
|
*/
|
|
346
|
-
export type InlineParseCallback = (arg: [InlineParseContext]) =>
|
|
358
|
+
export type InlineParseCallback = (arg: [InlineParseContext]) => InlineParseResult | null
|
|
347
359
|
|
|
348
360
|
/**
|
|
349
361
|
* Context passed to inline parser hooks.
|
|
@@ -363,7 +375,7 @@ export interface InlineParseContext {
|
|
|
363
375
|
* All fields are optional; omitting `inline` (or returning `undefined`)
|
|
364
376
|
* declines the position so the next hook / built-in parser handles it.
|
|
365
377
|
*/
|
|
366
|
-
export interface
|
|
378
|
+
export interface InlineParseResult {
|
|
367
379
|
/** The parsed inline node. */
|
|
368
380
|
inline?: Inline
|
|
369
381
|
/** Number of characters consumed (`0` or missing declines). */
|
|
@@ -376,7 +388,7 @@ export interface InlineParseResultJs {
|
|
|
376
388
|
* Returned from the JS `visitInline` callback. All fields are optional;
|
|
377
389
|
* omitting a field means "no change" for that operation.
|
|
378
390
|
*/
|
|
379
|
-
export interface
|
|
391
|
+
export interface InlineVisitorControl {
|
|
380
392
|
/** Nodes to insert before the current node. */
|
|
381
393
|
insertBefore?: Array<Inline>
|
|
382
394
|
/** Nodes to insert after the current node. */
|
|
@@ -406,39 +418,12 @@ export interface ListItem {
|
|
|
406
418
|
/** Nested block content of the item. */
|
|
407
419
|
children: Array<Block>
|
|
408
420
|
/** GFM task-list state: `None` = not a task, `Some` = checked / unchecked. */
|
|
409
|
-
task?:
|
|
421
|
+
task?: PeisarTaskState
|
|
410
422
|
/** Span of the item in the *sub-document* of its enclosing list. */
|
|
411
423
|
pos: Span
|
|
412
424
|
}
|
|
413
425
|
|
|
414
|
-
/**
|
|
415
|
-
* JavaScript object shape for a parser hook pair.
|
|
416
|
-
*
|
|
417
|
-
* ```js
|
|
418
|
-
* const myParser = {
|
|
419
|
-
* parseBlock(ctx) {
|
|
420
|
-
* if (!ctx.line.startsWith(':::')) return; // decline
|
|
421
|
-
* const name = ctx.line.slice(3).trim();
|
|
422
|
-
* return {
|
|
423
|
-
* block: { type: 'HtmlBlock', html: `<div data-name="${name}"></div>`, pos: { start: {}, end: {} } },
|
|
424
|
-
* consumed: 1,
|
|
425
|
-
* };
|
|
426
|
-
* },
|
|
427
|
-
* parseInline(ctx) {
|
|
428
|
-
* if (!ctx.rest.startsWith('@@')) return; // decline
|
|
429
|
-
* const end = ctx.rest.indexOf(' ', 2);
|
|
430
|
-
* const name = end === -1 ? ctx.rest.slice(2) : ctx.rest.slice(2, end);
|
|
431
|
-
* return {
|
|
432
|
-
* inline: { type: 'HtmlInline', html: `<span data-name="${name}"></span>`, pos: { start: {}, end: {} } },
|
|
433
|
-
* consumed: name.length + 2,
|
|
434
|
-
* };
|
|
435
|
-
* },
|
|
436
|
-
* };
|
|
437
|
-
* document.useParser(myParser);
|
|
438
|
-
* ```
|
|
439
|
-
*
|
|
440
|
-
* Either property may be omitted / `null` to skip that phase.
|
|
441
|
-
*/
|
|
426
|
+
/** Either property may be omitted / `null` to skip that phase. */
|
|
442
427
|
export interface Parser {
|
|
443
428
|
/** Optional JS block parser hook (JS: `parseBlock`). */
|
|
444
429
|
parseBlock?: BlockParseCallback
|
|
@@ -446,14 +431,6 @@ export interface Parser {
|
|
|
446
431
|
parseInline?: InlineParseCallback
|
|
447
432
|
}
|
|
448
433
|
|
|
449
|
-
/** The Markdown body and YAML metadata parsed from a front-matter document. */
|
|
450
|
-
export interface ParseResult {
|
|
451
|
-
/** Markdown source after the leading YAML front matter is removed. */
|
|
452
|
-
pureMarkdownContent: string
|
|
453
|
-
/** Deserialized YAML front matter, or `null` when no front matter exists. */
|
|
454
|
-
yamlData?: Record<string, any>
|
|
455
|
-
}
|
|
456
|
-
|
|
457
434
|
/**
|
|
458
435
|
* JavaScript options for Markdown parsing and HTML rendering.
|
|
459
436
|
*
|
|
@@ -588,7 +565,7 @@ export interface Table {
|
|
|
588
565
|
/** Body rows. */
|
|
589
566
|
rows: Array<TableRow>
|
|
590
567
|
/** Column alignment specifications (one per column). */
|
|
591
|
-
alignments:
|
|
568
|
+
alignments: PeisarTableCellAlignments
|
|
592
569
|
}
|
|
593
570
|
|
|
594
571
|
/** A single table cell. */
|
|
@@ -597,30 +574,33 @@ export interface TableCell {
|
|
|
597
574
|
children: Array<Inline>
|
|
598
575
|
}
|
|
599
576
|
|
|
600
|
-
/** Column alignment for table cells. */
|
|
601
|
-
export declare const enum TableCellAlignment {
|
|
602
|
-
/** `:---` or `---` — default (left) */
|
|
603
|
-
Default = 0,
|
|
604
|
-
/** `:---` */
|
|
605
|
-
Left = 1,
|
|
606
|
-
/** `:---:` */
|
|
607
|
-
Center = 2,
|
|
608
|
-
/** `---:` */
|
|
609
|
-
Right = 3,
|
|
610
|
-
}
|
|
611
|
-
|
|
612
577
|
/** A single table row (header or body). */
|
|
613
578
|
export interface TableRow {
|
|
614
579
|
/** The cells in this row. */
|
|
615
580
|
cells: Array<TableCell>
|
|
616
581
|
}
|
|
617
582
|
|
|
618
|
-
/**
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
583
|
+
/**
|
|
584
|
+
* JavaScript object shape for a visitor callback pair.
|
|
585
|
+
*
|
|
586
|
+
* On the JS side it is a plain object with two optional
|
|
587
|
+
* function properties:
|
|
588
|
+
*
|
|
589
|
+
* ```js
|
|
590
|
+
* const myPlugin = {
|
|
591
|
+
* visitBlock(block) { return { recurse: true }; },
|
|
592
|
+
* visitInline(inline) { return {}; },
|
|
593
|
+
* };
|
|
594
|
+
* ast.addVisitor(myPlugin);
|
|
595
|
+
* ```
|
|
596
|
+
*
|
|
597
|
+
* Either property may be omitted / `null` to skip that node kind.
|
|
598
|
+
*/
|
|
599
|
+
export interface Visitor {
|
|
600
|
+
/** Optional JS callback for block nodes (JS: `visitBlock`). */
|
|
601
|
+
visitBlock?: BlockCallback
|
|
602
|
+
/** Optional JS callback for inline nodes (JS: `visitInline`). */
|
|
603
|
+
visitInline?: InlineCallback
|
|
624
604
|
}
|
|
625
605
|
|
|
626
606
|
/**
|
|
@@ -629,7 +609,7 @@ export declare const enum TaskState {
|
|
|
629
609
|
* Returned from the JS `visitBlock` callback. All fields are optional;
|
|
630
610
|
* omitting a field means "no change" for that operation.
|
|
631
611
|
*/
|
|
632
|
-
export interface
|
|
612
|
+
export interface VisitorControl {
|
|
633
613
|
/** Nodes to insert before the current node. */
|
|
634
614
|
insertBefore?: Array<Block>
|
|
635
615
|
/** Nodes to insert after the current node. */
|
|
@@ -643,24 +623,13 @@ export interface VisitControlJs {
|
|
|
643
623
|
}
|
|
644
624
|
|
|
645
625
|
/**
|
|
646
|
-
*
|
|
626
|
+
* Parses a YAML document into a JSON-compatible value.
|
|
647
627
|
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
628
|
+
* When consumed from Node.js, the result is exposed as a JavaScript object
|
|
629
|
+
* with the TypeScript type `Record<string, any>`.
|
|
650
630
|
*
|
|
651
|
-
*
|
|
652
|
-
* const myPlugin = {
|
|
653
|
-
* visitBlock(block) { return { recurse: true }; },
|
|
654
|
-
* visitInline(inline) { return {}; },
|
|
655
|
-
* };
|
|
656
|
-
* ast.addVisitor(myPlugin);
|
|
657
|
-
* ```
|
|
631
|
+
* # Panics
|
|
658
632
|
*
|
|
659
|
-
*
|
|
633
|
+
* Panics when `yaml_str` is not valid YAML.
|
|
660
634
|
*/
|
|
661
|
-
export
|
|
662
|
-
/** Optional JS callback for block nodes (JS: `visitBlock`). */
|
|
663
|
-
visitBlock?: BlockCallback
|
|
664
|
-
/** Optional JS callback for inline nodes (JS: `visitInline`). */
|
|
665
|
-
visitInline?: InlineCallback
|
|
666
|
-
}
|
|
635
|
+
export declare function yamlParser(yamlStr: string): Record<string, any>
|
package/peisar.wasm32-wasi.wasm
CHANGED
|
Binary file
|