@pkcprotocol/pkc-js 0.0.74 → 0.0.76
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 +34 -1
- package/dist/browser/clients/rpc-client/pkc-rpc-client.d.ts +3 -1
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js +12 -1
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -1
- package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +18 -0
- package/dist/browser/clients/rpc-client/rpc-schema-util.js +5 -1
- package/dist/browser/clients/rpc-client/rpc-schema-util.js.map +1 -1
- package/dist/browser/clients/rpc-client/schema.d.ts +15 -0
- package/dist/browser/clients/rpc-client/schema.js +20 -0
- package/dist/browser/clients/rpc-client/schema.js.map +1 -1
- package/dist/browser/clients/rpc-client/types.d.ts +3 -2
- package/dist/browser/community/community-client-manager.js +9 -9
- package/dist/browser/community/community-client-manager.js.map +1 -1
- package/dist/browser/community/rpc-local-community.d.ts +6 -1
- package/dist/browser/community/rpc-local-community.js +32 -0
- package/dist/browser/community/rpc-local-community.js.map +1 -1
- package/dist/browser/community/schema.d.ts +15 -0
- package/dist/browser/community/schema.js +16 -1
- package/dist/browser/community/schema.js.map +1 -1
- package/dist/browser/community/types.d.ts +14 -1
- package/dist/browser/constants.d.ts +3 -1
- package/dist/browser/constants.js +9 -1
- package/dist/browser/constants.js.map +1 -1
- package/dist/browser/errors.d.ts +10 -0
- package/dist/browser/errors.js +10 -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/helia/helia-for-pkc.d.ts +1 -1
- package/dist/browser/helia/helia-for-pkc.js +41 -5
- package/dist/browser/helia/helia-for-pkc.js.map +1 -1
- package/dist/browser/helia/lru-blockstore.d.ts +92 -0
- package/dist/browser/helia/lru-blockstore.js +224 -0
- package/dist/browser/helia/lru-blockstore.js.map +1 -0
- package/dist/browser/index-with-compile-cache.d.ts +2 -0
- package/dist/browser/index-with-compile-cache.js +1 -0
- package/dist/browser/index-with-compile-cache.js.map +1 -1
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.js +8 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/pkc/pkc.js +41 -4
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/rpc/src/index.d.ts +4 -1
- package/dist/browser/rpc/src/index.js +29 -1
- package/dist/browser/rpc/src/index.js.map +1 -1
- package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +1 -0
- package/dist/browser/rpc/src/schema.d.ts +16 -0
- package/dist/browser/runtime/browser/blockstore.d.ts +25 -0
- package/dist/browser/runtime/browser/blockstore.js +40 -0
- package/dist/browser/runtime/browser/blockstore.js.map +1 -0
- package/dist/browser/runtime/node/blockstore.d.ts +32 -0
- package/dist/browser/runtime/node/blockstore.js +42 -0
- package/dist/browser/runtime/node/blockstore.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community/anchor-publishing.d.ts +9 -0
- package/dist/browser/runtime/node/community/local-community/anchor-publishing.js +197 -0
- package/dist/browser/runtime/node/community/local-community/anchor-publishing.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community/db-state.js +22 -4
- package/dist/browser/runtime/node/community/local-community/db-state.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/identity.d.ts +2 -0
- package/dist/browser/runtime/node/community/local-community/identity.js +13 -0
- package/dist/browser/runtime/node/community/local-community/identity.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community/lifecycle.js +24 -0
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-store.js +7 -3
- package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-validation.js +6 -2
- package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.d.ts +5 -1
- package/dist/browser/runtime/node/community/local-community.js +47 -6
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/schema/schema-util.d.ts +6 -0
- package/dist/browser/schema/schema.d.ts +1 -0
- package/dist/browser/schema/schema.js +11 -0
- package/dist/browser/schema/schema.js.map +1 -1
- package/dist/browser/schema.d.ts +20 -0
- package/dist/browser/schema.js +11 -1
- package/dist/browser/schema.js.map +1 -1
- package/dist/browser/signer/index.d.ts +1 -0
- package/dist/browser/signer/index.js +1 -0
- package/dist/browser/signer/index.js.map +1 -1
- package/dist/browser/signer/ipns-record.d.ts +7 -0
- package/dist/browser/signer/ipns-record.js +34 -0
- package/dist/browser/signer/ipns-record.js.map +1 -0
- package/dist/browser/signer/signatures.d.ts +2 -2
- package/dist/browser/signer/signatures.js +18 -6
- package/dist/browser/signer/signatures.js.map +1 -1
- package/dist/browser/test/test-util.d.ts +4 -0
- package/dist/bundled/bundle-manifest.json +204 -92
- package/dist/bundled/chunks/helia-for-pkc-cKp6JSwA.js +6915 -0
- package/dist/bundled/chunks/{local-community-Br1ipu1Z.js → local-community-B3Fhrtiy.js} +205 -38
- package/dist/bundled/chunks/{local-community-CIVs_iuS.js → local-community-DerKPzJm.js} +1 -1
- package/dist/bundled/chunks/{node-Cn7VaPDJ.js → node-DffqRPit.js} +43 -9
- package/dist/bundled/chunks/{rpc-local-community-DtdeJBOq.js → rpc-local-community-BdNiruAf.js} +96 -38
- package/dist/bundled/chunks/{schema-B1Ot-kux.js → schema-BvBJX6m7.js} +29 -5
- package/dist/bundled/chunks/{src-o_MYSn-E.js → src-B2CwDTfy.js} +2 -142
- package/dist/bundled/chunks/{src-4u0f92eE.js → src-BEjAH2gY.js} +3 -128
- package/dist/bundled/chunks/src-Cpx2Sts8.js +127 -0
- package/dist/bundled/chunks/src-DKntVmyX.js +142 -0
- package/dist/bundled/chunks/{util-B6v5HAdy.js → util-BRxHPb9G.js} +1 -1
- package/dist/bundled/index-with-compile-cache.js +2 -1
- package/dist/bundled/index.js +2 -2
- package/dist/bundled/rpc/src/index.js +27 -4
- package/dist/node/clients/rpc-client/pkc-rpc-client.d.ts +3 -1
- package/dist/node/clients/rpc-client/pkc-rpc-client.js +12 -1
- package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -1
- package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +18 -0
- package/dist/node/clients/rpc-client/rpc-schema-util.js +5 -1
- package/dist/node/clients/rpc-client/rpc-schema-util.js.map +1 -1
- package/dist/node/clients/rpc-client/schema.d.ts +15 -0
- package/dist/node/clients/rpc-client/schema.js +20 -0
- package/dist/node/clients/rpc-client/schema.js.map +1 -1
- package/dist/node/clients/rpc-client/types.d.ts +3 -2
- package/dist/node/community/community-client-manager.js +9 -9
- package/dist/node/community/community-client-manager.js.map +1 -1
- package/dist/node/community/rpc-local-community.d.ts +6 -1
- package/dist/node/community/rpc-local-community.js +32 -0
- package/dist/node/community/rpc-local-community.js.map +1 -1
- package/dist/node/community/schema.d.ts +15 -0
- package/dist/node/community/schema.js +16 -1
- package/dist/node/community/schema.js.map +1 -1
- package/dist/node/community/types.d.ts +14 -1
- package/dist/node/constants.d.ts +3 -1
- package/dist/node/constants.js +9 -1
- package/dist/node/constants.js.map +1 -1
- package/dist/node/errors.d.ts +10 -0
- package/dist/node/errors.js +10 -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/helia/helia-for-pkc.d.ts +1 -1
- package/dist/node/helia/helia-for-pkc.js +41 -5
- package/dist/node/helia/helia-for-pkc.js.map +1 -1
- package/dist/node/helia/lru-blockstore.d.ts +92 -0
- package/dist/node/helia/lru-blockstore.js +224 -0
- package/dist/node/helia/lru-blockstore.js.map +1 -0
- package/dist/node/index-with-compile-cache.d.ts +2 -0
- package/dist/node/index-with-compile-cache.js +1 -0
- package/dist/node/index-with-compile-cache.js.map +1 -1
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.js +8 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/pkc/pkc.js +41 -4
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/rpc/src/index.d.ts +4 -1
- package/dist/node/rpc/src/index.js +29 -1
- package/dist/node/rpc/src/index.js.map +1 -1
- package/dist/node/rpc/src/lib/pkc-js/index.d.ts +1 -0
- package/dist/node/rpc/src/schema.d.ts +16 -0
- package/dist/node/runtime/browser/blockstore.d.ts +25 -0
- package/dist/node/runtime/browser/blockstore.js +40 -0
- package/dist/node/runtime/browser/blockstore.js.map +1 -0
- package/dist/node/runtime/node/blockstore.d.ts +32 -0
- package/dist/node/runtime/node/blockstore.js +42 -0
- package/dist/node/runtime/node/blockstore.js.map +1 -0
- package/dist/node/runtime/node/community/local-community/anchor-publishing.d.ts +9 -0
- package/dist/node/runtime/node/community/local-community/anchor-publishing.js +197 -0
- package/dist/node/runtime/node/community/local-community/anchor-publishing.js.map +1 -0
- package/dist/node/runtime/node/community/local-community/db-state.js +22 -4
- package/dist/node/runtime/node/community/local-community/db-state.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/identity.d.ts +2 -0
- package/dist/node/runtime/node/community/local-community/identity.js +13 -0
- package/dist/node/runtime/node/community/local-community/identity.js.map +1 -0
- package/dist/node/runtime/node/community/local-community/lifecycle.js +24 -0
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-store.js +7 -3
- package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-validation.js +6 -2
- package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.d.ts +5 -1
- package/dist/node/runtime/node/community/local-community.js +47 -6
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/schema/schema-util.d.ts +6 -0
- package/dist/node/schema/schema.d.ts +1 -0
- package/dist/node/schema/schema.js +11 -0
- package/dist/node/schema/schema.js.map +1 -1
- package/dist/node/schema.d.ts +20 -0
- package/dist/node/schema.js +11 -1
- package/dist/node/schema.js.map +1 -1
- package/dist/node/signer/index.d.ts +1 -0
- package/dist/node/signer/index.js +1 -0
- package/dist/node/signer/index.js.map +1 -1
- package/dist/node/signer/ipns-record.d.ts +7 -0
- package/dist/node/signer/ipns-record.js +34 -0
- package/dist/node/signer/ipns-record.js.map +1 -0
- package/dist/node/signer/signatures.d.ts +2 -2
- package/dist/node/signer/signatures.js +18 -6
- package/dist/node/signer/signatures.js.map +1 -1
- package/dist/node/test/test-util.d.ts +4 -0
- package/package.json +8 -5
- package/dist/bundled/chunks/helia-for-pkc-B-75U9z9.js +0 -495
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
2
|
import { Buffer } from "buffer";
|
|
3
3
|
import { CID } from "multiformats/cid";
|
|
4
|
+
import { peerIdFromString } from "@libp2p/peer-id";
|
|
4
5
|
import * as Digest from "multiformats/hashes/digest";
|
|
5
6
|
import { base58btc } from "multiformats/bases/base58";
|
|
6
7
|
import { of } from "typestub-ipfs-only-hash";
|
|
7
8
|
import { toString } from "uint8arrays/to-string";
|
|
8
9
|
import { base32 } from "multiformats/bases/base32";
|
|
9
|
-
import { peerIdFromString } from "@libp2p/peer-id";
|
|
10
10
|
Object.freeze({ status: "aborted" });
|
|
11
11
|
function $constructor(name, initializer, params) {
|
|
12
12
|
function init(inst, def) {
|
|
@@ -5166,6 +5166,15 @@ var messages;
|
|
|
5166
5166
|
messages["ERR_FAILED_TO_SET_CONFIG_ON_KUBO_NODE"] = "Failed to set config on kubo node";
|
|
5167
5167
|
messages["ERR_FAILED_TO_SHUTDOWN_KUBO_NODE"] = "Failed to shutdown kubo node";
|
|
5168
5168
|
messages["ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY"] = "Can't create a new local community with the provided arguments";
|
|
5169
|
+
messages["ERR_CAN_NOT_CREATE_A_COMMUNITY_WITH_BOTH_SIGNER_AND_ANCHOR"] = "Can't create a community with both a signer and an anchor: a signer means the node holds the identity key, an anchor means the owner does";
|
|
5170
|
+
messages["ERR_CAN_NOT_CREATE_A_COMMUNITY_WITH_BOTH_ANCHOR_AND_IDENTIFIER"] = "Can't create a community with both an anchor and an address/name/publicKey: a delegated community is keyed by its anchor, so any other identifier would be silently ignored";
|
|
5171
|
+
messages["ERR_ANCHOR_PUBLIC_KEY_IS_INVALID"] = "anchor.publicKey is not a valid IPNS name: it becomes the community's address, so it has to be the same B58 representation community.publicKey uses";
|
|
5172
|
+
messages["ERR_COMMUNITY_IS_NOT_DELEGATED"] = "This community has no anchor, so it publishes under its own key and has no anchor record to prepare or publish";
|
|
5173
|
+
messages["ERR_UNABLE_TO_DETERMINE_ANCHOR_SEQUENCE"] = "Unable to determine the next anchor record sequence: neither this node nor the network knows one, and answering 0 could produce a record that can never win";
|
|
5174
|
+
messages["ERR_ANCHOR_IPNS_RECORD_IS_INVALID"] = "The anchor IPNS record is malformed or is not signed by the community's anchor key";
|
|
5175
|
+
messages["ERR_ANCHOR_IPNS_RECORD_POINTS_TO_DIFFERENT_MINTER"] = "The anchor IPNS record does not point at this node's minter key for this community";
|
|
5176
|
+
messages["ERR_ANCHOR_IPNS_RECORD_SEQUENCE_IS_NOT_GREATER"] = "The anchor IPNS record's sequence is not strictly greater than the highest already accepted (replay or rollback)";
|
|
5177
|
+
messages["ERR_DELEGATED_COMMUNITY_HAS_NO_ANCHOR_RECORD"] = "Can't start a delegated community before its anchor record has been published: nothing points the anchor at this node's minter, so the community would not be resolvable";
|
|
5169
5178
|
messages["ERR_COMMUNITY_ADDRESS_IS_PROVIDED_AS_NULL_OR_UNDEFINED"] = "User provided options.address in createCommunity that is either undefined or null";
|
|
5170
5179
|
messages["ERR_UNABLE_TO_DERIVE_PUBSUB_COMMENT_PUBLICATION_FROM_JSONIFIED_COMMENT"] = "User provided a jsonfied (cloned) Comment and we're unable to derive request.comment from it. This is an implementation error";
|
|
5171
5180
|
messages["ERR_UNABLE_TO_DERIVE_PUBSUB_COMMENT_EDIT_PUBLICATION_FROM_JSONIFIED_COMMENT_EDIT"] = "User provided a jsonfied (cloned) CommentEdit and we're unable to derive request.commentEdit from it. This is an implementation error";
|
|
@@ -5479,6 +5488,7 @@ var messages;
|
|
|
5479
5488
|
messages["ERR_RPC_CLIENT_TRYING_TO_STOP_REMOTE_COMMUNITY"] = "RPC client is attempting to stop a remote community";
|
|
5480
5489
|
messages["ERR_RPC_CLIENT_TRYING_TO_EDIT_REMOTE_COMMUNITY"] = "RPC client is attempting to edit remote community";
|
|
5481
5490
|
messages["ERR_RPC_CLIENT_TRYING_TO_DELETE_REMOTE_COMMUNITY"] = "RPC client is attempting to delete remote community";
|
|
5491
|
+
messages["ERR_RPC_CLIENT_TRYING_TO_USE_ANCHOR_METHOD_ON_NON_LOCAL_COMMUNITY"] = "RPC client is attempting to prepare or publish an anchor record for a community this node does not host locally";
|
|
5482
5492
|
messages["ERR_GENERIC_RPC_CLIENT_CALL_ERROR"] = "RPC client received an unknown error when executing call over websocket";
|
|
5483
5493
|
messages["ERR_RPC_CALL_TIMED_OUT"] = "RPC client call timed out without receiving a response from the RPC server";
|
|
5484
5494
|
messages["ERR_RPC_CLIENT_CHALLENGE_NAME_NOT_AVAILABLE_ON_SERVER"] = "The challenge name is not available on the RPC server. Available challenges are listed in details.availableChallenges";
|
|
@@ -6104,6 +6114,13 @@ const isIpfsCid$1 = (value) => {
|
|
|
6104
6114
|
return false;
|
|
6105
6115
|
}
|
|
6106
6116
|
};
|
|
6117
|
+
const isIpnsName = (value) => {
|
|
6118
|
+
try {
|
|
6119
|
+
return Boolean(peerIdFromString(value));
|
|
6120
|
+
} catch {
|
|
6121
|
+
return false;
|
|
6122
|
+
}
|
|
6123
|
+
};
|
|
6107
6124
|
const CidStringSchema = string().refine((arg) => isIpfsCid$1(arg), messages.ERR_CID_IS_INVALID);
|
|
6108
6125
|
const CidPathSchema = string().transform((arg) => arg.split("/")[2]).refine((arg) => isIpfsCid$1(arg), messages.ERR_CID_IS_INVALID);
|
|
6109
6126
|
const ChainTickerSchema$1 = string().min(1);
|
|
@@ -6708,8 +6725,10 @@ const CommunityEditOptionsSchema = CommunityIpfsSchema.pick({
|
|
|
6708
6725
|
settings: CommunitySettingsSchema.optional(),
|
|
6709
6726
|
roles: CommunityRolesToEditSchema.optional()
|
|
6710
6727
|
}).partial().strict();
|
|
6728
|
+
const CommunityAnchorSchema = object({ publicKey: string().refine((arg) => isIpnsName(arg), messages.ERR_ANCHOR_PUBLIC_KEY_IS_INVALID) }).strict();
|
|
6711
6729
|
const CreateNewLocalCommunityUserOptionsSchema = CommunityEditOptionsSchema.omit({ address: true }).extend({
|
|
6712
6730
|
signer: CreateSignerSchema.optional(),
|
|
6731
|
+
anchor: CommunityAnchorSchema.optional(),
|
|
6713
6732
|
roles: CommunityIpfsSchema.shape.roles
|
|
6714
6733
|
}).strict();
|
|
6715
6734
|
CreateNewLocalCommunityUserOptionsSchema.extend({
|
|
@@ -6766,6 +6785,7 @@ const CommunityIpfsReservedFields = r$2([
|
|
|
6766
6785
|
"shortAddress",
|
|
6767
6786
|
"nameResolved",
|
|
6768
6787
|
"ipnsHops",
|
|
6788
|
+
"anchor",
|
|
6769
6789
|
"raw",
|
|
6770
6790
|
"shortCommunityAddress",
|
|
6771
6791
|
"deleted",
|
|
@@ -15997,7 +16017,7 @@ async function fetchAndValidateIpnsRecordFromGateway(gatewayUrl, ipnsName, opts)
|
|
|
15997
16017
|
const textEncoder = new TextEncoder();
|
|
15998
16018
|
async function calculateStringSizeSameAsIpfsAddCidV0(content) {
|
|
15999
16019
|
const { MemoryBlockstore } = await import("blockstore-core");
|
|
16000
|
-
const { importFile } = await import("./src-
|
|
16020
|
+
const { importFile } = await import("./src-B2CwDTfy.js");
|
|
16001
16021
|
const blockstore = new MemoryBlockstore();
|
|
16002
16022
|
const entry = await importFile({
|
|
16003
16023
|
path: "content.json",
|
|
@@ -16035,7 +16055,7 @@ function extractNetworkErrorDetails(err, depth = 0) {
|
|
|
16035
16055
|
}
|
|
16036
16056
|
//#endregion
|
|
16037
16057
|
//#region dist/node/generated-version.js
|
|
16038
|
-
const version = "0.0.
|
|
16058
|
+
const version = "0.0.76";
|
|
16039
16059
|
//#endregion
|
|
16040
16060
|
//#region dist/node/version.js
|
|
16041
16061
|
const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
|
|
@@ -16076,7 +16096,11 @@ const PKCUserOptionBaseSchema = object({
|
|
|
16076
16096
|
libp2pJsClientsOptions: object({
|
|
16077
16097
|
key: string().min(1),
|
|
16078
16098
|
libp2pOptions: custom().default({}),
|
|
16079
|
-
heliaOptions: custom().default({})
|
|
16099
|
+
heliaOptions: custom().default({}),
|
|
16100
|
+
blockstoreOptions: object({
|
|
16101
|
+
maxBytes: number().positive().optional(),
|
|
16102
|
+
lowWaterRatio: number().gt(0).lte(1).optional()
|
|
16103
|
+
}).optional()
|
|
16080
16104
|
}).array().max(1, "Only one libp2pJsClientOptions is allowed at the moment").optional(),
|
|
16081
16105
|
validatePages: boolean(),
|
|
16082
16106
|
userAgent: UserAgentSchema,
|
|
@@ -16185,4 +16209,4 @@ const DecryptedChallengeVerificationSchema = object({
|
|
|
16185
16209
|
}).strict();
|
|
16186
16210
|
const ChallengeVerificationMessageSignedPropertyNames = t$3(n$3(ChallengeVerificationMessageSchema.shape, ["signature"]));
|
|
16187
16211
|
//#endregion
|
|
16188
|
-
export { pubsubTopicToDhtKey as $,
|
|
16212
|
+
export { pubsubTopicToDhtKey as $, n$3 as $n, CommunityChallengeSettingSchema as $t, extractNetworkErrorDetails as A, CommentsTableRowSchema as An, object as Ar, trackStartedCommunity as At, isIpfsCid as B, CommentEditsTableRowSchema as Bn, CommunityEditPublicationPubsubReservedFields as Bt, contentContainsMarkdownAudio as C, CommentUpdateChallengeReservedFieldNames as Cn, setErrorMap as Cr, findUpdatingCommunity as Ct, deepMergeRuntimeFields as D, CommentUpdateSchema as Dn, custom as Dr, refreshTrackedCommentAliases as Dt, createAbortError as E, CommentUpdateReservedFields as En, boolean as Er, listUpdatingCommunities as Et, getIpnsRecordInLocalKuboNode as F, CommentEditChallengeRequestToEncryptSchema as Fn, parsedType as Fr, untrackUpdatingCommunity as Ft, isLinkOfAudio as G, ChallengeAnswersSchema as Gn, CommentModerationPubsubMessagePublicationSchema as Gt, isIpns as H, AuthorAddressSchema as Hn, CommunityEditPubsubMessagePublicationSchema as Ht, getPostUpdateTimestampRange as I, CommentEditPubsubMessagePublicationSchema as In, stringifyPrimitive as Ir, require_sha256 as It, isLinkOfVideo as J, CommunityAddressSchema as Jn, CommentModerationsTableRowSchema as Jt, isLinkOfImage as K, CidPathSchema as Kn, CommentModerationReservedFields as Kt, hideClassPrivateProps as L, CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema as Ln, TimeoutError as Lt, genToArray as M, GetPageParamSchema as Mn, string as Mr, trackUpdatingCommunity as Mt, getEquivalentCommunityAddresses as N, ModQueuePageIpfsSchema as Nn, ZodError as Nr, untrackStartedCommunity as Nt, derivePublicationFromChallengeRequest as O, CommentUpdateSignedPropertyNames as On, literal as Or, refreshTrackedCommunityAliases as Ot, getErrorCodeFromMessage as P, PageIpfsSchema as Pn, joinValues as Pr, untrackUpdatingComment as Pt, isStringDomain as Q, t$1 as Qn, CommunityAnchorSchema as Qt, ipnsNameToIpnsOverPubsubTopic as R, CommentEditReservedFields as Rn, pTimeout as Rt, calculateStringSizeSameAsIpfsAddCidV0 as S, CommentSignedPropertyNames as Sn, require_ms as Sr, findUpdatingComment as St, contentContainsMarkdownVideos as T, CommentUpdateForChallengeVerificationSignedPropertyNames as Tn, array as Tr, listUpdatingComments as Tt, isIpnsPath as U, AuthorCommentIpfsReservedFields as Un, CreateCommunityEditPublicationOptionsWithRefinementSchema as Ut, isIpfsPath as V, CreateCommentEditOptionsWithRefinementSchema as Vn, CommunityEditPublicationSignedPropertyNames as Vt, isLinkOfAnimatedImage as W, AuthorReservedFields as Wn, CommentModerationChallengeRequestToEncryptSchema as Wt, isRequestPubsubPublicationOfPost as X, CreateSignerSchema as Xn, ChallengeFileFactorySchema as Xt, isLinkValid as Y, CommunityAuthorChallengeReservedFieldNames as Yn, CreateCommentModerationOptionsWithRefinementSchema as Yt, isRequestPubsubPublicationOfReply as Z, n as Zn, ChallengeFileSchema as Zt, PKCUserOptionBaseSchema as _, CommentChallengeRequestToEncryptSchema as _n, FailedToFetchPageIpfsFromGatewaysError as _r, timestamp as _t, ChallengeRequestMessageSchema as a, CreateNewLocalCommunityUserOptionsSchema as an, r$2 as ar, removeNullUndefinedValues as at, areEquivalentCommunityAddresses as b, CommentPubsubMessageReservedFields as bn, logger_default as br, findCommunityInRegistry as bt, ChallengeVerificationMessageSignedPropertyNames as c, ExportCommunityModLogsOptionsSchema as cn, r$4 as cr, resolveWhenPredicateIsTrue as ct, DecryptedChallengeRequestSchema as d, CreateVoteUserOptionsWithRefinementSchema as dn, e$4 as dr, retryKuboIpfsAddAndProvide as dt, CommunityEditOptionsSchema as en, t$2 as er, pubsubTopicToDhtKeyCid as et, DecryptedChallengeSchema as f, VoteChallengeRequestToEncryptSchema as fn, require_retry as fr, shortifyAddress as ft, PKCParsedOptionsSchema as g, VoteTablesRowSchema as gn, FailedToFetchGenericIpfsFromGatewaysError as gr, throwIfAbortSignalAborted as gt, NameResolverSerializedSchema as h, VoteSignedPropertyNames as hn, FailedToFetchCommunityFromGatewaysError as hr, statMfsPathSafely as ht, ChallengeMessageSignedPropertyNames as i, CommunitySignedPropertyNames as in, t$4 as ir, removeNullUndefinedEmptyObjectsValuesRecursively as it, fetchAndValidateIpnsRecordFromGateway as j, CreateCommentOptionsWithRefinementSchema as jn, record as jr, trackUpdatingComment as jt, doesDomainAddressHaveCapitalLetter as k, CommentUpdateTableRowSchema as kn, number as kr, syncCommunityRegistryEntry as kt, DecryptedChallengeAnswerSchema as l, PubsubTopicSchema as ln, t$7 as lr, retryKuboBlockPutPinAndProvidePubsubTopic as lt, NameResolveCacheOptionsSchema as m, VotePubsubReservedFields as mn, FailedToFetchCommentUpdateFromGatewaysError as mr, sleepUntilTimeoutOrAbort as mt, ChallengeAnswerMessageSignedPropertyNames as n, CommunityIpfsReservedFields as nn, e as nr, removeBlocksFromKuboNode as nt, ChallengeRequestMessageSignedPropertyNames as o, CreateRemoteCommunityFunctionArgumentSchema as on, t$5 as or, removeUndefinedValuesRecursively as ot, DecryptedChallengeVerificationSchema as p, VotePubsubMessagePublicationSchema as pn, FailedToFetchCommentIpfsFromGatewaysError as pr, shortifyCid as pt, isLinkOfMedia as q, CidStringSchema as qn, CommentModerationSignedPropertyNames as qt, ChallengeMessageSchema as r, CommunityIpfsSchema as rn, e$2 as rr, removeMfsFilesSafely as rt, ChallengeVerificationMessageSchema as s, CreateRpcCommunityFunctionArgumentSchema as sn, n$7 as sr, replaceXWithY as st, ChallengeAnswerMessageSchema as t, CommunityExportRecordsSchema as tn, t$3 as tr, raceAgainstAbort as tt, DecryptedChallengeRequestPublicationSchema as u, RpcRemoteCommunityUpdateEventResultSchema as un, t$8 as ur, retryKuboIpfsAdd as ut, PKCUserOptionsSchema as v, CommentIpfsReservedFields as vn, PKCError as vr, waitForUpdateInCommunityInstanceWithErrorAndTimeout as vt, contentContainsMarkdownImages as w, CommentUpdateForChallengeVerificationSchema as wn, _enum as wr, listStartedCommunities as wt, calculateIpfsCidV0 as x, CommentPubsubMessageWithFlexibleAuthorRefinementSchema as xn, require_supports_color as xr, findStartedCommunity as xt, version_default as y, CommentIpfsSchema as yn, messages as yr, writeKuboFilesWithTimeout as yt, isAbortError as z, CommentEditSignedPropertyNames as zn, CommunityEditPublicationChallengeRequestToEncryptSchema as zt };
|
|
@@ -1,156 +1,16 @@
|
|
|
1
1
|
import { i as __toESM, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
+
import { n as batch, t as parallelBatch } from "./src-DKntVmyX.js";
|
|
2
3
|
import { i as first, n as src_exports, r as prepare, t as encode } from "./src-BOzgM7Fp.js";
|
|
3
4
|
import { CID } from "multiformats/cid";
|
|
4
5
|
import { fromString } from "uint8arrays/from-string";
|
|
5
6
|
import { concat } from "uint8arrays/concat";
|
|
6
7
|
import { equals } from "uint8arrays/equals";
|
|
8
|
+
import * as raw from "multiformats/codecs/raw";
|
|
7
9
|
import { alloc, allocUnsafe } from "uint8arrays/alloc";
|
|
8
10
|
import { withArrayBuffer } from "uint8arrays/with-array-buffer";
|
|
9
|
-
import * as raw from "multiformats/codecs/raw";
|
|
10
11
|
import { sha256 } from "multiformats/hashes/sha2";
|
|
11
12
|
import { murmur3128 } from "@multiformats/murmur3";
|
|
12
13
|
import { BlackHoleBlockstore } from "blockstore-core/black-hole";
|
|
13
|
-
//#region node_modules/it-batch/dist/src/index.js
|
|
14
|
-
/**
|
|
15
|
-
* @packageDocumentation
|
|
16
|
-
*
|
|
17
|
-
* The final batch may be smaller than the max.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
*
|
|
21
|
-
* ```javascript
|
|
22
|
-
* import batch from 'it-batch'
|
|
23
|
-
* import all from 'it-all'
|
|
24
|
-
*
|
|
25
|
-
* // This can also be an iterator, generator, etc
|
|
26
|
-
* const values = [0, 1, 2, 3, 4]
|
|
27
|
-
* const batchSize = 2
|
|
28
|
-
*
|
|
29
|
-
* const result = all(batch(values, batchSize))
|
|
30
|
-
*
|
|
31
|
-
* console.info(result) // [0, 1], [2, 3], [4]
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* Async sources must be awaited:
|
|
35
|
-
*
|
|
36
|
-
* ```javascript
|
|
37
|
-
* import batch from 'it-batch'
|
|
38
|
-
* import all from 'it-all'
|
|
39
|
-
*
|
|
40
|
-
* const values = async function * () {
|
|
41
|
-
* yield * [0, 1, 2, 3, 4]
|
|
42
|
-
* }
|
|
43
|
-
*
|
|
44
|
-
* const batchSize = 2
|
|
45
|
-
* const result = await all(batch(values(), batchSize))
|
|
46
|
-
*
|
|
47
|
-
* console.info(result) // [0, 1], [2, 3], [4]
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
function isAsyncIterable$1(thing) {
|
|
51
|
-
return thing[Symbol.asyncIterator] != null;
|
|
52
|
-
}
|
|
53
|
-
function batch(source, size = 1) {
|
|
54
|
-
size = Number(size);
|
|
55
|
-
if (isAsyncIterable$1(source)) return async function* () {
|
|
56
|
-
let things = [];
|
|
57
|
-
if (size < 1) size = 1;
|
|
58
|
-
if (size !== Math.round(size)) throw new Error("Batch size must be an integer");
|
|
59
|
-
for await (const thing of source) {
|
|
60
|
-
things.push(thing);
|
|
61
|
-
while (things.length >= size) {
|
|
62
|
-
yield things.slice(0, size);
|
|
63
|
-
things = things.slice(size);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
while (things.length > 0) {
|
|
67
|
-
yield things.slice(0, size);
|
|
68
|
-
things = things.slice(size);
|
|
69
|
-
}
|
|
70
|
-
}();
|
|
71
|
-
return function* () {
|
|
72
|
-
let things = [];
|
|
73
|
-
if (size < 1) size = 1;
|
|
74
|
-
if (size !== Math.round(size)) throw new Error("Batch size must be an integer");
|
|
75
|
-
for (const thing of source) {
|
|
76
|
-
things.push(thing);
|
|
77
|
-
while (things.length >= size) {
|
|
78
|
-
yield things.slice(0, size);
|
|
79
|
-
things = things.slice(size);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
while (things.length > 0) {
|
|
83
|
-
yield things.slice(0, size);
|
|
84
|
-
things = things.slice(size);
|
|
85
|
-
}
|
|
86
|
-
}();
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region node_modules/it-parallel-batch/dist/src/index.js
|
|
90
|
-
/**
|
|
91
|
-
* @packageDocumentation
|
|
92
|
-
*
|
|
93
|
-
* Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results in the same order as the input.
|
|
94
|
-
*
|
|
95
|
-
* The final batch may be smaller than the batch size.
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
*
|
|
99
|
-
* ```javascript
|
|
100
|
-
* import parallelBatch from 'it-parallel-batch'
|
|
101
|
-
* import all from 'it-all'
|
|
102
|
-
* import delay from 'delay'
|
|
103
|
-
*
|
|
104
|
-
* // This can also be an iterator, async iterator, generator, etc
|
|
105
|
-
* const input = [
|
|
106
|
-
* async () => {
|
|
107
|
-
* await delay(500)
|
|
108
|
-
*
|
|
109
|
-
* return 1
|
|
110
|
-
* },
|
|
111
|
-
* async () => {
|
|
112
|
-
* await delay(200)
|
|
113
|
-
*
|
|
114
|
-
* return 2
|
|
115
|
-
* },
|
|
116
|
-
* async () => {
|
|
117
|
-
* await delay(100)
|
|
118
|
-
*
|
|
119
|
-
* return 3
|
|
120
|
-
* }
|
|
121
|
-
* ]
|
|
122
|
-
*
|
|
123
|
-
* const batchSize = 2
|
|
124
|
-
*
|
|
125
|
-
* const result = await all(parallelBatch(input, batchSize))
|
|
126
|
-
*
|
|
127
|
-
* console.info(result) // [1, 2, 3]
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
/**
|
|
131
|
-
* Takes an (async) iterator that emits promise-returning functions,
|
|
132
|
-
* invokes them in parallel and emits the results as they become available but
|
|
133
|
-
* in the same order as the input
|
|
134
|
-
*/
|
|
135
|
-
async function* parallelBatch(source, size = 1) {
|
|
136
|
-
for await (const tasks of batch(source, size)) {
|
|
137
|
-
const things = tasks.map(async (p) => {
|
|
138
|
-
return p().then((value) => ({
|
|
139
|
-
ok: true,
|
|
140
|
-
value
|
|
141
|
-
}), (err) => ({
|
|
142
|
-
ok: false,
|
|
143
|
-
err
|
|
144
|
-
}));
|
|
145
|
-
});
|
|
146
|
-
for (let i = 0; i < things.length; i++) {
|
|
147
|
-
const result = await things[i];
|
|
148
|
-
if (result.ok) yield result.value;
|
|
149
|
-
else throw result.err;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
//#endregion
|
|
154
14
|
//#region node_modules/ipfs-unixfs-importer/node_modules/uint8arraylist/dist/src/index.js
|
|
155
15
|
/**
|
|
156
16
|
* @packageDocumentation
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
2
|
import { t as all } from "./src-CYIMjhjK.js";
|
|
3
|
+
import { n as peekable, t as map } from "./src-Cpx2Sts8.js";
|
|
3
4
|
import { i as first, n as src_exports$2 } from "./src-BOzgM7Fp.js";
|
|
4
5
|
import http from "node:http";
|
|
5
6
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
6
7
|
import { webcrypto } from "node:crypto";
|
|
7
8
|
import { CID } from "multiformats/cid";
|
|
8
|
-
import { toString } from "uint8arrays/to-string";
|
|
9
9
|
import { peerIdFromString } from "@libp2p/peer-id";
|
|
10
|
+
import { toString } from "uint8arrays/to-string";
|
|
10
11
|
import { publicKeyFromProtobuf } from "@libp2p/crypto/keys";
|
|
11
12
|
import { fromString } from "uint8arrays/from-string";
|
|
12
13
|
import { bases, codecs, hashes } from "multiformats/basics";
|
|
@@ -5831,7 +5832,7 @@ async function* browserReadableStreamToIt(stream, options = {}) {
|
|
|
5831
5832
|
}
|
|
5832
5833
|
}
|
|
5833
5834
|
//#endregion
|
|
5834
|
-
//#region node_modules/
|
|
5835
|
+
//#region node_modules/kubo-rpc-client/dist/src/lib/errors.js
|
|
5835
5836
|
var import_err_code = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5836
5837
|
/**
|
|
5837
5838
|
* @typedef {{ [key: string]: any }} Extensions
|
|
@@ -5879,132 +5880,6 @@ var import_err_code = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
5879
5880
|
}
|
|
5880
5881
|
module.exports = createError;
|
|
5881
5882
|
})))(), 1);
|
|
5882
|
-
/**
|
|
5883
|
-
* @packageDocumentation
|
|
5884
|
-
*
|
|
5885
|
-
* Lets you look at the contents of an async iterator and decide what to do
|
|
5886
|
-
*
|
|
5887
|
-
* @example
|
|
5888
|
-
*
|
|
5889
|
-
* ```javascript
|
|
5890
|
-
* import peekable from 'it-peekable'
|
|
5891
|
-
*
|
|
5892
|
-
* // This can also be an iterator, generator, etc
|
|
5893
|
-
* const values = [0, 1, 2, 3, 4]
|
|
5894
|
-
*
|
|
5895
|
-
* const it = peekable(value)
|
|
5896
|
-
*
|
|
5897
|
-
* const first = it.peek()
|
|
5898
|
-
*
|
|
5899
|
-
* console.info(first) // 0
|
|
5900
|
-
*
|
|
5901
|
-
* it.push(first)
|
|
5902
|
-
*
|
|
5903
|
-
* console.info([...it])
|
|
5904
|
-
* // [ 0, 1, 2, 3, 4 ]
|
|
5905
|
-
* ```
|
|
5906
|
-
*
|
|
5907
|
-
* Async sources must be awaited:
|
|
5908
|
-
*
|
|
5909
|
-
* ```javascript
|
|
5910
|
-
* import peekable from 'it-peekable'
|
|
5911
|
-
*
|
|
5912
|
-
* const values = async function * () {
|
|
5913
|
-
* yield * [0, 1, 2, 3, 4]
|
|
5914
|
-
* }
|
|
5915
|
-
*
|
|
5916
|
-
* const it = peekable(values())
|
|
5917
|
-
*
|
|
5918
|
-
* const first = await it.peek()
|
|
5919
|
-
*
|
|
5920
|
-
* console.info(first) // 0
|
|
5921
|
-
*
|
|
5922
|
-
* it.push(first)
|
|
5923
|
-
*
|
|
5924
|
-
* console.info(await all(it))
|
|
5925
|
-
* // [ 0, 1, 2, 3, 4 ]
|
|
5926
|
-
* ```
|
|
5927
|
-
*/
|
|
5928
|
-
function peekable(iterable) {
|
|
5929
|
-
const [iterator, symbol] = iterable[Symbol.asyncIterator] != null ? [iterable[Symbol.asyncIterator](), Symbol.asyncIterator] : [iterable[Symbol.iterator](), Symbol.iterator];
|
|
5930
|
-
const queue = [];
|
|
5931
|
-
return {
|
|
5932
|
-
peek: () => {
|
|
5933
|
-
return iterator.next();
|
|
5934
|
-
},
|
|
5935
|
-
push: (value) => {
|
|
5936
|
-
queue.push(value);
|
|
5937
|
-
},
|
|
5938
|
-
next: () => {
|
|
5939
|
-
if (queue.length > 0) return {
|
|
5940
|
-
done: false,
|
|
5941
|
-
value: queue.shift()
|
|
5942
|
-
};
|
|
5943
|
-
return iterator.next();
|
|
5944
|
-
},
|
|
5945
|
-
[symbol]() {
|
|
5946
|
-
return this;
|
|
5947
|
-
}
|
|
5948
|
-
};
|
|
5949
|
-
}
|
|
5950
|
-
//#endregion
|
|
5951
|
-
//#region node_modules/it-map/dist/src/index.js
|
|
5952
|
-
/**
|
|
5953
|
-
* @packageDocumentation
|
|
5954
|
-
*
|
|
5955
|
-
* Convert one value from an (async)iterator into another.
|
|
5956
|
-
*
|
|
5957
|
-
* @example
|
|
5958
|
-
*
|
|
5959
|
-
* ```javascript
|
|
5960
|
-
* import map from 'it-map'
|
|
5961
|
-
*
|
|
5962
|
-
* // This can also be an iterator, generator, etc
|
|
5963
|
-
* const values = [0, 1, 2, 3, 4]
|
|
5964
|
-
*
|
|
5965
|
-
* const result = map(values, (val, index) => val++)
|
|
5966
|
-
*
|
|
5967
|
-
* console.info(result) // [1, 2, 3, 4, 5]
|
|
5968
|
-
* ```
|
|
5969
|
-
*
|
|
5970
|
-
* Async sources and transforms must be awaited:
|
|
5971
|
-
*
|
|
5972
|
-
* ```javascript
|
|
5973
|
-
* import map from 'it-map'
|
|
5974
|
-
*
|
|
5975
|
-
* const values = async function * () {
|
|
5976
|
-
* yield * [0, 1, 2, 3, 4]
|
|
5977
|
-
* }
|
|
5978
|
-
*
|
|
5979
|
-
* const result = await map(values(), async (val, index) => val++)
|
|
5980
|
-
*
|
|
5981
|
-
* console.info(result) // [1, 2, 3, 4, 5]
|
|
5982
|
-
* ```
|
|
5983
|
-
*/
|
|
5984
|
-
function isAsyncIterable$3(thing) {
|
|
5985
|
-
return thing[Symbol.asyncIterator] != null;
|
|
5986
|
-
}
|
|
5987
|
-
function map(source, func) {
|
|
5988
|
-
let index = 0;
|
|
5989
|
-
if (isAsyncIterable$3(source)) return (async function* () {
|
|
5990
|
-
for await (const val of source) yield func(val, index++);
|
|
5991
|
-
})();
|
|
5992
|
-
const peekable$6 = peekable(source);
|
|
5993
|
-
const { value, done } = peekable$6.next();
|
|
5994
|
-
if (done === true) return function* () {}();
|
|
5995
|
-
const res = func(value, index++);
|
|
5996
|
-
if (typeof res.then === "function") return (async function* () {
|
|
5997
|
-
yield await res;
|
|
5998
|
-
for (const val of peekable$6) yield func(val, index++);
|
|
5999
|
-
})();
|
|
6000
|
-
const fn = func;
|
|
6001
|
-
return (function* () {
|
|
6002
|
-
yield res;
|
|
6003
|
-
for (const val of peekable$6) yield fn(val, index++);
|
|
6004
|
-
})();
|
|
6005
|
-
}
|
|
6006
|
-
//#endregion
|
|
6007
|
-
//#region node_modules/kubo-rpc-client/dist/src/lib/errors.js
|
|
6008
5883
|
var HTTPError$2 = class extends Error {
|
|
6009
5884
|
response;
|
|
6010
5885
|
constructor(response) {
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
//#region node_modules/it-peekable/dist/src/index.js
|
|
2
|
+
/**
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*
|
|
5
|
+
* Lets you look at the contents of an async iterator and decide what to do
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* ```javascript
|
|
10
|
+
* import peekable from 'it-peekable'
|
|
11
|
+
*
|
|
12
|
+
* // This can also be an iterator, generator, etc
|
|
13
|
+
* const values = [0, 1, 2, 3, 4]
|
|
14
|
+
*
|
|
15
|
+
* const it = peekable(value)
|
|
16
|
+
*
|
|
17
|
+
* const first = it.peek()
|
|
18
|
+
*
|
|
19
|
+
* console.info(first) // 0
|
|
20
|
+
*
|
|
21
|
+
* it.push(first)
|
|
22
|
+
*
|
|
23
|
+
* console.info([...it])
|
|
24
|
+
* // [ 0, 1, 2, 3, 4 ]
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Async sources must be awaited:
|
|
28
|
+
*
|
|
29
|
+
* ```javascript
|
|
30
|
+
* import peekable from 'it-peekable'
|
|
31
|
+
*
|
|
32
|
+
* const values = async function * () {
|
|
33
|
+
* yield * [0, 1, 2, 3, 4]
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* const it = peekable(values())
|
|
37
|
+
*
|
|
38
|
+
* const first = await it.peek()
|
|
39
|
+
*
|
|
40
|
+
* console.info(first) // 0
|
|
41
|
+
*
|
|
42
|
+
* it.push(first)
|
|
43
|
+
*
|
|
44
|
+
* console.info(await all(it))
|
|
45
|
+
* // [ 0, 1, 2, 3, 4 ]
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
function peekable(iterable) {
|
|
49
|
+
const [iterator, symbol] = iterable[Symbol.asyncIterator] != null ? [iterable[Symbol.asyncIterator](), Symbol.asyncIterator] : [iterable[Symbol.iterator](), Symbol.iterator];
|
|
50
|
+
const queue = [];
|
|
51
|
+
return {
|
|
52
|
+
peek: () => {
|
|
53
|
+
return iterator.next();
|
|
54
|
+
},
|
|
55
|
+
push: (value) => {
|
|
56
|
+
queue.push(value);
|
|
57
|
+
},
|
|
58
|
+
next: () => {
|
|
59
|
+
if (queue.length > 0) return {
|
|
60
|
+
done: false,
|
|
61
|
+
value: queue.shift()
|
|
62
|
+
};
|
|
63
|
+
return iterator.next();
|
|
64
|
+
},
|
|
65
|
+
[symbol]() {
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region node_modules/it-map/dist/src/index.js
|
|
72
|
+
/**
|
|
73
|
+
* @packageDocumentation
|
|
74
|
+
*
|
|
75
|
+
* Convert one value from an (async)iterator into another.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
*
|
|
79
|
+
* ```javascript
|
|
80
|
+
* import map from 'it-map'
|
|
81
|
+
*
|
|
82
|
+
* // This can also be an iterator, generator, etc
|
|
83
|
+
* const values = [0, 1, 2, 3, 4]
|
|
84
|
+
*
|
|
85
|
+
* const result = map(values, (val, index) => val++)
|
|
86
|
+
*
|
|
87
|
+
* console.info(result) // [1, 2, 3, 4, 5]
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* Async sources and transforms must be awaited:
|
|
91
|
+
*
|
|
92
|
+
* ```javascript
|
|
93
|
+
* import map from 'it-map'
|
|
94
|
+
*
|
|
95
|
+
* const values = async function * () {
|
|
96
|
+
* yield * [0, 1, 2, 3, 4]
|
|
97
|
+
* }
|
|
98
|
+
*
|
|
99
|
+
* const result = await map(values(), async (val, index) => val++)
|
|
100
|
+
*
|
|
101
|
+
* console.info(result) // [1, 2, 3, 4, 5]
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
function isAsyncIterable(thing) {
|
|
105
|
+
return thing[Symbol.asyncIterator] != null;
|
|
106
|
+
}
|
|
107
|
+
function map(source, func) {
|
|
108
|
+
let index = 0;
|
|
109
|
+
if (isAsyncIterable(source)) return (async function* () {
|
|
110
|
+
for await (const val of source) yield func(val, index++);
|
|
111
|
+
})();
|
|
112
|
+
const peekable$1 = peekable(source);
|
|
113
|
+
const { value, done } = peekable$1.next();
|
|
114
|
+
if (done === true) return function* () {}();
|
|
115
|
+
const res = func(value, index++);
|
|
116
|
+
if (typeof res.then === "function") return (async function* () {
|
|
117
|
+
yield await res;
|
|
118
|
+
for (const val of peekable$1) yield func(val, index++);
|
|
119
|
+
})();
|
|
120
|
+
const fn = func;
|
|
121
|
+
return (function* () {
|
|
122
|
+
yield res;
|
|
123
|
+
for (const val of peekable$1) yield fn(val, index++);
|
|
124
|
+
})();
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { peekable as n, map as t };
|