@xyd-js/content 0.1.0-xyd.5 → 0.1.0-xyd.55

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 (92) hide show
  1. package/CHANGELOG.md +619 -0
  2. package/ISSUES.md +1 -0
  3. package/LICENSE +21 -0
  4. package/TODO.md +2 -0
  5. package/dist/index.d.ts +24 -5
  6. package/dist/index.js +212 -565
  7. package/dist/index.js.map +1 -1
  8. package/dist/md.d.ts +69 -0
  9. package/dist/md.js +23396 -0
  10. package/dist/md.js.map +1 -0
  11. package/dist/mdToc-NBBxMJ4l.d.ts +12 -0
  12. package/dist/vite.d.ts +129 -11
  13. package/dist/vite.js +19992 -169
  14. package/dist/vite.js.map +1 -1
  15. package/package.json +26 -7
  16. package/packages/md/index.ts +17 -8
  17. package/packages/md/plugins/component-directives/index.ts +3 -0
  18. package/packages/md/plugins/component-directives/mdComponentDirective.ts +524 -0
  19. package/packages/md/plugins/component-directives/types.ts +1 -0
  20. package/packages/md/plugins/component-directives/utils.ts +27 -0
  21. package/packages/md/plugins/composer/__fixtures__/1.single-example/input.md +7 -0
  22. package/packages/md/plugins/composer/__fixtures__/1.single-example/output.json +63 -0
  23. package/packages/md/plugins/composer/__fixtures__/2.single-example-with-name/input.md +7 -0
  24. package/packages/md/plugins/composer/__fixtures__/2.single-example-with-name/output.json +63 -0
  25. package/packages/md/plugins/composer/__fixtures__/3.multiple-examples/input.md +15 -0
  26. package/packages/md/plugins/composer/__fixtures__/3.multiple-examples/output.json +122 -0
  27. package/packages/md/plugins/composer/__fixtures__/4.example-groups/input.md +23 -0
  28. package/packages/md/plugins/composer/__fixtures__/4.example-groups/output.json +184 -0
  29. package/packages/md/plugins/composer/__tests__/mdComposer.test.ts +41 -0
  30. package/packages/md/plugins/composer/__tests__/testHelpers.ts +48 -0
  31. package/packages/md/plugins/composer/index.ts +1 -0
  32. package/packages/md/plugins/composer/mdComposer.ts +146 -0
  33. package/packages/md/plugins/developer-writing/index.ts +3 -0
  34. package/packages/md/plugins/developer-writing/mdCodeRehype.ts +78 -0
  35. package/packages/md/plugins/functions/__fixtures__/external.ts +4 -0
  36. package/packages/md/plugins/functions/__fixtures__/test.js +11 -0
  37. package/packages/md/plugins/functions/__fixtures__/test.py +9 -0
  38. package/packages/md/plugins/functions/__fixtures__/test.ts +18 -0
  39. package/packages/md/plugins/functions/__tests__/mdFunctionImportCode.test.ts +295 -0
  40. package/packages/md/plugins/functions/__tests__/parseFunctionCall.test.ts +47 -0
  41. package/packages/md/plugins/functions/__tests__/testHelpers.ts +71 -0
  42. package/packages/md/plugins/functions/index.ts +11 -0
  43. package/packages/md/plugins/functions/mdFunctionChangelog.ts +124 -0
  44. package/packages/md/plugins/functions/mdFunctionImportCode.ts +83 -0
  45. package/packages/md/plugins/functions/mdFunctionUniform.ts +79 -0
  46. package/packages/md/plugins/functions/types.ts +6 -0
  47. package/packages/md/plugins/functions/uniformProcessor.ts +349 -0
  48. package/packages/md/plugins/functions/utils.ts +423 -0
  49. package/packages/md/plugins/index.ts +56 -9
  50. package/packages/md/plugins/mdCode.ts +67 -0
  51. package/packages/md/plugins/mdHeadingId.ts +47 -0
  52. package/packages/md/plugins/mdPage.ts +35 -0
  53. package/packages/md/plugins/{md-themeSettings.ts → mdThemeSettings.ts} +8 -0
  54. package/packages/md/plugins/mdToc.ts +224 -0
  55. package/packages/md/plugins/meta/index.ts +1 -0
  56. package/packages/md/plugins/meta/mdMeta.ts +189 -0
  57. package/packages/md/plugins/output-variables/__fixtures__/1.simple/input.md +22 -0
  58. package/packages/md/plugins/output-variables/__fixtures__/1.simple/output.json +191 -0
  59. package/packages/md/plugins/output-variables/__fixtures__/2.multiple-vars/input.md +21 -0
  60. package/packages/md/plugins/output-variables/__fixtures__/2.multiple-vars/output.json +127 -0
  61. package/packages/md/plugins/output-variables/__tests__/index.test.ts +28 -0
  62. package/packages/md/plugins/output-variables/__tests__/testHelpers.ts +36 -0
  63. package/packages/md/plugins/output-variables/index.ts +1 -0
  64. package/packages/md/plugins/output-variables/lib/const.ts +4 -0
  65. package/packages/md/plugins/output-variables/lib/factoryAttributes.ts +350 -0
  66. package/packages/md/plugins/output-variables/lib/factoryLabel.ts +135 -0
  67. package/packages/md/plugins/output-variables/lib/factoryName.ts +59 -0
  68. package/packages/md/plugins/output-variables/lib/index.ts +21 -0
  69. package/packages/md/plugins/output-variables/lib/outputVarsContainer.ts +328 -0
  70. package/packages/md/plugins/output-variables/lib/util.ts +494 -0
  71. package/packages/md/plugins/output-variables/remarkOutputVars.ts +22 -0
  72. package/packages/md/plugins/rehypeHeading.ts +50 -0
  73. package/packages/md/plugins/types.ts +15 -0
  74. package/packages/md/plugins/utils/componentLike.ts +72 -0
  75. package/packages/md/plugins/utils/index.ts +2 -0
  76. package/packages/md/plugins/utils/mdParameters.test.ts +114 -0
  77. package/packages/md/plugins/utils/mdParameters.ts +249 -0
  78. package/packages/md/plugins/utils/mdastTypes.ts +42 -0
  79. package/packages/md/search/index.ts +251 -0
  80. package/packages/md/search/types.ts +36 -0
  81. package/packages/vite/index.ts +8 -2
  82. package/src/fs.ts +51 -36
  83. package/src/index.ts +4 -4
  84. package/src/navigation.ts +50 -38
  85. package/src/types.ts +8 -0
  86. package/tsconfig.json +31 -8
  87. package/tsup.config.ts +2 -0
  88. package/vitest.config.ts +17 -0
  89. package/packages/md/plugins/md-code.ts +0 -15
  90. package/packages/md/plugins/md-codegroup.ts +0 -36
  91. package/packages/md/plugins/md-page.ts +0 -22
  92. package/packages/md/plugins/md-toc.ts +0 -132
