@fuzdev/fuz_ui 0.185.2 → 0.187.0

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 (44) hide show
  1. package/dist/ApiModule.svelte +22 -6
  2. package/dist/ApiModule.svelte.d.ts.map +1 -1
  3. package/dist/DeclarationLink.svelte +1 -1
  4. package/dist/DocsLink.svelte +2 -2
  5. package/dist/DocsTertiaryNav.svelte +2 -2
  6. package/dist/Mdz.svelte +5 -0
  7. package/dist/Mdz.svelte.d.ts +1 -0
  8. package/dist/Mdz.svelte.d.ts.map +1 -1
  9. package/dist/MdzNodeView.svelte +19 -8
  10. package/dist/MdzNodeView.svelte.d.ts +1 -1
  11. package/dist/MdzNodeView.svelte.d.ts.map +1 -1
  12. package/dist/ModuleLink.svelte +1 -1
  13. package/dist/TypeLink.svelte +1 -1
  14. package/dist/library.svelte.d.ts +24 -27
  15. package/dist/library.svelte.d.ts.map +1 -1
  16. package/dist/library.svelte.js +16 -16
  17. package/dist/mdz.d.ts +13 -0
  18. package/dist/mdz.d.ts.map +1 -1
  19. package/dist/mdz.js +73 -280
  20. package/dist/mdz_components.d.ts +12 -0
  21. package/dist/mdz_components.d.ts.map +1 -1
  22. package/dist/mdz_components.js +8 -0
  23. package/dist/mdz_helpers.d.ts +108 -0
  24. package/dist/mdz_helpers.d.ts.map +1 -0
  25. package/dist/mdz_helpers.js +237 -0
  26. package/dist/mdz_lexer.d.ts +93 -0
  27. package/dist/mdz_lexer.d.ts.map +1 -0
  28. package/dist/mdz_lexer.js +727 -0
  29. package/dist/mdz_to_svelte.d.ts +5 -2
  30. package/dist/mdz_to_svelte.d.ts.map +1 -1
  31. package/dist/mdz_to_svelte.js +13 -2
  32. package/dist/mdz_token_parser.d.ts +14 -0
  33. package/dist/mdz_token_parser.d.ts.map +1 -0
  34. package/dist/mdz_token_parser.js +374 -0
  35. package/dist/svelte_preprocess_mdz.js +23 -7
  36. package/package.json +10 -9
  37. package/src/lib/library.svelte.ts +36 -35
  38. package/src/lib/mdz.ts +106 -302
  39. package/src/lib/mdz_components.ts +9 -0
  40. package/src/lib/mdz_helpers.ts +251 -0
  41. package/src/lib/mdz_lexer.ts +1003 -0
  42. package/src/lib/mdz_to_svelte.ts +15 -2
  43. package/src/lib/mdz_token_parser.ts +460 -0
  44. package/src/lib/svelte_preprocess_mdz.ts +23 -7
@@ -37,10 +37,15 @@
37
37
  );
38
38
 
39
39
  // find the module using the lookup helper
40
- const module = $derived(library.lookup_module(module_path));
40
+ const module = $derived(library.module_by_path.get(module_path));
41
+
42
+ // check if this is a directory prefix containing child modules
43
+ const directory_modules = $derived(module ? null : library.lookup_directory_modules(module_path));
41
44
 
42
45
  // fallback for 404
43
- const module_name = $derived(module?.path || '[missing module]');
46
+ const module_name = $derived(
47
+ module?.path || (directory_modules ? module_path : '[missing module]'),
48
+ );
44
49
 
45
50
  const search = $derived(create_module_declaration_search(module?.declarations ?? []));
46
51
 
@@ -57,7 +62,18 @@
57
62
  <h1 class="mt_xl4">{module_name}</h1>
58
63
  {/snippet}
59
64
 
