@syncended/dsh-automations 0.2.0 → 0.2.1
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/client.js +31 -2
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -66,6 +66,31 @@ window.__ModuleLoader__.load({
|
|
|
66
66
|
return error instanceof Error ? error.message : String(error);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
const CJK_LABEL_PATTERN = /[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uac00-\ud7af]/;
|
|
70
|
+
const BUILTIN_AGENT_PRESET_LABELS = {
|
|
71
|
+
standard: "Standard mode",
|
|
72
|
+
code: "PTC mode",
|
|
73
|
+
minimal: "Minimal mode",
|
|
74
|
+
cordis: "Creator mode",
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
function humanizePresetId(id) {
|
|
78
|
+
return id
|
|
79
|
+
.split(/[-_]+/)
|
|
80
|
+
.filter(Boolean)
|
|
81
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
82
|
+
.join(" ");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function agentPresetDisplayLabel(preset) {
|
|
86
|
+
const id = preset && typeof preset.id === "string" ? preset.id.trim() : "";
|
|
87
|
+
const name = preset && typeof preset.name === "string" ? preset.name.trim() : "";
|
|
88
|
+
if (id === "") return name !== "" && !CJK_LABEL_PATTERN.test(name) ? name : "Unknown preset";
|
|
89
|
+
if (name !== "" && name !== id && !CJK_LABEL_PATTERN.test(name)) return name + " (" + id + ")";
|
|
90
|
+
const readableId = BUILTIN_AGENT_PRESET_LABELS[id] || humanizePresetId(id) || id;
|
|
91
|
+
return readableId === id ? id : readableId + " (" + id + ")";
|
|
92
|
+
}
|
|
93
|
+
|
|
69
94
|
function browserTimezone() {
|
|
70
95
|
return BROWSER_TIMEZONE;
|
|
71
96
|
}
|
|
@@ -443,7 +468,7 @@ window.__ModuleLoader__.load({
|
|
|
443
468
|
h(
|
|
444
469
|
"option",
|
|
445
470
|
{ key: preset.id, value: preset.id },
|
|
446
|
-
preset
|
|
471
|
+
agentPresetDisplayLabel(preset) + (preset.broken ? " (broken: " + preset.broken + ")" : ""),
|
|
447
472
|
),
|
|
448
473
|
),
|
|
449
474
|
),
|
|
@@ -559,7 +584,10 @@ window.__ModuleLoader__.load({
|
|
|
559
584
|
? meta.agentPresets.find((preset) => preset.id === job.execution.agentPreset)
|
|
560
585
|
: undefined;
|
|
561
586
|
const presetLabel = job.execution.agentPreset
|
|
562
|
-
? (agentPreset
|
|
587
|
+
? agentPresetDisplayLabel(agentPreset || {
|
|
588
|
+
id: job.execution.agentPreset,
|
|
589
|
+
name: job.execution.agentPreset,
|
|
590
|
+
})
|
|
563
591
|
: "";
|
|
564
592
|
|
|
565
593
|
return h(
|
|
@@ -1499,6 +1527,7 @@ window.__ModuleLoader__.load({
|
|
|
1499
1527
|
}, AutomationsOverlay));
|
|
1500
1528
|
}
|
|
1501
1529
|
|
|
1530
|
+
exports.agentPresetDisplayLabel = agentPresetDisplayLabel;
|
|
1502
1531
|
exports.inject = inject;
|
|
1503
1532
|
exports.apply = apply;
|
|
1504
1533
|
return module.exports;
|