@@ -0,0 +1,12 @@
1
+ type CustomTag = {
2
+ name: RegExp;
3
+ depth: (name: string) => number;
4
+ };
5
+ interface RemarkMdxTocOptions {
6
+ name?: string;
7
+ customTags?: CustomTag[];
8
+ maxDepth?: number;
9
+ minDepth?: number;
10
+ }
11
+
12
+ export type { RemarkMdxTocOptions as R };
package/dist/vite.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as estree from 'estree';
2
+ import { Settings } from '@xyd-js/core';
3
+ import { R as RemarkMdxTocOptions } from './mdToc-NBBxMJ4l.js';
2
4
 
3
5
  declare module 'estree' {
4
6
  export interface Decorator extends estree.BaseNode {
@@ -18,6 +20,7 @@ declare module 'estree' {
18
20
 
19
21
  // utils
20
22
  type NullValue = null | undefined | void;
23
+ type MaybeArray<T> = T | T[];
21
24
  type MaybePromise<T> = T | Promise<T>;
22
25
 
23
26
  type PartialNull<T> = {
@@ -209,7 +212,10 @@ interface ModuleInfo extends ModuleOptions {
209
212
 
210
213
  type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
211
214
 
212
- type CustomPluginOptions = Record<string, any>;
215
+ // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style -- this is an interface so that it can be extended by plugins
216
+ interface CustomPluginOptions {
217
+ [plugin: string]: any;
218
+ }
213
219
 
214
220
  type LoggingFunctionWithPosition = (
215
221
  log: RollupLog | string | (() => RollupLog | string),
@@ -233,6 +239,7 @@ interface PluginContext extends MinimalPluginContext {
233
239
  debug: LoggingFunction;
234
240
  emitFile: EmitFile;
235
241
  error: (error: RollupError | string) => never;
242
+ fs: RollupFsModule;
236
243
  getFileName: (fileReferenceId: string) => string;
237
244
  getModuleIds: () => IterableIterator<string>;
238
245
  getModuleInfo: GetModuleInfo;
@@ -261,6 +268,20 @@ interface PluginContextMeta {
261
268
  watchMode: boolean;
262
269
  }
263
270
 
271
+ type StringOrRegExp = string | RegExp;
272
+
273
+ type StringFilter<Value = StringOrRegExp> =
274
+ | MaybeArray<Value>
275
+ | {
276
+ include?: MaybeArray<Value>;
277
+ exclude?: MaybeArray<Value>;
278
+ };
279
+
280
+ interface HookFilter {
281
+ id?: StringFilter;
282
+ code?: StringFilter;
283
+ }
284
+
264
285
  interface ResolvedId extends ModuleOptions {
265
286
  external: boolean | 'absolute';
266
287
  id: string;
@@ -375,11 +396,28 @@ type WatchChangeHook = (
375
396
 
376
397
  type OutputBundle = Record<string, OutputAsset | OutputChunk>;
377
398
 
399
+ type PreRenderedChunkWithFileName = PreRenderedChunk & { fileName: string };
400
+
401
+ interface ImportedInternalChunk {
402
+ type: 'internal';
403
+ fileName: string;
404
+ resolvedImportPath: string;
405
+ chunk: PreRenderedChunk;
406
+ }
407
+
408
+ interface ImportedExternalChunk {
409
+ type: 'external';
410
+ fileName: string;
411
+ resolvedImportPath: string;
412
+ }
413
+
414
+ type DynamicImportTargetChunk = ImportedInternalChunk | ImportedExternalChunk;
415
+
378
416
  interface FunctionPluginHooks {
379
417
  augmentChunkHash: (this: PluginContext, chunk: RenderedChunk) => string | void;
380
418
  buildEnd: (this: PluginContext, error?: Error) => void;
381
419
  buildStart: (this: PluginContext, options: NormalizedInputOptions) => void;
382
- closeBundle: (this: PluginContext) => void;
420
+ closeBundle: (this: PluginContext, error?: Error) => void;
383
421
  closeWatcher: (this: PluginContext) => void;
384
422
  generateBundle: (
385
423
  this: PluginContext,
@@ -400,6 +438,9 @@ interface FunctionPluginHooks {
400
438
  format: InternalModuleFormat;
401
439
  moduleId: string;
402
440
  targetModuleId: string | null;
441
+ chunk: PreRenderedChunkWithFileName;
442
+ targetChunk: PreRenderedChunkWithFileName | null;
443
+ getTargetChunkImports: () => DynamicImportTargetChunk[] | null;
403
444
  }
404
445
  ) => { left: string; right: string } | NullValue;
405
446
  renderError: (this: PluginContext, error?: Error) => void;
@@ -479,11 +520,20 @@ type MakeAsync<Function_> = Function_ extends (
479
520
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
480
521
  type ObjectHook<T, O = {}> = T | ({ handler: T; order?: 'pre' | 'post' | null } & O);
481
522
 
523
+ type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends 'transform'
524
+ ? { filter?: HookFilter }
525
+ : K extends 'load'
526
+ ? { filter?: Pick<HookFilter, 'id'> }
527
+ : K extends 'resolveId'
528
+ ? { filter?: { id?: StringFilter<RegExp> } }
529
+ : // eslint-disable-next-line @typescript-eslint/no-empty-object-type
530
+ {};
531
+
482
532
  type PluginHooks = {
483
533
  [K in keyof FunctionPluginHooks]: ObjectHook<
484
534
  K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K],
485
535
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
486
- K extends ParallelPluginHooks ? { sequential?: boolean } : {}
536
+ HookFilterExtension<K> & (K extends ParallelPluginHooks ? { sequential?: boolean } : {})
487
537
  >;
488
538
  };
489
539
 
@@ -601,6 +651,7 @@ interface InputOptions {
601
651
  experimentalCacheExpiry?: number;
602
652
  experimentalLogSideEffects?: boolean;
603
653
  external?: ExternalOption;
654
+ fs?: RollupFsModule;
604
655
  input?: InputOption;
605
656
  jsx?: false | JsxPreset | JsxOptions;
606
657
  logLevel?: LogLevelOption;
@@ -625,6 +676,7 @@ interface NormalizedInputOptions {
625
676
  experimentalCacheExpiry: number;
626
677
  experimentalLogSideEffects: boolean;
627
678
  external: IsExternal;
679
+ fs: RollupFsModule;
628
680
  input: string[] | Record<string, string>;
629
681
  jsx: false | NormalizedJsxOptions;
630
682
  logLevel: LogLevelOption;
@@ -905,12 +957,14 @@ interface ChokidarOptions {
905
957
  }
906
958
 
907
959
  interface WatcherOptions {
960
+ allowInputInsideOutputPath?: boolean;
908
961
  buildDelay?: number;
909
962
  chokidar?: ChokidarOptions;
910
963
  clearScreen?: boolean;
911
964
  exclude?: string | RegExp | (string | RegExp)[];
912
965
  include?: string | RegExp | (string | RegExp)[];
913
966
  skipWrite?: boolean;
967
+ onInvalidate?: (id: string) => void;
914
968
  }
915
969
 
916
970
  interface AstNodeLocation {
@@ -930,18 +984,82 @@ type RollupAstNode<T> = Omit<T, OmittedEstreeKeys> & AstNodeLocation;
930
984
  type ProgramNode = RollupAstNode<estree.Program>;
931
985
  type AstNode = RollupAstNode<estree.Node>;
932
986
 
933
- type CustomTag = {
934
- name: RegExp;
935
- depth: (name: string) => number;
936
- };
937
- interface RemarkMdxTocOptions {
938
- name?: string;
939
- customTags?: CustomTag[];
940
- minDepth?: number;
987
+ interface RollupFsModule {
988
+ appendFile(
989
+ path: string,
990
+ data: string | Uint8Array,
991
+ options?: { encoding?: BufferEncoding | null; mode?: string | number; flag?: string | number }
992
+ ): Promise<void>;
993
+
994
+ copyFile(source: string, destination: string, mode?: string | number): Promise<void>;
995
+
996
+ mkdir(path: string, options?: { recursive?: boolean; mode?: string | number }): Promise<void>;
997
+
998
+ mkdtemp(prefix: string): Promise<string>;
999
+
1000
+ readdir(path: string, options?: { withFileTypes?: false }): Promise<string[]>;
1001
+ readdir(path: string, options?: { withFileTypes: true }): Promise<RollupDirectoryEntry[]>;
1002
+
1003
+ readFile(
1004
+ path: string,
1005
+ options?: { encoding?: null; flag?: string | number; signal?: AbortSignal }
1006
+ ): Promise<Uint8Array>;
1007
+ readFile(
1008
+ path: string,
1009
+ options?: { encoding: BufferEncoding; flag?: string | number; signal?: AbortSignal }
1010
+ ): Promise<string>;
1011
+
1012
+ realpath(path: string): Promise<string>;
1013
+
1014
+ rename(oldPath: string, newPath: string): Promise<void>;
1015
+
1016
+ rmdir(path: string, options?: { recursive?: boolean }): Promise<void>;
1017
+
1018
+ stat(path: string): Promise<RollupFileStats>;
1019
+
1020
+ lstat(path: string): Promise<RollupFileStats>;
1021
+
1022
+ unlink(path: string): Promise<void>;
1023
+
1024
+ writeFile(
1025
+ path: string,
1026
+ data: string | Uint8Array,
1027
+ options?: { encoding?: BufferEncoding | null; mode?: string | number; flag?: string | number }
1028
+ ): Promise<void>;
1029
+ }
1030
+
1031
+ type BufferEncoding =
1032
+ | 'ascii'
1033
+ | 'utf8'
1034
+ | 'utf16le'
1035
+ | 'ucs2'
1036
+ | 'base64'
1037
+ | 'base64url'
1038
+ | 'latin1'
1039
+ | 'binary'
1040
+ | 'hex';
1041
+
1042
+ interface RollupDirectoryEntry {
1043
+ isFile(): boolean;
1044
+ isDirectory(): boolean;
1045
+ isSymbolicLink(): boolean;
1046
+ name: string;
1047
+ }
1048
+
1049
+ interface RollupFileStats {
1050
+ isFile(): boolean;
1051
+ isDirectory(): boolean;
1052
+ isSymbolicLink(): boolean;
1053
+ size: number;
1054
+ mtime: Date;
1055
+ ctime: Date;
1056
+ atime: Date;
1057
+ birthtime: Date;
941
1058
  }
942
1059
 
943
1060
  interface VitePluginInterface {
944
1061
  toc: RemarkMdxTocOptions;
1062
+ settings: Settings;
945
1063
  }
946
1064
  declare function vitePlugins(options: VitePluginInterface): Plugin[];
947
1065