@peisar/peisar-wasm32-wasi 0.3.11 → 0.3.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peisar/peisar-wasm32-wasi",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "main": "peisar.wasi.cjs",
5
5
  "files": [
6
6
  "peisar.wasm32-wasi.wasm",
@@ -1443,4 +1443,5 @@ export default __napiModule.exports
1443
1443
  export const Peisar = __napiModule.exports.Peisar
1444
1444
  export const PeisarCache = __napiModule.exports.PeisarCache
1445
1445
  export const frontmatter = __napiModule.exports.frontmatter
1446
+ export const HostingProvider = __napiModule.exports.HostingProvider
1446
1447
  export const yamlParser = __napiModule.exports.yamlParser
package/peisar.wasi.cjs CHANGED
@@ -1,4 +1,4 @@
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"]}
1
+ // napi-rs-artifact-metadata:{"version":2,"rootEntry":"index.cjs","exports":["Peisar","PeisarCache","frontmatter","HostingProvider","yamlParser"],"managedRootEntries":["browser.js","index.cjs","peisar.wasm","peisar.debug.wasm"]}
2
2
  /* eslint-disable */
3
3
  /* auto-generated by NAPI-RS */
4
4
 
@@ -2300,4 +2300,5 @@ module.exports = __napiModule.exports
2300
2300
  module.exports.Peisar = __napiModule.exports.Peisar
2301
2301
  module.exports.PeisarCache = __napiModule.exports.PeisarCache
2302
2302
  module.exports.frontmatter = __napiModule.exports.frontmatter
2303
+ module.exports.HostingProvider = __napiModule.exports.HostingProvider
2303
2304
  module.exports.yamlParser = __napiModule.exports.yamlParser
package/peisar.wasi.d.cts CHANGED
@@ -1,7 +1,3 @@
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";
5
1
 
6
2
  /** The WASI flavor this loader instantiates. */
7
3
  export declare const __napiBindingTarget: 'wasm32-wasi'
@@ -68,51 +64,116 @@ export declare class Peisar {
68
64
  }
69
65
 
70
66
  /**
71
- * In-memory cache of the Markdown and asset files under a directory tree.
67
+ * In-memory + archive-backed cache of the Markdown and asset files under a
68
+ * directory tree.
72
69
  *
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`, …).
70
+ * Memory is the source of truth for hot content; a background worker
71
+ * flushes a binary shard archive to `.peisar-cache` for cold/large
72
+ * entries, front-ended by the `map.json` search index. Watchers keep the
73
+ * memory tier in sync with the filesystem.
81
74
  */
82
75
  export declare class PeisarCache {
83
76
  /**
84
- * Construct a new PeisarCache using the default discovery behavior.
77
+ * JS: `new PeisarCache(entryDir, assetsDir?, options?)`.
85
78
  *
86
- * JS: `new PeisarCache(entryDir, assetsDir?)` — both plain strings.
79
+ * `options` configures markdown parsing (`fragment`, GFM, …), archive
80
+ * thresholds, hosting resolution, and the output directory. Custom
81
+ * visitors/parsers register afterwards via `useVisitor` /
82
+ * `useParser`.
83
+ */
84
+ constructor(entryDir: string, assetsDir?: string | undefined | null, options?: PeisarCacheJsOptions | undefined | null)
85
+ /**
86
+ * JS: `PeisarCache.withConfigJs(config)` — full configuration form,
87
+ * including memory-tier budgets.
87
88
  */
88
- constructor(entryDir: string, assetsDir?: string | undefined | null)
89
+ static withConfigJs(config: PeisarCacheConfig): PeisarCache
90
+ /**
91
+ * Register a JavaScript AST visitor applied to every page render
92
+ * (JS: `cache.useVisitor({ visitBlock, visitInline })`).
93
+ */
94
+ useVisitor(visitor: Visitor): void
89
95
  /**
90
- * JS: same as the constructor, for callers that prefer a factory shape.
91
- * Kept non-generic so NAPI can export it.
96
+ * Register a JavaScript parser hook applied to every page render
97
+ * (JS: `cache.useParser({ parseBlock, parseInline })`).
92
98
  */
93
- static withConfigJs(entryDir: string, assetsDir?: string | undefined | null): PeisarCache
99
+ useParser(parser: Parser): void
94
100
  /**
95
101
  * JS: `cache.startWatchingJs()` — start watching the entry (and
96
102
  * assets) directories recursively; errors surface as JS exceptions.
97
103
  */
98
104
  startWatchingJs(): void
99
105
  /**
100
- * ----------------------------------------------------------------
101
- * JavaScript (NAPI) surface
102
- * ----------------------------------------------------------------
103
- * All JS methods take/return plain strings because `&Path`/`PathBuf`
104
- * do not cross the NAPI boundary.
105
- * JS: `cache.getText(absPath)` — cached text of a file, or null.
106
+ * JS: `cache.getText(absPath)` — cached text of a file, or `null`.
107
+ * Reads fall through to the archive tier for evicted entries.
106
108
  */
107
109
  getText(absPath: string): string | null
108
- /** JS: `cache.getBinary(absPath)` — cached bytes of a binary asset, or null. */
110
+ /**
111
+ * JS: `cache.getBinary(absPath)` — cached bytes of a binary asset, or
112
+ * `null`. Reads fall through to the archive tier.
113
+ */
109
114
  getBinary(absPath: string): Array<number> | null
110
- /** JS: `cache.listFiles()` — absolute paths of everything cached. */
115
+ /**
116
+ * JS: `cache.listFiles()` — absolute paths of everything cached
117
+ * (memory + archive tiers).
118
+ */
111
119
  listFiles(): Array<string>
112
- /** JS: `cache.markdownFiles()` — absolute paths of cached markdown files. */
120
+ /**
121
+ * JS: `cache.markdownFiles()` — absolute paths of cached markdown
122
+ * files (either tier).
123
+ */
113
124
  markdownFiles(): Array<string>
114
- /** JS: `cache.assetFiles()` — absolute paths of cached non-markdown files. */
125
+ /**
126
+ * JS: `cache.assetFiles()` — absolute paths of cached non-markdown
127
+ * files (either tier).
128
+ */
115
129
  assetFiles(): Array<string>
130
+ /**
131
+ * JS: `cache.pages()` — every page object, for Liquid themes
132
+ * (`{{ page.title }}`, `{{ page.layout }}`, …).
133
+ */
134
+ pages(): Array<PageObject>
135
+ /**
136
+ * JS: `cache.getPage(inputPath)` — a single page object by absolute
137
+ * input path, or `null`.
138
+ */
139
+ getPage(inputPath: string): PageObject | null
140
+ /** JS: `cache.assets()` — every asset object. */
141
+ assets(): Array<AssetsObject>
142
+ /**
143
+ * JS: `cache.getAsset(inputPath)` — a single asset object by absolute
144
+ * input path, or `null`.
145
+ */
146
+ getAsset(inputPath: string): AssetsObject | null
147
+ /**
148
+ * JS: `cache.archived()` — absolute paths flushed to the disk
149
+ * archive. Everything not listed still lives in memory only.
150
+ */
151
+ archived(): Array<string>
152
+ /**
153
+ * JS: `cache.mapJson()` — the current `map.json` document (path →
154
+ * shard location + metadata, including front matter for search).
155
+ */
156
+ mapJson(): string
157
+ /**
158
+ * JS: `cache.flush()` — write all pending archive entries now,
159
+ * blocking until the worker is done.
160
+ */
161
+ flush(): void
162
+ /**
163
+ * JS: `cache.baseUrl()` — the resolved base URL path prefix for the
164
+ * configured hosting (e.g. `/repo/` for a GitHub Pages project site).
165
+ */
166
+ baseUrl(): string
167
+ /**
168
+ * JS: `cache.resolveUrl(path)` — prefix a site-relative path with the
169
+ * resolved base URL: `resolveUrl("docs/intro")` → `/repo/docs/intro`.
170
+ */
171
+ resolveUrl(path: string): string
172
+ /**
173
+ * JS: `cache.siteUrl()` — absolute origin URL for canonical URLs, or
174
+ * `null` when not configured.
175
+ */
176
+ siteUrl(): string | null
116
177
  /**
117
178
  * JS: `cache.onChange(cb)` — invoke `cb(event)` on every file change the
118
179
  * watcher detects while watching is active. Returns a subscription id
@@ -125,15 +186,50 @@ export declare class PeisarCache {
125
186
  /** JS: `cache.offChange(id)` — remove a previously registered callback. */
126
187
  offChange(id: number): void
127
188
  /**
128
- * JS: `cache.dispose()` — stop the watcher and drop JS change callbacks.
129
- * Safe to call more than once.
189
+ * JS: `cache.dispose()` — stop the watcher, flush pending archive
190
+ * writes, and drop JS change callbacks. Safe to call more than once.
130
191
  *
131
192
  * Rust consumers do not need this: dropping the [`PeisarCache`] stops
132
- * the watcher, closes the persistence channel, and joins the worker.
193
+ * the watcher, flushes the archive, and joins the workers.
133
194
  */
134
195
  dispose(): void
135
196
  }
136
197
 
198
+ /** Flush thresholds for the disk-archive tier. */
199
+ export interface ArchiveConfig {
200
+ /**
201
+ * Pending-content threshold (bytes) that triggers writing a new
202
+ * shard; `0` disables size-based flushing (interval/drop only).
203
+ */
204
+ shardBytes?: number
205
+ /**
206
+ * Maximum time (ms) pending entries may sit in the worker buffer
207
+ * before being flushed. `0` disables the timer.
208
+ */
209
+ flushIntervalMs?: number
210
+ }
211
+
212
+ /** An asset mirrored by the cache (JS/CSS/image/video/font/…). */
213
+ export interface AssetsObject {
214
+ /** File name without extension (`foo.png` → `foo`). */
215
+ fileName: string
216
+ /** URL for the asset (`path/to/foo.png` → `/path/to/foo.png`). */
217
+ slug: string
218
+ /** Raw content: UTF-8 text for textual assets, base64 for binaries. */
219
+ raw: string
220
+ /** Build output path for the asset. */
221
+ outFilePath: string
222
+ /** Original absolute source path (watch-process identity). */
223
+ inputFilePath: string
224
+ /** File extension (lowercase, without dot). */
225
+ ext: string
226
+ /**
227
+ * Kind classification: `"Js"`, `"Css"`, `"Image"`, `"Video"`,
228
+ * `"Font"`, or `"Other"`.
229
+ */
230
+ fileType: string
231
+ }
232
+
137
233
  /**
138
234
  * Options that control how Markdown is parsed.
139
235
  *
@@ -170,6 +266,27 @@ export interface Attributes {
170
266
  attributes?: Array<[string, string]>
171
267
  }
172
268
 
269
+ /**
270
+ * Resolved hosting configuration: the single source of truth for every
271
+ * URL the pipeline emits (page slugs, asset links, absolute URLs).
272
+ */
273
+ export interface BaseDirInfo {
274
+ /** Hosting provider in effect. */
275
+ provider: HostingProvider
276
+ /** Repository name (GitHub Pages project sites): `/<repo>/` prefix. */
277
+ repo?: string
278
+ /**
279
+ * Custom site URL (`https://example.com` or `https://user.github.io/repo`).
280
+ * Used verbatim as the URL root for [`Self::site_url`].
281
+ */
282
+ siteUrl?: string
283
+ /**
284
+ * Extra path prefix under the host (e.g. `subpath` for
285
+ * `example.com/subpath/`).
286
+ */
287
+ pathPrefix?: string
288
+ }
289
+
173
290
  /** Block-level nodes. */
174
291
  export type Block =
175
292
  | { type: 'Heading'; /** Heading level (1–6). */
@@ -270,7 +387,8 @@ export interface CacheChangeEvent {
270
387
  /**
271
388
  * An entry stored in the cache: raw UTF-8 text (markdown and textual
272
389
  * assets) or raw bytes (binary assets). Exposed to JavaScript so JS
273
- * consumers can branch on the variant.
390
+ * consumers can branch on the variant. The serde derives back the
391
+ * bincode round-trip through the disk archive.
274
392
  */
275
393
  export type CachedContent =
276
394
  | { type: 'Text'; field0: string }
@@ -305,6 +423,36 @@ export interface FrontmatterResult {
305
423
  yamlData?: Record<string, any>
306
424
  }
307
425
 
426
+ /** Static-hosting configuration for baseUrl resolution. */
427
+ export interface HostingConfig {
428
+ /** Hosting provider (see [`HostingProvider`]). */
429
+ provider?: HostingProvider
430
+ /** GitHub repository name for project pages (`/<repo>/` prefix). */
431
+ repo?: string
432
+ /** Custom site URL (overrides provider defaults when set). */
433
+ siteUrl?: string
434
+ /** Extra path prefix (e.g. `"subpath"` for `example.com/subpath/`). */
435
+ pathPrefix?: string
436
+ }
437
+
438
+ /** Static site hosting providers with known `baseUrl` behavior. */
439
+ export declare const enum HostingProvider {
440
+ /**
441
+ * GitHub Pages. User/org sites (`<user>.github.io`) serve at `/`;
442
+ * project sites at `/<repo>`. Pass the repository name via
443
+ * `repo` to get the `/<repo>/` prefix.
444
+ */
445
+ GithubPages = 'GithubPages',
446
+ /** Vercel: always `/` (subpath deployments use rewrites, not paths). */
447
+ Vercel = 'Vercel',
448
+ /** Netlify: always `/`. */
449
+ Netlify = 'Netlify',
450
+ /** Cloudflare Pages: always `/`. */
451
+ CloudflarePages = 'CloudflarePages',
452
+ /** Self-hosted or custom setup: use the `site_base_url` string as given. */
453
+ Custom = 'Custom',
454
+ }
455
+
308
456
  /** Inline-level nodes. */
309
457
  export type Inline =
310
458
  | { type: 'Text'; /** The text value. */
@@ -423,6 +571,59 @@ export interface ListItem {
423
571
  pos: Span
424
572
  }
425
573
 
574
+ /** LRU budgets for the memory tier. */
575
+ export interface MemoryConfig {
576
+ /**
577
+ * Maximum total bytes of raw content kept in memory (`0` =
578
+ * unlimited). When the budget is exceeded, the least recently used
579
+ * entries are evicted (they remain readable from the disk archive).
580
+ */
581
+ byteBudget?: number
582
+ /** Maximum number of entries in memory (`0` = unlimited). */
583
+ entryBudget?: number
584
+ }
585
+
586
+ /**
587
+ * A page rendered for a Liquid theme: front-matter fields flattened next
588
+ * to pipeline-derived fields (layout, slug, html, …).
589
+ */
590
+ export interface PageObject {
591
+ /**
592
+ * Layout name from front matter (e.g. `default`, `page`, `post`);
593
+ * `"default"` when front matter does not set one.
594
+ */
595
+ layout: string
596
+ /**
597
+ * File name without extension (`foo.md` → `foo`); `index` for
598
+ * directory roots. Used as a search / lookup key.
599
+ */
600
+ fileName: string
601
+ /** Request URL for the page (`path/to/foo.md` → `/path/to/foo`). */
602
+ slug: string
603
+ /** HTML rendered from the markdown by Peisar. */
604
+ html: string
605
+ /**
606
+ * Build output path (`path/to/foo.md` → `outDir/path/to/foo/index.html`),
607
+ * relative to the output root unless absolute.
608
+ */
609
+ outFilePath: string
610
+ /** Original absolute source path (watch-process identity). */
611
+ inputFilePath: string
612
+ /** Page title (from front matter, or the first `#` heading). */
613
+ title?: string
614
+ /** Short description from front matter. */
615
+ summary?: string
616
+ /** Category tags from front matter. */
617
+ tags?: Array<string>
618
+ /** Publication date from front matter (string form `yyyy-mm-dd`). */
619
+ publishDate?: string
620
+ /**
621
+ * Any extra front-matter keys not mapped to a named field, exposed
622
+ * verbatim (as strings) so themes can render `{{ page.custom }}`.
623
+ */
624
+ extra?: Record<string, string>
625
+ }
626
+
426
627
  /** Either property may be omitted / `null` to skip that phase. */
427
628
  export interface Parser {
428
629
  /** Optional JS block parser hook (JS: `parseBlock`). */
@@ -431,6 +632,59 @@ export interface Parser {
431
632
  parseInline?: InlineParseCallback
432
633
  }
433
634
 
635
+ /**
636
+ * Cache-wide configuration: directories, markdown options, memory/archive
637
+ * budgets, hosting/baseUrl resolution, and the build output directory.
638
+ */
639
+ export interface PeisarCacheConfig {
640
+ /**
641
+ * Entry directory holding the markdown files (absolute, or relative
642
+ * to the current working directory).
643
+ */
644
+ entryDir: string
645
+ /**
646
+ * Optional assets directory (defaults to `public` under the cwd when
647
+ * omitted).
648
+ */
649
+ assetsDir?: string
650
+ /**
651
+ * Markdown parsing/rendering options applied to every page render
652
+ * (GFM/Kramdown toggles, `fragment`, title, …). Custom visitors and
653
+ * parsers are registered separately via `useVisitor` / `useParser`.
654
+ */
655
+ markdown?: PeisarOptions
656
+ /**
657
+ * Memory-tier budgets (LRU eviction). Defaults: 64 MiB bytes,
658
+ * unlimited entries.
659
+ */
660
+ memory?: MemoryConfig
661
+ /** Disk-archive tier thresholds. Defaults: 8 MiB shards, 2 s flush. */
662
+ archive?: ArchiveConfig
663
+ /** Static-hosting baseUrl resolution (GitHub Pages/Vercel/…). */
664
+ hosting?: HostingConfig
665
+ /**
666
+ * Build output directory used for `outFilePath` fields (default
667
+ * `".peisar"`).
668
+ */
669
+ outDir?: string
670
+ }
671
+
672
+ /**
673
+ * JS-side options accepted by the `PeisarCache` constructor (a flattened
674
+ * subset of [`PeisarCacheConfig`]; memory budgets only apply through the
675
+ * `withConfig` factory).
676
+ */
677
+ export interface PeisarCacheJsOptions {
678
+ /** Markdown parsing/rendering options (`fragment`, GFM, …). */
679
+ markdown?: PeisarOptions
680
+ /** Disk-archive thresholds (shard size / flush interval). */
681
+ archive?: ArchiveConfig
682
+ /** Static-hosting baseUrl resolution. */
683
+ hosting?: HostingConfig
684
+ /** Build output directory. */
685
+ outDir?: string
686
+ }
687
+
434
688
  /**
435
689
  * JavaScript options for Markdown parsing and HTML rendering.
436
690
  *
Binary file