@pluv/crdt-loro 4.0.2 → 4.1.0
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/.turbo/turbo-build.log +25 -12
- package/CHANGELOG.md +11 -0
- package/README.md +27 -6
- package/dist/browser.mjs +1 -1
- package/dist/bundler.mjs +336 -0
- package/dist/bundler.mjs.map +1 -0
- package/package.json +30 -11
- package/src/loro-runtime.bundler.ts +1 -0
- package/tsconfig.bundler.build.json +8 -0
- package/tsdown.bundler.config.ts +15 -0
- package/tsdown.config.ts +2 -1
- /package/dist/{chunk-BBjsoOtd.mjs → rolldown-runtime-BBjsoOtd.mjs} +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
$ tsdown --config tsdown.browser.config.ts && tsdown --config tsdown.node.config.ts
|
|
2
|
-
[34mℹ[39m [34mtsdown v0.22.2[39m powered by [38;2;255;126;23mrolldown v1.1.
|
|
1
|
+
$ tsdown --config tsdown.browser.config.ts && tsdown --config tsdown.bundler.config.ts && tsdown --config tsdown.node.config.ts
|
|
2
|
+
[34mℹ[39m [34mtsdown v0.22.2[39m powered by [38;2;255;126;23mrolldown v1.1.1[39m
|
|
3
3
|
[34mℹ[39m config file: [4m/home/runner/work/pluv/pluv/packages/crdt-loro/tsdown.browser.config.ts[24m
|
|
4
4
|
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
5
5
|
[34mℹ[39m target: [34mesnext[39m
|
|
6
6
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
7
7
|
[34mℹ[39m Build start
|
|
8
|
-
[34mℹ[39m [2mdist/[22m[1mbrowser.mjs[22m
|
|
9
|
-
[34mℹ[39m [2mdist/[22mbrowser.mjs.map
|
|
10
|
-
[34mℹ[39m [2mdist/[22mbrowser.d.mts.map
|
|
11
|
-
[34mℹ[39m [2mdist/[
|
|
12
|
-
[34mℹ[39m [2mdist/[22m[32m[1mbrowser.d.mts[22m[39m
|
|
13
|
-
[34mℹ[39m 5 files, total: 39.
|
|
14
|
-
[33m[PLUGIN_TIMINGS] [0mYour build spent significant time in
|
|
8
|
+
[34mℹ[39m [2mdist/[22m[1mbrowser.mjs[22m [2m 8.99 kB[22m [2m│ gzip: 2.27 kB[22m
|
|
9
|
+
[34mℹ[39m [2mdist/[22mbrowser.mjs.map [2m21.63 kB[22m [2m│ gzip: 4.93 kB[22m
|
|
10
|
+
[34mℹ[39m [2mdist/[22mbrowser.d.mts.map [2m 2.70 kB[22m [2m│ gzip: 0.91 kB[22m
|
|
11
|
+
[34mℹ[39m [2mdist/[22mrolldown-runtime-BBjsoOtd.mjs [2m 1.11 kB[22m [2m│ gzip: 0.54 kB[22m
|
|
12
|
+
[34mℹ[39m [2mdist/[22m[32m[1mbrowser.d.mts[22m[39m [2m 4.88 kB[22m [2m│ gzip: 1.30 kB[22m
|
|
13
|
+
[34mℹ[39m 5 files, total: 39.31 kB
|
|
14
|
+
[33m[PLUGIN_TIMINGS] [0mYour build spent significant time in plugins. Here is a breakdown:
|
|
15
|
+
- rolldown-plugin-dts:generate (65%)
|
|
16
|
+
- tsdown:deps (20%)
|
|
17
|
+
See https://rolldown.rs/options/checks#plugintimings for more details.
|
|
15
18
|
|
|
16
|
-
[32m✔[39m Build complete in [
|
|
17
|
-
[34mℹ[39m [34mtsdown v0.22.2[39m powered by [38;2;255;126;23mrolldown v1.1.
|
|
19
|
+
[32m✔[39m Build complete in [32m3319ms[39m
|
|
20
|
+
[34mℹ[39m [34mtsdown v0.22.2[39m powered by [38;2;255;126;23mrolldown v1.1.1[39m
|
|
21
|
+
[34mℹ[39m config file: [4m/home/runner/work/pluv/pluv/packages/crdt-loro/tsdown.bundler.config.ts[24m
|
|
22
|
+
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
23
|
+
[34mℹ[39m target: [34mesnext[39m
|
|
24
|
+
[34mℹ[39m tsconfig: [34mtsconfig.bundler.build.json[39m
|
|
25
|
+
[34mℹ[39m Build start
|
|
26
|
+
[34mℹ[39m [2mdist/[22m[1mbundler.mjs[22m [2m10.00 kB[22m [2m│ gzip: 2.65 kB[22m
|
|
27
|
+
[34mℹ[39m [2mdist/[22mbundler.mjs.map [2m21.66 kB[22m [2m│ gzip: 4.93 kB[22m
|
|
28
|
+
[34mℹ[39m 2 files, total: 31.66 kB
|
|
29
|
+
[32m✔[39m Build complete in [32m106ms[39m
|
|
30
|
+
[34mℹ[39m [34mtsdown v0.22.2[39m powered by [38;2;255;126;23mrolldown v1.1.1[39m
|
|
18
31
|
[34mℹ[39m config file: [4m/home/runner/work/pluv/pluv/packages/crdt-loro/tsdown.node.config.ts[24m
|
|
19
32
|
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
20
33
|
[34mℹ[39m target: [34mesnext[39m
|
|
@@ -23,4 +36,4 @@ $ tsdown --config tsdown.browser.config.ts && tsdown --config tsdown.node.config
|
|
|
23
36
|
[34mℹ[39m [2mdist/[22m[1mnode.mjs[22m [2m 9.91 kB[22m [2m│ gzip: 2.65 kB[22m
|
|
24
37
|
[34mℹ[39m [2mdist/[22mnode.mjs.map [2m21.66 kB[22m [2m│ gzip: 4.93 kB[22m
|
|
25
38
|
[34mℹ[39m 2 files, total: 31.56 kB
|
|
26
|
-
[32m✔[39m Build complete in [
|
|
39
|
+
[32m✔[39m Build complete in [32m68ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @pluv/crdt-loro
|
|
2
2
|
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5aaef94: Add runtime-specific conditional exports for browser, workerd, bun, node, and deno. Cloudflare Workers and Bun resolve to `loro-crdt/bundler`; Node and Deno resolve to `loro-crdt/nodejs`; browsers resolve to bare `loro-crdt`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- @pluv/crdt@4.1.0
|
|
12
|
+
- @pluv/types@4.1.0
|
|
13
|
+
|
|
3
14
|
## 4.0.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -19,6 +19,29 @@ yarn add @pluv/crdt-loro loro-crdt
|
|
|
19
19
|
pnpm add @pluv/crdt-loro loro-crdt
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
## Runtime resolution
|
|
23
|
+
|
|
24
|
+
Import `@pluv/crdt-loro` normally. Conditional exports pick the Loro entry best suited for each runtime:
|
|
25
|
+
|
|
26
|
+
| Runtime | Resolved build | Loro entry |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| Browser (Vite, Webpack, etc.) | `dist/browser.mjs` | `loro-crdt` |
|
|
29
|
+
| Cloudflare Workers (Wrangler) | `dist/bundler.mjs` | `loro-crdt/bundler` |
|
|
30
|
+
| Bun | `dist/bundler.mjs` | `loro-crdt/bundler` |
|
|
31
|
+
| Node.js | `dist/node.mjs` | `loro-crdt/nodejs` |
|
|
32
|
+
| Deno | `dist/node.mjs` | `loro-crdt/nodejs` |
|
|
33
|
+
| Other bundlers (default) | `dist/bundler.mjs` | `loro-crdt/bundler` |
|
|
34
|
+
|
|
35
|
+
If your toolchain does not pick the expected build, import explicitly:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { loro } from "@pluv/crdt-loro/browser";
|
|
39
|
+
import { loro } from "@pluv/crdt-loro/workerd";
|
|
40
|
+
import { loro } from "@pluv/crdt-loro/bun";
|
|
41
|
+
import { loro } from "@pluv/crdt-loro/node";
|
|
42
|
+
import { loro } from "@pluv/crdt-loro/deno";
|
|
43
|
+
```
|
|
44
|
+
|
|
22
45
|
## Browser setup
|
|
23
46
|
|
|
24
47
|
When using Loro in the browser (e.g. with Next.js or Vite), configure your bundler to handle WASM. See the [Loro getting started guide](https://loro.dev/docs/tutorial/get_started).
|
|
@@ -32,12 +55,10 @@ webpack: (config) => {
|
|
|
32
55
|
},
|
|
33
56
|
```
|
|
34
57
|
|
|
35
|
-
## Node.js
|
|
58
|
+
## Node.js, Deno, and Bun
|
|
36
59
|
|
|
37
|
-
When running on Node.js (e.g. with `@pluv/platform-node`), import `@pluv/crdt-loro` normally.
|
|
60
|
+
When running on Node.js (e.g. with `@pluv/platform-node`), import `@pluv/crdt-loro` normally. Deno resolves to the same Node build. Bun resolves to the bundler build, which includes Bun-specific WASM initialization in `loro-crdt`.
|
|
38
61
|
|
|
39
|
-
|
|
62
|
+
## Cloudflare Workers
|
|
40
63
|
|
|
41
|
-
|
|
42
|
-
import { loro } from "@pluv/crdt-loro/node";
|
|
43
|
-
```
|
|
64
|
+
Import `@pluv/crdt-loro` normally in Workers. Wrangler resolves the `workerd` condition to the bundler build automatically. No wrangler alias is required.
|
package/dist/browser.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as __reExport, t as __exportAll } from "./
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-BBjsoOtd.mjs";
|
|
2
2
|
import { fromUint8Array, toUint8Array } from "js-base64";
|
|
3
3
|
import { AbstractCrdtDocFactory } from "@pluv/crdt";
|
|
4
4
|
//#region src/loro-runtime.browser.ts
|
package/dist/bundler.mjs
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { fromUint8Array, toUint8Array } from "js-base64";
|
|
2
|
+
import { AbstractCrdtDocFactory } from "@pluv/crdt";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __exportAll = (all, no_symbols) => {
|
|
9
|
+
let target = {};
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
+
key = keys[i];
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
+
get: ((k) => from[k]).bind(null, key),
|
|
22
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/loro-runtime.bundler.ts
|
|
30
|
+
var loro_runtime_bundler_exports = /* @__PURE__ */ __exportAll({});
|
|
31
|
+
import * as import_loro_crdt_bundler from "loro-crdt/bundler";
|
|
32
|
+
__reExport(loro_runtime_bundler_exports, import_loro_crdt_bundler);
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/counter.ts
|
|
35
|
+
const counter = () => {
|
|
36
|
+
return new loro_runtime_bundler_exports.LoroCounter();
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/doc/builder.ts
|
|
40
|
+
const builder = (doc) => {
|
|
41
|
+
return {
|
|
42
|
+
counter(name) {
|
|
43
|
+
return doc.getCounter(name);
|
|
44
|
+
},
|
|
45
|
+
list(name, value = []) {
|
|
46
|
+
const list = doc.getList(name);
|
|
47
|
+
value.forEach((item, i) => {
|
|
48
|
+
if ((0, loro_runtime_bundler_exports.isContainer)(item)) list.insertContainer(i, item);
|
|
49
|
+
else list.insert(i, item);
|
|
50
|
+
});
|
|
51
|
+
return list;
|
|
52
|
+
},
|
|
53
|
+
map(name, value = {}) {
|
|
54
|
+
const container = doc.getMap(name);
|
|
55
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
56
|
+
if ((0, loro_runtime_bundler_exports.isContainer)(item)) container.setContainer(key, item);
|
|
57
|
+
else container.set(key, item);
|
|
58
|
+
});
|
|
59
|
+
return container;
|
|
60
|
+
},
|
|
61
|
+
moveableList(name, value = []) {
|
|
62
|
+
const list = doc.getMovableList(name);
|
|
63
|
+
value.forEach((item, i) => {
|
|
64
|
+
if ((0, loro_runtime_bundler_exports.isContainer)(item)) list.insertContainer(i, item);
|
|
65
|
+
else list.insert(i, item);
|
|
66
|
+
});
|
|
67
|
+
return list;
|
|
68
|
+
},
|
|
69
|
+
text(name, value = "") {
|
|
70
|
+
const text = doc.getText(name);
|
|
71
|
+
text.insert(0, value);
|
|
72
|
+
return text;
|
|
73
|
+
},
|
|
74
|
+
tree(name) {
|
|
75
|
+
return doc.getTree(name);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/doc/CrdtLoroDoc.ts
|
|
81
|
+
const MAX_UNDO_STEPS = 100;
|
|
82
|
+
const MERGE_INTERVAL_MS = 1e3;
|
|
83
|
+
const PLUV_ID_FIELD = "__$pluv";
|
|
84
|
+
var CrdtLoroDoc = class {
|
|
85
|
+
value = new loro_runtime_bundler_exports.LoroDoc();
|
|
86
|
+
#_storage;
|
|
87
|
+
#_undoManager = null;
|
|
88
|
+
constructor(params = () => ({})) {
|
|
89
|
+
const storage = params(builder(this.value));
|
|
90
|
+
const keys = Object.keys(this.value.toJSON()).reduce((set, key) => set.add(key), /* @__PURE__ */ new Set());
|
|
91
|
+
this.#_storage = Object.entries(storage).reduce((acc, [key, node]) => keys.has(key) ? {
|
|
92
|
+
...acc,
|
|
93
|
+
[key]: node
|
|
94
|
+
} : acc, {});
|
|
95
|
+
if (!!Object.keys(storage).length) this.#_setPluvId();
|
|
96
|
+
this.value.commit();
|
|
97
|
+
}
|
|
98
|
+
applyEncodedState(params) {
|
|
99
|
+
const update = typeof params.update === "string" ? toUint8Array(params.update) : params.update;
|
|
100
|
+
if (!update) return this;
|
|
101
|
+
this.value.import(update);
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
batchApplyEncodedState(params) {
|
|
105
|
+
const filtered = (params.updates ?? []).reduce((acc, update) => {
|
|
106
|
+
if (!update) return acc;
|
|
107
|
+
if (typeof update === "string") {
|
|
108
|
+
acc.push(toUint8Array(update));
|
|
109
|
+
return acc;
|
|
110
|
+
}
|
|
111
|
+
if (typeof update === "object") {
|
|
112
|
+
acc.push(update);
|
|
113
|
+
return acc;
|
|
114
|
+
}
|
|
115
|
+
return acc;
|
|
116
|
+
}, []);
|
|
117
|
+
if (!filtered.length) return this;
|
|
118
|
+
if (filtered.length === 1) {
|
|
119
|
+
const update = filtered[0] ?? null;
|
|
120
|
+
if (!!update) this.value.import(update);
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
this.value.importBatch(filtered);
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
canRedo() {
|
|
127
|
+
if (!this.#_undoManager) return false;
|
|
128
|
+
return this.#_undoManager.canRedo();
|
|
129
|
+
}
|
|
130
|
+
canUndo() {
|
|
131
|
+
if (!this.#_undoManager) return false;
|
|
132
|
+
return this.#_undoManager.canUndo();
|
|
133
|
+
}
|
|
134
|
+
destroy() {}
|
|
135
|
+
get(key) {
|
|
136
|
+
if (typeof key === "undefined") return this.#_storage;
|
|
137
|
+
return this.#_storage[key];
|
|
138
|
+
}
|
|
139
|
+
getEncodedState() {
|
|
140
|
+
return fromUint8Array(this.value.export({ mode: "snapshot" }));
|
|
141
|
+
}
|
|
142
|
+
toJson(type) {
|
|
143
|
+
if (typeof type === "string") {
|
|
144
|
+
const container = this.#_storage[type];
|
|
145
|
+
return container instanceof loro_runtime_bundler_exports.LoroText ? container.toString() : container instanceof loro_runtime_bundler_exports.LoroCounter ? container.value : container.toJSON();
|
|
146
|
+
}
|
|
147
|
+
return Object.entries(this.#_storage).reduce((acc, [key, value]) => ({
|
|
148
|
+
...acc,
|
|
149
|
+
[key]: value instanceof loro_runtime_bundler_exports.LoroText ? value.toString() : value.toJSON()
|
|
150
|
+
}), {});
|
|
151
|
+
}
|
|
152
|
+
isEmpty() {
|
|
153
|
+
const serialized = this.value.toJSON();
|
|
154
|
+
return !serialized || !Object.keys(serialized).length;
|
|
155
|
+
}
|
|
156
|
+
rebuildStorage(reference) {
|
|
157
|
+
if (!!Object.keys(this.#_storage).length) {
|
|
158
|
+
console.warn("Attempted to rebuild storage multiple times");
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
this.#_storage = Object.entries(reference).reduce((acc, [key, node]) => {
|
|
162
|
+
if (node instanceof loro_runtime_bundler_exports.LoroCounter) return {
|
|
163
|
+
...acc,
|
|
164
|
+
[key]: this.value.getCounter(key)
|
|
165
|
+
};
|
|
166
|
+
if (node instanceof loro_runtime_bundler_exports.LoroList) return {
|
|
167
|
+
...acc,
|
|
168
|
+
[key]: this.value.getList(key)
|
|
169
|
+
};
|
|
170
|
+
if (node instanceof loro_runtime_bundler_exports.LoroMap) return {
|
|
171
|
+
...acc,
|
|
172
|
+
[key]: this.value.getMap(key)
|
|
173
|
+
};
|
|
174
|
+
if (node instanceof loro_runtime_bundler_exports.LoroMovableList) return {
|
|
175
|
+
...acc,
|
|
176
|
+
[key]: this.value.getMovableList(key)
|
|
177
|
+
};
|
|
178
|
+
if (node instanceof loro_runtime_bundler_exports.LoroText) return {
|
|
179
|
+
...acc,
|
|
180
|
+
[key]: this.value.getText(key)
|
|
181
|
+
};
|
|
182
|
+
if (node instanceof loro_runtime_bundler_exports.LoroTree) return {
|
|
183
|
+
...acc,
|
|
184
|
+
[key]: this.value.getTree(key)
|
|
185
|
+
};
|
|
186
|
+
return acc;
|
|
187
|
+
}, {});
|
|
188
|
+
return this.track();
|
|
189
|
+
}
|
|
190
|
+
redo() {
|
|
191
|
+
this.#_undoManager?.redo();
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
subscribe(listener) {
|
|
195
|
+
const fn = (event) => {
|
|
196
|
+
const update = fromUint8Array(this.value.export({ mode: "update" }));
|
|
197
|
+
listener({
|
|
198
|
+
doc: this,
|
|
199
|
+
local: event.by === "local",
|
|
200
|
+
origin: event.origin ? String(event.origin) : null,
|
|
201
|
+
update
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
return Object.values(this.#_storage).reduce((acc, crdtType) => {
|
|
205
|
+
const unsubscribe = crdtType.subscribe(fn);
|
|
206
|
+
return () => {
|
|
207
|
+
acc();
|
|
208
|
+
unsubscribe();
|
|
209
|
+
};
|
|
210
|
+
}, () => void 0);
|
|
211
|
+
}
|
|
212
|
+
track() {
|
|
213
|
+
if (this.#_undoManager) {
|
|
214
|
+
this.#_undoManager.clear();
|
|
215
|
+
this.#_undoManager.free();
|
|
216
|
+
this.#_undoManager = null;
|
|
217
|
+
}
|
|
218
|
+
this.#_undoManager = new loro_runtime_bundler_exports.UndoManager(this.value, {
|
|
219
|
+
maxUndoSteps: MAX_UNDO_STEPS,
|
|
220
|
+
mergeInterval: MERGE_INTERVAL_MS
|
|
221
|
+
});
|
|
222
|
+
return this;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @description Unlike Yjs, this method is required to be called after each loro operation.
|
|
226
|
+
* @date January 12, 2025
|
|
227
|
+
*/
|
|
228
|
+
transact(fn) {
|
|
229
|
+
fn();
|
|
230
|
+
this.value.commit();
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
233
|
+
undo() {
|
|
234
|
+
this.#_undoManager?.undo();
|
|
235
|
+
return this;
|
|
236
|
+
}
|
|
237
|
+
#_setPluvId() {
|
|
238
|
+
const text = this.value.getText(PLUV_ID_FIELD);
|
|
239
|
+
const id = typeof crypto !== "undefined" ? crypto.randomUUID() : Math.random().toString();
|
|
240
|
+
text.insert(0, id);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/doc/CrdtLoroDocFactory.ts
|
|
245
|
+
var CrdtLoroDocFactory = class CrdtLoroDocFactory extends AbstractCrdtDocFactory {
|
|
246
|
+
_initialStorage;
|
|
247
|
+
constructor(initialStorage = () => ({})) {
|
|
248
|
+
super(initialStorage);
|
|
249
|
+
this._initialStorage = initialStorage;
|
|
250
|
+
}
|
|
251
|
+
getEmpty() {
|
|
252
|
+
return new CrdtLoroDoc();
|
|
253
|
+
}
|
|
254
|
+
getFactory(initialStorage) {
|
|
255
|
+
return new CrdtLoroDocFactory(initialStorage ?? this._initialStorage);
|
|
256
|
+
}
|
|
257
|
+
getInitialized(initialStorage) {
|
|
258
|
+
return new CrdtLoroDoc(initialStorage ?? this._initialStorage);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/doc/doc.ts
|
|
263
|
+
const doc = (value = () => ({})) => {
|
|
264
|
+
return new CrdtLoroDocFactory(value);
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/list.ts
|
|
268
|
+
const list = (value = []) => {
|
|
269
|
+
const container = new loro_runtime_bundler_exports.LoroList();
|
|
270
|
+
value.forEach((item, i) => {
|
|
271
|
+
if ((0, loro_runtime_bundler_exports.isContainer)(item)) container.insertContainer(i, item);
|
|
272
|
+
else container.insert(i, item);
|
|
273
|
+
});
|
|
274
|
+
return container;
|
|
275
|
+
};
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/map.ts
|
|
278
|
+
const map = (value = []) => {
|
|
279
|
+
const container = new loro_runtime_bundler_exports.LoroMap();
|
|
280
|
+
value.forEach(([key, item]) => {
|
|
281
|
+
if ((0, loro_runtime_bundler_exports.isContainer)(item)) container.setContainer(key, item);
|
|
282
|
+
else container.set(key, item);
|
|
283
|
+
});
|
|
284
|
+
return container;
|
|
285
|
+
};
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/movableList.ts
|
|
288
|
+
const movableList = (value = []) => {
|
|
289
|
+
const container = new loro_runtime_bundler_exports.LoroMovableList();
|
|
290
|
+
value.forEach((item, i) => {
|
|
291
|
+
if ((0, loro_runtime_bundler_exports.isContainer)(item)) container.insertContainer(i, item);
|
|
292
|
+
else container.insert(i, item);
|
|
293
|
+
});
|
|
294
|
+
return container;
|
|
295
|
+
};
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/object.ts
|
|
298
|
+
const object = (value) => {
|
|
299
|
+
const container = new loro_runtime_bundler_exports.LoroMap();
|
|
300
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
301
|
+
if ((0, loro_runtime_bundler_exports.isContainer)(item)) container.setContainer(key, item);
|
|
302
|
+
else container.set(key, item);
|
|
303
|
+
});
|
|
304
|
+
return container;
|
|
305
|
+
};
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/text.ts
|
|
308
|
+
const text = (value = "") => {
|
|
309
|
+
const container = new loro_runtime_bundler_exports.LoroText();
|
|
310
|
+
container.insert(0, value);
|
|
311
|
+
return container;
|
|
312
|
+
};
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/tree.ts
|
|
315
|
+
const tree = () => {
|
|
316
|
+
return new loro_runtime_bundler_exports.LoroTree();
|
|
317
|
+
};
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/loro.ts
|
|
320
|
+
var loro_exports = /* @__PURE__ */ __exportAll({
|
|
321
|
+
CrdtLoroDoc: () => CrdtLoroDoc,
|
|
322
|
+
counter: () => counter,
|
|
323
|
+
doc: () => doc,
|
|
324
|
+
kind: () => kind,
|
|
325
|
+
list: () => list,
|
|
326
|
+
map: () => map,
|
|
327
|
+
movableList: () => movableList,
|
|
328
|
+
object: () => object,
|
|
329
|
+
text: () => text,
|
|
330
|
+
tree: () => tree
|
|
331
|
+
});
|
|
332
|
+
const kind = "loro";
|
|
333
|
+
//#endregion
|
|
334
|
+
export { loro_exports as loro };
|
|
335
|
+
|
|
336
|
+
//# sourceMappingURL=bundler.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler.mjs","names":["LoroCounter","LoroDoc","#_storage","#_setPluvId","#_undoManager","LoroText","LoroCounter","LoroList","LoroMap","LoroMovableList","LoroTree","container","UndoManager","LoroList","LoroMap","LoroMovableList","LoroMap","LoroText","LoroTree"],"sources":["../src/loro-runtime.bundler.ts","../src/counter.ts","../src/doc/builder.ts","../src/doc/CrdtLoroDoc.ts","../src/doc/CrdtLoroDocFactory.ts","../src/doc/doc.ts","../src/list.ts","../src/map.ts","../src/movableList.ts","../src/object.ts","../src/text.ts","../src/tree.ts","../src/loro.ts"],"sourcesContent":["export * from \"loro-crdt/bundler\";\n","import { LoroCounter } from \"@loro-runtime\";\nimport { LoroType } from \"./types\";\n\nexport const counter = (): LoroCounter => {\n const counter = new LoroCounter();\n\n return counter as unknown as LoroType<LoroCounter, number>;\n};\n","import type {\n Container,\n LoroCounter,\n LoroDoc,\n LoroList,\n LoroMap,\n LoroMovableList,\n LoroText,\n} from \"@loro-runtime\";\nimport { isContainer } from \"@loro-runtime\";\nimport type { LoroType } from \"../types\";\n\nexport type LoroBuilder = ReturnType<typeof builder>;\n\nexport const builder = (doc: LoroDoc) => {\n return {\n counter(name: string): LoroCounter {\n return doc.getCounter(name);\n },\n list<T extends unknown>(\n name: string,\n value: T[] | readonly T[] = [],\n ): LoroType<LoroList<T>, T[]> {\n const list = doc.getList(name);\n\n value.forEach((item, i) => {\n if (isContainer(item)) list.insertContainer(i, item);\n else list.insert(i, item as Exclude<T, Container>);\n });\n\n return list as unknown as LoroType<LoroList<T>, T[]>;\n },\n map<T extends Record<string, unknown>>(\n name: string,\n value: T = {} as T,\n ): LoroType<LoroMap<T>, T> {\n const container = doc.getMap(name);\n\n Object.entries(value).forEach(([key, item]) => {\n if (isContainer(item)) container.setContainer(key, item);\n else container.set(key, item as Exclude<T, Container>);\n });\n\n return container as unknown as LoroType<LoroMap<T>, T>;\n },\n moveableList<T extends unknown>(\n name: string,\n value: T[] | readonly T[] = [],\n ): LoroType<LoroMovableList<T>, T[]> {\n const list = doc.getMovableList(name);\n\n value.forEach((item, i) => {\n if (isContainer(item)) list.insertContainer(i, item);\n else list.insert(i, item as Exclude<T, Container>);\n });\n\n return list as unknown as LoroType<LoroMovableList<T>, T[]>;\n },\n text(name: string, value: string = \"\"): LoroType<LoroText, string> {\n const text = doc.getText(name);\n\n text.insert(0, value);\n\n return text as unknown as LoroType<LoroText, string>;\n },\n tree(name: string) {\n return doc.getTree(name);\n },\n };\n};\n","import type {\n DocApplyEncodedStateParams,\n DocBatchApplyEncodedStateParams,\n DocSubscribeCallbackParams,\n InferCrdtJson,\n} from \"@pluv/crdt\";\nimport type { CrdtDocLike } from \"@pluv/types\";\nimport { fromUint8Array, toUint8Array } from \"js-base64\";\nimport type { Container } from \"@loro-runtime\";\nimport {\n LoroCounter,\n LoroDoc,\n LoroEventBatch,\n LoroList,\n LoroMap,\n LoroMovableList,\n LoroText,\n LoroTree,\n UndoManager,\n} from \"@loro-runtime\";\nimport type { LoroType } from \"../types\";\nimport type { LoroBuilder } from \"./builder\";\nimport { builder } from \"./builder\";\n\nconst MAX_UNDO_STEPS = 100;\nconst MERGE_INTERVAL_MS = 1_000;\nconst PLUV_ID_FIELD = \"__$pluv\";\n\nexport type CrdtLoroDocParams<TStorage extends Record<string, LoroType<any, any>>> = (\n builder: LoroBuilder,\n) => TStorage;\n\nexport class CrdtLoroDoc<\n TStorage extends Record<string, LoroType<any, any>>,\n> implements CrdtDocLike<LoroDoc, TStorage> {\n public value: LoroDoc = new LoroDoc();\n\n #_storage: TStorage;\n #_undoManager: UndoManager | null = null;\n\n constructor(params: CrdtLoroDocParams<TStorage> = () => ({}) as TStorage) {\n const storage = params(builder(this.value));\n\n const keys = Object.keys(this.value.toJSON()).reduce(\n (set, key) => set.add(key),\n new Set<string>(),\n );\n\n this.#_storage = Object.entries(storage).reduce(\n (acc, [key, node]) => (keys.has(key) ? { ...acc, [key]: node } : acc),\n {} as TStorage,\n );\n if (!!Object.keys(storage).length) this.#_setPluvId();\n\n this.value.commit();\n }\n\n public applyEncodedState(params: DocApplyEncodedStateParams): this {\n const update =\n typeof params.update === \"string\" ? toUint8Array(params.update) : params.update;\n\n if (!update) return this;\n\n this.value.import(update);\n\n return this;\n }\n\n public batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this {\n const updates = params.updates ?? [];\n\n const filtered = updates.reduce<Uint8Array[]>((acc, update) => {\n if (!update) return acc;\n\n if (typeof update === \"string\") {\n acc.push(toUint8Array(update));\n return acc;\n }\n\n if (typeof update === \"object\") {\n acc.push(update);\n return acc;\n }\n\n return acc;\n }, []);\n\n if (!filtered.length) return this;\n\n if (filtered.length === 1) {\n const update = filtered[0] ?? null;\n\n if (!!update) this.value.import(update);\n\n return this;\n }\n\n this.value.importBatch(filtered);\n\n return this;\n }\n\n public canRedo(): boolean {\n if (!this.#_undoManager) return false;\n\n return this.#_undoManager.canRedo();\n }\n\n public canUndo(): boolean {\n if (!this.#_undoManager) return false;\n\n return this.#_undoManager.canUndo();\n }\n\n public destroy(): void {\n return;\n }\n\n public get(key?: undefined): TStorage;\n public get<TKey extends keyof TStorage>(key: TKey): TStorage[TKey];\n public get<TKey extends keyof TStorage>(key?: TKey): TStorage | TStorage[TKey] {\n if (typeof key === \"undefined\") return this.#_storage;\n\n return this.#_storage[key as TKey];\n }\n\n public getEncodedState(): string {\n return fromUint8Array(this.value.export({ mode: \"snapshot\" }));\n }\n\n public toJson(): InferCrdtJson<TStorage>;\n public toJson<TKey extends keyof TStorage>(type: TKey): InferCrdtJson<TStorage[TKey]>;\n public toJson<TKey extends keyof TStorage>(type?: TKey) {\n if (typeof type === \"string\") {\n const container = this.#_storage[type] as unknown as Container;\n\n return container instanceof LoroText\n ? container.toString()\n : container instanceof LoroCounter\n ? container.value\n : container.toJSON!();\n }\n\n return Object.entries(this.#_storage).reduce(\n (acc, [key, value]) => ({\n ...(acc as any),\n [key]: value instanceof LoroText ? value.toString() : value.toJSON!(),\n }),\n {} as InferCrdtJson<TStorage>,\n );\n }\n\n public isEmpty(): boolean {\n const serialized = this.value.toJSON();\n\n return !serialized || !Object.keys(serialized).length;\n }\n\n public rebuildStorage(reference: TStorage): this {\n const isBuilt = !!Object.keys(this.#_storage).length;\n\n if (isBuilt) {\n console.warn(\"Attempted to rebuild storage multiple times\");\n return this;\n }\n\n this.#_storage = Object.entries(reference).reduce((acc, [key, node]) => {\n if (node instanceof LoroCounter) return { ...acc, [key]: this.value.getCounter(key) };\n if (node instanceof LoroList) return { ...acc, [key]: this.value.getList(key) };\n if (node instanceof LoroMap) return { ...acc, [key]: this.value.getMap(key) };\n if (node instanceof LoroMovableList) {\n return { ...acc, [key]: this.value.getMovableList(key) };\n }\n if (node instanceof LoroText) return { ...acc, [key]: this.value.getText(key) };\n if (node instanceof LoroTree) return { ...acc, [key]: this.value.getTree(key) };\n\n return acc;\n }, {} as TStorage);\n\n return this.track();\n }\n\n public redo(): this {\n this.#_undoManager?.redo();\n\n return this;\n }\n\n public subscribe(\n listener: (params: DocSubscribeCallbackParams<LoroDoc, TStorage>) => void,\n ): () => void {\n const fn = (event: LoroEventBatch) => {\n const update = fromUint8Array(this.value.export({ mode: \"update\" }));\n\n listener({\n doc: this,\n local: event.by === \"local\",\n origin: event.origin ? String(event.origin) : null,\n update,\n });\n };\n\n const unsubcribeAll = Object.values(this.#_storage).reduce<() => void>(\n (acc, crdtType) => {\n const container = crdtType as unknown as Container;\n const unsubscribe = container.subscribe(fn);\n\n return () => {\n acc();\n unsubscribe();\n };\n },\n () => undefined,\n );\n\n return unsubcribeAll;\n }\n\n public track(): this {\n if (this.#_undoManager) {\n this.#_undoManager.clear();\n this.#_undoManager.free();\n\n this.#_undoManager = null;\n }\n\n this.#_undoManager = new UndoManager(this.value, {\n maxUndoSteps: MAX_UNDO_STEPS,\n mergeInterval: MERGE_INTERVAL_MS,\n });\n\n return this;\n }\n\n /**\n * @description Unlike Yjs, this method is required to be called after each loro operation.\n * @date January 12, 2025\n */\n public transact(fn: () => void): this {\n fn();\n\n this.value.commit();\n\n return this;\n }\n\n public undo(): this {\n this.#_undoManager?.undo();\n\n return this;\n }\n\n #_setPluvId() {\n const text = this.value.getText(PLUV_ID_FIELD);\n const id = typeof crypto !== \"undefined\" ? crypto.randomUUID() : Math.random().toString();\n\n text.insert(0, id);\n }\n}\n","import { AbstractCrdtDocFactory } from \"@pluv/crdt\";\nimport type { LoroDoc } from \"@loro-runtime\";\nimport type { LoroType } from \"../types\";\nimport { CrdtLoroDoc } from \"./CrdtLoroDoc\";\nimport type { LoroBuilder } from \"./builder\";\n\nexport class CrdtLoroDocFactory<\n TStorage extends Record<string, LoroType<any, any>>,\n> extends AbstractCrdtDocFactory<LoroDoc, TStorage> {\n public readonly _initialStorage: (builder: LoroBuilder) => TStorage;\n\n constructor(initialStorage: (builder: LoroBuilder) => TStorage = () => ({}) as TStorage) {\n super(initialStorage);\n\n this._initialStorage = initialStorage;\n }\n\n public getEmpty(): CrdtLoroDoc<TStorage> {\n return new CrdtLoroDoc<TStorage>();\n }\n\n public getFactory(\n initialStorage?: ((builder: LoroBuilder) => TStorage) | undefined,\n ): CrdtLoroDocFactory<TStorage> {\n return new CrdtLoroDocFactory<TStorage>(initialStorage ?? this._initialStorage);\n }\n\n public getInitialized(\n initialStorage?: (builder: LoroBuilder) => TStorage,\n ): CrdtLoroDoc<TStorage> {\n return new CrdtLoroDoc<TStorage>(initialStorage ?? this._initialStorage);\n }\n}\n","import type { LoroType } from \"../types\";\nimport type { LoroBuilder } from \"./builder\";\nimport { CrdtLoroDocFactory } from \"./CrdtLoroDocFactory\";\n\nexport const doc = <TStorage extends Record<string, LoroType<any, any>>>(\n value: (builder: LoroBuilder) => TStorage = () => ({}) as TStorage,\n): CrdtLoroDocFactory<TStorage> => {\n return new CrdtLoroDocFactory<TStorage>(value);\n};\n","import type { Container } from \"@loro-runtime\";\nimport { LoroList, isContainer } from \"@loro-runtime\";\nimport type { LoroType } from \"./types\";\n\nexport const list = <T extends unknown>(\n value: T[] | readonly T[] = [],\n): LoroType<LoroList<T>, T[]> => {\n const container = new LoroList();\n\n value.forEach((item, i) => {\n if (isContainer(item)) container.insertContainer(i, item);\n else container.insert(i, item as Exclude<T, Container>);\n });\n\n return container as unknown as LoroType<LoroList<T>, T[]>;\n};\n","import type { Container } from \"@loro-runtime\";\nimport { LoroMap, isContainer } from \"@loro-runtime\";\nimport type { LoroType } from \"./types\";\n\nexport const map = <T extends unknown>(\n value: readonly (readonly [key: string, value: T])[] = [],\n): LoroType<LoroMap<Record<string, T>>, Record<string, T>> => {\n const container = new LoroMap();\n\n value.forEach(([key, item]) => {\n if (isContainer(item)) container.setContainer(key, item);\n else container.set(key, item as Exclude<T, Container>);\n });\n\n return container as unknown as LoroType<LoroMap<Record<string, T>>, Record<string, T>>;\n};\n","import type { Container } from \"@loro-runtime\";\nimport { isContainer, LoroMovableList } from \"@loro-runtime\";\nimport type { LoroType } from \"./types\";\n\nexport const movableList = <T extends unknown>(value: T[] | readonly T[] = []) => {\n const container = new LoroMovableList();\n\n value.forEach((item, i) => {\n if (isContainer(item)) container.insertContainer(i, item);\n else container.insert(i, item as Exclude<T, Container>);\n });\n\n return container as unknown as LoroType<LoroMovableList<T>, T[]>;\n};\n","import type { Container } from \"@loro-runtime\";\nimport { LoroMap, isContainer } from \"@loro-runtime\";\nimport type { LoroType } from \"./types\";\n\nexport const object = <T extends Record<string, any>>(value: T): LoroType<LoroMap<T>, T> => {\n const container = new LoroMap();\n\n Object.entries(value).forEach(([key, item]) => {\n if (isContainer(item)) container.setContainer(key, item);\n else container.set(key, item as Exclude<T, Container>);\n });\n\n return container as unknown as LoroType<LoroMap<T>, T>;\n};\n","import { LoroText } from \"@loro-runtime\";\nimport type { LoroType } from \"./types\";\n\nexport const text = (value: string = \"\"): LoroType<LoroText, string> => {\n const container = new LoroText();\n\n container.insert(0, value);\n\n return container as unknown as LoroType<LoroText, string>;\n};\n","import { LoroTree } from \"@loro-runtime\";\n\nexport const tree = <T extends Record<string, unknown>>() => {\n const container = new LoroTree<T>();\n\n return container;\n};\n","export { counter } from \"./counter\";\nexport { CrdtLoroDoc, doc } from \"./doc\";\nexport type { LoroBuilder } from \"./doc\";\nexport { list } from \"./list\";\nexport { map } from \"./map\";\nexport { movableList } from \"./movableList\";\nexport { object } from \"./object\";\nexport { text } from \"./text\";\nexport { tree } from \"./tree\";\nexport type { LoroType } from \"./types\";\nexport const kind = \"loro\" as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACGA,MAAa,gBAA6B;CAGtC,OAAO,IAFaA,6BAAAA,YAEP;AACjB;;;ACOA,MAAa,WAAW,QAAiB;CACrC,OAAO;EACH,QAAQ,MAA2B;GAC/B,OAAO,IAAI,WAAW,IAAI;EAC9B;EACA,KACI,MACA,QAA4B,CAAC,GACH;GAC1B,MAAM,OAAO,IAAI,QAAQ,IAAI;GAE7B,MAAM,SAAS,MAAM,MAAM;IACvB,KAAA,GAAA,6BAAA,YAAA,CAAgB,IAAI,GAAG,KAAK,gBAAgB,GAAG,IAAI;SAC9C,KAAK,OAAO,GAAG,IAA6B;GACrD,CAAC;GAED,OAAO;EACX;EACA,IACI,MACA,QAAW,CAAC,GACW;GACvB,MAAM,YAAY,IAAI,OAAO,IAAI;GAEjC,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,UAAU;IAC3C,KAAA,GAAA,6BAAA,YAAA,CAAgB,IAAI,GAAG,UAAU,aAAa,KAAK,IAAI;SAClD,UAAU,IAAI,KAAK,IAA6B;GACzD,CAAC;GAED,OAAO;EACX;EACA,aACI,MACA,QAA4B,CAAC,GACI;GACjC,MAAM,OAAO,IAAI,eAAe,IAAI;GAEpC,MAAM,SAAS,MAAM,MAAM;IACvB,KAAA,GAAA,6BAAA,YAAA,CAAgB,IAAI,GAAG,KAAK,gBAAgB,GAAG,IAAI;SAC9C,KAAK,OAAO,GAAG,IAA6B;GACrD,CAAC;GAED,OAAO;EACX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28 +20,31 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@types/node": "^25.9.
|
|
23
|
+
"@types/node": "^25.9.3",
|
|
24
24
|
"js-base64": "^3.7.8",
|
|
25
|
-
"@pluv/crdt": "^4.0
|
|
26
|
-
"@pluv/types": "^4.0
|
|
25
|
+
"@pluv/crdt": "^4.1.0",
|
|
26
|
+
"@pluv/types": "^4.1.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"loro-crdt": "^1.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"eslint": "^10.
|
|
33
|
-
"loro-crdt": "^1.13.
|
|
32
|
+
"eslint": "^10.5.0",
|
|
33
|
+
"loro-crdt": "^1.13.2",
|
|
34
34
|
"tsdown": "0.22.2",
|
|
35
35
|
"typescript": "^5.9.3",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
36
|
+
"eslint-config-pluv": "^4.1.0",
|
|
37
|
+
"@pluv/tsconfig": "^4.1.0"
|
|
38
38
|
},
|
|
39
39
|
"exports": {
|
|
40
40
|
".": {
|
|
41
41
|
"types": "./dist/browser.d.mts",
|
|
42
|
-
"
|
|
42
|
+
"workerd": "./dist/bundler.mjs",
|
|
43
|
+
"deno": "./dist/node.mjs",
|
|
43
44
|
"node": "./dist/node.mjs",
|
|
44
|
-
"
|
|
45
|
+
"bun": "./dist/bundler.mjs",
|
|
46
|
+
"browser": "./dist/browser.mjs",
|
|
47
|
+
"default": "./dist/bundler.mjs"
|
|
45
48
|
},
|
|
46
49
|
"./browser": {
|
|
47
50
|
"types": "./dist/browser.d.mts",
|
|
@@ -51,10 +54,26 @@
|
|
|
51
54
|
"types": "./dist/browser.d.mts",
|
|
52
55
|
"default": "./dist/node.mjs"
|
|
53
56
|
},
|
|
57
|
+
"./bundler": {
|
|
58
|
+
"types": "./dist/browser.d.mts",
|
|
59
|
+
"default": "./dist/bundler.mjs"
|
|
60
|
+
},
|
|
61
|
+
"./workerd": {
|
|
62
|
+
"types": "./dist/browser.d.mts",
|
|
63
|
+
"default": "./dist/bundler.mjs"
|
|
64
|
+
},
|
|
65
|
+
"./bun": {
|
|
66
|
+
"types": "./dist/browser.d.mts",
|
|
67
|
+
"default": "./dist/bundler.mjs"
|
|
68
|
+
},
|
|
69
|
+
"./deno": {
|
|
70
|
+
"types": "./dist/browser.d.mts",
|
|
71
|
+
"default": "./dist/node.mjs"
|
|
72
|
+
},
|
|
54
73
|
"./*": "./*"
|
|
55
74
|
},
|
|
56
75
|
"scripts": {
|
|
57
|
-
"build": "tsdown --config tsdown.browser.config.ts && tsdown --config tsdown.node.config.ts",
|
|
76
|
+
"build": "tsdown --config tsdown.browser.config.ts && tsdown --config tsdown.bundler.config.ts && tsdown --config tsdown.node.config.ts",
|
|
58
77
|
"dev": "tsdown --config tsdown.browser.config.ts --watch",
|
|
59
78
|
"lint": "eslint \"src/**/*.ts*\" --fix --max-warnings 0",
|
|
60
79
|
"typecheck": "tsc --noEmit",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "loro-crdt/bundler";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from "tsdown";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: { bundler: "src/index.ts" },
|
|
5
|
+
alias: {
|
|
6
|
+
"@loro-runtime": "./src/loro-runtime.bundler.ts",
|
|
7
|
+
},
|
|
8
|
+
format: ["esm"],
|
|
9
|
+
target: "esnext",
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
tsconfig: "tsconfig.bundler.build.json",
|
|
12
|
+
dts: false,
|
|
13
|
+
outDir: "dist",
|
|
14
|
+
clean: false,
|
|
15
|
+
});
|
package/tsdown.config.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import browserConfig from "./tsdown.browser.config.ts";
|
|
2
|
+
import bundlerConfig from "./tsdown.bundler.config.ts";
|
|
2
3
|
import nodeConfig from "./tsdown.node.config.ts";
|
|
3
4
|
|
|
4
|
-
export default [browserConfig, nodeConfig];
|
|
5
|
+
export default [browserConfig, bundlerConfig, nodeConfig];
|
|
File without changes
|