@fireproof/core 0.0.0-dev

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.md ADDED
@@ -0,0 +1,232 @@
1
+ The contents of this repository are Copyright (c) corresponding authors and
2
+ contributors, licensed under the `Permissive License Stack` meaning either of:
3
+
4
+ - Apache-2.0 Software License: https://www.apache.org/licenses/LICENSE-2.0
5
+ ([...4tr2kfsq](https://dweb.link/ipfs/bafkreiankqxazcae4onkp436wag2lj3ccso4nawxqkkfckd6cg4tr2kfsq))
6
+
7
+ - MIT Software License: https://opensource.org/licenses/MIT
8
+ ([...vljevcba](https://dweb.link/ipfs/bafkreiepofszg4gfe2gzuhojmksgemsub2h4uy2gewdnr35kswvljevcba))
9
+
10
+ You may not use the contents of this repository except in compliance
11
+ with one of the listed Licenses. For an extended clarification of the
12
+ intent behind the choice of Licensing please refer to
13
+ https://protocol.ai/blog/announcing-the-permissive-license-stack/
14
+
15
+ Unless required by applicable law or agreed to in writing, software
16
+ distributed under the terms listed in this notice is distributed on
17
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
18
+ either express or implied. See each License for the specific language
19
+ governing permissions and limitations under that License.
20
+
21
+ <!--- SPDX-License-Identifier: Apache-2.0 OR MIT -->
22
+
23
+ `SPDX-License-Identifier: Apache-2.0 OR MIT`
24
+
25
+ Verbatim copies of both licenses are included below:
26
+
27
+ <details><summary>Apache-2.0 Software License</summary>
28
+
29
+ ```
30
+ Apache License
31
+ Version 2.0, January 2004
32
+ http://www.apache.org/licenses/
33
+
34
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
35
+
36
+ 1. Definitions.
37
+
38
+ "License" shall mean the terms and conditions for use, reproduction,
39
+ and distribution as defined by Sections 1 through 9 of this document.
40
+
41
+ "Licensor" shall mean the copyright owner or entity authorized by
42
+ the copyright owner that is granting the License.
43
+
44
+ "Legal Entity" shall mean the union of the acting entity and all
45
+ other entities that control, are controlled by, or are under common
46
+ control with that entity. For the purposes of this definition,
47
+ "control" means (i) the power, direct or indirect, to cause the
48
+ direction or management of such entity, whether by contract or
49
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
50
+ outstanding shares, or (iii) beneficial ownership of such entity.
51
+
52
+ "You" (or "Your") shall mean an individual or Legal Entity
53
+ exercising permissions granted by this License.
54
+
55
+ "Source" form shall mean the preferred form for making modifications,
56
+ including but not limited to software source code, documentation
57
+ source, and configuration files.
58
+
59
+ "Object" form shall mean any form resulting from mechanical
60
+ transformation or translation of a Source form, including but
61
+ not limited to compiled object code, generated documentation,
62
+ and conversions to other media types.
63
+
64
+ "Work" shall mean the work of authorship, whether in Source or
65
+ Object form, made available under the License, as indicated by a
66
+ copyright notice that is included in or attached to the work
67
+ (an example is provided in the Appendix below).
68
+
69
+ "Derivative Works" shall mean any work, whether in Source or Object
70
+ form, that is based on (or derived from) the Work and for which the
71
+ editorial revisions, annotations, elaborations, or other modifications
72
+ represent, as a whole, an original work of authorship. For the purposes
73
+ of this License, Derivative Works shall not include works that remain
74
+ separable from, or merely link (or bind by name) to the interfaces of,
75
+ the Work and Derivative Works thereof.
76
+
77
+ "Contribution" shall mean any work of authorship, including
78
+ the original version of the Work and any modifications or additions
79
+ to that Work or Derivative Works thereof, that is intentionally
80
+ submitted to Licensor for inclusion in the Work by the copyright owner
81
+ or by an individual or Legal Entity authorized to submit on behalf of
82
+ the copyright owner. For the purposes of this definition, "submitted"
83
+ means any form of electronic, verbal, or written communication sent
84
+ to the Licensor or its representatives, including but not limited to
85
+ communication on electronic mailing lists, source code control systems,
86
+ and issue tracking systems that are managed by, or on behalf of, the
87
+ Licensor for the purpose of discussing and improving the Work, but
88
+ excluding communication that is conspicuously marked or otherwise
89
+ designated in writing by the copyright owner as "Not a Contribution."
90
+
91
+ "Contributor" shall mean Licensor and any individual or Legal Entity
92
+ on behalf of whom a Contribution has been received by Licensor and
93
+ subsequently incorporated within the Work.
94
+
95
+ 2. Grant of Copyright License. Subject to the terms and conditions of
96
+ this License, each Contributor hereby grants to You a perpetual,
97
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
98
+ copyright license to reproduce, prepare Derivative Works of,
99
+ publicly display, publicly perform, sublicense, and distribute the
100
+ Work and such Derivative Works in Source or Object form.
101
+
102
+ 3. Grant of Patent License. Subject to the terms and conditions of
103
+ this License, each Contributor hereby grants to You a perpetual,
104
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
105
+ (except as stated in this section) patent license to make, have made,
106
+ use, offer to sell, sell, import, and otherwise transfer the Work,
107
+ where such license applies only to those patent claims licensable
108
+ by such Contributor that are necessarily infringed by their
109
+ Contribution(s) alone or by combination of their Contribution(s)
110
+ with the Work to which such Contribution(s) was submitted. If You
111
+ institute patent litigation against any entity (including a
112
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
113
+ or a Contribution incorporated within the Work constitutes direct
114
+ or contributory patent infringement, then any patent licenses
115
+ granted to You under this License for that Work shall terminate
116
+ as of the date such litigation is filed.
117
+
118
+ 4. Redistribution. You may reproduce and distribute copies of the
119
+ Work or Derivative Works thereof in any medium, with or without
120
+ modifications, and in Source or Object form, provided that You
121
+ meet the following conditions:
122
+
123
+ (a) You must give any other recipients of the Work or
124
+ Derivative Works a copy of this License; and
125
+
126
+ (b) You must cause any modified files to carry prominent notices
127
+ stating that You changed the files; and
128
+
129
+ (c) You must retain, in the Source form of any Derivative Works
130
+ that You distribute, all copyright, patent, trademark, and
131
+ attribution notices from the Source form of the Work,
132
+ excluding those notices that do not pertain to any part of
133
+ the Derivative Works; and
134
+
135
+ (d) If the Work includes a "NOTICE" text file as part of its
136
+ distribution, then any Derivative Works that You distribute must
137
+ include a readable copy of the attribution notices contained
138
+ within such NOTICE file, excluding those notices that do not
139
+ pertain to any part of the Derivative Works, in at least one
140
+ of the following places: within a NOTICE text file distributed
141
+ as part of the Derivative Works; within the Source form or
142
+ documentation, if provided along with the Derivative Works; or,
143
+ within a display generated by the Derivative Works, if and
144
+ wherever such third-party notices normally appear. The contents
145
+ of the NOTICE file are for informational purposes only and
146
+ do not modify the License. You may add Your own attribution
147
+ notices within Derivative Works that You distribute, alongside
148
+ or as an addendum to the NOTICE text from the Work, provided
149
+ that such additional attribution notices cannot be construed
150
+ as modifying the License.
151
+
152
+ You may add Your own copyright statement to Your modifications and
153
+ may provide additional or different license terms and conditions
154
+ for use, reproduction, or distribution of Your modifications, or
155
+ for any such Derivative Works as a whole, provided Your use,
156
+ reproduction, and distribution of the Work otherwise complies with
157
+ the conditions stated in this License.
158
+
159
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
160
+ any Contribution intentionally submitted for inclusion in the Work
161
+ by You to the Licensor shall be under the terms and conditions of
162
+ this License, without any additional terms or conditions.
163
+ Notwithstanding the above, nothing herein shall supersede or modify
164
+ the terms of any separate license agreement you may have executed
165
+ with Licensor regarding such Contributions.
166
+
167
+ 6. Trademarks. This License does not grant permission to use the trade
168
+ names, trademarks, service marks, or product names of the Licensor,
169
+ except as required for reasonable and customary use in describing the
170
+ origin of the Work and reproducing the content of the NOTICE file.
171
+
172
+ 7. Disclaimer of Warranty. Unless required by applicable law or
173
+ agreed to in writing, Licensor provides the Work (and each
174
+ Contributor provides its Contributions) on an "AS IS" BASIS,
175
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
176
+ implied, including, without limitation, any warranties or conditions
177
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
178
+ PARTICULAR PURPOSE. You are solely responsible for determining the
179
+ appropriateness of using or redistributing the Work and assume any
180
+ risks associated with Your exercise of permissions under this License.
181
+
182
+ 8. Limitation of Liability. In no event and under no legal theory,
183
+ whether in tort (including negligence), contract, or otherwise,
184
+ unless required by applicable law (such as deliberate and grossly
185
+ negligent acts) or agreed to in writing, shall any Contributor be
186
+ liable to You for damages, including any direct, indirect, special,
187
+ incidental, or consequential damages of any character arising as a
188
+ result of this License or out of the use or inability to use the
189
+ Work (including but not limited to damages for loss of goodwill,
190
+ work stoppage, computer failure or malfunction, or any and all
191
+ other commercial damages or losses), even if such Contributor
192
+ has been advised of the possibility of such damages.
193
+
194
+ 9. Accepting Warranty or Additional Liability. While redistributing
195
+ the Work or Derivative Works thereof, You may choose to offer,
196
+ and charge a fee for, acceptance of support, warranty, indemnity,
197
+ or other liability obligations and/or rights consistent with this
198
+ License. However, in accepting such obligations, You may act only
199
+ on Your own behalf and on Your sole responsibility, not on behalf
200
+ of any other Contributor, and only if You agree to indemnify,
201
+ defend, and hold each Contributor harmless for any liability
202
+ incurred by, or claims asserted against, such Contributor by reason
203
+ of your accepting any such warranty or additional liability.
204
+
205
+ END OF TERMS AND CONDITIONS
206
+ ```
207
+
208
+ </details>
209
+
210
+ <details><summary>MIT Software License</summary>
211
+
212
+ ```
213
+ Permission is hereby granted, free of charge, to any person obtaining a copy
214
+ of this software and associated documentation files (the "Software"), to deal
215
+ in the Software without restriction, including without limitation the rights
216
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
217
+ copies of the Software, and to permit persons to whom the Software is
218
+ furnished to do so, subject to the following conditions:
219
+
220
+ The above copyright notice and this permission notice shall be included in
221
+ all copies or substantial portions of the Software.
222
+
223
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
224
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
225
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
226
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
227
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
228
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
229
+ THE SOFTWARE.
230
+ ```
231
+
232
+ </details>
package/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # <img src="https://fireproof.storage/static/img/flame.svg" alt="Fireproof logo" width="25"> [Fireproof](https://fireproof.storage) realtime database
2
+
3
+ <p align="right">
4
+ <img src="https://img.shields.io/bundlephobia/minzip/%40fireproof%2Fcore" alt="Package size">
5
+ <a href="https://github.com/fireproof-storage/fireproof/actions/workflows/ci.yaml">
6
+ <img src="https://github.com/fireproof-storage/fireproof/actions/workflows/ci.yaml/badge.svg" alt="Build status">
7
+ </a>
8
+ </p>
9
+
10
+ ### No setup: write features first, access your data anywhere
11
+
12
+ Add collaboration to any app with Fireproof. Access data from JavaScript servers and edge functions. Use live queries to update your UI automatically when the database changes. [Connect realtime sync](https://www.npmjs.com/package/@fireproof/connect) and those changes will sync between browsers and backend functions. Apps built this way are multi-player by default.
13
+
14
+ ### JavaScript quick start
15
+
16
+ The document database API will feel familiar. Queries use dynamic indexes, and the database can refresh your UI, as seen in the `db.subscribe` call below, as well as the React liveQuery hook.
17
+
18
+ ```js
19
+ import { fireproof } from "@fireproof/core";
20
+
21
+ const db = fireproof("music-app");
22
+
23
+ await db.put({ _id: "beyonce", name: "Beyoncé", hitSingles: 29 });
24
+
25
+ db.subscribe(async () => {
26
+ const topArtists = await db.query("hitSingles", { range: [30, Infinity] });
27
+ // redraw the UI with the new topArtists
28
+ });
29
+
30
+ const beyonceDoc = await db.get("beyonce");
31
+ beyonceDoc.hitSingles += 1;
32
+ await db.put(beyonceDoc);
33
+ ```
34
+
35
+ Jump to the docs site [for JavaScript API basics.](https://use-fireproof.com/docs/database-api/basics)
36
+
37
+ ### Live data hooks for React
38
+
39
+ Fireproof [React hooks for live data](https://use-fireproof.com/docs/category/react-hooks) avoid boilerplate and make building collaborative apps a breeze.
40
+
41
+ ```js
42
+ import { useLiveQuery, useDocument } from 'use-fireproof'
43
+
44
+ function App() {
45
+ const completedTodos = useLiveQuery('completed', { limit: 10 })
46
+ const [newTodo, setNewTodoData, saveNewTodo] = useDocument({type: 'todo', text: '', completed: false, created: Date.now() })
47
+ ```
48
+
49
+ Read the [step-by-step React tutorial](https://use-fireproof.com/docs/react-tutorial) to get started.
50
+
51
+ ## Why choose Fireproof
52
+
53
+ Compared to other embedded databases, Fireproof:
54
+
55
+ - is network aware, encrypted, and multi-writer safe
56
+ - is designed for real-time collaboration with CRDTs
57
+ - offers cryptographic causal integrity for all operations
58
+ - is built for the web, with a small package size and no wasm
59
+
60
+ Deliver interactive experiences without waiting on the backend. Fireproof runs in any cloud, browser, or edge environment, so your application can access data anywhere.
61
+
62
+ [Get the latest roadmap updates on our blog](https://fireproof.storage/blog/) or join our [Discord](https://discord.gg/cCryrNHePH) to collaborate. Read the docs to learn more about the database [architecture](https://use-fireproof.com/docs/architecture).
63
+
64
+ ### Use cases
65
+
66
+ Fireproof allows web developers to build full-stack apps. It's especially useful for:
67
+
68
+ - Rapid prototyping
69
+ - AI copilot safety
70
+ - Collaborative editing
71
+ - Personalization and configuration
72
+ - Offline and local-first apps
73
+
74
+ With Fireproof, you **build first** and sync via your cloud of choice when you are ready, so it's as easy to add to existing apps as it is to build something new. Drop Fireproof in your page with a script tag and start sharing interactive data.
75
+
76
+ Fireproof is a great fit for code sandboxes and online IDEs, as you can get started without any configuration. This also makes it [easy for AI to write Fireproof apps](https://use-fireproof.com/docs/chatgpt-quick-start).
77
+
78
+ ### Install
79
+
80
+ Get started with the React hooks:
81
+
82
+ ```sh
83
+ npm install use-fireproof
84
+ ```
85
+
86
+ or install the database in any JavaScript environment:
87
+
88
+ ```sh
89
+ npm install @fireproof/core
90
+ ```
91
+
92
+ The default build is optimized for browsers, to load the node build add `/node`:
93
+
94
+ ```js
95
+ import { fireproof } from "@fireproof/core/node";
96
+ ```
97
+
98
+ Add the database to any web page via HTML script tag (global is `Fireproof`):
99
+
100
+ ```html
101
+ <script src="https://cdn.jsdelivr.net/npm/@fireproof/core/dist/browser/fireproof.global.js"></script>
102
+ ```
103
+
104
+ Go ahead and write features, then [connect to any cloud backend](https://www.npmjs.com/package/@fireproof/connect) later.
105
+
106
+ ### Debug
107
+
108
+ to control the log output you an either use the FP_DEBUG environment variable or set the debug level in your code:
109
+
110
+ ```shell
111
+ FP_DEBUG='*' node myapp.js
112
+ ```
113
+
114
+ ```js
115
+ logger.setDebug(...moduleNameList or '*')
116
+ ```
117
+
118
+ if you are in the browser you can use the following code to set the debug level:
119
+
120
+ ```js
121
+ this[Symbol.for("FP_ENV")].set("FP_DEBUG", "*");
122
+ ```
123
+
124
+ ## Thanks 🙏
125
+
126
+ Fireproof is a synthesis of work done by people in the web community over the years. I couldn't even begin to name all the folks who made pivotal contributions. Without npm, React, and VS Code all this would have taken so much longer. Thanks to everyone who supported me getting into database development via Apache CouchDB, one of the original document databases. The distinguishing work on immutable data-structures comes from the years of consideration [IPFS](https://ipfs.tech), [IPLD](https://ipld.io), and the [Filecoin APIs](https://docs.filecoin.io) have enjoyed.
127
+
128
+ Thanks to Alan Shaw and Mikeal Rogers without whom this project would have never got started. The core Merkle hash-tree clock is based on [Alan's Pail](https://github.com/alanshaw/pail), and you can see the repository history goes all the way back to work begun as a branch of that repo. Mikeal wrote [the prolly trees implementation](https://github.com/mikeal/prolly-trees).
129
+
130
+ ## Contributing
131
+
132
+ We love contributions. Feel free to [join in the conversation on Discord. All welcome.](https://discord.gg/cCryrNHePH)
133
+
134
+ # License
135
+
136
+ Dual-licensed under [MIT or Apache 2.0](https://github.com/fireproof-storage/fireproof/blob/main/LICENSE.md)
@@ -0,0 +1,39 @@
1
+ import {
2
+ SQLITE_VERSION,
3
+ ensureLogger
4
+ } from "./chunk-HCXR2M5B.js";
5
+
6
+ // src/runtime/store-sql/v0.19-sqlite/sqlite-ensure-version.ts
7
+ import { ResolveOnce } from "@adviser/cement";
8
+ var once = new ResolveOnce();
9
+ async function ensureSQLiteVersion(url, dbConn) {
10
+ const version = await once.once(async () => {
11
+ const logger = ensureLogger(dbConn.opts, "ensureSQLiteVersion", {
12
+ version: SQLITE_VERSION,
13
+ url: dbConn.url.toString()
14
+ });
15
+ await dbConn.client.prepare(
16
+ `CREATE TABLE IF NOT EXISTS version (
17
+ version TEXT NOT NULL,
18
+ updated_at TEXT NOT NULL)`
19
+ ).run();
20
+ const rows = await dbConn.client.prepare(`select version from version`).all();
21
+ if (rows.length > 1) {
22
+ throw logger.Error().Msg(`more than one version row found`).AsError();
23
+ }
24
+ if (rows.length === 0) {
25
+ await dbConn.client.prepare(`insert into version (version, updated_at) values (?, ?)`).run(SQLITE_VERSION, (/* @__PURE__ */ new Date()).toISOString());
26
+ return SQLITE_VERSION;
27
+ }
28
+ if (rows[0].version !== SQLITE_VERSION) {
29
+ logger.Warn().Any("row", rows[0]).Msg(`version mismatch`);
30
+ }
31
+ return rows[0].version;
32
+ });
33
+ url.searchParams.set("version", version);
34
+ }
35
+
36
+ export {
37
+ ensureSQLiteVersion
38
+ };
39
+ //# sourceMappingURL=chunk-7OGPZSGT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/store-sql/v0.19-sqlite/sqlite-ensure-version.ts"],"sourcesContent":["import { SQLiteConnection } from \"../sqlite-adapter-better-sqlite3\";\nimport { SQLITE_VERSION } from \"./version\";\nimport { ResolveOnce } from \"@adviser/cement\";\nimport { ensureLogger } from \"../../../utils\";\n\nconst once = new ResolveOnce<string>();\nexport async function ensureSQLiteVersion(url: URL, dbConn: SQLiteConnection) {\n const version = await once.once(async () => {\n const logger = ensureLogger(dbConn.opts, \"ensureSQLiteVersion\", {\n version: SQLITE_VERSION,\n url: dbConn.url.toString(),\n });\n await dbConn.client\n .prepare(\n `CREATE TABLE IF NOT EXISTS version (\n version TEXT NOT NULL,\n updated_at TEXT NOT NULL)`,\n )\n .run();\n const rows = (await dbConn.client.prepare(`select version from version`).all()) as { version: string }[];\n if (rows.length > 1) {\n throw logger.Error().Msg(`more than one version row found`).AsError();\n }\n if (rows.length === 0) {\n await dbConn.client\n .prepare(`insert into version (version, updated_at) values (?, ?)`)\n .run(SQLITE_VERSION, new Date().toISOString());\n return SQLITE_VERSION;\n }\n if (rows[0].version !== SQLITE_VERSION) {\n logger.Warn().Any(\"row\", rows[0]).Msg(`version mismatch`);\n }\n return rows[0].version;\n });\n url.searchParams.set(\"version\", version);\n}\n"],"mappings":";;;;;;AAEA,SAAS,mBAAmB;AAG5B,IAAM,OAAO,IAAI,YAAoB;AACrC,eAAsB,oBAAoB,KAAU,QAA0B;AAC5E,QAAM,UAAU,MAAM,KAAK,KAAK,YAAY;AAC1C,UAAM,SAAS,aAAa,OAAO,MAAM,uBAAuB;AAAA,MAC9D,SAAS;AAAA,MACT,KAAK,OAAO,IAAI,SAAS;AAAA,IAC3B,CAAC;AACD,UAAM,OAAO,OACV;AAAA,MACC;AAAA;AAAA;AAAA,IAGF,EACC,IAAI;AACP,UAAM,OAAQ,MAAM,OAAO,OAAO,QAAQ,6BAA6B,EAAE,IAAI;AAC7E,QAAI,KAAK,SAAS,GAAG;AACnB,YAAM,OAAO,MAAM,EAAE,IAAI,iCAAiC,EAAE,QAAQ;AAAA,IACtE;AACA,QAAI,KAAK,WAAW,GAAG;AACrB,YAAM,OAAO,OACV,QAAQ,yDAAyD,EACjE,IAAI,iBAAgB,oBAAI,KAAK,GAAE,YAAY,CAAC;AAC/C,aAAO;AAAA,IACT;AACA,QAAI,KAAK,CAAC,EAAE,YAAY,gBAAgB;AACtC,aAAO,KAAK,EAAE,IAAI,OAAO,KAAK,CAAC,CAAC,EAAE,IAAI,kBAAkB;AAAA,IAC1D;AACA,WAAO,KAAK,CAAC,EAAE;AAAA,EACjB,CAAC;AACD,MAAI,aAAa,IAAI,WAAW,OAAO;AACzC;","names":[]}
@@ -0,0 +1,164 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/types.ts
8
+ function isFalsy(value) {
9
+ return value === false && value === null && value === void 0;
10
+ }
11
+ function throwFalsy(value) {
12
+ if (isFalsy(value)) {
13
+ throw new Error("value is Falsy");
14
+ }
15
+ return value;
16
+ }
17
+ function falsyToUndef(value) {
18
+ if (isFalsy(value)) {
19
+ return void 0;
20
+ }
21
+ return value;
22
+ }
23
+
24
+ // src/runtime/sys-container.ts
25
+ import * as stdEnv from "std-env";
26
+ import { uuidv4 } from "uuidv7";
27
+ import { ResolveOnce, EnvImpl } from "@adviser/cement";
28
+ var onceStart = new ResolveOnce();
29
+ function join(...paths) {
30
+ return paths.map((i) => i.replace(/\/+$/, "")).join("/");
31
+ }
32
+ var envImpl = new EnvImpl({
33
+ symbol: "FP_ENV",
34
+ presetEnv: /* @__PURE__ */ new Map([
35
+ // ["FP_DEBUG", "xxx"],
36
+ // ["FP_ENV", "development"],
37
+ ])
38
+ });
39
+ var sysContainer = class {
40
+ constructor() {
41
+ this.freight = {
42
+ state: "seeded",
43
+ join,
44
+ dirname: (path) => path.split("/").slice(0, -1).join("/"),
45
+ homedir: () => {
46
+ throw new Error("SysContainer:homedir is not available in seeded state");
47
+ },
48
+ fileURLToPath: (strurl) => {
49
+ let url;
50
+ if (typeof strurl === "string") {
51
+ url = new URL(strurl);
52
+ } else {
53
+ url = strurl;
54
+ }
55
+ return url.pathname;
56
+ },
57
+ // assert: (condition: unknown, message?: string | Error) => {
58
+ // if (!condition) {
59
+ // if (message instanceof Error) {
60
+ // throw message;
61
+ // } else {
62
+ // throw new Error(message);
63
+ // }
64
+ // }
65
+ // },
66
+ mkdir: () => Promise.reject(new Error("SysContainer:mkdir is not available in seeded state")),
67
+ readdir: () => Promise.reject(new Error("SysContainer:readdir is not available in seeded state")),
68
+ rm: () => Promise.reject(new Error("SysContainer:rm is not available in seeded state")),
69
+ copyFile: () => Promise.reject(new Error("SysContainer:copyFile is not available in seeded state")),
70
+ readfile: () => Promise.reject(new Error("SysContainer:readfile is not available in seeded state")),
71
+ unlink: () => Promise.reject(new Error("SysContainer:unlink is not available in seeded state")),
72
+ writefile: () => Promise.reject(new Error("SysContainer:writefile is not available in seeded state")),
73
+ stat: () => Promise.reject(new Error("SysContainer:stat is not available in seeded state"))
74
+ };
75
+ this.id = uuidv4();
76
+ this.homedir = () => {
77
+ this.logSeeded("homedir");
78
+ return throwFalsy(this.freight).homedir();
79
+ };
80
+ this.env = envImpl;
81
+ }
82
+ async start() {
83
+ await onceStart.once(async () => {
84
+ switch (this.freight.state) {
85
+ case "seeded":
86
+ if (stdEnv.isNode) {
87
+ const { createNodeSysContainer } = await import("./node-sys-container-E7LADX2Z.js");
88
+ this.freight = await createNodeSysContainer();
89
+ } else {
90
+ this.freight.state = "browser";
91
+ }
92
+ return;
93
+ case "browser":
94
+ case "node":
95
+ return;
96
+ }
97
+ });
98
+ }
99
+ async readdir(path, options) {
100
+ this.logSeeded("readdir");
101
+ return throwFalsy(this.freight).readdir(path, options) || [];
102
+ }
103
+ async readdirent(path, options) {
104
+ this.logSeeded("readdirent");
105
+ return throwFalsy(this.freight).readdir(path, { ...options, withFileTypes: true }) || [];
106
+ }
107
+ async readfile(path, options) {
108
+ this.logSeeded("readfile");
109
+ return throwFalsy(this.freight).readfile(path, options);
110
+ }
111
+ async mkdir(path, options) {
112
+ this.logSeeded("mkdir");
113
+ return throwFalsy(this.freight).mkdir(path, options);
114
+ }
115
+ async rm(path, options) {
116
+ this.logSeeded("rm");
117
+ return throwFalsy(this.freight).rm(path, options);
118
+ }
119
+ async unlink(path) {
120
+ this.logSeeded("unlink");
121
+ return throwFalsy(this.freight).unlink(path);
122
+ }
123
+ async writefile(path, data) {
124
+ this.logSeeded("writefile");
125
+ return throwFalsy(this.freight).writefile(path, data);
126
+ }
127
+ async copyFile(source, destination) {
128
+ this.logSeeded("copyFile");
129
+ return throwFalsy(this.freight).copyFile(source, destination);
130
+ }
131
+ async stat(path) {
132
+ this.logSeeded("stat");
133
+ return throwFalsy(this.freight).stat(path);
134
+ }
135
+ fileURLToPath(url) {
136
+ this.logSeeded("fileURLToPath");
137
+ return throwFalsy(this.freight).fileURLToPath(url);
138
+ }
139
+ dirname(path) {
140
+ this.logSeeded("dirname");
141
+ return throwFalsy(this.freight).dirname(path);
142
+ }
143
+ join(...args) {
144
+ this.logSeeded("join");
145
+ return throwFalsy(this.freight).join(...args);
146
+ }
147
+ logSeeded(method) {
148
+ if (this.freight.state === "seeded") {
149
+ const err = new Error();
150
+ console.warn(`SysContainer.${method} is not available in seeded state:`, err.stack);
151
+ }
152
+ }
153
+ };
154
+ var SysContainer = new sysContainer();
155
+
156
+ export {
157
+ __export,
158
+ isFalsy,
159
+ throwFalsy,
160
+ falsyToUndef,
161
+ join,
162
+ SysContainer
163
+ };
164
+ //# sourceMappingURL=chunk-H3A2HMMM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types.ts","../../src/runtime/sys-container.ts"],"sourcesContent":["import type { EventLink } from \"@web3-storage/pail/clock/api\";\nimport type { Operation } from \"@web3-storage/pail/crdt/api\";\n\nimport type { DbMeta, CryptoOpts, StoreOpts, AnyLink } from \"./blockstore/index.js\";\nimport { Logger } from \"@adviser/cement\";\n\nexport type Falsy = false | null | undefined;\n\nexport function isFalsy(value: unknown): value is Falsy {\n return value === false && value === null && value === undefined;\n}\n\nexport function throwFalsy<T>(value: T | Falsy): T {\n if (isFalsy(value)) {\n throw new Error(\"value is Falsy\");\n }\n return value;\n}\n\nexport function falsyToUndef<T>(value: T | Falsy): T | undefined {\n if (isFalsy(value)) {\n return undefined;\n }\n return value;\n}\n\nexport interface ConfigOpts {\n readonly public?: boolean;\n readonly meta?: DbMeta;\n readonly persistIndexes?: boolean;\n readonly autoCompact?: number;\n readonly crypto?: CryptoOpts;\n readonly store?: StoreOpts;\n // readonly indexStore?: StoreOpts;\n readonly threshold?: number;\n readonly logger?: Logger;\n}\n\nexport type ClockLink = EventLink<Operation>;\n\nexport type ClockHead = ClockLink[];\n\nexport type DocFragment = Uint8Array | string | number | boolean | null | AnyLink | DocFragment[] | object;\n// | { [key: string]: DocFragment };\n\nexport type DocLiteral = string | number | boolean | Uint8Array | unknown;\n\nexport type DocObject = NonNullable<unknown>;\nexport type DocTypes = DocObject;\n\nexport type DocRecord<T extends DocObject> = T;\n\nexport type UnknownDoc = DocRecord<never>;\n\nexport type DocFiles = Record<string, DocFileMeta | File>;\n\nexport interface DocBase {\n readonly _id: string;\n readonly _files?: DocFiles;\n readonly _publicFiles?: DocFiles;\n readonly _deleted?: boolean;\n}\n\nexport type DocWithId<T extends DocTypes> = DocBase & T;\n\nexport type DocSet<T extends DocTypes> = Partial<DocBase> & T;\n\nexport interface DocFileMeta {\n readonly type: string;\n readonly size: number;\n readonly cid: AnyLink;\n readonly car?: AnyLink;\n url?: string;\n file?: () => Promise<File>;\n}\n\nexport interface DocUpdate<T extends DocTypes> {\n readonly id: string;\n readonly value?: DocSet<T>;\n readonly del?: boolean;\n readonly clock?: ClockLink; // would be useful to give ClockLinks a type\n}\n\n// todo merge into above\nexport interface DocValue<T extends DocTypes> {\n readonly doc: DocWithId<T>;\n readonly del: boolean;\n readonly cid: AnyLink;\n}\n\nexport type KeyLiteral = string | number | boolean;\nexport type IndexKeyType = KeyLiteral | KeyLiteral[];\nexport type IndexKey<K extends IndexKeyType> = [K, string];\n\nexport interface IndexUpdate<K extends IndexKeyType> {\n readonly key: IndexKey<K>;\n readonly value?: DocFragment;\n readonly del?: boolean;\n}\n\nexport interface IndexUpdateString {\n readonly key: string;\n readonly value?: DocFragment;\n readonly del?: boolean;\n}\n\n// export interface IndexRowObject<K extends IndexKeyType, T extends DocObject> {\n// readonly id: string;\n// readonly key: K;\n// readonly value: T\n// // readonly row: T // DocFragment;\n// // readonly doc?: DocWithId<T>;\n// // value?: T;\n// // readonly del?: boolean;\n// }\n\n// export interface IndexRowLiteral<K extends IndexKeyType, T extends DocLiteral> {\n// readonly id: string;\n// readonly key: IndexKey<K>;\n// readonly value: T\n// }\n\n// export type IndexRow<K extends IndexKeyType, T extends DocTypes> =\n// T extends DocLiteral ? IndexRowLiteral<K, T> : IndexRowObject<K, T>\n\nexport interface IndexRow<K extends IndexKeyType, T extends DocObject, R extends DocFragment> {\n readonly id: string;\n readonly key: K; // IndexKey<K>;\n readonly value: R;\n readonly doc?: DocWithId<T>;\n}\n\nexport interface IndexRows<K extends IndexKeyType, T extends DocObject, R extends DocFragment = T> {\n readonly rows: IndexRow<K, T, R>[];\n}\nexport interface CRDTMeta {\n readonly head: ClockHead;\n}\n\nexport interface IndexTransactionMeta {\n readonly indexes: Record<string, IdxMeta>;\n}\n\nexport interface FileTransactionMeta {\n readonly files?: AnyLink[];\n}\n\nexport type MetaType = CRDTMeta | IndexTransactionMeta | FileTransactionMeta;\n\nexport interface IdxMeta {\n readonly byId: AnyLink;\n readonly byKey: AnyLink;\n readonly map: string;\n readonly name: string;\n readonly head: ClockHead;\n}\n\nexport interface IdxMetaMap {\n readonly indexes?: Map<string, IdxMeta>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface QueryOpts<K extends IndexKeyType> {\n readonly descending?: boolean;\n readonly limit?: number;\n includeDocs?: boolean;\n readonly range?: [IndexKeyType, IndexKeyType];\n readonly key?: DocFragment;\n readonly keys?: DocFragment[];\n prefix?: IndexKeyType;\n}\n\ntype EmitFn = (k: IndexKeyType, v?: DocFragment) => void;\nexport type MapFn<T extends DocTypes> = (doc: DocWithId<T>, emit: EmitFn) => DocFragment | unknown;\n\nexport interface ChangesOptions {\n readonly dirty?: boolean;\n readonly limit?: number;\n}\n\nexport interface ChangesResponseRow<T extends DocTypes> {\n readonly key: string;\n readonly value: DocWithId<T>;\n readonly clock?: ClockLink;\n}\n\nexport interface ChangesResponse<T extends DocTypes> {\n readonly clock: ClockHead;\n readonly rows: ChangesResponseRow<T>[];\n}\n\nexport interface DbResponse {\n readonly id: string;\n readonly clock: ClockHead;\n}\n\nexport type UpdateListenerFn<T extends DocTypes> = (docs: DocWithId<T>[]) => Promise<void> | void;\nexport type NoUpdateListenerFn = () => Promise<void> | void;\nexport type ListenerFn<T extends DocTypes> = UpdateListenerFn<T> | NoUpdateListenerFn;\n","import type { Dirent, MakeDirectoryOptions, ObjectEncodingOptions, PathLike, Stats } from \"node:fs\";\n\nimport * as stdEnv from \"std-env\";\nimport { uuidv4 } from \"uuidv7\";\nimport { ResolveOnce, EnvImpl } from \"@adviser/cement\";\n\nimport { throwFalsy } from \"../types.js\";\n\nexport interface NodeMap {\n state: \"seeded\" | \"browser\" | \"node\";\n join: (...args: string[]) => string;\n dirname: (path: string) => string;\n homedir: () => string;\n fileURLToPath: (url: string | URL) => string;\n // assert: (condition: unknown, message?: string | Error) => void;\n\n mkdir: (path: PathLike, options?: { recursive: boolean }) => Promise<string | undefined>;\n readdir: (path: PathLike, options?: unknown) => Promise<unknown[]>;\n\n rm: (path: PathLike, options?: MakeDirectoryOptions & { recursive: boolean }) => Promise<void>;\n copyFile: (source: PathLike, destination: PathLike) => Promise<void>;\n\n readfile: (path: PathLike, options?: { encoding: BufferEncoding; flag?: string }) => Promise<string>;\n\n stat: (path: PathLike) => Promise<Stats>;\n\n unlink: (path: PathLike) => Promise<void>;\n writefile: (path: PathLike, data: Uint8Array | string) => Promise<void>;\n}\n\n// export function assert(condition: unknown, message?: string | Error): asserts condition {\n// SysContainer.freight?.assert(condition, message);\n// }\n\nconst onceStart = new ResolveOnce<void>();\n\nexport function join(...paths: string[]): string {\n return paths.map((i) => i.replace(/\\/+$/, \"\")).join(\"/\");\n}\n\nconst envImpl = new EnvImpl({\n symbol: \"FP_ENV\",\n presetEnv: new Map([\n // [\"FP_DEBUG\", \"xxx\"],\n // [\"FP_ENV\", \"development\"],\n ]),\n});\n// console.log(`EnvImpl`, envImpl);\n\nclass sysContainer {\n freight: NodeMap = {\n state: \"seeded\",\n join,\n dirname: (path: string) => path.split(\"/\").slice(0, -1).join(\"/\"),\n homedir: () => {\n throw new Error(\"SysContainer:homedir is not available in seeded state\");\n },\n fileURLToPath: (strurl: string | URL) => {\n let url: URL;\n if (typeof strurl === \"string\") {\n url = new URL(strurl);\n } else {\n url = strurl;\n }\n return url.pathname;\n },\n // assert: (condition: unknown, message?: string | Error) => {\n // if (!condition) {\n // if (message instanceof Error) {\n // throw message;\n // } else {\n // throw new Error(message);\n // }\n // }\n // },\n mkdir: () => Promise.reject(new Error(\"SysContainer:mkdir is not available in seeded state\")),\n readdir: () => Promise.reject(new Error(\"SysContainer:readdir is not available in seeded state\")),\n rm: () => Promise.reject(new Error(\"SysContainer:rm is not available in seeded state\")),\n copyFile: () => Promise.reject(new Error(\"SysContainer:copyFile is not available in seeded state\")),\n readfile: () => Promise.reject(new Error(\"SysContainer:readfile is not available in seeded state\")),\n unlink: () => Promise.reject(new Error(\"SysContainer:unlink is not available in seeded state\")),\n writefile: () => Promise.reject(new Error(\"SysContainer:writefile is not available in seeded state\")),\n stat: () => Promise.reject(new Error(\"SysContainer:stat is not available in seeded state\")),\n };\n\n readonly id = uuidv4();\n\n async start(): Promise<void> {\n await onceStart.once(async () => {\n switch (this.freight.state) {\n case \"seeded\":\n if (stdEnv.isNode) {\n const { createNodeSysContainer } = await import(\"./node-sys-container.js\");\n // console.log(\"use NodeSysContainer\");\n this.freight = await createNodeSysContainer();\n } else {\n // console.log(\"use BrowserSysContainer\");\n this.freight.state = \"browser\";\n }\n return;\n case \"browser\":\n case \"node\":\n return;\n }\n });\n }\n\n async readdir(\n path: PathLike,\n options?:\n | (ObjectEncodingOptions & { withFileTypes?: false | undefined; recursive?: boolean })\n | BufferEncoding\n | null\n | undefined,\n ) {\n this.logSeeded(\"readdir\");\n return (throwFalsy(this.freight).readdir(path, options) as Promise<string[]>) || [];\n }\n async readdirent(\n path: PathLike,\n options: (ObjectEncodingOptions & { withFileTypes: true; recursive?: boolean }) | BufferEncoding | null | undefined,\n ): Promise<Dirent[]> {\n this.logSeeded(\"readdirent\");\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (throwFalsy(this.freight).readdir(path, { ...(options as any), withFileTypes: true }) as Promise<Dirent[]>) || [];\n }\n\n async readfile(path: PathLike, options?: { encoding: BufferEncoding; flag?: string }) {\n this.logSeeded(\"readfile\");\n return throwFalsy(this.freight).readfile(path, options) as unknown as Promise<Buffer>;\n }\n\n async mkdir(path: PathLike, options: { recursive: boolean }) {\n this.logSeeded(\"mkdir\");\n return throwFalsy(this.freight).mkdir(path, options);\n }\n\n async rm(path: PathLike, options: MakeDirectoryOptions & { recursive: boolean }) {\n this.logSeeded(\"rm\");\n return throwFalsy(this.freight).rm(path, options);\n }\n\n async unlink(path: PathLike) {\n this.logSeeded(\"unlink\");\n return throwFalsy(this.freight).unlink(path);\n }\n\n async writefile(path: PathLike, data: Uint8Array | string) {\n this.logSeeded(\"writefile\");\n return throwFalsy(this.freight).writefile(path, data);\n }\n\n async copyFile(source: PathLike, destination: PathLike) {\n this.logSeeded(\"copyFile\");\n return throwFalsy(this.freight).copyFile(source, destination);\n }\n\n async stat(path: PathLike) {\n this.logSeeded(\"stat\");\n return throwFalsy(this.freight).stat(path);\n }\n\n fileURLToPath(url: string | URL) {\n this.logSeeded(\"fileURLToPath\");\n return throwFalsy(this.freight).fileURLToPath(url);\n }\n\n dirname(path: string) {\n this.logSeeded(\"dirname\");\n return throwFalsy(this.freight).dirname(path);\n }\n\n join(...args: string[]): string {\n this.logSeeded(\"join\");\n return throwFalsy(this.freight).join(...args);\n }\n\n homedir = () => {\n this.logSeeded(\"homedir\");\n return throwFalsy(this.freight).homedir();\n };\n\n logSeeded(method: string) {\n if (this.freight.state === \"seeded\") {\n const err = new Error();\n console.warn(`SysContainer.${method} is not available in seeded state:`, err.stack);\n }\n }\n readonly env = envImpl;\n}\n\n// // eslint-disable-next-line @typescript-eslint/no-explicit-any\n// export async function saveImport(fName: string): Promise<any> {\n// try {\n// const i = await import(fName);\n// return i;\n// } catch (e: unknown) {\n// console.error(`saveImport failed for ${fName} with`, e);\n// throw e;\n// }\n// }\n\nexport const SysContainer = new sysContainer();\n"],"mappings":";;;;;;;AAQO,SAAS,QAAQ,OAAgC;AACtD,SAAO,UAAU,SAAS,UAAU,QAAQ,UAAU;AACxD;AAEO,SAAS,WAAc,OAAqB;AACjD,MAAI,QAA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