@rsdoctor/utils 0.1.1 → 0.1.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.
Files changed (46) hide show
  1. package/dist/type/build/envinfo.d.ts +1 -1
  2. package/dist/type/build/file/cache.d.ts +1 -1
  3. package/dist/type/build/file/index.d.ts +1 -1
  4. package/dist/type/build/file/sharding.d.ts +20 -20
  5. package/dist/type/build/index.d.ts +1 -1
  6. package/dist/type/build/json.d.ts +1 -1
  7. package/dist/type/build/process.d.ts +1 -1
  8. package/dist/type/build/server.d.ts +5 -5
  9. package/dist/type/common/alerts.d.ts +1 -1
  10. package/dist/type/common/algorithm.d.ts +1 -1
  11. package/dist/type/common/bundle.d.ts +1 -1
  12. package/dist/type/common/crypto.d.ts +1 -1
  13. package/dist/type/common/data/index.d.ts +5 -5
  14. package/dist/type/common/graph/assets.d.ts +26 -26
  15. package/dist/type/common/graph/chunk.d.ts +1 -1
  16. package/dist/type/common/graph/dependency.d.ts +1 -1
  17. package/dist/type/common/graph/entrypoints.d.ts +1 -1
  18. package/dist/type/common/graph/index.d.ts +1 -1
  19. package/dist/type/common/graph/modules.d.ts +1 -1
  20. package/dist/type/common/index.d.ts +1 -1
  21. package/dist/type/common/loader.d.ts +3 -3
  22. package/dist/type/common/manifest.d.ts +1 -1
  23. package/dist/type/common/package.d.ts +1 -1
  24. package/dist/type/common/plugin.d.ts +1 -1
  25. package/dist/type/common/resolver.d.ts +1 -1
  26. package/dist/type/common/rspack.d.ts +5 -5
  27. package/dist/type/common/summary.d.ts +5 -5
  28. package/dist/type/common/time.d.ts +1 -1
  29. package/dist/type/common/url.d.ts +1 -1
  30. package/dist/type/error/error.d.ts +33 -33
  31. package/dist/type/error/index.d.ts +1 -1
  32. package/dist/type/error/transform.d.ts +1 -1
  33. package/dist/type/error/utils.d.ts +1 -4
  34. package/dist/type/index.d.ts +1 -1
  35. package/dist/type/logger.d.ts +1 -1
  36. package/dist/type/rule-utils/document/document.d.ts +13 -13
  37. package/dist/type/rule-utils/document/index.d.ts +1 -1
  38. package/dist/type/rule-utils/document/server.d.ts +1 -1
  39. package/dist/type/rule-utils/document/types.d.ts +16 -16
  40. package/dist/type/rule-utils/index.d.ts +1 -1
  41. package/dist/type/rule-utils/parser/asserts.d.ts +79 -79
  42. package/dist/type/rule-utils/parser/index.d.ts +1 -1
  43. package/dist/type/rule-utils/parser/parser.d.ts +108 -108
  44. package/dist/type/rule-utils/parser/types.d.ts +20 -20
  45. package/dist/type/rule-utils/parser/utils.d.ts +1 -1
  46. package/package.json +2 -2
@@ -9,4 +9,4 @@ export declare function getNpmPackageVersion(pkgs: string[]): Promise<string[]>;
9
9
  export declare function getGlobalNpmPackageVersion(pkg: string): Promise<string>;
10
10
  export declare function getGlobalNpmPackageVersion(pkgs: string[]): Promise<string[]>;
11
11
  export declare function getGitBranch(): Promise<string>;
12
- export declare function getGitRepo(): Promise<string>;
12
+ export declare function getGitRepo(): Promise<string>;
@@ -2,4 +2,4 @@ import { Common } from '@rsdoctor/types';
2
2
  export declare function readFile(path: string): Promise<string>;
3
3
  export declare function readFileSync(path: string): string;
4
4
  export declare function readJSON<T extends Common.PlainObject>(path: string): Promise<T>;
5
- export declare function readJSONSync<T extends Common.PlainObject>(path: string): T;
5
+ export declare function readJSONSync<T extends Common.PlainObject>(path: string): T;
@@ -1,3 +1,3 @@
1
1
  export * from './sharding';
2
2
  export * as fse from 'fs-extra';
3
- export * as cache from './cache';
3
+ export * as cache from './cache';
@@ -1,22 +1,22 @@
1
1
  /// <reference types="node" />
2
2
  export declare class FileSharding {
3
- protected content: string;
4
- protected limitBytes: number;
5
- protected encoding: BufferEncoding;
6
- constructor(content: string, limitBytes?: number, encoding?: BufferEncoding);
7
- /**
8
- * @param ext the extension name of the output file (must starts with ".")
9
- */
10
- createVirtualShardingFiles(ext?: string): {
11
- filename: string;
12
- content: Buffer;
13
- }[];
14
- /**
15
- * @param folder absolute path of folder which used to save string sharding files.
16
- * @param ext the extension name of the output file (must starts with ".")
17
- */
18
- writeStringToFolder(folder: string, ext?: string): Promise<{
19
- filename: string;
20
- content: Buffer;
21
- }[]>;
22
- }
3
+ protected content: string;
4
+ protected limitBytes: number;
5
+ protected encoding: BufferEncoding;
6
+ constructor(content: string, limitBytes?: number, encoding?: BufferEncoding);
7
+ /**
8
+ * @param ext the extension name of the output file (must starts with ".")
9
+ */
10
+ createVirtualShardingFiles(ext?: string): {
11
+ filename: string;
12
+ content: Buffer;
13
+ }[];
14
+ /**
15
+ * @param folder absolute path of folder which used to save string sharding files.
16
+ * @param ext the extension name of the output file (must starts with ".")
17
+ */
18
+ writeStringToFolder(folder: string, ext?: string): Promise<{
19
+ filename: string;
20
+ content: Buffer;
21
+ }[]>;
22
+ }
@@ -2,4 +2,4 @@ export * as File from './file';
2
2
  export * as Json from './json';
3
3
  export * as Server from './server';
4
4
  export * as EnvInfo from './envinfo';
5
- export * as Process from './process';
5
+ export * as Process from './process';
@@ -1 +1 @@
1
- export declare function stringify<T, P = T extends undefined ? undefined : string>(json: T, replacer?: (this: any, key: string, value: any) => any, space?: string | number, cycle?: boolean): Promise<P>;
1
+ export declare function stringify<T, P = T extends undefined ? undefined : string>(json: T, replacer?: (this: any, key: string, value: any) => any, space?: string | number, cycle?: boolean): Promise<P>;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="node" />
2
2
  export declare function getMemoryUsage(): NodeJS.MemoryUsage;
3
- export declare function getMemoryUsageMessage(): string;
3
+ export declare function getMemoryUsageMessage(): string;
@@ -8,8 +8,8 @@ export declare const createGetPortSyncFunctionString: (expectPort: number) => st
8
8
  export declare function getPortSync(expectPort: number): number | never;
9
9
  export declare function createApp(): connect.Server;
10
10
  export declare function createServer(port: number): Promise<{
11
- app: Thirdparty.connect.Server;
12
- server: http.Server;
13
- port: number;
14
- close(): Promise<void> | never;
15
- }>;
11
+ app: Thirdparty.connect.Server;
12
+ server: http.Server;
13
+ port: number;
14
+ close(): Promise<void> | never;
15
+ }>;
@@ -1,2 +1,2 @@
1
1
  import { Rule, SDK } from '@rsdoctor/types';
2
- export declare function getPackageRelationAlertDetails(modules: SDK.ModuleGraphData['modules'], dependencies: SDK.ModuleGraphData['dependencies'], root: string, packageDependencies: Rule.DependencyWithPackageData[], moduleCodeMap: SDK.ModuleCodeData): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPackageRelationAlertDetails>;
2
+ export declare function getPackageRelationAlertDetails(modules: SDK.ModuleGraphData['modules'], dependencies: SDK.ModuleGraphData['dependencies'], root: string, packageDependencies: Rule.DependencyWithPackageData[], moduleCodeMap: SDK.ModuleCodeData): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPackageRelationAlertDetails>;
@@ -1,4 +1,4 @@
1
1
  export declare function mergeIntervals(intervals: [number, number][]): [number, number][];
2
2
  export declare function compressText(input: string): string;
3
3
  export declare function decompressText(input: string): string;
4
- export declare function random(min: number, max: number): number;
4
+ export declare function random(min: number, max: number): number;
@@ -1,3 +1,3 @@
1
1
  export declare function getBundleDiffPageQueryString(files: string[]): string;
2
2
  export declare function getBundleDiffPageUrl(files: string[]): string;
