@pkcprotocol/pkc-js 0.0.128 → 0.0.130
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/README.md +16 -5
- package/dist/browser/clients/rpc-client/pkc-rpc-client.d.ts +2 -2
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js +8 -3
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -1
- package/dist/browser/clients/rpc-client/schema.d.ts +10 -1
- package/dist/browser/clients/rpc-client/schema.js +8 -1
- package/dist/browser/clients/rpc-client/schema.js.map +1 -1
- package/dist/browser/clients/rpc-client/types.d.ts +5 -1
- package/dist/browser/community/communities-entry-util.d.ts +14 -0
- package/dist/browser/community/communities-entry-util.js +20 -0
- package/dist/browser/community/communities-entry-util.js.map +1 -0
- package/dist/browser/errors.d.ts +1 -0
- package/dist/browser/errors.js +1 -0
- package/dist/browser/errors.js.map +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/pkc/pkc-with-rpc-client.d.ts +2 -0
- package/dist/browser/pkc/pkc-with-rpc-client.js +66 -3
- package/dist/browser/pkc/pkc-with-rpc-client.js.map +1 -1
- package/dist/browser/pkc/pkc.d.ts +5 -3
- package/dist/browser/pkc/pkc.js +15 -10
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/rpc/src/index.js +10 -8
- package/dist/browser/rpc/src/index.js.map +1 -1
- package/dist/browser/runtime/browser/util.d.ts +1 -0
- package/dist/browser/runtime/browser/util.js +3 -0
- package/dist/browser/runtime/browser/util.js.map +1 -1
- package/dist/browser/runtime/node/community/db-handler.js +2 -4
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/editing.js +13 -6
- package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.js +9 -1
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/runtime/node/community/start-lock.d.ts +8 -0
- package/dist/browser/runtime/node/community/start-lock.js +18 -0
- package/dist/browser/runtime/node/community/start-lock.js.map +1 -0
- package/dist/browser/runtime/node/util.d.ts +6 -0
- package/dist/browser/runtime/node/util.js +106 -8
- package/dist/browser/runtime/node/util.js.map +1 -1
- package/dist/browser/test/test-util.d.ts +20 -0
- package/dist/browser/test/test-util.js +25 -0
- package/dist/browser/test/test-util.js.map +1 -1
- package/dist/browser/types.d.ts +7 -3
- package/dist/bundled/bundle-manifest.json +53 -51
- package/dist/bundled/challenges.js +1 -1
- package/dist/bundled/chunks/{helia-for-pkc-6kkeZX1a.js → helia-for-pkc-CVGt82_T.js} +31 -31
- package/dist/bundled/chunks/{local-community-BST1U_f3.js → local-community-fdVlmCGN.js} +1 -1
- package/dist/bundled/chunks/{local-community-B79BAYRo.js → local-community-wNpPFFZe.js} +18 -1381
- package/dist/bundled/chunks/{node-BEH8NA_I.js → node-Z0wgsXeR.js} +76 -16
- package/dist/bundled/chunks/{page-sort-scoring-2FkqYYNf.js → page-sort-scoring-DerjGUL1.js} +1 -1
- package/dist/bundled/chunks/{rpc-local-community-SmLDPm1j.js → rpc-local-community-CJbuAfCd.js} +1571 -48
- package/dist/bundled/chunks/{util-LwSS90AE.js → util-B_sAleCo.js} +20 -19
- package/dist/bundled/chunks/{util-jyIDYw_Q.js → util-kemFUDC0.js} +1 -1
- package/dist/bundled/chunks/{validate-package-factories-_KKnb8At.js → validate-package-factories-DLuTOpn4.js} +2 -2
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/page-sorts.js +1 -1
- package/dist/bundled/rpc/src/index.js +10 -9
- package/dist/node/clients/rpc-client/pkc-rpc-client.d.ts +2 -2
- package/dist/node/clients/rpc-client/pkc-rpc-client.js +8 -3
- package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -1
- package/dist/node/clients/rpc-client/schema.d.ts +10 -1
- package/dist/node/clients/rpc-client/schema.js +8 -1
- package/dist/node/clients/rpc-client/schema.js.map +1 -1
- package/dist/node/clients/rpc-client/types.d.ts +5 -1
- package/dist/node/community/communities-entry-util.d.ts +14 -0
- package/dist/node/community/communities-entry-util.js +20 -0
- package/dist/node/community/communities-entry-util.js.map +1 -0
- package/dist/node/errors.d.ts +1 -0
- package/dist/node/errors.js +1 -0
- package/dist/node/errors.js.map +1 -1
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/pkc/pkc-with-rpc-client.d.ts +2 -0
- package/dist/node/pkc/pkc-with-rpc-client.js +66 -3
- package/dist/node/pkc/pkc-with-rpc-client.js.map +1 -1
- package/dist/node/pkc/pkc.d.ts +5 -3
- package/dist/node/pkc/pkc.js +15 -10
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/rpc/src/index.js +10 -8
- package/dist/node/rpc/src/index.js.map +1 -1
- package/dist/node/runtime/browser/util.d.ts +1 -0
- package/dist/node/runtime/browser/util.js +3 -0
- package/dist/node/runtime/browser/util.js.map +1 -1
- package/dist/node/runtime/node/community/db-handler.js +2 -4
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/editing.js +13 -6
- package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.js +9 -1
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/runtime/node/community/start-lock.d.ts +8 -0
- package/dist/node/runtime/node/community/start-lock.js +18 -0
- package/dist/node/runtime/node/community/start-lock.js.map +1 -0
- package/dist/node/runtime/node/util.d.ts +6 -0
- package/dist/node/runtime/node/util.js +106 -8
- package/dist/node/runtime/node/util.js.map +1 -1
- package/dist/node/test/test-util.d.ts +20 -0
- package/dist/node/test/test-util.js +25 -0
- package/dist/node/test/test-util.js.map +1 -1
- package/dist/node/types.d.ts +7 -3
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as retryKuboIpfsAddAndProvide, At as ChallengeAnswerMessageSchema, C as hideClassPrivateProps, D as isIpfsCid, Dt as require_sha256, E as isAbortError, Et as untrackUpdatingCommunity, H as rejectWhenAbortSignalFires, Hr as setErrorMap, It as ChallengeVerificationMessageSchema, J as removeUndefinedValuesRecursively, Jt as version_default, Lr as PKCError, Mr as FailedToFetchCommentIpfsFromGatewaysError, Mt as ChallengeMessageSchema,
|
|
3
|
-
import { $n as
|
|
4
|
-
import { s as getHeliaDebugContext } from "./util-
|
|
2
|
+
import { $ as retryKuboIpfsAddAndProvide, At as ChallengeAnswerMessageSchema, C as hideClassPrivateProps, D as isIpfsCid, Dt as require_sha256, E as isAbortError, Et as untrackUpdatingCommunity, H as rejectWhenAbortSignalFires, Hr as setErrorMap, In as CommentUpdateForChallengeVerificationSchema, It as ChallengeVerificationMessageSchema, J as removeUndefinedValuesRecursively, Jt as version_default, Lr as PKCError, Mr as FailedToFetchCommentIpfsFromGatewaysError, Mt as ChallengeMessageSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Ot as TimeoutError, Pt as ChallengeRequestMessageSchema, Q as retryKuboIpfsAdd, Rr as messages, Sr as e$1, St as trackUpdatingComment, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingComment, U as rejectWhenCommunityStopsOrAborts, X as resolveWhenPredicateIsTrue, Y as replaceXWithY, _t as listUpdatingCommunities, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as timestamp, br as t$1, cn as CommunityAnchorSchema, d as deepMergeRuntimeFields, dt as findStartedCommunity, et as shortifyAddress, ft as findUpdatingComment, gr as n$2, gt as listUpdatingComments, hr as isStringDomain, ht as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, it as throwIfAbortSignalAborted, jn as CommentIpfsSchema, jr as require_retry, k as isIpns, kt as pTimeout, ni as en_default, nt as sleepUntilTimeoutOrAbort, ot as waitForUpdateInCommunityInstanceWithErrorAndTimeout, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, r as calculateIpfsCidV0, tt as shortifyCid, u as createAbortError, vr as n$1, vt as refreshTrackedCommentAliases, wr as r, x as getPostUpdateTimestampRange, xn as PubsubTopicSchema, xr as e, zn as CommentUpdateSchema, zr as logger_default } from "./util-B_sAleCo.js";
|
|
3
|
+
import { $n as buildRuntimeCommunityFields, $r as require_undici, $t as RpcPublishCommunityListParamSchema, A as findCommentInParsedPages, Ar as setNativeFunctions$1, At as parseRpcCommentUpdateEventWithPKCErrorIfItFails, B as GenericStateClient, Bn as verifyCommunityEdit, Br as t$3, Bt as RpcCommunityIdentifierParamSchema, C as RepliesPages, Cn as signCommentModeration, Ct as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as signCommunityEdit, Dt as parseJsonWithPKCErrorIfFails, Er as monitorCommunitiesDirectory, Et as parseDecryptedChallengeWithPKCErrorIfItFails, F as cloneCrosspostForRuntime, Fn as verifyCommentIpfs, Ft as RpcAuthorNameParamSchema, G as PKCTypedEmitter, Gn as getAuthorNameFromRuntime, Gt as RpcExportCommunityParamSchema, H as InflightResourceTypes, Hn as verifyVote, Ht as RpcEditCommunityParamSchema, I as collectCrosspostAuthorsToResolve, In as verifyCommentModeration, It as RpcCancelExportParamSchema, J as decodeRpcChallengeRequestPubsubMsg, Jn as CreateCommunityListWithCidOptionsSchema, Jr as NAME_RESOLVED_TRUE_TTL_MS, Jt as RpcFetchCidResultSchema, K as decodeRpcChallengeAnswerPubsubMsg, Kn as getAuthorNameFromWire, Kr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Kt as RpcExportCommunityResultSchema, Ln as verifyCommentPubsubMessage, Lr as t$5, Lt as RpcCidParamSchema, M as parseRawPages, Mr as findCommunitiesEntry, Nn as verifyChallengeVerification, Nr as toCommunitiesEntry, Nt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, O as findCommentInPageInstance, On as signCommunityList, Ot as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as applyNameResolvedCacheToCrosspost, Pn as verifyCommentEdit, Pt as RpcAnchorPublishPreparationResultSchema, Qr as nativeFunctions$2, Qt as RpcPublishChallengeAnswersParamSchema, R as stripNameResolvedFromCrosspost, Rn as verifyCommentUpdate, Rt as RpcCommentRepliesPageParamSchema, Sn as signCommentEdit, Sr as getDefaultDataPath, St as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tr as listCommunitiesSync, Tt as parseDecryptedChallengeVerification, Un as buildRuntimeAuthor, Ur as t$2, Ut as RpcExportCommunityModLogsParamSchema, V as InflightFetchManager, Vn as verifyCommunityList, Vr as n$3, Vt as RpcCommunityPageParamSchema, Wn as cleanWireAuthor, Wr as t$4, Wt as RpcExportCommunityModLogsResultSchema, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, Xt as RpcFetchCommunityListResultSchema, Y as decodeRpcChallengeVerificationPubsubMsg, Yn as CreateNewCommunityListOptionsSchema, Yr as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, Yt as RpcFetchCommunityListParamSchema, Zt as RpcPublishAnchorRecordParamSchema, _n as signChallengeAnswer, _t as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as RpcUnsubscribeParamSchema, b as KeyvBetterSqlite3, br as findLocalCommunityAddress, ct as parseCommentUpdateSchemaWithPKCErrorIfItFails, dn as decryptEd25519AesGcm, en as RpcPublishCommunityListResultSchema, er as getCommunityAddressFromRecord, et as parseCidStringSchemaWithPKCErrorIfItFails, ft as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, gn as cleanUpBeforePublishing, gt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, hr as createKuboRpcClient, ht as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, in as RpcSuccessResultSchema, ir as decode, it as parseCommentIpfsSchemaWithPKCErrorIfItFails, jn as verifyChallengeMessage, jr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kn as signVote, kt as parseRpcCommentEventWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as createSigner, lr as getPKCAddressFromPublicKeySync, lt as parseCommunityAddressWithPKCErrorIfItFails, m as pkcJsChallenges, mt as parseCommunityListSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as RpcResolveAuthorNameResultSchema, nr as getCommunityPublicKeyFromWire, on as findCommunityRecordNameMismatch, or as getBufferedPKCAddressFromPublicKey, ot as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, pn as encryptEd25519AesGcm, q as decodeRpcChallengePubsubMsg, qn as normalizeCreatePublicationAuthor, qr as NAME_RESOLVED_FALSE_TTL_MS, qt as RpcFetchCidParamSchema, rn as RpcSubscriptionIdResultSchema, rr as normalizeCommunityInputFromCommunity, rt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, sn as require_lib$1, st as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as RpcPublishedAnchorRecordResultSchema, tr as getCommunityNameFromWire, un as createAnchorIpnsRecord$1, v as TrackedInstanceRegistry, vt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as RemoteCommunity, xn as signComment, xt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, yn as signChallengeRequest, z as PKCClientsManager, zt as RpcCommunitiesChangeEventResultSchema } from "./rpc-local-community-CJbuAfCd.js";
|
|
4
|
+
import { s as getHeliaDebugContext } from "./util-kemFUDC0.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -3513,8 +3513,8 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
|
|
|
3513
3513
|
this._callTimeoutMs = envCallTimeoutMs > 0 ? envCallTimeoutMs : 3e5;
|
|
3514
3514
|
this.communities = [];
|
|
3515
3515
|
this._subscriptionEvents = {};
|
|
3516
|
-
this.on("communitieschange", (
|
|
3517
|
-
this.communities =
|
|
3516
|
+
this.on("communitieschange", ({ communities }) => {
|
|
3517
|
+
this.communities = communities;
|
|
3518
3518
|
});
|
|
3519
3519
|
this.on("settingschange", (newSettings) => {
|
|
3520
3520
|
this.settings = newSettings;
|
|
@@ -3959,7 +3959,12 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
|
|
|
3959
3959
|
async initalizeCommunitieschangeEvent() {
|
|
3960
3960
|
const { subscriptionId } = await this._subscribe("communitiesSubscribe", [], "resubscribe");
|
|
3961
3961
|
this.getSubscription(subscriptionId).on("communitieschange", (res) => {
|
|
3962
|
-
|
|
3962
|
+
const parsed = RpcCommunitiesChangeEventResultSchema.loose().safeParse(res.params.result);
|
|
3963
|
+
if (!parsed.success) return this.emit("error", new PKCError("ERR_INVALID_RPC_COMMUNITIES_SCHEMA", {
|
|
3964
|
+
zodError: parsed.error,
|
|
3965
|
+
result: res.params.result
|
|
3966
|
+
}));
|
|
3967
|
+
this.emit("communitieschange", { communities: parsed.data.communities.map((entry) => toCommunitiesEntry(entry)) });
|
|
3963
3968
|
});
|
|
3964
3969
|
this.emitAllPendingMessages(subscriptionId);
|
|
3965
3970
|
}
|
|
@@ -8671,8 +8676,8 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8671
8676
|
pageSorts: this.parsedPKCOptions.pageSorts
|
|
8672
8677
|
};
|
|
8673
8678
|
this.nameResolvers = this.pkcRpcClientsOptions ? void 0 : this.parsedPKCOptions.nameResolvers;
|
|
8674
|
-
this.on("communitieschange", (
|
|
8675
|
-
this.communities =
|
|
8679
|
+
this.on("communitieschange", ({ communities }) => {
|
|
8680
|
+
this.communities = communities;
|
|
8676
8681
|
});
|
|
8677
8682
|
this._promiseToWaitForFirstCommunitieschangeEvent = new Promise((resolve) => this.once("communitieschange", resolve));
|
|
8678
8683
|
this.clients = {};
|
|
@@ -8745,7 +8750,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8745
8750
|
this.clients.libp2pJsClients = {};
|
|
8746
8751
|
if (!this.libp2pJsClientsOptions) return;
|
|
8747
8752
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
8748
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
8753
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-CVGt82_T.js");
|
|
8749
8754
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
8750
8755
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
8751
8756
|
...clientOptions,
|
|
@@ -9090,10 +9095,11 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9090
9095
|
if (!Array.isArray(this.communities)) throw Error("pkc.communities should be defined after communitieschange event");
|
|
9091
9096
|
}
|
|
9092
9097
|
async _awaitCommunitiesToIncludeCommunity(communityAddress) {
|
|
9093
|
-
|
|
9098
|
+
const isListed = () => Boolean(findCommunitiesEntry(this.communities, { address: communityAddress }));
|
|
9099
|
+
if (isListed()) return;
|
|
9094
9100
|
else await resolveWhenPredicateIsTrue({
|
|
9095
9101
|
toUpdate: this,
|
|
9096
|
-
predicate:
|
|
9102
|
+
predicate: isListed,
|
|
9097
9103
|
eventName: "communitieschange"
|
|
9098
9104
|
});
|
|
9099
9105
|
}
|
|
@@ -9109,7 +9115,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9109
9115
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
9110
9116
|
log.trace("Received community options to create a local community instance:", options);
|
|
9111
9117
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
9112
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
9118
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-fdVlmCGN.js");
|
|
9113
9119
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
9114
9120
|
const community = new LocalCommunity(this);
|
|
9115
9121
|
if (isLocalCommunity) {
|
|
@@ -9129,7 +9135,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9129
9135
|
} else throw Error("Are you trying to create a local community with no address or signer? This is a critical error");
|
|
9130
9136
|
}
|
|
9131
9137
|
async _createCommunityInstanceFromJsonifiedCommunity(jsonfied) {
|
|
9132
|
-
if (this.communities
|
|
9138
|
+
if (findCommunitiesEntry(this.communities, { address: jsonfied.address })) return this._createLocalCommunity(jsonfied);
|
|
9133
9139
|
else return this._createRemoteCommunityInstance(jsonfied);
|
|
9134
9140
|
}
|
|
9135
9141
|
async createCommunity(options = {}, opts) {
|
|
@@ -9176,7 +9182,11 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9176
9182
|
log(`Creating a delegated local community with anchor (${anchor.publicKey}) and minter (${minterSigner.address})`);
|
|
9177
9183
|
return this._createLocalCommunity(localOptions);
|
|
9178
9184
|
} else if (hasIdentifier && !hasSigner) {
|
|
9179
|
-
const localCommunityAddress = (
|
|
9185
|
+
const localCommunityAddress = findLocalCommunityAddress(this, {
|
|
9186
|
+
address: parsedOptions.address,
|
|
9187
|
+
name: parsedOptions.name,
|
|
9188
|
+
publicKey: parsedOptions.publicKey
|
|
9189
|
+
});
|
|
9180
9190
|
if (localCommunityAddress) return this._createLocalCommunity({ address: localCommunityAddress });
|
|
9181
9191
|
else {
|
|
9182
9192
|
const parsedRemoteOptions = parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails(options);
|
|
@@ -9530,6 +9540,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9530
9540
|
const nativeFunctions$1 = { fetch: (...args) => window.fetch(...args) };
|
|
9531
9541
|
//#endregion
|
|
9532
9542
|
//#region dist/node/pkc/pkc-with-rpc-client.js
|
|
9543
|
+
const isInvalidCommunitiesListError = (error) => error instanceof PKCError && error.code === "ERR_INVALID_RPC_COMMUNITIES_SCHEMA";
|
|
9533
9544
|
var PKCWithRpcClient = class extends PKC$1 {
|
|
9534
9545
|
constructor(options) {
|
|
9535
9546
|
super(options);
|
|
@@ -9539,6 +9550,7 @@ var PKCWithRpcClient = class extends PKC$1 {
|
|
|
9539
9550
|
await super._init();
|
|
9540
9551
|
const log = logger_default("pkc-js:pkc-with-rpc-client:_init");
|
|
9541
9552
|
this.communities = [];
|
|
9553
|
+
this._waitForFirstValidCommunitiesList();
|
|
9542
9554
|
this._pkcRpcClient.on("communitieschange", (newSubs) => this.emit("communitieschange", newSubs));
|
|
9543
9555
|
for (const rpcUrl of Object.keys(this.clients.pkcRpcClients)) {
|
|
9544
9556
|
const rpcClient = this.clients.pkcRpcClients[rpcUrl];
|
|
@@ -9554,6 +9566,27 @@ var PKCWithRpcClient = class extends PKC$1 {
|
|
|
9554
9566
|
this.emit("settingschange", newSettings.pkcOptions);
|
|
9555
9567
|
});
|
|
9556
9568
|
}
|
|
9569
|
+
_waitForFirstValidCommunitiesList() {
|
|
9570
|
+
this._promiseToWaitForFirstCommunitieschangeEvent = new Promise((resolve, reject) => {
|
|
9571
|
+
const cleanup = () => {
|
|
9572
|
+
this.removeListener("communitieschange", onCommunitiesChange);
|
|
9573
|
+
this._pkcRpcClient.removeListener("error", onRpcError);
|
|
9574
|
+
};
|
|
9575
|
+
const onCommunitiesChange = (event) => {
|
|
9576
|
+
cleanup();
|
|
9577
|
+
resolve(event);
|
|
9578
|
+
};
|
|
9579
|
+
const onRpcError = (error) => {
|
|
9580
|
+
if (!isInvalidCommunitiesListError(error)) return;
|
|
9581
|
+
cleanup();
|
|
9582
|
+
reject(error);
|
|
9583
|
+
this._waitForFirstValidCommunitiesList();
|
|
9584
|
+
};
|
|
9585
|
+
this.on("communitieschange", onCommunitiesChange);
|
|
9586
|
+
this._pkcRpcClient.on("error", onRpcError);
|
|
9587
|
+
});
|
|
9588
|
+
this._promiseToWaitForFirstCommunitieschangeEvent.catch(() => {});
|
|
9589
|
+
}
|
|
9557
9590
|
async fetchCid(cid) {
|
|
9558
9591
|
const parsedCid = parseRpcFetchCidParam(cid).cid;
|
|
9559
9592
|
return this._pkcRpcClient.fetchCid({ cid: parsedCid });
|
|
@@ -9562,6 +9595,28 @@ var PKCWithRpcClient = class extends PKC$1 {
|
|
|
9562
9595
|
const parsedArgs = parseRpcAuthorNameParam(args);
|
|
9563
9596
|
return this._pkcRpcClient.resolveAuthorName(parsedArgs);
|
|
9564
9597
|
}
|
|
9598
|
+
async _awaitCommunitiesToIncludeCommunity(communityAddress) {
|
|
9599
|
+
const isListed = () => Boolean(findCommunitiesEntry(this.communities, { address: communityAddress }));
|
|
9600
|
+
if (isListed()) return;
|
|
9601
|
+
await new Promise((resolve, reject) => {
|
|
9602
|
+
const cleanup = () => {
|
|
9603
|
+
this.removeListener("communitieschange", onCommunitiesChange);
|
|
9604
|
+
this._pkcRpcClient.removeListener("error", onRpcError);
|
|
9605
|
+
};
|
|
9606
|
+
const onCommunitiesChange = () => {
|
|
9607
|
+
if (!isListed()) return;
|
|
9608
|
+
cleanup();
|
|
9609
|
+
resolve();
|
|
9610
|
+
};
|
|
9611
|
+
const onRpcError = (error) => {
|
|
9612
|
+
if (!isInvalidCommunitiesListError(error)) return;
|
|
9613
|
+
cleanup();
|
|
9614
|
+
reject(error);
|
|
9615
|
+
};
|
|
9616
|
+
this.on("communitieschange", onCommunitiesChange);
|
|
9617
|
+
this._pkcRpcClient.on("error", onRpcError);
|
|
9618
|
+
});
|
|
9619
|
+
}
|
|
9565
9620
|
async destroy() {
|
|
9566
9621
|
for (const startedCommunity of listStartedCommunities(this)) await startedCommunity.stopWithoutRpcCall();
|
|
9567
9622
|
await super.destroy();
|
|
@@ -9604,7 +9659,12 @@ var PKCWithRpcClient = class extends PKC$1 {
|
|
|
9604
9659
|
const effectiveAddress = parsedRpcOptions.address || parsedRpcOptions.name || parsedRpcOptions.publicKey;
|
|
9605
9660
|
if (hasIdentifier && effectiveAddress) {
|
|
9606
9661
|
await this._waitForCommunitiesToBeDefined();
|
|
9607
|
-
const
|
|
9662
|
+
const rpcLocalEntry = findCommunitiesEntry(this.communities, {
|
|
9663
|
+
address: parsedRpcOptions.address,
|
|
9664
|
+
name: parsedRpcOptions.name,
|
|
9665
|
+
publicKey: parsedRpcOptions.publicKey
|
|
9666
|
+
});
|
|
9667
|
+
const isCommunityRpcLocal = Boolean(rpcLocalEntry);
|
|
9608
9668
|
if ("clients" in options && isCommunityRpcLocal) {
|
|
9609
9669
|
const community = new RpcLocalCommunity(this);
|
|
9610
9670
|
const jsonified = parsedRpcOptions;
|
|
@@ -9616,7 +9676,7 @@ var PKCWithRpcClient = class extends PKC$1 {
|
|
|
9616
9676
|
return community;
|
|
9617
9677
|
} else if (isCommunityRpcLocal) {
|
|
9618
9678
|
const community = new RpcLocalCommunity(this);
|
|
9619
|
-
community.setAddress(
|
|
9679
|
+
community.setAddress(rpcLocalEntry.address);
|
|
9620
9680
|
const updatePromise = new Promise((resolve) => community.once("update", resolve));
|
|
9621
9681
|
let error;
|
|
9622
9682
|
const errorPromise = new Promise((resolve) => community.once("error", (err) => resolve(error = err)));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bn as PageSortFileSchema,
|
|
1
|
+
import { bn as PageSortFileSchema, hr as isStringDomain, v as getEquivalentCommunityAddresses } from "./util-B_sAleCo.js";
|
|
2
2
|
//#region dist/node/pages/page-sort-scoring.js
|
|
3
3
|
function validatePageSortFile(rawFile) {
|
|
4
4
|
const validated = PageSortFileSchema.parse(rawFile);
|