@dimina-kit/devtools 0.4.0-dev.20260907055341 → 0.5.0-dev.20260908120530
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 +1 -1
- package/dist/main/app/window-runtime-services.d.ts +12 -12
- package/dist/main/app/window-runtime-services.js +34 -15
- package/dist/main/index.bundle.js +6307 -6050
- package/dist/main/services/elements-forward/index.d.ts +2 -2
- package/dist/main/services/elements-forward/index.js +6 -6
- package/dist/main/services/network-forward/body-cache.d.ts +2 -0
- package/dist/main/services/network-forward/body-cache.js +4 -0
- package/dist/main/services/network-forward/global-body-gate.d.ts +1 -1
- package/dist/main/services/network-forward/global-body-gate.js +4 -4
- package/dist/main/services/network-forward/http.d.ts +47 -0
- package/dist/main/services/network-forward/http.js +162 -0
- package/dist/main/services/network-forward/index.d.ts +19 -13
- package/dist/main/services/network-forward/index.js +220 -134
- package/dist/main/services/network-forward/request-ids.d.ts +5 -0
- package/dist/main/services/network-forward/request-ids.js +5 -0
- package/dist/main/services/safe-area/index.d.ts +7 -9
- package/dist/main/services/safe-area/index.js +7 -14
- package/dist/main/services/views/native-simulator-view.js +7 -8
- package/dist/main/services/workbench-context.d.ts +3 -3
- package/dist/main/services/workbench-context.js +7 -1
- package/dist/native-host/render/render.js +525 -482
- package/dist/native-host/service/service.js +2 -2
- package/dist/preload/shared/api-compat.js +63 -41
- package/dist/preload/windows/main.cjs +15 -1
- package/dist/preload/windows/main.cjs.map +2 -2
- package/dist/preload/windows/simulator.cjs +55 -134
- package/dist/preload/windows/simulator.cjs.map +4 -4
- package/dist/preload/windows/simulator.js +55 -134
- package/dist/renderer/assets/workbench-C0Jkdlps.js +5 -0
- package/dist/renderer/entries/workbench/index.html +1 -1
- package/dist/shared/types.d.ts +2 -0
- package/dist/simulator/assets/device-shell-DucLepkm.js +431 -0
- package/dist/simulator/assets/simulator-B4rbcOVt.js +10 -0
- package/dist/simulator/assets/simulator-ui-i3GCc7YJ.js +2 -0
- package/dist/simulator/simulator.html +2 -2
- package/package.json +12 -12
- package/dist/renderer/assets/workbench-BLJ0wKsg.js +0 -5
- package/dist/shared/request-core.d.ts +0 -2
- package/dist/shared/request-core.js +0 -2
- package/dist/simulator/assets/device-shell-pxnZZp10.js +0 -431
- package/dist/simulator/assets/simulator-Dwp7lnvu.js +0 -10
- package/dist/simulator/assets/simulator-ui-B2ddJB1R.js +0 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ipcRenderer } from "electron";
|
|
2
|
+
import { BRIDGE_CHANNELS } from "../../shared/bridge-channels.js";
|
|
2
3
|
function call(fn, payload) {
|
|
3
4
|
try {
|
|
4
5
|
fn?.(payload);
|
|
@@ -33,10 +34,10 @@ function makeStorageKey(key) {
|
|
|
33
34
|
return `dimina:${key}`;
|
|
34
35
|
}
|
|
35
36
|
function ensureWxApi(wx) {
|
|
36
|
-
if (typeof wx.canIUse !==
|
|
37
|
+
if (typeof wx.canIUse !== "function") {
|
|
37
38
|
wx.canIUse = (_schema) => true;
|
|
38
39
|
}
|
|
39
|
-
if (typeof wx.getWindowInfo !==
|
|
40
|
+
if (typeof wx.getWindowInfo !== "function") {
|
|
40
41
|
wx.getWindowInfo = (opts = {}) => {
|
|
41
42
|
const info = buildWindowInfo();
|
|
42
43
|
call(opts.success, info);
|
|
@@ -44,41 +45,41 @@ function ensureWxApi(wx) {
|
|
|
44
45
|
return info;
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
|
-
if (typeof wx.getSystemSetting !==
|
|
48
|
+
if (typeof wx.getSystemSetting !== "function") {
|
|
48
49
|
wx.getSystemSetting = (opts = {}) => {
|
|
49
50
|
const info = {
|
|
50
51
|
bluetoothEnabled: false,
|
|
51
52
|
locationEnabled: true,
|
|
52
53
|
wifiEnabled: true,
|
|
53
|
-
deviceOrientation:
|
|
54
|
+
deviceOrientation: "portrait",
|
|
54
55
|
};
|
|
55
56
|
call(opts.success, info);
|
|
56
57
|
call(opts.complete, undefined);
|
|
57
58
|
return info;
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
|
-
if (typeof wx.getSystemInfoSync !==
|
|
61
|
+
if (typeof wx.getSystemInfoSync !== "function") {
|
|
61
62
|
wx.getSystemInfoSync = () => ({
|
|
62
|
-
brand:
|
|
63
|
-
model:
|
|
64
|
-
platform:
|
|
65
|
-
system:
|
|
66
|
-
language:
|
|
67
|
-
SDKVersion:
|
|
63
|
+
brand: "simulator",
|
|
64
|
+
model: "web",
|
|
65
|
+
platform: "simulator",
|
|
66
|
+
system: "web",
|
|
67
|
+
language: "zh_CN",
|
|
68
|
+
SDKVersion: "3.0.0",
|
|
68
69
|
...buildWindowInfo(),
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
|
-
if (typeof wx.setStorageSync !==
|
|
72
|
+
if (typeof wx.setStorageSync !== "function") {
|
|
72
73
|
wx.setStorageSync = (key, data) => {
|
|
73
|
-
const value = typeof data ===
|
|
74
|
+
const value = typeof data === "string" ? data : JSON.stringify(data);
|
|
74
75
|
localStorage.setItem(makeStorageKey(String(key)), value);
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
|
-
if (typeof wx.getStorageSync !==
|
|
78
|
+
if (typeof wx.getStorageSync !== "function") {
|
|
78
79
|
wx.getStorageSync = (key) => {
|
|
79
80
|
const raw = localStorage.getItem(makeStorageKey(String(key)));
|
|
80
81
|
if (raw == null)
|
|
81
|
-
return
|
|
82
|
+
return "";
|
|
82
83
|
try {
|
|
83
84
|
return JSON.parse(raw);
|
|
84
85
|
}
|
|
@@ -87,14 +88,14 @@ function ensureWxApi(wx) {
|
|
|
87
88
|
}
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
|
-
if (typeof wx.removeStorageSync !==
|
|
91
|
+
if (typeof wx.removeStorageSync !== "function") {
|
|
91
92
|
wx.removeStorageSync = (key) => {
|
|
92
93
|
localStorage.removeItem(makeStorageKey(String(key)));
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
|
-
if (typeof wx.clearStorageSync !==
|
|
96
|
+
if (typeof wx.clearStorageSync !== "function") {
|
|
96
97
|
wx.clearStorageSync = () => {
|
|
97
|
-
const prefix =
|
|
98
|
+
const prefix = "dimina:";
|
|
98
99
|
const keys = [];
|
|
99
100
|
for (let i = 0; i < localStorage.length; i++) {
|
|
100
101
|
const key = localStorage.key(i);
|
|
@@ -104,9 +105,9 @@ function ensureWxApi(wx) {
|
|
|
104
105
|
keys.forEach((key) => localStorage.removeItem(key));
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
|
-
if (typeof wx.getStorageInfoSync !==
|
|
108
|
+
if (typeof wx.getStorageInfoSync !== "function") {
|
|
108
109
|
wx.getStorageInfoSync = () => {
|
|
109
|
-
const prefix =
|
|
110
|
+
const prefix = "dimina:";
|
|
110
111
|
const keys = [];
|
|
111
112
|
let currentSize = 0;
|
|
112
113
|
for (let i = 0; i < localStorage.length; i++) {
|
|
@@ -114,35 +115,56 @@ function ensureWxApi(wx) {
|
|
|
114
115
|
if (!fullKey?.startsWith(prefix))
|
|
115
116
|
continue;
|
|
116
117
|
keys.push(fullKey.slice(prefix.length));
|
|
117
|
-
currentSize += (localStorage.getItem(fullKey) ||
|
|
118
|
+
currentSize += (localStorage.getItem(fullKey) || "").length * 2;
|
|
118
119
|
}
|
|
119
120
|
return { keys, currentSize, limitSize: 10 * 1024 * 1024 };
|
|
120
121
|
};
|
|
121
122
|
}
|
|
122
|
-
if (typeof wx.request !==
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
// the
|
|
127
|
-
wx.request = (opts) =>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
123
|
+
if (typeof wx.request !== "function") {
|
|
124
|
+
// Route wx.request through the main-process native HTTP transport so it
|
|
125
|
+
// never executes in the renderer (no Chromium Fetch/CORS algorithm, no
|
|
126
|
+
// preflight). The main process owns the network I/O and returns a result
|
|
127
|
+
// object that already carries the wx.request success/fail shape.
|
|
128
|
+
wx.request = (opts) => {
|
|
129
|
+
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
130
|
+
const task = {
|
|
131
|
+
abort: () => ipcRenderer.send(BRIDGE_CHANNELS.NATIVE_REQUEST_ABORT, requestId),
|
|
132
|
+
};
|
|
133
|
+
ipcRenderer
|
|
134
|
+
.invoke(BRIDGE_CHANNELS.NATIVE_REQUEST, requestId, {
|
|
135
|
+
url: opts.url,
|
|
136
|
+
data: opts.data,
|
|
137
|
+
header: opts.header,
|
|
138
|
+
timeout: opts.timeout,
|
|
139
|
+
method: opts.method,
|
|
140
|
+
dataType: opts.dataType,
|
|
141
|
+
responseType: opts.responseType,
|
|
142
|
+
})
|
|
143
|
+
.then((result) => {
|
|
144
|
+
if (result && typeof result === "object" && "statusCode" in result) {
|
|
145
|
+
call(opts.success, result);
|
|
146
|
+
call(opts.complete, result);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
call(opts.fail, result);
|
|
150
|
+
call(opts.complete, result);
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
.catch((error) => {
|
|
154
|
+
const err = {
|
|
155
|
+
errMsg: `request:fail ${error instanceof Error ? error.message : String(error)}`,
|
|
156
|
+
};
|
|
157
|
+
call(opts.fail, err);
|
|
158
|
+
call(opts.complete, err);
|
|
159
|
+
});
|
|
160
|
+
return task;
|
|
161
|
+
};
|
|
140
162
|
}
|
|
141
163
|
}
|
|
142
164
|
export function setupApiCompatHook() {
|
|
143
165
|
const apply = () => {
|
|
144
166
|
const target = window;
|
|
145
|
-
if (!target.wx || typeof target.wx !==
|
|
167
|
+
if (!target.wx || typeof target.wx !== "object") {
|
|
146
168
|
target.wx = {};
|
|
147
169
|
}
|
|
148
170
|
const wx = target.wx;
|
|
@@ -3191,7 +3191,21 @@ var BRIDGE_CHANNELS = {
|
|
|
3191
3191
|
* active bridgeId via ACTIVE_PAGE), so automation's `App.getPageStack` needs
|
|
3192
3192
|
* this to report multi-page stacks. Fire-and-forget.
|
|
3193
3193
|
*/
|
|
3194
|
-
PAGE_STACK: "dmb:page-stack"
|
|
3194
|
+
PAGE_STACK: "dmb:page-stack",
|
|
3195
|
+
/**
|
|
3196
|
+
* preload (window.wx.request, no service-host in the picture) → main
|
|
3197
|
+
* (invoke): run an HTTP request through the main-process native transport
|
|
3198
|
+
* (`main/services/native-request`) instead of the renderer's `fetch()`, so
|
|
3199
|
+
* it never hits Chromium's Fetch/CORS algorithm (no spurious OPTIONS
|
|
3200
|
+
* preflight). Reply is a `NativeRequestResult` (success or fail shape).
|
|
3201
|
+
*/
|
|
3202
|
+
NATIVE_REQUEST: "dmb:native-request",
|
|
3203
|
+
/**
|
|
3204
|
+
* preload → main: cancel the in-flight native request named by the
|
|
3205
|
+
* requestId a prior NATIVE_REQUEST call was invoked with. Fire-and-forget;
|
|
3206
|
+
* a requestId that already settled or belongs to another sender is a no-op.
|
|
3207
|
+
*/
|
|
3208
|
+
NATIVE_REQUEST_ABORT: "dmb:native-request-abort"
|
|
3195
3209
|
};
|
|
3196
3210
|
var SIMULATOR_EVENTS = {
|
|
3197
3211
|
DOM_READY: "simulator:dom-ready",
|