3
- export declare function parseFilesFromBundlePageUrlQuery(queryValue: string): string[];
3
+ export declare function parseFilesFromBundlePageUrlQuery(queryValue: string): string[];
@@ -1,2 +1,2 @@
1
1
  export declare function encode(str: string): string;
2
- export declare function decode(str: string): string;
2
+ export declare function decode(str: string): string;
@@ -3,8 +3,8 @@ import { SDK, Manifest } from '@rsdoctor/types';
3
3
  * this class will run at both brower and node environment.
4
4
  */
5
5
  export declare class APIDataLoader {
6
- protected loader: Manifest.ManifestDataLoader;
7
- constructor(loader: Manifest.ManifestDataLoader);
8
- log(...args: unknown[]): void;
9
- loadAPI<T extends SDK.ServerAPI.API, B extends SDK.ServerAPI.InferRequestBodyType<T> = SDK.ServerAPI.InferRequestBodyType<T>, R extends SDK.ServerAPI.InferResponseType<T> = SDK.ServerAPI.InferResponseType<T>>(...args: B extends void ? [api: T] : [api: T, body: B]): Promise<SDK.ServerAPI.InferResponseType<T>>;
10
- }
6
+ protected loader: Manifest.ManifestDataLoader;
7
+ constructor(loader: Manifest.ManifestDataLoader);
8
+ log(...args: unknown[]): void;
9
+ loadAPI<T extends SDK.ServerAPI.API, B extends SDK.ServerAPI.InferRequestBodyType<T> = SDK.ServerAPI.InferRequestBodyType<T>, R extends SDK.ServerAPI.InferResponseType<T> = SDK.ServerAPI.InferResponseType<T>>(...args: B extends void ? [api: T] : [api: T, body: B]): Promise<SDK.ServerAPI.InferResponseType<T>>;
10
+ }
@@ -5,37 +5,37 @@ export declare function isAssetMatchExtensions(asset: SDK.AssetData, exts: strin
5
5
  export declare function filterAssetsByExtensions(assets: SDK.AssetData[], exts: string | string[]): SDK.AssetData[];
6
6
  type FilterFunctionOrExtensions = string | string[] | ((asset: SDK.AssetData) => boolean);
7
7
  interface GetAssetsOptions {
8
- /**
9
- * turn off it when you need not file content.
10
- * @default true
11
- */
12
- withFileContent?: boolean;
13
- /**
14
- * filter with assets
15
- */
16
- filterOrExtensions?: FilterFunctionOrExtensions;
8
+ /**
9
+ * turn off it when you need not file content.
10
+ * @default true
11
+ */
12
+ withFileContent?: boolean;
13
+ /**
14
+ * filter with assets
15
+ */
16
+ filterOrExtensions?: FilterFunctionOrExtensions;
17
17
  }
18
18
  export declare function filterAssets(assets: SDK.AssetData[], filterOrExtensions?: FilterFunctionOrExtensions): SDK.AssetData[];
19
19
  export declare function getAssetsSizeInfo(assets: SDK.AssetData[], chunks: SDK.ChunkData[], options?: GetAssetsOptions): {
20
- count: number;
21
- size: number;
22
- files: {
23
- path: string;
20
+ count: number;
24
21
  size: number;
25
- initial: boolean;
26
- content: string | undefined;
27
- }[];
22
+ files: {
23
+ path: string;
24
+ size: number;
25
+ initial: boolean;
26
+ content: string | undefined;
27
+ }[];
28
28
  };
29
29
  export declare function isInitialAsset(asset: SDK.AssetData, chunks: SDK.ChunkData[]): boolean;
30
30
  export declare function getInitialAssetsSizeInfo(assets: SDK.AssetData[], chunks: SDK.ChunkData[], options?: GetAssetsOptions): {
31
- count: number;
32
- size: number;
33
- files: {
34
- path: string;
31
+ count: number;
35
32
  size: number;
36
- initial: boolean;
37
- content: string | undefined;
38
- }[];
33
+ files: {
34
+ path: string;
35
+ size: number;
36
+ initial: boolean;
37
+ content: string | undefined;
38
+ }[];
39
39
  };
40
40
  export declare function getAssetsDiffResult(baseline: SDK.ChunkGraphData, current: SDK.ChunkGraphData): Client.RsdoctorClientAssetsDiffResult;
41
41
  /**
@@ -43,10 +43,10 @@ export declare function getAssetsDiffResult(baseline: SDK.ChunkGraphData, curren
43
43
  * @param cSize size of current
44
44
  */
45
45
  export declare function diffSize(bSize: number, cSize: number): {
46
- percent: number;
47
- state: Client.RsdoctorClientDiffState;
46
+ percent: number;
47
+ state: Client.RsdoctorClientDiffState;
48
48
  };
49
49
  export declare function diffAssetsByExtensions(baseline: SDK.ChunkGraphData, current: SDK.ChunkGraphData, filterOrExtensions?: FilterFunctionOrExtensions, isInitial?: boolean): Client.RsdoctorClientAssetsDiffItem;
50
50
  export declare function getAssetsSummary(assets: SDK.AssetData[], chunks: SDK.ChunkData[], options?: Omit<GetAssetsOptions, 'filterOrExtensions'>): Client.RsdoctorClientAssetsSummary;
51
51
  export declare function getAssetDetails(assetPath: string, assets: SDK.AssetData[], chunks: SDK.ChunkData[], modules: SDK.ModuleData[]): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetAssetDetails>;
52
- export {};
52
+ export {};
@@ -4,4 +4,4 @@ export declare function getChunksByModule(module: SDK.ModuleData, chunks: SDK.Ch
4
4
  export declare function getChunkByChunkId(chunkId: string, chunks: SDK.ChunkData[]): SDK.ChunkData;
5
5
  export declare function getChunksByChunkIds(chunkIds: string[], chunks: SDK.ChunkData[]): SDK.ChunkData[];
6
6
  export declare function getChunksByAsset(asset: SDK.AssetData, chunks: SDK.ChunkData[]): SDK.ChunkData[];
7
- export declare function getChunksByModuleId(id: number, modules: SDK.ModuleData[], chunks: SDK.ChunkData[]): SDK.ChunkData[];
7
+ export declare function getChunksByModuleId(id: number, modules: SDK.ModuleData[], chunks: SDK.ChunkData[]): SDK.ChunkData[];
@@ -1,4 +1,4 @@
1
1
  import { Rule, SDK } from '@rsdoctor/types';
2
2
  export declare function getDependencyByPackageData(dep: Rule.DependencyWithPackageData, dependencies: SDK.DependencyData[]): SDK.DependencyData | undefined;
3
3
  export declare function getDependenciesByModule(module: SDK.ModuleData, dependencies: SDK.DependencyData[]): SDK.DependencyData[];
4
- export declare function getDependencyByResolvedRequest(resolvedRequest: string, dependencies: SDK.DependencyData[]): SDK.DependencyData | undefined;
4
+ export declare function getDependencyByResolvedRequest(resolvedRequest: string, dependencies: SDK.DependencyData[]): SDK.DependencyData | undefined;
@@ -1,2 +1,2 @@
1
1
  import { SDK } from '@rsdoctor/types';
2
- export declare function getEntryPoints(entrypoints: SDK.EntryPointData[]): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetEntryPoints>;
2
+ export declare function getEntryPoints(entrypoints: SDK.EntryPointData[]): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetEntryPoints>;
@@ -2,4 +2,4 @@ export * from './assets';
2
2
  export * from './chunk';
3
3
  export * from './modules';
4
4
  export * from './dependency';
5
- export * from './entrypoints';
5
+ export * from './entrypoints';
@@ -6,4 +6,4 @@ export declare function getModulesByChunk(chunk: SDK.ChunkData, modules: SDK.Mod
6
6
  export declare function getModulesByChunks(chunks: SDK.ChunkData[], modules: SDK.ModuleData[]): SDK.ModuleData[];
7
7
  export declare function getModuleByDependency(dep: SDK.DependencyData, modules: SDK.ModuleData[]): SDK.ModuleData | undefined;
8
8
  export declare function filterModulesAndDependenciesByPackageDeps(deps: Rule.DependencyWithPackageData[], dependencies: SDK.DependencyData[], modules: SDK.ModuleData[]): Pick<SDK.ModuleGraphData, 'dependencies' | 'modules'>;
9
- export declare function getModuleDetails(moduleId: number, modules: SDK.ModuleData[], dependencies: SDK.DependencyData[]): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetModuleDetails>;
9
+ export declare function getModuleDetails(moduleId: number, modules: SDK.ModuleData[], dependencies: SDK.DependencyData[]): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetModuleDetails>;
@@ -12,4 +12,4 @@ export * as Plugin from './plugin';
12
12
  export * as Data from './data';
13
13
  export * as Alerts from './alerts';
14
14
  export * as Rspack from './rspack';
15
- export * as Package from './package';
15
+ export * as Package from './package';
@@ -1,7 +1,7 @@
1
1
  import { SDK } from '@rsdoctor/types';
2
2
  export declare function findLoaderTotalTiming(loaders: Pick<SDK.LoaderTransformData, 'startAt' | 'endAt'>[]): {
3
- start: number;
4
- end: number;
3
+ start: number;
4
+ end: number;
5
5
  };
6
6
  export declare function getLoadersCosts(filter: (loader: Pick<SDK.LoaderTransformData, 'loader' | 'startAt' | 'endAt' | 'pid'>) => boolean, loaders: Pick<SDK.LoaderTransformData, 'loader' | 'startAt' | 'endAt' | 'pid'>[]): number;
7
7
  export declare function getLoaderCosts(loader: SDK.LoaderTransformData, loaders: SDK.LoaderTransformData[]): number;
@@ -13,4 +13,4 @@ export declare function getLoaderFileDetails(path: string, loaders: SDK.LoaderDa
13
13
  export declare function getLoaderFolderStatistics(folder: string, loaders: SDK.LoaderData): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFolderStatistics>;
14
14
  export declare function getLoaderFileFirstInput(file: string, loaders: SDK.LoaderData): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFileFirstInput>;
15
15
  export declare function getLoaderFileInputAndOutput(file: string, loader: string, loaderIndex: number, loaders: SDK.LoaderData): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFileInputAndOutput>;
16
- export declare const LoaderInternalPropertyName = "__l__";
16
+ export declare const LoaderInternalPropertyName = "__l__";
@@ -1,4 +1,4 @@
1
1
  import { Manifest } from '@rsdoctor/types';
2
2
  export declare function isShardingData(data: unknown): data is string[];
3
3
  export declare function fetchShardingData(shardingFiles: string[], fetchImplement: (url: string) => Promise<string>): Promise<any>;
4
- export declare function fetchShardingFiles(data: Manifest.RsdoctorManifestWithShardingFiles['data'], fetchImplement: (url: string) => Promise<string>, filterKeys?: Array<keyof Manifest.RsdoctorManifestData>): Promise<Manifest.RsdoctorManifestData>;
4
+ export declare function fetchShardingFiles(data: Manifest.RsdoctorManifestWithShardingFiles['data'], fetchImplement: (url: string) => Promise<string>, filterKeys?: Array<keyof Manifest.RsdoctorManifestData>): Promise<Manifest.RsdoctorManifestData>;
@@ -4,4 +4,4 @@ export declare const PACKAGE_PATH_NAME: RegExp;
4
4
  /**
5
5
  * Heuristics to extract package id, name, and path from a module path
6
6
  */
7
- export declare const getPackageMetaFromModulePath: (modulePath: string) => SDK.PackageJSONData;
7
+ export declare const getPackageMetaFromModulePath: (modulePath: string) => SDK.PackageJSONData;
@@ -2,4 +2,4 @@ import { SDK } from '@rsdoctor/types';
2
2
  export declare function getPluginHooks(plugin: SDK.PluginData): string[];
3
3
  export declare function getPluginTapNames(plugin: SDK.PluginData): string[];
4
4
  export declare function getPluginSummary(plugin: SDK.PluginData): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPluginSummary>;
5
- export declare function getPluginData(plugin: SDK.PluginData, selectedHooks?: string[], selectedTapNames?: string[]): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPluginData>;
5
+ export declare function getPluginData(plugin: SDK.PluginData, selectedHooks?: string[], selectedTapNames?: string[]): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPluginData>;
@@ -3,4 +3,4 @@ export declare function isResolveSuccessData(data: SDK.PathResolverData): data i
3
3
  export declare function isResolveFailData(data: SDK.PathResolverData): data is SDK.PathResolverSuccessData;
4
4
  export declare function getResolverCosts(resolver: SDK.PathResolverData, resolvers: SDK.ResolverData): number;
5
5
  export declare function getResolverFileTree(resolver: SDK.ResolverData): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetResolverFileTree>;
6
- export declare function getResolverFileDetails(filepath: string, resolvers: SDK.ResolverData, modules: SDK.ModuleData[], moduleCodeMap: SDK.ModuleCodeData): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetResolverFileDetails>;
6
+ export declare function getResolverFileDetails(filepath: string, resolvers: SDK.ResolverData, modules: SDK.ModuleData[], moduleCodeMap: SDK.ModuleCodeData): SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetResolverFileDetails>;
@@ -1,7 +1,7 @@
1
1
  export declare const RspackLoaderInternalPropertyName = "__l__";
2
2
  export declare enum RspackSummaryCostsDataName {
3
- Bootstrap = "bootstrap->rspack:beforeCompile",
4
- Compile = "rspack:beforeCompile->afterCompile",
5
- Done = "rspack:afterCompile->done",
6
- Minify = "rspack:minify(rspack:optimizeChunkAssets)",
7
- }
3
+ Bootstrap = "bootstrap->rspack:beforeCompile",
4
+ Compile = "rspack:beforeCompile->afterCompile",
5
+ Done = "rspack:afterCompile->done",
6
+ Minify = "rspack:minify(rspack:optimizeChunkAssets)"
7
+ }
@@ -1,6 +1,6 @@
1
1
  export declare enum SummaryCostsDataName {
2
- Bootstrap = "bootstrap->beforeCompile",
3
- Compile = "beforeCompile->afterCompile",
4
- Done = "afterCompile->done",
5
- Minify = "minify(webpack4:optimizeChunkAssets|webpack5:processAssets|rspack:processAssets)",
6
- }
2
+ Bootstrap = "bootstrap->beforeCompile",
3
+ Compile = "beforeCompile->afterCompile",
4
+ Done = "afterCompile->done",
5
+ Minify = "minify(webpack4:optimizeChunkAssets|webpack5:processAssets|rspack:processAssets)"
6
+ }
@@ -1,4 +1,4 @@
1
1
  export declare function toFixedDigits(num: number, digits?: number): number;
2
2
  export declare function getUnit(num: number, type: 'm' | 'h'): string;
3
3
  export declare function formatCosts(costs: number | string): string;
4
- export declare function getCurrentTimestamp(start: number, startHRTime: [number, number]): number;
4
+ export declare function getCurrentTimestamp(start: number, startHRTime: [number, number]): number;
@@ -1,3 +1,3 @@
1
1
  export declare function isUrl(uri: string): boolean;
2
2
  export declare function isFilePath(uri: string): boolean;
3
- export declare function isRemoteUrl(uri: unknown): boolean;
3
+ export declare function isRemoteUrl(uri: unknown): boolean;
@@ -1,35 +1,35 @@
1
1
  import { Err, Rule } from '@rsdoctor/types';
2
2
  export declare class DevToolError extends Error implements Err.DevToolErrorInstance {
3
- static from(err: unknown, opt?: Err.DevToolErrorParams): DevToolError;
4
- readonly id: number;
5
- readonly code?: string;
6
- readonly category?: string;
7
- readonly title: string;
8
- readonly detail?: any;
9
- readonly fixData?: Err.FixData;
10
- readonly hint?: string;
11
- readonly referenceUrl?: string;
12
- private _codeFrame?;
13
- private _controller;
14
- private readonly _level;
15
- constructor(title: string, message: string, opts?: Err.DevToolErrorParams);
16
- get level(): "Ignore" | "Warn" | "Error";
17
- get path(): string | undefined;
18
- set path(file: string | undefined);
19
- get codeFrame(): Err.CodeFrameOption | undefined;
20
- private printCodeFrame;
21
- toString(): string;
22
- toData(): Rule.RuleStoreDataItem;
23
- toError(): Error;
24
- /**
25
- * for json stringify
26
- */
27
- toJSON(): {
28
- message: string;
29
- name: string;
30
- stack: string | undefined;
31
- };
32
- setControllerOption(opt: Err.ControllerOption): void;
33
- setCodeFrame(opt: Err.CodeFrameOption): void;
34
- isSame(error: Err.DevToolErrorInstance): boolean;
35
- }
3
+ static from(err: unknown, opt?: Err.DevToolErrorParams): DevToolError;
4
+ readonly id: number;
5
+ readonly code?: string;
6
+ readonly category?: string;
7
+ readonly title: string;
8
+ readonly detail?: any;
9
+ readonly fixData?: Err.FixData;
10
+ readonly hint?: string;
11
+ readonly referenceUrl?: string;
12
+ private _codeFrame?;
13
+ private _controller;
14
+ private readonly _level;
15
+ constructor(title: string, message: string, opts?: Err.DevToolErrorParams);
16
+ get level(): "Ignore" | "Warn" | "Error";
17
+ get path(): string | undefined;
18
+ set path(file: string | undefined);
19
+ get codeFrame(): Err.CodeFrameOption | undefined;
20
+ private printCodeFrame;
21
+ toString(): string;
22
+ toData(): Rule.RuleStoreDataItem;
23
+ toError(): Error;
24
+ /**
25
+ * for json stringify
26
+ */
27
+ toJSON(): {
28
+ message: string;
29
+ name: string;
30
+ stack: string | undefined;
31
+ };
32
+ setControllerOption(opt: Err.ControllerOption): void;
33
+ setCodeFrame(opt: Err.CodeFrameOption): void;
34
+ isSame(error: Err.DevToolErrorInstance): boolean;
35
+ }
@@ -1,2 +1,2 @@
1
1
  export * from './error';
2
- export { printErrors } from './utils';
2
+ export { printErrors } from './utils';
@@ -1,3 +1,3 @@
1
1
  import { Err } from '@rsdoctor/types';
2
2
  import { DevToolError } from './error';
3
- export declare function transform(err: any, opt?: Err.DevToolErrorParams): DevToolError;
3
+ export declare function transform(err: any, opt?: Err.DevToolErrorParams): DevToolError;
@@ -1,7 +1,4 @@
1
1
  import { Err, Logger } from '@rsdoctor/types';
2
2
  export declare function toLevel(level: keyof typeof Err.ErrorLevel): Err.ErrorLevel;
3
3
  export declare function insertSpace(rawLines: string, line: number, width: number): string;
4
- export declare function printErrors({
5
- errors,
6
- warnings
7
- }: Err.DevToolErrorsData, logLevel?: Logger.LogLevelName): string;
4
+ export declare function printErrors({ errors, warnings }: Err.DevToolErrorsData, logLevel?: Logger.LogLevelName): string;
@@ -1,2 +1,2 @@
1
1
  export * as RuleUtils from './rule-utils';
2
- export * as Logger from './logger';
2
+ export * as Logger from './logger';
@@ -4,4 +4,4 @@ import { logger } from 'rslog';
4
4
  * log debug message
5
5
  */
6
6
  export declare function debug(getMsg: () => string, prefix?: string): void;
7
- export { chalk, logger };
7
+ export { chalk, logger };
@@ -1,16 +1,16 @@
1
1
  import { Range, OffsetRange, Position, DocumentEditData } from './types';
2
2
  /** Document Catalogue */
3
3
  export declare class Document {
4
- /** Actual document content. */
5
- private _text;
6
- /** Get the displacement of the file position in the text. */
7
- positionAt: (offset: number) => Position | undefined;
8
- /** Get the position of the displacement point in the file. */
9
- offsetAt: (position: Position) => number | undefined;
10
- constructor(content: string);
11
- /** Generate location search */
12
- private createFinder;
13
- getText(range?: Range | OffsetRange): string;
14
- /** Edit document data */
15
- edit(data: DocumentEditData): string | undefined;
16
- }
4
+ /** Actual document content. */
5
+ private _text;
6
+ /** Get the displacement of the file position in the text. */
7
+ positionAt: (offset: number) => Position | undefined;
8
+ /** Get the position of the displacement point in the file. */
9
+ offsetAt: (position: Position) => number | undefined;
10
+ constructor(content: string);
11
+ /** Generate location search */
12
+ private createFinder;
13
+ getText(range?: Range | OffsetRange): string;
14
+ /** Edit document data */
15
+ edit(data: DocumentEditData): string | undefined;
16
+ }
@@ -1,3 +1,3 @@
1
1
  export * from './document';