60
- {#if !module}
65
+ {#if !module && directory_modules}
66
+ <section>
67
+ <p>{directory_modules.length} module{directory_modules.length === 1 ? '' : 's'}</p>
68
+ <ul>
69
+ {#each directory_modules as child_module (child_module.path)}
70
+ <li>
71
+ <ModuleLink module_path={child_module.path} />
72
+ </li>
73
+ {/each}
74
+ </ul>
75
+ </section>
76
+ {:else if !module}
61
77
  <section>
62
78
  <p>Module not found: {module_path}</p>
63
79
  </section>
@@ -67,7 +83,7 @@
67
83
  <Mdz content={module.module_comment} />
68
84
  </section>
69
85
  {/if}
70
- <!-- Declarations Section -->
86
+ <!-- Declarations section -->
71
87
  <TomeSection>
72
88
  <TomeSectionHeader text="Declarations" />
73
89
 
@@ -92,7 +108,7 @@
92
108
  <ApiDeclarationList declarations={search.filtered} search_query={search.query} />
93
109
  </TomeSection>
94
110
 
95
- <!-- Depends on Section -->
111
+ <!-- Depends on section -->
96
112
  {#if module.dependencies}
97
113
  <TomeSection>
98
114
  <TomeSectionHeader text="Depends on" />
@@ -106,7 +122,7 @@
106
122
  </TomeSection>
107
123
  {/if}
108
124
 
109
- <!-- Imported by Section -->
125
+ <!-- Imported by section -->
110
126
  {#if module.dependents}
111
127
  <TomeSection>
112
128
  <TomeSectionHeader text="Imported by" />
@@ -1 +1 @@
1
- {"version":3,"file":"ApiModule.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/ApiModule.svelte"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAmB,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAUrD,KAAK,gBAAgB,GAAI;IACxB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;CACZ,CAAC;AA2GH,QAAA,MAAM,SAAS,sDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"ApiModule.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/ApiModule.svelte"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAmB,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAUrD,KAAK,gBAAgB,GAAI;IACxB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;CACZ,CAAC;AA2HH,QAAA,MAAM,SAAS,sDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
@@ -20,7 +20,7 @@
20
20
 
21
21
  const library = library_context.get();
22
22
 
23
- const declaration = $derived(library.lookup_declaration(name));
23
+ const declaration = $derived(library.declaration_by_name.get(name));
24
24
 
25
25
  const contextmenu_entries = $derived(
26
26
  declaration ? create_declaration_contextmenu(declaration) : undefined,
@@ -22,8 +22,8 @@
22
22
  const library = library_context.get();
23
23
 
24
24
  // Try to find as declaration first, then module
25
- const declaration = $derived(library.lookup_declaration(reference));
26
- const module = $derived(declaration ? declaration.module : library.lookup_module(reference));
25
+ const declaration = $derived(library.declaration_by_name.get(reference));
26
+ const module = $derived(declaration ? declaration.module : library.module_by_path.get(reference));
27
27
  </script>
28
28
 
29
29
  {#if declaration}
@@ -33,13 +33,13 @@
33
33
 
34
34
  const modules_related_to_selected = $derived(
35
35
  selected_tome?.related_modules
36
- .map((path) => library.lookup_module(path))
36
+ .map((path) => library.module_by_path.get(path))
37
37
  .filter((m) => m !== undefined) ?? [],
38
38
  );
39
39
 
40
40
  const declarations_related_to_selected = $derived(
41
41
  selected_tome?.related_declarations
42
- .map((name) => library.lookup_declaration(name))
42
+ .map((name) => library.declaration_by_name.get(name))
43
43
  .filter((d) => d !== undefined) ?? [],
44
44
  );
45
45
 
package/dist/Mdz.svelte CHANGED
@@ -3,18 +3,23 @@
3
3
 
4
4
  import {mdz_parse} from './mdz.js';
5
5
  import MdzNodeView from './MdzNodeView.svelte';
6
+ import {mdz_base_context} from './mdz_components.js';
6
7
 
7
8
  const {
8
9
  content,
9
10
  inline = false,
10
11
  nowrap = false,
12
+ base,
11
13
  ...rest
12
14
  }: (SvelteHTMLElements['div'] | SvelteHTMLElements['span']) & {
13
15
  content: string;
14
16
  inline?: boolean;
15
17
  nowrap?: boolean;
18
+ base?: string;
16
19
  } = $props();
17
20
 
21
+ mdz_base_context.set(() => base);
22
+
18
23
  const nodes = $derived(mdz_parse(content));
19
24
  </script>
20
25
 
@@ -3,6 +3,7 @@ type $$ComponentProps = (SvelteHTMLElements['div'] | SvelteHTMLElements['span'])
3
3
  content: string;
4
4
  inline?: boolean;
5
5
  nowrap?: boolean;
6
+ base?: string;
6
7
  };
7
8
  declare const Mdz: import("svelte").Component<$$ComponentProps, {}, "">;
8
9
  type Mdz = ReturnType<typeof Mdz>;
@@ -1 +1 @@
1
- {"version":3,"file":"Mdz.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/Mdz.svelte"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAKvD,KAAK,gBAAgB,GAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAyBH,QAAA,MAAM,GAAG,sDAAwC,CAAC;AAClD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC;AAClC,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"Mdz.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/Mdz.svelte"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAMvD,KAAK,gBAAgB,GAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AA6BH,QAAA,MAAM,GAAG,sDAAwC,CAAC;AAClD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC;AAClC,eAAe,GAAG,CAAC"}
@@ -2,10 +2,14 @@
2
2
  import Code from '@fuzdev/fuz_code/Code.svelte';
3
3
  import {resolve} from '$app/paths';
4
4
 
5
- import type {MdzNode} from './mdz.js';
5
+ import {type MdzNode, resolve_relative_path} from './mdz.js';
6
6
  import DocsLink from './DocsLink.svelte';
7
7
  import MdzNodeView from './MdzNodeView.svelte';
8
- import {mdz_components_context, mdz_elements_context} from './mdz_components.js';
8
+ import {
9
+ mdz_components_context,
10
+ mdz_elements_context,
11
+ mdz_base_context,
12
+ } from './mdz_components.js';
9
13
 
10
14
  const {
11
15
  node,
@@ -15,6 +19,7 @@
15
19
 
16
20
  const components = mdz_components_context.get_maybe();
17
21
  const elements = mdz_elements_context.get_maybe();
22
+ const get_mdz_base = mdz_base_context.get_maybe();
18
23
  // TODO make `Code` customizable via context, maybe registered as component Codeblock?
19
24
  </script>
20
25
 
@@ -53,12 +58,18 @@
53
58
  {:else if node.type === 'Link'}
54
59
  {@const {reference} = node}
55
60
  {#if node.link_type === 'internal'}
56
- {@const is_fragment_or_query_only = reference.startsWith('#') || reference.startsWith('?')}
57
- <!-- Fragment/query-only links skip resolve() to avoid unwanted `/` prefix -->
58
- <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
59
- <a href={is_fragment_or_query_only ? reference : resolve(reference as any)}
60
- >{@render render_children(node.children)}</a
61
- >
61
+ {@const skip_resolve = reference.startsWith('#') || reference.startsWith('?')}
62
+ {@const mdz_base = get_mdz_base?.()}
63
+ {#if reference.startsWith('.') && mdz_base}
64
+ {@const resolved = resolve_relative_path(reference, mdz_base)}
65
+ <a href={resolve(resolved as any)}>{@render render_children(node.children)}</a>
66
+ {:else if skip_resolve || reference.startsWith('.')}
67
+ <!-- Fragment, query, and relative links without base skip resolve() -->
68
+ <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
69
+ <a href={reference}>{@render render_children(node.children)}</a>
70
+ {:else}
71
+ <a href={resolve(reference as any)}>{@render render_children(node.children)}</a>
72
+ {/if}
62
73
  {:else}
63
74
  <!-- external link -->
64
75
  <!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
@@ -1,4 +1,4 @@
1
- import type { MdzNode } from './mdz.js';
1
+ import { type MdzNode } from './mdz.js';
2
2
  import MdzNodeView from './MdzNodeView.svelte';
3
3
  type $$ComponentProps = {
4
4
  node: MdzNode;
@@ -1 +1 @@
1
- {"version":3,"file":"MdzNodeView.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/MdzNodeView.svelte"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,UAAU,CAAC;AAEtC,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAG9C,KAAK,gBAAgB,GAAI;IACxB,IAAI,EAAE,OAAO,CAAC;CACd,CAAC;AA2FH,QAAA,MAAM,WAAW,sDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"MdzNodeView.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/MdzNodeView.svelte"],"names":[],"mappings":"AAMA,OAAO,EAAC,KAAK,OAAO,EAAwB,MAAM,UAAU,CAAC;AAE7D,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAO9C,KAAK,gBAAgB,GAAI;IACxB,IAAI,EAAE,OAAO,CAAC;CACd,CAAC;AAoGH,QAAA,MAAM,WAAW,sDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
@@ -20,7 +20,7 @@
20
20
 
21
21
  const library = library_context.get();
22
22
 
23
- const module = $derived(library.lookup_module(module_path));
23
+ const module = $derived(library.module_by_path.get(module_path));
24
24
 
25
25
  const color_class = $derived(module_path.endsWith('.svelte') ? 'color_h' : '');
26
26
 
@@ -19,7 +19,7 @@
19
19
  // TODO maybe better name?
20
20
  </script>
21
21
 
22
- {#if library.lookup_declaration(type)}
22
+ {#if library.declaration_by_name.has(type)}
23
23
  <DeclarationLink name={type} {hash} />
24
24
  {:else}
25
25
  <Code lang="ts" content={type} inline />
@@ -22,7 +22,7 @@ export declare class Library {
22
22
  * Default `''` preserves single-package behavior.
23
23
  */
24
24
  readonly url_prefix: string;
25
- package_json: {
25
+ readonly package_json: {
26
26
  [x: string]: unknown;
27
27
  name: string;
28
28
  version: string;
@@ -86,7 +86,7 @@ export declare class Library {
86
86
  main?: string | undefined;
87
87
  exports?: string | Record<string, unknown> | null | undefined;
88
88
  };
89
- source_json: {
89
+ readonly source_json: {
90
90
  [x: string]: unknown;
91
91
  name: string;
92
92
  version: string;
@@ -162,49 +162,46 @@ export declare class Library {
162
162
  star_exports?: string[] | undefined;
163
163
  }[] | undefined;
164
164
  };
165
- name: string;
166
- repo_name: string;
167
- repo_url: import("@fuzdev/fuz_util/url.js").Url;
168
- owner_name: string | null;
169
- homepage_url: import("@fuzdev/fuz_util/url.js").Url | null;
170
- logo_url: import("@fuzdev/fuz_util/url.js").Url | null;
171
- logo_alt: string;
172
- npm_url: import("@fuzdev/fuz_util/url.js").Url | null;
173
- changelog_url: import("@fuzdev/fuz_util/url.js").Url | null;
174
- published: boolean;
165
+ readonly name: string;
166
+ readonly repo_name: string;
167
+ readonly repo_url: import("@fuzdev/fuz_util/url.js").Url;
168
+ readonly owner_name: string | null;
169
+ readonly homepage_url: import("@fuzdev/fuz_util/url.js").Url | null;
170
+ readonly logo_url: import("@fuzdev/fuz_util/url.js").Url | null;
171
+ readonly logo_alt: string;
172
+ readonly npm_url: import("@fuzdev/fuz_util/url.js").Url | null;
173
+ readonly changelog_url: import("@fuzdev/fuz_util/url.js").Url | null;
174
+ readonly published: boolean;
175
175
  /**
176
176
  * Organization URL (e.g., 'https://github.com/ryanatkn').
177
177
  */
178
- org_url: string | null;
178
+ readonly org_url: string | null;
179
179
  /**
180
180
  * All modules as rich Module instances.
181
181
  */
182
- modules: Module[];
182
+ readonly modules: Module[];
183
183
  /**
184
184
  * All modules sorted alphabetically by path.
185
185
  */
186
- modules_sorted: Module[];
186
+ readonly modules_sorted: Module[];
187
187
  /**
188
188
  * All declarations across all modules as a flat array.
189
189
  */
190
- declarations: Declaration[];
190
+ readonly declarations: Declaration[];
191
191
  /**
192
- * Declaration lookup map by name. Provides O(1) lookup.
193
- */
194
- declaration_map: Map<string, Declaration>;
195
- constructor(library_json: LibraryJson, url_prefix?: string);
196
- /**
197
- * Look up a declaration by name.
192
+ * Module lookup map by path. Provides O(1) lookup.
198
193
  */
199
- lookup_declaration(name: string): Declaration | undefined;
194
+ readonly module_by_path: Map<string, Module>;
200
195
  /**
201
- * Check if a declaration exists.
196
+ * Declaration lookup map by name. Provides O(1) lookup.
202
197
  */
203
- has_declaration(name: string): boolean;
198
+ readonly declaration_by_name: Map<string, Declaration>;
199
+ constructor(library_json: LibraryJson, url_prefix?: string);
204
200
  /**
205
- * Look up a module by its canonical path.
201
+ * Look up modules within a directory prefix.
202
+ * Returns modules whose paths start with `path + "/"`, or `null` if none match.
206
203
  */
207
- lookup_module(path: string): Module | undefined;
204
+ lookup_directory_modules(path: string): Array<Module> | null;
208
205
  /**
209
206
  * Search declarations by query string with multi-term AND logic.
210
207
  */
@@ -1 +1 @@
1
- {"version":3,"file":"library.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAIlE,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,MAGzD,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,OAAO;IACnB,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAiB;IAEnD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IACH,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC;CAGtD;AAED,eAAO,MAAM,eAAe;;;;CAA4B,CAAC"}
@@ -61,31 +61,31 @@ export class Library {
61
61
  * All declarations across all modules as a flat array.
62
62
  */
63
63
  declarations = $derived(this.modules.flatMap((module) => module.declarations));
64
+ /**
65
+ * Module lookup map by path. Provides O(1) lookup.
66
+ */
67
+ module_by_path = $derived(new Map(this.modules.map((m) => [m.path, m])));
64
68
  /**
65
69
  * Declaration lookup map by name. Provides O(1) lookup.
66
70
  */
67
- declaration_map = $derived(new Map(this.declarations.map((d) => [d.name, d])));
71
+ declaration_by_name = $derived(new Map(this.declarations.map((d) => [d.name, d])));
68
72
  constructor(library_json, url_prefix = '') {
69
73
  this.library_json = library_json;
70
74
  this.url_prefix = parse_library_url_prefix(url_prefix);
71
75
  }
72
76
  /**
73
- * Look up a declaration by name.
74
- */
75
- lookup_declaration(name) {
76
- return this.declaration_map.get(name);
77
- }
78
- /**
79
- * Check if a declaration exists.
77
+ * Look up modules within a directory prefix.
78
+ * Returns modules whose paths start with `path + "/"`, or `null` if none match.
80
79
  */
81
- has_declaration(name) {
82
- return this.declaration_map.has(name);
83
- }
84
- /**
85
- * Look up a module by its canonical path.
86
- */
87
- lookup_module(path) {
88
- return this.modules.find((m) => m.path === path);
80
+ lookup_directory_modules(path) {
81
+ const prefix = path + '/';
82
+ let result = null;
83
+ for (const m of this.modules_sorted) {
84
+ if (m.path.startsWith(prefix)) {
85
+ (result ??= []).push(m);
86
+ }
87
+ }
88
+ return result;
89
89
  }
90
90
  /**
91
91
  * Search declarations by query string with multi-term AND logic.
package/dist/mdz.d.ts CHANGED
@@ -109,4 +109,17 @@ export declare class MdzParser {
109
109
  parse(): Array<MdzNode>;
110
110
  }
111
111
  export declare const mdz_is_url: (s: string) => boolean;
112
+ /**
113
+ * Resolves a relative path (`./` or `../`) against a base path.
114
+ * The base is treated as a directory regardless of trailing slash
115
+ * (`'/docs/mdz'` and `'/docs/mdz/'` behave identically).
116
+ * Handles embedded `.` and `..` segments within the reference
117
+ * (e.g., `'./a/../b'` → navigates up then down).
118
+ * Clamps at root — excess `..` segments stop at `/` rather than escaping.
119
+ *
120
+ * @param reference A relative path starting with `./` or `../`.
121
+ * @param base An absolute base path (e.g., `'/docs/mdz/'`). Empty string is treated as root.
122
+ * @returns An absolute resolved path (e.g., `'/docs/mdz/grammar'`).
123
+ */
124
+ export declare const resolve_relative_path: (reference: string, base: string) => string;
112
125
  //# sourceMappingURL=mdz.d.ts.map
package/dist/mdz.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mdz.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,KAAK,CAAC,OAAO,CAAgC,CAAC;AAEvF,MAAM,MAAM,OAAO,GAChB,WAAW,GACX,WAAW,GACX,gBAAgB,GAChB,WAAW,GACX,aAAa,GACb,oBAAoB,GACpB,WAAW,GACX,gBAAgB,GAChB,SAAS,GACT,cAAc,GACd,cAAc,GACd,gBAAgB,CAAC;AAEpB,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACpD,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,E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