dsh-workbench-danmaku 0.3.2 → 0.3.3
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 +1 -874
- package/lib/index.js +0 -1
- package/package.json +5 -6
package/lib/client.js
CHANGED
|
@@ -3577,873 +3577,6 @@ var require_config = __commonJS({
|
|
|
3577
3577
|
}
|
|
3578
3578
|
});
|
|
3579
3579
|
|
|
3580
|
-
// packages/addons/lib/highlight.cjs
|
|
3581
|
-
var require_highlight = __commonJS({
|
|
3582
|
-
"packages/addons/lib/highlight.cjs"(exports2, module2) {
|
|
3583
|
-
"use strict";
|
|
3584
|
-
module2.exports = function(React) {
|
|
3585
|
-
var h = React.createElement;
|
|
3586
|
-
function sourceOf(keyword) {
|
|
3587
|
-
var pattern = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3588
|
-
return pattern.replace(/[a-zA-Z]/g, function(letter) {
|
|
3589
|
-
return "[" + letter.toLowerCase() + letter.toUpperCase() + "]";
|
|
3590
|
-
});
|
|
3591
|
-
}
|
|
3592
|
-
return function createHighlight(prefix) {
|
|
3593
|
-
var className = String(prefix || "wb") + "-hit";
|
|
3594
|
-
function hit(rawText, rawKeyword) {
|
|
3595
|
-
var text = rawText == null ? "" : String(rawText);
|
|
3596
|
-
var keyword = rawKeyword == null ? "" : String(rawKeyword);
|
|
3597
|
-
if (!keyword) return text;
|
|
3598
|
-
var matcher, match, end = 0, parts = [];
|
|
3599
|
-
try {
|
|
3600
|
-
matcher = new RegExp(sourceOf(keyword), "g");
|
|
3601
|
-
} catch (error) {
|
|
3602
|
-
return text;
|
|
3603
|
-
}
|
|
3604
|
-
while (match = matcher.exec(text)) {
|
|
3605
|
-
if (match.index > end) parts.push(text.slice(end, match.index));
|
|
3606
|
-
parts.push(h("mark", { className, key: match.index }, match[0]));
|
|
3607
|
-
end = match.index + match[0].length;
|
|
3608
|
-
if (!match[0]) matcher.lastIndex += 1;
|
|
3609
|
-
}
|
|
3610
|
-
if (!parts.length) return text;
|
|
3611
|
-
if (end < text.length) parts.push(text.slice(end));
|
|
3612
|
-
return parts;
|
|
3613
|
-
}
|
|
3614
|
-
function Highlight(props) {
|
|
3615
|
-
return hit(props.text, props.keyword);
|
|
3616
|
-
}
|
|
3617
|
-
Highlight.hit = hit;
|
|
3618
|
-
return Highlight;
|
|
3619
|
-
};
|
|
3620
|
-
};
|
|
3621
|
-
}
|
|
3622
|
-
});
|
|
3623
|
-
|
|
3624
|
-
// node_modules/.pnpm/lucide-react@1.70.0_react@19.2.0/node_modules/lucide-react/dist/esm/icons/chevron-right.mjs
|
|
3625
|
-
var chevron_right_exports = {};
|
|
3626
|
-
__export(chevron_right_exports, {
|
|
3627
|
-
__iconData: () => __iconData17,
|
|
3628
|
-
default: () => ChevronRight
|
|
3629
|
-
});
|
|
3630
|
-
var __iconData17, ChevronRight;
|
|
3631
|
-
var init_chevron_right = __esm({
|
|
3632
|
-
"node_modules/.pnpm/lucide-react@1.70.0_react@19.2.0/node_modules/lucide-react/dist/esm/icons/chevron-right.mjs"() {
|
|
3633
|
-
init_createLucideIcon();
|
|
3634
|
-
__iconData17 = {
|
|
3635
|
-
name: "chevron-right",
|
|
3636
|
-
size: 24,
|
|
3637
|
-
node: [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]]
|
|
3638
|
-
};
|
|
3639
|
-
__iconData17.node;
|
|
3640
|
-
ChevronRight = createLucideIcon(__iconData17);
|
|
3641
|
-
}
|
|
3642
|
-
});
|
|
3643
|
-
|
|
3644
|
-
// packages/addons/lib/disclosure-styles.cjs
|
|
3645
|
-
var require_disclosure_styles = __commonJS({
|
|
3646
|
-
"packages/addons/lib/disclosure-styles.cjs"(exports2, module2) {
|
|
3647
|
-
"use strict";
|
|
3648
|
-
module2.exports = [
|
|
3649
|
-
".wb-disc{min-width:0;border:0;padding:0;margin:0}",
|
|
3650
|
-
// 原生 details/summary 保留键盘与无障碍语义,这里只接管观感:去掉默认三角并铺满整行。
|
|
3651
|
-
".wb-disc>summary{display:flex;align-items:center;gap:6px;cursor:pointer;font-size:12.5px;font-weight:600;line-height:1.6;color:inherit;user-select:none;list-style:none;padding:2px 8px 2px 2px;margin:-2px -8px -2px -2px;border-radius:7px}",
|
|
3652
|
-
".wb-disc>summary::-webkit-details-marker{display:none}",
|
|
3653
|
-
'.wb-disc>summary::marker{content:""}',
|
|
3654
|
-
".wb-disc>summary:hover{background:color-mix(in oklab,currentColor 6%,transparent)}",
|
|
3655
|
-
".wb-disc>summary:focus-visible{outline:2px solid var(--wb-accent,var(--dsw-alias-brand-primary,Highlight));outline-offset:2px}",
|
|
3656
|
-
".wb-disc-chev{flex:0 0 auto;width:14px;height:14px;transition:transform 160ms ease}",
|
|
3657
|
-
".wb-disc[open]>summary .wb-disc-chev{transform:rotate(90deg)}",
|
|
3658
|
-
".wb-disc-title{min-width:0;overflow-wrap:anywhere}",
|
|
3659
|
-
".wb-disc-meta{font-weight:400;font-size:12px;color:var(--wb-muted,var(--dsw-alias-label-tertiary,GrayText))}",
|
|
3660
|
-
".wb-disc-body{margin-top:8px;min-width:0;animation:wb-disc-in 160ms ease}",
|
|
3661
|
-
"@keyframes wb-disc-in{from{opacity:0;transform:translateY(-2px)}to{opacity:1;transform:none}}",
|
|
3662
|
-
"@media(prefers-reduced-motion:reduce){.wb-disc-chev{transition:none}.wb-disc-body{animation:none}}"
|
|
3663
|
-
].join("\n");
|
|
3664
|
-
}
|
|
3665
|
-
});
|
|
3666
|
-
|
|
3667
|
-
// packages/addons/lib/disclosure.cjs
|
|
3668
|
-
var require_disclosure = __commonJS({
|
|
3669
|
-
"packages/addons/lib/disclosure.cjs"(exports2, module2) {
|
|
3670
|
-
"use strict";
|
|
3671
|
-
var ChevronRight2 = (init_chevron_right(), __toCommonJS(chevron_right_exports)).default;
|
|
3672
|
-
function createDisclosure(React) {
|
|
3673
|
-
var h = React.createElement;
|
|
3674
|
-
function Disclosure(props) {
|
|
3675
|
-
var attrs = Object.assign({ className: ("wb-disc " + (props.className || "")).trim() }, props.attrs || {});
|
|
3676
|
-
if (props.open !== void 0) attrs.open = !!props.open;
|
|
3677
|
-
else if (props.defaultOpen !== void 0) attrs.open = !!props.defaultOpen;
|
|
3678
|
-
if (props.onToggle) attrs.onToggle = props.onToggle;
|
|
3679
|
-
return h(
|
|
3680
|
-
"details",
|
|
3681
|
-
attrs,
|
|
3682
|
-
h(
|
|
3683
|
-
"summary",
|
|
3684
|
-
null,
|
|
3685
|
-
h(ChevronRight2, { className: "wb-disc-chev", "aria-hidden": true, focusable: false }),
|
|
3686
|
-
h("span", { className: "wb-disc-title" }, props.title),
|
|
3687
|
-
props.meta != null && props.meta !== "" ? h("span", { className: "wb-disc-meta" }, props.meta) : null
|
|
3688
|
-
),
|
|
3689
|
-
h("div", { className: "wb-disc-body" }, props.children)
|
|
3690
|
-
);
|
|
3691
|
-
}
|
|
3692
|
-
return { Disclosure, css: require_disclosure_styles() };
|
|
3693
|
-
}
|
|
3694
|
-
module2.exports = { createDisclosure, css: require_disclosure_styles() };
|
|
3695
|
-
}
|
|
3696
|
-
});
|
|
3697
|
-
|
|
3698
|
-
// packages/addons/lib/action-schema-style.cjs
|
|
3699
|
-
var require_action_schema_style = __commonJS({
|
|
3700
|
-
"packages/addons/lib/action-schema-style.cjs"(exports2, module2) {
|
|
3701
|
-
"use strict";
|
|
3702
|
-
module2.exports = function(PREFIX, DOMAIN) {
|
|
3703
|
-
var P = PREFIX + "-as";
|
|
3704
|
-
var hairline = "1px solid color-mix(in oklab,currentColor 8%,transparent)";
|
|
3705
|
-
var CSS = [
|
|
3706
|
-
"." + P + "{display:flex;flex-direction:column;gap:12px;width:100%;min-width:0;font-size:13px;color:inherit}",
|
|
3707
|
-
"." + P + "-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
|
|
3708
|
-
"." + P + "-title{font-size:15px;font-weight:660;margin:0}",
|
|
3709
|
-
"." + P + "-badge{display:inline-flex;align-items:center;gap:4px;max-width:100%;border:1px solid var(--wb-border,#e3e5e9);border-radius:999px;padding:1px 8px;font-size:11px;color:var(--dsw-alias-label-secondary,currentColor);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}",
|
|
3710
|
-
"." + P + "-mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px}",
|
|
3711
|
-
"." + P + "-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
|
|
3712
|
-
"." + P + "-search{position:relative;flex:1 1 220px;min-width:0;display:flex;align-items:center}",
|
|
3713
|
-
"." + P + "-search input{width:100%;border:1px solid var(--wb-border,#e3e5e9);border-radius:8px;background:var(--wb-surface,var(--dsw-alias-bg-layer-1,transparent));color:inherit;font:inherit;padding:6px 10px 6px 30px}",
|
|
3714
|
-
"." + P + "-search input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}",
|
|
3715
|
-
"." + P + "-search .wbi-svg{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--dsw-alias-label-tertiary,inherit)}",
|
|
3716
|
-
"." + P + " select{border:1px solid var(--wb-border,#e3e5e9);border-radius:8px;background:var(--wb-surface,var(--dsw-alias-bg-layer-1,transparent));color:inherit;font:inherit;padding:6px 8px;max-width:100%}",
|
|
3717
|
-
"." + P + " select:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}",
|
|
3718
|
-
"." + P + "-list{display:flex;flex-direction:column;gap:8px}",
|
|
3719
|
-
"." + P + "-card{border:1px solid var(--wb-border,#e3e5e9);border-radius:10px;padding:10px 12px;background:var(--wb-surface,var(--dsw-alias-bg-layer-1,transparent));display:flex;flex-direction:column;gap:8px;min-width:0}",
|
|
3720
|
-
"." + P + "-cardhead{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:8px}",
|
|
3721
|
-
"." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
|
|
3722
|
-
"." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
|
|
3723
|
-
"." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
|
|
3724
|
-
"." + P + "-origins{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end;min-width:0}",
|
|
3725
|
-
"." + P + "-origins-label{font-size:11px;color:var(--wb-muted);white-space:nowrap}",
|
|
3726
|
-
"." + P + "-origin{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--wb-muted);cursor:pointer;user-select:none}",
|
|
3727
|
-
// 该 action 本身不支持的来源:整项置灰、不可点,示意「不是没开,是开不了」。
|
|
3728
|
-
"." + P + "-origin-off{opacity:.55;cursor:not-allowed}",
|
|
3729
|
-
"." + P + "-origin input[type=checkbox]{width:13px;height:13px;margin:0;accent-color:var(--wb-accent);cursor:inherit}",
|
|
3730
|
-
"." + P + "-origin input[type=checkbox]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
|
|
3731
|
-
"." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
|
|
3732
|
-
"." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px;overflow-wrap:anywhere}",
|
|
3733
|
-
// 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
|
|
3734
|
-
"." + P + " mark." + P + "-hit{background:color-mix(in oklab,var(--dsw-alias-brand-primary,#4f6ef7) 22%,transparent);color:inherit;border-radius:2px;padding:0;font:inherit;box-decoration-break:clone;-webkit-box-decoration-break:clone}",
|
|
3735
|
-
"." + P + "-table{width:100%;border-collapse:collapse;font-size:12px;table-layout:auto}",
|
|
3736
|
-
"." + P + "-table th{text-align:left;font-weight:620;font-size:11px;letter-spacing:.4px;text-transform:uppercase;color:var(--dsw-alias-label-tertiary,inherit);padding:4px 8px 4px 0;white-space:nowrap}",
|
|
3737
|
-
"." + P + "-table td{padding:4px 8px 4px 0;vertical-align:top;border-top:" + hairline + ";line-height:1.5;overflow-wrap:anywhere}",
|
|
3738
|
-
"." + P + "-req{color:var(--dsw-alias-state-error-primary,#d9534f);font-weight:620}",
|
|
3739
|
-
"." + P + "-opt{color:var(--dsw-alias-label-tertiary,inherit)}",
|
|
3740
|
-
"." + P + "-none{color:var(--dsw-alias-label-tertiary,inherit);font-size:12px}",
|
|
3741
|
-
"." + P + "-example{position:relative;display:flex;flex-direction:column;gap:4px;min-width:0}",
|
|
3742
|
-
"." + P + "-examplehead{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}",
|
|
3743
|
-
"." + P + "-pre{margin:0;padding:8px 10px;border-radius:8px;background:var(--dsw-alias-bg-skeleton,#f2f3f5);color:inherit;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;line-height:1.5;overflow:auto;max-height:280px;white-space:pre-wrap;word-break:break-word}",
|
|
3744
|
-
"." + P + "-copy{border:1px solid var(--wb-border,#e3e5e9);border-radius:7px;background:transparent;color:inherit;font:inherit;font-size:11.5px;padding:2px 8px;cursor:pointer}",
|
|
3745
|
-
"." + P + "-copy:hover{background:var(--dsw-alias-interactive-bg-hover,color-mix(in oklab,currentColor 5%,transparent))}",
|
|
3746
|
-
"." + P + "-copy:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:2px}",
|
|
3747
|
-
// 折叠头观感已收口到共享控件 disclosure-styles.cjs(.wb-disc),这里不再重复定义 details>summary。
|
|
3748
|
-
"." + P + "-params{min-width:0}",
|
|
3749
|
-
"." + P + "-empty{padding:24px;text-align:center;border:1px dashed var(--wb-border,#e3e5e9);border-radius:10px;color:var(--dsw-alias-label-tertiary,inherit)}",
|
|
3750
|
-
"." + P + "-error{padding:12px;border:1px solid var(--dsw-alias-state-error-primary,#d9534f);border-radius:10px;color:var(--dsw-alias-state-error-primary,#d9534f);display:flex;gap:10px;align-items:center;flex-wrap:wrap;overflow-wrap:anywhere}",
|
|
3751
|
-
"." + P + "-toast{position:sticky;bottom:8px;align-self:flex-start;border-radius:999px;padding:3px 10px;background:var(--dsw-alias-bg-skeleton,#f2f3f5);font-size:11.5px;max-width:100%}",
|
|
3752
|
-
// 窄屏:五列参数表压成一列会丢失列名、且 table 布局按最小内容宽度撑破容器,
|
|
3753
|
-
// 这里整体改成块级网格:每行 = 名称 / 类型 / 必填 + 约束行 + 说明行,行间用细线分隔。
|
|
3754
|
-
"@media(max-width:760px){." + P + "-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;align-items:end}." + P + "-search{grid-column:1/-1}." + P + "-toolbar>label{display:flex;flex-direction:column;align-items:stretch;gap:4px;min-width:0}." + P + "-toolbar select{width:100%;min-width:0}." + P + "-cardhead{grid-template-columns:minmax(0,1fr);row-gap:6px}." + P + "-origins{justify-content:flex-start}." + P + "-table{display:block}." + P + "-table thead{display:none}." + P + "-table tbody{display:block}." + P + '-table tr{display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-areas:"name type need" "extra extra extra" "desc desc desc";column-gap:8px;padding:9px 0;border-top:' + hairline + "}." + P + "-table tr:first-child{border-top:0;padding-top:2px}." + P + "-table tr:last-child{padding-bottom:2px}." + P + "-table td{display:block;border:0;padding:0;min-width:0}." + P + "-table td:empty{display:none}." + P + "-pname{grid-area:name;font-weight:640}." + P + "-ptype{grid-area:type;justify-self:start;align-self:center;color:var(--dsw-alias-label-tertiary,inherit)}." + P + "-pneed{grid-area:need;justify-self:end;align-self:center;font-size:11px;line-height:1.6;white-space:nowrap}." + P + "-pextra{grid-area:extra;margin-top:3px;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55}." + P + "-pdesc{grid-area:desc;margin-top:3px;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55}}",
|
|
3755
|
-
// 中等宽度(521–760px)三个筛选项正好排成一行,避免第三项独占一行显得参差。
|
|
3756
|
-
"@media(min-width:521px) and (max-width:760px){." + P + "-toolbar{grid-template-columns:repeat(3,minmax(0,1fr))}}",
|
|
3757
|
-
"@media(max-width:420px){." + P + "-toolbar{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}." + P + "-card{padding:10px}." + P + "-table tr{padding:8px 0}}"
|
|
3758
|
-
].join("\n") + "\n" + require_disclosure_styles();
|
|
3759
|
-
return function injectCss() {
|
|
3760
|
-
if (typeof document === "undefined") return;
|
|
3761
|
-
var id = "wb-addon-" + DOMAIN + "-actions-css";
|
|
3762
|
-
var old = document.getElementById(id);
|
|
3763
|
-
if (old) {
|
|
3764
|
-
old.textContent = CSS;
|
|
3765
|
-
return;
|
|
3766
|
-
}
|
|
3767
|
-
var style = document.createElement("style");
|
|
3768
|
-
style.id = id;
|
|
3769
|
-
style.setAttribute("data-wb-addon", "wb-addon-" + DOMAIN);
|
|
3770
|
-
style.textContent = CSS;
|
|
3771
|
-
document.head.appendChild(style);
|
|
3772
|
-
};
|
|
3773
|
-
};
|
|
3774
|
-
}
|
|
3775
|
-
});
|
|
3776
|
-
|
|
3777
|
-
// packages/addons/lib/action-schema-view.cjs
|
|
3778
|
-
var require_action_schema_view = __commonJS({
|
|
3779
|
-
"packages/addons/lib/action-schema-view.cjs"(exports2, module2) {
|
|
3780
|
-
"use strict";
|
|
3781
|
-
var React = require("react");
|
|
3782
|
-
var createHighlight = require_highlight()(React);
|
|
3783
|
-
var Disclosure = require_disclosure().createDisclosure(React).Disclosure;
|
|
3784
|
-
var h = React.createElement;
|
|
3785
|
-
var COPY = {
|
|
3786
|
-
zh: {
|
|
3787
|
-
title: "Action",
|
|
3788
|
-
hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
|
|
3789
|
-
switchHint: "\u5141\u8BB8\u6765\u6E90\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1A\u52FE\u4E0A\u7684\u6765\u6E90\u624D\u80FD\u8C03\u7528\u8BE5 action\uFF0C\u5176\u4F59\u4F1A\u88AB ACTION_ORIGIN_DENIED \u62E6\u4E0B\u3002",
|
|
3790
|
-
hostHint: "\u5BBF\u4E3B action \u7684\u5141\u8BB8\u6765\u6E90\uFF1B\u6807\u300C\u6765\u6E90\u56FA\u5B9A\u300D\u7684\u4E0D\u53EF\u4FEE\u6539\u3002",
|
|
3791
|
-
originsLabel: "\u5141\u8BB8\u6765\u6E90",
|
|
3792
|
-
originUi: "\u754C\u9762",
|
|
3793
|
-
originPlugin: "\u63D2\u4EF6",
|
|
3794
|
-
originAgent: "agent",
|
|
3795
|
-
originSync: "\u540C\u6B65",
|
|
3796
|
-
originsSaving: "\u4FDD\u5B58\u4E2D\u2026",
|
|
3797
|
-
originsToast: "\u5DF2\u66F4\u65B0\u5141\u8BB8\u6765\u6E90",
|
|
3798
|
-
originsFail: "\u66F4\u65B0\u5141\u8BB8\u6765\u6E90\u5931\u8D25",
|
|
3799
|
-
originsEmpty: "\u81F3\u5C11\u8981\u4FDD\u7559\u4E00\u4E2A\u6765\u6E90",
|
|
3800
|
-
originsUnsupported: "\u8BE5 action \u672C\u8EAB\u4E0D\u652F\u6301\u8FD9\u4E2A\u6765\u6E90",
|
|
3801
|
-
originsPinned: "\u6765\u6E90\u56FA\u5B9A",
|
|
3802
|
-
originsPinnedHint: "\u8BE5 action \u7684\u5141\u8BB8\u6765\u6E90\u88AB\u56FA\u5B9A\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539",
|
|
3803
|
-
domain: "\u57DF",
|
|
3804
|
-
versionLabel: "\u7248\u672C",
|
|
3805
|
-
shell: "\u5BBF\u4E3B",
|
|
3806
|
-
count: function(shown, total) {
|
|
3807
|
-
return shown + " / " + total + " \u4E2A action";
|
|
3808
|
-
},
|
|
3809
|
-
search: "\u641C\u7D22\u540D\u79F0\u3001\u63CF\u8FF0\u3001\u53C2\u6570\uFF08\u547D\u4E2D\u5904\u9AD8\u4EAE\uFF09",
|
|
3810
|
-
filterReq: "\u5FC5\u586B\u7B5B\u9009",
|
|
3811
|
-
all: "\u5168\u90E8",
|
|
3812
|
-
onlyRequired: "\u542B\u5FC5\u586B\u9879",
|
|
3813
|
-
onlyOptional: "\u65E0\u5FC5\u586B\u9879",
|
|
3814
|
-
filterType: "\u53C2\u6570\u7C7B\u578B",
|
|
3815
|
-
allTypes: "\u5168\u90E8\u7C7B\u578B",
|
|
3816
|
-
filterOrigin: "\u5141\u8BB8\u6765\u6E90",
|
|
3817
|
-
allOrigins: "\u5168\u90E8\u6765\u6E90",
|
|
3818
|
-
colName: "\u53C2\u6570",
|
|
3819
|
-
colType: "\u7C7B\u578B",
|
|
3820
|
-
colReq: "\u5FC5\u586B",
|
|
3821
|
-
colExtra: "\u9ED8\u8BA4 / \u679A\u4E3E / \u7EA6\u675F",
|
|
3822
|
-
colDesc: "\u8BF4\u660E",
|
|
3823
|
-
required: "\u5FC5\u586B",
|
|
3824
|
-
optional: "\u53EF\u9009",
|
|
3825
|
-
noParams: "\u65E0\u53C2\u6570",
|
|
3826
|
-
paramCount: function(n) {
|
|
3827
|
-
return n + " \u4E2A\u53C2\u6570";
|
|
3828
|
-
},
|
|
3829
|
-
params: "\u53C2\u6570",
|
|
3830
|
-
requiredCount: function(n) {
|
|
3831
|
-
return "\u5FC5\u586B " + n;
|
|
3832
|
-
},
|
|
3833
|
-
examples: "\u793A\u4F8B",
|
|
3834
|
-
noExamples: "\u65E0\u793A\u4F8B",
|
|
3835
|
-
copy: "\u590D\u5236",
|
|
3836
|
-
copied: "\u5DF2\u590D\u5236",
|
|
3837
|
-
raw: "\u539F\u59CB JSON Schema",
|
|
3838
|
-
loading: "\u8F7D\u5165\u4E2D\u2026",
|
|
3839
|
-
loadFail: "\u8BFB\u53D6 action schema \u5931\u8D25",
|
|
3840
|
-
retry: "\u91CD\u8BD5",
|
|
3841
|
-
empty: "\u6CA1\u6709\u5339\u914D\u7684 action",
|
|
3842
|
-
emptyRegistry: "\u8BE5\u57DF\u6CA1\u6709\u6CE8\u518C action",
|
|
3843
|
-
envelope: "\u9ED8\u8BA4",
|
|
3844
|
-
enumLabel: "\u679A\u4E3E",
|
|
3845
|
-
range: "\u8303\u56F4",
|
|
3846
|
-
length: "\u957F\u5EA6",
|
|
3847
|
-
pattern: "\u6B63\u5219",
|
|
3848
|
-
format: "\u683C\u5F0F",
|
|
3849
|
-
items: "\u5143\u7D20\u6570"
|
|
3850
|
-
},
|
|
3851
|
-
en: {
|
|
3852
|
-
title: "Actions",
|
|
3853
|
-
hint: "runtime registry \xB7 read-only",
|
|
3854
|
-
switchHint: "Allowed origins are stored locally and apply immediately: only checked origins may call the action; others get ACTION_ORIGIN_DENIED.",
|
|
3855
|
-
hostHint: "Allowed origins for host actions; items marked pinned cannot be changed.",
|
|
3856
|
-
originsLabel: "Origins",
|
|
3857
|
-
originUi: "UI",
|
|
3858
|
-
originPlugin: "Plugin",
|
|
3859
|
-
originAgent: "Agent",
|
|
3860
|
-
originSync: "Sync",
|
|
3861
|
-
originsSaving: "Saving\u2026",
|
|
3862
|
-
originsToast: "Allowed origins updated",
|
|
3863
|
-
originsFail: "Failed to update allowed origins",
|
|
3864
|
-
originsEmpty: "Keep at least one origin",
|
|
3865
|
-
originsUnsupported: "This action does not support this origin",
|
|
3866
|
-
originsPinned: "Pinned",
|
|
3867
|
-
originsPinnedHint: "Allowed origins are pinned for this action (security constraint) and cannot be changed",
|
|
3868
|
-
originsDefaultOn: "Allowed by default",
|
|
3869
|
-
originsDefaultOff: "Off by default, can be enabled",
|
|
3870
|
-
domain: "Domain",
|
|
3871
|
-
versionLabel: "Version",
|
|
3872
|
-
shell: "Host",
|
|
3873
|
-
count: function(shown, total) {
|
|
3874
|
-
return shown + " / " + total + " actions";
|
|
3875
|
-
},
|
|
3876
|
-
search: "Search name, description, params (matches highlighted)",
|
|
3877
|
-
filterReq: "Required",
|
|
3878
|
-
all: "All",
|
|
3879
|
-
onlyRequired: "Has required",
|
|
3880
|
-
onlyOptional: "No required",
|
|
3881
|
-
filterType: "Param type",
|
|
3882
|
-
allTypes: "All types",
|
|
3883
|
-
filterOrigin: "Origins",
|
|
3884
|
-
allOrigins: "All origins",
|
|
3885
|
-
colName: "Param",
|
|
3886
|
-
colType: "Type",
|
|
3887
|
-
colReq: "Required",
|
|
3888
|
-
colExtra: "Default / enum / constraints",
|
|
3889
|
-
colDesc: "Description",
|
|
3890
|
-
required: "required",
|
|
3891
|
-
optional: "optional",
|
|
3892
|
-
noParams: "No parameters",
|
|
3893
|
-
paramCount: function(n) {
|
|
3894
|
-
return n + " params";
|
|
3895
|
-
},
|
|
3896
|
-
params: "Parameters",
|
|
3897
|
-
requiredCount: function(n) {
|
|
3898
|
-
return n + " required";
|
|
3899
|
-
},
|
|
3900
|
-
examples: "Examples",
|
|
3901
|
-
noExamples: "No examples",
|
|
3902
|
-
copy: "Copy",
|
|
3903
|
-
copied: "Copied",
|
|
3904
|
-
raw: "Raw JSON Schema",
|
|
3905
|
-
loading: "Loading\u2026",
|
|
3906
|
-
loadFail: "Failed to read action schema",
|
|
3907
|
-
retry: "Retry",
|
|
3908
|
-
empty: "No matching action",
|
|
3909
|
-
emptyRegistry: "This domain has no registered action",
|
|
3910
|
-
envelope: "Default",
|
|
3911
|
-
enumLabel: "Enum",
|
|
3912
|
-
range: "Range",
|
|
3913
|
-
length: "Length",
|
|
3914
|
-
pattern: "Pattern",
|
|
3915
|
-
format: "Format",
|
|
3916
|
-
items: "Items"
|
|
3917
|
-
}
|
|
3918
|
-
};
|
|
3919
|
-
function typeLabel(schema) {
|
|
3920
|
-
if (!schema || typeof schema !== "object") return "";
|
|
3921
|
-
if (Array.isArray(schema.type)) return schema.type.join(" | ");
|
|
3922
|
-
if (typeof schema.type === "string") {
|
|
3923
|
-
if (schema.type === "array" && schema.items) {
|
|
3924
|
-
var inner = typeLabel(schema.items);
|
|
3925
|
-
return inner ? inner + "[]" : "array";
|
|
3926
|
-
}
|
|
3927
|
-
return schema.type;
|
|
3928
|
-
}
|
|
3929
|
-
if (Array.isArray(schema.oneOf)) return schema.oneOf.map(typeLabel).filter(Boolean).join(" | ");
|
|
3930
|
-
if (Array.isArray(schema.anyOf)) return schema.anyOf.map(typeLabel).filter(Boolean).join(" | ");
|
|
3931
|
-
return "";
|
|
3932
|
-
}
|
|
3933
|
-
function typeNames(schema) {
|
|
3934
|
-
var label = typeLabel(schema);
|
|
3935
|
-
if (!label) return [];
|
|
3936
|
-
return label.split("|").map(function(x) {
|
|
3937
|
-
return x.trim().replace(/\[\]$/, "");
|
|
3938
|
-
}).filter(Boolean);
|
|
3939
|
-
}
|
|
3940
|
-
function scalar(value) {
|
|
3941
|
-
if (typeof value === "string") return JSON.stringify(value);
|
|
3942
|
-
return String(value);
|
|
3943
|
-
}
|
|
3944
|
-
function extraText(schema, t) {
|
|
3945
|
-
if (!schema || typeof schema !== "object") return "";
|
|
3946
|
-
var parts = [];
|
|
3947
|
-
if (Object.prototype.hasOwnProperty.call(schema, "default")) {
|
|
3948
|
-
parts.push(t.envelope + " " + scalar(schema.default));
|
|
3949
|
-
}
|
|
3950
|
-
if (Array.isArray(schema.enum)) {
|
|
3951
|
-
parts.push(t.enumLabel + " " + schema.enum.map(scalar).join(" / "));
|
|
3952
|
-
}
|
|
3953
|
-
if (typeof schema.minimum === "number" || typeof schema.maximum === "number") {
|
|
3954
|
-
var lo = typeof schema.minimum === "number" ? schema.minimum : null;
|
|
3955
|
-
var hi = typeof schema.maximum === "number" ? schema.maximum : null;
|
|
3956
|
-
if (lo !== null && hi !== null) parts.push(t.range + " \u2265" + lo + " \u4E14 \u2264" + hi);
|
|
3957
|
-
else if (lo !== null) parts.push(t.range + " \u2265" + lo);
|
|
3958
|
-
else parts.push(t.range + " \u2264" + hi);
|
|
3959
|
-
}
|
|
3960
|
-
if (typeof schema.minLength === "number" || typeof schema.maxLength === "number") {
|
|
3961
|
-
parts.push(t.length + " " + (schema.minLength ?? 0) + "\u2013" + (schema.maxLength ?? "\u221E"));
|
|
3962
|
-
}
|
|
3963
|
-
if (typeof schema.minItems === "number" || typeof schema.maxItems === "number") {
|
|
3964
|
-
parts.push(t.items + " " + (schema.minItems ?? 0) + "\u2013" + (schema.maxItems ?? "\u221E"));
|
|
3965
|
-
}
|
|
3966
|
-
if (typeof schema.pattern === "string") parts.push(t.pattern + " " + schema.pattern);
|
|
3967
|
-
if (typeof schema.format === "string") parts.push(t.format + " " + schema.format);
|
|
3968
|
-
return parts.join(" \xB7 ");
|
|
3969
|
-
}
|
|
3970
|
-
function paramRows(action) {
|
|
3971
|
-
var input = action && action.input && typeof action.input === "object" ? action.input : {};
|
|
3972
|
-
var props = input.properties && typeof input.properties === "object" ? input.properties : {};
|
|
3973
|
-
var required = Array.isArray(input.required) ? input.required : [];
|
|
3974
|
-
return Object.keys(props).map(function(key) {
|
|
3975
|
-
var schema = props[key] && typeof props[key] === "object" ? props[key] : {};
|
|
3976
|
-
return {
|
|
3977
|
-
name: key,
|
|
3978
|
-
schema,
|
|
3979
|
-
type: typeLabel(schema),
|
|
3980
|
-
types: typeNames(schema),
|
|
3981
|
-
required: required.indexOf(key) >= 0,
|
|
3982
|
-
description: typeof schema.description === "string" ? schema.description : ""
|
|
3983
|
-
};
|
|
3984
|
-
});
|
|
3985
|
-
}
|
|
3986
|
-
module2.exports = function createActionSchemaView(options) {
|
|
3987
|
-
var raw = String(options.domain || "");
|
|
3988
|
-
var SOURCE = options.source === "actions.list" ? "actions.list" : "actionSchema";
|
|
3989
|
-
var DOMAIN = SOURCE === "actions.list" ? raw : raw.indexOf("wb-addon-") === 0 ? raw : "wb-addon-" + raw;
|
|
3990
|
-
var LIST_DOMAIN = options.listDomain ? String(options.listDomain) : DOMAIN;
|
|
3991
|
-
var prefix = options.prefix;
|
|
3992
|
-
var P = prefix + "-as";
|
|
3993
|
-
var Icon2 = options.Icon || null;
|
|
3994
|
-
var injectCss = require_action_schema_style()(prefix, DOMAIN);
|
|
3995
|
-
var Highlight = createHighlight(P);
|
|
3996
|
-
function icon(name, size) {
|
|
3997
|
-
return Icon2 ? h(Icon2, { name, size: size || 14 }) : null;
|
|
3998
|
-
}
|
|
3999
|
-
function plainCopy(text) {
|
|
4000
|
-
if (typeof document === "undefined") return;
|
|
4001
|
-
var area = document.createElement("textarea");
|
|
4002
|
-
area.value = text;
|
|
4003
|
-
area.setAttribute("readonly", "readonly");
|
|
4004
|
-
area.style.position = "fixed";
|
|
4005
|
-
area.style.opacity = "0";
|
|
4006
|
-
document.body.appendChild(area);
|
|
4007
|
-
area.select();
|
|
4008
|
-
try {
|
|
4009
|
-
document.execCommand("copy");
|
|
4010
|
-
} catch (e) {
|
|
4011
|
-
}
|
|
4012
|
-
document.body.removeChild(area);
|
|
4013
|
-
}
|
|
4014
|
-
function ActionSchemaView(props) {
|
|
4015
|
-
var lang = props.lang === "en" ? "en" : "zh";
|
|
4016
|
-
var t = COPY[lang];
|
|
4017
|
-
var api = props.api;
|
|
4018
|
-
var snapState = React.useState(null);
|
|
4019
|
-
var snap = snapState[0], setSnap = snapState[1];
|
|
4020
|
-
var errState = React.useState("");
|
|
4021
|
-
var err = errState[0], setErr = errState[1];
|
|
4022
|
-
var loadingState = React.useState(true);
|
|
4023
|
-
var loading = loadingState[0], setLoading = loadingState[1];
|
|
4024
|
-
var reloadState = React.useState(0);
|
|
4025
|
-
var reload = reloadState[0], setReload = reloadState[1];
|
|
4026
|
-
var queryState = React.useState("");
|
|
4027
|
-
var query = queryState[0], setQuery = queryState[1];
|
|
4028
|
-
var reqState = React.useState("all");
|
|
4029
|
-
var reqMode = reqState[0], setReqMode = reqState[1];
|
|
4030
|
-
var typeState = React.useState("");
|
|
4031
|
-
var typePick = typeState[0], setTypePick = typeState[1];
|
|
4032
|
-
var originFilterState = React.useState("");
|
|
4033
|
-
var originPick = originFilterState[0], setOriginPick = originFilterState[1];
|
|
4034
|
-
var toastState = React.useState("");
|
|
4035
|
-
var toast = toastState[0], setToast = toastState[1];
|
|
4036
|
-
var savingState = React.useState("");
|
|
4037
|
-
var saving = savingState[0], setSaving = savingState[1];
|
|
4038
|
-
var foldsState = React.useState({});
|
|
4039
|
-
var folds = foldsState[0], setFolds = foldsState[1];
|
|
4040
|
-
React.useEffect(function() {
|
|
4041
|
-
injectCss();
|
|
4042
|
-
}, []);
|
|
4043
|
-
React.useEffect(function() {
|
|
4044
|
-
var alive = true;
|
|
4045
|
-
setLoading(true);
|
|
4046
|
-
setErr("");
|
|
4047
|
-
var pending;
|
|
4048
|
-
var actionName = SOURCE === "actions.list" ? "actions.list" : DOMAIN.replace(/^wb-addon-/, "") + ".actionSchema";
|
|
4049
|
-
var callArgs = SOURCE === "actions.list" ? { detail: true, domain: LIST_DOMAIN } : void 0;
|
|
4050
|
-
if (api && typeof api.call === "function") {
|
|
4051
|
-
pending = Promise.resolve(api.call(actionName, callArgs)).then(function(r) {
|
|
4052
|
-
if (r && r.ok === false) return r;
|
|
4053
|
-
return r && r.result || r;
|
|
4054
|
-
});
|
|
4055
|
-
} else {
|
|
4056
|
-
pending = Promise.reject(new Error("no call api"));
|
|
4057
|
-
}
|
|
4058
|
-
Promise.resolve(pending).then(function(r) {
|
|
4059
|
-
if (!alive) return;
|
|
4060
|
-
if (!r || r.ok === false) {
|
|
4061
|
-
setSnap(null);
|
|
4062
|
-
setErr(String(r && (r.error || r.text) || t.loadFail));
|
|
4063
|
-
} else {
|
|
4064
|
-
setSnap(r);
|
|
4065
|
-
}
|
|
4066
|
-
setLoading(false);
|
|
4067
|
-
}, function(e) {
|
|
4068
|
-
if (!alive) return;
|
|
4069
|
-
setSnap(null);
|
|
4070
|
-
setErr(String(e && e.message || e || t.loadFail));
|
|
4071
|
-
setLoading(false);
|
|
4072
|
-
});
|
|
4073
|
-
return function() {
|
|
4074
|
-
alive = false;
|
|
4075
|
-
};
|
|
4076
|
-
}, [reload]);
|
|
4077
|
-
function copy(text) {
|
|
4078
|
-
var done = function() {
|
|
4079
|
-
setToast(t.copied);
|
|
4080
|
-
};
|
|
4081
|
-
if (typeof navigator !== "undefined" && navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
|
|
4082
|
-
navigator.clipboard.writeText(text).then(done, function() {
|
|
4083
|
-
plainCopy(text);
|
|
4084
|
-
done();
|
|
4085
|
-
});
|
|
4086
|
-
return;
|
|
4087
|
-
}
|
|
4088
|
-
plainCopy(text);
|
|
4089
|
-
done();
|
|
4090
|
-
}
|
|
4091
|
-
var ORIGINS = ["ui", "plugin", "agent", "sync"];
|
|
4092
|
-
var originText = { ui: t.originUi, plugin: t.originPlugin, agent: t.originAgent, sync: t.originSync };
|
|
4093
|
-
function setOrigins(action, origin) {
|
|
4094
|
-
var name = action.name;
|
|
4095
|
-
var current = Array.isArray(action.origins) ? action.origins.slice() : [];
|
|
4096
|
-
var index = current.indexOf(origin);
|
|
4097
|
-
var next = index >= 0 ? current.filter(function(o) {
|
|
4098
|
-
return o !== origin;
|
|
4099
|
-
}) : current.concat([origin]);
|
|
4100
|
-
if (next.length === 0) {
|
|
4101
|
-
setToast(t.originsEmpty);
|
|
4102
|
-
return;
|
|
4103
|
-
}
|
|
4104
|
-
next = ORIGINS.filter(function(o) {
|
|
4105
|
-
return next.indexOf(o) >= 0;
|
|
4106
|
-
});
|
|
4107
|
-
setSaving(name);
|
|
4108
|
-
setToast("");
|
|
4109
|
-
var fail = function(e) {
|
|
4110
|
-
setSaving("");
|
|
4111
|
-
setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
|
|
4112
|
-
};
|
|
4113
|
-
var done = function(r) {
|
|
4114
|
-
setSaving("");
|
|
4115
|
-
var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
|
|
4116
|
-
if (r && r.ok === false) {
|
|
4117
|
-
setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
|
|
4118
|
-
return;
|
|
4119
|
-
}
|
|
4120
|
-
var value = payload && Array.isArray(payload.origins) ? payload.origins : next;
|
|
4121
|
-
var source = payload && typeof payload.source === "string" ? payload.source : action.originsSource;
|
|
4122
|
-
setSnap(function(prev) {
|
|
4123
|
-
if (!prev || !Array.isArray(prev.actions)) return prev;
|
|
4124
|
-
return Object.assign({}, prev, {
|
|
4125
|
-
actions: prev.actions.map(function(a) {
|
|
4126
|
-
if (!a || a.name !== name) return a;
|
|
4127
|
-
return Object.assign({}, a, { origins: value, originsSource: source });
|
|
4128
|
-
})
|
|
4129
|
-
});
|
|
4130
|
-
});
|
|
4131
|
-
setToast(t.originsToast);
|
|
4132
|
-
};
|
|
4133
|
-
if (!api || typeof api.call !== "function") {
|
|
4134
|
-
fail(new Error("no call api"));
|
|
4135
|
-
return;
|
|
4136
|
-
}
|
|
4137
|
-
Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
|
|
4138
|
-
}
|
|
4139
|
-
function paramsOpen(action) {
|
|
4140
|
-
if (Object.prototype.hasOwnProperty.call(folds, action.name)) return folds[action.name] === true;
|
|
4141
|
-
return Boolean(String(query || "").trim()) || reqMode !== "all" || Boolean(typePick);
|
|
4142
|
-
}
|
|
4143
|
-
function resetFolds() {
|
|
4144
|
-
setFolds(function(prev) {
|
|
4145
|
-
return Object.keys(prev).length ? {} : prev;
|
|
4146
|
-
});
|
|
4147
|
-
}
|
|
4148
|
-
var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
|
|
4149
|
-
return a && a.domain === DOMAIN;
|
|
4150
|
-
}) : [];
|
|
4151
|
-
var info = snap && Array.isArray(snap.domains) ? snap.domains.filter(function(d) {
|
|
4152
|
-
return d && d.id === DOMAIN;
|
|
4153
|
-
})[0] || null : null;
|
|
4154
|
-
var typeOptions = [];
|
|
4155
|
-
all.forEach(function(a) {
|
|
4156
|
-
paramRows(a).forEach(function(row) {
|
|
4157
|
-
row.types.forEach(function(name) {
|
|
4158
|
-
if (typeOptions.indexOf(name) < 0) typeOptions.push(name);
|
|
4159
|
-
});
|
|
4160
|
-
});
|
|
4161
|
-
});
|
|
4162
|
-
typeOptions.sort();
|
|
4163
|
-
var kw = String(query || "").trim();
|
|
4164
|
-
var q = kw.toLowerCase();
|
|
4165
|
-
var visible = all.filter(function(a) {
|
|
4166
|
-
var rows = paramRows(a);
|
|
4167
|
-
if (q) {
|
|
4168
|
-
var hay = [a.name || "", a.description || ""].concat(rows.map(function(row) {
|
|
4169
|
-
return row.name + " " + row.type + " " + row.description;
|
|
4170
|
-
})).join(" ").toLowerCase();
|
|
4171
|
-
if (hay.indexOf(q) < 0) return false;
|
|
4172
|
-
}
|
|
4173
|
-
var hasRequired = rows.some(function(row) {
|
|
4174
|
-
return row.required;
|
|
4175
|
-
});
|
|
4176
|
-
if (reqMode === "required" && !hasRequired) return false;
|
|
4177
|
-
if (reqMode === "optional" && hasRequired) return false;
|
|
4178
|
-
if (typePick && !rows.some(function(row) {
|
|
4179
|
-
return row.types.indexOf(typePick) >= 0;
|
|
4180
|
-
})) return false;
|
|
4181
|
-
if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
|
|
4182
|
-
return true;
|
|
4183
|
-
});
|
|
4184
|
-
function paramRow(row) {
|
|
4185
|
-
var extra = extraText(row.schema, t);
|
|
4186
|
-
return h(
|
|
4187
|
-
"tr",
|
|
4188
|
-
{ key: row.name },
|
|
4189
|
-
h("td", { className: P + "-mono " + P + "-pname" }, Highlight.hit(row.name, kw)),
|
|
4190
|
-
h("td", { className: P + "-mono " + P + "-ptype" }, Highlight.hit(row.type, kw)),
|
|
4191
|
-
h(
|
|
4192
|
-
"td",
|
|
4193
|
-
{ className: row.required ? P + "-req " + P + "-pneed" : P + "-opt " + P + "-pneed" },
|
|
4194
|
-
row.required ? t.required : t.optional
|
|
4195
|
-
),
|
|
4196
|
-
// extra(默认 / 枚举 / 约束)不在过滤 haystack 里,因此也不高亮,保持「显示即命中」口径。
|
|
4197
|
-
h("td", { className: P + "-mono " + P + "-pextra" }, extra),
|
|
4198
|
-
h("td", { className: P + "-pdesc" }, Highlight.hit(row.description, kw))
|
|
4199
|
-
);
|
|
4200
|
-
}
|
|
4201
|
-
function originsChips(action) {
|
|
4202
|
-
if (!Array.isArray(action.origins)) return null;
|
|
4203
|
-
if (action.originsSource === "invalid") {
|
|
4204
|
-
return h("span", { className: P + "-badge " + P + "-locked", title: t.originsPinnedHint, "data-origins-invalid": action.name }, t.originsPinned);
|
|
4205
|
-
}
|
|
4206
|
-
var busy = saving === action.name;
|
|
4207
|
-
var pinned = action.name === "actions.setActionOrigins";
|
|
4208
|
-
var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
|
|
4209
|
-
return h(
|
|
4210
|
-
"div",
|
|
4211
|
-
{ className: P + "-origins", "data-origins-row": action.name },
|
|
4212
|
-
h("span", { className: P + "-origins-label" }, t.originsLabel),
|
|
4213
|
-
ORIGINS.map(function(origin) {
|
|
4214
|
-
var on = action.origins.indexOf(origin) >= 0;
|
|
4215
|
-
var allowed = supported.indexOf(origin) >= 0;
|
|
4216
|
-
var preset = Array.isArray(action.originsDefault) ? action.originsDefault : supported;
|
|
4217
|
-
var byDefault = preset.indexOf(origin) >= 0;
|
|
4218
|
-
return h(
|
|
4219
|
-
"label",
|
|
4220
|
-
{
|
|
4221
|
-
key: origin,
|
|
4222
|
-
className: P + "-origin" + (allowed ? "" : " " + P + "-origin-off"),
|
|
4223
|
-
title: pinned ? t.originsPinnedHint : !allowed ? t.originsUnsupported : originText[origin] + " \xB7 " + action.name + " \xB7 " + (byDefault ? t.originsDefaultOn : t.originsDefaultOff)
|
|
4224
|
-
},
|
|
4225
|
-
h("input", {
|
|
4226
|
-
type: "checkbox",
|
|
4227
|
-
checked: on,
|
|
4228
|
-
disabled: busy || pinned || !allowed,
|
|
4229
|
-
"data-origin": origin,
|
|
4230
|
-
"data-origin-row": action.name,
|
|
4231
|
-
"data-origin-supported": allowed ? "1" : "0",
|
|
4232
|
-
onChange: function() {
|
|
4233
|
-
setOrigins(action, origin);
|
|
4234
|
-
}
|
|
4235
|
-
}),
|
|
4236
|
-
h("span", null, originText[origin])
|
|
4237
|
-
);
|
|
4238
|
-
}),
|
|
4239
|
-
busy ? h("span", { className: P + "-origins-label" }, t.originsSaving) : null
|
|
4240
|
-
);
|
|
4241
|
-
}
|
|
4242
|
-
function card(action) {
|
|
4243
|
-
var rows = paramRows(action);
|
|
4244
|
-
var required = rows.filter(function(row) {
|
|
4245
|
-
return row.required;
|
|
4246
|
-
}).length;
|
|
4247
|
-
var open = paramsOpen(action);
|
|
4248
|
-
var examples = Array.isArray(action.examples) ? action.examples : [];
|
|
4249
|
-
return h(
|
|
4250
|
-
"div",
|
|
4251
|
-
{ className: P + "-card", key: action.name },
|
|
4252
|
-
h(
|
|
4253
|
-
"div",
|
|
4254
|
-
{ className: P + "-cardhead" },
|
|
4255
|
-
h(
|
|
4256
|
-
"div",
|
|
4257
|
-
{ className: P + "-cardmeta" },
|
|
4258
|
-
h("code", { className: P + "-mono" }, Highlight.hit(action.name, kw)),
|
|
4259
|
-
h("span", { className: P + "-badge" }, rows.length ? t.paramCount(rows.length) : t.noParams),
|
|
4260
|
-
rows.some(function(row) {
|
|
4261
|
-
return row.required;
|
|
4262
|
-
}) ? h("span", { className: P + "-badge " + P + "-req" }, t.required) : null
|
|
4263
|
-
),
|
|
4264
|
-
originsChips(action)
|
|
4265
|
-
),
|
|
4266
|
-
action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
|
|
4267
|
-
rows.length ? h(
|
|
4268
|
-
Disclosure,
|
|
4269
|
-
{
|
|
4270
|
-
className: P + "-params",
|
|
4271
|
-
title: t.params,
|
|
4272
|
-
meta: required ? t.requiredCount(required) : "",
|
|
4273
|
-
attrs: { "data-params-fold": action.name },
|
|
4274
|
-
open,
|
|
4275
|
-
// 原生 details 自带键盘与无障碍语义,这里只记下用户的开合;
|
|
4276
|
-
// 筛选变化引起的程序性开合也会触发 toggle,记下的值与当次默认一致,随后由 resetFolds 清掉。
|
|
4277
|
-
onToggle: function(e) {
|
|
4278
|
-
var next = !!(e && e.currentTarget && e.currentTarget.open);
|
|
4279
|
-
setFolds(function(prev) {
|
|
4280
|
-
if (prev[action.name] === next) return prev;
|
|
4281
|
-
var out = Object.assign({}, prev);
|
|
4282
|
-
out[action.name] = next;
|
|
4283
|
-
return out;
|
|
4284
|
-
});
|
|
4285
|
-
}
|
|
4286
|
-
},
|
|
4287
|
-
h(
|
|
4288
|
-
"table",
|
|
4289
|
-
{ className: P + "-table" },
|
|
4290
|
-
h("thead", null, h(
|
|
4291
|
-
"tr",
|
|
4292
|
-
null,
|
|
4293
|
-
h("th", null, t.colName),
|
|
4294
|
-
h("th", null, t.colType),
|
|
4295
|
-
h("th", null, t.colReq),
|
|
4296
|
-
h("th", null, t.colExtra),
|
|
4297
|
-
h("th", null, t.colDesc)
|
|
4298
|
-
)),
|
|
4299
|
-
h("tbody", null, rows.map(paramRow))
|
|
4300
|
-
)
|
|
4301
|
-
) : h("div", { className: P + "-none" }, t.noParams),
|
|
4302
|
-
h(
|
|
4303
|
-
"div",
|
|
4304
|
-
{ className: P + "-example" },
|
|
4305
|
-
h(
|
|
4306
|
-
"div",
|
|
4307
|
-
{ className: P + "-examplehead" },
|
|
4308
|
-
h("span", { className: P + "-none" }, t.examples),
|
|
4309
|
-
examples.length ? h("button", {
|
|
4310
|
-
type: "button",
|
|
4311
|
-
className: P + "-copy",
|
|
4312
|
-
"data-copy-example": action.name,
|
|
4313
|
-
onClick: function() {
|
|
4314
|
-
copy(JSON.stringify(examples.length === 1 ? examples[0] : examples, null, 2));
|
|
4315
|
-
}
|
|
4316
|
-
}, t.copy) : null
|
|
4317
|
-
),
|
|
4318
|
-
examples.length ? examples.map(function(example, index) {
|
|
4319
|
-
return h("pre", { className: P + "-pre", key: index }, JSON.stringify(example, null, 2));
|
|
4320
|
-
}) : h("div", { className: P + "-none" }, t.noExamples)
|
|
4321
|
-
),
|
|
4322
|
-
h(
|
|
4323
|
-
Disclosure,
|
|
4324
|
-
{ title: t.raw },
|
|
4325
|
-
h("pre", { className: P + "-pre" }, JSON.stringify(action.input || {}, null, 2))
|
|
4326
|
-
)
|
|
4327
|
-
);
|
|
4328
|
-
}
|
|
4329
|
-
var body;
|
|
4330
|
-
if (loading) {
|
|
4331
|
-
body = h("div", { className: P + "-empty", role: "status" }, t.loading);
|
|
4332
|
-
} else if (err) {
|
|
4333
|
-
body = h(
|
|
4334
|
-
"div",
|
|
4335
|
-
{ className: P + "-error", role: "alert" },
|
|
4336
|
-
h("span", null, t.loadFail + "\uFF1A" + err),
|
|
4337
|
-
h("button", { type: "button", className: P + "-copy", onClick: function() {
|
|
4338
|
-
setReload(reload + 1);
|
|
4339
|
-
} }, t.retry)
|
|
4340
|
-
);
|
|
4341
|
-
} else if (!all.length) {
|
|
4342
|
-
body = h("div", { className: P + "-empty" }, t.emptyRegistry);
|
|
4343
|
-
} else if (!visible.length) {
|
|
4344
|
-
body = h("div", { className: P + "-empty" }, t.empty);
|
|
4345
|
-
} else {
|
|
4346
|
-
body = h("div", { className: P + "-list" }, visible.map(card));
|
|
4347
|
-
}
|
|
4348
|
-
return h(
|
|
4349
|
-
"div",
|
|
4350
|
-
{ className: P },
|
|
4351
|
-
h(
|
|
4352
|
-
"div",
|
|
4353
|
-
{ className: P + "-head" },
|
|
4354
|
-
h("h3", { className: P + "-title" }, t.title),
|
|
4355
|
-
h("span", { className: P + "-badge" }, t.domain + " " + DOMAIN),
|
|
4356
|
-
info && info.version ? h("span", { className: P + "-badge" }, t.versionLabel + " v" + info.version) : null,
|
|
4357
|
-
snap && snap.shellVersion ? h("span", { className: P + "-badge" }, t.shell + " v" + snap.shellVersion) : null,
|
|
4358
|
-
h("span", { className: P + "-badge" }, t.count(visible.length, all.length)),
|
|
4359
|
-
h("span", { className: P + "-none" }, t.hint)
|
|
4360
|
-
),
|
|
4361
|
-
h("p", { className: P + "-hintline" }, SOURCE === "actions.list" ? t.hostHint : t.switchHint),
|
|
4362
|
-
snap ? h(
|
|
4363
|
-
"div",
|
|
4364
|
-
{ className: P + "-toolbar" },
|
|
4365
|
-
h(
|
|
4366
|
-
"label",
|
|
4367
|
-
{ className: P + "-search" },
|
|
4368
|
-
icon("search", 14),
|
|
4369
|
-
h("input", {
|
|
4370
|
-
type: "search",
|
|
4371
|
-
value: query,
|
|
4372
|
-
placeholder: t.search,
|
|
4373
|
-
"aria-label": t.search,
|
|
4374
|
-
onChange: function(e) {
|
|
4375
|
-
setQuery(e.target.value);
|
|
4376
|
-
resetFolds();
|
|
4377
|
-
}
|
|
4378
|
-
})
|
|
4379
|
-
),
|
|
4380
|
-
h(
|
|
4381
|
-
"label",
|
|
4382
|
-
{ className: P + "-none" },
|
|
4383
|
-
t.filterReq + " ",
|
|
4384
|
-
h(
|
|
4385
|
-
"select",
|
|
4386
|
-
{ value: reqMode, "aria-label": t.filterReq, onChange: function(e) {
|
|
4387
|
-
setReqMode(e.target.value);
|
|
4388
|
-
resetFolds();
|
|
4389
|
-
} },
|
|
4390
|
-
h("option", { value: "all" }, t.all),
|
|
4391
|
-
h("option", { value: "required" }, t.onlyRequired),
|
|
4392
|
-
h("option", { value: "optional" }, t.onlyOptional)
|
|
4393
|
-
)
|
|
4394
|
-
),
|
|
4395
|
-
h(
|
|
4396
|
-
"label",
|
|
4397
|
-
{ className: P + "-none" },
|
|
4398
|
-
t.filterType + " ",
|
|
4399
|
-
h(
|
|
4400
|
-
"select",
|
|
4401
|
-
{ value: typePick, "aria-label": t.filterType, onChange: function(e) {
|
|
4402
|
-
setTypePick(e.target.value);
|
|
4403
|
-
resetFolds();
|
|
4404
|
-
} },
|
|
4405
|
-
h("option", { value: "" }, t.allTypes),
|
|
4406
|
-
typeOptions.map(function(name) {
|
|
4407
|
-
return h("option", { value: name, key: name }, name);
|
|
4408
|
-
})
|
|
4409
|
-
)
|
|
4410
|
-
),
|
|
4411
|
-
h(
|
|
4412
|
-
"label",
|
|
4413
|
-
{ className: P + "-none" },
|
|
4414
|
-
t.filterOrigin + " ",
|
|
4415
|
-
h(
|
|
4416
|
-
"select",
|
|
4417
|
-
{ value: originPick, "aria-label": t.filterOrigin, "data-origin-filter": "", onChange: function(e) {
|
|
4418
|
-
setOriginPick(e.target.value);
|
|
4419
|
-
} },
|
|
4420
|
-
h("option", { value: "" }, t.allOrigins),
|
|
4421
|
-
ORIGINS.map(function(origin) {
|
|
4422
|
-
return h("option", { value: origin, key: origin }, originText[origin]);
|
|
4423
|
-
})
|
|
4424
|
-
)
|
|
4425
|
-
)
|
|
4426
|
-
) : null,
|
|
4427
|
-
body,
|
|
4428
|
-
toast ? h("div", { className: P + "-toast", role: "status" }, toast) : null
|
|
4429
|
-
);
|
|
4430
|
-
}
|
|
4431
|
-
return { ActionSchemaView, DOMAIN, typeLabel, paramRows };
|
|
4432
|
-
};
|
|
4433
|
-
}
|
|
4434
|
-
});
|
|
4435
|
-
|
|
4436
|
-
// packages/addons/danmaku/client/views/actions.cjs
|
|
4437
|
-
var require_actions = __commonJS({
|
|
4438
|
-
"packages/addons/danmaku/client/views/actions.cjs"(exports2, module2) {
|
|
4439
|
-
"use strict";
|
|
4440
|
-
module2.exports = require_action_schema_view()({
|
|
4441
|
-
domain: "danmaku",
|
|
4442
|
-
prefix: "wbdm"
|
|
4443
|
-
});
|
|
4444
|
-
}
|
|
4445
|
-
});
|
|
4446
|
-
|
|
4447
3580
|
// packages/addons/danmaku/client/client.src.cjs
|
|
4448
3581
|
var GLYPHS = require_icons2().ICONS;
|
|
4449
3582
|
var styles = require_styles();
|
|
@@ -4491,7 +3624,7 @@ function definition(host) {
|
|
|
4491
3624
|
var tab = makeTab(host.react);
|
|
4492
3625
|
return {
|
|
4493
3626
|
id: ADDON_ID,
|
|
4494
|
-
version: "0.3.
|
|
3627
|
+
version: "0.3.3",
|
|
4495
3628
|
icon: tab("megaphone"),
|
|
4496
3629
|
views: [
|
|
4497
3630
|
{
|
|
@@ -4505,12 +3638,6 @@ function definition(host) {
|
|
|
4505
3638
|
icon: tab("settings"),
|
|
4506
3639
|
title: { zh: "\u914D\u7F6E", en: "Settings" },
|
|
4507
3640
|
component: require_config()
|
|
4508
|
-
},
|
|
4509
|
-
{
|
|
4510
|
-
id: "actions",
|
|
4511
|
-
icon: tab("play"),
|
|
4512
|
-
title: { zh: "Action", en: "Actions" },
|
|
4513
|
-
component: require_actions()
|
|
4514
3641
|
}
|
|
4515
3642
|
]
|
|
4516
3643
|
};
|
package/lib/index.js
CHANGED
|
@@ -166,7 +166,6 @@ export function apply(ctx) {
|
|
|
166
166
|
views: [
|
|
167
167
|
{ id: "library", title: { zh: "弹幕库", en: "Library" } },
|
|
168
168
|
{ id: "config", title: { zh: "配置", en: "Config" } },
|
|
169
|
-
{ id: "actions", title: { zh: "Action", en: "Actions" } },
|
|
170
169
|
],
|
|
171
170
|
capability: {
|
|
172
171
|
taskOwnership: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workbench-danmaku",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "个人工作台弹幕插件:把自建弹幕轮播在整个 DSH 界面,并可叠加到整个桌面",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -16,16 +16,15 @@
|
|
|
16
16
|
"addon": {
|
|
17
17
|
"id": "wb-addon-danmaku",
|
|
18
18
|
"title": "弹幕",
|
|
19
|
-
"description": "在整个 DSH
|
|
20
|
-
"version": "0.3.
|
|
19
|
+
"description": "在整个 DSH 界面(含工作台业务页与宿主弹窗之外的所有区域)与桌面透明层轮播自建弹幕;含弹幕库、配置两个视图",
|
|
20
|
+
"version": "0.3.3",
|
|
21
21
|
"minShell": "0.8.0",
|
|
22
22
|
"tables": [
|
|
23
23
|
"danmaku"
|
|
24
24
|
],
|
|
25
25
|
"views": [
|
|
26
26
|
"library",
|
|
27
|
-
"config"
|
|
28
|
-
"actions"
|
|
27
|
+
"config"
|
|
29
28
|
],
|
|
30
29
|
"toolActions": [
|
|
31
30
|
"danmaku.list",
|
|
@@ -50,7 +49,7 @@
|
|
|
50
49
|
"./package.json": "./package.json"
|
|
51
50
|
},
|
|
52
51
|
"dependencies": {
|
|
53
|
-
"dsh-workbench-host": "^0.17.
|
|
52
|
+
"dsh-workbench-host": "^0.17.8"
|
|
54
53
|
},
|
|
55
54
|
"dsh": {
|
|
56
55
|
"bundle": {
|