2
2
  export * from './types';
3
- export * from './server';
3
+ export * from './server';
@@ -1,4 +1,4 @@
1
1
  import { Document } from './document';
2
2
  /** Create Document */
3
3
  export declare function getDocument(content: string): Document;
4
- export declare function clearDocument(): void;
4
+ export declare function clearDocument(): void;
@@ -4,28 +4,28 @@
4
4
  * - column starting point is 0
5
5
  */
6
6
  export interface Position {
7
- line: number;
8
- column: number;
7
+ line: number;
8
+ column: number;
9
9
  }
10
10
  /** Location range */
11
11
  export interface Range {
12
- start: Position;
13
- end: Position;
12
+ start: Position;
13
+ end: Position;
14
14
  }
15
15
  /** Offset range */
16
16
  export interface OffsetRange {
17
- start: number;
18
- end: number;
17
+ start: number;
18
+ end: number;
19
19
  }
20
20
  /** Text repair data */
21
21
  export interface DocumentEditData {
22
- /** Modify the starting position of string in the original text */
23
- start: number | Position;
24
- /** Modify string in the key position of the original text */
25
- end: number | Position;
26
- /**
27
- * Replaced new text
28
- * - If empty, delete the original text
29
- */
30
- newText?: string;
31
- }
22
+ /** Modify the starting position of string in the original text */
23
+ start: number | Position;
24
+ /** Modify string in the key position of the original text */
25
+ end: number | Position;
26
+ /**
27
+ * Replaced new text
28
+ * - If empty, delete the original text
29
+ */
30
+ newText?: string;
31
+ }
@@ -1,2 +1,2 @@
1
1
  export * from './document';
