vite-plugin-blocklet 0.12.4 → 0.13.0
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 +112 -42
- package/index.js +18 -11
- package/libs/loading.js +94 -31
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -254,25 +254,19 @@ function createMetaPlugin() {
|
|
|
254
254
|
* @param {Object} options - The options for generating the HTML.
|
|
255
255
|
* @param {string} options.color - The color of the spinner. Defaults to "#333".
|
|
256
256
|
* @param {string} options.image - The URL of the image to display alongside the spinner.
|
|
257
|
+
* @param {boolean} [options.showDots=true] - Whether to show the loading dots animation.
|
|
258
|
+
* @param {boolean} options.showPoweredBy - Whether to show the "Powered by" text.
|
|
259
|
+
* @param {string} [options.poweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
257
260
|
* @return {string} The generated HTML string.
|
|
258
261
|
*/
|
|
259
|
-
function generateHtml({ color, image }) {
|
|
262
|
+
function generateHtml({ color, image, showDots = true, showPoweredBy, poweredByText = 'Powered by ArcBlock' }) {
|
|
260
263
|
return `<style>
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
flex-direction: column;
|
|
268
|
-
justify-content: center;
|
|
269
|
-
align-items: center;
|
|
270
|
-
margin: 0;
|
|
271
|
-
padding: 0;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
.spinner-wrapper {
|
|
275
|
-
width: 70px;
|
|
264
|
+
#loadingSpinnerWrapper {
|
|
265
|
+
position: fixed;
|
|
266
|
+
top: 0;
|
|
267
|
+
left: 0;
|
|
268
|
+
right: 0;
|
|
269
|
+
bottom: 0;
|
|
276
270
|
opacity: 0;
|
|
277
271
|
animation-name: fadeIn;
|
|
278
272
|
animation-duration: 500ms;
|
|
@@ -286,14 +280,18 @@ function generateHtml({ color, image }) {
|
|
|
286
280
|
align-items: center;
|
|
287
281
|
}
|
|
288
282
|
|
|
289
|
-
.spinner {
|
|
283
|
+
#loadingSpinnerWrapper .spinner {
|
|
290
284
|
width: 70px;
|
|
291
285
|
text-align: center;
|
|
286
|
+
margin-top: 16px;
|
|
292
287
|
}
|
|
293
288
|
|
|
294
|
-
.spinner
|
|
289
|
+
#loadingSpinnerWrapper .spinner>.bounce1,
|
|
290
|
+
#loadingSpinnerWrapper .spinner>.bounce2,
|
|
291
|
+
#loadingSpinnerWrapper .spinner>.bounce3 {
|
|
295
292
|
width: 18px;
|
|
296
293
|
height: 18px;
|
|
294
|
+
|
|
297
295
|
background-color: ${color};
|
|
298
296
|
|
|
299
297
|
border-radius: 100%;
|
|
@@ -302,26 +300,57 @@ function generateHtml({ color, image }) {
|
|
|
302
300
|
animation: sk-bouncedelay 1.4s infinite ease-in-out both;
|
|
303
301
|
}
|
|
304
302
|
|
|
305
|
-
.spinner .bounce1 {
|
|
303
|
+
#loadingSpinnerWrapper .spinner .bounce1 {
|
|
306
304
|
-webkit-animation-delay: -0.32s;
|
|
307
305
|
animation-delay: -0.32s;
|
|
308
306
|
}
|
|
309
307
|
|
|
310
|
-
.spinner .bounce2 {
|
|
308
|
+
#loadingSpinnerWrapper .spinner .bounce2 {
|
|
311
309
|
-webkit-animation-delay: -0.16s;
|
|
312
310
|
animation-delay: -0.16s;
|
|
313
311
|
}
|
|
312
|
+
|
|
313
|
+
#loadingImageWrapper {
|
|
314
|
+
width: 70px;
|
|
315
|
+
height: 70px;
|
|
316
|
+
display: flex;
|
|
317
|
+
justify-content: center;
|
|
318
|
+
align-items: center;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
#loadingImageWrapper.loading-image {
|
|
322
|
+
border-radius: 4px;
|
|
323
|
+
background-color: oklch(87.2% 0.01 258.338);
|
|
324
|
+
animation: 2s ease-in-out 0.5s infinite none running skeleton;
|
|
325
|
+
}
|
|
326
|
+
|
|
314
327
|
#loadingImage {
|
|
315
|
-
|
|
328
|
+
display: inline-block;
|
|
329
|
+
width: 100%;
|
|
330
|
+
height: 100%;
|
|
316
331
|
object-fit: contain;
|
|
317
332
|
}
|
|
318
333
|
|
|
334
|
+
|
|
335
|
+
@-webkit-keyframes skeleton {
|
|
336
|
+
0% { opacity: 0.6; }
|
|
337
|
+
50% { opacity: 0.4; }
|
|
338
|
+
100% { opacity: 0.6; }
|
|
339
|
+
}
|
|
340
|
+
@keyframes skeleton {
|
|
341
|
+
0% { opacity: 0.6; }
|
|
342
|
+
50% { opacity: 0.4; }
|
|
343
|
+
100% { opacity: 0.6; }
|
|
344
|
+
}
|
|
345
|
+
|
|
319
346
|
@-webkit-keyframes fadeIn {
|
|
320
347
|
0% { opacity: 0; }
|
|
348
|
+
50% { opacity: 0.4; }
|
|
321
349
|
100% { opacity: 1; }
|
|
322
350
|
}
|
|
323
351
|
@keyframes fadeIn {
|
|
324
352
|
0% { opacity: 0; }
|
|
353
|
+
50% { opacity: 0.4; }
|
|
325
354
|
100% { opacity: 1; }
|
|
326
355
|
}
|
|
327
356
|
|
|
@@ -348,21 +377,36 @@ function generateHtml({ color, image }) {
|
|
|
348
377
|
transform: scale(1);
|
|
349
378
|
}
|
|
350
379
|
}
|
|
380
|
+
|
|
381
|
+
#loadingPoweredBy {
|
|
382
|
+
position: fixed;
|
|
383
|
+
color: oklch(70.7% 0.022 261.325);
|
|
384
|
+
bottom: 16px;
|
|
385
|
+
left: 0;
|
|
386
|
+
right: 0;
|
|
387
|
+
text-align: center;
|
|
388
|
+
opacity: ${showPoweredBy ? 1 : 0.01};
|
|
389
|
+
}
|
|
390
|
+
|
|
351
391
|
</style>
|
|
352
|
-
<div
|
|
353
|
-
<
|
|
354
|
-
|
|
392
|
+
<div id="loadingSpinnerWrapper">
|
|
393
|
+
<div id="loadingImageWrapper" class="loading-image"></div>
|
|
394
|
+
${
|
|
395
|
+
showDots
|
|
396
|
+
? `<div class="spinner">
|
|
355
397
|
<div class="bounce1"></div>
|
|
356
398
|
<div class="bounce2"></div>
|
|
357
399
|
<div class="bounce3"></div>
|
|
358
|
-
</div
|
|
400
|
+
</div>`
|
|
401
|
+
: ''
|
|
402
|
+
}
|
|
359
403
|
</div>
|
|
404
|
+
<div id="loadingPoweredBy">${poweredByText}</div>
|
|
360
405
|
<script>
|
|
361
406
|
(() => {
|
|
362
|
-
const loadingImage = document.getElementById('loadingImage');
|
|
363
407
|
const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
|
|
364
|
-
|
|
365
|
-
let logo = "${image}";
|
|
408
|
+
|
|
409
|
+
let logo = "${image}";
|
|
366
410
|
|
|
367
411
|
if (window?.blocklet) {
|
|
368
412
|
const { appLogo, appLogoDark } = window.blocklet;
|
|
@@ -370,8 +414,14 @@ function generateHtml({ color, image }) {
|
|
|
370
414
|
logo = isDark && appLogoDark ? appLogoDark : appLogo;
|
|
371
415
|
}
|
|
372
416
|
}
|
|
373
|
-
|
|
374
|
-
|
|
417
|
+
const img = document.createElement('img');
|
|
418
|
+
img.id = 'loadingImage';
|
|
419
|
+
img.src = logo;
|
|
420
|
+
img.onload = () => {
|
|
421
|
+
const loadingImageWrapper = document.getElementById('loadingImageWrapper');
|
|
422
|
+
loadingImageWrapper.appendChild(img);
|
|
423
|
+
loadingImageWrapper.classList.remove('loading-image');
|
|
424
|
+
};
|
|
375
425
|
})();
|
|
376
426
|
</script>`;
|
|
377
427
|
}
|
|
@@ -383,9 +433,19 @@ function generateHtml({ color, image }) {
|
|
|
383
433
|
* @param {string} [options.loadingElementId='app'] - The ID of the loading element.
|
|
384
434
|
* @param {string} [options.loadingColor='#8abaf0'] - The color of the loading animation.
|
|
385
435
|
* @param {string} [options.loadingImage='/.well-known/service/blocklet/logo?imageFilter=convert&f=png&w=80'] - The URL of the loading image.
|
|
436
|
+
* @param {boolean} [options.loadingShowDots=true] - Whether to show the loading dots animation.
|
|
437
|
+
* @param {boolean} [options.loadingShowPoweredBy=true] - Whether to show the "Powered by" text.
|
|
438
|
+
* @param {string} [options.loadingPoweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
386
439
|
* @return {Object} - The Vite plugin object.
|
|
387
440
|
*/
|
|
388
|
-
function createLoadingPlugin({
|
|
441
|
+
function createLoadingPlugin({
|
|
442
|
+
loadingElementId = 'app',
|
|
443
|
+
loadingColor = '#8abaf0',
|
|
444
|
+
loadingImage,
|
|
445
|
+
loadingShowDots = true,
|
|
446
|
+
loadingShowPoweredBy = true,
|
|
447
|
+
loadingPoweredByText = 'Powered by ArcBlock',
|
|
448
|
+
} = {}) {
|
|
389
449
|
if (!loadingImage) {
|
|
390
450
|
loadingImage = ufo.withQuery('/.well-known/service/blocklet/logo', {
|
|
391
451
|
imageFilter: 'convert',
|
|
@@ -396,6 +456,9 @@ function createLoadingPlugin({ loadingElementId = 'app', loadingColor = '#8abaf0
|
|
|
396
456
|
const injectHtml = generateHtml({
|
|
397
457
|
color: loadingColor,
|
|
398
458
|
image: loadingImage,
|
|
459
|
+
showDots: loadingShowDots,
|
|
460
|
+
showPoweredBy: loadingShowPoweredBy,
|
|
461
|
+
poweredByText: loadingPoweredByText,
|
|
399
462
|
});
|
|
400
463
|
|
|
401
464
|
return {
|
|
@@ -843,19 +906,26 @@ async function setupClient(app, options = {}) {
|
|
|
843
906
|
* @property {boolean} [disableLoading=false] - Disable loading plugin.
|
|
844
907
|
* @property {boolean} [disableDebug=false] - Disable debug plugin.
|
|
845
908
|
* @property {boolean} [disableEmbed=false] - Disable embed plugin.
|
|
909
|
+
*
|
|
846
910
|
* @property {import('vite-plugin-node-polyfills').PolyfillOptions} [nodePolyfillsOptions]
|
|
847
911
|
*
|
|
848
|
-
* @property {string} [loadingElementId]
|
|
849
|
-
* @property {string} [loadingColor]
|
|
850
|
-
* @property {string} [loadingImage]
|
|
851
|
-
* @property {
|
|
852
|
-
* @property {
|
|
853
|
-
* @property {
|
|
854
|
-
*
|
|
855
|
-
* @
|
|
856
|
-
* @
|
|
857
|
-
* @
|
|
858
|
-
* @
|
|
912
|
+
* @property {string} [loadingElementId='app'] - The ID of the loading element.
|
|
913
|
+
* @property {string} [loadingColor='#8abaf0'] - The color of the loading animation.
|
|
914
|
+
* @property {string} [loadingImage='/.well-known/service/blocklet/logo?imageFilter=convert&f=png&w=80'] - The URL of the loading image.
|
|
915
|
+
* @property {boolean} [loadingShowDots=true] - Whether to show the loading dots animation.
|
|
916
|
+
* @property {boolean} [loadingShowPoweredBy=true] - Whether to show the "Powered by" text.
|
|
917
|
+
* @property {string} [loadingPoweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
918
|
+
*
|
|
919
|
+
* @property {'all'|'mobile'|'desktop'} [debugPlatform='mobile'] - The platforms to enable debug mode for.
|
|
920
|
+
* @property {string} [debugScript] - The initialization code for the debug script.
|
|
921
|
+
* @property {number} [positionX=0] - The initialization positionX for entry button.
|
|
922
|
+
* @property {number} [positionY=0] - The initialization positionY for entry button.
|
|
923
|
+
*
|
|
924
|
+
* @property {object} [embeds={}] - The embeds to be built.
|
|
925
|
+
* @property {array} [embedExternals=['react', '@arcblock/ux/lib/Locale/context', '@arcblock/did-connect-react/lib/Session']] - The external modules to be used in the embeds.
|
|
926
|
+
* @property {array} [embedPlugins=[]] - The plugins to be used in the embeds.
|
|
927
|
+
* @property {number} [embedBuildConcurrency=0] - The plugins to be used in the embeds.
|
|
928
|
+
*
|
|
859
929
|
* @property {'middleware'|'client'|'server'|'wsUpgrade'} [hmrMode='middleware'] - 当未传入任何 option 参数时,会自动变为 middleware 模式
|
|
860
930
|
*/
|
|
861
931
|
|
package/index.js
CHANGED
|
@@ -20,19 +20,26 @@ import setupClient from './libs/client.js';
|
|
|
20
20
|
* @property {boolean} [disableLoading=false] - Disable loading plugin.
|
|
21
21
|
* @property {boolean} [disableDebug=false] - Disable debug plugin.
|
|
22
22
|
* @property {boolean} [disableEmbed=false] - Disable embed plugin.
|
|
23
|
+
*
|
|
23
24
|
* @property {import('vite-plugin-node-polyfills').PolyfillOptions} [nodePolyfillsOptions]
|
|
24
25
|
*
|
|
25
|
-
* @property {string} [loadingElementId]
|
|
26
|
-
* @property {string} [loadingColor]
|
|
27
|
-
* @property {string} [loadingImage]
|
|
28
|
-
* @property {
|
|
29
|
-
* @property {
|
|
30
|
-
* @property {
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
34
|
-
* @
|
|
35
|
-
* @
|
|
26
|
+
* @property {string} [loadingElementId='app'] - The ID of the loading element.
|
|
27
|
+
* @property {string} [loadingColor='#8abaf0'] - The color of the loading animation.
|
|
28
|
+
* @property {string} [loadingImage='/.well-known/service/blocklet/logo?imageFilter=convert&f=png&w=80'] - The URL of the loading image.
|
|
29
|
+
* @property {boolean} [loadingShowDots=true] - Whether to show the loading dots animation.
|
|
30
|
+
* @property {boolean} [loadingShowPoweredBy=true] - Whether to show the "Powered by" text.
|
|
31
|
+
* @property {string} [loadingPoweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
32
|
+
*
|
|
33
|
+
* @property {'all'|'mobile'|'desktop'} [debugPlatform='mobile'] - The platforms to enable debug mode for.
|
|
34
|
+
* @property {string} [debugScript] - The initialization code for the debug script.
|
|
35
|
+
* @property {number} [positionX=0] - The initialization positionX for entry button.
|
|
36
|
+
* @property {number} [positionY=0] - The initialization positionY for entry button.
|
|
37
|
+
*
|
|
38
|
+
* @property {object} [embeds={}] - The embeds to be built.
|
|
39
|
+
* @property {array} [embedExternals=['react', '@arcblock/ux/lib/Locale/context', '@arcblock/did-connect-react/lib/Session']] - The external modules to be used in the embeds.
|
|
40
|
+
* @property {array} [embedPlugins=[]] - The plugins to be used in the embeds.
|
|
41
|
+
* @property {number} [embedBuildConcurrency=0] - The plugins to be used in the embeds.
|
|
42
|
+
*
|
|
36
43
|
* @property {'middleware'|'client'|'server'|'wsUpgrade'} [hmrMode='middleware'] - 当未传入任何 option 参数时,会自动变为 middleware 模式
|
|
37
44
|
*/
|
|
38
45
|
|
package/libs/loading.js
CHANGED
|
@@ -6,25 +6,19 @@ import { withQuery } from 'ufo';
|
|
|
6
6
|
* @param {Object} options - The options for generating the HTML.
|
|
7
7
|
* @param {string} options.color - The color of the spinner. Defaults to "#333".
|
|
8
8
|
* @param {string} options.image - The URL of the image to display alongside the spinner.
|
|
9
|
+
* @param {boolean} [options.showDots=true] - Whether to show the loading dots animation.
|
|
10
|
+
* @param {boolean} options.showPoweredBy - Whether to show the "Powered by" text.
|
|
11
|
+
* @param {string} [options.poweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
9
12
|
* @return {string} The generated HTML string.
|
|
10
13
|
*/
|
|
11
|
-
function generateHtml({ color, image }) {
|
|
14
|
+
function generateHtml({ color, image, showDots = true, showPoweredBy, poweredByText = 'Powered by ArcBlock' }) {
|
|
12
15
|
return `<style>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
flex-direction: column;
|
|
20
|
-
justify-content: center;
|
|
21
|
-
align-items: center;
|
|
22
|
-
margin: 0;
|
|
23
|
-
padding: 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.spinner-wrapper {
|
|
27
|
-
width: 70px;
|
|
16
|
+
#loadingSpinnerWrapper {
|
|
17
|
+
position: fixed;
|
|
18
|
+
top: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
right: 0;
|
|
21
|
+
bottom: 0;
|
|
28
22
|
opacity: 0;
|
|
29
23
|
animation-name: fadeIn;
|
|
30
24
|
animation-duration: 500ms;
|
|
@@ -38,14 +32,18 @@ function generateHtml({ color, image }) {
|
|
|
38
32
|
align-items: center;
|
|
39
33
|
}
|
|
40
34
|
|
|
41
|
-
.spinner {
|
|
35
|
+
#loadingSpinnerWrapper .spinner {
|
|
42
36
|
width: 70px;
|
|
43
37
|
text-align: center;
|
|
38
|
+
margin-top: 16px;
|
|
44
39
|
}
|
|
45
40
|
|
|
46
|
-
.spinner
|
|
41
|
+
#loadingSpinnerWrapper .spinner>.bounce1,
|
|
42
|
+
#loadingSpinnerWrapper .spinner>.bounce2,
|
|
43
|
+
#loadingSpinnerWrapper .spinner>.bounce3 {
|
|
47
44
|
width: 18px;
|
|
48
45
|
height: 18px;
|
|
46
|
+
|
|
49
47
|
background-color: ${color};
|
|
50
48
|
|
|
51
49
|
border-radius: 100%;
|
|
@@ -54,26 +52,57 @@ function generateHtml({ color, image }) {
|
|
|
54
52
|
animation: sk-bouncedelay 1.4s infinite ease-in-out both;
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
.spinner .bounce1 {
|
|
55
|
+
#loadingSpinnerWrapper .spinner .bounce1 {
|
|
58
56
|
-webkit-animation-delay: -0.32s;
|
|
59
57
|
animation-delay: -0.32s;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
.spinner .bounce2 {
|
|
60
|
+
#loadingSpinnerWrapper .spinner .bounce2 {
|
|
63
61
|
-webkit-animation-delay: -0.16s;
|
|
64
62
|
animation-delay: -0.16s;
|
|
65
63
|
}
|
|
64
|
+
|
|
65
|
+
#loadingImageWrapper {
|
|
66
|
+
width: 70px;
|
|
67
|
+
height: 70px;
|
|
68
|
+
display: flex;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
align-items: center;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
#loadingImageWrapper.loading-image {
|
|
74
|
+
border-radius: 4px;
|
|
75
|
+
background-color: oklch(87.2% 0.01 258.338);
|
|
76
|
+
animation: 2s ease-in-out 0.5s infinite none running skeleton;
|
|
77
|
+
}
|
|
78
|
+
|
|
66
79
|
#loadingImage {
|
|
67
|
-
|
|
80
|
+
display: inline-block;
|
|
81
|
+
width: 100%;
|
|
82
|
+
height: 100%;
|
|
68
83
|
object-fit: contain;
|
|
69
84
|
}
|
|
70
85
|
|
|
86
|
+
|
|
87
|
+
@-webkit-keyframes skeleton {
|
|
88
|
+
0% { opacity: 0.6; }
|
|
89
|
+
50% { opacity: 0.4; }
|
|
90
|
+
100% { opacity: 0.6; }
|
|
91
|
+
}
|
|
92
|
+
@keyframes skeleton {
|
|
93
|
+
0% { opacity: 0.6; }
|
|
94
|
+
50% { opacity: 0.4; }
|
|
95
|
+
100% { opacity: 0.6; }
|
|
96
|
+
}
|
|
97
|
+
|
|
71
98
|
@-webkit-keyframes fadeIn {
|
|
72
99
|
0% { opacity: 0; }
|
|
100
|
+
50% { opacity: 0.4; }
|
|
73
101
|
100% { opacity: 1; }
|
|
74
102
|
}
|
|
75
103
|
@keyframes fadeIn {
|
|
76
104
|
0% { opacity: 0; }
|
|
105
|
+
50% { opacity: 0.4; }
|
|
77
106
|
100% { opacity: 1; }
|
|
78
107
|
}
|
|
79
108
|
|
|
@@ -100,21 +129,36 @@ function generateHtml({ color, image }) {
|
|
|
100
129
|
transform: scale(1);
|
|
101
130
|
}
|
|
102
131
|
}
|
|
132
|
+
|
|
133
|
+
#loadingPoweredBy {
|
|
134
|
+
position: fixed;
|
|
135
|
+
color: oklch(70.7% 0.022 261.325);
|
|
136
|
+
bottom: 16px;
|
|
137
|
+
left: 0;
|
|
138
|
+
right: 0;
|
|
139
|
+
text-align: center;
|
|
140
|
+
opacity: ${showPoweredBy ? 1 : 0.01};
|
|
141
|
+
}
|
|
142
|
+
|
|
103
143
|
</style>
|
|
104
|
-
<div
|
|
105
|
-
<
|
|
106
|
-
|
|
144
|
+
<div id="loadingSpinnerWrapper">
|
|
145
|
+
<div id="loadingImageWrapper" class="loading-image"></div>
|
|
146
|
+
${
|
|
147
|
+
showDots
|
|
148
|
+
? `<div class="spinner">
|
|
107
149
|
<div class="bounce1"></div>
|
|
108
150
|
<div class="bounce2"></div>
|
|
109
151
|
<div class="bounce3"></div>
|
|
110
|
-
</div
|
|
152
|
+
</div>`
|
|
153
|
+
: ''
|
|
154
|
+
}
|
|
111
155
|
</div>
|
|
156
|
+
<div id="loadingPoweredBy">${poweredByText}</div>
|
|
112
157
|
<script>
|
|
113
158
|
(() => {
|
|
114
|
-
const loadingImage = document.getElementById('loadingImage');
|
|
115
159
|
const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
|
|
116
|
-
|
|
117
|
-
let logo = "${image}";
|
|
160
|
+
|
|
161
|
+
let logo = "${image}";
|
|
118
162
|
|
|
119
163
|
if (window?.blocklet) {
|
|
120
164
|
const { appLogo, appLogoDark } = window.blocklet;
|
|
@@ -122,8 +166,14 @@ function generateHtml({ color, image }) {
|
|
|
122
166
|
logo = isDark && appLogoDark ? appLogoDark : appLogo;
|
|
123
167
|
}
|
|
124
168
|
}
|
|
125
|
-
|
|
126
|
-
|
|
169
|
+
const img = document.createElement('img');
|
|
170
|
+
img.id = 'loadingImage';
|
|
171
|
+
img.src = logo;
|
|
172
|
+
img.onload = () => {
|
|
173
|
+
const loadingImageWrapper = document.getElementById('loadingImageWrapper');
|
|
174
|
+
loadingImageWrapper.appendChild(img);
|
|
175
|
+
loadingImageWrapper.classList.remove('loading-image');
|
|
176
|
+
};
|
|
127
177
|
})();
|
|
128
178
|
</script>`;
|
|
129
179
|
}
|
|
@@ -135,9 +185,19 @@ function generateHtml({ color, image }) {
|
|
|
135
185
|
* @param {string} [options.loadingElementId='app'] - The ID of the loading element.
|
|
136
186
|
* @param {string} [options.loadingColor='#8abaf0'] - The color of the loading animation.
|
|
137
187
|
* @param {string} [options.loadingImage='/.well-known/service/blocklet/logo?imageFilter=convert&f=png&w=80'] - The URL of the loading image.
|
|
188
|
+
* @param {boolean} [options.loadingShowDots=true] - Whether to show the loading dots animation.
|
|
189
|
+
* @param {boolean} [options.loadingShowPoweredBy=true] - Whether to show the "Powered by" text.
|
|
190
|
+
* @param {string} [options.loadingPoweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
138
191
|
* @return {Object} - The Vite plugin object.
|
|
139
192
|
*/
|
|
140
|
-
export default function createLoadingPlugin({
|
|
193
|
+
export default function createLoadingPlugin({
|
|
194
|
+
loadingElementId = 'app',
|
|
195
|
+
loadingColor = '#8abaf0',
|
|
196
|
+
loadingImage,
|
|
197
|
+
loadingShowDots = true,
|
|
198
|
+
loadingShowPoweredBy = true,
|
|
199
|
+
loadingPoweredByText = 'Powered by ArcBlock',
|
|
200
|
+
} = {}) {
|
|
141
201
|
if (!loadingImage) {
|
|
142
202
|
loadingImage = withQuery('/.well-known/service/blocklet/logo', {
|
|
143
203
|
imageFilter: 'convert',
|
|
@@ -148,6 +208,9 @@ export default function createLoadingPlugin({ loadingElementId = 'app', loadingC
|
|
|
148
208
|
const injectHtml = generateHtml({
|
|
149
209
|
color: loadingColor,
|
|
150
210
|
image: loadingImage,
|
|
211
|
+
showDots: loadingShowDots,
|
|
212
|
+
showPoweredBy: loadingShowPoweredBy,
|
|
213
|
+
poweredByText: loadingPoweredByText,
|
|
151
214
|
});
|
|
152
215
|
|
|
153
216
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-blocklet",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.13.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"rollup": "^4.34.8"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@arcblock/did": "^1.27.
|
|
34
|
-
"@ocap/mcrypto": "^1.27.
|
|
35
|
-
"@ocap/util": "^1.27.
|
|
33
|
+
"@arcblock/did": "^1.27.15",
|
|
34
|
+
"@ocap/mcrypto": "^1.27.15",
|
|
35
|
+
"@ocap/util": "^1.27.15",
|
|
36
36
|
"get-port": "^5.1.1",
|
|
37
37
|
"http-proxy-middleware": "^3.0.3",
|
|
38
38
|
"ismobilejs": "^1.1.1",
|