vite-plugin-blocklet 0.6.1 → 0.6.3
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 +11 -5
- package/index.js +2 -1
- package/libs/config.js +5 -4
- package/libs/utils.js +5 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,10 @@ var mri__default = /*#__PURE__*/_interopDefaultLegacy(mri);
|
|
|
27
27
|
const { types } = Mcrypto__default["default"];
|
|
28
28
|
|
|
29
29
|
function toBlockletDid(name) {
|
|
30
|
+
if (did.isValid(name)) {
|
|
31
|
+
return name;
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
const pk = util.toHex(Buffer.from(typeof name === 'string' ? name.trim() : name));
|
|
31
35
|
return did.fromPublicKey(pk, { role: types.RoleType.ROLE_ANY });
|
|
32
36
|
}
|
|
@@ -99,11 +103,12 @@ function createConfigPlugin() {
|
|
|
99
103
|
try {
|
|
100
104
|
const blockletYamlPath = './blocklet.yml';
|
|
101
105
|
const blockletYaml = YAML__default["default"].parse(fs__default["default"].readFileSync(blockletYamlPath, 'utf8'));
|
|
102
|
-
|
|
103
|
-
if (name) {
|
|
104
|
-
|
|
106
|
+
let { name, did } = blockletYaml;
|
|
107
|
+
if (!did && name) {
|
|
108
|
+
did = toBlockletDid(name);
|
|
109
|
+
}
|
|
110
|
+
if (did) {
|
|
105
111
|
const base = `/.blocklet/proxy/${did}/`;
|
|
106
|
-
|
|
107
112
|
return {
|
|
108
113
|
base,
|
|
109
114
|
};
|
|
@@ -187,7 +192,8 @@ async function setupClient(app, options = {}) {
|
|
|
187
192
|
function createBlockletPlugin(options = {}) {
|
|
188
193
|
const {
|
|
189
194
|
// NOTICE: 由于 polyfill 不是每个项目都必须的,并且有些现有的项目已经配置了 polyfill,所以这个配置默认 disable 会比较好
|
|
190
|
-
|
|
195
|
+
// UPDATE: 经过实践,大部分项目都需要此配置,现变更为默认开启 @2023-04-25
|
|
196
|
+
disableNodePolyfills = false,
|
|
191
197
|
disableConfig = false,
|
|
192
198
|
disableMeta = false,
|
|
193
199
|
disableHmr = false,
|
package/index.js
CHANGED
|
@@ -7,7 +7,8 @@ import setupClient from './libs/client.js';
|
|
|
7
7
|
export function createBlockletPlugin(options = {}) {
|
|
8
8
|
const {
|
|
9
9
|
// NOTICE: 由于 polyfill 不是每个项目都必须的,并且有些现有的项目已经配置了 polyfill,所以这个配置默认 disable 会比较好
|
|
10
|
-
|
|
10
|
+
// UPDATE: 经过实践,大部分项目都需要此配置,现变更为默认开启 @2023-04-25
|
|
11
|
+
disableNodePolyfills = false,
|
|
11
12
|
disableConfig = false,
|
|
12
13
|
disableMeta = false,
|
|
13
14
|
disableHmr = false,
|
package/libs/config.js
CHANGED
|
@@ -48,11 +48,12 @@ export default function createConfigPlugin() {
|
|
|
48
48
|
try {
|
|
49
49
|
const blockletYamlPath = './blocklet.yml';
|
|
50
50
|
const blockletYaml = YAML.parse(fs.readFileSync(blockletYamlPath, 'utf8'));
|
|
51
|
-
|
|
52
|
-
if (name) {
|
|
53
|
-
|
|
51
|
+
let { name, did } = blockletYaml;
|
|
52
|
+
if (!did && name) {
|
|
53
|
+
did = toBlockletDid(name);
|
|
54
|
+
}
|
|
55
|
+
if (did) {
|
|
54
56
|
const base = `/.blocklet/proxy/${did}/`;
|
|
55
|
-
|
|
56
57
|
return {
|
|
57
58
|
base,
|
|
58
59
|
};
|
package/libs/utils.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import Mcrypto from '@ocap/mcrypto';
|
|
2
2
|
import { toHex } from '@ocap/util';
|
|
3
|
-
import { fromPublicKey } from '@arcblock/did';
|
|
3
|
+
import { fromPublicKey, isValid } from '@arcblock/did';
|
|
4
4
|
|
|
5
5
|
const { types } = Mcrypto;
|
|
6
6
|
|
|
7
7
|
export function toBlockletDid(name) {
|
|
8
|
+
if (isValid(name)) {
|
|
9
|
+
return name;
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
const pk = toHex(Buffer.from(typeof name === 'string' ? name.trim() : name));
|
|
9
13
|
return fromPublicKey(pk, { role: types.RoleType.ROLE_ANY });
|
|
10
14
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-blocklet",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.3",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"rollup": "^2.79.1"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@arcblock/did": "^1.18.
|
|
31
|
-
"@ocap/mcrypto": "^1.18.
|
|
32
|
-
"@ocap/util": "^1.18.
|
|
30
|
+
"@arcblock/did": "^1.18.78",
|
|
31
|
+
"@ocap/mcrypto": "^1.18.78",
|
|
32
|
+
"@ocap/util": "^1.18.78",
|
|
33
33
|
"get-port": "^5.1.1",
|
|
34
34
|
"mri": "^1.2.0",
|
|
35
|
-
"semver": "^7.
|
|
35
|
+
"semver": "^7.5.0",
|
|
36
36
|
"vite-plugin-node-polyfills": "^0.7.0",
|
|
37
|
-
"yaml": "^2.2.
|
|
37
|
+
"yaml": "^2.2.2"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"vite": ">=2"
|