@atlaspack/cache 2.13.3-dev.53 → 2.13.3-dev.58

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 CHANGED
@@ -1,5 +1,32 @@
1
1
  # @atlaspack/cache
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#512](https://github.com/atlassian-labs/atlaspack/pull/512) [`8f4e6c1`](https://github.com/atlassian-labs/atlaspack/commit/8f4e6c1b0e7c1fd48624afda48c1dcc599f1460f) Thanks [@yamadapc](https://github.com/yamadapc)! - Remove LMDB cache back-end
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`a891d65`](https://github.com/atlassian-labs/atlaspack/commit/a891d652bc4eb3d757d381adf65c5083f706effc), [`d02eab9`](https://github.com/atlassian-labs/atlaspack/commit/d02eab95eb60bf7457e0869af0b773608592c0e6), [`fb87a90`](https://github.com/atlassian-labs/atlaspack/commit/fb87a901973776b33ca4ce530e9d71669a9bd36d), [`7b9e8cf`](https://github.com/atlassian-labs/atlaspack/commit/7b9e8cf29e01a98e72e46b2b2fb74ccc514f4463)]:
12
+ - @atlaspack/rust@3.1.0
13
+ - @atlaspack/fs@2.14.2
14
+ - @atlaspack/utils@2.14.2
15
+ - @atlaspack/logger@2.14.2
16
+
17
+ ## 2.13.3
18
+
19
+ ### Patch Changes
20
+
21
+ - [#478](https://github.com/atlassian-labs/atlaspack/pull/478) [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b) Thanks [@yamadapc](https://github.com/yamadapc)! - The first attempt at Version Packages didn't include the built artifacts.
22
+ This has hopefully been fixed, so this change will force those packages to re-release.
23
+ - Updated dependencies [[`80bd57b`](https://github.com/atlassian-labs/atlaspack/commit/80bd57b9f9e966563957dee0780d956a682eb2d4), [`ae70b81`](https://github.com/atlassian-labs/atlaspack/commit/ae70b810384cf58f9c57d341ab4c925c7bb2060c), [`ce13d5e`](https://github.com/atlassian-labs/atlaspack/commit/ce13d5e885d55518ee6318e7a72e3a6e4e5126f2), [`c0a61a9`](https://github.com/atlassian-labs/atlaspack/commit/c0a61a92405b6830fe39cc17622cc2e97bf02dd7), [`cb35e7d`](https://github.com/atlassian-labs/atlaspack/commit/cb35e7d2b90b372de8401792915f12f410508d24), [`6ec11f1`](https://github.com/atlassian-labs/atlaspack/commit/6ec11f10a9366fb8a9fc0475c7678235056bd80e), [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b)]:
24
+ - @atlaspack/fs@2.14.1
25
+ - @atlaspack/rust@3.0.1
26
+ - @atlaspack/utils@2.14.1
27
+ - @atlaspack/logger@2.14.1
28
+ - @atlaspack/build-cache@2.13.3
29
+
3
30
  ## 2.13.2
4
31
 
5
32
  ### Patch Changes
package/index.d.ts CHANGED
@@ -7,10 +7,6 @@ export const FSCache: {
7
7
  new (cacheDir: FilePath): Cache;
8
8
  };
9
9
 
10
- export const LMDBCache: {
11
- new (cacheDir: FilePath): Cache;
12
- };
13
-
14
10
  export const LMDBLiteCache: {
15
11
  new (cacheDir: FilePath): Cache;
16
12
  };
@@ -98,7 +98,8 @@ class LMDBLiteCache {
98
98
  getNativeRef() {
99
99
  return this.store.lmdb;
100
100
  }
101
- ensure() {
101
+ async ensure() {
102
+ await this.fsCache.ensure();
102
103
  return Promise.resolve();
103
104
  }
104
105
  serialize() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaspack/cache",
3
3
  "description": "Interface for defining caches and file-system, IDB and LMDB implementations.",
4
- "version": "2.13.3-dev.53+75290c6cb",
4
+ "version": "2.13.3-dev.58+304528673",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "type": "commonjs",
7
7
  "publishConfig": {
@@ -23,19 +23,17 @@
23
23
  "check-ts": "tsc --noEmit index.d.ts"
24
24
  },
25
25
  "dependencies": {
26
- "@atlaspack/build-cache": "2.13.3-dev.53+75290c6cb",
27
- "@atlaspack/fs": "2.14.1-dev.53+75290c6cb",
28
- "@atlaspack/logger": "2.14.1-dev.53+75290c6cb",
29
- "@atlaspack/rust": "3.0.1-dev.53+75290c6cb",
30
- "@atlaspack/utils": "2.14.1-dev.53+75290c6cb",
31
- "lmdb": "2.8.5"
26
+ "@atlaspack/build-cache": "2.13.3-dev.58+304528673",
27
+ "@atlaspack/fs": "2.14.1-dev.58+304528673",
28
+ "@atlaspack/logger": "2.14.1-dev.58+304528673",
29
+ "@atlaspack/rust": "3.0.1-dev.58+304528673",
30
+ "@atlaspack/utils": "2.14.1-dev.58+304528673"
32
31
  },
33
32
  "devDependencies": {
34
33
  "idb": "^5.0.8"
35
34
  },
36
35
  "browser": {
37
- "./src/IDBCache.js": "./src/IDBCache.browser.js",
38
- "./src/LMDBCache.js": false
36
+ "./src/IDBCache.js": "./src/IDBCache.browser.js"
39
37
  },
40
- "gitHead": "75290c6cb03e7253ab1f9bfc6859d518a7d313cc"
38
+ "gitHead": "304528673208007ba9e03ec6360fdf99a4945910"
41
39
  }
@@ -63,7 +63,10 @@ export function open(
63
63
  new Lmdb({
64
64
  path: directory,
65
65
  asyncWrites: true,
66
- mapSize: 1024 * 1024 * 1024 * 15,
66
+ mapSize:
67
+ process.env.ATLASPACK_BUILD_ENV === 'test'
68
+ ? 1024 * 1024 * 1024
69
+ : 1024 * 1024 * 1024 * 15,
67
70
  }),
68
71
  );
69
72
  }
@@ -101,7 +104,8 @@ export class LMDBLiteCache implements Cache {
101
104
  return this.store.lmdb;
102
105
  }
103
106
 
104
- ensure(): Promise<void> {
107
+ async ensure(): Promise<void> {
108
+ await this.fsCache.ensure();
105
109
  return Promise.resolve();
106
110
  }
107
111
 
package/src/index.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  export * from './FSCache';
4
4
  export * from './IDBCache';
5
- // export * from './LMDBCache';
6
5
  export * from './LMDBLiteCache';
7
6
 
8
7
  export type {Cache} from './types';
package/lib/LMDBCache.js DELETED
@@ -1,136 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.LMDBCache = void 0;
7
- function _stream() {
8
- const data = _interopRequireDefault(require("stream"));
9
- _stream = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _path() {
15
- const data = _interopRequireDefault(require("path"));
16
- _path = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _util() {
22
- const data = require("util");
23
- _util = function () {
24
- return data;
25
- };
26
- return data;
27
- }
28
- function _buildCache() {
29
- const data = require("@atlaspack/build-cache");
30
- _buildCache = function () {
31
- return data;
32
- };
33
- return data;
34
- }
35
- function _fs() {
36
- const data = require("@atlaspack/fs");
37
- _fs = function () {
38
- return data;
39
- };
40
- return data;
41
- }
42
- function _lmdb() {
43
- const data = _interopRequireDefault(require("lmdb"));
44
- _lmdb = function () {
45
- return data;
46
- };
47
- return data;
48
- }
49
- var _package = _interopRequireDefault(require("../package.json"));
50
- var _FSCache = require("./FSCache");
51
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
52
- // flowlint-next-line untyped-import:off
53
- // $FlowFixMe
54
- const pipeline = (0, _util().promisify)(_stream().default.pipeline);
55
- class LMDBCache {
56
- // $FlowFixMe
57
-
58
- constructor(cacheDir) {
59
- this.fs = new (_fs().NodeFS)();
60
- this.dir = cacheDir;
61
- this.fsCache = new _FSCache.FSCache(this.fs, cacheDir);
62
- this.store = _lmdb().default.open(cacheDir, {
63
- name: 'parcel-cache',
64
- encoding: 'binary',
65
- compression: true
66
- });
67
- }
68
- ensure() {
69
- return Promise.resolve();
70
- }
71
- serialize() {
72
- return {
73
- dir: this.dir
74
- };
75
- }
76
- static deserialize(opts) {
77
- return new LMDBCache(opts.dir);
78
- }
79
- has(key) {
80
- return Promise.resolve(this.store.get(key) != null);
81
- }
82
- get(key) {
83
- let data = this.store.get(key);
84
- if (data == null) {
85
- return Promise.resolve(null);
86
- }
87
- return Promise.resolve((0, _buildCache().deserialize)(data));
88
- }
89
- async set(key, value) {
90
- await this.setBlob(key, (0, _buildCache().serialize)(value));
91
- }
92
- getStream(key) {
93
- return this.fs.createReadStream(_path().default.join(this.dir, key));
94
- }
95
- setStream(key, stream) {
96
- return pipeline(stream, this.fs.createWriteStream(_path().default.join(this.dir, key)));
97
- }
98
- getBlob(key) {
99
- let buffer = this.store.get(key);
100
- return buffer != null ? Promise.resolve(buffer) : Promise.reject(new Error(`Key ${key} not found in cache`));
101
- }
102
- async setBlob(key, contents) {
103
- await this.store.put(key, contents);
104
- }
105
- getBuffer(key) {
106
- return Promise.resolve(this.store.get(key));
107
- }
108
- #getFilePath(key, index) {
109
- return _path().default.join(this.dir, `${key}-${index}`);
110
- }
111
- hasLargeBlob(key) {
112
- return this.fs.exists(this.#getFilePath(key, 0));
113
- }
114
-
115
- // eslint-disable-next-line require-await
116
- async getLargeBlob(key) {
117
- return this.fsCache.getLargeBlob(key);
118
- }
119
-
120
- // eslint-disable-next-line require-await
121
- async setLargeBlob(key, contents, options) {
122
- return this.fsCache.setLargeBlob(key, contents, options);
123
- }
124
- deleteLargeBlob(key) {
125
- return this.fsCache.deleteLargeBlob(key);
126
- }
127
- refresh() {
128
- // Reset the read transaction for the store. This guarantees that
129
- // the next read will see the latest changes to the store.
130
- // Useful in scenarios where reads and writes are multi-threaded.
131
- // See https://github.com/kriszyp/lmdb-js#resetreadtxn-void
132
- this.store.resetReadTxn();
133
- }
134
- }
135
- exports.LMDBCache = LMDBCache;
136
- (0, _buildCache().registerSerializableClass)(`${_package.default.version}:LMDBCache`, LMDBCache);
package/src/LMDBCache.js DELETED
@@ -1,139 +0,0 @@
1
- // @flow strict-local
2
- import type {FilePath} from '@atlaspack/types';
3
- import type {Cache} from './types';
4
- import type {Readable, Writable} from 'stream';
5
-
6
- import stream from 'stream';
7
- import path from 'path';
8
- import {promisify} from 'util';
9
-
10
- import {
11
- deserialize,
12
- registerSerializableClass,
13
- serialize,
14
- } from '@atlaspack/build-cache';
15
- import {NodeFS} from '@atlaspack/fs';
16
- // flowlint-next-line untyped-import:off
17
- import lmdb from 'lmdb';
18
-
19
- // $FlowFixMe
20
- import packageJson from '../package.json';
21
-
22
- import {FSCache} from './FSCache';
23
-
24
- const pipeline: (Readable, Writable) => Promise<void> = promisify(
25
- stream.pipeline,
26
- );
27
-
28
- export class LMDBCache implements Cache {
29
- fs: NodeFS;
30
- dir: FilePath;
31
- // $FlowFixMe
32
- store: any;
33
- fsCache: FSCache;
34
-
35
- constructor(cacheDir: FilePath) {
36
- this.fs = new NodeFS();
37
- this.dir = cacheDir;
38
- this.fsCache = new FSCache(this.fs, cacheDir);
39
-
40
- this.store = lmdb.open(cacheDir, {
41
- name: 'parcel-cache',
42
- encoding: 'binary',
43
- compression: true,
44
- });
45
- }
46
-
47
- ensure(): Promise<void> {
48
- return Promise.resolve();
49
- }
50
-
51
- serialize(): {|dir: FilePath|} {
52
- return {
53
- dir: this.dir,
54
- };
55
- }
56
-
57
- static deserialize(opts: {|dir: FilePath|}): LMDBCache {
58
- return new LMDBCache(opts.dir);
59
- }
60
-
61
- has(key: string): Promise<boolean> {
62
- return Promise.resolve(this.store.get(key) != null);
63
- }
64
-
65
- get<T>(key: string): Promise<?T> {
66
- let data = this.store.get(key);
67
- if (data == null) {
68
- return Promise.resolve(null);
69
- }
70
-
71
- return Promise.resolve(deserialize(data));
72
- }
73
-
74
- async set(key: string, value: mixed): Promise<void> {
75
- await this.setBlob(key, serialize(value));
76
- }
77
-
78
- getStream(key: string): Readable {
79
- return this.fs.createReadStream(path.join(this.dir, key));
80
- }
81
-
82
- setStream(key: string, stream: Readable): Promise<void> {
83
- return pipeline(
84
- stream,
85
- this.fs.createWriteStream(path.join(this.dir, key)),
86
- );
87
- }
88
-
89
- getBlob(key: string): Promise<Buffer> {
90
- let buffer = this.store.get(key);
91
- return buffer != null
92
- ? Promise.resolve(buffer)
93
- : Promise.reject(new Error(`Key ${key} not found in cache`));
94
- }
95
-
96
- async setBlob(key: string, contents: Buffer | string): Promise<void> {
97
- await this.store.put(key, contents);
98
- }
99
-
100
- getBuffer(key: string): Promise<?Buffer> {
101
- return Promise.resolve(this.store.get(key));
102
- }
103
-
104
- #getFilePath(key: string, index: number): string {
105
- return path.join(this.dir, `${key}-${index}`);
106
- }
107
-
108
- hasLargeBlob(key: string): Promise<boolean> {
109
- return this.fs.exists(this.#getFilePath(key, 0));
110
- }
111
-
112
- // eslint-disable-next-line require-await
113
- async getLargeBlob(key: string): Promise<Buffer> {
114
- return this.fsCache.getLargeBlob(key);
115
- }
116
-
117
- // eslint-disable-next-line require-await
118
- async setLargeBlob(
119
- key: string,
120
- contents: Buffer | string,
121
- options?: {|signal?: AbortSignal|},
122
- ): Promise<void> {
123
- return this.fsCache.setLargeBlob(key, contents, options);
124
- }
125
-
126
- deleteLargeBlob(key: string): Promise<void> {
127
- return this.fsCache.deleteLargeBlob(key);
128
- }
129
-
130
- refresh(): void {
131
- // Reset the read transaction for the store. This guarantees that
132
- // the next read will see the latest changes to the store.
133
- // Useful in scenarios where reads and writes are multi-threaded.
134
- // See https://github.com/kriszyp/lmdb-js#resetreadtxn-void
135
- this.store.resetReadTxn();
136
- }
137
- }
138
-
139
- registerSerializableClass(`${packageJson.version}:LMDBCache`, LMDBCache);