vite-plugin-blocklet 0.9.22 → 0.9.24
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 +24 -1
- package/index.js +2 -0
- package/libs/debug.js +22 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -406,6 +406,8 @@ function createLoadingPlugin({ loadingElementId = 'app', loadingColor = '#8abaf0
|
|
|
406
406
|
* @param {object} options - The options for the plugin.
|
|
407
407
|
* @param {'all'|'mobile'|'desktop'} [options.debugPlatform='mobile'] - The platforms to enable debug mode for.
|
|
408
408
|
* @param {string} [options.debugScript] - The initialization code for the debug script.
|
|
409
|
+
* @param {number} [options.positionX = 0] - The initialization positionX for entry button.
|
|
410
|
+
* @param {number} [options.positionY = 0] - The initialization positionY for entry button.
|
|
409
411
|
* @return {object} The Vite config plugin.
|
|
410
412
|
*/
|
|
411
413
|
function createConfigPlugin(options) {
|
|
@@ -457,8 +459,27 @@ function createConfigPlugin(options) {
|
|
|
457
459
|
* @returns {import('vite').IndexHtmlTransformResult}
|
|
458
460
|
*/
|
|
459
461
|
transformIndexHtml(html, ctx) {
|
|
462
|
+
const entryButtonWidth = 50;
|
|
463
|
+
const entryButtonHeight = 50 + 50; // Avoid bottom occlusion in ArcSphere
|
|
460
464
|
const debugScript =
|
|
461
|
-
options.debugScript ||
|
|
465
|
+
options.debugScript ||
|
|
466
|
+
`import('https://esm.run/eruda').then(({ default: eruda }) => {
|
|
467
|
+
const positionX = Number(${options.positionX});
|
|
468
|
+
const positionY = Number(${options.positionY});
|
|
469
|
+
const entryButtonWidth = ${entryButtonWidth};
|
|
470
|
+
const entryButtonHeight = ${entryButtonHeight};
|
|
471
|
+
|
|
472
|
+
const initialized = !!localStorage.getItem('eruda-entry-button');
|
|
473
|
+
eruda.init();
|
|
474
|
+
const position = eruda.position();
|
|
475
|
+
|
|
476
|
+
if (!Number.isNaN(positionX)) position.x = positionX;
|
|
477
|
+
if (!Number.isNaN(positionY)) position.y = positionY;
|
|
478
|
+
if (position.x >= window.innerWidth - entryButtonWidth) position.x = window.innerWidth - entryButtonWidth;
|
|
479
|
+
if (position.y >= window.innerHeight - entryButtonHeight) position.y = window.innerHeight - entryButtonHeight;
|
|
480
|
+
|
|
481
|
+
if (!initialized) eruda.position(position);
|
|
482
|
+
});`;
|
|
462
483
|
try {
|
|
463
484
|
const url = new URL(ctx.originalUrl, 'http://localhost');
|
|
464
485
|
if (url.searchParams.has('debug')) {
|
|
@@ -782,6 +803,8 @@ async function setupClient(app, options = {}) {
|
|
|
782
803
|
* @property {string} [loadingImage]
|
|
783
804
|
* @property {'all'|'mobile'|'desktop'} [debugPlatform='mobile']
|
|
784
805
|
* @property {string} [debugScript]
|
|
806
|
+
* @property {number} [positionX]
|
|
807
|
+
* @property {number} [positionY]
|
|
785
808
|
* @param {object} [embeds={}] - The embeds to be built.
|
|
786
809
|
* @param {array} [embedExternals=['react', '@arcblock/ux/lib/Locale/context', '@arcblock/did-connect/lib/Session']] - The external modules to be used in the embeds.
|
|
787
810
|
* @param {array} [embedPlugins=[]] - The plugins to be used in the embeds.
|
package/index.js
CHANGED
|
@@ -26,6 +26,8 @@ import setupClient from './libs/client.js';
|
|
|
26
26
|
* @property {string} [loadingImage]
|
|
27
27
|
* @property {'all'|'mobile'|'desktop'} [debugPlatform='mobile']
|
|
28
28
|
* @property {string} [debugScript]
|
|
29
|
+
* @property {number} [positionX]
|
|
30
|
+
* @property {number} [positionY]
|
|
29
31
|
* @param {object} [embeds={}] - The embeds to be built.
|
|
30
32
|
* @param {array} [embedExternals=['react', '@arcblock/ux/lib/Locale/context', '@arcblock/did-connect/lib/Session']] - The external modules to be used in the embeds.
|
|
31
33
|
* @param {array} [embedPlugins=[]] - The plugins to be used in the embeds.
|
package/libs/debug.js
CHANGED
|
@@ -7,6 +7,8 @@ import { isInBlocklet } from './utils.js';
|
|
|
7
7
|
* @param {object} options - The options for the plugin.
|
|
8
8
|
* @param {'all'|'mobile'|'desktop'} [options.debugPlatform='mobile'] - The platforms to enable debug mode for.
|
|
9
9
|
* @param {string} [options.debugScript] - The initialization code for the debug script.
|
|
10
|
+
* @param {number} [options.positionX = 0] - The initialization positionX for entry button.
|
|
11
|
+
* @param {number} [options.positionY = 0] - The initialization positionY for entry button.
|
|
10
12
|
* @return {object} The Vite config plugin.
|
|
11
13
|
*/
|
|
12
14
|
export default function createConfigPlugin(options) {
|
|
@@ -58,8 +60,27 @@ export default function createConfigPlugin(options) {
|
|
|
58
60
|
* @returns {import('vite').IndexHtmlTransformResult}
|
|
59
61
|
*/
|
|
60
62
|
transformIndexHtml(html, ctx) {
|
|
63
|
+
const entryButtonWidth = 50;
|
|
64
|
+
const entryButtonHeight = 50 + 50; // Avoid bottom occlusion in ArcSphere
|
|
61
65
|
const debugScript =
|
|
62
|
-
options.debugScript ||
|
|
66
|
+
options.debugScript ||
|
|
67
|
+
`import('https://esm.run/eruda').then(({ default: eruda }) => {
|
|
68
|
+
const positionX = Number(${options.positionX});
|
|
69
|
+
const positionY = Number(${options.positionY});
|
|
70
|
+
const entryButtonWidth = ${entryButtonWidth};
|
|
71
|
+
const entryButtonHeight = ${entryButtonHeight};
|
|
72
|
+
|
|
73
|
+
const initialized = !!localStorage.getItem('eruda-entry-button');
|
|
74
|
+
eruda.init();
|
|
75
|
+
const position = eruda.position();
|
|
76
|
+
|
|
77
|
+
if (!Number.isNaN(positionX)) position.x = positionX;
|
|
78
|
+
if (!Number.isNaN(positionY)) position.y = positionY;
|
|
79
|
+
if (position.x >= window.innerWidth - entryButtonWidth) position.x = window.innerWidth - entryButtonWidth;
|
|
80
|
+
if (position.y >= window.innerHeight - entryButtonHeight) position.y = window.innerHeight - entryButtonHeight;
|
|
81
|
+
|
|
82
|
+
if (!initialized) eruda.position(position);
|
|
83
|
+
});`;
|
|
63
84
|
try {
|
|
64
85
|
const url = new URL(ctx.originalUrl, 'http://localhost');
|
|
65
86
|
if (url.searchParams.has('debug')) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-blocklet",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.24",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"rollup": "^4.34.8"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@arcblock/did": "^1.19.
|
|
31
|
-
"@ocap/mcrypto": "^1.19.
|
|
32
|
-
"@ocap/util": "^1.19.
|
|
30
|
+
"@arcblock/did": "^1.19.15",
|
|
31
|
+
"@ocap/mcrypto": "^1.19.15",
|
|
32
|
+
"@ocap/util": "^1.19.15",
|
|
33
33
|
"get-port": "^5.1.1",
|
|
34
34
|
"http-proxy-middleware": "^3.0.3",
|
|
35
35
|
"ismobilejs": "^1.1.1",
|