@welshman/domain 0.9.0-pre3 → 0.9.0-pre4
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/dist/lib/src/LRUCache.d.ts +0 -1
- package/dist/lib/src/LRUCache.d.ts.map +1 -1
- package/dist/lib/src/LRUCache.js +9 -10
- package/dist/lib/src/LRUCache.js.map +1 -1
- package/dist/signer/src/signers/nip55.d.ts +46 -6
- package/dist/signer/src/signers/nip55.d.ts.map +1 -1
- package/dist/signer/src/signers/nip55.js +53 -54
- package/dist/signer/src/signers/nip55.js.map +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LRUCache.d.ts","sourceRoot":"","sources":["../../../../lib/src/LRUCache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"LRUCache.d.ts","sourceRoot":"","sources":["../../../../lib/src/LRUCache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC;IAGZ,QAAQ,CAAC,OAAO,EAAE,MAAM;IAFpC,GAAG,YAAkB;gBAEA,OAAO,GAAE,MAAiB;IAE/C,GAAG,CAAC,CAAC,EAAE,CAAC;IAIR,GAAG,CAAC,CAAC,EAAE,CAAC;IAWR,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAWd,GAAG,CAAC,CAAC,EAAE,CAAC;CAOT;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,SAAS,GAAG,EAAE,EAAE,EAC/C,OAAO,EACP,MAAM,EACN,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,CAAA;IACzB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,CAAA;CAC5B;cAGuB,IAAI;;mBALX,IAAI,KAAK,CAAC;qBACR,IAAI,KAAK,CAAC;mBAcL,IAAI;EAY3B;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,SAAS,GAAG,EAAE,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC;;;;;;EAE7E"}
|
package/dist/lib/src/LRUCache.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
export class LRUCache {
|
|
7
7
|
maxSize;
|
|
8
8
|
map = new Map();
|
|
9
|
-
keys = [];
|
|
10
9
|
constructor(maxSize = Infinity) {
|
|
11
10
|
this.maxSize = maxSize;
|
|
12
11
|
}
|
|
@@ -14,24 +13,24 @@ export class LRUCache {
|
|
|
14
13
|
return this.map.has(k);
|
|
15
14
|
}
|
|
16
15
|
get(k) {
|
|
16
|
+
if (!this.map.has(k))
|
|
17
|
+
return;
|
|
17
18
|
const v = this.map.get(k);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (this.keys.length > this.maxSize * 2) {
|
|
21
|
-
this.keys = this.keys.splice(-this.maxSize);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
19
|
+
this.map.delete(k);
|
|
20
|
+
this.map.set(k, v);
|
|
24
21
|
return v;
|
|
25
22
|
}
|
|
26
23
|
set(k, v) {
|
|
24
|
+
this.map.delete(k);
|
|
27
25
|
this.map.set(k, v);
|
|
28
|
-
this.keys.push(k);
|
|
29
26
|
if (this.map.size > this.maxSize) {
|
|
30
|
-
this.map.
|
|
27
|
+
const oldest = this.map.keys().next();
|
|
28
|
+
if (!oldest.done)
|
|
29
|
+
this.map.delete(oldest.value);
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
pop(k) {
|
|
34
|
-
const v = this.get(k);
|
|
33
|
+
const v = this.map.get(k);
|
|
35
34
|
this.map.delete(k);
|
|
36
35
|
return v;
|
|
37
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LRUCache.js","sourceRoot":"","sources":["../../../../lib/src/LRUCache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,QAAQ;
|
|
1
|
+
{"version":3,"file":"LRUCache.js","sourceRoot":"","sources":["../../../../lib/src/LRUCache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IAGE;IAFrB,GAAG,GAAG,IAAI,GAAG,EAAQ,CAAA;IAErB,YAAqB,UAAkB,QAAQ;QAA1B,YAAO,GAAP,OAAO,CAAmB;IAAG,CAAC;IAEnD,GAAG,CAAC,CAAI;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACxB,CAAC;IAED,GAAG,CAAC,CAAI;QACN,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAM;QAE5B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAM,CAAA;QAE9B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAClB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAElB,OAAO,CAAC,CAAA;IACV,CAAC;IAED,GAAG,CAAC,CAAI,EAAE,CAAI;QACZ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAClB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAElB,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAA;YAErC,IAAI,CAAC,MAAM,CAAC,IAAI;gBAAE,IAAI,CAAC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AG,CAAA;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAwB,QAA2B;IAC5E,OAAO,MAAM,CAAC,EAAC,OAAO,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAC,CAAC,CAAA;AACzE,CAAC"}
|
|
@@ -1,7 +1,47 @@
|
|
|
1
|
-
import { AppInfo } from "nostr-signer-capacitor-plugin";
|
|
2
1
|
import { SignedEvent, StampedEvent } from "@welshman/util";
|
|
3
2
|
import { SignOptions, ISigner } from "../util.js";
|
|
4
|
-
export
|
|
3
|
+
export type Nip55AppInfo = {
|
|
4
|
+
name: string;
|
|
5
|
+
packageName: string;
|
|
6
|
+
iconUrl?: string;
|
|
7
|
+
};
|
|
8
|
+
export type Nip55Crypt = (packageName: string, text: string, id: string, pubKey: string, npub: string) => Promise<{
|
|
9
|
+
result: string;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* The part of nostr-signer-capacitor-plugin's `NostrSignerPlugin` that
|
|
13
|
+
* `Nip55Signer` uses, declared structurally so this package never imports the
|
|
14
|
+
* plugin. It only exists in Capacitor apps, and a bundler can't resolve a
|
|
15
|
+
* package that was never installed.
|
|
16
|
+
*/
|
|
17
|
+
export type Nip55 = {
|
|
18
|
+
setPackageName: (packageName: string) => Promise<void>;
|
|
19
|
+
getInstalledSignerApps: () => Promise<{
|
|
20
|
+
apps: Nip55AppInfo[];
|
|
21
|
+
}>;
|
|
22
|
+
getPublicKey: (packageName?: string) => Promise<{
|
|
23
|
+
npub: string;
|
|
24
|
+
}>;
|
|
25
|
+
signEvent: (packageName: string, eventJson: string, id: string, npub: string) => Promise<{
|
|
26
|
+
event: string;
|
|
27
|
+
}>;
|
|
28
|
+
nip04Encrypt: Nip55Crypt;
|
|
29
|
+
nip04Decrypt: Nip55Crypt;
|
|
30
|
+
nip44Encrypt: Nip55Crypt;
|
|
31
|
+
nip44Decrypt: Nip55Crypt;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Register the NIP-55 plugin. Capacitor apps should call this once at startup:
|
|
35
|
+
*
|
|
36
|
+
* import {NostrSignerPlugin} from "nostr-signer-capacitor-plugin"
|
|
37
|
+
* import {setNip55Plugin} from "@welshman/signer"
|
|
38
|
+
*
|
|
39
|
+
* setNip55Plugin(NostrSignerPlugin)
|
|
40
|
+
*/
|
|
41
|
+
export declare const setNip55Plugin: (nip55: Nip55 | undefined) => void;
|
|
42
|
+
export declare const getNip55Plugin: () => Nip55 | undefined;
|
|
43
|
+
/** Installed signer apps, or an empty list if no plugin has been registered. */
|
|
44
|
+
export declare const getNip55: () => Promise<Nip55AppInfo[]>;
|
|
5
45
|
export declare class Nip55Signer implements ISigner {
|
|
6
46
|
#private;
|
|
7
47
|
readonly packageName: string;
|
|
@@ -9,12 +49,12 @@ export declare class Nip55Signer implements ISigner {
|
|
|
9
49
|
getPubkey: () => Promise<string>;
|
|
10
50
|
sign: (template: StampedEvent, options?: SignOptions) => Promise<SignedEvent>;
|
|
11
51
|
nip04: {
|
|
12
|
-
encrypt: (
|
|
13
|
-
decrypt: (
|
|
52
|
+
encrypt: (pubkey: string, message: string) => Promise<string>;
|
|
53
|
+
decrypt: (pubkey: string, message: string) => Promise<string>;
|
|
14
54
|
};
|
|
15
55
|
nip44: {
|
|
16
|
-
encrypt: (
|
|
17
|
-
decrypt: (
|
|
56
|
+
encrypt: (pubkey: string, message: string) => Promise<string>;
|
|
57
|
+
decrypt: (pubkey: string, message: string) => Promise<string>;
|
|
18
58
|
};
|
|
19
59
|
}
|
|
20
60
|
//# sourceMappingURL=nip55.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nip55.d.ts","sourceRoot":"","sources":["../../../../../signer/src/signers/nip55.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nip55.d.ts","sourceRoot":"","sources":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SAEtD,CAAA;AAED,eAAO,MAAM,cAAc,yBAAe,CAAA;AAE1C,gFAAgF;AAChF,eAAO,MAAM,QAAQ,QAAa,OAAO,CAAC,YAAY,EAAE,CAMvD,CAAA;AAID,qBAAa,WAAY,YAAW,OAAO;;IAMvC,QAAQ,CAAC,WAAW,EAAE,MAAM;gBAAnB,WAAW,EAAE,MAAM,EAC5B,MAAM,CAAC,EAAE,MAAM;IAmDjB,SAAS,QAAa,OAAO,CAAC,MAAM,CAAC,CAUpC;IAED,IAAI,GAAI,UAAU,YAAY,EAAE,UAAS,WAAgB,KAAG,OAAO,CAAC,WAAW,CAAC,CAiB7E;IAEH,KAAK;0BACe,MAAM,WAAW,MAAM;0BACvB,MAAM,WAAW,MAAM;MAC1C;IAED,KAAK;0BACe,MAAM,WAAW,MAAM;0BACvB,MAAM,WAAW,MAAM;MAC1C;CACF"}
|
|
@@ -1,28 +1,67 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { noop } from "@welshman/lib";
|
|
2
2
|
import { hash, own, Pubkey } from "@welshman/util";
|
|
3
3
|
import { signWithOptions } from "../util.js";
|
|
4
|
+
let plugin;
|
|
5
|
+
/**
|
|
6
|
+
* Register the NIP-55 plugin. Capacitor apps should call this once at startup:
|
|
7
|
+
*
|
|
8
|
+
* import {NostrSignerPlugin} from "nostr-signer-capacitor-plugin"
|
|
9
|
+
* import {setNip55Plugin} from "@welshman/signer"
|
|
10
|
+
*
|
|
11
|
+
* setNip55Plugin(NostrSignerPlugin)
|
|
12
|
+
*/
|
|
13
|
+
export const setNip55Plugin = (nip55) => {
|
|
14
|
+
plugin = nip55;
|
|
15
|
+
};
|
|
16
|
+
export const getNip55Plugin = () => plugin;
|
|
17
|
+
/** Installed signer apps, or an empty list if no plugin has been registered. */
|
|
4
18
|
export const getNip55 = async () => {
|
|
5
|
-
|
|
19
|
+
if (!plugin)
|
|
20
|
+
return [];
|
|
21
|
+
const { apps } = await plugin.getInstalledSignerApps();
|
|
6
22
|
return apps;
|
|
7
23
|
};
|
|
24
|
+
const makeRequestId = () => `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
8
25
|
export class Nip55Signer {
|
|
9
26
|
packageName;
|
|
10
27
|
#pubkey;
|
|
11
|
-
#lock;
|
|
28
|
+
#lock = Promise.resolve();
|
|
29
|
+
#setup;
|
|
12
30
|
constructor(packageName, pubkey) {
|
|
13
31
|
this.packageName = packageName;
|
|
14
32
|
this.#pubkey = pubkey;
|
|
15
|
-
this.#lock = NostrSignerPlugin.setPackageName(packageName);
|
|
16
33
|
}
|
|
17
34
|
#then = async (f) => {
|
|
18
|
-
const promise = this.#lock.then(
|
|
19
|
-
|
|
35
|
+
const promise = this.#lock.then(async () => {
|
|
36
|
+
const nip55 = plugin;
|
|
37
|
+
if (!nip55)
|
|
38
|
+
throw new Error("Nip55 is not enabled");
|
|
39
|
+
if (!this.#setup) {
|
|
40
|
+
this.#setup = nip55.setPackageName(this.packageName);
|
|
41
|
+
this.#setup.catch(() => {
|
|
42
|
+
this.#setup = undefined;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
await this.#setup;
|
|
46
|
+
return f(nip55);
|
|
47
|
+
});
|
|
48
|
+
// Swallow the result either way — a failed call must not poison the lock
|
|
49
|
+
this.#lock = promise.then(noop, noop);
|
|
20
50
|
return promise;
|
|
21
51
|
};
|
|
52
|
+
#crypt = async (method, pubkey, message) => {
|
|
53
|
+
if (!this.#pubkey) {
|
|
54
|
+
await this.getPubkey();
|
|
55
|
+
}
|
|
56
|
+
return this.#then(async (plugin) => {
|
|
57
|
+
const { result } = await plugin[method](this.packageName, message, makeRequestId(), pubkey, this.#pubkey);
|
|
58
|
+
return result;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
22
61
|
getPubkey = async () => {
|
|
23
|
-
return this.#then(async () => {
|
|
62
|
+
return this.#then(async (plugin) => {
|
|
24
63
|
if (!this.#pubkey) {
|
|
25
|
-
const { npub } = await
|
|
64
|
+
const { npub } = await plugin.getPublicKey(this.packageName);
|
|
26
65
|
this.#pubkey = Pubkey.from(npub).toString();
|
|
27
66
|
}
|
|
28
67
|
return this.#pubkey;
|
|
@@ -30,58 +69,18 @@ export class Nip55Signer {
|
|
|
30
69
|
};
|
|
31
70
|
sign = (template, options = {}) => signWithOptions(this.getPubkey().then(pubkey => {
|
|
32
71
|
const hashedEvent = hash(own(template, pubkey));
|
|
33
|
-
return this.#then(async () => {
|
|
34
|
-
const { event: json } = await
|
|
72
|
+
return this.#then(async (plugin) => {
|
|
73
|
+
const { event: json } = await plugin.signEvent(this.packageName, JSON.stringify({ sig: "", ...hashedEvent }), hashedEvent.id, this.#pubkey);
|
|
35
74
|
return JSON.parse(json);
|
|
36
75
|
});
|
|
37
76
|
}), options);
|
|
38
77
|
nip04 = {
|
|
39
|
-
encrypt:
|
|
40
|
-
|
|
41
|
-
if (!myPubkey) {
|
|
42
|
-
await this.getPubkey();
|
|
43
|
-
}
|
|
44
|
-
return this.#then(async () => {
|
|
45
|
-
const id = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
46
|
-
const { result } = await NostrSignerPlugin.nip04Encrypt(this.packageName, message, id, recipientPubKey, this.#pubkey);
|
|
47
|
-
return result;
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
decrypt: async (senderPubKey, message) => {
|
|
51
|
-
const myPubkey = this.#pubkey;
|
|
52
|
-
if (!myPubkey) {
|
|
53
|
-
await this.getPubkey();
|
|
54
|
-
}
|
|
55
|
-
return this.#then(async () => {
|
|
56
|
-
const id = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
57
|
-
const { result } = await NostrSignerPlugin.nip04Decrypt(this.packageName, message, id, senderPubKey, this.#pubkey);
|
|
58
|
-
return result;
|
|
59
|
-
});
|
|
60
|
-
},
|
|
78
|
+
encrypt: (pubkey, message) => this.#crypt("nip04Encrypt", pubkey, message),
|
|
79
|
+
decrypt: (pubkey, message) => this.#crypt("nip04Decrypt", pubkey, message),
|
|
61
80
|
};
|
|
62
81
|
nip44 = {
|
|
63
|
-
encrypt:
|
|
64
|
-
|
|
65
|
-
if (!myPubkey) {
|
|
66
|
-
await this.getPubkey();
|
|
67
|
-
}
|
|
68
|
-
return this.#then(async () => {
|
|
69
|
-
const id = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
70
|
-
const { result } = await NostrSignerPlugin.nip44Encrypt(this.packageName, message, id, recipientPubKey, this.#pubkey);
|
|
71
|
-
return result;
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
decrypt: async (senderPubKey, message) => {
|
|
75
|
-
const myPubkey = this.#pubkey;
|
|
76
|
-
if (!myPubkey) {
|
|
77
|
-
await this.getPubkey();
|
|
78
|
-
}
|
|
79
|
-
return this.#then(async () => {
|
|
80
|
-
const id = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
81
|
-
const { result } = await NostrSignerPlugin.nip44Decrypt(this.packageName, message, id, senderPubKey, this.#pubkey);
|
|
82
|
-
return result;
|
|
83
|
-
});
|
|
84
|
-
},
|
|
82
|
+
encrypt: (pubkey, message) => this.#crypt("nip44Encrypt", pubkey, message),
|
|
83
|
+
decrypt: (pubkey, message) => this.#crypt("nip44Decrypt", pubkey, message),
|
|
85
84
|
};
|
|
86
85
|
}
|
|
87
86
|
//# sourceMappingURL=nip55.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nip55.js","sourceRoot":"","sources":["../../../../../signer/src/signers/nip55.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"nip55.js","sourceRoot":"","sources":["../../../../../signer/src/signers/nip55.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAA;AAClC,OAAO,EAA4B,IAAI,EAAE,GAAG,EAAE,MAAM,EAAC,MAAM,gBAAgB,CAAA;AAC3E,OAAO,EAAC,eAAe,EAAuB,MAAM,YAAY,CAAA;AAsChE,IAAI,MAAyB,CAAA;AA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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@welshman/domain",
|
|
3
|
-
"version": "0.9.0-
|
|
3
|
+
"version": "0.9.0-pre4",
|
|
4
4
|
"author": "hodlbod",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Stateless utilities for translating nostr events to and from domain objects.",
|
|
@@ -15,21 +15,21 @@
|
|
|
15
15
|
],
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"nostr-tools": "^2.19.4",
|
|
18
|
-
"@welshman/feeds": "0.9.0-
|
|
19
|
-
"@welshman/
|
|
20
|
-
"@welshman/
|
|
21
|
-
"@welshman/
|
|
22
|
-
"@welshman/lib": "0.9.0-
|
|
18
|
+
"@welshman/feeds": "0.9.0-pre4",
|
|
19
|
+
"@welshman/util": "0.9.0-pre4",
|
|
20
|
+
"@welshman/net": "0.9.0-pre4",
|
|
21
|
+
"@welshman/signer": "0.9.0-pre4",
|
|
22
|
+
"@welshman/lib": "0.9.0-pre4"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"nostr-tools": "^2.19.4",
|
|
26
26
|
"rimraf": "~6.0.0",
|
|
27
27
|
"typescript": "~5.8.0",
|
|
28
|
-
"@welshman/feeds": "0.9.0-
|
|
29
|
-
"@welshman/signer": "0.9.0-
|
|
30
|
-
"@welshman/
|
|
31
|
-
"@welshman/
|
|
32
|
-
"@welshman/lib": "0.9.0-
|
|
28
|
+
"@welshman/feeds": "0.9.0-pre4",
|
|
29
|
+
"@welshman/signer": "0.9.0-pre4",
|
|
30
|
+
"@welshman/net": "0.9.0-pre4",
|
|
31
|
+
"@welshman/util": "0.9.0-pre4",
|
|
32
|
+
"@welshman/lib": "0.9.0-pre4"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "pnpm run clean && pnpm run compile --force",
|