@electric-sql/pglite-prepopulatedfs 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/README.md +76 -1
- package/dist/index.cjs +103 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/prepopulatedfs.tgz +0 -0
- package/package.json +15 -14
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
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
|
package/README.md
CHANGED
|
@@ -1,9 +1,84 @@
|
|
|
1
1
|
# pglite-prepopulatedfs
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A pre-populated FS that you can use instead of letting initdb run (which is the default). This can lead to faster startup times because initdb doesn't need to run.
|
|
4
4
|
|
|
5
5
|
Install with:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @electric-sql/pglite-prepopulatedfs
|
|
9
9
|
```
|
|
10
|
+
|
|
11
|
+
This package contains an archive as a static asset that you can access through the `dataDir()` function.
|
|
12
|
+
|
|
13
|
+
:::info
|
|
14
|
+
The prepopulated FS is created during build on our CI and therefore guaranteed to work only for the corresponding version of PGlite from which it was created. If you encounter issues, make sure this package is up to date with your PGlite version.
|
|
15
|
+
:::
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @electric-sql/pglite-prepopulatedfs
|
|
21
|
+
# or
|
|
22
|
+
yarn add @electric-sql/pglite-prepopulatedfs
|
|
23
|
+
# or
|
|
24
|
+
pnpm add @electric-sql/pglite-prepopulatedfs
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { PGlite } from '@electric-sql/pglite'
|
|
31
|
+
import { dataDir } from '@electric-sql/pglite-prepopulatedfs'
|
|
32
|
+
|
|
33
|
+
// Create a PGlite instance with the prepopulated FS
|
|
34
|
+
const pg = await PGlite.create({
|
|
35
|
+
loadDataDir: await dataDir(),
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
As an example, this is useful when you have multiple test, each with its own PGlite instance. Consider the following usage with vitest:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { describe, it, expect, beforeEach } from 'vitest'
|
|
43
|
+
import { PGlite } from '@electric-sql/pglite'
|
|
44
|
+
import { dataDir } from '@electric-sql/pglite-prepopulatedfs'
|
|
45
|
+
|
|
46
|
+
describe('query and exec with different data sizes', () => {
|
|
47
|
+
let pg: PGlite
|
|
48
|
+
|
|
49
|
+
beforeEach(async () => {
|
|
50
|
+
pg = await PGlite.create({
|
|
51
|
+
loadDataDir: await dataDir(),
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
await pg.exec(`
|
|
55
|
+
// setup default data
|
|
56
|
+
`)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
describe('test no. 1', () => {
|
|
60
|
+
...
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
describe('test no. 2', () => {
|
|
64
|
+
...
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
// many more tests here
|
|
68
|
+
})
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Although more bandwidth is needed to download the `@electric-sql/pglite-prepopulatedfs` package, the tests will run faster as PGlite doesn't need to run `initdb` for each one of them.
|
|
72
|
+
|
|
73
|
+
The same applies if your application needs to instantiate PGlite over and over again with a clean slate. You will initialy use more bandwidth but will save on speed in the long-run.
|
|
74
|
+
|
|
75
|
+
## Benchmarking
|
|
76
|
+
|
|
77
|
+
A simple benchmarking is done as part of our automated testing in `packages/pglite-prepopulatedfs/tests/prepopulatedfs.test.ts`.
|
|
78
|
+
|
|
79
|
+
Here is a sample output on an Apple M1:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
initdb duration: prepopulated avg (trimmed) 263.38 ms vs. classic initdb 886.29 ms.
|
|
83
|
+
Speedup: 3.37x
|
|
84
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
dataDir: () => dataDir
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
|
|
37
|
+
// ../../node_modules/.pnpm/tsup@8.3.0_@microsoft+api-extractor@7.47.7_@types+node@20.16.11__postcss@8.4.47_tsx@4.19.2_typescript@5.6.3/node_modules/tsup/assets/cjs_shims.js
|
|
38
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
39
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
40
|
+
|
|
41
|
+
// ../pglite-utils/dist/index.js
|
|
42
|
+
var b = Object.defineProperty;
|
|
43
|
+
var p = (e, s) => {
|
|
44
|
+
for (var t in s) b(e, t, { get: s[t], enumerable: true });
|
|
45
|
+
};
|
|
46
|
+
var f = {};
|
|
47
|
+
p(f, { IN_NODE: () => c, getFsBundle: () => y, instantiateWasm: () => u, startWasmDownload: () => m, toPostgresName: () => h, uuid: () => g });
|
|
48
|
+
var c = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
|
|
49
|
+
var o = /* @__PURE__ */ new Map();
|
|
50
|
+
async function m(e) {
|
|
51
|
+
c || o.has(e) || o.set(e, fetch(e));
|
|
52
|
+
}
|
|
53
|
+
var r = /* @__PURE__ */ new Map();
|
|
54
|
+
async function u(e, s, t) {
|
|
55
|
+
if (t || r.has(s)) {
|
|
56
|
+
let n = t || r.get(s);
|
|
57
|
+
return { instance: await WebAssembly.instantiate(n, e), module: n };
|
|
58
|
+
}
|
|
59
|
+
if (c) {
|
|
60
|
+
let a = await (await import("fs/promises")).readFile(s), { module: i, instance: l } = await WebAssembly.instantiate(a, e);
|
|
61
|
+
return r.set(s, i), { instance: l, module: i };
|
|
62
|
+
} else {
|
|
63
|
+
o.has(s) || o.set(s, fetch(s));
|
|
64
|
+
let n = await o.get(s), { module: a, instance: i } = await WebAssembly.instantiateStreaming(n, e);
|
|
65
|
+
return r.set(s, a), { instance: i, module: a };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function y(e) {
|
|
69
|
+
return c ? (await (await import("fs/promises")).readFile(e)).buffer : (await fetch(e)).arrayBuffer();
|
|
70
|
+
}
|
|
71
|
+
var g = () => {
|
|
72
|
+
if (globalThis.crypto?.randomUUID) return globalThis.crypto.randomUUID();
|
|
73
|
+
let e = new Uint8Array(16);
|
|
74
|
+
if (globalThis.crypto?.getRandomValues) globalThis.crypto.getRandomValues(e);
|
|
75
|
+
else for (let t = 0; t < e.length; t++) e[t] = Math.floor(Math.random() * 256);
|
|
76
|
+
e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
|
|
77
|
+
let s = [];
|
|
78
|
+
return e.forEach((t) => {
|
|
79
|
+
s.push(t.toString(16).padStart(2, "0"));
|
|
80
|
+
}), s.slice(0, 4).join("") + "-" + s.slice(4, 6).join("") + "-" + s.slice(6, 8).join("") + "-" + s.slice(8, 10).join("") + "-" + s.slice(10).join("");
|
|
81
|
+
};
|
|
82
|
+
function h(e) {
|
|
83
|
+
let s;
|
|
84
|
+
return e.startsWith('"') && e.endsWith('"') ? s = e.substring(1, e.length - 1) : s = e.toLowerCase(), s;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/index.ts
|
|
88
|
+
async function dataDir() {
|
|
89
|
+
const moduleUrl = new URL("../release/prepopulatedfs.tgz", importMetaUrl);
|
|
90
|
+
if (f.IN_NODE) {
|
|
91
|
+
const fs = await import("fs/promises");
|
|
92
|
+
const buffer = await fs.readFile(moduleUrl);
|
|
93
|
+
return new Blob([new Uint8Array(buffer)]);
|
|
94
|
+
} else {
|
|
95
|
+
const wasmDownloadPromise = await fetch(moduleUrl);
|
|
96
|
+
return wasmDownloadPromise.blob();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
dataDir
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../../../node_modules/.pnpm/tsup@8.3.0_@microsoft+api-extractor@7.47.7_@types+node@20.16.11__postcss@8.4.47_tsx@4.19.2_typescript@5.6.3/node_modules/tsup/assets/cjs_shims.js","../../pglite-utils/src/utils.ts"],"sourcesContent":["import { pglUtils } from '@electric-sql/pglite-utils'\n\nexport async function dataDir(): Promise<Blob> {\n const moduleUrl = new URL('../release/prepopulatedfs.tgz', import.meta.url)\n if (pglUtils.IN_NODE) {\n const fs = await import('fs/promises')\n const buffer = await fs.readFile(moduleUrl)\n return new Blob([new Uint8Array(buffer)])\n } else {\n const wasmDownloadPromise = await fetch(moduleUrl)\n return wasmDownloadPromise.blob()\n }\n}\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","export const IN_NODE =\n typeof process === 'object' &&\n typeof process.versions === 'object' &&\n typeof process.versions.node === 'string'\n\nconst wasmDownloadPromises = new Map<URL, Promise<Response>>()\n\nexport async function startWasmDownload(url: URL) {\n if (IN_NODE || wasmDownloadPromises.has(url)) {\n return\n }\n wasmDownloadPromises.set(url, fetch(url))\n}\n\n// This is a global cache of the Wasm modules to avoid having to re-download or\n// compile them on subsequent calls.\nconst cachedWasmModules = new Map<URL, WebAssembly.Module>()\n\nexport async function instantiateWasm(\n imports: WebAssembly.Imports,\n moduleUrl: URL,\n module?: WebAssembly.Module,\n): Promise<{\n instance: WebAssembly.Instance\n module: WebAssembly.Module\n}> {\n if (module || cachedWasmModules.has(moduleUrl)) {\n const mod = module || cachedWasmModules.get(moduleUrl)!\n return {\n instance: await WebAssembly.instantiate(mod, imports),\n module: mod,\n }\n }\n if (IN_NODE) {\n const fs = await import('fs/promises')\n const buffer = await fs.readFile(moduleUrl)\n const { module: newModule, instance } = await WebAssembly.instantiate(\n buffer,\n imports,\n )\n cachedWasmModules.set(moduleUrl, newModule)\n return {\n instance,\n module: newModule,\n }\n } else {\n if (!wasmDownloadPromises.has(moduleUrl)) {\n wasmDownloadPromises.set(moduleUrl, fetch(moduleUrl))\n }\n const response = await wasmDownloadPromises.get(moduleUrl)\n const { module: newModule, instance } =\n await WebAssembly.instantiateStreaming(response!, imports)\n cachedWasmModules.set(moduleUrl, newModule)\n return {\n instance,\n module: newModule,\n }\n }\n}\n\nexport async function getFsBundle(fsBundleUrl: URL): Promise<ArrayBuffer> {\n if (IN_NODE) {\n const fs = await import('fs/promises')\n const fileData = await fs.readFile(fsBundleUrl)\n return fileData.buffer\n } else {\n const response = await fetch(fsBundleUrl)\n return response.arrayBuffer()\n }\n}\n\nexport const uuid = (): string => {\n // best case, `crypto.randomUUID` is available\n if (globalThis.crypto?.randomUUID) {\n return globalThis.crypto.randomUUID()\n }\n\n const bytes = new Uint8Array(16)\n\n if (globalThis.crypto?.getRandomValues) {\n // `crypto.getRandomValues` is available even in non-secure contexts\n globalThis.crypto.getRandomValues(bytes)\n } else {\n // fallback to Math.random, if the Crypto API is completely missing\n for (let i = 0; i < bytes.length; i++) {\n bytes[i] = Math.floor(Math.random() * 256)\n }\n }\n\n bytes[6] = (bytes[6] & 0x0f) | 0x40 // Set the 4 most significant bits to 0100\n bytes[8] = (bytes[8] & 0x3f) | 0x80 // Set the 2 most significant bits to 10\n\n const hexValues: string[] = []\n bytes.forEach((byte) => {\n hexValues.push(byte.toString(16).padStart(2, '0'))\n })\n\n return (\n hexValues.slice(0, 4).join('') +\n '-' +\n hexValues.slice(4, 6).join('') +\n '-' +\n hexValues.slice(6, 8).join('') +\n '-' +\n hexValues.slice(8, 10).join('') +\n '-' +\n hexValues.slice(10).join('')\n )\n}\n\n/**\n * Postgresql handles quoted names as CaseSensitive and unquoted as lower case.\n * If input is quoted, returns an unquoted string (same casing)\n * If input is unquoted, returns a lower-case string\n */\nexport function toPostgresName(input: string): string {\n let output\n if (input.startsWith('\"') && input.endsWith('\"')) {\n // Postgres sensitive case\n output = input.substring(1, input.length - 1)\n } else {\n // Postgres case insensitive - all to lower\n output = input.toLowerCase()\n }\n return output\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS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I,iCAAiC,aAAe;AAC1E,MAAI,EAAS,SAAS;AACpB,UAAM,KAAK,MAAM,OAAO,aAAa;AACrC,UAAM,SAAS,MAAM,GAAG,SAAS,SAAS;AAC1C,WAAO,IAAI,KAAK,CAAC,IAAI,WAAW,MAAM,CAAC,CAAC;AAAA,EAC1C,OAAO;AACL,UAAM,sBAAsB,MAAM,MAAM,SAAS;AACjD,WAAO,oBAAoB,KAAK;AAAA,EAClC;AACF;","names":["utils_exports","__export","IN_NODE","getFsBundle","instantiateWasm","startWasmDownload","toPostgresName","uuid","wasmDownloadPromises","url","cachedWasmModules","imports","moduleUrl","module","mod","buffer","newModule","instance","response","fsBundleUrl","bytes","i","hexValues","byte","input","output"]}
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// ../pglite-utils/dist/index.js
|
|
2
|
+
var b = Object.defineProperty;
|
|
3
|
+
var p = (e, s) => {
|
|
4
|
+
for (var t in s) b(e, t, { get: s[t], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
var f = {};
|
|
7
|
+
p(f, { IN_NODE: () => c, getFsBundle: () => y, instantiateWasm: () => u, startWasmDownload: () => m, toPostgresName: () => h, uuid: () => g });
|
|
8
|
+
var c = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string";
|
|
9
|
+
var o = /* @__PURE__ */ new Map();
|
|
10
|
+
async function m(e) {
|
|
11
|
+
c || o.has(e) || o.set(e, fetch(e));
|
|
12
|
+
}
|
|
13
|
+
var r = /* @__PURE__ */ new Map();
|
|
14
|
+
async function u(e, s, t) {
|
|
15
|
+
if (t || r.has(s)) {
|
|
16
|
+
let n = t || r.get(s);
|
|
17
|
+
return { instance: await WebAssembly.instantiate(n, e), module: n };
|
|
18
|
+
}
|
|
19
|
+
if (c) {
|
|
20
|
+
let a = await (await import("fs/promises")).readFile(s), { module: i, instance: l } = await WebAssembly.instantiate(a, e);
|
|
21
|
+
return r.set(s, i), { instance: l, module: i };
|
|
22
|
+
} else {
|
|
23
|
+
o.has(s) || o.set(s, fetch(s));
|
|
24
|
+
let n = await o.get(s), { module: a, instance: i } = await WebAssembly.instantiateStreaming(n, e);
|
|
25
|
+
return r.set(s, a), { instance: i, module: a };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function y(e) {
|
|
29
|
+
return c ? (await (await import("fs/promises")).readFile(e)).buffer : (await fetch(e)).arrayBuffer();
|
|
30
|
+
}
|
|
31
|
+
var g = () => {
|
|
32
|
+
if (globalThis.crypto?.randomUUID) return globalThis.crypto.randomUUID();
|
|
33
|
+
let e = new Uint8Array(16);
|
|
34
|
+
if (globalThis.crypto?.getRandomValues) globalThis.crypto.getRandomValues(e);
|
|
35
|
+
else for (let t = 0; t < e.length; t++) e[t] = Math.floor(Math.random() * 256);
|
|
36
|
+
e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
|
|
37
|
+
let s = [];
|
|
38
|
+
return e.forEach((t) => {
|
|
39
|
+
s.push(t.toString(16).padStart(2, "0"));
|
|
40
|
+
}), s.slice(0, 4).join("") + "-" + s.slice(4, 6).join("") + "-" + s.slice(6, 8).join("") + "-" + s.slice(8, 10).join("") + "-" + s.slice(10).join("");
|
|
41
|
+
};
|
|
42
|
+
function h(e) {
|
|
43
|
+
let s;
|
|
44
|
+
return e.startsWith('"') && e.endsWith('"') ? s = e.substring(1, e.length - 1) : s = e.toLowerCase(), s;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/index.ts
|
|
48
|
+
async function dataDir() {
|
|
49
|
+
const moduleUrl = new URL("../release/prepopulatedfs.tgz", import.meta.url);
|
|
50
|
+
if (f.IN_NODE) {
|
|
51
|
+
const fs = await import("fs/promises");
|
|
52
|
+
const buffer = await fs.readFile(moduleUrl);
|
|
53
|
+
return new Blob([new Uint8Array(buffer)]);
|
|
54
|
+
} else {
|
|
55
|
+
const wasmDownloadPromise = await fetch(moduleUrl);
|
|
56
|
+
return wasmDownloadPromise.blob();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
dataDir
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../pglite-utils/src/utils.ts","../src/index.ts"],"sourcesContent":["export const IN_NODE =\n typeof process === 'object' &&\n typeof process.versions === 'object' &&\n typeof process.versions.node === 'string'\n\nconst wasmDownloadPromises = new Map<URL, Promise<Response>>()\n\nexport async function startWasmDownload(url: URL) {\n if (IN_NODE || wasmDownloadPromises.has(url)) {\n return\n }\n wasmDownloadPromises.set(url, fetch(url))\n}\n\n// This is a global cache of the Wasm modules to avoid having to re-download or\n// compile them on subsequent calls.\nconst cachedWasmModules = new Map<URL, WebAssembly.Module>()\n\nexport async function instantiateWasm(\n imports: WebAssembly.Imports,\n moduleUrl: URL,\n module?: WebAssembly.Module,\n): Promise<{\n instance: WebAssembly.Instance\n module: WebAssembly.Module\n}> {\n if (module || cachedWasmModules.has(moduleUrl)) {\n const mod = module || cachedWasmModules.get(moduleUrl)!\n return {\n instance: await WebAssembly.instantiate(mod, imports),\n module: mod,\n }\n }\n if (IN_NODE) {\n const fs = await import('fs/promises')\n const buffer = await fs.readFile(moduleUrl)\n const { module: newModule, instance } = await WebAssembly.instantiate(\n buffer,\n imports,\n )\n cachedWasmModules.set(moduleUrl, newModule)\n return {\n instance,\n module: newModule,\n }\n } else {\n if (!wasmDownloadPromises.has(moduleUrl)) {\n wasmDownloadPromises.set(moduleUrl, fetch(moduleUrl))\n }\n const response = await wasmDownloadPromises.get(moduleUrl)\n const { module: newModule, instance } =\n await WebAssembly.instantiateStreaming(response!, imports)\n cachedWasmModules.set(moduleUrl, newModule)\n return {\n instance,\n module: newModule,\n }\n }\n}\n\nexport async function getFsBundle(fsBundleUrl: URL): Promise<ArrayBuffer> {\n if (IN_NODE) {\n const fs = await import('fs/promises')\n const fileData = await fs.readFile(fsBundleUrl)\n return fileData.buffer\n } else {\n const response = await fetch(fsBundleUrl)\n return response.arrayBuffer()\n }\n}\n\nexport const uuid = (): string => {\n // best case, `crypto.randomUUID` is available\n if (globalThis.crypto?.randomUUID) {\n return globalThis.crypto.randomUUID()\n }\n\n const bytes = new Uint8Array(16)\n\n if (globalThis.crypto?.getRandomValues) {\n // `crypto.getRandomValues` is available even in non-secure contexts\n globalThis.crypto.getRandomValues(bytes)\n } else {\n // fallback to Math.random, if the Crypto API is completely missing\n for (let i = 0; i < bytes.length; i++) {\n bytes[i] = Math.floor(Math.random() * 256)\n }\n }\n\n bytes[6] = (bytes[6] & 0x0f) | 0x40 // Set the 4 most significant bits to 0100\n bytes[8] = (bytes[8] & 0x3f) | 0x80 // Set the 2 most significant bits to 10\n\n const hexValues: string[] = []\n bytes.forEach((byte) => {\n hexValues.push(byte.toString(16).padStart(2, '0'))\n })\n\n return (\n hexValues.slice(0, 4).join('') +\n '-' +\n hexValues.slice(4, 6).join('') +\n '-' +\n hexValues.slice(6, 8).join('') +\n '-' +\n hexValues.slice(8, 10).join('') +\n '-' +\n hexValues.slice(10).join('')\n )\n}\n\n/**\n * Postgresql handles quoted names as CaseSensitive and unquoted as lower case.\n * If input is quoted, returns an unquoted string (same casing)\n * If input is unquoted, returns a lower-case string\n */\nexport function toPostgresName(input: string): string {\n let output\n if (input.startsWith('\"') && input.endsWith('\"')) {\n // Postgres sensitive case\n output = input.substring(1, input.length - 1)\n } else {\n // Postgres case insensitive - all to lower\n output = input.toLowerCase()\n }\n return output\n}\n","import { pglUtils } from '@electric-sql/pglite-utils'\n\nexport async function dataDir(): Promise<Blob> {\n const moduleUrl = new URL('../release/prepopulatedfs.tgz', import.meta.url)\n if (pglUtils.IN_NODE) {\n const fs = await import('fs/promises')\n const buffer = await fs.readFile(moduleUrl)\n return new Blob([new Uint8Array(buffer)])\n } else {\n const wasmDownloadPromise = await fetch(moduleUrl)\n return wasmDownloadPromise.blob()\n }\n}\n"],"mapp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AAa;AACrC,UAAM,SAAS,MAAM,GAAG,SAAS,SAAS;AAC1C,WAAO,IAAI,KAAK,CAAC,IAAI,WAAW,MAAM,CAAC,CAAC;AAAA,EAC1C,OAAO;AACL,UAAM,sBAAsB,MAAM,MAAM,SAAS;AACjD,WAAO,oBAAoB,KAAK;AAAA,EAClC;AACF;","names":["utils_exports","__export","IN_NODE","getFsBundle","instantiateWasm","startWasmDownload","toPostgresName","uuid","wasmDownloadPromises","url","cachedWasmModules","imports","moduleUrl","module","mod","buffer","newModule","instance","response","fsBundleUrl","bytes","i","hexValues","byte","input","output"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@electric-sql/pglite-prepopulatedfs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Prepopulated filesystem for faster PGlite startups",
|
|
5
5
|
"author": "Electric DB Limited",
|
|
6
6
|
"homepage": "https://pglite.dev",
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"files": [
|
|
25
|
+
"files": [
|
|
26
|
+
"./dist"
|
|
27
|
+
],
|
|
26
28
|
"type": "module",
|
|
27
29
|
"types": "dist/index.d.ts",
|
|
28
30
|
"main": "dist/index.cjs",
|
|
@@ -39,6 +41,15 @@
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@arethetypeswrong/cli": "^0.18.1",
|
|
46
|
+
"@types/emscripten": "^1.41.1",
|
|
47
|
+
"@types/node": "^20.16.11",
|
|
48
|
+
"tsx": "^4.19.2",
|
|
49
|
+
"vitest": "^1.3.1",
|
|
50
|
+
"@electric-sql/pglite": "0.4.3",
|
|
51
|
+
"@electric-sql/pglite-utils": "0.0.1"
|
|
52
|
+
},
|
|
42
53
|
"scripts": {
|
|
43
54
|
"build": "tsx ./scripts/generateFS.ts && tsup && cp release/* ./dist/",
|
|
44
55
|
"check:exports": "attw . --pack --profile node16",
|
|
@@ -46,16 +57,6 @@
|
|
|
46
57
|
"format": "prettier --write ./tests",
|
|
47
58
|
"typecheck": "tsc",
|
|
48
59
|
"stylecheck": "pnpm lint && prettier --check ./tests",
|
|
49
|
-
"test": "vitest"
|
|
50
|
-
"prepublishOnly": "pnpm check:exports"
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@arethetypeswrong/cli": "^0.18.1",
|
|
54
|
-
"@electric-sql/pglite": "workspace:*",
|
|
55
|
-
"@types/emscripten": "^1.41.1",
|
|
56
|
-
"@types/node": "^20.16.11",
|
|
57
|
-
"tsx": "^4.19.2",
|
|
58
|
-
"vitest": "^1.3.1",
|
|
59
|
-
"@electric-sql/pglite-utils": "workspace:*"
|
|
60
|
+
"test": "vitest"
|
|
60
61
|
}
|
|
61
|
-
}
|
|
62
|
+
}
|