@longform/longform 0.0.4 → 0.0.5

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.
@@ -1,70 +1,18 @@
1
- declare module "types" {
2
- export type WorkingElement = {
3
- indent: number;
4
- key?: string;
5
- id?: string;
6
- tag?: string;
7
- class?: string;
8
- attrs: Record<string, string | null>;
9
- text?: string;
10
- html: string;
11
- mount?: string;
12
- };
13
- export type WorkingFragmentType = 'root' | 'embed' | 'bare' | 'range' | 'text' | 'mount' | 'template';
14
- export type FragmentType = 'embed' | 'bare' | 'range' | 'text';
15
- export type FragmentRef = {
16
- id: string;
17
- start: number;
18
- end: number;
19
- };
20
- export type WorkingFragment = {
21
- id?: string;
22
- template: boolean;
23
- mountable: boolean;
24
- type: WorkingFragmentType;
25
- html: string;
26
- refs: FragmentRef[];
27
- els: WorkingElement[];
28
- mountPoints: MountPoint[];
29
- };
30
- export type Fragment = {
31
- id: string;
32
- selector: string;
33
- type: FragmentType;
34
- html: string;
35
- };
36
- export type MountPoint = {
37
- id: string;
38
- part: string;
39
- };
40
- export type ParsedResult = {
41
- mountable?: boolean;
42
- root: string | null;
43
- selector: string | null;
44
- mountPoints: MountPoint[];
45
- tail?: string;
46
- fragments: Record<string, Fragment>;
47
- templates: Record<string, string>;
48
- };
49
- }
50
- declare module "longform" {
51
- import type { FragmentType, ParsedResult, Fragment } from "types";
52
- export type { FragmentType, Fragment, ParsedResult };
53
- /**
54
- * Parses a longform document into a object containing the root and fragments
55
- * in the output format.
56
- *
57
- * @param {string} doc - The longform document to parse.
58
- * @returns {ParsedResult}
59
- */
60
- export function longform(doc: string, debug?: (...d: unknown[]) => void): ParsedResult;
61
- /**
62
- * Processes a client side Longform template to HTML fragment string.
63
- *
64
- * @param fragment - The fragment identifier.
65
- * @param args - A record of template arguments.
66
- * @param getFragment - A function which returns an already processed fragment's HTML string.
67
- * @returns The processed template.
68
- */
69
- export function processTemplate(template: string, args: Record<string, string | number>, getFragment: (fragment: string) => string | undefined): string | undefined;
70
- }
1
+ import type { ParsedResult } from "./types.ts";
2
+ /**
3
+ * Parses a longform document into a object containing the root and fragments
4
+ * in the output format.
5
+ *
6
+ * @param {string} doc - The longform document to parse.
7
+ * @returns {ParsedResult}
8
+ */
9
+ export declare function longform(doc: string, debug?: (...d: unknown[]) => void): ParsedResult;
10
+ /**
11
+ * Processes a client side Longform template to HTML fragment string.
12
+ *
13
+ * @param fragment - The fragment identifier.
14
+ * @param args - A record of template arguments.
15
+ * @param getFragment - A function which returns an already processed fragment's HTML string.
16
+ * @returns The processed template.
17
+ */
18
+ export declare function processTemplate(template: string, args: Record<string, string | number>, getFragment: (fragment: string) => string | undefined): string | undefined;