@atlaspack/utils 2.17.3-typescript-5b4d3ad41.0 → 2.17.3

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 (114) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/lib/DefaultMap.js +4 -0
  3. package/lib/ansi-html.js +0 -2
  4. package/lib/config.js +1 -3
  5. package/lib/debug-tools.js +0 -1
  6. package/lib/glob.js +4 -12
  7. package/lib/index.js +9 -164
  8. package/lib/is-url.js +0 -2
  9. package/lib/objectHash.js +1 -0
  10. package/lib/prettyDiagnostic.js +5 -3
  11. package/lib/schema.js +19 -38
  12. package/lib/shared-buffer.js +1 -5
  13. package/lib/urlJoin.js +1 -1
  14. package/package.json +15 -22
  15. package/src/{DefaultMap.ts → DefaultMap.js} +12 -8
  16. package/src/Deferred.js +23 -0
  17. package/src/{PromiseQueue.ts → PromiseQueue.js} +35 -40
  18. package/src/{TapStream.ts → TapStream.js} +7 -8
  19. package/src/{alternatives.ts → alternatives.js} +15 -14
  20. package/src/{ansi-html.ts → ansi-html.js} +1 -1
  21. package/src/{blob.ts → blob.js} +4 -2
  22. package/src/{bundle-url.ts → bundle-url.js} +5 -3
  23. package/src/{collection.ts → collection.js} +21 -14
  24. package/src/{config.ts → config.js} +19 -18
  25. package/src/{countLines.ts → countLines.js} +2 -0
  26. package/src/{debounce.ts → debounce.js} +5 -3
  27. package/src/{debug-tools.ts → debug-tools.js} +8 -6
  28. package/src/{dependency-location.ts → dependency-location.js} +11 -15
  29. package/src/{escape-html.ts → escape-html.js} +3 -5
  30. package/src/{generateBuildMetrics.ts → generateBuildMetrics.js} +18 -16
  31. package/src/{generateCertificate.ts → generateCertificate.js} +5 -7
  32. package/src/{getCertificate.ts → getCertificate.js} +3 -5
  33. package/src/{getExisting.ts → getExisting.js} +3 -4
  34. package/src/{getModuleParts.ts → getModuleParts.js} +2 -3
  35. package/src/{getRootDir.ts → getRootDir.js} +2 -0
  36. package/src/{glob.ts → glob.js} +10 -14
  37. package/src/{hash.ts → hash.js} +17 -22
  38. package/src/{http-server.ts → http-server.js} +38 -32
  39. package/src/{index.ts → index.js} +8 -7
  40. package/src/{is-url.ts → is-url.js} +2 -1
  41. package/src/{isDirectoryInside.ts → isDirectoryInside.js} +1 -0
  42. package/src/{objectHash.ts → objectHash.js} +4 -1
  43. package/src/{openInBrowser.ts → openInBrowser.js} +4 -2
  44. package/src/{parseCSSImport.ts → parseCSSImport.js} +2 -0
  45. package/src/{path.ts → path.js} +3 -1
  46. package/src/{prettifyTime.ts → prettifyTime.js} +2 -0
  47. package/src/{prettyDiagnostic.ts → prettyDiagnostic.js} +20 -22
  48. package/src/{progress-message.ts → progress-message.js} +2 -3
  49. package/src/{relativeBundlePath.ts → relativeBundlePath.js} +3 -3
  50. package/src/{relativeUrl.ts → relativeUrl.js} +1 -0
  51. package/src/{replaceBundleReferences.ts → replaceBundleReferences.js} +36 -54
  52. package/src/{schema.ts → schema.js} +141 -158
  53. package/src/{shared-buffer.ts → shared-buffer.js} +3 -5
  54. package/src/{sourcemap.ts → sourcemap.js} +6 -16
  55. package/src/{stream.ts → stream.js} +21 -29
  56. package/src/throttle.js +15 -0
  57. package/src/{urlJoin.ts → urlJoin.js} +3 -1
  58. package/test/{DefaultMap.test.ts → DefaultMap.test.js} +6 -4
  59. package/test/{PromiseQueue.test.ts → PromiseQueue.test.js} +6 -5
  60. package/test/{collection.test.ts → collection.test.js} +2 -0
  61. package/test/{config.test.ts → config.test.js} +3 -0
  62. package/test/{objectHash.test.ts → objectHash.test.js} +5 -4
  63. package/test/{prettifyTime.test.ts → prettifyTime.test.js} +1 -0
  64. package/test/{replaceBundleReferences.test.ts → replaceBundleReferences.test.js} +32 -0
  65. package/test/{sourcemap.test.ts → sourcemap.test.js} +1 -0
  66. package/test/{throttle.test.ts → throttle.test.js} +3 -1
  67. package/test/{urlJoin.test.ts → urlJoin.test.js} +2 -0
  68. package/LICENSE +0 -201
  69. package/lib/DefaultMap.d.ts +0 -13
  70. package/lib/Deferred.d.ts +0 -8
  71. package/lib/PromiseQueue.d.ts +0 -25
  72. package/lib/TapStream.d.ts +0 -6
  73. package/lib/alternatives.d.ts +0 -3
  74. package/lib/ansi-html.d.ts +0 -1
  75. package/lib/blob.d.ts +0 -4
  76. package/lib/bundle-url.d.ts +0 -4
  77. package/lib/collection.d.ts +0 -33
  78. package/lib/config.d.ts +0 -17
  79. package/lib/countLines.d.ts +0 -1
  80. package/lib/debounce.d.ts +0 -1
  81. package/lib/debug-tools.d.ts +0 -6
  82. package/lib/dependency-location.d.ts +0 -14
  83. package/lib/escape-html.d.ts +0 -1
  84. package/lib/generateBuildMetrics.d.ts +0 -18
  85. package/lib/generateCertificate.d.ts +0 -5
  86. package/lib/getCertificate.d.ts +0 -6
  87. package/lib/getExisting.d.ts +0 -8
  88. package/lib/getModuleParts.d.ts +0 -4
  89. package/lib/getRootDir.d.ts +0 -2
  90. package/lib/glob.d.ts +0 -10
  91. package/lib/hash.d.ts +0 -7
  92. package/lib/http-server.d.ts +0 -19
  93. package/lib/index.d.ts +0 -48
  94. package/lib/is-url.d.ts +0 -1
  95. package/lib/isDirectoryInside.d.ts +0 -2
  96. package/lib/objectHash.d.ts +0 -3
  97. package/lib/openInBrowser.d.ts +0 -1
  98. package/lib/parseCSSImport.d.ts +0 -1
  99. package/lib/path.d.ts +0 -8
  100. package/lib/prettifyTime.d.ts +0 -1
  101. package/lib/prettyDiagnostic.d.ts +0 -17
  102. package/lib/progress-message.d.ts +0 -3
  103. package/lib/relativeBundlePath.d.ts +0 -4
  104. package/lib/relativeUrl.d.ts +0 -1
  105. package/lib/replaceBundleReferences.d.ts +0 -39
  106. package/lib/schema.d.ts +0 -107
  107. package/lib/shared-buffer.d.ts +0 -2
  108. package/lib/sourcemap.d.ts +0 -16
  109. package/lib/stream.d.ts +0 -8
  110. package/lib/throttle.d.ts +0 -1
  111. package/lib/urlJoin.d.ts +0 -5
  112. package/src/Deferred.ts +0 -26
  113. package/src/throttle.ts +0 -13
  114. package/tsconfig.json +0 -4
