@pkcprotocol/pkc-js 0.0.46 → 0.0.47
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/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/bundled/bundle-manifest.json +31 -31
- package/dist/bundled/chunks/{helia-for-pkc-uRINWDzG.js → helia-for-pkc-Kr0fvym5.js} +2 -2
- package/dist/bundled/chunks/{local-community-iVvgerOY.js → local-community-1YWTMINk.js} +2 -2
- package/dist/bundled/chunks/{local-community-CCSP8e6_.js → local-community-DyL61Q84.js} +1 -1
- package/dist/bundled/chunks/{node-DMNVMYGv.js → node-7bvDHqBl.js} +5 -5
- package/dist/bundled/chunks/{rpc-local-community-DG6G0xL6.js → rpc-local-community-Xpx65cbz.js} +1 -1
- package/dist/bundled/chunks/{schema-Bo3XK8Oe.js → schema-CijXm_fr.js} +1 -1
- package/dist/bundled/chunks/{util-I3gVOp6w.js → util-RR1J0iZB.js} +1 -1
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/package.json +12 -2
- package/dist/browser/decorator-util.d.ts +0 -1
- package/dist/browser/decorator-util.js +0 -35
- package/dist/browser/decorator-util.js.map +0 -1
- package/dist/browser/rpc/src/lib/pkc-js/pkc-js-mock.d.ts +0 -1
- package/dist/browser/rpc/src/lib/pkc-js/pkc-js-mock.js +0 -472
- package/dist/browser/rpc/src/lib/pkc-js/pkc-js-mock.js.map +0 -1
- package/dist/node/decorator-util.d.ts +0 -1
- package/dist/node/decorator-util.js +0 -35
- package/dist/node/decorator-util.js.map +0 -1
- package/dist/node/rpc/src/lib/pkc-js/pkc-js-mock.d.ts +0 -1
- package/dist/node/rpc/src/lib/pkc-js/pkc-js-mock.js +0 -472
- package/dist/node/rpc/src/lib/pkc-js/pkc-js-mock.js.map +0 -1
|
@@ -1,472 +0,0 @@
|
|
|
1
|
-
// import EventEmitter from "events";
|
|
2
|
-
export {};
|
|
3
|
-
// const loadingTime = 10;
|
|
4
|
-
// export const simulateLoadingTime = () => new Promise((r) => setTimeout(r, loadingTime));
|
|
5
|
-
// // keep a list of created and edited owner communities
|
|
6
|
-
// // to reinitialize them with pkc.createCommunity()
|
|
7
|
-
// let createdOwnerCommunitys: any = {};
|
|
8
|
-
// let editedOwnerCommunitys: any = {};
|
|
9
|
-
// // reset the pkc-js global state in between tests
|
|
10
|
-
// export const resetPKCJsMock = () => {
|
|
11
|
-
// createdOwnerCommunitys = {};
|
|
12
|
-
// editedOwnerCommunitys = {};
|
|
13
|
-
// };
|
|
14
|
-
// export const debugPKCJsMock = () => {
|
|
15
|
-
// console.log({ createdOwnerCommunitys, editedOwnerCommunitys });
|
|
16
|
-
// };
|
|
17
|
-
// export class PKC extends EventEmitter {
|
|
18
|
-
// async resolveAuthorAddress(authorAddress: { address: string }) {}
|
|
19
|
-
// async createSigner() {
|
|
20
|
-
// return {
|
|
21
|
-
// privateKey: "private key",
|
|
22
|
-
// address: "address"
|
|
23
|
-
// };
|
|
24
|
-
// }
|
|
25
|
-
// async createCommunity(createCommunityOptions: any) {
|
|
26
|
-
// if (!createCommunityOptions) {
|
|
27
|
-
// createCommunityOptions = {};
|
|
28
|
-
// }
|
|
29
|
-
// // no address provided so probably a user creating an owner community
|
|
30
|
-
// if (!createCommunityOptions.address && !createdOwnerCommunitys[createCommunityOptions.address]) {
|
|
31
|
-
// createCommunityOptions = { ...createCommunityOptions, address: "created community address" };
|
|
32
|
-
// // createdCommunityAddresses.push('created community address')
|
|
33
|
-
// createdOwnerCommunitys[createCommunityOptions.address] = { ...createCommunityOptions };
|
|
34
|
-
// }
|
|
35
|
-
// // only address provided, so could be a previously created owner community
|
|
36
|
-
// // add props from previously created community
|
|
37
|
-
// else if (
|
|
38
|
-
// createdOwnerCommunitys[createCommunityOptions.address] &&
|
|
39
|
-
// JSON.stringify(Object.keys(createCommunityOptions)) === '["address"]'
|
|
40
|
-
// ) {
|
|
41
|
-
// for (const prop in createdOwnerCommunitys[createCommunityOptions.address]) {
|
|
42
|
-
// if (createdOwnerCommunitys[createCommunityOptions.address][prop]) {
|
|
43
|
-
// createCommunityOptions[prop] = createdOwnerCommunitys[createCommunityOptions.address][prop];
|
|
44
|
-
// }
|
|
45
|
-
// }
|
|
46
|
-
// }
|
|
47
|
-
// // add edited props if owner community was edited in the past
|
|
48
|
-
// if (editedOwnerCommunitys[createCommunityOptions.address]) {
|
|
49
|
-
// for (const prop in editedOwnerCommunitys[createCommunityOptions.address]) {
|
|
50
|
-
// if (editedOwnerCommunitys[createCommunityOptions.address][prop]) {
|
|
51
|
-
// createCommunityOptions[prop] = editedOwnerCommunitys[createCommunityOptions.address][prop];
|
|
52
|
-
// }
|
|
53
|
-
// }
|
|
54
|
-
// }
|
|
55
|
-
// return new Community(createCommunityOptions);
|
|
56
|
-
// }
|
|
57
|
-
// async getCommunity({address: communityAddress}: { address: string }) {
|
|
58
|
-
// await simulateLoadingTime();
|
|
59
|
-
// const createCommunityOptions = {
|
|
60
|
-
// address: communityAddress
|
|
61
|
-
// };
|
|
62
|
-
// const community: any = new Community(createCommunityOptions);
|
|
63
|
-
// community.title = community.address + " title";
|
|
64
|
-
// const hotPageCid = community.address + " page cid hot";
|
|
65
|
-
// community.posts.pages.hot = getCommentsPage(hotPageCid, community);
|
|
66
|
-
// community.posts.pageCids = {
|
|
67
|
-
// hot: hotPageCid,
|
|
68
|
-
// topAll: community.address + " page cid topAll",
|
|
69
|
-
// new: community.address + " page cid new",
|
|
70
|
-
// active: community.address + " page cid active"
|
|
71
|
-
// };
|
|
72
|
-
// return community;
|
|
73
|
-
// }
|
|
74
|
-
// async listCommunitys() {
|
|
75
|
-
// return ["list community address 1", "list community address 2", ...Object.keys(createdOwnerCommunitys)];
|
|
76
|
-
// }
|
|
77
|
-
// async createComment(createCommentOptions: any) {
|
|
78
|
-
// return new Comment(createCommentOptions);
|
|
79
|
-
// }
|
|
80
|
-
// async getComment({cid: commentCid}: { cid: string }) {
|
|
81
|
-
// await simulateLoadingTime();
|
|
82
|
-
// const createCommentOptions = {
|
|
83
|
-
// cid: commentCid,
|
|
84
|
-
// ipnsName: commentCid + " ipns name",
|
|
85
|
-
// // useComment() requires timestamp or will use account comment instead of comment from store
|
|
86
|
-
// timestamp: 1670000000,
|
|
87
|
-
// ...this.commentToGet(commentCid)
|
|
88
|
-
// };
|
|
89
|
-
// return new Comment(createCommentOptions);
|
|
90
|
-
// }
|
|
91
|
-
// // mock this method to get a comment with different content, timestamp, address, etc
|
|
92
|
-
// commentToGet(commentCid?: string) {
|
|
93
|
-
// return {
|
|
94
|
-
// // content: 'mock some content'
|
|
95
|
-
// // author: {address: 'mock some address'},
|
|
96
|
-
// // timestamp: 1234
|
|
97
|
-
// };
|
|
98
|
-
// }
|
|
99
|
-
// async createVote() {
|
|
100
|
-
// return new Vote();
|
|
101
|
-
// }
|
|
102
|
-
// async createCommentEdit(createCommentEditOptions: any) {
|
|
103
|
-
// return new CommentEdit(createCommentEditOptions);
|
|
104
|
-
// }
|
|
105
|
-
// async createCommunityEdit(createCommunityEditOptions: any) {
|
|
106
|
-
// return new CommunityEdit(createCommunityEditOptions);
|
|
107
|
-
// }
|
|
108
|
-
// async fetchCid({cid}: { cid: string }) {
|
|
109
|
-
// if (cid?.startsWith("statscid")) {
|
|
110
|
-
// return JSON.stringify({ hourActiveUserCount: 1 });
|
|
111
|
-
// }
|
|
112
|
-
// throw Error(`pkc.fetchCid not implemented in pkc-js mock for cid '${cid}'`);
|
|
113
|
-
// }
|
|
114
|
-
// async pubsubSubscribe(communityAddress: string) {}
|
|
115
|
-
// async pubsubUnsubscribe(communityAddress: string) {}
|
|
116
|
-
// }
|
|
117
|
-
// export class Pages {
|
|
118
|
-
// pageCids: any = {};
|
|
119
|
-
// pages: any = {};
|
|
120
|
-
// community: any;
|
|
121
|
-
// comment: any;
|
|
122
|
-
// constructor(pagesOptions?: any) {
|
|
123
|
-
// Object.defineProperty(this, "community", { value: pagesOptions?.community, enumerable: false });
|
|
124
|
-
// Object.defineProperty(this, "comment", { value: pagesOptions?.comment, enumerable: false });
|
|
125
|
-
// }
|
|
126
|
-
// async getPage({cid: pageCid}: { cid: string }) {
|
|
127
|
-
// // need to wait twice otherwise react renders too fast and fetches too many pages in advance
|
|
128
|
-
// await simulateLoadingTime();
|
|
129
|
-
// return getCommentsPage(pageCid, this.community);
|
|
130
|
-
// }
|
|
131
|
-
// async _fetchAndVerifyPage(pageCid: string) {
|
|
132
|
-
// return this.getPage({cid: pageCid});
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
|
-
// export class Community extends EventEmitter {
|
|
136
|
-
// updateCalledTimes = 0;
|
|
137
|
-
// updating = false;
|
|
138
|
-
// firstUpdate = true;
|
|
139
|
-
// address: string | undefined;
|
|
140
|
-
// title: string | undefined;
|
|
141
|
-
// description: string | undefined;
|
|
142
|
-
// posts: Pages;
|
|
143
|
-
// updatedAt: number | undefined;
|
|
144
|
-
// statsCid: string | undefined;
|
|
145
|
-
// state: string;
|
|
146
|
-
// updatingState: string;
|
|
147
|
-
// constructor(createCommunityOptions?: any) {
|
|
148
|
-
// super();
|
|
149
|
-
// this.address = createCommunityOptions?.address;
|
|
150
|
-
// this.title = createCommunityOptions?.title;
|
|
151
|
-
// this.description = createCommunityOptions?.description;
|
|
152
|
-
// this.statsCid = "statscid";
|
|
153
|
-
// this.state = "stopped";
|
|
154
|
-
// this.updatingState = "stopped";
|
|
155
|
-
// this.posts = new Pages({ community: this });
|
|
156
|
-
// // add community.posts from createCommunityOptions
|
|
157
|
-
// if (createCommunityOptions?.posts?.pages) {
|
|
158
|
-
// this.posts.pages = createCommunityOptions?.posts?.pages;
|
|
159
|
-
// }
|
|
160
|
-
// if (createCommunityOptions?.posts?.pageCids) {
|
|
161
|
-
// this.posts.pageCids = createCommunityOptions?.posts?.pageCids;
|
|
162
|
-
// }
|
|
163
|
-
// // only trigger a first update if argument is only ({address})
|
|
164
|
-
// if (!createCommunityOptions?.address || Object.keys(createCommunityOptions).length !== 1) {
|
|
165
|
-
// this.firstUpdate = false;
|
|
166
|
-
// }
|
|
167
|
-
// }
|
|
168
|
-
// toJSONInternalRpc() {
|
|
169
|
-
// return {
|
|
170
|
-
// title: this.title,
|
|
171
|
-
// description: this.description,
|
|
172
|
-
// address: this.address,
|
|
173
|
-
// statsCid: this.statsCid,
|
|
174
|
-
// roles: this.roles,
|
|
175
|
-
// posts: this.posts
|
|
176
|
-
// };
|
|
177
|
-
// }
|
|
178
|
-
// toJSONIpfs() {
|
|
179
|
-
// return this.toJSONInternalRpc();
|
|
180
|
-
// }
|
|
181
|
-
// async update() {
|
|
182
|
-
// this.updateCalledTimes++;
|
|
183
|
-
// if (this.updateCalledTimes > 1) {
|
|
184
|
-
// throw Error(
|
|
185
|
-
// "with the current hooks, community.update() should be called maximum 1 times, this number might change if the hooks change and is only there to catch bugs, the real comment.update() can be called infinite times"
|
|
186
|
-
// );
|
|
187
|
-
// }
|
|
188
|
-
// // is ipnsName is known, look for updates and emit updates immediately after creation
|
|
189
|
-
// if (!this.address) {
|
|
190
|
-
// throw Error(`can't update without community.address`);
|
|
191
|
-
// }
|
|
192
|
-
// // don't update twice
|
|
193
|
-
// if (this.updating) {
|
|
194
|
-
// return;
|
|
195
|
-
// }
|
|
196
|
-
// this.updating = true;
|
|
197
|
-
// this.state = "updating";
|
|
198
|
-
// this.updatingState = "fetching-ipns";
|
|
199
|
-
// this.emit("statechange", "updating");
|
|
200
|
-
// this.emit("updatingstatechange", "fetching-ipns");
|
|
201
|
-
// simulateLoadingTime().then(() => {
|
|
202
|
-
// this.simulateUpdateEvent();
|
|
203
|
-
// });
|
|
204
|
-
// }
|
|
205
|
-
// async stop() {}
|
|
206
|
-
// async start() {}
|
|
207
|
-
// async delete() {
|
|
208
|
-
// if (this.address) {
|
|
209
|
-
// delete createdOwnerCommunitys[this.address];
|
|
210
|
-
// delete editedOwnerCommunitys[this.address];
|
|
211
|
-
// }
|
|
212
|
-
// }
|
|
213
|
-
// simulateUpdateEvent() {
|
|
214
|
-
// if (this.firstUpdate) {
|
|
215
|
-
// this.simulateFirstUpdateEvent();
|
|
216
|
-
// return;
|
|
217
|
-
// }
|
|
218
|
-
// this.description = this.address + " description updated";
|
|
219
|
-
// this.updatedAt = Math.floor(Date.now() / 1000);
|
|
220
|
-
// this.updatingState = "succeeded";
|
|
221
|
-
// this.emit("update", this);
|
|
222
|
-
// this.emit("updatingstatechange", "succeeded");
|
|
223
|
-
// }
|
|
224
|
-
// // the first update event adds all the field from getCommunity
|
|
225
|
-
// async simulateFirstUpdateEvent() {
|
|
226
|
-
// this.firstUpdate = false;
|
|
227
|
-
// this.title = this.address + " title";
|
|
228
|
-
// const hotPageCid = this.address + " page cid hot";
|
|
229
|
-
// this.posts.pages.hot = getCommentsPage(hotPageCid, this);
|
|
230
|
-
// this.posts.pageCids = {
|
|
231
|
-
// hot: hotPageCid,
|
|
232
|
-
// best: this.address + " page cid best",
|
|
233
|
-
// new: this.address + " page cid new",
|
|
234
|
-
// active: this.address + " page cid active"
|
|
235
|
-
// };
|
|
236
|
-
// // simulate the ipns update
|
|
237
|
-
// this.updatingState = "succeeded";
|
|
238
|
-
// this.emit("update", this);
|
|
239
|
-
// this.emit("updatingstatechange", "succeeded");
|
|
240
|
-
// // simulate the next update
|
|
241
|
-
// this.updatingState = "fetching-ipns";
|
|
242
|
-
// this.emit("updatingstatechange", "fetching-ipns");
|
|
243
|
-
// simulateLoadingTime().then(() => {
|
|
244
|
-
// this.simulateUpdateEvent();
|
|
245
|
-
// });
|
|
246
|
-
// }
|
|
247
|
-
// // use getting to easily mock it
|
|
248
|
-
// get roles() {
|
|
249
|
-
// return this.rolesToGet();
|
|
250
|
-
// }
|
|
251
|
-
// // mock this method to get different roles
|
|
252
|
-
// rolesToGet() {
|
|
253
|
-
// return {};
|
|
254
|
-
// }
|
|
255
|
-
// async edit(editCommunityOptions: any) {
|
|
256
|
-
// if (!this.address || typeof this.address !== "string") {
|
|
257
|
-
// throw Error(`can't community.edit with no community.address`);
|
|
258
|
-
// }
|
|
259
|
-
// const previousAddress = this.address;
|
|
260
|
-
// // do community.edit
|
|
261
|
-
// for (const prop in editCommunityOptions) {
|
|
262
|
-
// if (editCommunityOptions[prop]) {
|
|
263
|
-
// // @ts-ignore
|
|
264
|
-
// this[prop] = editCommunityOptions[prop];
|
|
265
|
-
// }
|
|
266
|
-
// }
|
|
267
|
-
// // keep a list of edited communities to reinitialize
|
|
268
|
-
// // them with pkc.createCommunity()
|
|
269
|
-
// editedOwnerCommunitys[this.address] = {
|
|
270
|
-
// address: this.address,
|
|
271
|
-
// title: this.title,
|
|
272
|
-
// description: this.description
|
|
273
|
-
// };
|
|
274
|
-
// // handle change of community.address
|
|
275
|
-
// if (editCommunityOptions.address) {
|
|
276
|
-
// // apply address change to editedOwnerCommunitys
|
|
277
|
-
// editedOwnerCommunitys[previousAddress] = {
|
|
278
|
-
// address: this.address,
|
|
279
|
-
// title: this.title,
|
|
280
|
-
// description: this.description
|
|
281
|
-
// };
|
|
282
|
-
// delete editedOwnerCommunitys[previousAddress];
|
|
283
|
-
// // apply address change to createdOwnerCommunitys
|
|
284
|
-
// createdOwnerCommunitys[this.address] = {
|
|
285
|
-
// ...createdOwnerCommunitys[previousAddress],
|
|
286
|
-
// address: this.address
|
|
287
|
-
// };
|
|
288
|
-
// delete createdOwnerCommunitys[previousAddress];
|
|
289
|
-
// }
|
|
290
|
-
// }
|
|
291
|
-
// }
|
|
292
|
-
// // make roles enumarable so it acts like a regular prop
|
|
293
|
-
// Object.defineProperty(Community.prototype, "roles", { enumerable: true });
|
|
294
|
-
// // define it here because also used it pkc.getCommunity({address: )
|
|
295
|
-
// const getCommentsPage = (pageCid: string, community: any}) => {
|
|
296
|
-
// const page: any = {
|
|
297
|
-
// nextCid: community.address + " " + pageCid + " - next page cid",
|
|
298
|
-
// comments: []
|
|
299
|
-
// };
|
|
300
|
-
// const postCount = 100;
|
|
301
|
-
// let index = 0;
|
|
302
|
-
// while (index++ < postCount) {
|
|
303
|
-
// page.comments.push({
|
|
304
|
-
// timestamp: index,
|
|
305
|
-
// cid: pageCid + " comment cid " + index,
|
|
306
|
-
// communityAddress: community.address,
|
|
307
|
-
// upvoteCount: index,
|
|
308
|
-
// downvoteCount: 10,
|
|
309
|
-
// author: {
|
|
310
|
-
// address: pageCid + " author address " + index
|
|
311
|
-
// },
|
|
312
|
-
// updatedAt: index
|
|
313
|
-
// });
|
|
314
|
-
// }
|
|
315
|
-
// return { ...page, _fetchAndVerifyPage: () => page };
|
|
316
|
-
// };
|
|
317
|
-
// let challengeRequestCount = 0;
|
|
318
|
-
// class Publication extends EventEmitter {
|
|
319
|
-
// timestamp: number | undefined;
|
|
320
|
-
// content: string | undefined;
|
|
321
|
-
// cid: string | undefined;
|
|
322
|
-
// challengeRequestId = new TextEncoder().encode(`r${++challengeRequestCount}`);
|
|
323
|
-
// state: string | undefined;
|
|
324
|
-
// publishingState: string | undefined;
|
|
325
|
-
// async publish() {
|
|
326
|
-
// this.state = "publishing";
|
|
327
|
-
// this.publishingState = "publishing-challenge-request";
|
|
328
|
-
// this.emit("statechange", "publishing");
|
|
329
|
-
// this.emit("publishingstatechange", "publishing-challenge-request");
|
|
330
|
-
// await simulateLoadingTime();
|
|
331
|
-
// this.simulateChallengeEvent();
|
|
332
|
-
// }
|
|
333
|
-
// async stop() {}
|
|
334
|
-
// simulateChallengeEvent() {
|
|
335
|
-
// this.publishingState = "waiting-challenge-answers";
|
|
336
|
-
// this.emit("publishingstatechange", "waiting-challenge-answers");
|
|
337
|
-
// const challenge = { type: "text", challenge: "2+2=?" };
|
|
338
|
-
// const challengeMessage = {
|
|
339
|
-
// type: "CHALLENGE",
|
|
340
|
-
// challengeRequestId: this.challengeRequestId,
|
|
341
|
-
// challenges: [challenge]
|
|
342
|
-
// };
|
|
343
|
-
// this.emit("challenge", challengeMessage, this);
|
|
344
|
-
// }
|
|
345
|
-
// async publishChallengeAnswers(challengeAnswers: string[]) {
|
|
346
|
-
// this.publishingState = "publishing-challenge-answer";
|
|
347
|
-
// this.emit("publishingstatechange", "publishing-challenge-answer");
|
|
348
|
-
// await simulateLoadingTime();
|
|
349
|
-
// this.publishingState = "waiting-challenge-verification";
|
|
350
|
-
// this.emit("publishingstatechange", "waiting-challenge-verification");
|
|
351
|
-
// await simulateLoadingTime();
|
|
352
|
-
// this.simulateChallengeVerificationEvent();
|
|
353
|
-
// }
|
|
354
|
-
// simulateChallengeVerificationEvent() {
|
|
355
|
-
// // if publication has content, create cid for this content and add it to comment and challengeVerificationMessage
|
|
356
|
-
// this.cid = this.content && `${this.content} cid`;
|
|
357
|
-
// const publication = this.cid && { cid: this.cid };
|
|
358
|
-
// const challengeVerificationMessage = {
|
|
359
|
-
// type: "CHALLENGEVERIFICATION",
|
|
360
|
-
// challengeRequestId: this.challengeRequestId,
|
|
361
|
-
// challengeSuccess: true,
|
|
362
|
-
// publication
|
|
363
|
-
// };
|
|
364
|
-
// this.emit("challengeverification", challengeVerificationMessage, this);
|
|
365
|
-
// this.publishingState = "succeeded";
|
|
366
|
-
// this.emit("publishingstatechange", "succeeded");
|
|
367
|
-
// }
|
|
368
|
-
// }
|
|
369
|
-
// export class Comment extends Publication {
|
|
370
|
-
// updateCalledTimes = 0;
|
|
371
|
-
// updating = false;
|
|
372
|
-
// author: any;
|
|
373
|
-
// ipnsName: string | undefined;
|
|
374
|
-
// upvoteCount: number | undefined;
|
|
375
|
-
// downvoteCount: number | undefined;
|
|
376
|
-
// override content: string | undefined;
|
|
377
|
-
// parentCid: string | undefined;
|
|
378
|
-
// replies: any;
|
|
379
|
-
// updatedAt: number | undefined;
|
|
380
|
-
// communityAddress: string | undefined;
|
|
381
|
-
// override state: string;
|
|
382
|
-
// updatingState: string;
|
|
383
|
-
// override publishingState: string;
|
|
384
|
-
// constructor(createCommentOptions?: any) {
|
|
385
|
-
// super();
|
|
386
|
-
// this.ipnsName = createCommentOptions?.ipnsName;
|
|
387
|
-
// this.cid = createCommentOptions?.cid;
|
|
388
|
-
// this.upvoteCount = createCommentOptions?.upvoteCount;
|
|
389
|
-
// this.downvoteCount = createCommentOptions?.downvoteCount;
|
|
390
|
-
// this.content = createCommentOptions?.content;
|
|
391
|
-
// this.author = createCommentOptions?.author;
|
|
392
|
-
// this.timestamp = createCommentOptions?.timestamp;
|
|
393
|
-
// this.parentCid = createCommentOptions?.parentCid;
|
|
394
|
-
// this.replies = new Pages({ comment: this });
|
|
395
|
-
// this.communityAddress = createCommentOptions?.communityAddress;
|
|
396
|
-
// this.state = "stopped";
|
|
397
|
-
// this.updatingState = "stopped";
|
|
398
|
-
// this.publishingState = "stopped";
|
|
399
|
-
// if (createCommentOptions?.author?.address) {
|
|
400
|
-
// this.author.shortAddress = `short ${createCommentOptions.author.address}`;
|
|
401
|
-
// }
|
|
402
|
-
// //@ts-expect-error
|
|
403
|
-
// this.raw = {
|
|
404
|
-
// comment: {
|
|
405
|
-
// ipnsName: this.ipnsName,
|
|
406
|
-
// content: this.content,
|
|
407
|
-
// author: this.author,
|
|
408
|
-
// timestamp: this.timestamp,
|
|
409
|
-
// parentCid: this.parentCid,
|
|
410
|
-
// communityAddress: this.communityAddress
|
|
411
|
-
// }
|
|
412
|
-
// };
|
|
413
|
-
// }
|
|
414
|
-
// async update() {
|
|
415
|
-
// this.updateCalledTimes++;
|
|
416
|
-
// if (this.updateCalledTimes > 2) {
|
|
417
|
-
// throw Error(
|
|
418
|
-
// "with the current hooks, comment.update() should be called maximum 2 times, this number might change if the hooks change and is only there to catch bugs, the real comment.update() can be called infinite times"
|
|
419
|
-
// );
|
|
420
|
-
// }
|
|
421
|
-
// // don't update twice
|
|
422
|
-
// if (this.updating) {
|
|
423
|
-
// return;
|
|
424
|
-
// }
|
|
425
|
-
// this.updating = true;
|
|
426
|
-
// this.state = "updating";
|
|
427
|
-
// this.updatingState = "fetching-ipfs";
|
|
428
|
-
// this.emit("statechange", "updating");
|
|
429
|
-
// this.emit("updatingstatechange", "fetching-ipfs");
|
|
430
|
-
// simulateLoadingTime().then(() => {
|
|
431
|
-
// this.simulateUpdateEvent();
|
|
432
|
-
// });
|
|
433
|
-
// }
|
|
434
|
-
// simulateUpdateEvent() {
|
|
435
|
-
// // if timestamp isn't defined, simulate fetching the comment ipfs
|
|
436
|
-
// if (!this.timestamp) {
|
|
437
|
-
// this.simulateFetchCommentIpfsUpdateEvent();
|
|
438
|
-
// return;
|
|
439
|
-
// }
|
|
440
|
-
// // simulate finding vote counts on an IPNS record
|
|
441
|
-
// this.upvoteCount = typeof this.upvoteCount === "number" ? this.upvoteCount + 2 : 3;
|
|
442
|
-
// this.downvoteCount = typeof this.downvoteCount === "number" ? this.downvoteCount + 1 : 1;
|
|
443
|
-
// this.updatedAt = Math.floor(Date.now() / 1000);
|
|
444
|
-
// this.updatingState = "succeeded";
|
|
445
|
-
// this.emit("update", this);
|
|
446
|
-
// this.emit("updatingstatechange", "succeeded");
|
|
447
|
-
// }
|
|
448
|
-
// async simulateFetchCommentIpfsUpdateEvent() {
|
|
449
|
-
// // use pkc.getComment({cid: ) so mocking PKC.prototype.getComment works
|
|
450
|
-
// const commentIpfs = await new PKC(}).getComment({cid: this.cid || ""});
|
|
451
|
-
// this.ipnsName = commentIpfs.ipnsName;
|
|
452
|
-
// this.content = commentIpfs.content;
|
|
453
|
-
// this.author = commentIpfs.author;
|
|
454
|
-
// this.timestamp = commentIpfs.timestamp;
|
|
455
|
-
// this.parentCid = commentIpfs.parentCid;
|
|
456
|
-
// this.communityAddress = commentIpfs.communityAddress;
|
|
457
|
-
// // simulate the ipns update
|
|
458
|
-
// this.updatingState = "fetching-update-ipns";
|
|
459
|
-
// this.emit("update", this);
|
|
460
|
-
// this.emit("updatingstatechange", "fetching-update-ipns");
|
|
461
|
-
// simulateLoadingTime().then(() => {
|
|
462
|
-
// this.simulateUpdateEvent();
|
|
463
|
-
// });
|
|
464
|
-
// }
|
|
465
|
-
// }
|
|
466
|
-
// export class Vote extends Publication {}
|
|
467
|
-
// export class CommentEdit extends Publication {}
|
|
468
|
-
// export class CommunityEdit extends Publication {}
|
|
469
|
-
// export default async function () {
|
|
470
|
-
// return new PKC();
|
|
471
|
-
// }
|
|
472
|
-
//# sourceMappingURL=pkc-js-mock.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pkc-js-mock.js","sourceRoot":"","sources":["../../../../../../src/rpc/src/lib/pkc-js/pkc-js-mock.ts"],"names":[],"mappings":"AAAA,qCAAqC;;AAErC,0BAA0B;AAC1B,2FAA2F;AAE3F,yDAAyD;AACzD,qDAAqD;AACrD,wCAAwC;AACxC,uCAAuC;AAEvC,oDAAoD;AACpD,wCAAwC;AACxC,mCAAmC;AACnC,kCAAkC;AAClC,KAAK;AACL,wCAAwC;AACxC,sEAAsE;AACtE,KAAK;AAEL,0CAA0C;AAC1C,wEAAwE;AAExE,6BAA6B;AAC7B,mBAAmB;AACnB,yCAAyC;AACzC,iCAAiC;AACjC,aAAa;AACb,QAAQ;AAER,2DAA2D;AAC3D,yCAAyC;AACzC,2CAA2C;AAC3C,YAAY;AAEZ,gFAAgF;AAChF,4GAA4G;AAC5G,4GAA4G;AAC5G,6EAA6E;AAC7E,sGAAsG;AACtG,YAAY;AACZ,qFAAqF;AACrF,yDAAyD;AACzD,oBAAoB;AACpB,wEAAwE;AACxE,oFAAoF;AACpF,cAAc;AACd,2FAA2F;AAC3F,sFAAsF;AACtF,mHAAmH;AACnH,oBAAoB;AACpB,gBAAgB;AAChB,YAAY;AAEZ,wEAAwE;AACxE,uEAAuE;AACvE,0FAA0F;AAC1F,qFAAqF;AACrF,kHAAkH;AAClH,oBAAoB;AACpB,gBAAgB;AAChB,YAAY;AAEZ,wDAAwD;AACxD,QAAQ;AAER,6EAA6E;AAC7E,uCAAuC;AACvC,2CAA2C;AAC3C,wCAAwC;AACxC,aAAa;AACb,wEAAwE;AACxE,0DAA0D;AAC1D,kEAAkE;AAClE,8EAA8E;A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CAAuC;AACvC,6CAA6C;AAC7C,6CAA6C;AAC7C,0DAA0D;AAC1D,gBAAgB;AAChB,aAAa;AACb,QAAQ;AAER,uBAAuB;AACvB,oCAAoC;AACpC,4CAA4C;AAC5C,2BAA2B;AAC3B,oOAAoO;AACpO,iBAAiB;AACjB,YAAY;AACZ,gCAAgC;AAChC,+BAA+B;AAC/B,sBAAsB;AACtB,YAAY;AACZ,gCAAgC;AAEhC,mCAAmC;AACnC,gDAAgD;AAChD,gDAAgD;AAChD,6DAA6D;AAE7D,6CAA6C;AAC7C,0CAA0C;AAC1C,cAAc;AACd,QAAQ;AAER,8BAA8B;AAC9B,4EAA4E;AAC5E,iCAAiC;AACjC,0DAA0D;AAC1D,sBAAsB;AACtB,YAAY;AAEZ,4DAA4D;AAC5D,8FAA8F;AAC9F,oGAAoG;AACpG,0DAA0D;AAE1D,4CAA4C;AAC5C,qCAAqC;AACrC,yDAAyD;AACzD,QAAQ;AAER,oDAAoD;AACpD,kFAAkF;AAClF,kFAAkF;AAClF,gDAAgD;AAChD,8CAA8C;AAC9C,4CAA4C;AAC5C,kDAAkD;AAClD,kDAAkD;AAClD,gEAAgE;AAEhE,sCAAsC;AACtC,uDAAuD;AACvD,qCAAqC;AACrC,oEAAoE;AACpE,6CAA6C;AAC7C,0CAA0C;AAC1C,cAAc;AACd,QAAQ;AACR,IAAI;AAEJ,2CAA2C;AAE3C,kDAAkD;AAElD,oDAAoD;AAEpD,qCAAqC;AACrC,wBAAwB;AACxB,IAAI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function measurePerformance(thresholdMs?: number): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export function measurePerformance(thresholdMs = 300) {
|
|
2
|
-
return function (target, propertyKey, descriptor) {
|
|
3
|
-
const originalMethod = descriptor.value;
|
|
4
|
-
const isAsync = originalMethod.constructor.name === "AsyncFunction";
|
|
5
|
-
descriptor.value = function (...args) {
|
|
6
|
-
const start = performance.now();
|
|
7
|
-
try {
|
|
8
|
-
const result = originalMethod.apply(this, args);
|
|
9
|
-
if (isAsync || result instanceof Promise) {
|
|
10
|
-
return result.then((resolvedResult) => {
|
|
11
|
-
const end = performance.now();
|
|
12
|
-
const executionTime = end - start;
|
|
13
|
-
if (executionTime > thresholdMs) {
|
|
14
|
-
console.warn(`⚠️ Slow execution: ${propertyKey} took ${executionTime.toFixed(2)}ms to execute`);
|
|
15
|
-
}
|
|
16
|
-
return resolvedResult;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
const end = performance.now();
|
|
21
|
-
const executionTime = end - start;
|
|
22
|
-
if (executionTime > thresholdMs) {
|
|
23
|
-
console.warn(`⚠️ Slow execution: ${propertyKey} took ${executionTime.toFixed(2)}ms to execute`);
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
return descriptor;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=decorator-util.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorator-util.js","sourceRoot":"","sources":["../../src/decorator-util.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,cAAsB,GAAG;IACxD,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC7E,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QACxC,MAAM,OAAO,GAAG,cAAc,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe,CAAC;QAEpE,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAW;YACvC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;YAEhC,IAAI,CAAC;gBACD,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CA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