@marko/vite 2.3.10 → 2.3.11
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/README.md +20 -0
- package/dist/chunk-DCBMHGK4.mjs +20 -0
- package/dist/chunk-FCWFM7VD.mjs +63 -0
- package/dist/chunk-KIYHBIE6.mjs +0 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +10 -30
- package/dist/index.mjs +16 -30
- package/dist/store/file-store.d.ts +11 -0
- package/dist/store/file-store.js +93 -0
- package/dist/store/file-store.mjs +6 -0
- package/dist/store/index.d.ts +3 -0
- package/dist/store/index.js +41 -0
- package/dist/store/index.mjs +11 -0
- package/dist/store/memory-store.d.ts +8 -0
- package/dist/store/memory-store.js +40 -0
- package/dist/store/memory-store.mjs +6 -0
- package/dist/store/types.d.ts +5 -0
- package/dist/store/types.js +16 -0
- package/dist/store/types.mjs +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,6 +118,26 @@ marko({ runtimeId: "MY_MARKO_RUNTIME_ID" });
|
|
|
118
118
|
|
|
119
119
|
Set this to `false` to opt out of [linked mode](#linked-mode). When this is false, the plugin will only handle resolving and transforming `.marko` files.
|
|
120
120
|
|
|
121
|
+
### options.store
|
|
122
|
+
|
|
123
|
+
Storage mechanism to preserve data between SSR and client builds when building in linked mode. Two implementations are available:
|
|
124
|
+
|
|
125
|
+
- FileStore _(default)_
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
import { FileStore } from "@marko/vite";
|
|
129
|
+
const store = new FileStore();
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Reads/writes data to the file system. Use this when running the SSR and client builds in seperate processes such as when using Vite from the command line or npm scripts.
|
|
133
|
+
|
|
134
|
+
- MemoryStore
|
|
135
|
+
```js
|
|
136
|
+
import { MemoryStore } from "@marko/vite";
|
|
137
|
+
const store = new MemoryStore();
|
|
138
|
+
```
|
|
139
|
+
Reads/writes data to memory. This option can be used when building with Vite programatically.
|
|
140
|
+
|
|
121
141
|
## Code of Conduct
|
|
122
142
|
|
|
123
143
|
This project adheres to the [eBay Code of Conduct](./.github/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/store/memory-store.ts
|
|
2
|
+
var MemoryStore = class {
|
|
3
|
+
_store;
|
|
4
|
+
constructor() {
|
|
5
|
+
this._store = /* @__PURE__ */ new Map();
|
|
6
|
+
}
|
|
7
|
+
async has(key) {
|
|
8
|
+
return Promise.resolve(this._store.has(key));
|
|
9
|
+
}
|
|
10
|
+
async get(key) {
|
|
11
|
+
return Promise.resolve(this._store.get(key));
|
|
12
|
+
}
|
|
13
|
+
async set(key, value) {
|
|
14
|
+
this._store.set(key, value);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
MemoryStore
|
|
20
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/store/file-store.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import os from "os";
|
|
5
|
+
var FileStore = class {
|
|
6
|
+
_id;
|
|
7
|
+
_temp;
|
|
8
|
+
_cache;
|
|
9
|
+
constructor(id) {
|
|
10
|
+
this._id = id;
|
|
11
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
12
|
+
}
|
|
13
|
+
async _getKeyPath(key) {
|
|
14
|
+
this._temp ?? (this._temp = getTempDir(this._id));
|
|
15
|
+
return path.join(await this._temp, key);
|
|
16
|
+
}
|
|
17
|
+
async has(key) {
|
|
18
|
+
if (!this._cache.has(key)) {
|
|
19
|
+
const path2 = await this._getKeyPath(key);
|
|
20
|
+
try {
|
|
21
|
+
await fs.promises.access(path2);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
async get(key) {
|
|
29
|
+
let value = this._cache.get(key);
|
|
30
|
+
if (value === void 0) {
|
|
31
|
+
const path2 = await this._getKeyPath(key);
|
|
32
|
+
try {
|
|
33
|
+
value = await fs.promises.readFile(path2, "utf-8");
|
|
34
|
+
} catch (e) {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
this._cache.set(key, value);
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
async set(key, value) {
|
|
42
|
+
this._cache.set(key, value);
|
|
43
|
+
const path2 = await this._getKeyPath(key);
|
|
44
|
+
await fs.promises.writeFile(path2, value, "utf-8");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
async function getTempDir(id) {
|
|
48
|
+
const dir = path.join(os.tmpdir(), id);
|
|
49
|
+
try {
|
|
50
|
+
const stat = await fs.promises.stat(dir);
|
|
51
|
+
if (stat.isDirectory()) {
|
|
52
|
+
return dir;
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
await fs.promises.mkdir(dir);
|
|
56
|
+
return dir;
|
|
57
|
+
}
|
|
58
|
+
throw new Error("Unable to create temp directory");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
FileStore
|
|
63
|
+
};
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type * as vite from "vite";
|
|
2
2
|
import type * as Compiler from "@marko/compiler";
|
|
3
|
+
import { BuildStore } from "./store";
|
|
4
|
+
export * from "./store";
|
|
5
|
+
export type { BuildStore } from "./store";
|
|
3
6
|
export interface Options {
|
|
4
7
|
linked?: boolean;
|
|
5
8
|
compiler?: string;
|
|
6
9
|
runtimeId?: string;
|
|
7
10
|
translator?: string;
|
|
8
11
|
babelConfig?: Compiler.Config["babelConfig"];
|
|
12
|
+
store?: BuildStore;
|
|
9
13
|
}
|
|
10
14
|
export default function markoPlugin(opts?: Options): vite.Plugin[];
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
21
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
22
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
23
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -31,7 +32,6 @@ __export(src_exports, {
|
|
|
31
32
|
default: () => markoPlugin
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(src_exports);
|
|
34
|
-
var import_os = __toESM(require("os"));
|
|
35
35
|
var import_fs = __toESM(require("fs"));
|
|
36
36
|
var import_path = __toESM(require("path"));
|
|
37
37
|
var import_crypto = __toESM(require("crypto"));
|
|
@@ -41,6 +41,8 @@ var import_relative_import_path = require("relative-import-path");
|
|
|
41
41
|
var import_server_entry_template = __toESM(require("./server-entry-template"));
|
|
42
42
|
var import_manifest_generator = require("./manifest-generator");
|
|
43
43
|
var import_esbuild_plugin = __toESM(require("./esbuild-plugin"));
|
|
44
|
+
var import_store = require("./store");
|
|
45
|
+
__reExport(src_exports, require("./store"), module.exports);
|
|
44
46
|
const import_meta = {};
|
|
45
47
|
const normalizePath = import_path.default.sep === "\\" ? (id) => id.replace(/\\/g, "/") : (id) => id;
|
|
46
48
|
const virtualFiles = /* @__PURE__ */ new Map();
|
|
@@ -48,12 +50,12 @@ const queryReg = /\?marko-.+$/;
|
|
|
48
50
|
const browserEntryQuery = "?marko-browser-entry";
|
|
49
51
|
const serverEntryQuery = "?marko-server-entry";
|
|
50
52
|
const virtualFileQuery = "?marko-virtual";
|
|
53
|
+
const manifestFileName = "manifest.json";
|
|
51
54
|
const markoExt = ".marko";
|
|
52
55
|
const htmlExt = ".html";
|
|
53
56
|
const resolveOpts = { skipSelf: true };
|
|
54
57
|
const cache = /* @__PURE__ */ new Map();
|
|
55
58
|
const thisFile = typeof __filename === "string" ? __filename : (0, import_url.fileURLToPath)(import_meta.url);
|
|
56
|
-
let tempDir;
|
|
57
59
|
function markoPlugin(opts = {}) {
|
|
58
60
|
var _a;
|
|
59
61
|
let compiler;
|
|
@@ -111,6 +113,7 @@ function markoPlugin(opts = {}) {
|
|
|
111
113
|
let devServer;
|
|
112
114
|
let registeredTag = false;
|
|
113
115
|
let serverManifest;
|
|
116
|
+
let store;
|
|
114
117
|
const entrySources = /* @__PURE__ */ new Map();
|
|
115
118
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
116
119
|
const transformOptionalFiles = /* @__PURE__ */ new Map();
|
|
@@ -125,6 +128,9 @@ function markoPlugin(opts = {}) {
|
|
|
125
128
|
devEntryFile = import_path.default.join(root, "index.html");
|
|
126
129
|
isBuild = env.command === "build";
|
|
127
130
|
isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
|
|
131
|
+
store = opts.store || new import_store.FileStore(
|
|
132
|
+
`marko-vite-${import_crypto.default.createHash("SHA1").update(root).digest("hex")}`
|
|
133
|
+
);
|
|
128
134
|
if (linked && !registeredTag) {
|
|
129
135
|
const transformer = import_path.default.resolve(
|
|
130
136
|
thisFile,
|
|
@@ -204,11 +210,9 @@ function markoPlugin(opts = {}) {
|
|
|
204
210
|
},
|
|
205
211
|
async buildStart(inputOptions) {
|
|
206
212
|
if (isBuild && linked && !isSSRBuild) {
|
|
207
|
-
const serverMetaFile = await getServerManifestFile(root);
|
|
208
|
-
this.addWatchFile(serverMetaFile);
|
|
209
213
|
try {
|
|
210
214
|
serverManifest = JSON.parse(
|
|
211
|
-
await
|
|
215
|
+
await store.get(manifestFileName)
|
|
212
216
|
);
|
|
213
217
|
inputOptions.input = toHTMLEntries(root, serverManifest.entries);
|
|
214
218
|
for (const entry in serverManifest.entrySources) {
|
|
@@ -392,10 +396,7 @@ if (import.meta.hot) import.meta.hot.accept();`;
|
|
|
392
396
|
}
|
|
393
397
|
}
|
|
394
398
|
}
|
|
395
|
-
await
|
|
396
|
-
await getServerManifestFile(root),
|
|
397
|
-
JSON.stringify(serverManifest)
|
|
398
|
-
);
|
|
399
|
+
await store.set(manifestFileName, JSON.stringify(serverManifest));
|
|
399
400
|
} else {
|
|
400
401
|
const browserManifest = {};
|
|
401
402
|
for (const entryId in serverManifest.entries) {
|
|
@@ -448,27 +449,6 @@ function toHTMLEntries(root, serverEntries) {
|
|
|
448
449
|
}
|
|
449
450
|
return result;
|
|
450
451
|
}
|
|
451
|
-
async function getServerManifestFile(root) {
|
|
452
|
-
return import_path.default.join(await getTempDir(root), "manifest.json");
|
|
453
|
-
}
|
|
454
|
-
function getTempDir(root) {
|
|
455
|
-
return tempDir || (tempDir = (async () => {
|
|
456
|
-
const dir = import_path.default.join(
|
|
457
|
-
import_os.default.tmpdir(),
|
|
458
|
-
`marko-vite-${import_crypto.default.createHash("SHA1").update(root).digest("hex")}`
|
|
459
|
-
);
|
|
460
|
-
try {
|
|
461
|
-
const stat = await import_fs.default.promises.stat(dir);
|
|
462
|
-
if (stat.isDirectory()) {
|
|
463
|
-
return dir;
|
|
464
|
-
}
|
|
465
|
-
} catch {
|
|
466
|
-
await import_fs.default.promises.mkdir(dir);
|
|
467
|
-
return dir;
|
|
468
|
-
}
|
|
469
|
-
throw new Error("Unable to create temp directory");
|
|
470
|
-
})());
|
|
471
|
-
}
|
|
472
452
|
function toEntryId(id) {
|
|
473
453
|
const lastSepIndex = id.lastIndexOf(import_path.default.sep);
|
|
474
454
|
let name = id.slice(lastSepIndex + 1, id.indexOf(".", lastSepIndex));
|
package/dist/index.mjs
CHANGED
|
@@ -9,9 +9,15 @@ import "./chunk-VL2HLMVE.mjs";
|
|
|
9
9
|
import {
|
|
10
10
|
server_entry_template_default
|
|
11
11
|
} from "./chunk-HWRQJHCN.mjs";
|
|
12
|
+
import "./chunk-KIYHBIE6.mjs";
|
|
13
|
+
import {
|
|
14
|
+
MemoryStore
|
|
15
|
+
} from "./chunk-DCBMHGK4.mjs";
|
|
16
|
+
import {
|
|
17
|
+
FileStore
|
|
18
|
+
} from "./chunk-FCWFM7VD.mjs";
|
|
12
19
|
|
|
13
20
|
// src/index.ts
|
|
14
|
-
import os from "os";
|
|
15
21
|
import fs from "fs";
|
|
16
22
|
import path from "path";
|
|
17
23
|
import crypto from "crypto";
|
|
@@ -24,12 +30,12 @@ var queryReg = /\?marko-.+$/;
|
|
|
24
30
|
var browserEntryQuery = "?marko-browser-entry";
|
|
25
31
|
var serverEntryQuery = "?marko-server-entry";
|
|
26
32
|
var virtualFileQuery = "?marko-virtual";
|
|
33
|
+
var manifestFileName = "manifest.json";
|
|
27
34
|
var markoExt = ".marko";
|
|
28
35
|
var htmlExt = ".html";
|
|
29
36
|
var resolveOpts = { skipSelf: true };
|
|
30
37
|
var cache = /* @__PURE__ */ new Map();
|
|
31
38
|
var thisFile = typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
|
|
32
|
-
var tempDir;
|
|
33
39
|
function markoPlugin(opts = {}) {
|
|
34
40
|
var _a;
|
|
35
41
|
let compiler;
|
|
@@ -87,6 +93,7 @@ function markoPlugin(opts = {}) {
|
|
|
87
93
|
let devServer;
|
|
88
94
|
let registeredTag = false;
|
|
89
95
|
let serverManifest;
|
|
96
|
+
let store;
|
|
90
97
|
const entrySources = /* @__PURE__ */ new Map();
|
|
91
98
|
const transformWatchFiles = /* @__PURE__ */ new Map();
|
|
92
99
|
const transformOptionalFiles = /* @__PURE__ */ new Map();
|
|
@@ -101,6 +108,9 @@ function markoPlugin(opts = {}) {
|
|
|
101
108
|
devEntryFile = path.join(root, "index.html");
|
|
102
109
|
isBuild = env.command === "build";
|
|
103
110
|
isSSRBuild = isBuild && linked && Boolean(config.build.ssr);
|
|
111
|
+
store = opts.store || new FileStore(
|
|
112
|
+
`marko-vite-${crypto.createHash("SHA1").update(root).digest("hex")}`
|
|
113
|
+
);
|
|
104
114
|
if (linked && !registeredTag) {
|
|
105
115
|
const transformer = path.resolve(
|
|
106
116
|
thisFile,
|
|
@@ -180,11 +190,9 @@ function markoPlugin(opts = {}) {
|
|
|
180
190
|
},
|
|
181
191
|
async buildStart(inputOptions) {
|
|
182
192
|
if (isBuild && linked && !isSSRBuild) {
|
|
183
|
-
const serverMetaFile = await getServerManifestFile(root);
|
|
184
|
-
this.addWatchFile(serverMetaFile);
|
|
185
193
|
try {
|
|
186
194
|
serverManifest = JSON.parse(
|
|
187
|
-
await
|
|
195
|
+
await store.get(manifestFileName)
|
|
188
196
|
);
|
|
189
197
|
inputOptions.input = toHTMLEntries(root, serverManifest.entries);
|
|
190
198
|
for (const entry in serverManifest.entrySources) {
|
|
@@ -368,10 +376,7 @@ if (import.meta.hot) import.meta.hot.accept();`;
|
|
|
368
376
|
}
|
|
369
377
|
}
|
|
370
378
|
}
|
|
371
|
-
await
|
|
372
|
-
await getServerManifestFile(root),
|
|
373
|
-
JSON.stringify(serverManifest)
|
|
374
|
-
);
|
|
379
|
+
await store.set(manifestFileName, JSON.stringify(serverManifest));
|
|
375
380
|
} else {
|
|
376
381
|
const browserManifest = {};
|
|
377
382
|
for (const entryId in serverManifest.entries) {
|
|
@@ -424,27 +429,6 @@ function toHTMLEntries(root, serverEntries) {
|
|
|
424
429
|
}
|
|
425
430
|
return result;
|
|
426
431
|
}
|
|
427
|
-
async function getServerManifestFile(root) {
|
|
428
|
-
return path.join(await getTempDir(root), "manifest.json");
|
|
429
|
-
}
|
|
430
|
-
function getTempDir(root) {
|
|
431
|
-
return tempDir || (tempDir = (async () => {
|
|
432
|
-
const dir = path.join(
|
|
433
|
-
os.tmpdir(),
|
|
434
|
-
`marko-vite-${crypto.createHash("SHA1").update(root).digest("hex")}`
|
|
435
|
-
);
|
|
436
|
-
try {
|
|
437
|
-
const stat = await fs.promises.stat(dir);
|
|
438
|
-
if (stat.isDirectory()) {
|
|
439
|
-
return dir;
|
|
440
|
-
}
|
|
441
|
-
} catch {
|
|
442
|
-
await fs.promises.mkdir(dir);
|
|
443
|
-
return dir;
|
|
444
|
-
}
|
|
445
|
-
throw new Error("Unable to create temp directory");
|
|
446
|
-
})());
|
|
447
|
-
}
|
|
448
432
|
function toEntryId(id) {
|
|
449
433
|
const lastSepIndex = id.lastIndexOf(path.sep);
|
|
450
434
|
let name = id.slice(lastSepIndex + 1, id.indexOf(".", lastSepIndex));
|
|
@@ -480,5 +464,7 @@ function isEmpty(obj) {
|
|
|
480
464
|
return true;
|
|
481
465
|
}
|
|
482
466
|
export {
|
|
467
|
+
FileStore,
|
|
468
|
+
MemoryStore,
|
|
483
469
|
markoPlugin as default
|
|
484
470
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BuildStore } from "./types";
|
|
2
|
+
export default class FileStore implements BuildStore {
|
|
3
|
+
_id: string;
|
|
4
|
+
_temp: Promise<string> | undefined;
|
|
5
|
+
_cache: Map<string, string>;
|
|
6
|
+
constructor(id: string);
|
|
7
|
+
_getKeyPath(key: string): Promise<string>;
|
|
8
|
+
has(key: string): Promise<boolean>;
|
|
9
|
+
get(key: string): Promise<string | undefined>;
|
|
10
|
+
set(key: string, value: string): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var file_store_exports = {};
|
|
30
|
+
__export(file_store_exports, {
|
|
31
|
+
default: () => FileStore
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(file_store_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
var import_os = __toESM(require("os"));
|
|
37
|
+
class FileStore {
|
|
38
|
+
_id;
|
|
39
|
+
_temp;
|
|
40
|
+
_cache;
|
|
41
|
+
constructor(id) {
|
|
42
|
+
this._id = id;
|
|
43
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
44
|
+
}
|
|
45
|
+
async _getKeyPath(key) {
|
|
46
|
+
this._temp ?? (this._temp = getTempDir(this._id));
|
|
47
|
+
return import_path.default.join(await this._temp, key);
|
|
48
|
+
}
|
|
49
|
+
async has(key) {
|
|
50
|
+
if (!this._cache.has(key)) {
|
|
51
|
+
const path2 = await this._getKeyPath(key);
|
|
52
|
+
try {
|
|
53
|
+
await import_fs.default.promises.access(path2);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
async get(key) {
|
|
61
|
+
let value = this._cache.get(key);
|
|
62
|
+
if (value === void 0) {
|
|
63
|
+
const path2 = await this._getKeyPath(key);
|
|
64
|
+
try {
|
|
65
|
+
value = await import_fs.default.promises.readFile(path2, "utf-8");
|
|
66
|
+
} catch (e) {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
this._cache.set(key, value);
|
|
70
|
+
}
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
async set(key, value) {
|
|
74
|
+
this._cache.set(key, value);
|
|
75
|
+
const path2 = await this._getKeyPath(key);
|
|
76
|
+
await import_fs.default.promises.writeFile(path2, value, "utf-8");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function getTempDir(id) {
|
|
80
|
+
const dir = import_path.default.join(import_os.default.tmpdir(), id);
|
|
81
|
+
try {
|
|
82
|
+
const stat = await import_fs.default.promises.stat(dir);
|
|
83
|
+
if (stat.isDirectory()) {
|
|
84
|
+
return dir;
|
|
85
|
+
}
|
|
86
|
+
} catch {
|
|
87
|
+
await import_fs.default.promises.mkdir(dir);
|
|
88
|
+
return dir;
|
|
89
|
+
}
|
|
90
|
+
throw new Error("Unable to create temp directory");
|
|
91
|
+
}
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var store_exports = {};
|
|
30
|
+
__export(store_exports, {
|
|
31
|
+
FileStore: () => import_file_store.default,
|
|
32
|
+
MemoryStore: () => import_memory_store.default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(store_exports);
|
|
35
|
+
var import_file_store = __toESM(require("./file-store"));
|
|
36
|
+
var import_memory_store = __toESM(require("./memory-store"));
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
FileStore,
|
|
40
|
+
MemoryStore
|
|
41
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BuildStore } from "./types";
|
|
2
|
+
export default class MemoryStore implements BuildStore {
|
|
3
|
+
_store: Map<string, string>;
|
|
4
|
+
constructor();
|
|
5
|
+
has(key: string): Promise<boolean>;
|
|
6
|
+
get(key: string): Promise<string | undefined>;
|
|
7
|
+
set(key: string, value: string): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var memory_store_exports = {};
|
|
20
|
+
__export(memory_store_exports, {
|
|
21
|
+
default: () => MemoryStore
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(memory_store_exports);
|
|
24
|
+
class MemoryStore {
|
|
25
|
+
_store;
|
|
26
|
+
constructor() {
|
|
27
|
+
this._store = /* @__PURE__ */ new Map();
|
|
28
|
+
}
|
|
29
|
+
async has(key) {
|
|
30
|
+
return Promise.resolve(this._store.has(key));
|
|
31
|
+
}
|
|
32
|
+
async get(key) {
|
|
33
|
+
return Promise.resolve(this._store.get(key));
|
|
34
|
+
}
|
|
35
|
+
async set(key, value) {
|
|
36
|
+
this._store.set(key, value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
File without changes
|
package/package.json
CHANGED