@longform/longform 0.0.18 → 0.0.20

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/lib/mod.ts CHANGED
@@ -1,3 +1,18 @@
1
1
 
2
- export type { FragmentType, Fragment, ParsedResult } from './types.js';
3
- export { longform, processTemplate } from './longform.js';
2
+ export type {
3
+ SerializationElement,
4
+ SerializerConfig,
5
+ Doc,
6
+ Element,
7
+ GlobalCtx,
8
+ MetaCtx,
9
+ ElementCtx,
10
+ AttrCtx,
11
+ RenderCtx,
12
+ AsyncRenderCtx,
13
+ DirectiveDef,
14
+ OutputMode,
15
+ LongformArgs,
16
+ ParsedResult,
17
+ } from './types.ts';
18
+ export { longform, processTemplate } from './longform.ts';
package/lib/types.ts CHANGED
@@ -15,9 +15,9 @@ export type WorkingElement = {
15
15
  indent: number;
16
16
  key?: string;
17
17
  id?: string;
18
- tag?: string;
18
+ tag: string;
19
19
  class?: string;
20
- attrs: Record<string, string | null>;
20
+ attrs: Record<string, string | true | null>;
21
21
  text?: string;
22
22
  html: string;
23
23
  mount?: string;
@@ -50,7 +50,7 @@ export type FragmentRef = {
50
50
  };
51
51
 
52
52
  export type WorkingFragment = {
53
- id?: string;
53
+ id: string;
54
54
  template: boolean;
55
55
  mountable: boolean;
56
56
  type: WorkingFragmentType;
@@ -83,7 +83,7 @@ export type Doc = {
83
83
  allowElements(elements: Record<string, SerializationElement>): void;
84
84
  };
85
85
 
86
- export type SimplifiedElement = {
86
+ export type Element = {
87
87
  id?: string;
88
88
  tag: string;
89
89
  class?: string;
@@ -96,19 +96,27 @@ export type GlobalCtx = {
96
96
 
97
97
  export type MetaCtx = {
98
98
  inlineArgs?: string;
99
- }
99
+ blockArgs?: string;
100
+ };
100
101
 
101
- export type BeforeRenderCtx = {
102
- inlineArg?: string;
103
- blockArg?: string;
104
- el: SimplifiedElement;
105
- chain: SimplifiedElement[];
102
+ export type ElementCtx = {
103
+ inlineArgs?: string;
104
+ blockArgs?: string;
105
+ el: Element;
106
+ chain: Element[];
107
+ doc: Readonly<Doc>;
108
+ };
109
+
110
+ export type RenderCtx = {
111
+ inlineArgs?: string;
112
+ blockArgs?: string;
113
+ doc: Readonly<Doc>;
114
+ };
115
+
116
+ export type AsyncRenderCtx = {
117
+ inlineArgs?: string;
118
+ blockArgs?: string;
106
119
  doc: Readonly<Doc>;
107
- //serializerConfig?: SerializerConfig;
108
- //setMeta(key: string, value: unknown): void;
109
- //allowAll(): void;
110
- //allowAttributes(attributes: string[]): void;
111
- //allowElements(elements: Record<string, SerializationElement>): void;
112
120
  };
113
121
 
114
122
  export type AttrCtx = {
@@ -131,27 +139,21 @@ export type DirectiveDef = {
131
139
  */
132
140
  meta?: (args: MetaCtx) => unknown;
133
141
  global?: (ctx: GlobalCtx) => void;
134
- beforeFragment?: () => void;
135
- beforeElement?: () => void;
136
- beforeRender?: (ctx: BeforeRenderCtx) => void;
137
- render?: (inlineArgs?: string, blockArgs?: string) => string;
138
- attr?: (ctx: AttrCtx) => string;
142
+ element?: (ctx: ElementCtx) => void;
143
+ render?: (ctx: RenderCtx) => string | undefined;
144
+ asyncRender?: (ctx: AsyncRenderCtx) => Promise<string | undefined>;
145
+ attr?: (ctx: AttrCtx) => string | boolean | undefined | null;
139
146
  };
140
147
 
141
148
  export type AppliedDirective = {
142
- inlineArg?: string;
143
- blockArg?: string;
144
- onGlobal?: (ctx: GlobalCtx) => void;
145
- beforeFragment?: () => void;
146
- beforeElement?: () => void;
147
- beforeRender?: (ctx: BeforeRenderCtx) => void;
148
- render?: (inlineArgs?: string, blockArgs?: string) => string;
149
- attr?: (ctx: AttrCtx) => string;
149
+ inlineArgs?: string;
150
+ blockArgs?: string;
151
+ element?: (ctx: ElementCtx) => void;
150
152
  }
151
153
 
152
154
  export type OutputMode =
153
155
  | 'doc'
154
- | 'meta'
156
+ | 'head'
155
157
  | 'mountable'
156
158
  ;
157
159
 
@@ -212,6 +214,7 @@ export type LongformArgs = {
212
214
  allowedElements?: Array<string | SerializationElement>;
213
215
  directives?: Record<string, DirectiveDef>;
214
216
  fragments?: Record<string, Fragment>;
217
+ debug?: boolean;
215
218
  };
216
219
 
217
220
  export type ParsedResult = {
@@ -220,6 +223,7 @@ export type ParsedResult = {
220
223
  lang?: string;
221
224
  dir?: string;
222
225
  meta: Record<string, unknown>;
226
+ data: Record<string, unknown>;
223
227
  mountable?: boolean;
224
228
  root?: string;
225
229
  selector?: string;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Matthew Quinn",
5
5
  "homepage": "https://github.com/occultist-dev/longform",
6
6
  "license": "MIT",
7
- "version": "0.0.18",
7
+ "version": "0.0.20",
8
8
  "type": "module",
9
9
  "keywords": [
10
10
  "HTML",
@@ -37,6 +37,7 @@
37
37
  }
38
38
  ],
39
39
  "devDependencies": {
40
+ "@rollup/plugin-terser": "^1.0.0",
40
41
  "@rollup/plugin-typescript": "^12.3.0",
41
42
  "@types/commonmark": "^0.27.10",
42
43
  "@types/deno": "^2.5.0",
@@ -63,6 +64,7 @@
63
64
  "build": "node build.ts",
64
65
  "bench": "deno bench --no-check --allow-read ./bench/longform.bench.ts",
65
66
  "test": "node --test test/**/*.test.ts",
66
- "serve": "node ./serve.ts"
67
+ "serve": "node ./serve.ts",
68
+ "spec": "node ./spec.ts"
67
69
  }
68
70
  }