@wovin/core 0.0.1-RC20 → 0.0.1-RC21
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/applog.js +5 -4
- package/dist/chunk-3VDDRHGD.js +9854 -0
- package/dist/chunk-3VDDRHGD.js.map +1 -0
- package/dist/{chunk-RBXGBMA7.js → chunk-5FO6VRGW.js} +16 -5
- package/dist/chunk-5FO6VRGW.js.map +1 -0
- package/dist/chunk-AWVTEBES.js +7 -0
- package/dist/chunk-AWVTEBES.js.map +1 -0
- package/dist/chunk-JHX2WWYS.js +78766 -0
- package/dist/chunk-JHX2WWYS.js.map +1 -0
- package/dist/{chunk-XJPITJRE.js → chunk-JI36NHJX.js} +18 -6
- package/dist/chunk-JI36NHJX.js.map +1 -0
- package/dist/chunk-MTQJBBHB.js +4586 -0
- package/dist/chunk-MTQJBBHB.js.map +1 -0
- package/dist/chunk-TIIA4ZAI.js +56 -0
- package/dist/chunk-TIIA4ZAI.js.map +1 -0
- package/dist/chunk-TYUDGJVU.js +7 -0
- package/dist/chunk-TYUDGJVU.js.map +1 -0
- package/dist/chunk-YJXKRB2D.js +7651 -0
- package/dist/chunk-YJXKRB2D.js.map +1 -0
- package/dist/chunk-YNB6ALUV.js +56 -0
- package/dist/chunk-YNB6ALUV.js.map +1 -0
- package/dist/index.js +13 -9
- package/dist/index.js.map +1 -1
- package/dist/ipfs.js +4 -3
- package/dist/pubsub.js +5 -4
- package/dist/query.js +5 -4
- package/dist/stream.js +4 -3
- package/dist/types.js +5 -4
- package/dist/utils.js +6 -0
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6ZDPEEFN.js +0 -67
- package/dist/chunk-6ZDPEEFN.js.map +0 -1
- package/dist/chunk-DBACGNVR.js +0 -1
- package/dist/chunk-DBACGNVR.js.map +0 -1
- package/dist/chunk-I5PELB4T.js +0 -770
- package/dist/chunk-I5PELB4T.js.map +0 -1
- package/dist/chunk-K2JRTCRC.js +0 -44
- package/dist/chunk-K2JRTCRC.js.map +0 -1
- package/dist/chunk-RBXGBMA7.js.map +0 -1
- package/dist/chunk-TR5AJKIN.js +0 -1
- package/dist/chunk-TR5AJKIN.js.map +0 -1
- package/dist/chunk-VKQDEGWA.js +0 -561
- package/dist/chunk-VKQDEGWA.js.map +0 -1
- package/dist/chunk-X23XAGRU.js +0 -60
- package/dist/chunk-X23XAGRU.js.map +0 -1
- package/dist/chunk-XJPITJRE.js.map +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_system,
|
|
3
|
+
require_typebox
|
|
4
|
+
} from "./chunk-MTQJBBHB.js";
|
|
5
|
+
import {
|
|
6
|
+
ApplogStream
|
|
7
|
+
} from "./chunk-YJXKRB2D.js";
|
|
8
|
+
import {
|
|
9
|
+
__toESM,
|
|
10
|
+
init_dirname
|
|
11
|
+
} from "./chunk-TIIA4ZAI.js";
|
|
12
|
+
|
|
13
|
+
// src/types.ts
|
|
14
|
+
init_dirname();
|
|
15
|
+
|
|
16
|
+
// src/types/typescript-utils.ts
|
|
17
|
+
init_dirname();
|
|
18
|
+
var import_typebox = __toESM(require_typebox(), 1);
|
|
19
|
+
var import_system = __toESM(require_system(), 1);
|
|
20
|
+
var ApplogStreamTB = import_system.TypeSystem.Type("ApplogStream", (options, value) => {
|
|
21
|
+
return value instanceof ApplogStream;
|
|
22
|
+
})();
|
|
23
|
+
var { String: StringTB, Optional: OptionalTB, Boolean: BooleanTB, Object: ObjectTB, Number: NumberTB } = import_typebox.Type;
|
|
24
|
+
var Str = StringTB.bind(import_typebox.Type);
|
|
25
|
+
var Num = NumberTB.bind(import_typebox.Type);
|
|
26
|
+
var Obj = ObjectTB.bind(import_typebox.Type);
|
|
27
|
+
var Opt = OptionalTB.bind(import_typebox.Type);
|
|
28
|
+
var Bool = BooleanTB.bind(import_typebox.Type);
|
|
29
|
+
var STR = Str();
|
|
30
|
+
var NUM = Num();
|
|
31
|
+
var BOOL = Bool();
|
|
32
|
+
var DefaultTrue = true;
|
|
33
|
+
var DefaultFalse = false;
|
|
34
|
+
function checkParityTB() {
|
|
35
|
+
const s1 = Str();
|
|
36
|
+
const s2 = Str();
|
|
37
|
+
const n1 = Num();
|
|
38
|
+
const n2 = Num();
|
|
39
|
+
console.log({ s1, s2, n1, n2 });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
ApplogStreamTB,
|
|
44
|
+
Str,
|
|
45
|
+
Num,
|
|
46
|
+
Obj,
|
|
47
|
+
Opt,
|
|
48
|
+
Bool,
|
|
49
|
+
STR,
|
|
50
|
+
NUM,
|
|
51
|
+
BOOL,
|
|
52
|
+
DefaultTrue,
|
|
53
|
+
DefaultFalse,
|
|
54
|
+
checkParityTB
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=chunk-YNB6ALUV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/types/typescript-utils.ts"],"sourcesContent":["export * from './types/typescript-utils'\n","import { Type as T } from '@sinclair/typebox'\nimport { TypeSystem } from '@sinclair/typebox/system'\nimport type { CID } from 'multiformats'\nimport { ApplogStream } from '../stream'\n\nexport const ApplogStreamTB = TypeSystem.Type<ApplogStream>('ApplogStream', (options, value) => {\n\treturn value instanceof ApplogStream\n})()\nconst { String: StringTB, Optional: OptionalTB, Boolean: BooleanTB, Object: ObjectTB, Number: NumberTB } = T\nexport const Str: typeof StringTB = StringTB.bind(T)\nexport const Num: typeof NumberTB = NumberTB.bind(T)\nexport const Obj: typeof ObjectTB = ObjectTB.bind(T)\nexport const Opt: typeof OptionalTB = OptionalTB.bind(T)\nexport const Bool: typeof BooleanTB = BooleanTB.bind(T)\n\nexport const STR: ReturnType<typeof T.String> = Str()\nexport const NUM: ReturnType<typeof T.Number> = Num()\nexport const BOOL: ReturnType<typeof T.Boolean> = Bool()\n\nexport type DefaultTrue = true | boolean\nexport const DefaultTrue: DefaultTrue = true\n\nexport type DefaultFalse = false | boolean\nexport const DefaultFalse: DefaultFalse = false\n\nexport type GenericObject = Record<string, any>\nexport type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>\nexport type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\nexport type PromiseType<T extends Promise<any>> = T extends Promise<infer U> ? U : never\n\nexport type CoerceToString<T> = T extends string ? T : never\n\n/**\n * Define nominal type of U based on type of T. Similar to Opaque types in Flow\n */\nexport type Tagged<T, Tag> = T & { tag?: Tag }\n\n// export interface Service {\n// \tendpoint?: URL\n// \ttoken: string\n// \trateLimiter?: RateLimiter\n// \tfetch?: typeof _fetch\n// }\n\n// https://stackoverflow.com/a/76276541\nexport type LastElementOf<T extends readonly unknown[]> = T extends readonly [...unknown[], infer Last] ? Last : never\n\nexport function checkParityTB() {\n\t/* Most examples are constantly calling Type.*() - needed to check if its really needed\n https://github.com/sinclairzx81/typebox/issues/587#issuecomment-1712457623\n */\n\tconst s1 = Str()\n\tconst s2 = Str()\n\tconst n1 = Num()\n\tconst n2 = Num()\n\tconsole.log({ s1, s2, n1, n2 })\n}\n\n/** solidjs Setter requires returning something, which I often don't */\nexport type GenericSetter<T> = (newValue: T) => void\n"],"mappings":";;;;;;;;;;;;;AAAA;;;ACAA;AAAA,qBAA0B;AAC1B,oBAA2B;AAIpB,IAAM,iBAAiB,yBAAW,KAAmB,gBAAgB,CAAC,SAAS,UAAU;AAC/F,SAAO,iBAAiB;AACzB,CAAC,EAAE;AACH,IAAM,EAAE,QAAQ,UAAU,UAAU,YAAY,SAAS,WAAW,QAAQ,UAAU,QAAQ,SAAS,IAAI,eAAAA;AACpG,IAAM,MAAuB,SAAS,KAAK,eAAAA,IAAC;AAC5C,IAAM,MAAuB,SAAS,KAAK,eAAAA,IAAC;AAC5C,IAAM,MAAuB,SAAS,KAAK,eAAAA,IAAC;AAC5C,IAAM,MAAyB,WAAW,KAAK,eAAAA,IAAC;AAChD,IAAM,OAAyB,UAAU,KAAK,eAAAA,IAAC;AAE/C,IAAM,MAAmC,IAAI;AAC7C,IAAM,MAAmC,IAAI;AAC7C,IAAM,OAAqC,KAAK;AAGhD,IAAM,cAA2B;AAGjC,IAAM,eAA6B;AAwBnC,SAAS,gBAAgB;AAI/B,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,IAAI;AACf,QAAM,KAAK,IAAI;AACf,UAAQ,IAAI,EAAE,IAAI,IAAI,IAAI,GAAG,CAAC;AAC/B;","names":["T"]}
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-AWVTEBES.js";
|
|
2
|
+
import "./chunk-TYUDGJVU.js";
|
|
3
3
|
import {
|
|
4
4
|
isPublication,
|
|
5
5
|
isSubscription,
|
|
6
6
|
neverEncryptAttrs,
|
|
7
7
|
preparePubForPush
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5FO6VRGW.js";
|
|
9
9
|
import {
|
|
10
10
|
decodeCar,
|
|
11
11
|
decodeCarToApplogs,
|
|
12
12
|
makeCarBlob,
|
|
13
13
|
makeCarOut
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-3VDDRHGD.js";
|
|
15
15
|
import {
|
|
16
16
|
includedIn,
|
|
17
17
|
includes,
|
|
18
18
|
queryDivergencesByPrev
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-JI36NHJX.js";
|
|
20
20
|
import {
|
|
21
21
|
ApplogStreamTB,
|
|
22
22
|
BOOL,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
STR,
|
|
31
31
|
Str,
|
|
32
32
|
checkParityTB
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-YNB6ALUV.js";
|
|
34
34
|
import {
|
|
35
35
|
AppLogTB,
|
|
36
36
|
AppLogTBC,
|
|
@@ -66,7 +66,7 @@ import {
|
|
|
66
66
|
withTs,
|
|
67
67
|
withoutDeleted,
|
|
68
68
|
withoutHistory
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-MTQJBBHB.js";
|
|
70
70
|
import {
|
|
71
71
|
ApplogStream,
|
|
72
72
|
MappedApplogStream,
|
|
@@ -109,7 +109,7 @@ import {
|
|
|
109
109
|
tsNearlySame,
|
|
110
110
|
uniqueEnFromAppLogs,
|
|
111
111
|
variableNameWithoutQuestionmark
|
|
112
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-YJXKRB2D.js";
|
|
113
113
|
import {
|
|
114
114
|
encodeApplog,
|
|
115
115
|
encodeApplogAndGetCid,
|
|
@@ -117,9 +117,13 @@ import {
|
|
|
117
117
|
encodeBlockOriginal,
|
|
118
118
|
getCidSync,
|
|
119
119
|
prepareForPub
|
|
120
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-JHX2WWYS.js";
|
|
121
|
+
import {
|
|
122
|
+
init_dirname
|
|
123
|
+
} from "./chunk-TIIA4ZAI.js";
|
|
121
124
|
|
|
122
125
|
// src/index.ts
|
|
126
|
+
init_dirname();
|
|
123
127
|
var wovinCoreTest = 12345.7;
|
|
124
128
|
export {
|
|
125
129
|
AppLogTB,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const wovinCoreTest = 12345.7\n\nexport * from './applog'\nexport * from './ipfs'\nexport * from './pubsub'\nexport * from './query'\nexport * from './stream'\nexport * from './types'\n// export * from './utils'\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const wovinCoreTest = 12345.7\n\nexport * from './applog'\nexport * from './ipfs'\nexport * from './pubsub'\nexport * from './query'\nexport * from './stream'\nexport * from './types'\n// export * from './utils'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAO,IAAM,gBAAgB;","names":[]}
|
package/dist/ipfs.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-TYUDGJVU.js";
|
|
2
2
|
import {
|
|
3
3
|
decodeCar,
|
|
4
4
|
decodeCarToApplogs,
|
|
5
5
|
makeCarBlob,
|
|
6
6
|
makeCarOut
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3VDDRHGD.js";
|
|
8
8
|
import {
|
|
9
9
|
encodeApplog,
|
|
10
10
|
encodeApplogAndGetCid,
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
encodeBlockOriginal,
|
|
13
13
|
getCidSync,
|
|
14
14
|
prepareForPub
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-JHX2WWYS.js";
|
|
16
|
+
import "./chunk-TIIA4ZAI.js";
|
|
16
17
|
export {
|
|
17
18
|
decodeCar,
|
|
18
19
|
decodeCarToApplogs,
|
package/dist/pubsub.js
CHANGED
|
@@ -3,10 +3,11 @@ import {
|
|
|
3
3
|
isSubscription,
|
|
4
4
|
neverEncryptAttrs,
|
|
5
5
|
preparePubForPush
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-5FO6VRGW.js";
|
|
7
|
+
import "./chunk-3VDDRHGD.js";
|
|
8
|
+
import "./chunk-YJXKRB2D.js";
|
|
9
|
+
import "./chunk-JHX2WWYS.js";
|
|
10
|
+
import "./chunk-TIIA4ZAI.js";
|
|
10
11
|
export {
|
|
11
12
|
isPublication,
|
|
12
13
|
isSubscription,
|
package/dist/query.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
includedIn,
|
|
3
3
|
includes,
|
|
4
4
|
queryDivergencesByPrev
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-JI36NHJX.js";
|
|
6
6
|
import {
|
|
7
7
|
QueryNode,
|
|
8
8
|
QueryNodes,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
startsWith,
|
|
22
22
|
withoutDeleted,
|
|
23
23
|
withoutHistory
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-MTQJBBHB.js";
|
|
25
25
|
import {
|
|
26
26
|
applogStreamComparer,
|
|
27
27
|
computedFnDeepCompare,
|
|
@@ -31,8 +31,9 @@ import {
|
|
|
31
31
|
observableArrayMap,
|
|
32
32
|
prettifyStreamName,
|
|
33
33
|
queryNodesComparer
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import "./chunk-
|
|
34
|
+
} from "./chunk-YJXKRB2D.js";
|
|
35
|
+
import "./chunk-JHX2WWYS.js";
|
|
36
|
+
import "./chunk-TIIA4ZAI.js";
|
|
36
37
|
export {
|
|
37
38
|
QueryNode,
|
|
38
39
|
QueryNodes,
|
package/dist/stream.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApplogStreamInMemory,
|
|
3
3
|
WriteableApplogStream
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MTQJBBHB.js";
|
|
5
5
|
import {
|
|
6
6
|
ApplogStream,
|
|
7
7
|
MappedApplogStream,
|
|
@@ -15,8 +15,9 @@ import {
|
|
|
15
15
|
rollingAcc,
|
|
16
16
|
rollingFilter,
|
|
17
17
|
rollingMapper
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-YJXKRB2D.js";
|
|
19
|
+
import "./chunk-JHX2WWYS.js";
|
|
20
|
+
import "./chunk-TIIA4ZAI.js";
|
|
20
21
|
export {
|
|
21
22
|
ApplogStream,
|
|
22
23
|
ApplogStreamInMemory,
|
package/dist/types.js
CHANGED
|
@@ -11,10 +11,11 @@ import {
|
|
|
11
11
|
STR,
|
|
12
12
|
Str,
|
|
13
13
|
checkParityTB
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-YNB6ALUV.js";
|
|
15
|
+
import "./chunk-MTQJBBHB.js";
|
|
16
|
+
import "./chunk-YJXKRB2D.js";
|
|
17
|
+
import "./chunk-JHX2WWYS.js";
|
|
18
|
+
import "./chunk-TIIA4ZAI.js";
|
|
18
19
|
export {
|
|
19
20
|
ApplogStreamTB,
|
|
20
21
|
BOOL,
|
package/dist/utils.js
CHANGED
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts"],"sourcesContent":[""],"mappings":";;;;;AAAA;","names":[]}
|
package/package.json
CHANGED
package/dist/chunk-6ZDPEEFN.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// src/ipfs/ipfs-utils.ts
|
|
9
|
-
import * as dagJson from "@ipld/dag-json";
|
|
10
|
-
import { sha256 } from "@noble/hashes/sha256";
|
|
11
|
-
import { Logger } from "besonders-logger";
|
|
12
|
-
import { CID, digest as Digest } from "multiformats";
|
|
13
|
-
import { encode as multiformatsEncode } from "multiformats/block";
|
|
14
|
-
import { sha256 as sha265Hasher } from "multiformats/hashes/sha2";
|
|
15
|
-
var { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO);
|
|
16
|
-
function prepareForPub(log, without = ["cid"]) {
|
|
17
|
-
const logWithout = {};
|
|
18
|
-
for (let [key, val] of Object.entries(log)) {
|
|
19
|
-
if (val === void 0) {
|
|
20
|
-
WARN(`log.${key} is undefined, which is not allowed - encoding as null`, log);
|
|
21
|
-
val = null;
|
|
22
|
-
}
|
|
23
|
-
if (!without.includes(key)) {
|
|
24
|
-
logWithout[key] = val && key === "pv" ? CID.parse(val) : val;
|
|
25
|
-
} else {
|
|
26
|
-
VERBOSE("excluding app log", { key, val });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return logWithout;
|
|
30
|
-
}
|
|
31
|
-
function encodeApplogAndGetCid(log) {
|
|
32
|
-
return getCidSync(encodeApplog(log).bytes);
|
|
33
|
-
}
|
|
34
|
-
function encodeApplog(log) {
|
|
35
|
-
return encodeBlock(prepareForPub(log));
|
|
36
|
-
}
|
|
37
|
-
function getCidSync(bytes) {
|
|
38
|
-
const hash = sha256(bytes);
|
|
39
|
-
const digest = Digest.create(sha265Hasher.code, hash);
|
|
40
|
-
const cid = CID.create(1, dagJson.code, digest);
|
|
41
|
-
VERBOSE(`[getCidSync]`, { bytes, hash, digest, cid });
|
|
42
|
-
return cid;
|
|
43
|
-
}
|
|
44
|
-
function encodeBlock(jsonObject) {
|
|
45
|
-
DEBUG("[encodeBlock]", jsonObject);
|
|
46
|
-
const byteView = dagJson.encode(jsonObject);
|
|
47
|
-
return { bytes: byteView, cid: getCidSync(byteView) };
|
|
48
|
-
}
|
|
49
|
-
async function encodeBlockOriginal(jsonObject) {
|
|
50
|
-
const encoded = await multiformatsEncode({ value: jsonObject, codec: dagJson, hasher: sha265Hasher });
|
|
51
|
-
const syncVariant = encodeBlock(jsonObject);
|
|
52
|
-
if (syncVariant.cid.toString() !== encoded.cid.toString()) {
|
|
53
|
-
ERROR(`[encodeBlockOriginal] sync cid mismatch`, { jsonObject, encoded, syncVariant });
|
|
54
|
-
}
|
|
55
|
-
return encoded;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export {
|
|
59
|
-
__publicField,
|
|
60
|
-
prepareForPub,
|
|
61
|
-
encodeApplogAndGetCid,
|
|
62
|
-
encodeApplog,
|
|
63
|
-
getCidSync,
|
|
64
|
-
encodeBlock,
|
|
65
|
-
encodeBlockOriginal
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=chunk-6ZDPEEFN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ipfs/ipfs-utils.ts"],"sourcesContent":["import * as dagJson from '@ipld/dag-json'\nimport { sha256 } from '@noble/hashes/sha256'\nimport { Logger } from 'besonders-logger'\nimport { CID, digest as Digest } from 'multiformats'\nimport { encode as multiformatsEncode } from 'multiformats/block'\n// import { encode } from 'multiformats/block';\nimport { Applog, ApplogForInsert, ApplogNoCid } from '../applog/datom-types'\n\nimport { sha256 as sha265Hasher } from 'multiformats/hashes/sha2'\n\n/* THIS FILE SHOULD NOT DEPEND ON UI STUFF, SO THAT TESTS CAN RUN WITH MINIMAL DEPENDENCIES */\n\nconst { WARN, LOG, DEBUG, VERBOSE, ERROR } = Logger.setup(Logger.INFO) // eslint-disable-line no-unused-vars\n\nexport function prepareForPub(log: Applog | ApplogForInsert, without: string[] = ['cid']) {\n\tconst logWithout = {}\n\tfor (let [key, val] of Object.entries(log)) {\n\t\tif (val === undefined) {\n\t\t\tWARN(`log.${key} is undefined, which is not allowed - encoding as null`, log)\n\t\t\tval = null\n\t\t}\n\t\tif (!without.includes(key)) {\n\t\t\tlogWithout[key] = val && key === 'pv' ? CID.parse(val) : val\n\t\t} else {\n\t\t\tVERBOSE('excluding app log', { key, val })\n\t\t}\n\t}\n\treturn logWithout as Applog\n}\n\nexport function encodeApplogAndGetCid(log: ApplogNoCid) {\n\treturn getCidSync(encodeApplog(log).bytes)\n}\nexport function encodeApplog(log: ApplogNoCid) {\n\treturn encodeBlock(prepareForPub(log))\n}\n\nexport function getCidSync(bytes: dagJson.ByteView<any>) {\n\t// Hacky way to use a sync sha265 lib to create a CID - code inspired by https://github.com/multiformats/js-multiformats#multihash-hashers\n\tconst hash = sha256(bytes)\n\tconst digest = Digest.create(sha265Hasher.code, hash)\n\tconst cid = CID.create(1, dagJson.code, digest)\n\tVERBOSE(`[getCidSync]`, { bytes, hash, digest, cid })\n\treturn cid\n}\n/** encode the json object into an IPLD block */\nexport function encodeBlock(jsonObject: any) {\n\tDEBUG('[encodeBlock]', jsonObject)\n\tconst byteView = dagJson.encode(jsonObject)\n\treturn { bytes: byteView, cid: getCidSync(byteView) }\n}\n\nexport async function encodeBlockOriginal(jsonObject: any) {\n\t// HACK re-added this to verify the sync variant is sane\n\tconst encoded = await multiformatsEncode({ value: jsonObject, codec: dagJson, hasher: sha265Hasher })\n\tconst syncVariant = encodeBlock(jsonObject)\n\tif (syncVariant.cid.toString() !== encoded.cid.toString()) {\n\t\tERROR(`[encodeBlockOriginal] sync cid mismatch`, { jsonObject, encoded, syncVariant })\n\t}\n\treturn encoded\n}\n"],"mappings":";;;;;;;;AAAA,YAAY,aAAa;AACzB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,KAAK,UAAU,cAAc;AACtC,SAAS,UAAU,0BAA0B;AAI7C,SAAS,UAAU,oBAAoB;AAIvC,IAAM,EAAE,MAAM,KAAK,OAAO,SAAS,MAAM,IAAI,OAAO,MAAM,OAAO,IAAI;AAE9D,SAAS,cAAc,KAA+B,UAAoB,CAAC,KAAK,GAAG;AACzF,QAAM,aAAa,CAAC;AACpB,WAAS,CAAC,KAAK,GAAG,KAAK,OAAO,QAAQ,GAAG,GAAG;AAC3C,QAAI,QAAQ,QAAW;AACtB,WAAK,OAAO,GAAG,0DAA0D,GAAG;AAC5E,YAAM;AAAA,IACP;AACA,QAAI,CAAC,QAAQ,SAAS,GAAG,GAAG;AAC3B,iBAAW,GAAG,IAAI,OAAO,QAAQ,OAAO,IAAI,MAAM,GAAG,IAAI;AAAA,IAC1D,OAAO;AACN,cAAQ,qBAAqB,EAAE,KAAK,IAAI,CAAC;AAAA,IAC1C;AAAA,EACD;AACA,SAAO;AACR;AAEO,SAAS,sBAAsB,KAAkB;AACvD,SAAO,WAAW,aAAa,GAAG,EAAE,KAAK;AAC1C;AACO,SAAS,aAAa,KAAkB;AAC9C,SAAO,YAAY,cAAc,GAAG,CAAC;AACtC;AAEO,SAAS,WAAW,OAA8B;AAExD,QAAM,OAAO,OAAO,KAAK;AACzB,QAAM,SAAS,OAAO,OAAO,aAAa,MAAM,IAAI;AACpD,QAAM,MAAM,IAAI,OAAO,GAAW,cAAM,MAAM;AAC9C,UAAQ,gBAAgB,EAAE,OAAO,MAAM,QAAQ,IAAI,CAAC;AACpD,SAAO;AACR;AAEO,SAAS,YAAY,YAAiB;AAC5C,QAAM,iBAAiB,UAAU;AACjC,QAAM,WAAmB,eAAO,UAAU;AAC1C,SAAO,EAAE,OAAO,UAAU,KAAK,WAAW,QAAQ,EAAE;AACrD;AAEA,eAAsB,oBAAoB,YAAiB;AAE1D,QAAM,UAAU,MAAM,mBAAmB,EAAE,OAAO,YAAY,OAAO,SAAS,QAAQ,aAAa,CAAC;AACpG,QAAM,cAAc,YAAY,UAAU;AAC1C,MAAI,YAAY,IAAI,SAAS,MAAM,QAAQ,IAAI,SAAS,GAAG;AAC1D,UAAM,2CAA2C,EAAE,YAAY,SAAS,YAAY,CAAC;AAAA,EACtF;AACA,SAAO;AACR;","names":[]}
|
package/dist/chunk-DBACGNVR.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-DBACGNVR.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|