2
- export * from './parser';
2
+ export * from './parser';
@@ -1,81 +1,81 @@
1
1
  import { Node } from './types';
2
2
  export declare const asserts: {
3
- readonly isProgram: (node: unknown) => node is Node.Program;
4
- readonly isEmptyStatement: (node: unknown) => node is Node.EmptyStatement;
5
- readonly isBlockStatement: (node: unknown) => node is Node.BlockStatement;
6
- readonly isStaticBlock: (node: unknown) => node is Node.StaticBlock;
7
- readonly isExpressionStatement: (node: unknown) => node is Node.ExpressionStatement;
8
- readonly isIfStatement: (node: unknown) => node is Node.IfStatement;
9
- readonly isLabeledStatement: (node: unknown) => node is Node.LabeledStatement;
10
- readonly isBreakStatement: (node: unknown) => node is Node.BreakStatement;
11
- readonly isContinueStatement: (node: unknown) => node is Node.ContinueStatement;
12
- readonly isWithStatement: (node: unknown) => node is Node.WithStatement;
13
- readonly isSwitchStatement: (node: unknown) => node is Node.SwitchStatement;
14
- readonly isReturnStatement: (node: unknown) => node is Node.ReturnStatement;
15
- readonly isThrowStatement: (node: unknown) => node is Node.ThrowStatement;
16
- readonly isTryStatement: (node: unknown) => node is Node.TryStatement;
17
- readonly isWhileStatement: (node: unknown) => node is Node.WhileStatement;
18
- readonly isDoWhileStatement: (node: unknown) => node is Node.DoWhileStatement;
19
- readonly isForStatement: (node: unknown) => node is Node.ForStatement;
20
- readonly isForInStatement: (node: unknown) => node is Node.ForInStatement;
21
- readonly isForOfStatement: (node: unknown) => node is Node.ForOfStatement;
22
- readonly isDebuggerStatement: (node: unknown) => node is Node.DebuggerStatement;
23
- readonly isFunctionDeclaration: (node: unknown) => node is Node.FunctionDeclaration;
24
- readonly isVariableDeclaration: (node: unknown) => node is Node.VariableDeclaration;
25
- readonly isVariableDeclarator: (node: unknown) => node is Node.VariableDeclarator;
26
- readonly isChainExpression: (node: unknown) => node is Node.ChainExpression;
27
- readonly isThisExpression: (node: unknown) => node is Node.ThisExpression;
28
- readonly isArrayExpression: (node: unknown) => node is Node.ArrayExpression;
29
- readonly isObjectExpression: (node: unknown) => node is Node.ObjectExpression;
30
- readonly isPrivateIdentifier: (node: unknown) => node is Node.PrivateIdentifier;
31
- readonly isProperty: (node: unknown) => node is Node.Property;
32
- readonly isPropertyDefinition: (node: unknown) => node is Node.PropertyDefinition;
33
- readonly isFunctionExpression: (node: unknown) => node is Node.FunctionExpression;
34
- readonly isSequenceExpression: (node: unknown) => node is Node.SequenceExpression;
35
- readonly isUnaryExpression: (node: unknown) => node is Node.UnaryExpression;
36
- readonly isBinaryExpression: (node: unknown) => node is Node.BinaryExpression;
37
- readonly isAssignmentExpression: (node: unknown) => node is Node.AssignmentExpression;
38
- readonly isUpdateExpression: (node: unknown) => node is Node.UpdateExpression;
39
- readonly isLogicalExpression: (node: unknown) => node is Node.LogicalExpression;
40
- readonly isConditionalExpression: (node: unknown) => node is Node.ConditionalExpression;
41
- readonly isNewExpression: (node: unknown) => node is Node.NewExpression;
42
- readonly isSwitchCase: (node: unknown) => node is Node.SwitchCase;
43
- readonly isCatchClause: (node: unknown) => node is Node.CatchClause;
44
- readonly isIdentifier: (node: unknown) => node is Node.Identifier;
45
- readonly isLiteral: (node: unknown) => node is Node.Literal;
46
- readonly isSuper: (node: unknown) => node is Node.Super;
47
- readonly isSpreadElement: (node: unknown) => node is Node.SpreadElement;
48
- readonly isArrowFunctionExpression: (node: unknown) => node is Node.ArrowFunctionExpression;
49
- readonly isYieldExpression: (node: unknown) => node is Node.YieldExpression;
50
- readonly isTemplateLiteral: (node: unknown) => node is Node.TemplateLiteral;
51
- readonly isTaggedTemplateExpression: (node: unknown) => node is Node.TaggedTemplateExpression;
52
- readonly isTemplateElement: (node: unknown) => node is Node.TemplateElement;
53
- readonly isObjectPattern: (node: unknown) => node is Node.ObjectPattern;
54
- readonly isArrayPattern: (node: unknown) => node is Node.ArrayPattern;
55
- readonly isRestElement: (node: unknown) => node is Node.RestElement;
56
- readonly isAssignmentPattern: (node: unknown) => node is Node.AssignmentPattern;
57
- readonly isClassBody: (node: unknown) => node is Node.ClassBody;
58
- readonly isClassDeclaration: (node: unknown) => node is Node.ClassDeclaration;
59
- readonly isClassExpression: (node: unknown) => node is Node.ClassExpression;
60
- readonly isMetaProperty: (node: unknown) => node is Node.MetaProperty;
61
- readonly isImportDeclaration: (node: unknown) => node is Node.ImportDeclaration;
62
- readonly isImportSpecifier: (node: unknown) => node is Node.ImportSpecifier;
63
- readonly isImportExpression: (node: unknown) => node is Node.ImportExpression;
64
- readonly isImportDefaultSpecifier: (node: unknown) => node is Node.ImportDefaultSpecifier;
65
- readonly isImportNamespaceSpecifier: (node: unknown) => node is Node.ImportNamespaceSpecifier;
66
- readonly isExportNamedDeclaration: (node: unknown) => node is Node.ExportNamedDeclaration;
67
- readonly isExportSpecifier: (node: unknown) => node is Node.ExportSpecifier;
68
- readonly isExportDefaultDeclaration: (node: unknown) => node is Node.ExportDefaultDeclaration;
69
- readonly isExportAllDeclaration: (node: unknown) => node is Node.ExportAllDeclaration;
70
- readonly isAwaitExpression: (node: unknown) => node is Node.AwaitExpression;
71
- readonly isMethodDefinition: (node: unknown) => node is Node.MethodDefinition;
72
- readonly isMemberExpression: (node: unknown) => node is Node.MemberExpression;
73
- readonly isComment: (node: unknown) => node is Node.Comment;
74
- readonly isDirective: (node: unknown) => node is Node.Directive;
75
- readonly isSimpleCallExpression: (node: unknown) => node is Node.SimpleCallExpression;
76
- readonly isAssignmentProperty: (node: unknown) => node is Node.AssignmentProperty;
77
- readonly isSimpleLiteral: (node: unknown) => node is Node.SimpleLiteral;
78
- readonly isRegExpLiteral: (node: unknown) => node is Node.RegExpLiteral;
79
- readonly isBigIntLiteral: (node: unknown) => node is Node.BigIntLiteral;
80
- readonly isExportStatement: (node: unknown) => node is Node.ExportStatement;
81
- };
3
+ readonly isProgram: (node: unknown) => node is Node.Program;
4
+ readonly isEmptyStatement: (node: unknown) => node is Node.EmptyStatement;
5
+ readonly isBlockStatement: (node: unknown) => node is Node.BlockStatement;
6
+ readonly isStaticBlock: (node: unknown) => node is Node.StaticBlock;
7
+ readonly isExpressionStatement: (node: unknown) => node is Node.ExpressionStatement;
8
+ readonly isIfStatement: (node: unknown) => node is Node.IfStatement;
9
+ readonly isLabeledStatement: (node: unknown) => node is Node.LabeledStatement;
10
+ readonly isBreakStatement: (node: unknown) => node is Node.BreakStatement;
11
+ readonly isContinueStatement: (node: unknown) => node is Node.ContinueStatement;
12
+ readonly isWithStatement: (node: unknown) => node is Node.WithStatement;
13
+ readonly isSwitchStatement: (node: unknown) => node is Node.SwitchStatement;
14
+ readonly isReturnStatement: (node: unknown) => node is Node.ReturnStatement;
15
+ readonly isThrowStatement: (node: unknown) => node is Node.ThrowStatement;
16
+ readonly isTryStatement: (node: unknown) => node is Node.TryStatement;
17
+ readonly isWhileStatement: (node: unknown) => node is Node.WhileStatement;
18
+ readonly isDoWhileStatement: (node: unknown) => node is Node.DoWhileStatement;
19
+ readonly isForStatement: (node: unknown) => node is Node.ForStatement;
20
+ readonly isForInStatement: (node: unknown) => node is Node.ForInStatement;
21
+ readonly isForOfStatement: (node: unknown) => node is Node.ForOfStatement;
22
+ readonly isDebuggerStatement: (node: unknown) => node is Node.DebuggerStatement;
23
+ readonly isFunctionDeclaration: (node: unknown) => node is Node.FunctionDeclaration;
24
+ readonly isVariableDeclaration: (node: unknown) => node is Node.VariableDeclaration;
25
+ readonly isVariableDeclarator: (node: unknown) => node is Node.VariableDeclarator;
26
+ readonly isChainExpression: (node: unknown) => node is Node.ChainExpression;
27
+ readonly isThisExpression: (node: unknown) => node is Node.ThisExpression;
28
+ readonly isArrayExpression: (node: unknown) => node is Node.ArrayExpression;
29
+ readonly isObjectExpression: (node: unknown) => node is Node.ObjectExpression;
30
+ readonly isPrivateIdentifier: (node: unknown) => node is Node.PrivateIdentifier;
31
+ readonly isProperty: (node: unknown) => node is Node.Property;
32
+ readonly isPropertyDefinition: (node: unknown) => node is Node.PropertyDefinition;
33
+ readonly isFunctionExpression: (node: unknown) => node is Node.FunctionExpression;
34
+ readonly isSequenceExpression: (node: unknown) => node is Node.SequenceExpression;
35
+ readonly isUnaryExpression: (node: unknown) => node is Node.UnaryExpression;
36
+ readonly isBinaryExpression: (node: unknown) => node is Node.BinaryExpression;
37
+ readonly isAssignmentExpression: (node: unknown) => node is Node.AssignmentExpression;
38
+ readonly isUpdateExpression: (node: unknown) => node is Node.UpdateExpression;
39
+ readonly isLogicalExpression: (node: unknown) => node is Node.LogicalExpression;
40
+ readonly isConditionalExpression: (node: unknown) => node is Node.ConditionalExpression;
41
+ readonly isNewExpression: (node: unknown) => node is Node.NewExpression;
42
+ readonly isSwitchCase: (node: unknown) => node is Node.SwitchCase;
43
+ readonly isCatchClause: (node: unknown) => node is Node.CatchClause;
44
+ readonly isIdentifier: (node: unknown) => node is Node.Identifier;
45
+ readonly isLiteral: (node: unknown) => node is Node.Literal;
46
+ readonly isSuper: (node: unknown) => node is Node.Super;
47
+ readonly isSpreadElement: (node: unknown) => node is Node.SpreadElement;
48
+ readonly isArrowFunctionExpression: (node: unknown) => node is Node.ArrowFunctionExpression;
49
+ readonly isYieldExpression: (node: unknown) => node is Node.YieldExpression;
50
+ readonly isTemplateLiteral: (node: unknown) => node is Node.TemplateLiteral;
51
+ readonly isTaggedTemplateExpression: (node: unknown) => node is Node.TaggedTemplateExpression;
52
+ readonly isTemplateElement: (node: unknown) => node is Node.TemplateElement;
53
+ readonly isObjectPattern: (node: unknown) => node is Node.ObjectPattern;
54
+ readonly isArrayPattern: (node: unknown) => node is Node.ArrayPattern;
55
+ readonly isRestElement: (node: unknown) => node is Node.RestElement;
56
+ readonly isAssignmentPattern: (node: unknown) => node is Node.AssignmentPattern;
57
+ readonly isClassBody: (node: unknown) => node is Node.ClassBody;
58
+ readonly isClassDeclaration: (node: unknown) => node is Node.ClassDeclaration;
59
+ readonly isClassExpression: (node: unknown) => node is Node.ClassExpression;
60
+ readonly isMetaProperty: (node: unknown) => node is Node.MetaProperty;
61
+ readonly isImportDeclaration: (node: unknown) => node is Node.ImportDeclaration;
62
+ readonly isImportSpecifier: (node: unknown) => node is Node.ImportSpecifier;
63
+ readonly isImportExpression: (node: unknown) => node is Node.ImportExpression;
64
+ readonly isImportDefaultSpecifier: (node: unknown) => node is Node.ImportDefaultSpecifier;
65
+ readonly isImportNamespaceSpecifier: (node: unknown) => node is Node.ImportNamespaceSpecifier;
66
+ readonly isExportNamedDeclaration: (node: unknown) => node is Node.ExportNamedDeclaration;
67
+ readonly isExportSpecifier: (node: unknown) => node is Node.ExportSpecifier;
68
+ readonly isExportDefaultDeclaration: (node: unknown) => node is Node.ExportDefaultDeclaration;
69
+ readonly isExportAllDeclaration: (node: unknown) => node is Node.ExportAllDeclaration;
70
+ readonly isAwaitExpression: (node: unknown) => node is Node.AwaitExpression;
71
+ readonly isMethodDefinition: (node: unknown) => node is Node.MethodDefinition;
72
+ readonly isMemberExpression: (node: unknown) => node is Node.MemberExpression;
73
+ readonly isComment: (node: unknown) => node is Node.Comment;
74
+ readonly isDirective: (node: unknown) => node is Node.Directive;
75
+ readonly isSimpleCallExpression: (node: unknown) => node is Node.SimpleCallExpression;
76
+ readonly isAssignmentProperty: (node: unknown) => node is Node.AssignmentProperty;
77
+ readonly isSimpleLiteral: (node: unknown) => node is Node.SimpleLiteral;
78
+ readonly isRegExpLiteral: (node: unknown) => node is Node.RegExpLiteral;
79
+ readonly isBigIntLiteral: (node: unknown) => node is Node.BigIntLiteral;
80
+ readonly isExportStatement: (node: unknown) => node is Node.ExportStatement;
81
+ };
@@ -1,4 +1,4 @@
1
1
  export * from './asserts';
