@xyd-js/context 0.1.0-xyd.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # @xyd-js/context
2
+
3
+ ## 0.1.0-xyd.2
4
+
5
+ ### Patch Changes
6
+
7
+ - test
8
+ - Updated dependencies
9
+ - @xyd-js/core@0.1.0-xyd.15
10
+
11
+ ## 0.1.0-xyd.1
12
+
13
+ ### Patch Changes
14
+
15
+ - update packages
16
+ - Updated dependencies
17
+ - @xyd-js/core@0.1.0-xyd.14
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 xyd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,1028 @@
1
+ import { Theme, Settings } from '@xyd-js/core';
2
+ import { Node as Node$1, Data as Data$1 } from 'unist';
3
+
4
+ // ## Enumeration
5
+
6
+ /**
7
+ * How phrasing content is aligned
8
+ * ({@link https://drafts.csswg.org/css-text/ | [CSSTEXT]}).
9
+ *
10
+ * * `'left'`: See the
11
+ * {@link https://drafts.csswg.org/css-text/#valdef-text-align-left | left}
12
+ * value of the `text-align` CSS property
13
+ * * `'right'`: See the
14
+ * {@link https://drafts.csswg.org/css-text/#valdef-text-align-right | right}
15
+ * value of the `text-align` CSS property
16
+ * * `'center'`: See the
17
+ * {@link https://drafts.csswg.org/css-text/#valdef-text-align-center | center}
18
+ * value of the `text-align` CSS property
19
+ * * `null`: phrasing content is aligned as defined by the host environment
20
+ *
21
+ * Used in GFM tables.
22
+ */
23
+ type AlignType = "center" | "left" | "right" | null;
24
+
25
+ /**
26
+ * Explicitness of a reference.
27
+ *
28
+ * `'shortcut'`: the reference is implicit, its identifier inferred from its
29
+ * content
30
+ * `'collapsed'`: the reference is explicit, its identifier inferred from its
31
+ * content
32
+ * `'full'`: the reference is explicit, its identifier explicitly set
33
+ */
34
+ type ReferenceType = "shortcut" | "collapsed" | "full";
35
+
36
+ // ## Mixin
37
+
38
+ /**
39
+ * Node with a fallback.
40
+ */
41
+ interface Alternative {
42
+ /**
43
+ * Equivalent content for environments that cannot represent the node as
44
+ * intended.
45
+ */
46
+ alt?: string | null | undefined;
47
+ }
48
+
49
+ /**
50
+ * Internal relation from one node to another.
51
+ *
52
+ * Whether the value of `identifier` is expected to be a unique identifier or
53
+ * not depends on the type of node including the Association.
54
+ * An example of this is that they should be unique on {@link Definition},
55
+ * whereas multiple {@link LinkReference}s can be non-unique to be associated
56
+ * with one definition.
57
+ */
58
+ interface Association {
59
+ /**
60
+ * Relation of association.
61
+ *
62
+ * `identifier` is a source value: character escapes and character
63
+ * references are not parsed.
64
+ *
65
+ * It can match another node.
66
+ *
67
+ * Its value must be normalized.
68
+ * To normalize a value, collapse markdown whitespace (`[\t\n\r ]+`) to a space,
69
+ * trim the optional initial and/or final space, and perform Unicode-aware
70
+ * case-folding.
71
+ */
72
+ identifier: string;
73
+
74
+ /**
75
+ * Relation of association, in parsed form.
76
+ *
77
+ * `label` is a `string` value: it works just like `title` on {@link Link}
78
+ * or a `lang` on {@link Code}: character escapes and character references
79
+ * are parsed.
80
+ *
81
+ * It can match another node.
82
+ */
83
+ label?: string | null | undefined;
84
+ }
85
+
86
+ /**
87
+ * Marker that is associated to another node.
88
+ */
89
+ interface Reference extends Association {
90
+ /**
91
+ * Explicitness of the reference.
92
+ */
93
+ referenceType: ReferenceType;
94
+ }
95
+
96
+ /**
97
+ * Reference to resource.
98
+ */
99
+ interface Resource {
100
+ /**
101
+ * URL to the referenced resource.
102
+ */
103
+ url: string;
104
+ /**
105
+ * Advisory information for the resource, such as would be appropriate for
106
+ * a tooltip.
107
+ */
108
+ title?: string | null | undefined;
109
+ }
110
+
111
+ // ## Interfaces
112
+
113
+ /**
114
+ * Info associated with mdast nodes by the ecosystem.
115
+ *
116
+ * This space is guaranteed to never be specified by unist or mdast.
117
+ * But you can use it in utilities and plugins to store data.
118
+ *
119
+ * This type can be augmented to register custom data.
120
+ * For example:
121
+ *
122
+ * ```ts
123
+ * declare module 'mdast' {
124
+ * interface Data {
125
+ * // `someNode.data.myId` is typed as `number | undefined`
126
+ * myId?: number | undefined
127
+ * }
128
+ * }
129
+ * ```
130
+ */
131
+ interface Data extends Data$1 {}
132
+
133
+ // ## Content maps
134
+
135
+ /**
136
+ * Union of registered mdast nodes that can occur where block content is
137
+ * expected.
138
+ *
139
+ * To register custom mdast nodes, add them to {@link BlockContentMap}.
140
+ * They will be automatically added here.
141
+ */
142
+ type BlockContent = BlockContentMap[keyof BlockContentMap];
143
+
144
+ /**
145
+ * Registry of all mdast nodes that can occur where {@link BlockContent} is
146
+ * expected.
147
+ *
148
+ * This interface can be augmented to register custom node types:
149
+ *
150
+ * ```ts
151
+ * declare module 'mdast' {
152
+ * interface BlockContentMap {
153
+ * // Allow using MDX ESM nodes defined by `remark-mdx`.
154
+ * mdxjsEsm: MdxjsEsm;
155
+ * }
156
+ * }
157
+ * ```
158
+ *
159
+ * For a union of all block content, see {@link RootContent}.
160
+ */
161
+ interface BlockContentMap {
162
+ blockquote: Blockquote;
163
+ code: Code;
164
+ heading: Heading;
165
+ html: Html;
166
+ list: List;
167
+ paragraph: Paragraph;
168
+ table: Table;
169
+ thematicBreak: ThematicBreak;
170
+ }
171
+
172
+ /**
173
+ * Union of registered mdast nodes that can occur where definition content is
174
+ * expected.
175
+ *
176
+ * To register custom mdast nodes, add them to {@link DefinitionContentMap}.
177
+ * They will be automatically added here.
178
+ */
179
+ type DefinitionContent = DefinitionContentMap[keyof DefinitionContentMap];
180
+
181
+ /**
182
+ * Registry of all mdast nodes that can occur where {@link DefinitionContent}
183
+ * is expected.
184
+ *
185
+ * This interface can be augmented to register custom node types:
186
+ *
187
+ * ```ts
188
+ * declare module 'mdast' {
189
+ * interface DefinitionContentMap {
190
+ * custom: Custom;
191
+ * }
192
+ * }
193
+ * ```
194
+ *
195
+ * For a union of all definition content, see {@link RootContent}.
196
+ */
197
+ interface DefinitionContentMap {
198
+ definition: Definition;
199
+ footnoteDefinition: FootnoteDefinition;
200
+ }
201
+
202
+ /**
203
+ * Union of registered mdast nodes that can occur where list content is
204
+ * expected.
205
+ *
206
+ * To register custom mdast nodes, add them to {@link ListContentMap}.
207
+ * They will be automatically added here.
208
+ */
209
+ type ListContent = ListContentMap[keyof ListContentMap];
210
+
211
+ /**
212
+ * Registry of all mdast nodes that can occur where {@link ListContent}
213
+ * is expected.
214
+ *
215
+ * This interface can be augmented to register custom node types:
216
+ *
217
+ * ```ts
218
+ * declare module 'mdast' {
219
+ * interface ListContentMap {
220
+ * custom: Custom;
221
+ * }
222
+ * }
223
+ * ```
224
+ *
225
+ * For a union of all list content, see {@link RootContent}.
226
+ */
227
+ interface ListContentMap {
228
+ listItem: ListItem;
229
+ }
230
+
231
+ /**
232
+ * Union of registered mdast nodes that can occur where phrasing content is
233
+ * expected.
234
+ *
235
+ * To register custom mdast nodes, add them to {@link PhrasingContentMap}.
236
+ * They will be automatically added here.
237
+ */
238
+ type PhrasingContent = PhrasingContentMap[keyof PhrasingContentMap];
239
+
240
+ /**
241
+ * Registry of all mdast nodes that can occur where {@link PhrasingContent}
242
+ * is expected.
243
+ *
244
+ * This interface can be augmented to register custom node types:
245
+ *
246
+ * ```ts
247
+ * declare module 'mdast' {
248
+ * interface PhrasingContentMap {
249
+ * // Allow using MDX JSX (text) nodes defined by `remark-mdx`.
250
+ * mdxJsxTextElement: MDXJSXTextElement;
251
+ * }
252
+ * }
253
+ * ```
254
+ *
255
+ * For a union of all phrasing content, see {@link RootContent}.
256
+ */
257
+ interface PhrasingContentMap {
258
+ break: Break;
259
+ delete: Delete;
260
+ emphasis: Emphasis;
261
+ footnoteReference: FootnoteReference;
262
+ html: Html;
263
+ image: Image;
264
+ imageReference: ImageReference;
265
+ inlineCode: InlineCode;
266
+ link: Link;
267
+ linkReference: LinkReference;
268
+ strong: Strong;
269
+ text: Text;
270
+ }
271
+
272
+ /**
273
+ * Union of registered mdast nodes that can occur in {@link Root}.
274
+ *
275
+ * To register custom mdast nodes, add them to {@link RootContentMap}.
276
+ * They will be automatically added here.
277
+ */
278
+ type RootContent = RootContentMap[keyof RootContentMap];
279
+
280
+ /**
281
+ * Registry of all mdast nodes that can occur as children of {@link Root}.
282
+ *
283
+ * > **Note**: {@link Root} does not need to be an entire document.
284
+ * > it can also be a fragment.
285
+ *
286
+ * This interface can be augmented to register custom node types:
287
+ *
288
+ * ```ts
289
+ * declare module 'mdast' {
290
+ * interface RootContentMap {
291
+ * // Allow using toml nodes defined by `remark-frontmatter`.
292
+ * toml: TOML;
293
+ * }
294
+ * }
295
+ * ```
296
+ *
297
+ * For a union of all {@link Root} children, see {@link RootContent}.
298
+ */
299
+ interface RootContentMap {
300
+ blockquote: Blockquote;
301
+ break: Break;
302
+ code: Code;
303
+ definition: Definition;
304
+ delete: Delete;
305
+ emphasis: Emphasis;
306
+ footnoteDefinition: FootnoteDefinition;
307
+ footnoteReference: FootnoteReference;
308
+ heading: Heading;
309
+ html: Html;
310
+ image: Image;
311
+ imageReference: ImageReference;
312
+ inlineCode: InlineCode;
313
+ link: Link;
314
+ linkReference: LinkReference;
315
+ list: List;
316
+ listItem: ListItem;
317
+ paragraph: Paragraph;
318
+ strong: Strong;
319
+ table: Table;
320
+ tableCell: TableCell;
321
+ tableRow: TableRow;
322
+ text: Text;
323
+ thematicBreak: ThematicBreak;
324
+ yaml: Yaml;
325
+ }
326
+
327
+ /**
328
+ * Union of registered mdast nodes that can occur where row content is
329
+ * expected.
330
+ *
331
+ * To register custom mdast nodes, add them to {@link RowContentMap}.
332
+ * They will be automatically added here.
333
+ */
334
+ type RowContent = RowContentMap[keyof RowContentMap];
335
+
336
+ /**
337
+ * Registry of all mdast nodes that can occur where {@link RowContent}
338
+ * is expected.
339
+ *
340
+ * This interface can be augmented to register custom node types:
341
+ *
342
+ * ```ts
343
+ * declare module 'mdast' {
344
+ * interface RowContentMap {
345
+ * custom: Custom;
346
+ * }
347
+ * }
348
+ * ```
349
+ *
350
+ * For a union of all row content, see {@link RootContent}.
351
+ */
352
+ interface RowContentMap {
353
+ tableCell: TableCell;
354
+ }
355
+
356
+ /**
357
+ * Union of registered mdast nodes that can occur where table content is
358
+ * expected.
359
+ *
360
+ * To register custom mdast nodes, add them to {@link TableContentMap}.
361
+ * They will be automatically added here.
362
+ */
363
+ type TableContent = TableContentMap[keyof TableContentMap];
364
+
365
+ /**
366
+ * Registry of all mdast nodes that can occur where {@link TableContent}
367
+ * is expected.
368
+ *
369
+ * This interface can be augmented to register custom node types:
370
+ *
371
+ * ```ts
372
+ * declare module 'mdast' {
373
+ * interface TableContentMap {
374
+ * custom: Custom;
375
+ * }
376
+ * }
377
+ * ```
378
+ *
379
+ * For a union of all table content, see {@link RootContent}.
380
+ */
381
+ interface TableContentMap {
382
+ tableRow: TableRow;
383
+ }
384
+
385
+ // ## Abstract nodes
386
+
387
+ /**
388
+ * Abstract mdast node that contains the smallest possible value.
389
+ *
390
+ * This interface is supposed to be extended if you make custom mdast nodes.
391
+ *
392
+ * For a union of all registered mdast literals, see {@link Literals}.
393
+ */
394
+ interface Literal extends Node {
395
+ /**
396
+ * Plain-text value.
397
+ */
398
+ value: string;
399
+ }
400
+
401
+ /**
402
+ * Abstract mdast node.
403
+ *
404
+ * This interface is supposed to be extended.
405
+ * If you can use {@link Literal} or {@link Parent}, you should.
406
+ * But for example in markdown, a thematic break (`***`) is neither literal nor
407
+ * parent, but still a node.
408
+ *
409
+ * To register custom mdast nodes, add them to {@link RootContentMap} and other
410
+ * places where relevant (such as {@link ElementContentMap}).
411
+ *
412
+ * For a union of all registered mdast nodes, see {@link Nodes}.
413
+ */
414
+ interface Node extends Node$1 {
415
+ /**
416
+ * Info from the ecosystem.
417
+ */
418
+ data?: Data | undefined;
419
+ }
420
+
421
+ /**
422
+ * Abstract mdast node that contains other mdast nodes (*children*).
423
+ *
424
+ * This interface is supposed to be extended if you make custom mdast nodes.
425
+ *
426
+ * For a union of all registered mdast parents, see {@link Parents}.
427
+ */
428
+ interface Parent extends Node {
429
+ /**
430
+ * List of children.
431
+ */
432
+ children: RootContent[];
433
+ }
434
+
435
+ // ## Concrete nodes
436
+
437
+ /**
438
+ * Markdown block quote.
439
+ */
440
+ interface Blockquote extends Parent {
441
+ /**
442
+ * Node type of mdast block quote.
443
+ */
444
+ type: "blockquote";
445
+ /**
446
+ * Children of block quote.
447
+ */
448
+ children: Array<BlockContent | DefinitionContent>;
449
+ /**
450
+ * Data associated with the mdast block quote.
451
+ */
452
+ data?: BlockquoteData | undefined;
453
+ }
454
+
455
+ /**
456
+ * Info associated with mdast block quote nodes by the ecosystem.
457
+ */
458
+ interface BlockquoteData extends Data {}
459
+
460
+ /**
461
+ * Markdown break.
462
+ */
463
+ interface Break extends Node {
464
+ /**
465
+ * Node type of mdast break.
466
+ */
467
+ type: "break";
468
+ /**
469
+ * Data associated with the mdast break.
470
+ */
471
+ data?: BreakData | undefined;
472
+ }
473
+
474
+ /**
475
+ * Info associated with mdast break nodes by the ecosystem.
476
+ */
477
+ interface BreakData extends Data {}
478
+
479
+ /**
480
+ * Markdown code (flow) (block).
481
+ */
482
+ interface Code extends Literal {
483
+ /**
484
+ * Node type of mdast code (flow).
485
+ */
486
+ type: "code";
487
+ /**
488
+ * Language of computer code being marked up.
489
+ */
490
+ lang?: string | null | undefined;
491
+ /**
492
+ * Custom information relating to the node.
493
+ *
494
+ * If the lang field is present, a meta field can be present.
495
+ */
496
+ meta?: string | null | undefined;
497
+ /**
498
+ * Data associated with the mdast code (flow).
499
+ */
500
+ data?: CodeData | undefined;
501
+ }
502
+
503
+ /**
504
+ * Info associated with mdast code (flow) (block) nodes by the ecosystem.
505
+ */
506
+ interface CodeData extends Data {}
507
+
508
+ /**
509
+ * Markdown definition.
510
+ */
511
+ interface Definition extends Node, Association, Resource {
512
+ /**
513
+ * Node type of mdast definition.
514
+ */
515
+ type: "definition";
516
+ /**
517
+ * Data associated with the mdast definition.
518
+ */
519
+ data?: DefinitionData | undefined;
520
+ }
521
+
522
+ /**
523
+ * Info associated with mdast definition nodes by the ecosystem.
524
+ */
525
+ interface DefinitionData extends Data {}
526
+
527
+ /**
528
+ * Markdown GFM delete (strikethrough).
529
+ */
530
+ interface Delete extends Parent {
531
+ /**
532
+ * Node type of mdast GFM delete.
533
+ */
534
+ type: "delete";
535
+ /**
536
+ * Children of GFM delete.
537
+ */
538
+ children: PhrasingContent[];
539
+ /**
540
+ * Data associated with the mdast GFM delete.
541
+ */
542
+ data?: DeleteData | undefined;
543
+ }
544
+
545
+ /**
546
+ * Info associated with mdast GFM delete nodes by the ecosystem.
547
+ */
548
+ interface DeleteData extends Data {}
549
+
550
+ /**
551
+ * Markdown emphasis.
552
+ */
553
+ interface Emphasis extends Parent {
554
+ /**
555
+ * Node type of mdast emphasis.
556
+ */
557
+ type: "emphasis";
558
+ /**
559
+ * Children of emphasis.
560
+ */
561
+ children: PhrasingContent[];
562
+ /**
563
+ * Data associated with the mdast emphasis.
564
+ */
565
+ data?: EmphasisData | undefined;
566
+ }
567
+
568
+ /**
569
+ * Info associated with mdast emphasis nodes by the ecosystem.
570
+ */
571
+ interface EmphasisData extends Data {}
572
+
573
+ /**
574
+ * Markdown GFM footnote definition.
575
+ */
576
+ interface FootnoteDefinition extends Parent, Association {
577
+ /**
578
+ * Node type of mdast GFM footnote definition.
579
+ */
580
+ type: "footnoteDefinition";
581
+ /**
582
+ * Children of GFM footnote definition.
583
+ */
584
+ children: Array<BlockContent | DefinitionContent>;
585
+ /**
586
+ * Data associated with the mdast GFM footnote definition.
587
+ */
588
+ data?: FootnoteDefinitionData | undefined;
589
+ }
590
+
591
+ /**
592
+ * Info associated with mdast GFM footnote definition nodes by the ecosystem.
593
+ */
594
+ interface FootnoteDefinitionData extends Data {}
595
+
596
+ /**
597
+ * Markdown GFM footnote reference.
598
+ */
599
+ interface FootnoteReference extends Association, Node {
600
+ /**
601
+ * Node type of mdast GFM footnote reference.
602
+ */
603
+ type: "footnoteReference";
604
+ /**
605
+ * Data associated with the mdast GFM footnote reference.
606
+ */
607
+ data?: FootnoteReferenceData | undefined;
608
+ }
609
+
610
+ /**
611
+ * Info associated with mdast GFM footnote reference nodes by the ecosystem.
612
+ */
613
+ interface FootnoteReferenceData extends Data {}
614
+
615
+ /**
616
+ * Markdown heading.
617
+ */
618
+ interface Heading extends Parent {
619
+ /**
620
+ * Node type of mdast heading.
621
+ */
622
+ type: "heading";
623
+ /**
624
+ * Heading rank.
625
+ *
626
+ * A value of `1` is said to be the highest rank and `6` the lowest.
627
+ */
628
+ depth: 1 | 2 | 3 | 4 | 5 | 6;
629
+ /**
630
+ * Children of heading.
631
+ */
632
+ children: PhrasingContent[];
633
+ /**
634
+ * Data associated with the mdast heading.
635
+ */
636
+ data?: HeadingData | undefined;
637
+ }
638
+
639
+ /**
640
+ * Info associated with mdast heading nodes by the ecosystem.
641
+ */
642
+ interface HeadingData extends Data {}
643
+
644
+ /**
645
+ * Markdown HTML.
646
+ */
647
+ interface Html extends Literal {
648
+ /**
649
+ * Node type of mdast HTML.
650
+ */
651
+ type: "html";
652
+ /**
653
+ * Data associated with the mdast HTML.
654
+ */
655
+ data?: HtmlData | undefined;
656
+ }
657
+
658
+ /**
659
+ * Info associated with mdast HTML nodes by the ecosystem.
660
+ */
661
+ interface HtmlData extends Data {}
662
+
663
+ /**
664
+ * Markdown image.
665
+ */
666
+ interface Image extends Alternative, Node, Resource {
667
+ /**
668
+ * Node type of mdast image.
669
+ */
670
+ type: "image";
671
+ /**
672
+ * Data associated with the mdast image.
673
+ */
674
+ data?: ImageData | undefined;
675
+ }
676
+
677
+ /**
678
+ * Info associated with mdast image nodes by the ecosystem.
679
+ */
680
+ interface ImageData extends Data {}
681
+
682
+ /**
683
+ * Markdown image reference.
684
+ */
685
+ interface ImageReference extends Alternative, Node, Reference {
686
+ /**
687
+ * Node type of mdast image reference.
688
+ */
689
+ type: "imageReference";
690
+ /**
691
+ * Data associated with the mdast image reference.
692
+ */
693
+ data?: ImageReferenceData | undefined;
694
+ }
695
+
696
+ /**
697
+ * Info associated with mdast image reference nodes by the ecosystem.
698
+ */
699
+ interface ImageReferenceData extends Data {}
700
+
701
+ /**
702
+ * Markdown code (text) (inline).
703
+ */
704
+ interface InlineCode extends Literal {
705
+ /**
706
+ * Node type of mdast code (text).
707
+ */
708
+ type: "inlineCode";
709
+ /**
710
+ * Data associated with the mdast code (text).
711
+ */
712
+ data?: InlineCodeData | undefined;
713
+ }
714
+
715
+ /**
716
+ * Info associated with mdast code (text) (inline) nodes by the ecosystem.
717
+ */
718
+ interface InlineCodeData extends Data {}
719
+
720
+ /**
721
+ * Markdown link.
722
+ */
723
+ interface Link extends Parent, Resource {
724
+ /**
725
+ * Node type of mdast link.
726
+ */
727
+ type: "link";
728
+ /**
729
+ * Children of link.
730
+ */
731
+ children: PhrasingContent[];
732
+ /**
733
+ * Data associated with the mdast link.
734
+ */
735
+ data?: LinkData | undefined;
736
+ }
737
+
738
+ /**
739
+ * Info associated with mdast link nodes by the ecosystem.
740
+ */
741
+ interface LinkData extends Data {}
742
+
743
+ /**
744
+ * Markdown link reference.
745
+ */
746
+ interface LinkReference extends Parent, Reference {
747
+ /**
748
+ * Node type of mdast link reference.
749
+ */
750
+ type: "linkReference";
751
+ /**
752
+ * Children of link reference.
753
+ */
754
+ children: PhrasingContent[];
755
+ /**
756
+ * Data associated with the mdast link reference.
757
+ */
758
+ data?: LinkReferenceData | undefined;
759
+ }
760
+
761
+ /**
762
+ * Info associated with mdast link reference nodes by the ecosystem.
763
+ */
764
+ interface LinkReferenceData extends Data {}
765
+
766
+ /**
767
+ * Markdown list.
768
+ */
769
+ interface List extends Parent {
770
+ /**
771
+ * Node type of mdast list.
772
+ */
773
+ type: "list";
774
+ /**
775
+ * Whether the items have been intentionally ordered (when `true`), or that
776
+ * the order of items is not important (when `false` or not present).
777
+ */
778
+ ordered?: boolean | null | undefined;
779
+ /**
780
+ * The starting number of the list, when the `ordered` field is `true`.
781
+ */
782
+ start?: number | null | undefined;
783
+ /**
784
+ * Whether one or more of the children are separated with a blank line from
785
+ * its siblings (when `true`), or not (when `false` or not present).
786
+ */
787
+ spread?: boolean | null | undefined;
788
+ /**
789
+ * Children of list.
790
+ */
791
+ children: ListContent[];
792
+ /**
793
+ * Data associated with the mdast list.
794
+ */
795
+ data?: ListData | undefined;
796
+ }
797
+
798
+ /**
799
+ * Info associated with mdast list nodes by the ecosystem.
800
+ */
801
+ interface ListData extends Data {}
802
+
803
+ /**
804
+ * Markdown list item.
805
+ */
806
+ interface ListItem extends Parent {
807
+ /**
808
+ * Node type of mdast list item.
809
+ */
810
+ type: "listItem";
811
+ /**
812
+ * Whether the item is a tasklist item (when `boolean`).
813
+ *
814
+ * When `true`, the item is complete.
815
+ * When `false`, the item is incomplete.
816
+ */
817
+ checked?: boolean | null | undefined;
818
+ /**
819
+ * Whether one or more of the children are separated with a blank line from
820
+ * its siblings (when `true`), or not (when `false` or not present).
821
+ */
822
+ spread?: boolean | null | undefined;
823
+ /**
824
+ * Children of list item.
825
+ */
826
+ children: Array<BlockContent | DefinitionContent>;
827
+ /**
828
+ * Data associated with the mdast list item.
829
+ */
830
+ data?: ListItemData | undefined;
831
+ }
832
+
833
+ /**
834
+ * Info associated with mdast list item nodes by the ecosystem.
835
+ */
836
+ interface ListItemData extends Data {}
837
+
838
+ /**
839
+ * Markdown paragraph.
840
+ */
841
+ interface Paragraph extends Parent {
842
+ /**
843
+ * Node type of mdast paragraph.
844
+ */
845
+ type: "paragraph";
846
+ /**
847
+ * Children of paragraph.
848
+ */
849
+ children: PhrasingContent[];
850
+ /**
851
+ * Data associated with the mdast paragraph.
852
+ */
853
+ data?: ParagraphData | undefined;
854
+ }
855
+
856
+ /**
857
+ * Info associated with mdast paragraph nodes by the ecosystem.
858
+ */
859
+ interface ParagraphData extends Data {}
860
+
861
+ /**
862
+ * Markdown strong.
863
+ */
864
+ interface Strong extends Parent {
865
+ /**
866
+ * Node type of mdast strong.
867
+ */
868
+ type: "strong";
869
+ /**
870
+ * Children of strong.
871
+ */
872
+ children: PhrasingContent[];
873
+ /**
874
+ * Data associated with the mdast strong.
875
+ */
876
+ data?: StrongData | undefined;
877
+ }
878
+
879
+ /**
880
+ * Info associated with mdast strong nodes by the ecosystem.
881
+ */
882
+ interface StrongData extends Data {}
883
+
884
+ /**
885
+ * Markdown GFM table.
886
+ */
887
+ interface Table extends Parent {
888
+ /**
889
+ * Node type of mdast GFM table.
890
+ */
891
+ type: "table";
892
+ /**
893
+ * How cells in columns are aligned.
894
+ */
895
+ align?: AlignType[] | null | undefined;
896
+ /**
897
+ * Children of GFM table.
898
+ */
899
+ children: TableContent[];
900
+ /**
901
+ * Data associated with the mdast GFM table.
902
+ */
903
+ data?: TableData | undefined;
904
+ }
905
+
906
+ /**
907
+ * Info associated with mdast GFM table nodes by the ecosystem.
908
+ */
909
+ interface TableData extends Data {}
910
+
911
+ /**
912
+ * Markdown GFM table row.
913
+ */
914
+ interface TableRow extends Parent {
915
+ /**
916
+ * Node type of mdast GFM table row.
917
+ */
918
+ type: "tableRow";
919
+ /**
920
+ * Children of GFM table row.
921
+ */
922
+ children: RowContent[];
923
+ /**
924
+ * Data associated with the mdast GFM table row.
925
+ */
926
+ data?: TableRowData | undefined;
927
+ }
928
+
929
+ /**
930
+ * Info associated with mdast GFM table row nodes by the ecosystem.
931
+ */
932
+ interface TableRowData extends Data {}
933
+
934
+ /**
935
+ * Markdown GFM table cell.
936
+ */
937
+ interface TableCell extends Parent {
938
+ /**
939
+ * Node type of mdast GFM table cell.
940
+ */
941
+ type: "tableCell";
942
+ /**
943
+ * Children of GFM table cell.
944
+ */
945
+ children: PhrasingContent[];
946
+ /**
947
+ * Data associated with the mdast GFM table cell.
948
+ */
949
+ data?: TableCellData | undefined;
950
+ }
951
+
952
+ /**
953
+ * Info associated with mdast GFM table cell nodes by the ecosystem.
954
+ */
955
+ interface TableCellData extends Data {}
956
+
957
+ /**
958
+ * Markdown text.
959
+ */
960
+ interface Text extends Literal {
961
+ /**
962
+ * Node type of mdast text.
963
+ */
964
+ type: "text";
965
+ /**
966
+ * Data associated with the mdast text.
967
+ */
968
+ data?: TextData | undefined;
969
+ }
970
+
971
+ /**
972
+ * Info associated with mdast text nodes by the ecosystem.
973
+ */
974
+ interface TextData extends Data {}
975
+
976
+ /**
977
+ * Markdown thematic break (horizontal rule).
978
+ */
979
+ interface ThematicBreak extends Node {
980
+ /**
981
+ * Node type of mdast thematic break.
982
+ */
983
+ type: "thematicBreak";
984
+ /**
985
+ * Data associated with the mdast thematic break.
986
+ */
987
+ data?: ThematicBreakData | undefined;
988
+ }
989
+
990
+ /**
991
+ * Info associated with mdast thematic break nodes by the ecosystem.
992
+ */
993
+ interface ThematicBreakData extends Data {}
994
+
995
+ /**
996
+ * Markdown YAML.
997
+ */
998
+ interface Yaml extends Literal {
999
+ /**
1000
+ * Node type of mdast YAML.
1001
+ */
1002
+ type: "yaml";
1003
+ /**
1004
+ * Data associated with the mdast YAML.
1005
+ */
1006
+ data?: YamlData | undefined;
1007
+ }
1008
+
1009
+ /**
1010
+ * Info associated with mdast YAML nodes by the ecosystem.
1011
+ */
1012
+ interface YamlData extends Data {}
1013
+
1014
+ type TransformFn = (themeSettings: Theme, metaProps: any, meta: any, treeChilds: readonly RootContent[]) => any;
1015
+ interface MetaComponent {
1016
+ name: string;
1017
+ componentName: string;
1018
+ transform: TransformFn;
1019
+ }
1020
+ declare function registerMetaComponent(name: string, componentName: string, transform: TransformFn): void;
1021
+ declare function getMetaComponent(name: string): MetaComponent | undefined;
1022
+
1023
+ declare function contextSettings(): Settings;
1024
+ declare function setContextSettings(s: Settings): void;
1025
+ declare function contextBasePath(): string;
1026
+ declare function setContextBasePath(p: string): void;
1027
+
1028
+ export { contextBasePath, contextSettings, getMetaComponent, registerMetaComponent, setContextBasePath, setContextSettings };
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ // src/meta.ts
2
+ var registry = /* @__PURE__ */ new Map();
3
+ function registerMetaComponent(name, componentName, transform) {
4
+ registry.set(name, {
5
+ name,
6
+ componentName,
7
+ transform
8
+ });
9
+ }
10
+ function getMetaComponent(name) {
11
+ return registry.get(name);
12
+ }
13
+
14
+ // src/index.ts
15
+ var settings = null;
16
+ var basePath = null;
17
+ function contextSettings() {
18
+ if (!settings) {
19
+ throw new Error("Context settings not found");
20
+ }
21
+ return settings;
22
+ }
23
+ function setContextSettings(s) {
24
+ settings = s;
25
+ }
26
+ function contextBasePath() {
27
+ if (!basePath) {
28
+ throw new Error("Context base path not found");
29
+ }
30
+ return basePath;
31
+ }
32
+ function setContextBasePath(p) {
33
+ basePath = p;
34
+ }
35
+ export {
36
+ contextBasePath,
37
+ contextSettings,
38
+ getMetaComponent,
39
+ registerMetaComponent,
40
+ setContextBasePath,
41
+ setContextSettings
42
+ };
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/meta.ts","../src/index.ts"],"sourcesContent":["import type { RootContent } from 'mdast'\n\nimport type { Theme } from '@xyd-js/core'\n\ntype TransformFn = (\n themeSettings: Theme,\n metaProps: any, \n meta: any,\n treeChilds: readonly RootContent[]\n) => any // TODO: fix any\n\ninterface MetaComponent {\n name: string\n \n componentName: string\n\n transform: TransformFn\n}\n\nconst registry = new Map<string, MetaComponent>()\n\nexport function registerMetaComponent(\n name: string,\n componentName: string,\n transform: TransformFn\n) {\n registry.set(name, {\n name,\n componentName,\n transform\n })\n}\n\nexport function getMetaComponent(name: string) {\n return registry.get(name)\n}\n","import { Settings } from \"@xyd-js/core\";\n\nexport * from \"./meta\"\n\nlet settings: Settings | null = null\nlet basePath: string | null = null\n\nexport function contextSettings(): Settings {\n if (!settings) {\n throw new Error(\"Context settings not found\")\n }\n\n return settings\n}\n\nexport function setContextSettings(s: Settings) {\n settings = s\n}\n\nexport function contextBasePath(): string {\n if (!basePath) {\n throw new Error(\"Context base path not found\")\n }\n\n return basePath\n}\n\nexport function setContextBasePath(p: string) {\n basePath = p\n}"],"mappings":";AAmBA,IAAM,WAAW,oBAAI,IAA2B;AAEzC,SAAS,sBACZ,MACA,eACA,WACF;AACE,WAAS,IAAI,MAAM;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,EACJ,CAAC;AACL;AAEO,SAAS,iBAAiB,MAAc;AAC3C,SAAO,SAAS,IAAI,IAAI;AAC5B;;;AC/BA,IAAI,WAA4B;AAChC,IAAI,WAA0B;AAEvB,SAAS,kBAA4B;AACxC,MAAI,CAAC,UAAU;AACX,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAChD;AAEA,SAAO;AACX;AAEO,SAAS,mBAAmB,GAAa;AAC5C,aAAW;AACf;AAEO,SAAS,kBAA0B;AACtC,MAAI,CAAC,UAAU;AACX,UAAM,IAAI,MAAM,6BAA6B;AAAA,EACjD;AAEA,SAAO;AACX;AAEO,SAAS,mBAAmB,GAAW;AAC1C,aAAW;AACf;","names":[]}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@xyd-js/context",
3
+ "version": "0.1.0-xyd.2",
4
+ "description": "shared xyd context",
5
+ "main": "./dist/index.js",
6
+ "type": "module",
7
+ "exports": {
8
+ "./package.json": "./package.json",
9
+ ".": "./dist/index.js"
10
+ },
11
+ "dependencies": {
12
+ "@xyd-js/core": "0.1.0-xyd.15"
13
+ },
14
+ "devDependencies": {
15
+ "@types/mdast": "^4.0.3",
16
+ "@types/node": "^22.14.1",
17
+ "@vitest/coverage-v8": "^1.3.1",
18
+ "rimraf": "^3.0.2",
19
+ "tsup": "^8.3.0",
20
+ "typescript": "^4.5.5",
21
+ "vitest": "^1.3.1"
22
+ },
23
+ "scripts": {
24
+ "clean": "rimraf build",
25
+ "prebuild": "pnpm clean",
26
+ "build": "tsup",
27
+ "watch": "tsup --watch",
28
+ "test": "vitest",
29
+ "test:watch": "vitest watch"
30
+ }
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { Settings } from "@xyd-js/core";
2
+
3
+ export * from "./meta"
4
+
5
+ let settings: Settings | null = null
6
+ let basePath: string | null = null
7
+
8
+ export function contextSettings(): Settings {
9
+ if (!settings) {
10
+ throw new Error("Context settings not found")
11
+ }
12
+
13
+ return settings
14
+ }
15
+
16
+ export function setContextSettings(s: Settings) {
17
+ settings = s
18
+ }
19
+
20
+ export function contextBasePath(): string {
21
+ if (!basePath) {
22
+ throw new Error("Context base path not found")
23
+ }
24
+
25
+ return basePath
26
+ }
27
+
28
+ export function setContextBasePath(p: string) {
29
+ basePath = p
30
+ }
package/src/meta.ts ADDED
@@ -0,0 +1,36 @@
1
+ import type { RootContent } from 'mdast'
2
+
3
+ import type { Theme } from '@xyd-js/core'
4
+
5
+ type TransformFn = (
6
+ themeSettings: Theme,
7
+ metaProps: any,
8
+ meta: any,
9
+ treeChilds: readonly RootContent[]
10
+ ) => any // TODO: fix any
11
+
12
+ interface MetaComponent {
13
+ name: string
14
+
15
+ componentName: string
16
+
17
+ transform: TransformFn
18
+ }
19
+
20
+ const registry = new Map<string, MetaComponent>()
21
+
22
+ export function registerMetaComponent(
23
+ name: string,
24
+ componentName: string,
25
+ transform: TransformFn
26
+ ) {
27
+ registry.set(name, {
28
+ name,
29
+ componentName,
30
+ transform
31
+ })
32
+ }
33
+
34
+ export function getMetaComponent(name: string) {
35
+ return registry.get(name)
36
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "esnext",
4
+ "esModuleInterop": true,
5
+ "moduleResolution": "node",
6
+ "target": "ES6",
7
+ "lib": [
8
+ "dom",
9
+ "dom.iterable",
10
+ "esnext"
11
+ ],
12
+ "allowJs": true,
13
+ "skipLibCheck": true,
14
+ "strict": false,
15
+ "noEmit": false,
16
+ "incremental": false,
17
+ "resolveJsonModule": true,
18
+ "isolatedModules": true,
19
+ "jsx": "react",
20
+ "plugins": [
21
+ {
22
+ "name": "next"
23
+ }
24
+ ],
25
+ "strictNullChecks": true,
26
+ "baseUrl": ".",
27
+ "paths": {
28
+ "@xyd-js/core": ["../xyd-core/src"]
29
+ },
30
+ "typeRoots": [
31
+ "./types.d.ts"
32
+ ]
33
+ },
34
+ "include": [
35
+ "next-env.d.ts",
36
+ "**/*.ts",
37
+ "**/*.tsx",
38
+ ".next/types/**/*.ts",
39
+ "types.d.ts"
40
+ ],
41
+ "exclude": [
42
+ "node_modules"
43
+ ]
44
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,23 @@
1
+ import {defineConfig, Options} from 'tsup';
2
+
3
+ const config: Options = {
4
+ entry: ['src/index.ts'],
5
+ format: ['esm'], // Output both ESM and CJS formats
6
+ target: 'node16', // Ensure compatibility with Node.js 16
7
+ dts: {
8
+ entry: 'src/index.ts', // Specify the entry for DTS
9
+ resolve: true, // Resolve external types
10
+ },
11
+ splitting: false, // Disable code splitting
12
+ sourcemap: true, // Generate source maps
13
+ clean: true, // Clean the output directory before each build
14
+ esbuildOptions: (options) => {
15
+ options.platform = 'node'; // Ensure the platform is set to Node.js
16
+ options.external = ['node:fs/promises']; // Mark 'node:fs/promises' as external
17
+ options.loader = {'.js': 'jsx'}; // Ensure proper handling of .js files
18
+ },
19
+ tsconfig: 'tsconfig.json',
20
+ ignoreWatch: ['node_modules', 'dist', '.git', 'build'] // Exclude unnecessary directories
21
+ }
22
+
23
+ export default defineConfig(config);