@atlaspack/utils 2.17.3-typescript-bc4459c37.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.
- package/CHANGELOG.md +7 -0
- package/lib/DefaultMap.js +4 -0
- package/lib/ansi-html.js +0 -2
- package/lib/config.js +1 -3
- package/lib/debug-tools.js +0 -1
- package/lib/glob.js +4 -12
- package/lib/index.js +9 -164
- package/lib/is-url.js +0 -2
- package/lib/objectHash.js +1 -0
- package/lib/prettyDiagnostic.js +5 -3
- package/lib/schema.js +19 -38
- package/lib/shared-buffer.js +1 -5
- package/lib/urlJoin.js +1 -1
- package/package.json +15 -22
- package/src/{DefaultMap.ts → DefaultMap.js} +12 -8
- package/src/Deferred.js +23 -0
- package/src/{PromiseQueue.ts → PromiseQueue.js} +35 -40
- package/src/{TapStream.ts → TapStream.js} +7 -8
- package/src/{alternatives.ts → alternatives.js} +15 -14
- package/src/{ansi-html.ts → ansi-html.js} +1 -1
- package/src/{blob.ts → blob.js} +4 -2
- package/src/{bundle-url.ts → bundle-url.js} +5 -3
- package/src/{collection.ts → collection.js} +21 -14
- package/src/{config.ts → config.js} +19 -18
- package/src/{countLines.ts → countLines.js} +2 -0
- package/src/{debounce.ts → debounce.js} +5 -3
- package/src/{debug-tools.ts → debug-tools.js} +8 -6
- package/src/{dependency-location.ts → dependency-location.js} +11 -15
- package/src/{escape-html.ts → escape-html.js} +3 -5
- package/src/{generateBuildMetrics.ts → generateBuildMetrics.js} +18 -16
- package/src/{generateCertificate.ts → generateCertificate.js} +5 -7
- package/src/{getCertificate.ts → getCertificate.js} +3 -5
- package/src/{getExisting.ts → getExisting.js} +3 -4
- package/src/{getModuleParts.ts → getModuleParts.js} +2 -3
- package/src/{getRootDir.ts → getRootDir.js} +2 -0
- package/src/{glob.ts → glob.js} +10 -14
- package/src/{hash.ts → hash.js} +17 -22
- package/src/{http-server.ts → http-server.js} +38 -32
- package/src/{index.ts → index.js} +8 -7
- package/src/{is-url.ts → is-url.js} +2 -1
- package/src/{isDirectoryInside.ts → isDirectoryInside.js} +1 -0
- package/src/{objectHash.ts → objectHash.js} +4 -1
- package/src/{openInBrowser.ts → openInBrowser.js} +4 -2
- package/src/{parseCSSImport.ts → parseCSSImport.js} +2 -0
- package/src/{path.ts → path.js} +3 -1
- package/src/{prettifyTime.ts → prettifyTime.js} +2 -0
- package/src/{prettyDiagnostic.ts → prettyDiagnostic.js} +20 -22
- package/src/{progress-message.ts → progress-message.js} +2 -3
- package/src/{relativeBundlePath.ts → relativeBundlePath.js} +3 -3
- package/src/{relativeUrl.ts → relativeUrl.js} +1 -0
- package/src/{replaceBundleReferences.ts → replaceBundleReferences.js} +36 -54
- package/src/{schema.ts → schema.js} +141 -158
- package/src/{shared-buffer.ts → shared-buffer.js} +3 -5
- package/src/{sourcemap.ts → sourcemap.js} +6 -16
- package/src/{stream.ts → stream.js} +21 -29
- package/src/throttle.js +15 -0
- package/src/{urlJoin.ts → urlJoin.js} +3 -1
- package/test/{DefaultMap.test.ts → DefaultMap.test.js} +6 -4
- package/test/{PromiseQueue.test.ts → PromiseQueue.test.js} +6 -5
- package/test/{collection.test.ts → collection.test.js} +2 -0
- package/test/{config.test.ts → config.test.js} +3 -0
- package/test/{objectHash.test.ts → objectHash.test.js} +5 -4
- package/test/{prettifyTime.test.ts → prettifyTime.test.js} +1 -0
- package/test/{replaceBundleReferences.test.ts → replaceBundleReferences.test.js} +32 -0
- package/test/{sourcemap.test.ts → sourcemap.test.js} +1 -0
- package/test/{throttle.test.ts → throttle.test.js} +3 -1
- package/test/{urlJoin.test.ts → urlJoin.test.js} +2 -0
- package/LICENSE +0 -201
- package/lib/DefaultMap.d.ts +0 -13
- package/lib/Deferred.d.ts +0 -8
- package/lib/PromiseQueue.d.ts +0 -25
- package/lib/TapStream.d.ts +0 -6
- package/lib/alternatives.d.ts +0 -3
- package/lib/ansi-html.d.ts +0 -1
- package/lib/blob.d.ts +0 -4
- package/lib/bundle-url.d.ts +0 -4
- package/lib/collection.d.ts +0 -33
- package/lib/config.d.ts +0 -17
- package/lib/countLines.d.ts +0 -1
- package/lib/debounce.d.ts +0 -1
- package/lib/debug-tools.d.ts +0 -6
- package/lib/dependency-location.d.ts +0 -14
- package/lib/escape-html.d.ts +0 -1
- package/lib/generateBuildMetrics.d.ts +0 -18
- package/lib/generateCertificate.d.ts +0 -5
- package/lib/getCertificate.d.ts +0 -6
- package/lib/getExisting.d.ts +0 -8
- package/lib/getModuleParts.d.ts +0 -4
- package/lib/getRootDir.d.ts +0 -2
- package/lib/glob.d.ts +0 -10
- package/lib/hash.d.ts +0 -7
- package/lib/http-server.d.ts +0 -19
- package/lib/index.d.ts +0 -48
- package/lib/is-url.d.ts +0 -1
- package/lib/isDirectoryInside.d.ts +0 -2
- package/lib/objectHash.d.ts +0 -3
- package/lib/openInBrowser.d.ts +0 -1
- package/lib/parseCSSImport.d.ts +0 -1
- package/lib/path.d.ts +0 -8
- package/lib/prettifyTime.d.ts +0 -1
- package/lib/prettyDiagnostic.d.ts +0 -17
- package/lib/progress-message.d.ts +0 -3
- package/lib/relativeBundlePath.d.ts +0 -4
- package/lib/relativeUrl.d.ts +0 -1
- package/lib/replaceBundleReferences.d.ts +0 -39
- package/lib/schema.d.ts +0 -107
- package/lib/shared-buffer.d.ts +0 -2
- package/lib/sourcemap.d.ts +0 -16
- package/lib/stream.d.ts +0 -8
- package/lib/throttle.d.ts +0 -1
- package/lib/urlJoin.d.ts +0 -5
- package/src/Deferred.ts +0 -26
- package/src/throttle.ts +0 -13
- package/tsconfig.json +0 -4
|
@@ -1,20 +1,17 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
1
3
|
import {Readable, PassThrough} from 'stream';
|
|
2
4
|
import type {Blob} from '@atlaspack/types';
|
|
3
5
|
|
|
4
6
|
export function measureStreamLength(stream: Readable): Promise<number> {
|
|
5
|
-
return new Promise(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
stream.on('end', () => resolve(length));
|
|
15
|
-
stream.on('error', reject);
|
|
16
|
-
},
|
|
17
|
-
);
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
let length = 0;
|
|
9
|
+
stream.on('data', (chunk) => {
|
|
10
|
+
length += chunk;
|
|
11
|
+
});
|
|
12
|
+
stream.on('end', () => resolve(length));
|
|
13
|
+
stream.on('error', reject);
|
|
14
|
+
});
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
export function readableFromStringOrBuffer(str: string | Buffer): Readable {
|
|
@@ -26,21 +23,16 @@ export function readableFromStringOrBuffer(str: string | Buffer): Readable {
|
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
export function bufferStream(stream: Readable): Promise<Buffer> {
|
|
29
|
-
return new Promise(
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
resolve(buf);
|
|
40
|
-
});
|
|
41
|
-
stream.on('error', reject);
|
|
42
|
-
},
|
|
43
|
-
);
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
let buf = Buffer.from([]);
|
|
28
|
+
stream.on('data', (data) => {
|
|
29
|
+
buf = Buffer.concat([buf, data]);
|
|
30
|
+
});
|
|
31
|
+
stream.on('end', () => {
|
|
32
|
+
resolve(buf);
|
|
33
|
+
});
|
|
34
|
+
stream.on('error', reject);
|
|
35
|
+
});
|
|
44
36
|
}
|
|
45
37
|
|
|
46
38
|
export function blobToStream(blob: Blob): Readable {
|
|
@@ -70,7 +62,7 @@ export function fallbackStream(
|
|
|
70
62
|
): Readable {
|
|
71
63
|
const res = new PassThrough();
|
|
72
64
|
stream.on('error', (err) => {
|
|
73
|
-
if (
|
|
65
|
+
if (err.code === 'ENOENT') {
|
|
74
66
|
fallback().pipe(res);
|
|
75
67
|
} else {
|
|
76
68
|
res.emit('error', err);
|
package/src/throttle.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
3
|
+
export default function throttle<TArgs: Iterable<mixed>>(
|
|
4
|
+
fn: (...args: TArgs) => mixed,
|
|
5
|
+
delay: number,
|
|
6
|
+
): (...args: TArgs) => void {
|
|
7
|
+
let lastCalled: ?number;
|
|
8
|
+
|
|
9
|
+
return function throttled(...args: TArgs) {
|
|
10
|
+
if (lastCalled == null || lastCalled + delay <= Date.now()) {
|
|
11
|
+
fn.call(this, ...args);
|
|
12
|
+
lastCalled = Date.now();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
1
3
|
import URL from 'url';
|
|
2
4
|
import path from 'path';
|
|
3
5
|
|
|
@@ -10,7 +12,7 @@ export default function urlJoin(publicURL: string, assetPath: string): string {
|
|
|
10
12
|
// Leading / ensures that paths with colons are not parsed as a protocol.
|
|
11
13
|
let p = assetPath.startsWith('/') ? assetPath : '/' + assetPath;
|
|
12
14
|
const assetUrl = URL.parse(p);
|
|
13
|
-
url.pathname = path.posix.join(url.pathname
|
|
15
|
+
url.pathname = path.posix.join(url.pathname, assetUrl.pathname);
|
|
14
16
|
url.search = assetUrl.search;
|
|
15
17
|
url.hash = assetUrl.hash;
|
|
16
18
|
return URL.format(url);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
1
3
|
import assert from 'assert';
|
|
2
4
|
import {DefaultMap} from '../src/DefaultMap';
|
|
3
5
|
|
|
4
6
|
describe('DefaultMap', () => {
|
|
5
7
|
it('constructs with entries just like Map', () => {
|
|
6
8
|
let map = new DefaultMap(
|
|
7
|
-
(k
|
|
9
|
+
(k) => k,
|
|
8
10
|
[
|
|
9
11
|
[1, 3],
|
|
10
12
|
[2, 27],
|
|
@@ -18,18 +20,18 @@ describe('DefaultMap', () => {
|
|
|
18
20
|
});
|
|
19
21
|
|
|
20
22
|
it("returns a default value based on a key if it doesn't exist", () => {
|
|
21
|
-
let map = new DefaultMap((k
|
|
23
|
+
let map = new DefaultMap((k) => k);
|
|
22
24
|
assert.equal(map.get(3), 3);
|
|
23
25
|
});
|
|
24
26
|
|
|
25
27
|
it("sets a default value based on a key if it doesn't exist", () => {
|
|
26
|
-
let map = new DefaultMap((k
|
|
28
|
+
let map = new DefaultMap((k) => k);
|
|
27
29
|
map.get(3);
|
|
28
30
|
assert.deepEqual(Array.from(map.entries()), [[3, 3]]);
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
it('respects undefined/null if it already existed in the map', () => {
|
|
32
|
-
let map = new DefaultMap<number, number |
|
|
34
|
+
let map = new DefaultMap<number, number | void | null>((k) => k);
|
|
33
35
|
map.set(3, undefined);
|
|
34
36
|
assert.equal(map.get(3), undefined);
|
|
35
37
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @flow
|
|
1
2
|
import assert from 'assert';
|
|
2
3
|
import randomInt from 'random-int';
|
|
3
4
|
|
|
@@ -24,7 +25,7 @@ describe('PromiseQueue', () => {
|
|
|
24
25
|
let queue = new PromiseQueue();
|
|
25
26
|
queue.add(() => Promise.reject(error));
|
|
26
27
|
await queue.run();
|
|
27
|
-
} catch (e
|
|
28
|
+
} catch (e) {
|
|
28
29
|
assert.equal(e, error);
|
|
29
30
|
}
|
|
30
31
|
});
|
|
@@ -37,7 +38,7 @@ describe('PromiseQueue', () => {
|
|
|
37
38
|
throw error;
|
|
38
39
|
});
|
|
39
40
|
await queue.run();
|
|
40
|
-
} catch (e
|
|
41
|
+
} catch (e) {
|
|
41
42
|
assert.equal(e, error);
|
|
42
43
|
}
|
|
43
44
|
});
|
|
@@ -91,17 +92,17 @@ describe('PromiseQueue', () => {
|
|
|
91
92
|
|
|
92
93
|
const fn1 = sinon
|
|
93
94
|
.stub()
|
|
94
|
-
.returns(new Promise((resolve
|
|
95
|
+
.returns(new Promise((resolve) => setTimeout(resolve, 5000)));
|
|
95
96
|
|
|
96
97
|
queue.add(fn1); // queue does not work if nothing is running, this is broken behaviour
|
|
97
98
|
queue.run();
|
|
98
99
|
|
|
99
100
|
const fn2 = sinon
|
|
100
101
|
.stub()
|
|
101
|
-
.returns(new Promise((resolve
|
|
102
|
+
.returns(new Promise((resolve) => setTimeout(resolve, 5000)));
|
|
102
103
|
const fn3 = sinon
|
|
103
104
|
.stub()
|
|
104
|
-
.returns(new Promise((resolve
|
|
105
|
+
.returns(new Promise((resolve) => setTimeout(resolve, 5000)));
|
|
105
106
|
|
|
106
107
|
queue.add(fn2);
|
|
107
108
|
queue.add(fn3);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
1
3
|
import assert from 'assert';
|
|
2
4
|
import {loadConfig} from '../src/config';
|
|
3
5
|
import {inputFS as fs} from '@atlaspack/test-utils';
|
|
@@ -21,6 +23,7 @@ describe('loadConfig', () => {
|
|
|
21
23
|
});
|
|
22
24
|
|
|
23
25
|
it('should throw error with empty string json', async () => {
|
|
26
|
+
// $FlowFixMe[prop-missing]
|
|
24
27
|
await assert.rejects(async () => {
|
|
25
28
|
await loadConfig(
|
|
26
29
|
fs,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @flow
|
|
1
2
|
import assert from 'assert';
|
|
2
3
|
import objectHash from '../src/objectHash';
|
|
3
4
|
|
|
@@ -7,12 +8,12 @@ describe('objectHash', () => {
|
|
|
7
8
|
foo: {foo: 'foo', baz: ['foo', 'baz', 'bar'], bar: 'bar'},
|
|
8
9
|
baz: 'baz',
|
|
9
10
|
bar: 'bar',
|
|
10
|
-
}
|
|
11
|
+
};
|
|
11
12
|
const obj2 = {
|
|
12
13
|
foo: {foo: 'foo', baz: ['foo', 'baz', 'bar'], bar: 'bar'},
|
|
13
14
|
baz: 'baz',
|
|
14
15
|
bar: 'bar',
|
|
15
|
-
}
|
|
16
|
+
};
|
|
16
17
|
|
|
17
18
|
assert.equal(objectHash(obj1), objectHash(obj2));
|
|
18
19
|
});
|
|
@@ -21,11 +22,11 @@ describe('objectHash', () => {
|
|
|
21
22
|
const obj1 = {
|
|
22
23
|
baz: 'baz',
|
|
23
24
|
bar: 'ba',
|
|
24
|
-
}
|
|
25
|
+
};
|
|
25
26
|
const obj2 = {
|
|
26
27
|
baz: 'baz',
|
|
27
28
|
bar: 'bar',
|
|
28
|
-
}
|
|
29
|
+
};
|
|
29
30
|
|
|
30
31
|
assert.notEqual(objectHash(obj1), objectHash(obj2));
|
|
31
32
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
1
3
|
import type {NamedBundle, Dependency} from '@atlaspack/types';
|
|
2
4
|
|
|
3
5
|
import assert from 'assert';
|
|
@@ -5,25 +7,30 @@ import {getURLReplacement} from '../src/replaceBundleReferences';
|
|
|
5
7
|
|
|
6
8
|
describe('replace bundle references', () => {
|
|
7
9
|
it('Query params and named pipeline, relative', () => {
|
|
10
|
+
// $FlowFixMe
|
|
8
11
|
let fromBundle: NamedBundle = {
|
|
9
12
|
filePath: '/user/dist/reformat.html',
|
|
10
13
|
name: 'reformat.html',
|
|
14
|
+
// $FlowFixMe
|
|
11
15
|
target: {
|
|
12
16
|
distDir: '/user/dist',
|
|
13
17
|
publicUrl: '/',
|
|
14
18
|
},
|
|
15
19
|
};
|
|
16
20
|
|
|
21
|
+
// $FlowFixMe
|
|
17
22
|
let toBundle: NamedBundle = {
|
|
18
23
|
filePath:
|
|
19
24
|
'/user/dist/image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
|
|
20
25
|
name: 'image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
|
|
26
|
+
// $FlowFixMe
|
|
21
27
|
target: {
|
|
22
28
|
distDir: '/user/dist',
|
|
23
29
|
publicUrl: '/',
|
|
24
30
|
},
|
|
25
31
|
};
|
|
26
32
|
|
|
33
|
+
// $FlowFixMe
|
|
27
34
|
let dependency: Dependency = {
|
|
28
35
|
id: '074b36596e3147e900a8ad17ceb5c90b',
|
|
29
36
|
specifier: 'url:./image.jpg?as=webp',
|
|
@@ -45,25 +52,30 @@ describe('replace bundle references', () => {
|
|
|
45
52
|
});
|
|
46
53
|
|
|
47
54
|
it('Query params and named pipeline, absolute', () => {
|
|
55
|
+
// $FlowFixMe
|
|
48
56
|
let fromBundle: NamedBundle = {
|
|
49
57
|
filePath: '/user/dist/reformat.html',
|
|
50
58
|
name: 'reformat.html',
|
|
59
|
+
// $FlowFixMe
|
|
51
60
|
target: {
|
|
52
61
|
distDir: '/user/dist',
|
|
53
62
|
publicUrl: '/',
|
|
54
63
|
},
|
|
55
64
|
};
|
|
56
65
|
|
|
66
|
+
// $FlowFixMe
|
|
57
67
|
let toBundle: NamedBundle = {
|
|
58
68
|
filePath:
|
|
59
69
|
'/user/dist/image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
|
|
60
70
|
name: 'image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
|
|
71
|
+
// $FlowFixMe
|
|
61
72
|
target: {
|
|
62
73
|
distDir: '/user/dist',
|
|
63
74
|
publicUrl: '/',
|
|
64
75
|
},
|
|
65
76
|
};
|
|
66
77
|
|
|
78
|
+
// $FlowFixMe
|
|
67
79
|
let dependency: Dependency = {
|
|
68
80
|
id: '074b36596e3147e900a8ad17ceb5c90b',
|
|
69
81
|
specifier: 'url:./image.jpg?as=webp',
|
|
@@ -85,25 +97,30 @@ describe('replace bundle references', () => {
|
|
|
85
97
|
});
|
|
86
98
|
|
|
87
99
|
it('Custom Public URL', () => {
|
|
100
|
+
// $FlowFixMe
|
|
88
101
|
let fromBundle: NamedBundle = {
|
|
89
102
|
filePath: '/user/dist/reformat.html',
|
|
90
103
|
name: 'reformat.html',
|
|
104
|
+
// $FlowFixMe
|
|
91
105
|
target: {
|
|
92
106
|
distDir: '/user/dist',
|
|
93
107
|
publicUrl: 'https://test.com/static',
|
|
94
108
|
},
|
|
95
109
|
};
|
|
96
110
|
|
|
111
|
+
// $FlowFixMe
|
|
97
112
|
let toBundle: NamedBundle = {
|
|
98
113
|
filePath:
|
|
99
114
|
'/user/dist/image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
|
|
100
115
|
name: 'image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
|
|
116
|
+
// $FlowFixMe
|
|
101
117
|
target: {
|
|
102
118
|
distDir: '/user/dist',
|
|
103
119
|
publicUrl: 'https://test.com/static',
|
|
104
120
|
},
|
|
105
121
|
};
|
|
106
122
|
|
|
123
|
+
// $FlowFixMe
|
|
107
124
|
let dependency: Dependency = {
|
|
108
125
|
id: '074b36596e314797845a8ad17ceb5c9b',
|
|
109
126
|
specifier: './image.jpg',
|
|
@@ -125,25 +142,30 @@ describe('replace bundle references', () => {
|
|
|
125
142
|
});
|
|
126
143
|
|
|
127
144
|
it('Relative with folders in between', () => {
|
|
145
|
+
// $FlowFixMe
|
|
128
146
|
let fromBundle: NamedBundle = {
|
|
129
147
|
filePath: '/user/dist/reformat.html',
|
|
130
148
|
name: 'reformat.html',
|
|
149
|
+
// $FlowFixMe
|
|
131
150
|
target: {
|
|
132
151
|
distDir: '/user/dist',
|
|
133
152
|
publicUrl: 'https://test.com/static',
|
|
134
153
|
},
|
|
135
154
|
};
|
|
136
155
|
|
|
156
|
+
// $FlowFixMe
|
|
137
157
|
let toBundle: NamedBundle = {
|
|
138
158
|
filePath:
|
|
139
159
|
'/user/dist/assets/image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
|
|
140
160
|
name: 'image.HASH_REF_87f9d66c16c2216ccc7e5664cf089305.webp',
|
|
161
|
+
// $FlowFixMe
|
|
141
162
|
target: {
|
|
142
163
|
distDir: '/user/dist/assets',
|
|
143
164
|
publicUrl: 'https://test.com/static',
|
|
144
165
|
},
|
|
145
166
|
};
|
|
146
167
|
|
|
168
|
+
// $FlowFixMe
|
|
147
169
|
let dependency: Dependency = {
|
|
148
170
|
id: '074b36596e3147e900a8ad17ceb5c90b',
|
|
149
171
|
specifier: 'url:./image.jpg?as=webp',
|
|
@@ -165,24 +187,29 @@ describe('replace bundle references', () => {
|
|
|
165
187
|
});
|
|
166
188
|
|
|
167
189
|
it('should work with bundle names with colons, relative', () => {
|
|
190
|
+
// $FlowFixMe
|
|
168
191
|
let fromBundle: NamedBundle = {
|
|
169
192
|
filePath: '/user/dist/reformat.html',
|
|
170
193
|
name: 'reformat.html',
|
|
194
|
+
// $FlowFixMe
|
|
171
195
|
target: {
|
|
172
196
|
distDir: '/user/dist',
|
|
173
197
|
publicUrl: '/',
|
|
174
198
|
},
|
|
175
199
|
};
|
|
176
200
|
|
|
201
|
+
// $FlowFixMe
|
|
177
202
|
let toBundle: NamedBundle = {
|
|
178
203
|
filePath: '/user/dist/a:b:c.html',
|
|
179
204
|
name: 'a:b:c.html',
|
|
205
|
+
// $FlowFixMe
|
|
180
206
|
target: {
|
|
181
207
|
distDir: '/user/dist',
|
|
182
208
|
publicUrl: '/',
|
|
183
209
|
},
|
|
184
210
|
};
|
|
185
211
|
|
|
212
|
+
// $FlowFixMe
|
|
186
213
|
let dependency: Dependency = {
|
|
187
214
|
id: '074b36596e3147e900a8ad17ceb5c90b',
|
|
188
215
|
specifier: './a:b:c.html',
|
|
@@ -200,24 +227,29 @@ describe('replace bundle references', () => {
|
|
|
200
227
|
});
|
|
201
228
|
|
|
202
229
|
it('should work with bundle names with colons, absolute', () => {
|
|
230
|
+
// $FlowFixMe
|
|
203
231
|
let fromBundle: NamedBundle = {
|
|
204
232
|
filePath: '/user/dist/reformat.html',
|
|
205
233
|
name: 'reformat.html',
|
|
234
|
+
// $FlowFixMe
|
|
206
235
|
target: {
|
|
207
236
|
distDir: '/user/dist',
|
|
208
237
|
publicUrl: '/',
|
|
209
238
|
},
|
|
210
239
|
};
|
|
211
240
|
|
|
241
|
+
// $FlowFixMe
|
|
212
242
|
let toBundle: NamedBundle = {
|
|
213
243
|
filePath: '/user/dist/a:b:c.html',
|
|
214
244
|
name: 'a:b:c.html',
|
|
245
|
+
// $FlowFixMe
|
|
215
246
|
target: {
|
|
216
247
|
distDir: '/user/dist',
|
|
217
248
|
publicUrl: '/',
|
|
218
249
|
},
|
|
219
250
|
};
|
|
220
251
|
|
|
252
|
+
// $FlowFixMe
|
|
221
253
|
let dependency: Dependency = {
|
|
222
254
|
id: '074b36596e3147e900a8ad17ceb5c90b',
|
|
223
255
|
specifier: './a:b:c.html',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
1
3
|
import assert from 'assert';
|
|
2
4
|
import sinon from 'sinon';
|
|
3
5
|
import throttle from '../src/throttle';
|
|
@@ -31,7 +33,7 @@ describe('throttle', () => {
|
|
|
31
33
|
});
|
|
32
34
|
|
|
33
35
|
it('preserves the `this` when throttled functions are invoked', () => {
|
|
34
|
-
let result
|
|
36
|
+
let result;
|
|
35
37
|
let throttled = throttle(function () {
|
|
36
38
|
result = this.bar;
|
|
37
39
|
}, 100);
|
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright (c) 2024 Atlassian US., Inc.
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
package/lib/DefaultMap.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare class DefaultMap<K, V> extends Map<K, V> {
|
|
2
|
-
_getDefault: (arg1: K) => V;
|
|
3
|
-
constructor(getDefault: (arg1: K) => V, entries?: Iterable<[K, V]>);
|
|
4
|
-
get(key: K): V;
|
|
5
|
-
}
|
|
6
|
-
interface Key {
|
|
7
|
-
}
|
|
8
|
-
export declare class DefaultWeakMap<K extends Key, V> extends WeakMap<K, V> {
|
|
9
|
-
_getDefault: (arg1: K) => V;
|
|
10
|
-
constructor(getDefault: (arg1: K) => V, entries?: Iterable<[K, V]>);
|
|
11
|
-
get(key: K): V;
|
|
12
|
-
}
|
|
13
|
-
export {};
|