@blocklet/store 1.16.29-next-680cf137 → 1.16.30-beta-00e8bdd1
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/index.cjs +76 -6
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +72 -4
- package/package.json +13 -10
package/dist/index.cjs
CHANGED
|
@@ -7,13 +7,17 @@ const SealedBox = require('tweetnacl-sealedbox-js');
|
|
|
7
7
|
const ufo = require('ufo');
|
|
8
8
|
const axios = require('@abtnode/util/lib/axios');
|
|
9
9
|
const pWaitFor = require('p-wait-for');
|
|
10
|
-
const wallet = require('@ocap/wallet');
|
|
11
|
-
const util$1 = require('@blocklet/meta/lib/util');
|
|
12
|
-
const path = require('path');
|
|
13
|
-
const fs$1 = require('fs-extra');
|
|
14
10
|
const did = require('@arcblock/did');
|
|
15
11
|
const v2 = require('@blocklet/meta/lib/payment/v2');
|
|
12
|
+
const util$1 = require('@blocklet/meta/lib/util');
|
|
13
|
+
const utilMeta = require('@blocklet/meta/lib/util-meta');
|
|
14
|
+
const wallet = require('@ocap/wallet');
|
|
16
15
|
const FormData = require('form-data');
|
|
16
|
+
const fs$1 = require('fs-extra');
|
|
17
|
+
const yaml = require('js-yaml');
|
|
18
|
+
const pAll = require('p-all');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const createBlockletRelease = require('@abtnode/util/lib/create-blocklet-release');
|
|
17
21
|
const Client = require('@ocap/client');
|
|
18
22
|
const constant$1 = require('@abtnode/constant');
|
|
19
23
|
const constant = require('@blocklet/constant');
|
|
@@ -28,9 +32,11 @@ const tweetnacl__default = /*#__PURE__*/_interopDefaultCompat(tweetnacl);
|
|
|
28
32
|
const SealedBox__default = /*#__PURE__*/_interopDefaultCompat(SealedBox);
|
|
29
33
|
const axios__default = /*#__PURE__*/_interopDefaultCompat(axios);
|
|
30
34
|
const pWaitFor__default = /*#__PURE__*/_interopDefaultCompat(pWaitFor);
|
|
31
|
-
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
32
|
-
const fs__default$1 = /*#__PURE__*/_interopDefaultCompat(fs$1);
|
|
33
35
|
const FormData__default = /*#__PURE__*/_interopDefaultCompat(FormData);
|
|
36
|
+
const fs__default$1 = /*#__PURE__*/_interopDefaultCompat(fs$1);
|
|
37
|
+
const yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
|
|
38
|
+
const pAll__default = /*#__PURE__*/_interopDefaultCompat(pAll);
|
|
39
|
+
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
34
40
|
const Client__default = /*#__PURE__*/_interopDefaultCompat(Client);
|
|
35
41
|
const stableStringify__default = /*#__PURE__*/_interopDefaultCompat(stableStringify);
|
|
36
42
|
const xbytes__default = /*#__PURE__*/_interopDefaultCompat(xbytes);
|
|
@@ -155,6 +161,7 @@ async function createConnect({
|
|
|
155
161
|
source,
|
|
156
162
|
closeOnSuccess
|
|
157
163
|
});
|
|
164
|
+
console.log("If browser does not open automatically, please open the following link in your browser:", pageUrl);
|
|
158
165
|
openPage?.(pageUrl);
|
|
159
166
|
return await wrapSpinner(`Waiting for connection: ${connectUrl}`, async () => {
|
|
160
167
|
const fetchData = await fetchConfigs({
|
|
@@ -242,6 +249,17 @@ const ensureBlockletNftFactory = async ({
|
|
|
242
249
|
return itx.address;
|
|
243
250
|
};
|
|
244
251
|
|
|
252
|
+
function replaceOrigin(originalUrl, newUrl) {
|
|
253
|
+
try {
|
|
254
|
+
const originalUrlObj = new URL(originalUrl);
|
|
255
|
+
const newUrlObj = new URL(newUrl, originalUrlObj.origin);
|
|
256
|
+
return originalUrl.replace(originalUrlObj.origin, newUrlObj.origin);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.error("Invalid URL provided:", error);
|
|
259
|
+
return originalUrl;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
245
263
|
const sign = (blockletMeta, wallet) => {
|
|
246
264
|
const walletJSON = wallet.toJSON();
|
|
247
265
|
const signatureData = {
|
|
@@ -282,6 +300,7 @@ async function upload({
|
|
|
282
300
|
developerDid,
|
|
283
301
|
metaFile,
|
|
284
302
|
source,
|
|
303
|
+
possibleSameStore,
|
|
285
304
|
wrapSpinner = baseWrapSpinner,
|
|
286
305
|
printSuccess = () => {
|
|
287
306
|
},
|
|
@@ -294,6 +313,57 @@ async function upload({
|
|
|
294
313
|
throw new Error(`Invalid release meta file ${metaFile} not exists`);
|
|
295
314
|
}
|
|
296
315
|
const meta = fs__default$1.readJSONSync(metaFile);
|
|
316
|
+
const releaseReleaseDir = path__default.resolve(metaFile, "..", "..", "bundle");
|
|
317
|
+
if (possibleSameStore && meta.components) {
|
|
318
|
+
const parseSource = async (component) => {
|
|
319
|
+
try {
|
|
320
|
+
const nextComponent = { ...component };
|
|
321
|
+
if (nextComponent.source) {
|
|
322
|
+
nextComponent.source = { ...nextComponent.source };
|
|
323
|
+
if (nextComponent.source.url) {
|
|
324
|
+
nextComponent.source.url = replaceOrigin(nextComponent.source.url, storeUrl);
|
|
325
|
+
const res = await axios__default.get(nextComponent.source.url);
|
|
326
|
+
return res?.data?.did ? nextComponent : component;
|
|
327
|
+
}
|
|
328
|
+
nextComponent.source.store = storeUrl;
|
|
329
|
+
} else {
|
|
330
|
+
nextComponent.source = { name: component.name, store: storeUrl, version: "latest" };
|
|
331
|
+
}
|
|
332
|
+
const urls = utilMeta.getSourceUrlsFromConfig(nextComponent);
|
|
333
|
+
await utilMeta.getBlockletMetaFromUrls(urls, {
|
|
334
|
+
returnUrl: false,
|
|
335
|
+
validateFn: () => true,
|
|
336
|
+
ensureTarball: false
|
|
337
|
+
});
|
|
338
|
+
return nextComponent;
|
|
339
|
+
} catch (err) {
|
|
340
|
+
return component;
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
const events = meta.components.map((component) => {
|
|
344
|
+
return () => parseSource(component);
|
|
345
|
+
});
|
|
346
|
+
meta.components = await pAll__default(events, { concurrency: 4 });
|
|
347
|
+
const yamlFile = path__default.join(releaseReleaseDir, "blocklet.yml");
|
|
348
|
+
const metaYaml = yaml__default.load(fs__default$1.readFileSync(yamlFile).toString(), { json: true });
|
|
349
|
+
metaYaml.components = meta.components;
|
|
350
|
+
if (meta.engine && meta.engine?.source?.store) {
|
|
351
|
+
meta.engine = await parseSource({ ...meta.engine });
|
|
352
|
+
metaYaml.engine = meta.engine;
|
|
353
|
+
}
|
|
354
|
+
fs__default$1.writeFileSync(yamlFile, yaml__default.dump(metaYaml, { sortKeys: false, skipInvalid: true }));
|
|
355
|
+
const dir = path__default.resolve(metaFile, "..", "..");
|
|
356
|
+
const release = await createBlockletRelease.createRelease(dir, {
|
|
357
|
+
printError: (err) => {
|
|
358
|
+
throw err;
|
|
359
|
+
},
|
|
360
|
+
printInfo: () => {
|
|
361
|
+
},
|
|
362
|
+
tarball: meta.dist.tarball
|
|
363
|
+
});
|
|
364
|
+
meta.dist.integrity = release.meta.dist.integrity;
|
|
365
|
+
meta.dist.size = release.meta.dist.size;
|
|
366
|
+
}
|
|
297
367
|
if (meta.payment === void 0) {
|
|
298
368
|
const { charging } = meta;
|
|
299
369
|
const payment = {};
|
package/dist/index.d.cts
CHANGED
|
@@ -28,6 +28,7 @@ interface UploadOptions {
|
|
|
28
28
|
storeUrl: string;
|
|
29
29
|
accessToken: string;
|
|
30
30
|
developerDid: string;
|
|
31
|
+
possibleSameStore?: boolean;
|
|
31
32
|
metaFile: string;
|
|
32
33
|
source: string;
|
|
33
34
|
wrapSpinner?: typeof baseWrapSpinner;
|
|
@@ -35,6 +36,6 @@ interface UploadOptions {
|
|
|
35
36
|
printTar: (meta: unknown, metaPath: string) => Promise<void>;
|
|
36
37
|
debug: (...args: unknown[]) => void;
|
|
37
38
|
}
|
|
38
|
-
declare function upload({ storeUrl, accessToken, developerDid, metaFile, source, wrapSpinner, printSuccess, printTar, debug, }: UploadOptions): Promise<BlockletMeta | undefined>;
|
|
39
|
+
declare function upload({ storeUrl, accessToken, developerDid, metaFile, source, possibleSameStore, wrapSpinner, printSuccess, printTar, debug, }: UploadOptions): Promise<BlockletMeta | undefined>;
|
|
39
40
|
|
|
40
41
|
export { type UploadOptions, createConnect, upload };
|
package/dist/index.d.mts
CHANGED
|
@@ -28,6 +28,7 @@ interface UploadOptions {
|
|
|
28
28
|
storeUrl: string;
|
|
29
29
|
accessToken: string;
|
|
30
30
|
developerDid: string;
|
|
31
|
+
possibleSameStore?: boolean;
|
|
31
32
|
metaFile: string;
|
|
32
33
|
source: string;
|
|
33
34
|
wrapSpinner?: typeof baseWrapSpinner;
|
|
@@ -35,6 +36,6 @@ interface UploadOptions {
|
|
|
35
36
|
printTar: (meta: unknown, metaPath: string) => Promise<void>;
|
|
36
37
|
debug: (...args: unknown[]) => void;
|
|
37
38
|
}
|
|
38
|
-
declare function upload({ storeUrl, accessToken, developerDid, metaFile, source, wrapSpinner, printSuccess, printTar, debug, }: UploadOptions): Promise<BlockletMeta | undefined>;
|
|
39
|
+
declare function upload({ storeUrl, accessToken, developerDid, metaFile, source, possibleSameStore, wrapSpinner, printSuccess, printTar, debug, }: UploadOptions): Promise<BlockletMeta | undefined>;
|
|
39
40
|
|
|
40
41
|
export { type UploadOptions, createConnect, upload };
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ interface UploadOptions {
|
|
|
28
28
|
storeUrl: string;
|
|
29
29
|
accessToken: string;
|
|
30
30
|
developerDid: string;
|
|
31
|
+
possibleSameStore?: boolean;
|
|
31
32
|
metaFile: string;
|
|
32
33
|
source: string;
|
|
33
34
|
wrapSpinner?: typeof baseWrapSpinner;
|
|
@@ -35,6 +36,6 @@ interface UploadOptions {
|
|
|
35
36
|
printTar: (meta: unknown, metaPath: string) => Promise<void>;
|
|
36
37
|
debug: (...args: unknown[]) => void;
|
|
37
38
|
}
|
|
38
|
-
declare function upload({ storeUrl, accessToken, developerDid, metaFile, source, wrapSpinner, printSuccess, printTar, debug, }: UploadOptions): Promise<BlockletMeta | undefined>;
|
|
39
|
+
declare function upload({ storeUrl, accessToken, developerDid, metaFile, source, possibleSameStore, wrapSpinner, printSuccess, printTar, debug, }: UploadOptions): Promise<BlockletMeta | undefined>;
|
|
39
40
|
|
|
40
41
|
export { type UploadOptions, createConnect, upload };
|
package/dist/index.mjs
CHANGED
|
@@ -5,13 +5,17 @@ import SealedBox from 'tweetnacl-sealedbox-js';
|
|
|
5
5
|
import { withQuery, joinURL } from 'ufo';
|
|
6
6
|
import axios from '@abtnode/util/lib/axios';
|
|
7
7
|
import pWaitFor from 'p-wait-for';
|
|
8
|
-
import { fromSecretKey } from '@ocap/wallet';
|
|
9
|
-
import { isFreeBlocklet } from '@blocklet/meta/lib/util';
|
|
10
|
-
import path from 'path';
|
|
11
|
-
import fs$1 from 'fs-extra';
|
|
12
8
|
import { isValid, toTypeInfo, types } from '@arcblock/did';
|
|
13
9
|
import { createNftFactoryItx, checkFreeBlocklet } from '@blocklet/meta/lib/payment/v2';
|
|
10
|
+
import { isFreeBlocklet } from '@blocklet/meta/lib/util';
|
|
11
|
+
import { getSourceUrlsFromConfig, getBlockletMetaFromUrls } from '@blocklet/meta/lib/util-meta';
|
|
12
|
+
import { fromSecretKey } from '@ocap/wallet';
|
|
14
13
|
import FormData from 'form-data';
|
|
14
|
+
import fs$1 from 'fs-extra';
|
|
15
|
+
import yaml from 'js-yaml';
|
|
16
|
+
import pAll from 'p-all';
|
|
17
|
+
import path from 'path';
|
|
18
|
+
import { createRelease } from '@abtnode/util/lib/create-blocklet-release';
|
|
15
19
|
import Client from '@ocap/client';
|
|
16
20
|
import { BLOCKLET_STORE_META_PATH } from '@abtnode/constant';
|
|
17
21
|
import { BLOCKLET_FACTORY_SHARES } from '@blocklet/constant';
|
|
@@ -139,6 +143,7 @@ async function createConnect({
|
|
|
139
143
|
source,
|
|
140
144
|
closeOnSuccess
|
|
141
145
|
});
|
|
146
|
+
console.log("If browser does not open automatically, please open the following link in your browser:", pageUrl);
|
|
142
147
|
openPage?.(pageUrl);
|
|
143
148
|
return await wrapSpinner(`Waiting for connection: ${connectUrl}`, async () => {
|
|
144
149
|
const fetchData = await fetchConfigs({
|
|
@@ -226,6 +231,17 @@ const ensureBlockletNftFactory = async ({
|
|
|
226
231
|
return itx.address;
|
|
227
232
|
};
|
|
228
233
|
|
|
234
|
+
function replaceOrigin(originalUrl, newUrl) {
|
|
235
|
+
try {
|
|
236
|
+
const originalUrlObj = new URL(originalUrl);
|
|
237
|
+
const newUrlObj = new URL(newUrl, originalUrlObj.origin);
|
|
238
|
+
return originalUrl.replace(originalUrlObj.origin, newUrlObj.origin);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
console.error("Invalid URL provided:", error);
|
|
241
|
+
return originalUrl;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
229
245
|
const sign = (blockletMeta, wallet) => {
|
|
230
246
|
const walletJSON = wallet.toJSON();
|
|
231
247
|
const signatureData = {
|
|
@@ -266,6 +282,7 @@ async function upload({
|
|
|
266
282
|
developerDid,
|
|
267
283
|
metaFile,
|
|
268
284
|
source,
|
|
285
|
+
possibleSameStore,
|
|
269
286
|
wrapSpinner = baseWrapSpinner,
|
|
270
287
|
printSuccess = () => {
|
|
271
288
|
},
|
|
@@ -278,6 +295,57 @@ async function upload({
|
|
|
278
295
|
throw new Error(`Invalid release meta file ${metaFile} not exists`);
|
|
279
296
|
}
|
|
280
297
|
const meta = fs$1.readJSONSync(metaFile);
|
|
298
|
+
const releaseReleaseDir = path.resolve(metaFile, "..", "..", "bundle");
|
|
299
|
+
if (possibleSameStore && meta.components) {
|
|
300
|
+
const parseSource = async (component) => {
|
|
301
|
+
try {
|
|
302
|
+
const nextComponent = { ...component };
|
|
303
|
+
if (nextComponent.source) {
|
|
304
|
+
nextComponent.source = { ...nextComponent.source };
|
|
305
|
+
if (nextComponent.source.url) {
|
|
306
|
+
nextComponent.source.url = replaceOrigin(nextComponent.source.url, storeUrl);
|
|
307
|
+
const res = await axios.get(nextComponent.source.url);
|
|
308
|
+
return res?.data?.did ? nextComponent : component;
|
|
309
|
+
}
|
|
310
|
+
nextComponent.source.store = storeUrl;
|
|
311
|
+
} else {
|
|
312
|
+
nextComponent.source = { name: component.name, store: storeUrl, version: "latest" };
|
|
313
|
+
}
|
|
314
|
+
const urls = getSourceUrlsFromConfig(nextComponent);
|
|
315
|
+
await getBlockletMetaFromUrls(urls, {
|
|
316
|
+
returnUrl: false,
|
|
317
|
+
validateFn: () => true,
|
|
318
|
+
ensureTarball: false
|
|
319
|
+
});
|
|
320
|
+
return nextComponent;
|
|
321
|
+
} catch (err) {
|
|
322
|
+
return component;
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
const events = meta.components.map((component) => {
|
|
326
|
+
return () => parseSource(component);
|
|
327
|
+
});
|
|
328
|
+
meta.components = await pAll(events, { concurrency: 4 });
|
|
329
|
+
const yamlFile = path.join(releaseReleaseDir, "blocklet.yml");
|
|
330
|
+
const metaYaml = yaml.load(fs$1.readFileSync(yamlFile).toString(), { json: true });
|
|
331
|
+
metaYaml.components = meta.components;
|
|
332
|
+
if (meta.engine && meta.engine?.source?.store) {
|
|
333
|
+
meta.engine = await parseSource({ ...meta.engine });
|
|
334
|
+
metaYaml.engine = meta.engine;
|
|
335
|
+
}
|
|
336
|
+
fs$1.writeFileSync(yamlFile, yaml.dump(metaYaml, { sortKeys: false, skipInvalid: true }));
|
|
337
|
+
const dir = path.resolve(metaFile, "..", "..");
|
|
338
|
+
const release = await createRelease(dir, {
|
|
339
|
+
printError: (err) => {
|
|
340
|
+
throw err;
|
|
341
|
+
},
|
|
342
|
+
printInfo: () => {
|
|
343
|
+
},
|
|
344
|
+
tarball: meta.dist.tarball
|
|
345
|
+
});
|
|
346
|
+
meta.dist.integrity = release.meta.dist.integrity;
|
|
347
|
+
meta.dist.size = release.meta.dist.size;
|
|
348
|
+
}
|
|
281
349
|
if (meta.payment === void 0) {
|
|
282
350
|
const { charging } = meta;
|
|
283
351
|
const payment = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/store",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.30-beta-00e8bdd1",
|
|
4
4
|
"description": "Connect Store and upload blocklet to Store",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -27,18 +27,20 @@
|
|
|
27
27
|
"author": "",
|
|
28
28
|
"license": "ISC",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@abtnode/constant": "1.16.
|
|
31
|
-
"@abtnode/util": "1.16.
|
|
32
|
-
"@arcblock/did": "1.18.
|
|
33
|
-
"@blocklet/constant": "1.16.
|
|
34
|
-
"@blocklet/meta": "1.16.
|
|
35
|
-
"@ocap/client": "^1.18.
|
|
36
|
-
"@ocap/util": "1.18.
|
|
37
|
-
"@ocap/wallet": "1.18.
|
|
30
|
+
"@abtnode/constant": "1.16.30-beta-00e8bdd1",
|
|
31
|
+
"@abtnode/util": "1.16.30-beta-00e8bdd1",
|
|
32
|
+
"@arcblock/did": "1.18.128",
|
|
33
|
+
"@blocklet/constant": "1.16.30-beta-00e8bdd1",
|
|
34
|
+
"@blocklet/meta": "1.16.30-beta-00e8bdd1",
|
|
35
|
+
"@ocap/client": "^1.18.128",
|
|
36
|
+
"@ocap/util": "1.18.128",
|
|
37
|
+
"@ocap/wallet": "1.18.128",
|
|
38
38
|
"form-data": "^4.0.0",
|
|
39
39
|
"fs-extra": "^11.2.0",
|
|
40
|
+
"js-yaml": "^4.1.0",
|
|
40
41
|
"json-stable-stringify": "^1.0.1",
|
|
41
42
|
"lodash": "^4.17.21",
|
|
43
|
+
"p-all": "3.0.0",
|
|
42
44
|
"p-wait-for": "3.2.0",
|
|
43
45
|
"tweetnacl": "^1.0.3",
|
|
44
46
|
"tweetnacl-sealedbox-js": "^1.2.0",
|
|
@@ -48,6 +50,7 @@
|
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"@arcblock/eslint-config-ts": "^0.3.2",
|
|
50
52
|
"@types/jest": "^29.5.11",
|
|
53
|
+
"@types/js-yaml": "^4.0.5",
|
|
51
54
|
"@types/node": "^18.11.0",
|
|
52
55
|
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
|
53
56
|
"@typescript-eslint/parser": "^5.40.1",
|
|
@@ -59,5 +62,5 @@
|
|
|
59
62
|
"typescript": "^5.0.4",
|
|
60
63
|
"unbuild": "^2.0.0"
|
|
61
64
|
},
|
|
62
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "e165c7e64a2900b4c390b7435c0bb71abbf9b625"
|
|
63
66
|
}
|