package/lib/Deferred.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export type Deferred<T> = {
2
- resolve(arg1: T): void;
3
- reject(arg1: unknown): void;
4
- };
5
- export declare function makeDeferredWithPromise<T>(): {
6
- deferred: Deferred<T>;
7
- promise: Promise<T>;
8
- };
@@ -1,25 +0,0 @@
1
- import { type Deferred } from './Deferred';
2
- type PromiseQueueOpts = {
3
- maxConcurrent: number;
4
- };
5
- export default class PromiseQueue<T> {
6
- _deferred: Deferred<Array<T>> | null | undefined;
7
- _maxConcurrent: number;
8
- _numRunning: number;
9
- _queue: Array<() => Promise<void>>;
10
- _runPromise: Promise<Array<T>> | null | undefined;
11
- _error: unknown;
12
- _count: number;
13
- _results: Array<T>;
14
- _addSubscriptions: Set<() => void>;
15
- constructor(opts?: PromiseQueueOpts);
16
- getNumWaiting(): number;
17
- add(fn: () => Promise<T>): void;
18
- subscribeToAdd(fn: () => void): () => void;
19
- run(): Promise<Array<T>>;
20
- _next(): Promise<void>;
21
- _runFn(fn: () => unknown): Promise<void>;
22
- _resetState(): void;
23
- _done(): void;
24
- }
25
- export {};
@@ -1,6 +0,0 @@
1
- import { Transform } from 'stream';
2
- export default class TapStream extends Transform {
3
- _tap: (arg1: Buffer) => unknown;
4
- constructor(tap: (arg1: Buffer) => unknown, options: unknown);
5
- _transform(chunk: Buffer | string, encoding: string, callback: (err?: Error | null | undefined, chunk?: Buffer | string) => unknown): void;
6
- }
@@ -1,3 +0,0 @@
1
- import type { FileSystem } from '@atlaspack/types';
2
- export declare function findAlternativeNodeModules(fs: FileSystem, moduleName: string, dir: string): Promise<Array<string>>;
3
- export declare function findAlternativeFiles(fs: FileSystem, fileSpecifier: string, dir: string, projectRoot: string, leadingDotSlash?: boolean, includeDirectories?: boolean, includeExtension?: boolean): Promise<Array<string>>;
@@ -1 +0,0 @@
1
- export declare function ansiHtml(ansi: string): string;
package/lib/blob.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { Blob } from '@atlaspack/types';
2
- import { Buffer } from 'buffer';
3
- export declare function blobToBuffer(blob: Blob): Promise<Buffer>;
4
- export declare function blobToString(blob: Blob): Promise<string>;
@@ -1,4 +0,0 @@
1
- declare function getBundleURLCached(): string;
2
- export declare function getBaseURL(url?: string | null): string;
3
- export declare const getBundleURL: typeof getBundleURLCached;
4
- export {};
@@ -1,33 +0,0 @@
1
- export declare function unique<T>(array: Array<T>): Array<T>;
2
- export declare function objectSortedEntries(obj: {
3
- readonly [key: string]: unknown;
4
- }): Array<[string, unknown]>;
5
- export declare function objectSortedEntriesDeep(object: {
6
- readonly [key: string]: unknown;
7
- }): Array<[string, unknown]>;
8
- /**
9
- * Get the difference of A and B sets
10
- *
11
- * This is the set of elements which are in A but not in B
12
- * For example, the difference of the sets {1,2,3} and {3,4} is {1,2}
13
- *
14
- * @param {*} a Set A
15
- * @param {*} b Set B
16
- * @returns A \ B
17
- */
18
- export declare function setDifference<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): Set<T>;
19
- /**
20
- * Get the symmetric difference of A and B sets
21
- *
22
- * This is the set of elements which are in either of the sets, but not in their intersection.
23
- * For example, the symmetric difference of the sets {1,2,3} and {3,4} is {1,2,4}
24
- *
25
- * @param {*} a Set A
26
- * @param {*} b Set B
27
- * @returns A Δ B
28
- */
29
- export declare function setSymmetricDifference<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): Set<T>;
30
- export declare function setIntersect<T>(a: Set<T>, b: ReadonlySet<T>): void;
31
- export declare function setIntersectStatic<T>(a: Set<T>, b: Set<T>): Set<T>;
32
- export declare function setUnion<T>(a: Iterable<T>, b: Iterable<T>): Set<T>;
33
- export declare function setEqual<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): boolean;
package/lib/config.d.ts DELETED
@@ -1,17 +0,0 @@
1
- import type { ConfigResult, File, FilePath } from '@atlaspack/types';
2
- import type { FileSystem } from '@atlaspack/fs';
3
- export type ConfigOutput = {
4
- config: ConfigResult;
5
- files: Array<File>;
6
- };
7
- export type ConfigOptions = {
8
- parse?: boolean;
9
- parser?: (arg1: string) => any;
10
- };
11
- export declare function resolveConfig(fs: FileSystem, filepath: FilePath, filenames: Array<FilePath>, projectRoot: FilePath): Promise<FilePath | null | undefined>;
12
- export declare function resolveConfigSync(fs: FileSystem, filepath: FilePath, filenames: Array<FilePath>, projectRoot: FilePath): FilePath | null | undefined;
13
- export declare function loadConfig(fs: FileSystem, filepath: FilePath, filenames: Array<FilePath>, projectRoot: FilePath, opts?: ConfigOptions | null): Promise<ConfigOutput | null>;
14
- export declare namespace loadConfig {
15
- var clear: () => void;
16
- }
17
- export declare function readConfig(fs: FileSystem, configFile: FilePath, opts?: ConfigOptions | null): Promise<ConfigOutput | null>;
@@ -1 +0,0 @@
1
- export default function countLines(string: string, startIndex?: number): number;
package/lib/debounce.d.ts DELETED
@@ -1 +0,0 @@
1
- export default function debounce<TArgs extends Array<unknown>>(fn: (...args: TArgs) => unknown, delay: number): (...args: TArgs) => void;
@@ -1,6 +0,0 @@
1
- type DebugTools = {
2
- ['asset-file-names-in-output']: boolean;
3
- ['simple-cli-reporter']: boolean;
4
- };
5
- export declare let debugTools: DebugTools;
6
- export {};
@@ -1,14 +0,0 @@
1
- export default function createDependencyLocation(start: {
2
- line: number;
3
- column: number;
4
- }, specifier: string, lineOffset?: number, columnOffset?: number, importWrapperLength?: number): {
5
- end: {
6
- column: number;
7
- line: number;
8
- };
9
- filePath: string;
10
- start: {
11
- column: number;
12
- line: number;
13
- };
14
- };
@@ -1 +0,0 @@
1
- export declare function escapeHTML(s: string): string;
@@ -1,18 +0,0 @@
1
- import type { FilePath, PackagedBundle } from '@atlaspack/types';
2
- import type { FileSystem } from '@atlaspack/fs';
3
- export type AssetStats = {
4
- filePath: string;
5
- size: number;
6
- originalSize: number;
7
- time: number;
8
- };
9
- export type BundleStats = {
10
- filePath: string;
11
- size: number;
12
- time: number;
13
- assets: Array<AssetStats>;
14
- };
15
- export type BuildMetrics = {
16
- bundles: Array<BundleStats>;
17
- };
18
- export default function generateBuildMetrics(bundles: Array<PackagedBundle>, fs: FileSystem, projectRoot: FilePath): Promise<BuildMetrics>;
@@ -1,5 +0,0 @@
1
- import type { FileSystem } from '@atlaspack/fs';
2
- export default function generateCertificate(fs: FileSystem, cacheDir: string, host?: string | null): Promise<{
3
- cert: Buffer;
4
- key: Buffer;
5
- }>;
@@ -1,6 +0,0 @@
1
- import type { HTTPSOptions } from '@atlaspack/types';
2
- import type { FileSystem } from '@atlaspack/fs';
3
- export default function getCertificate(fs: FileSystem, options: HTTPSOptions): Promise<{
4
- cert: Buffer;
5
- key: Buffer;
6
- }>;
@@ -1,8 +0,0 @@
1
- /**
2
- * Creates an object that contains both source and minified (using the source as a fallback).
3
- * e.g. builtins.min.js and builtins.js.
4
- */
5
- export default function getExisting(minifiedPath: string, sourcePath: string): {
6
- minified: string;
7
- source: string;
8
- };
@@ -1,4 +0,0 @@
1
- /**
2
- * Returns the package name and the optional subpath
3
- */
4
- export default function getModuleParts(_name: string): [string, string | null | undefined];
@@ -1,2 +0,0 @@
1
- import type { FilePath } from '@atlaspack/types';
2
- export default function getRootDir(files: Array<FilePath>): FilePath;
package/lib/glob.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { FilePath, Glob } from '@atlaspack/types';
2
- import type { FileSystem } from '@atlaspack/fs';
3
- import { FastGlobOptions } from 'fast-glob';
4
- import { type Options } from 'micromatch';
5
- export declare function isGlob(p: FilePath): any;
6
- export declare function isGlobMatch(filePath: FilePath, glob: Glob | Array<Glob>, opts?: Options): any;
7
- export declare function globMatch(values: Array<string>, glob: Glob | Array<Glob>, opts?: Options): Array<string>;
8
- export declare function globToRegex(glob: Glob, opts?: Options): RegExp;
9
- export declare function globSync(p: FilePath, fs: FileSystem, options?: FastGlobOptions<FilePath>): Array<FilePath>;
10
- export declare function glob(p: FilePath, fs: FileSystem, options: FastGlobOptions<FilePath>): Promise<Array<FilePath>>;
package/lib/hash.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { Readable } from 'stream';
2
- import type { FileSystem } from '@atlaspack/fs';
3
- export declare function hashStream(stream: Readable): Promise<string>;
4
- export declare function hashObject(obj: {
5
- readonly [key: string]: unknown;
6
- }): string;
7
- export declare function hashFile(fs: FileSystem, filePath: string): Promise<string>;
@@ -1,19 +0,0 @@
1
- import type { Server as HTTPOnlyServer, IncomingMessage as HTTPRequest, ServerResponse as HTTPResponse } from 'http';
2
- import type { Server as HTTPSServer } from 'https';
3
- import type { FilePath, HTTPSOptions } from '@atlaspack/types';
4
- import type { FileSystem } from '@atlaspack/fs';
5
- type CreateHTTPServerOpts = {
6
- listener?: (arg1: HTTPRequest, arg2: HTTPResponse) => void;
7
- host?: string;
8
- } & ({
9
- https: HTTPSOptions | boolean | null | undefined;
10
- inputFS: FileSystem;
11
- outputFS: FileSystem;
12
- cacheDir: FilePath;
13
- } | Record<any, any>);
14
- export type HTTPServer = HTTPOnlyServer | HTTPSServer;
15
- export declare function createHTTPServer(options: CreateHTTPServerOpts): Promise<{
16
- stop: () => Promise<void>;
17
- server: HTTPServer;
18
- }>;
19
- export {};
package/lib/index.d.ts DELETED
@@ -1,48 +0,0 @@
1
- export * from './config';
2
- export * from './Deferred';
3
- export * from './generateBuildMetrics';
4
- export * from './http-server';
5
- export * from './path';
6
- export * from './prettyDiagnostic';
7
- export * from './schema';
8
- export { default as countLines } from './countLines';
9
- export { default as generateBuildMetrics } from './generateBuildMetrics';
10
- export { default as generateCertificate } from './generateCertificate';
11
- export { default as getCertificate } from './getCertificate';
12
- export { default as getModuleParts } from './getModuleParts';
13
- export { default as getRootDir } from './getRootDir';
14
- export { default as isDirectoryInside } from './isDirectoryInside';
15
- export { default as isURL } from './is-url';
16
- export { default as objectHash } from './objectHash';
17
- export { default as prettifyTime } from './prettifyTime';
18
- export { default as prettyDiagnostic } from './prettyDiagnostic';
19
- export { default as PromiseQueue } from './PromiseQueue';
20
- export { default as validateSchema } from './schema';
21
- export { default as TapStream } from './TapStream';
22
- export { default as urlJoin } from './urlJoin';
23
- export { default as relativeUrl } from './relativeUrl';
24
- export { default as createDependencyLocation } from './dependency-location';
25
- export { default as debounce } from './debounce';
26
- export { default as throttle } from './throttle';
27
- export { default as openInBrowser } from './openInBrowser';
28
- export { findAlternativeNodeModules, findAlternativeFiles } from './alternatives';
29
- export { blobToBuffer, blobToString } from './blob';
30
- export { unique, objectSortedEntries, objectSortedEntriesDeep, setDifference, setSymmetricDifference, setEqual, setIntersect, setIntersectStatic, setUnion, } from './collection';
31
- export { resolveConfig, resolveConfigSync, loadConfig, readConfig, } from './config';
32
- export { debugTools } from './debug-tools';
33
- export { DefaultMap, DefaultWeakMap } from './DefaultMap';
34
- export { makeDeferredWithPromise } from './Deferred';
35
- export { getProgressMessage, getPackageProgressMessage, } from './progress-message';
36
- export { isGlob, isGlobMatch, globMatch, globSync, glob, globToRegex, } from './glob';
37
- export { hashStream, hashObject, hashFile } from './hash';
38
- export { SharedBuffer } from './shared-buffer';
39
- export { fuzzySearch } from './schema';
40
- export { createHTTPServer } from './http-server';
41
- export { normalizePath, normalizeSeparators, relativePath } from './path';
42
- export { replaceURLReferences, replaceInlineReferences, } from './replaceBundleReferences';
43
- export { measureStreamLength, readableFromStringOrBuffer, bufferStream, blobToStream, streamFromPromise, fallbackStream, } from './stream';
44
- export { relativeBundlePath } from './relativeBundlePath';
45
- export { ansiHtml } from './ansi-html';
46
- export { escapeHTML } from './escape-html';
47
- export { SOURCEMAP_RE, SOURCEMAP_EXTENSIONS, matchSourceMappingURL, loadSourceMapUrl, loadSourceMap, remapSourceLocation, } from './sourcemap';
48
- export { default as stripAnsi } from 'strip-ansi';
package/lib/is-url.d.ts DELETED
@@ -1 +0,0 @@
1
- export default function isURL(url: string): boolean;
@@ -1,2 +0,0 @@
1
- import type { FilePath } from '@atlaspack/types';
2
- export default function isDirectoryInside(child: FilePath, parent: FilePath): boolean;
@@ -1,3 +0,0 @@
1
- type Hashable = any;
2
- export default function objectHash(object: Hashable): string;
3
- export {};
@@ -1 +0,0 @@
1
- export default function openInBrowser(url: string, browser: string): Promise<void>;
@@ -1 +0,0 @@
1
- export default function parseCSSImport(url: string): string;
package/lib/path.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import type { FilePath } from '@atlaspack/types';
2
- export declare function isAbsolute(filepath: string): boolean;
3
- export declare function normalizeSeparators(filePath: FilePath): FilePath;
4
- export type PathOptions = {
5
- noLeadingDotSlash?: boolean;
6
- };
7
- export declare function normalizePath(filePath: FilePath, leadingDotSlash?: boolean): FilePath;
8
- export declare function relativePath(from: string, to: string, leadingDotSlash?: boolean): FilePath;
@@ -1 +0,0 @@
1
- export default function prettifyTime(timeInMs: number): string;
@@ -1,17 +0,0 @@
1
- import type { Diagnostic } from '@atlaspack/diagnostic';
2
- import type { PluginOptions } from '@atlaspack/types';
3
- export type FormattedCodeFrame = {
4
- location: string;
5
- code: string;
6
- };
7
- export type AnsiDiagnosticResult = {
8
- message: string;
9
- stack: string;
10
- /** A formatted string containing all code frames, including their file locations. */
11
- codeframe: string;
12
- /** A list of code frames with highlighted code and file locations separately. */
13
- frames: Array<FormattedCodeFrame>;
14
- hints: Array<string>;
15
- documentation: string;
16
- };
17
- export default function prettyDiagnostic(diagnostic: Diagnostic, options?: PluginOptions, terminalWidth?: number, format?: 'ansi' | 'html'): Promise<AnsiDiagnosticResult>;
@@ -1,3 +0,0 @@
1
- import type { BuildProgressEvent } from '@atlaspack/types';
2
- export declare function getProgressMessage(event: BuildProgressEvent): string | null | undefined;
3
- export declare function getPackageProgressMessage(completeBundles: number, totalBundles: number): string;
@@ -1,4 +0,0 @@
1
- import type { FilePath, NamedBundle } from '@atlaspack/types';
2
- export declare function relativeBundlePath(from: NamedBundle, to: NamedBundle, opts?: {
3
- leadingDotSlash: boolean;
4
- }): FilePath;
@@ -1 +0,0 @@
1
- export default function relativeUrl(from: string, to: string): string;
@@ -1,39 +0,0 @@
1
- import type SourceMap from '@parcel/source-map';
2
- import type { Async, Blob, Bundle, BundleGraph, Dependency, NamedBundle } from '@atlaspack/types';
3
- export declare function replaceURLReferences({ bundle, bundleGraph, contents, map, getReplacement, relative, }: {
4
- bundle: NamedBundle;
5
- bundleGraph: BundleGraph<NamedBundle>;
6
- contents: string;
7
- relative?: boolean;
8
- map?: SourceMap | null | undefined;
9
- getReplacement?: (arg1: string) => string;
10
- }): {
11
- readonly contents: string;
12
- readonly map: SourceMap | null | undefined;
13
- };
14
- export declare function replaceInlineReferences({ bundle, bundleGraph, contents, map, getInlineReplacement, getInlineBundleContents, }: {
15
- bundle: Bundle;
16
- bundleGraph: BundleGraph<NamedBundle>;
17
- contents: string;
18
- getInlineReplacement: (arg1: Dependency, arg2: 'string' | null | undefined, arg3: string) => {
19
- from: string;
20
- to: string;
21
- };
22
- getInlineBundleContents: (arg1: Bundle, arg2: BundleGraph<NamedBundle>) => Async<{
23
- contents: Blob;
24
- }>;
25
- map?: SourceMap | null | undefined;
26
- }): Promise<{
27
- readonly contents: string;
28
- readonly map: SourceMap | null | undefined;
29
- }>;
30
- export declare function getURLReplacement({ dependency, fromBundle, toBundle, relative, getReplacement, }: {
31
- dependency: Dependency;
32
- fromBundle: NamedBundle;
33
- toBundle: NamedBundle;
34
- relative: boolean;
35
- getReplacement?: (arg1: string) => string;
36
- }): {
37
- from: string;
38
- to: string;
39
- };
package/lib/schema.d.ts DELETED
@@ -1,107 +0,0 @@
1
- import type { Mapping } from '@mischnic/json-sourcemap';
2
- export type SchemaEntity = SchemaObject | SchemaArray | SchemaBoolean | SchemaString | SchemaNumber | SchemaEnum | SchemaOneOf | SchemaAllOf | SchemaNot | SchemaAny;
3
- export type SchemaArray = {
4
- type: 'array';
5
- items?: SchemaEntity;
6
- __type?: string;
7
- };
8
- export type SchemaBoolean = {
9
- type: 'boolean';
10
- __type?: string;
11
- };
12
- export type SchemaOneOf = {
13
- oneOf: Array<SchemaEntity>;
14
- };
15
- export type SchemaAllOf = {
16
- allOf: Array<SchemaEntity>;
17
- };
18
- export type SchemaNot = {
19
- not: SchemaEntity;
20
- __message: string;
21
- };
22
- export type SchemaString = {
23
- type: 'string';
24
- enum?: Array<string>;
25
- __validate?: (val: string) => string | null | undefined;
26
- __type?: string;
27
- };
28
- export type SchemaNumber = {
29
- type: 'number';
30
- enum?: Array<number>;
31
- __type?: string;
32
- };
33
- export type SchemaEnum = {
34
- enum: Array<unknown>;
35
- };
36
- export type SchemaObject = {
37
- type: 'object';
38
- properties: {
39
- [key: string]: SchemaEntity;
40
- };
41
- additionalProperties?: boolean | SchemaEntity;
42
- required?: Array<string>;
43
- __forbiddenProperties?: Array<string>;
44
- __type?: string;
45
- };
46
- export type SchemaAny = Record<any, any>;
47
- export type SchemaError = {
48
- type: 'type';
49
- expectedTypes: Array<string>;
50
- dataType: 'key' | null | undefined | 'value';
51
- dataPath: string;
52
- ancestors: Array<SchemaEntity>;
53
- prettyType?: string;
54
- } | {
55
- type: 'enum';
56
- expectedValues: Array<unknown>;
57
- dataType: 'key' | 'value';
58
- actualValue: unknown;
59
- dataPath: string;
60
- ancestors: Array<SchemaEntity>;
61
- prettyType?: string;
62
- } | {
63
- type: 'forbidden-prop';
64
- prop: string;
65
- expectedProps: Array<string>;
66
- actualProps: Array<string>;
67
- dataType: 'key';
68
- dataPath: string;
69
- ancestors: Array<SchemaEntity>;
70
- prettyType?: string;
71
- } | {
72
- type: 'missing-prop';
73
- prop: string;
74
- expectedProps: Array<string>;
75
- actualProps: Array<string>;
76
- dataType: 'key' | 'value';
77
- dataPath: string;
78
- ancestors: Array<SchemaEntity>;
79
- prettyType?: string;
80
- } | {
81
- type: 'other';
82
- actualValue: unknown;
83
- dataType: 'key' | null | undefined | 'value';
84
- message?: string;
85
- dataPath: string;
86
- ancestors: Array<SchemaEntity>;
87
- };
88
- declare function validateSchema(schema: SchemaEntity, data: unknown): Array<SchemaError>;
89
- declare namespace validateSchema {
90
- var diagnostic: (schema: SchemaEntity, data: ({
91
- source?: string | null | undefined;
92
- data?: unknown;
93
- } | {
94
- source: string;
95
- map: {
96
- data: unknown;
97
- pointers: {
98
- [key: string]: Mapping;
99
- };
100
- };
101
- }) & {
102
- filePath?: string | null | undefined;
103
- prependKey?: string | null | undefined;
104
- }, origin: string, message: string) => undefined;
105
- }
106
- export default validateSchema;
107
- export declare function fuzzySearch(expectedValues: Array<string>, actualValue: string): Array<string>;
@@ -1,2 +0,0 @@
1
- export type Class<T> = new (...args: any[]) => T;
2
- export declare let SharedBuffer: Class<ArrayBuffer> | Class<SharedArrayBuffer>;
@@ -1,16 +0,0 @@
1
- import type { SourceLocation } from '@atlaspack/types';
2
- import type { FileSystem } from '@atlaspack/fs';
3
- import SourceMap from '@parcel/source-map';
4
- export declare const SOURCEMAP_RE: RegExp;
5
- export declare const SOURCEMAP_EXTENSIONS: Set<string>;
6
- export declare function matchSourceMappingURL(contents: string): RegExpMatchArray | null;
7
- export declare function loadSourceMapUrl(fs: FileSystem, filename: string, contents: string): Promise<{
8
- filename: string;
9
- map: any;
10
- url: string;
11
- } | null | undefined>;
12
- export declare function loadSourceMap(filename: string, contents: string, options: {
13
- fs: FileSystem;
14
- projectRoot: string;
15
- }): Promise<SourceMap | null | undefined>;
16
- export declare function remapSourceLocation(loc: SourceLocation, originalMap: SourceMap): SourceLocation;
package/lib/stream.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { Readable } from 'stream';
2
- import type { Blob } from '@atlaspack/types';
3
- export declare function measureStreamLength(stream: Readable): Promise<number>;
4
- export declare function readableFromStringOrBuffer(str: string | Buffer): Readable;
5
- export declare function bufferStream(stream: Readable): Promise<Buffer>;
6
- export declare function blobToStream(blob: Blob): Readable;
7
- export declare function streamFromPromise(promise: Promise<Blob>): Readable;
8
- export declare function fallbackStream(stream: Readable, fallback: () => Readable): Readable;
package/lib/throttle.d.ts DELETED
@@ -1 +0,0 @@
1
- export default function throttle<TArgs extends Array<unknown>>(fn: (...args: TArgs) => unknown, delay: number): (...args: TArgs) => void;
package/lib/urlJoin.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * Joins a path onto a URL, and normalizes Windows paths
3
- * e.g. from \path\to\res.js to /path/to/res.js.
4
- */
5
- export default function urlJoin(publicURL: string, assetPath: string): string;
package/src/Deferred.ts DELETED
@@ -1,26 +0,0 @@
1
- import invariant from 'assert';
2
-
3
- export type Deferred<T> = {
4
- resolve(arg1: T): void;
5
- reject(arg1: unknown): void;
6
- };
7
-
8
- export function makeDeferredWithPromise<T>(): {
9
- deferred: Deferred<T>;
10
- promise: Promise<T>;
11
- } {
12
- let deferred: Deferred<T> | null | undefined;
13
- let promise = new Promise<T>(
14
- (
15
- resolve: (result: Promise<T> | T) => void,
16
- reject: (error?: any) => void,
17
- ) => {
18
- deferred = {resolve, reject};
19
- },
20
- );
21
-
22
- // Promise constructor callback executes synchronously, so this is defined
23
- invariant(deferred != null);
24
-
25
- return {deferred, promise};
26
- }
package/src/throttle.ts DELETED
@@ -1,13 +0,0 @@
1
- export default function throttle<TArgs extends Array<unknown>>(
2
- fn: (...args: TArgs) => unknown,
3
- delay: number,
4
- ): (...args: TArgs) => void {
5
- let lastCalled: number | null | undefined;
6
-
7
- return function throttled(this: any, ...args: TArgs) {
8
- if (lastCalled == null || lastCalled + delay <= Date.now()) {
9
- fn.call(this, ...args);
10
- lastCalled = Date.now();
11
- }
12
- };
13
- }
package/tsconfig.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.json",
3
- "include": ["src"]
4
- }