dsh-mobile-plugin 0.5.16 → 0.5.17
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/lib/mobile/host-settings.js +23 -1
- package/package.json +1 -1
|
@@ -153,6 +153,26 @@ function describeField(node, refs) {
|
|
|
153
153
|
return out;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
/**
|
|
157
|
+
* 一层键值映射(schemastery 的 `z.dict(inner)`):每个键的取值都是同一种控件。
|
|
158
|
+
*
|
|
159
|
+
* 权限档那一项就是这种形状 —— `presets` 是一个映射,每个键是一档的名字、值是「沙箱 + 审批」
|
|
160
|
+
* 那组常量。手机端不画整份映射,只画其中一个键(通常是当前生效的那档)里的那几个常量,所以
|
|
161
|
+
* 这一层要认得出来。只走到根下面一层,再深就不认(那种在手机上怎么改都是在猜)。
|
|
162
|
+
*/
|
|
163
|
+
function dictFieldOf(node, refs) {
|
|
164
|
+
const inner = node && node.type === 'dict' && refs && refs[String(node.inner)] ? refs[String(node.inner)] : null;
|
|
165
|
+
const dict = inner && inner.type === 'object' ? inner.dict : null;
|
|
166
|
+
if (!dict || typeof dict !== 'object' || Array.isArray(dict)) return null;
|
|
167
|
+
const fields = [];
|
|
168
|
+
for (const key of Object.keys(dict).slice(0, HOST_SETTINGS_MAX_FIELDS)) {
|
|
169
|
+
const child = refs[String(dict[key])];
|
|
170
|
+
const field = describeField(child, refs);
|
|
171
|
+
if (field) fields.push({ key, ...field });
|
|
172
|
+
}
|
|
173
|
+
return fields.length > 0 ? fields : null;
|
|
174
|
+
}
|
|
175
|
+
|
|
156
176
|
/** 一个命名空间里各字段的控件形状;推不出来(老宿主 / 畸形 schema)就是 null。 */
|
|
157
177
|
function fieldsOf(schema) {
|
|
158
178
|
const shape = schemaDict(schema);
|
|
@@ -161,7 +181,9 @@ function fieldsOf(schema) {
|
|
|
161
181
|
for (const key of Object.keys(shape.dict).slice(0, HOST_SETTINGS_MAX_FIELDS)) {
|
|
162
182
|
const node = shape.refs[String(shape.dict[key])];
|
|
163
183
|
const field = describeField(node, shape.refs);
|
|
164
|
-
if (field) fields.push({ key, ...field });
|
|
184
|
+
if (field) { fields.push({ key, ...field }); continue; }
|
|
185
|
+
const nested = dictFieldOf(node, shape.refs);
|
|
186
|
+
if (nested) fields.push({ key, type: 'map', fields: nested });
|
|
165
187
|
}
|
|
166
188
|
return fields.length > 0 ? fields : null;
|
|
167
189
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mobile-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.17",
|
|
4
4
|
"description": "Mobile API (/api/mobile/v1) and relay client for the DSH mobile app — desktop profile build (dsh 0.2.x, peers resolved by the host)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"icon": "./icon.png",
|