@foldkit/markdown 0.8.1 → 0.9.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.
- package/README.md +13 -9
- package/dist/ast/ast.d.ts +42 -42
- package/dist/ast/ast.d.ts.map +1 -1
- package/dist/ast/ast.js +60 -38
- package/dist/island/island.d.ts +3 -3
- package/dist/island/island.d.ts.map +1 -1
- package/dist/view/view.d.ts +6 -4
- package/dist/view/view.d.ts.map +1 -1
- package/dist/view/view.js +26 -19
- package/dist/vite/frontmatter.js +3 -3
- package/dist/vite/normalize.d.ts.map +1 -1
- package/dist/vite/normalize.js +7 -7
- package/dist/vite/validateFields.d.ts +2 -2
- package/dist/vite/validateFields.d.ts.map +1 -1
- package/dist/vite/validateFields.js +3 -3
- package/dist/vite/vite.d.ts.map +1 -1
- package/dist/vite/vite.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -65,10 +65,14 @@ Markdown.view(about, {
|
|
|
65
65
|
h.p([h.Class('leading-relaxed text-stone-700')], content),
|
|
66
66
|
Link: ({ url }, content) =>
|
|
67
67
|
h.a([h.Href(url), h.Class('underline underline-offset-2')], content),
|
|
68
|
+
CodeBlock: ({ value }, occurrenceIndex) =>
|
|
69
|
+
h.pre([h.Id(`code-${occurrenceIndex}`)], [h.code([], [value])]),
|
|
68
70
|
},
|
|
69
71
|
})
|
|
70
72
|
```
|
|
71
73
|
|
|
74
|
+
The `CodeBlock` view's second argument is its zero-based occurrence index in document order, for deriving stable per-instance identifiers.
|
|
75
|
+
|
|
72
76
|
`Markdown.viewBlocks` returns one `Html` per top-level block instead, for when the blocks should land directly inside your own container element.
|
|
73
77
|
|
|
74
78
|
## Islands
|
|
@@ -89,11 +93,11 @@ Declare each island's attributes as a Schema struct, once, in a module both your
|
|
|
89
93
|
|
|
90
94
|
```typescript
|
|
91
95
|
// src/islands.ts
|
|
92
|
-
import { Schema
|
|
96
|
+
import { Schema } from 'effect'
|
|
93
97
|
|
|
94
98
|
export const islandAttributes = {
|
|
95
|
-
Counter:
|
|
96
|
-
Note:
|
|
99
|
+
Counter: Schema.Struct({ label: Schema.optionalKey(Schema.String) }),
|
|
100
|
+
Note: Schema.Struct({ tone: Schema.optionalKey(Schema.String) }),
|
|
97
101
|
}
|
|
98
102
|
```
|
|
99
103
|
|
|
@@ -144,7 +148,7 @@ const postView = (
|
|
|
144
148
|
})
|
|
145
149
|
```
|
|
146
150
|
|
|
147
|
-
Attribute values are strings on the wire, so transforming field schemas decode past them: `
|
|
151
|
+
Attribute values are strings on the wire, so transforming field schemas decode past them: `Schema.NumberFromString` turns `::Chart{height="240"}` into `height: number`. A plain `islands` record of untyped views (`Readonly<Record<string, IslandView>>`) also works when you want to skip the schemas.
|
|
148
152
|
|
|
149
153
|
## Frontmatter
|
|
150
154
|
|
|
@@ -152,11 +156,11 @@ Documents can open with a frontmatter block when the plugin is given a schema fo
|
|
|
152
156
|
|
|
153
157
|
```typescript
|
|
154
158
|
// src/postFrontmatter.ts
|
|
155
|
-
import { Schema
|
|
159
|
+
import { Schema } from 'effect'
|
|
156
160
|
|
|
157
|
-
export const PostFrontmatter =
|
|
158
|
-
title:
|
|
159
|
-
date:
|
|
161
|
+
export const PostFrontmatter = Schema.Struct({
|
|
162
|
+
title: Schema.String.check(Schema.isNonEmpty()),
|
|
163
|
+
date: Schema.String,
|
|
160
164
|
})
|
|
161
165
|
```
|
|
162
166
|
|
|
@@ -187,7 +191,7 @@ Every compiled `.md` module carries a `frontmatter` named export alongside the d
|
|
|
187
191
|
import postRaw, { frontmatter } from './post/introducing-the-blog.md'
|
|
188
192
|
```
|
|
189
193
|
|
|
190
|
-
The fields arrive as the raw strings the block declares. The build validates them against the schema and discards the decoded result, so where the application needs typed values, decode the export with the same schema at runtime; validation at build time means that decode cannot fail. `
|
|
194
|
+
The fields arrive as the raw strings the block declares. The build validates them against the schema and discards the decoded result, so where the application needs typed values, decode the export with the same schema at runtime; validation at build time means that decode cannot fail. `Schema.NumberFromString` and friends do their transformation in that runtime decode, not in the emitted module.
|
|
191
195
|
|
|
192
196
|
## Vocabulary
|
|
193
197
|
|
package/dist/ast/ast.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Option, Schema
|
|
1
|
+
import { Option, Schema } from 'effect';
|
|
2
2
|
import type { Array, SchemaAST } from 'effect';
|
|
3
3
|
/** Plain text. */
|
|
4
4
|
export type Text = Readonly<{
|
|
@@ -76,45 +76,45 @@ export type InlineEncoded = Readonly<{
|
|
|
76
76
|
}>;
|
|
77
77
|
/** Schema for {@link Text}. */
|
|
78
78
|
export declare const Text: import("foldkit/schema").CallableTaggedStruct<"Text", {
|
|
79
|
-
value:
|
|
79
|
+
value: Schema.String;
|
|
80
80
|
}>;
|
|
81
81
|
/** Schema for {@link InlineCode}. */
|
|
82
82
|
export declare const InlineCode: import("foldkit/schema").CallableTaggedStruct<"InlineCode", {
|
|
83
|
-
value:
|
|
83
|
+
value: Schema.String;
|
|
84
84
|
}>;
|
|
85
85
|
/** Schema for {@link HardBreak}. */
|
|
86
86
|
export declare const HardBreak: import("foldkit/schema").CallableTaggedStruct<"HardBreak", {}>;
|
|
87
87
|
/** Schema for {@link Inline}. */
|
|
88
|
-
export declare const Inline:
|
|
88
|
+
export declare const Inline: Schema.Codec<Inline, InlineEncoded>;
|
|
89
89
|
/** Schema for {@link Emphasis}. */
|
|
90
90
|
export declare const Emphasis: import("foldkit/schema").CallableTaggedStruct<"Emphasis", {
|
|
91
|
-
content:
|
|
91
|
+
content: Schema.$Array<Schema.Codec<Inline, InlineEncoded, never, never>>;
|
|
92
92
|
}>;
|
|
93
93
|
/** Schema for {@link Strong}. */
|
|
94
94
|
export declare const Strong: import("foldkit/schema").CallableTaggedStruct<"Strong", {
|
|
95
|
-
content:
|
|
95
|
+
content: Schema.$Array<Schema.Codec<Inline, InlineEncoded, never, never>>;
|
|
96
96
|
}>;
|
|
97
97
|
/** Schema for {@link Strikethrough}. */
|
|
98
98
|
export declare const Strikethrough: import("foldkit/schema").CallableTaggedStruct<"Strikethrough", {
|
|
99
|
-
content:
|
|
99
|
+
content: Schema.$Array<Schema.Codec<Inline, InlineEncoded, never, never>>;
|
|
100
100
|
}>;
|
|
101
101
|
/** Schema for {@link Link}. */
|
|
102
102
|
export declare const Link: import("foldkit/schema").CallableTaggedStruct<"Link", {
|
|
103
|
-
url:
|
|
104
|
-
maybeTitle:
|
|
105
|
-
content:
|
|
103
|
+
url: Schema.String;
|
|
104
|
+
maybeTitle: Schema.OptionFromNullishOr<Schema.String>;
|
|
105
|
+
content: Schema.$Array<Schema.Codec<Inline, InlineEncoded, never, never>>;
|
|
106
106
|
}>;
|
|
107
107
|
/** Schema for {@link Image}. */
|
|
108
108
|
export declare const Image: import("foldkit/schema").CallableTaggedStruct<"Image", {
|
|
109
|
-
url:
|
|
110
|
-
alt:
|
|
111
|
-
maybeTitle:
|
|
109
|
+
url: Schema.String;
|
|
110
|
+
alt: Schema.String;
|
|
111
|
+
maybeTitle: Schema.OptionFromNullishOr<Schema.String>;
|
|
112
112
|
}>;
|
|
113
113
|
/** Heading depth, `1` through `6`. */
|
|
114
|
-
export declare const HeadingLevel:
|
|
114
|
+
export declare const HeadingLevel: Schema.Literals<readonly [1, 2, 3, 4, 5, 6]>;
|
|
115
115
|
export type HeadingLevel = typeof HeadingLevel.Type;
|
|
116
116
|
/** Column alignment of a table, from the delimiter row of the source. */
|
|
117
|
-
export declare const Alignment:
|
|
117
|
+
export declare const Alignment: Schema.Literals<readonly ["None", "Left", "Center", "Right"]>;
|
|
118
118
|
export type Alignment = typeof Alignment.Type;
|
|
119
119
|
/** Section heading. */
|
|
120
120
|
export type Heading = Readonly<{
|
|
@@ -235,73 +235,73 @@ export type BlockEncoded = Readonly<{
|
|
|
235
235
|
blocks: ReadonlyArray<BlockEncoded>;
|
|
236
236
|
}>;
|
|
237
237
|
/** Schema for {@link Block}. */
|
|
238
|
-
export declare const Block:
|
|
238
|
+
export declare const Block: Schema.Codec<Block, BlockEncoded>;
|
|
239
239
|
/** Schema for {@link Heading}. */
|
|
240
240
|
export declare const Heading: import("foldkit/schema").CallableTaggedStruct<"Heading", {
|
|
241
|
-
level:
|
|
242
|
-
content:
|
|
241
|
+
level: Schema.Literals<readonly [1, 2, 3, 4, 5, 6]>;
|
|
242
|
+
content: Schema.$Array<Schema.Codec<Inline, InlineEncoded, never, never>>;
|
|
243
243
|
}>;
|
|
244
244
|
/** Schema for {@link Paragraph}. */
|
|
245
245
|
export declare const Paragraph: import("foldkit/schema").CallableTaggedStruct<"Paragraph", {
|
|
246
|
-
content:
|
|
246
|
+
content: Schema.$Array<Schema.Codec<Inline, InlineEncoded, never, never>>;
|
|
247
247
|
}>;
|
|
248
248
|
/** Schema for {@link CodeBlock}. */
|
|
249
249
|
export declare const CodeBlock: import("foldkit/schema").CallableTaggedStruct<"CodeBlock", {
|
|
250
|
-
maybeLanguage:
|
|
251
|
-
maybeMeta:
|
|
252
|
-
value:
|
|
250
|
+
maybeLanguage: Schema.OptionFromNullishOr<Schema.String>;
|
|
251
|
+
maybeMeta: Schema.OptionFromNullishOr<Schema.String>;
|
|
252
|
+
value: Schema.String;
|
|
253
253
|
}>;
|
|
254
254
|
/** Schema for {@link ListItem}. */
|
|
255
255
|
export declare const ListItem: import("foldkit/schema").CallableTaggedStruct<"ListItem", {
|
|
256
|
-
blocks:
|
|
256
|
+
blocks: Schema.$Array<Schema.Codec<Block, BlockEncoded, never, never>>;
|
|
257
257
|
}>;
|
|
258
258
|
/** Schema for {@link List}. */
|
|
259
259
|
export declare const List: import("foldkit/schema").CallableTaggedStruct<"List", {
|
|
260
|
-
isOrdered:
|
|
261
|
-
maybeStartNumber:
|
|
262
|
-
items:
|
|
263
|
-
blocks:
|
|
260
|
+
isOrdered: Schema.Boolean;
|
|
261
|
+
maybeStartNumber: Schema.OptionFromNullishOr<Schema.Number>;
|
|
262
|
+
items: Schema.NonEmptyArray<import("foldkit/schema").CallableTaggedStruct<"ListItem", {
|
|
263
|
+
blocks: Schema.$Array<Schema.Codec<Block, BlockEncoded, never, never>>;
|
|
264
264
|
}>>;
|
|
265
265
|
}>;
|
|
266
266
|
/** Schema for {@link Blockquote}. */
|
|
267
267
|
export declare const Blockquote: import("foldkit/schema").CallableTaggedStruct<"Blockquote", {
|
|
268
|
-
blocks:
|
|
268
|
+
blocks: Schema.$Array<Schema.Codec<Block, BlockEncoded, never, never>>;
|
|
269
269
|
}>;
|
|
270
270
|
/** Schema for {@link ThematicBreak}. */
|
|
271
271
|
export declare const ThematicBreak: import("foldkit/schema").CallableTaggedStruct<"ThematicBreak", {}>;
|
|
272
272
|
/** Schema for {@link TableCell}. */
|
|
273
273
|
export declare const TableCell: import("foldkit/schema").CallableTaggedStruct<"TableCell", {
|
|
274
|
-
content:
|
|
274
|
+
content: Schema.$Array<Schema.Codec<Inline, InlineEncoded, never, never>>;
|
|
275
275
|
}>;
|
|
276
276
|
/** Schema for {@link TableRow}. */
|
|
277
277
|
export declare const TableRow: import("foldkit/schema").CallableTaggedStruct<"TableRow", {
|
|
278
|
-
cells:
|
|
279
|
-
content:
|
|
278
|
+
cells: Schema.$Array<import("foldkit/schema").CallableTaggedStruct<"TableCell", {
|
|
279
|
+
content: Schema.$Array<Schema.Codec<Inline, InlineEncoded, never, never>>;
|
|
280
280
|
}>>;
|
|
281
281
|
}>;
|
|
282
282
|
/** Schema for {@link Table}. */
|
|
283
283
|
export declare const Table: import("foldkit/schema").CallableTaggedStruct<"Table", {
|
|
284
|
-
alignments:
|
|
284
|
+
alignments: Schema.$Array<Schema.Literals<readonly ["None", "Left", "Center", "Right"]>>;
|
|
285
285
|
headerRow: import("foldkit/schema").CallableTaggedStruct<"TableRow", {
|
|
286
|
-
cells:
|
|
287
|
-
content:
|
|
286
|
+
cells: Schema.$Array<import("foldkit/schema").CallableTaggedStruct<"TableCell", {
|
|
287
|
+
content: Schema.$Array<Schema.Codec<Inline, InlineEncoded, never, never>>;
|
|
288
288
|
}>>;
|
|
289
289
|
}>;
|
|
290
|
-
bodyRows:
|
|
291
|
-
cells:
|
|
292
|
-
content:
|
|
290
|
+
bodyRows: Schema.$Array<import("foldkit/schema").CallableTaggedStruct<"TableRow", {
|
|
291
|
+
cells: Schema.$Array<import("foldkit/schema").CallableTaggedStruct<"TableCell", {
|
|
292
|
+
content: Schema.$Array<Schema.Codec<Inline, InlineEncoded, never, never>>;
|
|
293
293
|
}>>;
|
|
294
294
|
}>>;
|
|
295
295
|
}>;
|
|
296
296
|
/** Schema for {@link Island}. */
|
|
297
297
|
export declare const Island: import("foldkit/schema").CallableTaggedStruct<"Island", {
|
|
298
|
-
name:
|
|
299
|
-
attributes:
|
|
300
|
-
blocks:
|
|
298
|
+
name: Schema.String;
|
|
299
|
+
attributes: Schema.$Record<Schema.String, Schema.String>;
|
|
300
|
+
blocks: Schema.$Array<Schema.Codec<Block, BlockEncoded, never, never>>;
|
|
301
301
|
}>;
|
|
302
302
|
/** A compiled markdown document: the block sequence of one source file. */
|
|
303
|
-
export declare const MarkdownDocument:
|
|
304
|
-
readonly blocks:
|
|
303
|
+
export declare const MarkdownDocument: Schema.Struct<{
|
|
304
|
+
readonly blocks: Schema.$Array<Schema.Codec<Block, BlockEncoded, never, never>>;
|
|
305
305
|
}>;
|
|
306
306
|
export type MarkdownDocument = typeof MarkdownDocument.Type;
|
|
307
307
|
/** The wire form of {@link MarkdownDocument}. */
|
package/dist/ast/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/ast/ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/ast/ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;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C;AACpC,eAAO,MAAM,SAAS;;;;EAQpB,CAAA;AAEF,mCAAmC;AACnC,eAAO,MAAM,QAAQ;;EAEnB,CAAA;AAEF,+BAA+B;AAC/B,eAAO,MAAM,IAAI;;;;;;EAMf,CAAA;AAEF,qCAAqC;AACrC,eAAO,MAAM,UAAU;;EAErB,CAAA;AAEF,wCAAwC;AACxC,eAAO,MAAM,aAAa,oEAAgC,CAAA;AAE1D,oCAAoC;AACpC,eAAO,MAAM,SAAS;;EAEpB,CAAA;AAEF,mCAAmC;AACnC,eAAO,MAAM,QAAQ;;;;EAEnB,CAAA;AAEF,gCAAgC;AAChC,eAAO,MAAM,KAAK;;;;;;;;;;;;EAIhB,CAAA;AAEF,iCAAiC;AACjC,eAAO,MAAM,MAAM;;;;EAIjB,CAAA;AAIF,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB;;EAAiD,CAAA;AAC9E,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAA;AAE3D,iDAAiD;AACjD,MAAM,MAAM,uBAAuB,GAAG,OAAO,gBAAgB,CAAC,OAAO,CAAA;AAMrE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,SACnB,OAAO,oBACK,SAAS,CAAC,YAAY,KACvC,gBAaF,CAAA;AAED,uEAAuE;AACvE,eAAO,MAAM,cAAc;;;;CAAsC,CAAA"}
|
package/dist/ast/ast.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Function, Option, Predicate, Schema
|
|
1
|
+
import { Function, Option, Predicate, Schema } from 'effect';
|
|
2
2
|
import { taggedStruct } from 'foldkit/schema';
|
|
3
3
|
/** Schema for {@link Text}. */
|
|
4
|
-
export const Text = taggedStruct('Text', { value:
|
|
4
|
+
export const Text = taggedStruct('Text', { value: Schema.String });
|
|
5
5
|
/** Schema for {@link InlineCode}. */
|
|
6
|
-
export const InlineCode = taggedStruct('InlineCode', { value:
|
|
6
|
+
export const InlineCode = taggedStruct('InlineCode', { value: Schema.String });
|
|
7
7
|
/** Schema for {@link HardBreak}. */
|
|
8
8
|
export const HardBreak = taggedStruct('HardBreak');
|
|
9
9
|
// NOTE: Manual type definitions and the explicit annotation are required
|
|
10
10
|
// because TypeScript cannot infer types for self-recursive schemas built
|
|
11
|
-
// through
|
|
11
|
+
// through Schema.suspend. Deriving the member types from their schemas instead
|
|
12
12
|
// (`type Emphasis = typeof Emphasis.Type`) recreates the circularity through
|
|
13
13
|
// the union alias and fails with TS2456, so the unions and their members stay
|
|
14
14
|
// hand-written.
|
|
15
15
|
/** Schema for {@link Inline}. */
|
|
16
|
-
export const Inline =
|
|
16
|
+
export const Inline = Schema.suspend(() => Schema.Union([
|
|
17
17
|
Text,
|
|
18
18
|
InlineCode,
|
|
19
19
|
HardBreak,
|
|
@@ -24,38 +24,44 @@ export const Inline = S.suspend(() => S.Union([
|
|
|
24
24
|
Image,
|
|
25
25
|
]));
|
|
26
26
|
/** Schema for {@link Emphasis}. */
|
|
27
|
-
export const Emphasis = taggedStruct('Emphasis', {
|
|
27
|
+
export const Emphasis = taggedStruct('Emphasis', {
|
|
28
|
+
content: Schema.Array(Inline),
|
|
29
|
+
});
|
|
28
30
|
/** Schema for {@link Strong}. */
|
|
29
|
-
export const Strong = taggedStruct('Strong', { content:
|
|
31
|
+
export const Strong = taggedStruct('Strong', { content: Schema.Array(Inline) });
|
|
30
32
|
/** Schema for {@link Strikethrough}. */
|
|
31
33
|
export const Strikethrough = taggedStruct('Strikethrough', {
|
|
32
|
-
content:
|
|
34
|
+
content: Schema.Array(Inline),
|
|
33
35
|
});
|
|
34
36
|
/** Schema for {@link Link}. */
|
|
35
37
|
export const Link = taggedStruct('Link', {
|
|
36
|
-
url:
|
|
37
|
-
maybeTitle:
|
|
38
|
-
|
|
38
|
+
url: Schema.String,
|
|
39
|
+
maybeTitle: Schema.OptionFromNullishOr(Schema.String, {
|
|
40
|
+
onNoneEncoding: null,
|
|
41
|
+
}),
|
|
42
|
+
content: Schema.Array(Inline),
|
|
39
43
|
});
|
|
40
44
|
/** Schema for {@link Image}. */
|
|
41
45
|
export const Image = taggedStruct('Image', {
|
|
42
|
-
url:
|
|
43
|
-
alt:
|
|
44
|
-
maybeTitle:
|
|
46
|
+
url: Schema.String,
|
|
47
|
+
alt: Schema.String,
|
|
48
|
+
maybeTitle: Schema.OptionFromNullishOr(Schema.String, {
|
|
49
|
+
onNoneEncoding: null,
|
|
50
|
+
}),
|
|
45
51
|
});
|
|
46
52
|
// BLOCK
|
|
47
53
|
/** Heading depth, `1` through `6`. */
|
|
48
|
-
export const HeadingLevel =
|
|
54
|
+
export const HeadingLevel = Schema.Literals([1, 2, 3, 4, 5, 6]);
|
|
49
55
|
/** Column alignment of a table, from the delimiter row of the source. */
|
|
50
|
-
export const Alignment =
|
|
56
|
+
export const Alignment = Schema.Literals(['None', 'Left', 'Center', 'Right']);
|
|
51
57
|
// NOTE: Manual type definitions and the explicit annotation are required
|
|
52
58
|
// because TypeScript cannot infer types for self-recursive schemas built
|
|
53
|
-
// through
|
|
59
|
+
// through Schema.suspend. Deriving the member types from their schemas instead
|
|
54
60
|
// (`type Emphasis = typeof Emphasis.Type`) recreates the circularity through
|
|
55
61
|
// the union alias and fails with TS2456, so the unions and their members stay
|
|
56
62
|
// hand-written.
|
|
57
63
|
/** Schema for {@link Block}. */
|
|
58
|
-
export const Block =
|
|
64
|
+
export const Block = Schema.suspend(() => Schema.Union([
|
|
59
65
|
Heading,
|
|
60
66
|
Paragraph,
|
|
61
67
|
CodeBlock,
|
|
@@ -68,48 +74,64 @@ export const Block = S.suspend(() => S.Union([
|
|
|
68
74
|
/** Schema for {@link Heading}. */
|
|
69
75
|
export const Heading = taggedStruct('Heading', {
|
|
70
76
|
level: HeadingLevel,
|
|
71
|
-
content:
|
|
77
|
+
content: Schema.Array(Inline),
|
|
72
78
|
});
|
|
73
79
|
/** Schema for {@link Paragraph}. */
|
|
74
|
-
export const Paragraph = taggedStruct('Paragraph', {
|
|
80
|
+
export const Paragraph = taggedStruct('Paragraph', {
|
|
81
|
+
content: Schema.Array(Inline),
|
|
82
|
+
});
|
|
75
83
|
/** Schema for {@link CodeBlock}. */
|
|
76
84
|
export const CodeBlock = taggedStruct('CodeBlock', {
|
|
77
|
-
maybeLanguage:
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
maybeLanguage: Schema.OptionFromNullishOr(Schema.String, {
|
|
86
|
+
onNoneEncoding: null,
|
|
87
|
+
}),
|
|
88
|
+
maybeMeta: Schema.OptionFromNullishOr(Schema.String, {
|
|
89
|
+
onNoneEncoding: null,
|
|
90
|
+
}),
|
|
91
|
+
value: Schema.String,
|
|
80
92
|
});
|
|
81
93
|
/** Schema for {@link ListItem}. */
|
|
82
|
-
export const ListItem = taggedStruct('ListItem', {
|
|
94
|
+
export const ListItem = taggedStruct('ListItem', {
|
|
95
|
+
blocks: Schema.Array(Block),
|
|
96
|
+
});
|
|
83
97
|
/** Schema for {@link List}. */
|
|
84
98
|
export const List = taggedStruct('List', {
|
|
85
|
-
isOrdered:
|
|
86
|
-
maybeStartNumber:
|
|
87
|
-
|
|
99
|
+
isOrdered: Schema.Boolean,
|
|
100
|
+
maybeStartNumber: Schema.OptionFromNullishOr(Schema.Number, {
|
|
101
|
+
onNoneEncoding: null,
|
|
102
|
+
}),
|
|
103
|
+
items: Schema.NonEmptyArray(ListItem),
|
|
88
104
|
});
|
|
89
105
|
/** Schema for {@link Blockquote}. */
|
|
90
|
-
export const Blockquote = taggedStruct('Blockquote', {
|
|
106
|
+
export const Blockquote = taggedStruct('Blockquote', {
|
|
107
|
+
blocks: Schema.Array(Block),
|
|
108
|
+
});
|
|
91
109
|
/** Schema for {@link ThematicBreak}. */
|
|
92
110
|
export const ThematicBreak = taggedStruct('ThematicBreak');
|
|
93
111
|
/** Schema for {@link TableCell}. */
|
|
94
|
-
export const TableCell = taggedStruct('TableCell', {
|
|
112
|
+
export const TableCell = taggedStruct('TableCell', {
|
|
113
|
+
content: Schema.Array(Inline),
|
|
114
|
+
});
|
|
95
115
|
/** Schema for {@link TableRow}. */
|
|
96
|
-
export const TableRow = taggedStruct('TableRow', {
|
|
116
|
+
export const TableRow = taggedStruct('TableRow', {
|
|
117
|
+
cells: Schema.Array(TableCell),
|
|
118
|
+
});
|
|
97
119
|
/** Schema for {@link Table}. */
|
|
98
120
|
export const Table = taggedStruct('Table', {
|
|
99
|
-
alignments:
|
|
121
|
+
alignments: Schema.Array(Alignment),
|
|
100
122
|
headerRow: TableRow,
|
|
101
|
-
bodyRows:
|
|
123
|
+
bodyRows: Schema.Array(TableRow),
|
|
102
124
|
});
|
|
103
125
|
/** Schema for {@link Island}. */
|
|
104
126
|
export const Island = taggedStruct('Island', {
|
|
105
|
-
name:
|
|
106
|
-
attributes:
|
|
107
|
-
blocks:
|
|
127
|
+
name: Schema.String,
|
|
128
|
+
attributes: Schema.Record(Schema.String, Schema.String),
|
|
129
|
+
blocks: Schema.Array(Block),
|
|
108
130
|
});
|
|
109
131
|
// DOCUMENT
|
|
110
132
|
/** A compiled markdown document: the block sequence of one source file. */
|
|
111
|
-
export const MarkdownDocument =
|
|
112
|
-
const decodeDocumentUncached =
|
|
133
|
+
export const MarkdownDocument = Schema.Struct({ blocks: Schema.Array(Block) });
|
|
134
|
+
const decodeDocumentUncached = Schema.decodeUnknownSync(MarkdownDocument);
|
|
113
135
|
const documentByWire = new WeakMap();
|
|
114
136
|
/**
|
|
115
137
|
* Decodes the default export of a compiled markdown module into a typed
|
|
@@ -142,4 +164,4 @@ export const decodeDocument = (wire, overrideOptions) => {
|
|
|
142
164
|
}
|
|
143
165
|
};
|
|
144
166
|
/** Encodes a {@link MarkdownDocument} into its JSON-safe wire form. */
|
|
145
|
-
export const encodeDocument =
|
|
167
|
+
export const encodeDocument = Schema.encodeSync(MarkdownDocument);
|
package/dist/island/island.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Schema
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
2
|
/**
|
|
3
3
|
* Schema for one island's attributes: a struct that decodes the directive's
|
|
4
4
|
* string attributes into typed values. Use transforming field schemas to
|
|
5
|
-
* decode past strings, for example `
|
|
5
|
+
* decode past strings, for example `Schema.NumberFromString` for numeric
|
|
6
6
|
* attributes.
|
|
7
7
|
*/
|
|
8
|
-
export type IslandDefinition =
|
|
8
|
+
export type IslandDefinition = Schema.Struct<Schema.Struct.Fields> & Readonly<{
|
|
9
9
|
DecodingServices: never;
|
|
10
10
|
EncodingServices: never;
|
|
11
11
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"island.d.ts","sourceRoot":"","sources":["../../src/island/island.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"island.d.ts","sourceRoot":"","sources":["../../src/island/island.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAChE,QAAQ,CAAC;IAAE,gBAAgB,EAAE,KAAK,CAAC;IAAC,gBAAgB,EAAE,KAAK,CAAA;CAAE,CAAC,CAAA;AAEhE;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAA"}
|
package/dist/view/view.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ export type InlineContent = ReadonlyArray<Html | string>;
|
|
|
10
10
|
* occurrence index to derive identifiers that must be unique per instance,
|
|
11
11
|
* such as an `h.submodel` slotId.
|
|
12
12
|
*/
|
|
13
|
-
export type IslandView = (attributes: Readonly<Record<string, string>>, content: ReadonlyArray<Html>, occurrenceIndex: number) => Html;
|
|
13
|
+
export type IslandView = (attributes: Readonly<globalThis.Record<string, string>>, content: ReadonlyArray<Html>, occurrenceIndex: number) => Html;
|
|
14
14
|
/** Island views by directive name. */
|
|
15
|
-
export type Islands = Readonly<Record<string, IslandView>>;
|
|
15
|
+
export type Islands = Readonly<globalThis.Record<string, IslandView>>;
|
|
16
16
|
/**
|
|
17
17
|
* One typed island view per definition. Each view receives its attributes
|
|
18
18
|
* already decoded through the island's schema, so the record is exhaustive
|
|
@@ -23,7 +23,9 @@ export type IslandViewsFor<Definitions extends IslandDefinitions> = Readonly<{
|
|
|
23
23
|
}>;
|
|
24
24
|
/**
|
|
25
25
|
* One view function per markdown node. Container nodes receive their already
|
|
26
|
-
* rendered content alongside the node itself.
|
|
26
|
+
* rendered content alongside the node itself. Code blocks additionally receive
|
|
27
|
+
* their zero-based occurrence index in document order so consumers can derive
|
|
28
|
+
* stable per-instance identifiers.
|
|
27
29
|
*/
|
|
28
30
|
export type Views = Readonly<{
|
|
29
31
|
Text: (text: Text) => Html | string;
|
|
@@ -36,7 +38,7 @@ export type Views = Readonly<{
|
|
|
36
38
|
Image: (image: Image) => Html;
|
|
37
39
|
Heading: (heading: Heading, content: InlineContent) => Html;
|
|
38
40
|
Paragraph: (paragraph: Paragraph, content: InlineContent) => Html;
|
|
39
|
-
CodeBlock: (codeBlock: CodeBlock) => Html;
|
|
41
|
+
CodeBlock: (codeBlock: CodeBlock, occurrenceIndex: number) => Html;
|
|
40
42
|
List: (list: List, items: ReadonlyArray<Html>) => Html;
|
|
41
43
|
ListItem: (listItem: ListItem, blocks: ReadonlyArray<Html>) => Html;
|
|
42
44
|
Blockquote: (blockquote: Blockquote, blocks: ReadonlyArray<Html>) => Html;
|
package/dist/view/view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/view/view.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/view/view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAA;AAEpD,OA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AAE,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,IAAI,CAAA;IAClE,SAAS,EAAE,CACT,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,OAAO,KACd,IAAI,CAAA;CACV,CAAC,CAAA;AAEF,6DAA6D;AAC7D,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,SAAS,CAAA;CACnC,CAAC,CAAA;AAuBF;;;;;;;;;;;;GAYG;AAMH,eAAO,MAAM,YAAY,EAAE,KA4C1B,CAAA;AAuED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,CAAC,WAAW,SAAS,iBAAiB,eACvD,WAAW,eACX,cAAc,CAAC,WAAW,CAAC,KACvC,OAuCF,CAAA;AAyGD;;;GAGG;AACH,eAAO,MAAM,UAAU,aACX,gBAAgB,WAClB,UAAU,KACjB,aAAa,CAAC,IAAI,CAUpB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,IAAI,aACL,gBAAgB,WAClB,UAAU,KACjB,IAAgD,CAAA"}
|
package/dist/view/view.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array, Match
|
|
1
|
+
import { Array, Match, Option, Record, Schema } from 'effect';
|
|
2
2
|
import { inertHtml as ih } from 'foldkit/html';
|
|
3
3
|
const titleAttribute = (maybeTitle) => Option.match(maybeTitle, {
|
|
4
4
|
onNone: () => [],
|
|
@@ -8,7 +8,7 @@ const startAttribute = (maybeStartNumber) => Option.match(maybeStartNumber, {
|
|
|
8
8
|
onNone: () => [],
|
|
9
9
|
onSome: startNumber => [ih.Start(startNumber)],
|
|
10
10
|
});
|
|
11
|
-
const alignmentAttribute = (alignment) =>
|
|
11
|
+
const alignmentAttribute = (alignment) => Match.value(alignment).pipe(Match.when('None', () => []), Match.when('Left', () => [ih.Style({ 'text-align': 'left' })]), Match.when('Center', () => [ih.Style({ 'text-align': 'center' })]), Match.when('Right', () => [ih.Style({ 'text-align': 'right' })]), Match.exhaustive);
|
|
12
12
|
/**
|
|
13
13
|
* Unstyled semantic defaults for every markdown node. Spread these into your
|
|
14
14
|
* own record and replace the nodes you want to restyle:
|
|
@@ -36,7 +36,7 @@ export const defaultViews = {
|
|
|
36
36
|
Strikethrough: (_strikethrough, content) => ih.del([], content),
|
|
37
37
|
Link: ({ url, maybeTitle }, content) => ih.a([ih.Href(url), ...titleAttribute(maybeTitle)], content),
|
|
38
38
|
Image: ({ url, alt, maybeTitle }) => ih.img([ih.Src(url), ih.Alt(alt), ...titleAttribute(maybeTitle)]),
|
|
39
|
-
Heading: ({ level }, content) =>
|
|
39
|
+
Heading: ({ level }, content) => Match.value(level).pipe(Match.withReturnType(), Match.when(1, () => ih.h1([], content)), Match.when(2, () => ih.h2([], content)), Match.when(3, () => ih.h3([], content)), Match.when(4, () => ih.h4([], content)), Match.when(5, () => ih.h5([], content)), Match.when(6, () => ih.h6([], content)), Match.exhaustive),
|
|
40
40
|
Paragraph: (_paragraph, content) => ih.p([], content),
|
|
41
41
|
CodeBlock: ({ value }) => ih.pre([], [ih.code([], [value])]),
|
|
42
42
|
List: ({ isOrdered, maybeStartNumber }, items) => {
|
|
@@ -61,7 +61,7 @@ export const defaultViews = {
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
};
|
|
64
|
-
const inlineView = (views, inline) =>
|
|
64
|
+
const inlineView = (views, inline) => Match.value(inline).pipe(Match.withReturnType(), Match.tagsExhaustive({
|
|
65
65
|
Text: views.Text,
|
|
66
66
|
InlineCode: views.InlineCode,
|
|
67
67
|
HardBreak: views.HardBreak,
|
|
@@ -97,9 +97,9 @@ const warnInvalidAttributesOnce = (islandName, detail) => {
|
|
|
97
97
|
export const islandsFor = (definitions, islandViews) => {
|
|
98
98
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
99
99
|
const islandViewsByName = islandViews;
|
|
100
|
-
return
|
|
101
|
-
const decodeAttributes =
|
|
102
|
-
return (attributes, content, occurrenceIndex) => Option.match(
|
|
100
|
+
return Record.map(definitions, (attributesSchema, islandName) => {
|
|
101
|
+
const decodeAttributes = Schema.decodeUnknownSync(attributesSchema);
|
|
102
|
+
return (attributes, content, occurrenceIndex) => Option.match(Record.get(islandViewsByName, islandName), {
|
|
103
103
|
onNone: () => {
|
|
104
104
|
warnMissingIslandOnce(islandName);
|
|
105
105
|
return null;
|
|
@@ -124,26 +124,30 @@ const warnMissingIslandOnce = (islandName) => {
|
|
|
124
124
|
'Add it to the islands record passed to Markdown.view.');
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
|
-
const
|
|
128
|
-
const occurrenceIndex =
|
|
129
|
-
|
|
130
|
-
return
|
|
127
|
+
const nextOccurrenceIndex = (occurrenceCounts, key) => {
|
|
128
|
+
const occurrenceIndex = occurrenceCounts.get(key) ?? 0;
|
|
129
|
+
occurrenceCounts.set(key, occurrenceIndex + 1);
|
|
130
|
+
return occurrenceIndex;
|
|
131
|
+
};
|
|
132
|
+
const islandView = (views, islands, viewState, island) => {
|
|
133
|
+
const occurrenceIndex = nextOccurrenceIndex(viewState.islandOccurrenceCounts, island.name);
|
|
134
|
+
return Option.match(Record.get(islands, island.name), {
|
|
131
135
|
onNone: () => {
|
|
132
136
|
warnMissingIslandOnce(island.name);
|
|
133
137
|
return null;
|
|
134
138
|
},
|
|
135
|
-
onSome: renderIsland => renderIsland(island.attributes, Array.map(island.blocks, block => blockView(views, islands,
|
|
139
|
+
onSome: renderIsland => renderIsland(island.attributes, Array.map(island.blocks, block => blockView(views, islands, viewState, block)), occurrenceIndex),
|
|
136
140
|
});
|
|
137
141
|
};
|
|
138
|
-
const blockView = (views, islands,
|
|
142
|
+
const blockView = (views, islands, viewState, block) => Match.value(block).pipe(Match.withReturnType(), Match.tagsExhaustive({
|
|
139
143
|
Heading: heading => views.Heading(heading, inlineContent(views, heading.content)),
|
|
140
144
|
Paragraph: paragraph => views.Paragraph(paragraph, inlineContent(views, paragraph.content)),
|
|
141
|
-
CodeBlock: views.CodeBlock,
|
|
142
|
-
List: list => views.List(list, Array.map(list.items, item => views.ListItem(item, Array.map(item.blocks, child => blockView(views, islands,
|
|
143
|
-
Blockquote: blockquote => views.Blockquote(blockquote, Array.map(blockquote.blocks, child => blockView(views, islands,
|
|
145
|
+
CodeBlock: codeBlock => views.CodeBlock(codeBlock, nextOccurrenceIndex(viewState.blockOccurrenceCounts, codeBlock._tag)),
|
|
146
|
+
List: list => views.List(list, Array.map(list.items, item => views.ListItem(item, Array.map(item.blocks, child => blockView(views, islands, viewState, child))))),
|
|
147
|
+
Blockquote: blockquote => views.Blockquote(blockquote, Array.map(blockquote.blocks, child => blockView(views, islands, viewState, child))),
|
|
144
148
|
ThematicBreak: views.ThematicBreak,
|
|
145
149
|
Table: table => views.Table(table, tableRowView(views, table, table.headerRow, true), Array.map(table.bodyRows, row => tableRowView(views, table, row, false))),
|
|
146
|
-
Island: island => islandView(views, islands,
|
|
150
|
+
Island: island => islandView(views, islands, viewState, island),
|
|
147
151
|
}));
|
|
148
152
|
/**
|
|
149
153
|
* Folds a document into one Html node per top-level block. Use this when the
|
|
@@ -152,8 +156,11 @@ const blockView = (views, islands, islandOccurrenceCounts, block) => M.value(blo
|
|
|
152
156
|
export const viewBlocks = (document, config = {}) => {
|
|
153
157
|
const views = { ...defaultViews, ...config.views };
|
|
154
158
|
const islands = config.islands ?? {};
|
|
155
|
-
const
|
|
156
|
-
|
|
159
|
+
const viewState = {
|
|
160
|
+
islandOccurrenceCounts: new Map(),
|
|
161
|
+
blockOccurrenceCounts: new Map(),
|
|
162
|
+
};
|
|
163
|
+
return Array.map(document.blocks, block => blockView(views, islands, viewState, block));
|
|
157
164
|
};
|
|
158
165
|
/**
|
|
159
166
|
* Folds a document into a single Html tree. Every node renders through
|
package/dist/vite/frontmatter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array, Option, String
|
|
1
|
+
import { Array, Option, String, pipe } from 'effect';
|
|
2
2
|
import { validateFields } from './validateFields.js';
|
|
3
3
|
const FRONTMATTER_ENTRY_PATTERN = /^([A-Za-z][A-Za-z0-9_-]*):(.*)$/;
|
|
4
4
|
const sourceLocation = (maybePosition, lineOffset) => {
|
|
@@ -26,10 +26,10 @@ export const parseFrontmatterFields = (value, maybePosition) => {
|
|
|
26
26
|
// anywhere but an own property of the returned record.
|
|
27
27
|
const fieldValues = new Map();
|
|
28
28
|
const fieldLineOffsets = new Map();
|
|
29
|
-
const entryLines = pipe(
|
|
29
|
+
const entryLines = pipe(String.split(value, '\n'), Array.map((line, lineIndex) => ({ line, lineIndex })), Array.filter(({ line }) => String.isNonEmpty(line.trim())));
|
|
30
30
|
for (const { line, lineIndex } of entryLines) {
|
|
31
31
|
const location = sourceLocation(maybePosition, lineIndex + 1);
|
|
32
|
-
const [fieldName, rawFieldValue] = Option.match(
|
|
32
|
+
const [fieldName, rawFieldValue] = Option.match(String.match(FRONTMATTER_ENTRY_PATTERN)(line), {
|
|
33
33
|
onNone: () => {
|
|
34
34
|
throw new Error(`Invalid frontmatter entry${location}. ` +
|
|
35
35
|
'Frontmatter supports flat `key: value` pairs of strings only. ' +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/vite/normalize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAKV,IAAI,EAEL,MAAM,OAAO,CAAA;AAId,OAAO,EAeL,gBAAgB,EASjB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAG7E;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,OAAO,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAA;CACxC,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/vite/normalize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAKV,IAAI,EAEL,MAAM,OAAO,CAAA;AAId,OAAO,EAeL,gBAAgB,EASjB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAG7E;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,OAAO,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAA;CACxC,CAAC,CAAA;AAoIF;;;GAGG;AACH,eAAO,MAAM,aAAa,SAClB,IAAI,YACD,gBAAgB,KACxB,gBA0GF,CAAA"}
|
package/dist/vite/normalize.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array, Match
|
|
1
|
+
import { Array, Match, Option, Record } from 'effect';
|
|
2
2
|
import { Blockquote, CodeBlock, Emphasis, HardBreak, Heading, Image, InlineCode, Island, Link, List, ListItem, Paragraph, Strikethrough, Strong, Table, TableCell, TableRow, Text, ThematicBreak, } from '../ast/index.js';
|
|
3
3
|
import { validateFields } from './validateFields.js';
|
|
4
4
|
const UNSUPPORTED_GUIDANCE = {
|
|
@@ -44,7 +44,7 @@ const toSafeUrl = (node, url) => {
|
|
|
44
44
|
}
|
|
45
45
|
return url;
|
|
46
46
|
};
|
|
47
|
-
const toInline = (node) =>
|
|
47
|
+
const toInline = (node) => Match.value(node).pipe(Match.withReturnType(), Match.discriminators('type')({
|
|
48
48
|
text: ({ value }) => Text({ value }),
|
|
49
49
|
inlineCode: ({ value }) => InlineCode({ value }),
|
|
50
50
|
break: () => HardBreak(),
|
|
@@ -61,8 +61,8 @@ const toInline = (node) => M.value(node).pipe(M.withReturnType(), M.discriminato
|
|
|
61
61
|
alt: imageNode.alt ?? '',
|
|
62
62
|
maybeTitle: Option.fromNullishOr(imageNode.title),
|
|
63
63
|
}),
|
|
64
|
-
}),
|
|
65
|
-
const toAlignment = (align) =>
|
|
64
|
+
}), Match.orElse(unsupported));
|
|
65
|
+
const toAlignment = (align) => Match.value(align).pipe(Match.withReturnType(), Match.when('left', () => 'Left'), Match.when('center', () => 'Center'), Match.when('right', () => 'Right'), Match.orElse(() => 'None'));
|
|
66
66
|
const toTableRow = (row) => TableRow({
|
|
67
67
|
cells: row.children.map(cell => TableCell({ content: cell.children.map(toInline) })),
|
|
68
68
|
});
|
|
@@ -83,7 +83,7 @@ export const normalizeRoot = (root, options = {}) => {
|
|
|
83
83
|
const attributes = normalizeAttributes(directive.attributes);
|
|
84
84
|
const { islands } = options;
|
|
85
85
|
if (islands !== undefined) {
|
|
86
|
-
Option.match(
|
|
86
|
+
Option.match(Record.get(islands, directive.name), {
|
|
87
87
|
onNone: () => {
|
|
88
88
|
throw new Error(`Unknown island "${directive.name}"${sourceLocation(directive)}. ` +
|
|
89
89
|
`Allowed islands: ${Object.keys(islands).join(', ')}.`);
|
|
@@ -109,7 +109,7 @@ export const normalizeRoot = (root, options = {}) => {
|
|
|
109
109
|
bodyRows,
|
|
110
110
|
}),
|
|
111
111
|
});
|
|
112
|
-
const toBlock = (node) =>
|
|
112
|
+
const toBlock = (node) => Match.value(node).pipe(Match.withReturnType(), Match.discriminators('type')({
|
|
113
113
|
heading: ({ depth, children }) => Heading({ level: depth, content: children.map(toInline) }),
|
|
114
114
|
paragraph: ({ children }) => Paragraph({ content: children.map(toInline) }),
|
|
115
115
|
code: ({ lang, meta, value }) => CodeBlock({
|
|
@@ -142,6 +142,6 @@ export const normalizeRoot = (root, options = {}) => {
|
|
|
142
142
|
}),
|
|
143
143
|
}),
|
|
144
144
|
containerDirective: directive => toIsland(directive, directive.children.map(toBlock)),
|
|
145
|
-
}),
|
|
145
|
+
}), Match.orElse(unsupported));
|
|
146
146
|
return { blocks: root.children.map(toBlock) };
|
|
147
147
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Option, Schema
|
|
1
|
+
import { Option, Schema } from 'effect';
|
|
2
2
|
/**
|
|
3
3
|
* A struct schema describing a flat record of string values, the shape shared
|
|
4
4
|
* by island attribute definitions and frontmatter definitions.
|
|
5
5
|
*/
|
|
6
|
-
export type FieldsSchema =
|
|
6
|
+
export type FieldsSchema = Schema.Struct<Schema.Struct.Fields> & Readonly<{
|
|
7
7
|
DecodingServices: never;
|
|
8
8
|
EncodingServices: never;
|
|
9
9
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateFields.d.ts","sourceRoot":"","sources":["../../src/vite/validateFields.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"validateFields.d.ts","sourceRoot":"","sources":["../../src/vite/validateFields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAa,MAAM,EAAqB,MAAM,QAAQ,CAAA;AAI5E;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAC5D,QAAQ,CAAC;IAAE,gBAAgB,EAAE,KAAK,CAAC;IAAC,gBAAgB,EAAE,KAAK,CAAA;CAAE,CAAC,CAAA;AAoBhE;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,WACjB,QAAQ,CAAC;IACf,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACxC,gBAAgB,EAAE,MAAM,CAAA;IACxB,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,KAAK,MAAM,CAAA;IACvE,aAAa,EAAE,CACb,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAClC,MAAM,CAAA;CACZ,CAAC,KACD,IA6BF,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Array, Option, Predicate, Schema
|
|
2
|
-
const maybeInvalidFieldName = (error) => pipe(error, Option.liftPredicate(
|
|
1
|
+
import { Array, Option, Predicate, Schema, SchemaIssue, pipe } from 'effect';
|
|
2
|
+
const maybeInvalidFieldName = (error) => pipe(error, Option.liftPredicate(Schema.isSchemaError), Option.map(schemaError => schemaError.issue), Option.flatMap(issue => issue instanceof SchemaIssue.Composite
|
|
3
3
|
? Array.head(issue.issues)
|
|
4
4
|
: Option.some(issue)), Option.flatMap(issue => issue instanceof SchemaIssue.Pointer
|
|
5
5
|
? Array.head(issue.path)
|
|
@@ -23,7 +23,7 @@ export const validateFields = (config) => {
|
|
|
23
23
|
throw new Error(config.unknownField(Array.headNonEmpty(unknownFieldNames), allowedDescription));
|
|
24
24
|
}
|
|
25
25
|
try {
|
|
26
|
-
|
|
26
|
+
Schema.decodeUnknownSync(config.schema)(config.values);
|
|
27
27
|
}
|
|
28
28
|
catch (error) {
|
|
29
29
|
throw new Error(config.invalidValues(error instanceof Error ? error.message : String(error), maybeInvalidFieldName(error)));
|
package/dist/vite/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/vite/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/vite/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAgB,MAAM,QAAQ,CAAA;AAOpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,OAAO,EAAE,gBAAgB,EAAkB,MAAM,iBAAiB,CAAA;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAM7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AActD,qGAAqG;AACrG,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAClD,QAAQ,CAAC;IACP,WAAW,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAA;CAChD,CAAC,CAAA;AA0BJ,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;CAClE,CAAC,CAAA;AAwDF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,WAChB,MAAM,YACL,qBAAqB,KAC7B,gBAEU,CAAA;AAEb;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,WAC/B,MAAM,YACL,qBAAqB,KAC7B,cACwE,CAAA;AAE3E;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,aAAa,qBAAqB,KAAQ,MA2B9D,CAAA"}
|
package/dist/vite/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array, Option, Schema
|
|
1
|
+
import { Array, Option, Schema, pipe } from 'effect';
|
|
2
2
|
import remarkDirective from 'remark-directive';
|
|
3
3
|
import remarkFrontmatter from 'remark-frontmatter';
|
|
4
4
|
import remarkGfm from 'remark-gfm';
|
|
@@ -18,7 +18,7 @@ const processor = unified()
|
|
|
18
18
|
.use(remarkGfm)
|
|
19
19
|
.use(remarkDirective)
|
|
20
20
|
.freeze();
|
|
21
|
-
const isSchemaStruct = (value) =>
|
|
21
|
+
const isSchemaStruct = (value) => Schema.isSchema(value) && 'fields' in value;
|
|
22
22
|
const validateMarkdownPluginOptions = (options) => {
|
|
23
23
|
const { islands, frontmatter } = options;
|
|
24
24
|
if (islands !== undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foldkit/markdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Write markdown files, get Foldkit views with live islands.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": "^7.0.2",
|
|
47
47
|
"vite": "^8.2.2",
|
|
48
48
|
"vitest": "^4.1.11",
|
|
49
|
-
"foldkit": "0.
|
|
49
|
+
"foldkit": "0.157.0"
|
|
50
50
|
},
|
|
51
51
|
"keywords": [
|
|
52
52
|
"foldkit",
|