@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.
- package/CHANGELOG.md +619 -0
- package/ISSUES.md +1 -0
- package/LICENSE +21 -0
- package/TODO.md +2 -0
- package/dist/index.d.ts +24 -5
- package/dist/index.js +212 -565
- package/dist/index.js.map +1 -1
- package/dist/md.d.ts +69 -0
- package/dist/md.js +23396 -0
- package/dist/md.js.map +1 -0
- package/dist/mdToc-NBBxMJ4l.d.ts +12 -0
- package/dist/vite.d.ts +129 -11
- package/dist/vite.js +19992 -169
- package/dist/vite.js.map +1 -1
- package/package.json +26 -7
- package/packages/md/index.ts +17 -8
- package/packages/md/plugins/component-directives/index.ts +3 -0
- package/packages/md/plugins/component-directives/mdComponentDirective.ts +524 -0
- package/packages/md/plugins/component-directives/types.ts +1 -0
- package/packages/md/plugins/component-directives/utils.ts +27 -0
- package/packages/md/plugins/composer/__fixtures__/1.single-example/input.md +7 -0
- package/packages/md/plugins/composer/__fixtures__/1.single-example/output.json +63 -0
- package/packages/md/plugins/composer/__fixtures__/2.single-example-with-name/input.md +7 -0
- package/packages/md/plugins/composer/__fixtures__/2.single-example-with-name/output.json +63 -0
- package/packages/md/plugins/composer/__fixtures__/3.multiple-examples/input.md +15 -0
- package/packages/md/plugins/composer/__fixtures__/3.multiple-examples/output.json +122 -0
- package/packages/md/plugins/composer/__fixtures__/4.example-groups/input.md +23 -0
- package/packages/md/plugins/composer/__fixtures__/4.example-groups/output.json +184 -0
- package/packages/md/plugins/composer/__tests__/mdComposer.test.ts +41 -0
- package/packages/md/plugins/composer/__tests__/testHelpers.ts +48 -0
- package/packages/md/plugins/composer/index.ts +1 -0
- package/packages/md/plugins/composer/mdComposer.ts +146 -0
- package/packages/md/plugins/developer-writing/index.ts +3 -0
- package/packages/md/plugins/developer-writing/mdCodeRehype.ts +78 -0
- package/packages/md/plugins/functions/__fixtures__/external.ts +4 -0
- package/packages/md/plugins/functions/__fixtures__/test.js +11 -0
- package/packages/md/plugins/functions/__fixtures__/test.py +9 -0
- package/packages/md/plugins/functions/__fixtures__/test.ts +18 -0
- package/packages/md/plugins/functions/__tests__/mdFunctionImportCode.test.ts +295 -0
- package/packages/md/plugins/functions/__tests__/parseFunctionCall.test.ts +47 -0
- package/packages/md/plugins/functions/__tests__/testHelpers.ts +71 -0
- package/packages/md/plugins/functions/index.ts +11 -0
- package/packages/md/plugins/functions/mdFunctionChangelog.ts +124 -0
- package/packages/md/plugins/functions/mdFunctionImportCode.ts +83 -0
- package/packages/md/plugins/functions/mdFunctionUniform.ts +79 -0
- package/packages/md/plugins/functions/types.ts +6 -0
- package/packages/md/plugins/functions/uniformProcessor.ts +349 -0
- package/packages/md/plugins/functions/utils.ts +423 -0
- package/packages/md/plugins/index.ts +56 -9
- package/packages/md/plugins/mdCode.ts +67 -0
- package/packages/md/plugins/mdHeadingId.ts +47 -0
- package/packages/md/plugins/mdPage.ts +35 -0
- package/packages/md/plugins/{md-themeSettings.ts → mdThemeSettings.ts} +8 -0
- package/packages/md/plugins/mdToc.ts +224 -0
- package/packages/md/plugins/meta/index.ts +1 -0
- package/packages/md/plugins/meta/mdMeta.ts +189 -0
- package/packages/md/plugins/output-variables/__fixtures__/1.simple/input.md +22 -0
- package/packages/md/plugins/output-variables/__fixtures__/1.simple/output.json +191 -0
- package/packages/md/plugins/output-variables/__fixtures__/2.multiple-vars/input.md +21 -0
- package/packages/md/plugins/output-variables/__fixtures__/2.multiple-vars/output.json +127 -0
- package/packages/md/plugins/output-variables/__tests__/index.test.ts +28 -0
- package/packages/md/plugins/output-variables/__tests__/testHelpers.ts +36 -0
- package/packages/md/plugins/output-variables/index.ts +1 -0
- package/packages/md/plugins/output-variables/lib/const.ts +4 -0
- package/packages/md/plugins/output-variables/lib/factoryAttributes.ts +350 -0
- package/packages/md/plugins/output-variables/lib/factoryLabel.ts +135 -0
- package/packages/md/plugins/output-variables/lib/factoryName.ts +59 -0
- package/packages/md/plugins/output-variables/lib/index.ts +21 -0
- package/packages/md/plugins/output-variables/lib/outputVarsContainer.ts +328 -0
- package/packages/md/plugins/output-variables/lib/util.ts +494 -0
- package/packages/md/plugins/output-variables/remarkOutputVars.ts +22 -0
- package/packages/md/plugins/rehypeHeading.ts +50 -0
- package/packages/md/plugins/types.ts +15 -0
- package/packages/md/plugins/utils/componentLike.ts +72 -0
- package/packages/md/plugins/utils/index.ts +2 -0
- package/packages/md/plugins/utils/mdParameters.test.ts +114 -0
- package/packages/md/plugins/utils/mdParameters.ts +249 -0
- package/packages/md/plugins/utils/mdastTypes.ts +42 -0
- package/packages/md/search/index.ts +251 -0
- package/packages/md/search/types.ts +36 -0
- package/packages/vite/index.ts +8 -2
- package/src/fs.ts +51 -36
- package/src/index.ts +4 -4
- package/src/navigation.ts +50 -38
- package/src/types.ts +8 -0
- package/tsconfig.json +31 -8
- package/tsup.config.ts +2 -0
- package/vitest.config.ts +17 -0
- package/packages/md/plugins/md-code.ts +0 -15
- package/packages/md/plugins/md-codegroup.ts +0 -36
- package/packages/md/plugins/md-page.ts +0 -22
- package/packages/md/plugins/md-toc.ts +0 -132
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
|
-
|
|
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
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
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
|
|