2
2
  export * from './parser';
3
3
  export * from './utils';
4
- export * from './types';
4
+ export * from './types';
@@ -4,115 +4,115 @@ import * as utils from './utils';
4
4
  import type { Node } from './types';
5
5
  export type { Options as ParseOptions } from 'acorn';
6
6
  export interface ParseError extends Error {
7
- loc?: Position;
8
- pos: number;
9
- raisedAt: number;
7
+ loc?: Position;
8
+ pos: number;
9
+ raisedAt: number;
10
10
  }
11
11
  export declare const parser: {
12
- /** AST iterator */
13
- walk: typeof walk;
14
- /**
15
- * Compile code
16
- * - Output root node is `Node.Program`
17
- */
18
- parse: (input: string, options: Options) => Node.Program;
19
- /**
20
- * Compile the next first expression
21
- * - The output root node is `Node.ExpressionStatement`
22
- */
23
- parseExpressionAt: (input: string, pos: number, options: Options) => Node.ExpressionStatement;
24
- /**
25
- * add plugins for acorn
26
- */
27
- extend(...args: Parameters<typeof AcornParser.extend>): typeof AcornParser;
28
- /** Set of assertions */
29
- asserts: {
30
- readonly isProgram: (node: unknown) => node is Node.Program;
31
- readonly isEmptyStatement: (node: unknown) => node is Node.EmptyStatement;
32
- readonly isBlockStatement: (node: unknown) => node is Node.BlockStatement;
33
- readonly isStaticBlock: (node: unknown) => node is Node.StaticBlock;
34
- readonly isExpressionStatement: (node: unknown) => node is Node.ExpressionStatement;
35
- readonly isIfStatement: (node: unknown) => node is Node.IfStatement;
36
- readonly isLabeledStatement: (node: unknown) => node is Node.LabeledStatement;
37
- readonly isBreakStatement: (node: unknown) => node is Node.BreakStatement;
38
- readonly isContinueStatement: (node: unknown) => node is Node.ContinueStatement;
39
- readonly isWithStatement: (node: unknown) => node is Node.WithStatement;
40
- readonly isSwitchStatement: (node: unknown) => node is Node.SwitchStatement;
41
- readonly isReturnStatement: (node: unknown) => node is Node.ReturnStatement;
42
- readonly isThrowStatement: (node: unknown) => node is Node.ThrowStatement;
43
- readonly isTryStatement: (node: unknown) => node is Node.TryStatement; /** Set of assertions */
44
- readonly isWhileStatement: (node: unknown) => node is Node.WhileStatement;
45
- readonly isDoWhileStatement: (node: unknown) => node is Node.DoWhileStatement;
46
- readonly isForStatement: (node: unknown) => node is Node.ForStatement;
47
- readonly isForInStatement: (node: unknown) => node is Node.ForInStatement;
48
- readonly isForOfStatement: (node: unknown) => node is Node.ForOfStatement;
49
- readonly isDebuggerStatement: (node: unknown) => node is Node.DebuggerStatement;
50
- readonly isFunctionDeclaration: (node: unknown) => node is Node.FunctionDeclaration;
51
- readonly isVariableDeclaration: (node: unknown) => node is Node.VariableDeclaration;
52
- readonly isVariableDeclarator: (node: unknown) => node is Node.VariableDeclarator;
53
- readonly isChainExpression: (node: unknown) => node is Node.ChainExpression;
54
- readonly isThisExpression: (node: unknown) => node is Node.ThisExpression;
55
- readonly isArrayExpression: (node: unknown) => node is Node.ArrayExpression;
56
- readonly isObjectExpression: (node: unknown) => node is Node.ObjectExpression;
57
- readonly isPrivateIdentifier: (node: unknown) => node is Node.PrivateIdentifier;
58
- readonly isProperty: (node: unknown) => node is Node.Property;
59
- readonly isPropertyDefinition: (node: unknown) => node is Node.PropertyDefinition;
60
- readonly isFunctionExpression: (node: unknown) => node is Node.FunctionExpression;
61
- readonly isSequenceExpression: (node: unknown) => node is Node.SequenceExpression;
62
- readonly isUnaryExpression: (node: unknown) => node is Node.UnaryExpression;
63
- readonly isBinaryExpression: (node: unknown) => node is Node.BinaryExpression;
64
- readonly isAssignmentExpression: (node: unknown) => node is Node.AssignmentExpression;
65
- readonly isUpdateExpression: (node: unknown) => node is Node.UpdateExpression;
66
- readonly isLogicalExpression: (node: unknown) => node is Node.LogicalExpression;
67
- readonly isConditionalExpression: (node: unknown) => node is Node.ConditionalExpression;
68
- readonly isNewExpression: (node: unknown) => node is Node.NewExpression;
69
- readonly isSwitchCase: (node: unknown) => node is Node.SwitchCase;
70
- readonly isCatchClause: (node: unknown) => node is Node.CatchClause;
71
- readonly isIdentifier: (node: unknown) => node is Node.Identifier;
72
- readonly isLiteral: (node: unknown) => node is Node.Literal;
73
- readonly isSuper: (node: unknown) => node is Node.Super;
74
- readonly isSpreadElement: (node: unknown) => node is Node.SpreadElement;
75
- readonly isArrowFunctionExpression: (node: unknown) => node is Node.ArrowFunctionExpression;
76
- readonly isYieldExpression: (node: unknown) => node is Node.YieldExpression;
77
- readonly isTemplateLiteral: (node: unknown) => node is Node.TemplateLiteral;
78
- readonly isTaggedTemplateExpression: (node: unknown) => node is Node.TaggedTemplateExpression;
79
- readonly isTemplateElement: (node: unknown) => node is Node.TemplateElement;
80
- readonly isObjectPattern: (node: unknown) => node is Node.ObjectPattern;
81
- readonly isArrayPattern: (node: unknown) => node is Node.ArrayPattern;
82
- readonly isRestElement: (node: unknown) => node is Node.RestElement;
83
- readonly isAssignmentPattern: (node: unknown) => node is Node.AssignmentPattern;
84
- readonly isClassBody: (node: unknown) => node is Node.ClassBody;
85
- readonly isClassDeclaration: (node: unknown) => node is Node.ClassDeclaration;
86
- readonly isClassExpression: (node: unknown) => node is Node.ClassExpression;
87
- readonly isMetaProperty: (node: unknown) => node is Node.MetaProperty;
88
- readonly isImportDeclaration: (node: unknown) => node is Node.ImportDeclaration;
89
- readonly isImportSpecifier: (node: unknown) => node is Node.ImportSpecifier;
90
- readonly isImportExpression: (node: unknown) => node is Node.ImportExpression;
91
- readonly isImportDefaultSpecifier: (node: unknown) => node is Node.ImportDefaultSpecifier;
92
- readonly isImportNamespaceSpecifier: (node: unknown) => node is Node.ImportNamespaceSpecifier;
93
- readonly isExportNamedDeclaration: (node: unknown) => node is Node.ExportNamedDeclaration;
94
- readonly isExportSpecifier: (node: unknown) => node is Node.ExportSpecifier;
95
- readonly isExportDefaultDeclaration: (node: unknown) => node is Node.ExportDefaultDeclaration;
96
- readonly isExportAllDeclaration: (node: unknown) => node is Node.ExportAllDeclaration;
97
- readonly isAwaitExpression: (node: unknown) => node is Node.AwaitExpression;
98
- readonly isMethodDefinition: (node: unknown) => node is Node.MethodDefinition;
99
- readonly isMemberExpression: (node: unknown) => node is Node.MemberExpression;
100
- readonly isComment: (node: unknown) => node is Node.Comment;
101
- readonly isDirective: (node: unknown) => node is Node.Directive;
102
- readonly isSimpleCallExpression: (node: unknown) => node is Node.SimpleCallExpression;
103
- readonly isAssignmentProperty: (node: unknown) => node is Node.AssignmentProperty;
104
- readonly isSimpleLiteral: (node: unknown) => node is Node.SimpleLiteral;
105
- readonly isRegExpLiteral: (node: unknown) => node is Node.RegExpLiteral;
106
- readonly isBigIntLiteral: (node: unknown) => node is Node.BigIntLiteral;
107
- readonly isExportStatement: (node: unknown) => node is Node.ExportStatement;
108
- };
109
- utils: typeof utils;
110
- /**
111
- * @internal
112
- * parser for internal packages
113
- */
114
- internal: {
12
+ /** AST iterator */
13
+ walk: typeof walk;
14
+ /**
15
+ * Compile code
16
+ * - Output root node is `Node.Program`
17
+ */
115
18
  parse: (input: string, options: Options) => Node.Program;
19
+ /**
20
+ * Compile the next first expression
21
+ * - The output root node is `Node.ExpressionStatement`
22
+ */
116
23
  parseExpressionAt: (input: string, pos: number, options: Options) => Node.ExpressionStatement;
117
- };
118
- };
24
+ /**
25
+ * add plugins for acorn
26
+ */
27
+ extend(...args: Parameters<typeof AcornParser.extend>): typeof AcornParser;
28
+ /** Set of assertions */
29
+ asserts: {
30
+ readonly isProgram: (node: unknown) => node is Node.Program;
31
+ readonly isEmptyStatement: (node: unknown) => node is Node.EmptyStatement;
32
+ readonly isBlockStatement: (node: unknown) => node is Node.BlockStatement;
33
+ readonly isStaticBlock: (node: unknown) => node is Node.StaticBlock;
34
+ readonly isExpressionStatement: (node: unknown) => node is Node.ExpressionStatement;
35
+ readonly isIfStatement: (node: unknown) => node is Node.IfStatement;
36
+ readonly isLabeledStatement: (node: unknown) => node is Node.LabeledStatement;
37
+ readonly isBreakStatement: (node: unknown) => node is Node.BreakStatement;
38
+ readonly isContinueStatement: (node: unknown) => node is Node.ContinueStatement;
39
+ readonly isWithStatement: (node: unknown) => node is Node.WithStatement;
40
+ readonly isSwitchStatement: (node: unknown) => node is Node.SwitchStatement;
41
+ readonly isReturnStatement: (node: unknown) => node is Node.ReturnStatement;
42
+ readonly isThrowStatement: (node: unknown) => node is Node.ThrowStatement;
43
+ readonly isTryStatement: (node: unknown) => node is Node.TryStatement; /** Set of assertions */
44
+ readonly isWhileStatement: (node: unknown) => node is Node.WhileStatement;
45
+ readonly isDoWhileStatement: (node: unknown) => node is Node.DoWhileStatement;
46
+ readonly isForStatement: (node: unknown) => node is Node.ForStatement;
47
+ readonly isForInStatement: (node: unknown) => node is Node.ForInStatement;
48
+ readonly isForOfStatement: (node: unknown) => node is Node.ForOfStatement;
49
+ readonly isDebuggerStatement: (node: unknown) => node is Node.DebuggerStatement;
50
+ readonly isFunctionDeclaration: (node: unknown) => node is Node.FunctionDeclaration;
51
+ readonly isVariableDeclaration: (node: unknown) => node is Node.VariableDeclaration;
52
+ readonly isVariableDeclarator: (node: unknown) => node is Node.VariableDeclarator;
53
+ readonly isChainExpression: (node: unknown) => node is Node.ChainExpression;
54
+ readonly isThisExpression: (node: unknown) => node is Node.ThisExpression;
55
+ readonly isArrayExpression: (node: unknown) => node is Node.ArrayExpression;
56
+ readonly isObjectExpression: (node: unknown) => node is Node.ObjectExpression;
57
+ readonly isPrivateIdentifier: (node: unknown) => node is Node.PrivateIdentifier;
58
+ readonly isProperty: (node: unknown) => node is Node.Property;
59
+ readonly isPropertyDefinition: (node: unknown) => node is Node.PropertyDefinition;
60
+ readonly isFunctionExpression: (node: unknown) => node is Node.FunctionExpression;
61
+ readonly isSequenceExpression: (node: unknown) => node is Node.SequenceExpression;
62
+ readonly isUnaryExpression: (node: unknown) => node is Node.UnaryExpression;
63
+ readonly isBinaryExpression: (node: unknown) => node is Node.BinaryExpression;
64
+ readonly isAssignmentExpression: (node: unknown) => node is Node.AssignmentExpression;
65
+ readonly isUpdateExpression: (node: unknown) => node is Node.UpdateExpression;
66
+ readonly isLogicalExpression: (node: unknown) => node is Node.LogicalExpression;
67
+ readonly isConditionalExpression: (node: unknown) => node is Node.ConditionalExpression;
68
+ readonly isNewExpression: (node: unknown) => node is Node.NewExpression;
69
+ readonly isSwitchCase: (node: unknown) => node is Node.SwitchCase;
70
+ readonly isCatchClause: (node: unknown) => node is Node.CatchClause;
71
+ readonly isIdentifier: (node: unknown) => node is Node.Identifier;
72
+ readonly isLiteral: (node: unknown) => node is Node.Literal;
73
+ readonly isSuper: (node: unknown) => node is Node.Super;
74
+ readonly isSpreadElement: (node: unknown) => node is Node.SpreadElement;
75
+ readonly isArrowFunctionExpression: (node: unknown) => node is Node.ArrowFunctionExpression;
76
+ readonly isYieldExpression: (node: unknown) => node is Node.YieldExpression;
77
+ readonly isTemplateLiteral: (node: unknown) => node is Node.TemplateLiteral;
78
+ readonly isTaggedTemplateExpression: (node: unknown) => node is Node.TaggedTemplateExpression;
79
+ readonly isTemplateElement: (node: unknown) => node is Node.TemplateElement;
80
+ readonly isObjectPattern: (node: unknown) => node is Node.ObjectPattern;
81
+ readonly isArrayPattern: (node: unknown) => node is Node.ArrayPattern;
82
+ readonly isRestElement: (node: unknown) => node is Node.RestElement;
83
+ readonly isAssignmentPattern: (node: unknown) => node is Node.AssignmentPattern;
84
+ readonly isClassBody: (node: unknown) => node is Node.ClassBody;
85
+ readonly isClassDeclaration: (node: unknown) => node is Node.ClassDeclaration;
86
+ readonly isClassExpression: (node: unknown) => node is Node.ClassExpression;
87
+ readonly isMetaProperty: (node: unknown) => node is Node.MetaProperty;
88
+ readonly isImportDeclaration: (node: unknown) => node is Node.ImportDeclaration;
89
+ readonly isImportSpecifier: (node: unknown) => node is Node.ImportSpecifier;
90
+ readonly isImportExpression: (node: unknown) => node is Node.ImportExpression;
91
+ readonly isImportDefaultSpecifier: (node: unknown) => node is Node.ImportDefaultSpecifier;
92
+ readonly isImportNamespaceSpecifier: (node: unknown) => node is Node.ImportNamespaceSpecifier;
93
+ readonly isExportNamedDeclaration: (node: unknown) => node is Node.ExportNamedDeclaration;
94
+ readonly isExportSpecifier: (node: unknown) => node is Node.ExportSpecifier;
95
+ readonly isExportDefaultDeclaration: (node: unknown) => node is Node.ExportDefaultDeclaration;
96
+ readonly isExportAllDeclaration: (node: unknown) => node is Node.ExportAllDeclaration;
97
+ readonly isAwaitExpression: (node: unknown) => node is Node.AwaitExpression;
98
+ readonly isMethodDefinition: (node: unknown) => node is Node.MethodDefinition;
99
+ readonly isMemberExpression: (node: unknown) => node is Node.MemberExpression;
100
+ readonly isComment: (node: unknown) => node is Node.Comment;
101
+ readonly isDirective: (node: unknown) => node is Node.Directive;
102
+ readonly isSimpleCallExpression: (node: unknown) => node is Node.SimpleCallExpression;
103
+ readonly isAssignmentProperty: (node: unknown) => node is Node.AssignmentProperty;
104
+ readonly isSimpleLiteral: (node: unknown) => node is Node.SimpleLiteral;
105
+ readonly isRegExpLiteral: (node: unknown) => node is Node.RegExpLiteral;
106
+ readonly isBigIntLiteral: (node: unknown) => node is Node.BigIntLiteral;
107
+ readonly isExportStatement: (node: unknown) => node is Node.ExportStatement;
108
+ };
109
+ utils: typeof utils;
110
+ /**
111
+ * @internal
112
+ * parser for internal packages
113
+ */
114
+ internal: {
115
+ parse: (input: string, options: Options) => Node.Program;
116
+ parseExpressionAt: (input: string, pos: number, options: Options) => Node.ExpressionStatement;
117
+ };
118
+ };
@@ -1,9 +1,9 @@
1
1
  import type * as Node from 'estree';
2
2
  export type { Node };
3
3
  export declare enum ECMAVersion {
4
- ES5 = "ES5",
5
- ES6 = "ES6",
6
- ES7P = "ES7+",
4
+ ES5 = "ES5",
5
+ ES6 = "ES6",
6
+ ES7P = "ES7+"
7
7
  }
8
8
  /**
9
9
  * estree supplement type
@@ -11,20 +11,20 @@ export declare enum ECMAVersion {
11
11
  * The main reason for not using the type of acorn directly is that the node type described by acorn itself is too simple
12
12
  */
13
13
  declare module 'estree' {
14
- interface BaseNode {
15
- start: number;
16
- end: number;
17
- loc?: SourceLocation | undefined;
18
- }
19
- interface Position {
20
- offset: number;
21
- }
22
- /** all syntax nodes */
23
- type SyntaxNode = Node.Comment | Node.Program | Node.Directive | Node.EmptyStatement | Node.BlockStatement | Node.StaticBlock | Node.ExpressionStatement | Node.IfStatement | Node.LabeledStatement | Node.BreakStatement | Node.ContinueStatement | Node.WithStatement | Node.SwitchStatement | Node.ReturnStatement | Node.ThrowStatement | Node.TryStatement | Node.WhileStatement | Node.DoWhileStatement | Node.ForStatement | Node.ForInStatement | Node.DebuggerStatement | Node.FunctionDeclaration | Node.VariableDeclaration | Node.VariableDeclarator | Node.ChainExpression | Node.ThisExpression | Node.ArrayExpression | Node.ObjectExpression | Node.PrivateIdentifier | Node.Property | Node.PropertyDefinition | Node.FunctionExpression | Node.SequenceExpression | Node.UnaryExpression | Node.BinaryExpression | Node.AssignmentExpression | Node.UpdateExpression | Node.LogicalExpression | Node.ConditionalExpression | Node.SimpleCallExpression | Node.NewExpression | Node.MemberExpression | Node.SwitchCase | Node.CatchClause | Node.Identifier | Node.SimpleLiteral | Node.RegExpLiteral | Node.BigIntLiteral | Node.ForOfStatement | Node.Super | Node.SpreadElement | Node.ArrowFunctionExpression | Node.YieldExpression | Node.TemplateLiteral | Node.TaggedTemplateExpression | Node.TemplateElement | Node.AssignmentProperty | Node.ObjectPattern | Node.ArrayPattern | Node.RestElement | Node.AssignmentPattern | Node.ClassBody | Node.MethodDefinition | Node.ClassDeclaration | Node.ClassExpression | Node.MetaProperty | Node.ImportDeclaration | Node.ImportSpecifier | Node.ImportExpression | Node.ImportDefaultSpecifier | Node.ImportNamespaceSpecifier | Node.ExportNamedDeclaration | Node.ExportSpecifier | Node.ExportDefaultDeclaration | Node.ExportAllDeclaration | Node.AwaitExpression;
24
- /** all operators */
25
- type SyntaxOperator = Node.UnaryOperator | Node.BinaryOperator | Node.LogicalOperator | Node.AssignmentOperator | Node.UpdateOperator;
26
- /** Block-scoped statement */
27
- type BlockScopeStatement = Node.StaticBlock | Node.BlockStatement | Node.ForInStatement | Node.ForOfStatement | Node.ForStatement | Node.CatchClause | Node.SwitchStatement;
28
- /** Export statement */
29
- type ExportStatement = Node.ExportAllDeclaration | Node.ExportDefaultDeclaration | Node.ExportNamedDeclaration;
30
- }
14
+ interface BaseNode {
15
+ start: number;
16
+ end: number;
17
+ loc?: SourceLocation | undefined;
18
+ }
19
+ interface Position {
20
+ offset: number;
21
+ }
22
+ /** all syntax nodes */
23
+ type SyntaxNode = Node.Comment | Node.Program | Node.Directive | Node.EmptyStatement | Node.BlockStatement | Node.StaticBlock | Node.ExpressionStatement | Node.IfStatement | Node.LabeledStatement | Node.BreakStatement | Node.ContinueStatement | Node.WithStatement | Node.SwitchStatement | Node.ReturnStatement | Node.ThrowStatement | Node.TryStatement | Node.WhileStatement | Node.DoWhileStatement | Node.ForStatement | Node.ForInStatement | Node.DebuggerStatement | Node.FunctionDeclaration | Node.VariableDeclaration | Node.VariableDeclarator | Node.ChainExpression | Node.ThisExpression | Node.ArrayExpression | Node.ObjectExpression | Node.PrivateIdentifier | Node.Property | Node.PropertyDefinition | Node.FunctionExpression | Node.SequenceExpression | Node.UnaryExpression | Node.BinaryExpression | Node.AssignmentExpression | Node.UpdateExpression | Node.LogicalExpression | Node.ConditionalExpression | Node.SimpleCallExpression | Node.NewExpression | Node.MemberExpression | Node.SwitchCase | Node.CatchClause | Node.Identifier | Node.SimpleLiteral | Node.RegExpLiteral | Node.BigIntLiteral | Node.ForOfStatement | Node.Super | Node.SpreadElement | Node.ArrowFunctionExpression | Node.YieldExpression | Node.TemplateLiteral | Node.TaggedTemplateExpression | Node.TemplateElement | Node.AssignmentProperty | Node.ObjectPattern | Node.ArrayPattern | Node.RestElement | Node.AssignmentPattern | Node.ClassBody | Node.MethodDefinition | Node.ClassDeclaration | Node.ClassExpression | Node.MetaProperty | Node.ImportDeclaration | Node.ImportSpecifier | Node.ImportExpression | Node.ImportDefaultSpecifier | Node.ImportNamespaceSpecifier | Node.ExportNamedDeclaration | Node.ExportSpecifier | Node.ExportDefaultDeclaration | Node.ExportAllDeclaration | Node.AwaitExpression;
24
+ /** all operators */
25
+ type SyntaxOperator = Node.UnaryOperator | Node.BinaryOperator | Node.LogicalOperator | Node.AssignmentOperator | Node.UpdateOperator;
26
+ /** Block-scoped statement */
27
+ type BlockScopeStatement = Node.StaticBlock | Node.BlockStatement | Node.ForInStatement | Node.ForOfStatement | Node.ForStatement | Node.CatchClause | Node.SwitchStatement;
28
+ /** Export statement */
29
+ type ExportStatement = Node.ExportAllDeclaration | Node.ExportDefaultDeclaration | Node.ExportNamedDeclaration;
30
+ }
@@ -27,4 +27,4 @@ export declare function isES5(code: string): boolean;
27
27
  /** Determine whether it is all ES6 version code. */
28
28
  export declare function isES6(code: string): boolean;
29
29
  /** Detect ECMA version. */
30
- export declare function detectECMAVersion(code: string): ECMAVersion;
30
+ export declare function detectECMAVersion(code: string): ECMAVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/utils",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -62,7 +62,7 @@
62
62
  "lodash": "^4.17.21",
63
63
  "rslog": "^1.2.0",
64
64
  "strip-ansi": "^6.0.1",
65
- "@rsdoctor/types": "0.1.1"
65
+ "@rsdoctor/types": "0.1.2"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/deep-eql": "4.0.0",