@jayyuen66/dsh-scrapling 0.0.1-rc.3 → 0.0.2
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 +56 -13
- package/README.zh-CN.md +17 -8
- package/client.js +480 -102
- package/host.js +21 -17
- package/package.json +45 -40
- package/py/adapters.py +400 -64
- package/py/bridge.py +16 -9
- package/py/crawl.py +162 -31
- package/py/guard.py +142 -51
package/client.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// GENERATED by build-client.ts — edit src/client-entry.ts, then run `node build-client.ts`.
|
|
2
2
|
window.__ModuleLoader__.load({
|
|
3
|
-
id:
|
|
3
|
+
id: "@jayyuen66/dsh-scrapling",
|
|
4
4
|
factory: (require) => {
|
|
5
|
+
"use strict";
|
|
5
6
|
var module = { exports: {} };
|
|
6
7
|
var exports = module.exports;
|
|
7
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
9
|
let react = require("react");
|
|
9
|
-
//#region node_modules/.pnpm/@jayyuen66+dsh-plugin-shared@0.1.
|
|
10
|
+
//#region node_modules/.pnpm/@jayyuen66+dsh-plugin-shared@0.1.4_c79f541388a18a6a0476b83d3755b171/node_modules/@jayyuen66/dsh-plugin-shared/dist/card-apply.js
|
|
10
11
|
function e$1(e, t, n) {
|
|
11
12
|
let r = globalThis;
|
|
12
13
|
if (r[t] === !0) return !1;
|
|
@@ -21,12 +22,14 @@ function e$1(e, t, n) {
|
|
|
21
22
|
return !0;
|
|
22
23
|
}
|
|
23
24
|
//#endregion
|
|
24
|
-
//#region node_modules/.pnpm/@jayyuen66+dsh-plugin-shared@0.1.
|
|
25
|
+
//#region node_modules/.pnpm/@jayyuen66+dsh-plugin-shared@0.1.4_c79f541388a18a6a0476b83d3755b171/node_modules/@jayyuen66/dsh-plugin-shared/dist/record.js
|
|
25
26
|
function e(e) {
|
|
26
27
|
return typeof e == `object` && !!e && !Array.isArray(e);
|
|
27
28
|
}
|
|
28
29
|
//#endregion
|
|
29
30
|
//#region src/settings-fields.ts
|
|
31
|
+
/** 设置卡对应的 Host 条目 id(cordis.patch.yml 里 `insert` 的 `id`),也是设置命名空间。 */
|
|
32
|
+
const SETTINGS_ENTRY_ID = "scrapling";
|
|
30
33
|
/** 本包在插件管理器里的包名,也就是 `plugins.bundle.config` 这张 keyed slot 的键。 */
|
|
31
34
|
const BUNDLE_PACKAGE_NAME = "@jayyuen66/dsh-scrapling";
|
|
32
35
|
/** 字段表。顺序即卡上的呈现顺序,按「先让用户认出东西、再调细节」排。 */
|
|
@@ -472,13 +475,14 @@ const SETTINGS_GROUPS = [
|
|
|
472
475
|
{
|
|
473
476
|
key: "proxyUrl",
|
|
474
477
|
kind: "text",
|
|
478
|
+
secret: true,
|
|
475
479
|
label: {
|
|
476
480
|
zh: "代理地址",
|
|
477
481
|
en: "Proxy URL"
|
|
478
482
|
},
|
|
479
483
|
hint: {
|
|
480
|
-
zh: "如 http://127.0.0.1:7890 或 socks5://127.0.0.1:7890,可带 user:pass
|
|
481
|
-
en: "e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:7890, user:pass@ allowed. Empty follows the environment and then the OS proxy settings; setting it outranks both."
|
|
484
|
+
zh: "如 http://127.0.0.1:7890 或 socks5://127.0.0.1:7890,可带 user:pass@。留空=依次跟随环境变量与系统代理设置;填了就压过那两者。值按密码遮罩显示,点「显示」可查看。",
|
|
485
|
+
en: "e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:7890, user:pass@ allowed. Empty follows the environment and then the OS proxy settings; setting it outranks both. Masked like a password; press Show to reveal it."
|
|
482
486
|
},
|
|
483
487
|
fallback: ""
|
|
484
488
|
},
|
|
@@ -618,8 +622,123 @@ const SETTINGS_GROUPS = [
|
|
|
618
622
|
/** 展平后的字段表,顺序与卡上一致。 */
|
|
619
623
|
const SETTINGS_FIELDS = SETTINGS_GROUPS.flatMap((group) => group.fields);
|
|
620
624
|
SETTINGS_FIELDS.map((field) => field.key);
|
|
625
|
+
/** 本包 Client 半注册的字典命名空间。 */
|
|
626
|
+
const LOCALE_NS = "dshScrapling";
|
|
627
|
+
/** 设置卡自身的文案:按钮、状态行与读屏提示。字段标签不在这里 —— 它们由字段表摊出来。 */
|
|
628
|
+
const CHROME = {
|
|
629
|
+
zh: {
|
|
630
|
+
save: "保存",
|
|
631
|
+
saving: "保存中…",
|
|
632
|
+
undo: "撤销",
|
|
633
|
+
reveal: "显示",
|
|
634
|
+
conceal: "隐藏",
|
|
635
|
+
revealHint: "这一项按密码遮罩显示",
|
|
636
|
+
statusLoading: "正在读取设置…",
|
|
637
|
+
statusReadonly: "这个连接以只读方式运行,设置改不了。",
|
|
638
|
+
statusClean: "没有未保存的改动",
|
|
639
|
+
statusChanged: "已改动 {count} 项,未保存",
|
|
640
|
+
statusInvalid: "有 {count} 项填的不是合法数字,改好后才能保存",
|
|
641
|
+
rejected: "保存被宿主拒绝了,设置未改动",
|
|
642
|
+
stale: "设置已经被别处改过,请重新打开这张卡再保存",
|
|
643
|
+
failed: "保存失败:{reason}"
|
|
644
|
+
},
|
|
645
|
+
en: {
|
|
646
|
+
save: "Save",
|
|
647
|
+
saving: "Saving…",
|
|
648
|
+
undo: "Undo",
|
|
649
|
+
reveal: "Show",
|
|
650
|
+
conceal: "Hide",
|
|
651
|
+
revealHint: "this field is masked like a password",
|
|
652
|
+
statusLoading: "Reading settings…",
|
|
653
|
+
statusReadonly: "This connection runs read-only; settings cannot be changed here.",
|
|
654
|
+
statusClean: "No unsaved changes",
|
|
655
|
+
statusChanged: "{count} change(s) not saved yet",
|
|
656
|
+
statusInvalid: "{count} field(s) are not valid numbers; fix them to save",
|
|
657
|
+
rejected: "The host refused the save; nothing changed",
|
|
658
|
+
stale: "Settings changed elsewhere; reopen this page before saving",
|
|
659
|
+
failed: "Save failed: {reason}"
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
/** 结果行那一行的文案:字段名与那一个「看详情」的入口。 */
|
|
663
|
+
const ROW_CHROME = {
|
|
664
|
+
zh: {
|
|
665
|
+
"row.url": "URL",
|
|
666
|
+
"row.http": "HTTP",
|
|
667
|
+
"row.body": "正文",
|
|
668
|
+
"row.matched": "匹配",
|
|
669
|
+
"row.sessionCount": "会话数",
|
|
670
|
+
"row.session": "会话",
|
|
671
|
+
"row.type": "类型",
|
|
672
|
+
"row.start": "起始",
|
|
673
|
+
"row.pageCap": "上限",
|
|
674
|
+
"row.job": "作业",
|
|
675
|
+
"row.inspect": "在轨迹里查看",
|
|
676
|
+
"row.truncated": "已截断"
|
|
677
|
+
},
|
|
678
|
+
en: {
|
|
679
|
+
"row.url": "URL",
|
|
680
|
+
"row.http": "HTTP",
|
|
681
|
+
"row.body": "Body",
|
|
682
|
+
"row.matched": "Matched",
|
|
683
|
+
"row.sessionCount": "Sessions",
|
|
684
|
+
"row.session": "Session",
|
|
685
|
+
"row.type": "Type",
|
|
686
|
+
"row.start": "Start",
|
|
687
|
+
"row.pageCap": "Page cap",
|
|
688
|
+
"row.job": "Job",
|
|
689
|
+
"row.inspect": "Inspect this call",
|
|
690
|
+
"row.truncated": "Truncated"
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
/**
|
|
694
|
+
* 把字段表与卡面文案摊成宿主 locale 服务要的字典。
|
|
695
|
+
*
|
|
696
|
+
* 键的形状:字段是 `field.<key>.label` / `field.<key>.hint`,分组是
|
|
697
|
+
* `group.<id>.title` / `group.<id>.note`,卡面文案直接用自己的键。键从字段表推出来,
|
|
698
|
+
* 所以往表里加一个字段就自动多出两条词典项 —— 不需要在这里再抄一遍。
|
|
699
|
+
*
|
|
700
|
+
* @returns 语言 → 键值表;两份的键集相等
|
|
701
|
+
*/
|
|
702
|
+
function localeDictionaries() {
|
|
703
|
+
const result = {
|
|
704
|
+
zh: {
|
|
705
|
+
...CHROME.zh,
|
|
706
|
+
...ROW_CHROME.zh
|
|
707
|
+
},
|
|
708
|
+
en: {
|
|
709
|
+
...CHROME.en,
|
|
710
|
+
...ROW_CHROME.en
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
for (const group of SETTINGS_GROUPS) {
|
|
714
|
+
result.zh[`group.${group.id}.title`] = group.title.zh;
|
|
715
|
+
result.zh[`group.${group.id}.note`] = group.note.zh;
|
|
716
|
+
result.en[`group.${group.id}.title`] = group.title.en;
|
|
717
|
+
result.en[`group.${group.id}.note`] = group.note.en;
|
|
718
|
+
for (const field of group.fields) {
|
|
719
|
+
result.zh[`field.${field.key}.label`] = field.label.zh;
|
|
720
|
+
result.zh[`field.${field.key}.hint`] = field.hint.zh;
|
|
721
|
+
result.en[`field.${field.key}.label`] = field.label.en;
|
|
722
|
+
result.en[`field.${field.key}.hint`] = field.hint.en;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return result;
|
|
726
|
+
}
|
|
621
727
|
//#endregion
|
|
622
728
|
//#region src/settings-card.ts
|
|
729
|
+
/** 没给值面时读到的那一版:既不在线也不可写,于是卡片画出一张锁住的空表。 */
|
|
730
|
+
const LOADING_STATE = {
|
|
731
|
+
status: "loading",
|
|
732
|
+
writable: false
|
|
733
|
+
};
|
|
734
|
+
/** 值面缺席时的 getSnapshot:永远返回同一个引用,订阅因此不会被反复重建。 */
|
|
735
|
+
function loadingSnapshot() {
|
|
736
|
+
return LOADING_STATE;
|
|
737
|
+
}
|
|
738
|
+
/** 值面缺席时的 subscribe:永远不通知,回收是空操作。 */
|
|
739
|
+
function loadingSubscribe() {
|
|
740
|
+
return () => void 0;
|
|
741
|
+
}
|
|
623
742
|
/** 把任意设置值转成控件能显示的字符串;结构值给空串而不是 `[object Object]`。 */
|
|
624
743
|
function textOf(value) {
|
|
625
744
|
if (typeof value === "string") return value;
|
|
@@ -643,36 +762,43 @@ function displayValue(field, host, draft) {
|
|
|
643
762
|
/**
|
|
644
763
|
* 把控件里敲进去的一串字翻成设置值。
|
|
645
764
|
*
|
|
646
|
-
* 清空 =
|
|
647
|
-
*
|
|
648
|
-
*
|
|
765
|
+
* 清空 = 交回默认值,所以空串给 `clear`。数字字段按 schema 的下界夹住;非数字、零、负数与
|
|
766
|
+
* 小数一律给 `invalid` 而不是 `clear`。早先把它们当成清除,用户填错一个数就会把自己原来
|
|
767
|
+
* 那条覆盖静默删掉,而且界面上看不出发生过什么 —— 非法输入留在控件里、保存按钮因此不可用,
|
|
768
|
+
* 比悄悄改掉用户的配置好。
|
|
649
769
|
*
|
|
650
770
|
* @param field - 字段描述
|
|
651
771
|
* @param raw - 控件里的原始字符串
|
|
652
|
-
* @returns
|
|
772
|
+
* @returns 解析结果
|
|
653
773
|
*/
|
|
654
774
|
function parseInput(field, raw) {
|
|
655
|
-
if (field.kind === "boolean") return
|
|
775
|
+
if (field.kind === "boolean") return {
|
|
776
|
+
kind: "value",
|
|
777
|
+
value: raw === "true"
|
|
778
|
+
};
|
|
656
779
|
const text = raw.trim();
|
|
657
|
-
if (text === "") return
|
|
658
|
-
if (field.kind === "number") {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
}
|
|
662
|
-
return
|
|
780
|
+
if (text === "") return { kind: "clear" };
|
|
781
|
+
if (field.kind === "number") return /^[1-9]\d*$/u.test(text) ? {
|
|
782
|
+
kind: "value",
|
|
783
|
+
value: Number(text)
|
|
784
|
+
} : { kind: "invalid" };
|
|
785
|
+
return {
|
|
786
|
+
kind: "value",
|
|
787
|
+
value: text
|
|
788
|
+
};
|
|
663
789
|
}
|
|
664
790
|
/**
|
|
665
791
|
* 把草稿翻成一串写入操作。
|
|
666
792
|
*
|
|
667
793
|
* 与默认值相同的项走 unset:用户层里「显式写了默认值」和「没写」在将来改默认值时行为完全
|
|
668
794
|
* 不同,只有 unset 能保住这个区别。顺序跟字段表一致,于是同一份草稿每次生成同样的操作串,
|
|
669
|
-
* 宿主按 revision
|
|
795
|
+
* 宿主按 revision 拒绝时也不会因为顺序抖动而给出不同的理由。非法字段不出现在串里。
|
|
670
796
|
*
|
|
671
797
|
* @param draft - 用户改过的字段(只有改过的在里面)
|
|
672
798
|
* @returns 写入操作
|
|
673
799
|
*/
|
|
674
800
|
function buildOps(draft) {
|
|
675
|
-
return SETTINGS_FIELDS.filter((field) => field.key
|
|
801
|
+
return SETTINGS_FIELDS.filter((field) => Object.hasOwn(draft, field.key)).filter((field) => draft[field.key] !== void 0).map((field) => {
|
|
676
802
|
const value = draft[field.key];
|
|
677
803
|
return value === null || value === field.fallback ? {
|
|
678
804
|
op: "unset",
|
|
@@ -696,6 +822,8 @@ const CARD_CSS = `
|
|
|
696
822
|
.dss-label{font-size:13px;line-height:20px}
|
|
697
823
|
.dss-hint{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;grid-column:1}
|
|
698
824
|
.dss-control{grid-column:2;display:flex;justify-content:flex-end}
|
|
825
|
+
.dss-secret{display:flex;gap:8px;align-items:center;justify-content:flex-end;width:100%}
|
|
826
|
+
.dss-reveal{flex:none;padding:5px 8px;white-space:nowrap}
|
|
699
827
|
.dss-control input[type=text],.dss-control input[type=number]{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;padding:5px 8px;width:100%;max-width:280px}
|
|
700
828
|
.dss-control input:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
|
|
701
829
|
.dss-control select{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;padding:5px 8px;max-width:280px}
|
|
@@ -714,7 +842,9 @@ const CARD_CSS = `
|
|
|
714
842
|
`;
|
|
715
843
|
/** 这个值是不是一个带本卡所需那点 API 的 document。类型守卫而不是断言。 */
|
|
716
844
|
function isDocumentFace(value) {
|
|
717
|
-
|
|
845
|
+
if (typeof value !== "object" || value === null) return false;
|
|
846
|
+
const head = Reflect.get(value, "head");
|
|
847
|
+
return typeof Reflect.get(value, "querySelector") === "function" && typeof Reflect.get(value, "createElement") === "function" && typeof head === "object" && head !== null && typeof Reflect.get(head, "append") === "function";
|
|
718
848
|
}
|
|
719
849
|
/** 宿主浏览器里的 document;Node 侧(测试、打包)没有,返回 undefined。
|
|
720
850
|
*
|
|
@@ -725,27 +855,64 @@ function browserDocument() {
|
|
|
725
855
|
const candidate = Reflect.get(globalThis, "document");
|
|
726
856
|
return isDocumentFace(candidate) ? candidate : void 0;
|
|
727
857
|
}
|
|
728
|
-
/**
|
|
858
|
+
/**
|
|
859
|
+
* 把一段样式挂进文档,返回摘掉它的函数。同一 id 只会有一段,重复调用是空操作。
|
|
860
|
+
*
|
|
861
|
+
* **由 apply 注册在 ctx.effect 里,不在组件的 render 里调**:渲染期改 DOM 是 React 明令
|
|
862
|
+
* 禁止的副作用,并发渲染与 StrictMode 的双调用都会让注入时机不可预测,而同一段 `<style>`
|
|
863
|
+
* 重复注入就会叠两份规则。文档里已经有它时返回的函数也就不该把别人的摘掉。
|
|
729
864
|
*
|
|
730
865
|
* 导出是为了能被直接测 —— 同 :func:`browserDocument` 的理由。
|
|
866
|
+
*
|
|
867
|
+
* @param doc - 宿主文档
|
|
868
|
+
* @param id - 样式元素的 id,也是「已经挂过没有」的判据
|
|
869
|
+
* @param css - 样式正文
|
|
870
|
+
* @returns 摘掉本次注入的样式;没有注入时是空操作
|
|
731
871
|
*/
|
|
732
|
-
function
|
|
733
|
-
const
|
|
734
|
-
if (
|
|
872
|
+
function installStyle(doc, id, css) {
|
|
873
|
+
const present = doc.querySelector(`#${id}`);
|
|
874
|
+
if (present !== void 0 && present !== null) return () => void 0;
|
|
735
875
|
const tag = doc.createElement("style");
|
|
736
876
|
tag.id = id;
|
|
737
|
-
tag.textContent =
|
|
877
|
+
tag.textContent = css;
|
|
738
878
|
doc.head.append(tag);
|
|
879
|
+
return () => {
|
|
880
|
+
tag.remove();
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* 把设置卡的样式挂进文档。
|
|
885
|
+
*
|
|
886
|
+
* @param doc - 宿主文档
|
|
887
|
+
* @returns 摘掉本次注入的样式
|
|
888
|
+
*/
|
|
889
|
+
function installStyles(doc) {
|
|
890
|
+
return installStyle(doc, "dsh-scrapling-settings-css", CARD_CSS);
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* 文本类控件的 input type。
|
|
894
|
+
*
|
|
895
|
+
* 凭据型字段默认走 ``password``:浏览器只画圆点,值本身丝毫不动 —— 编辑、草稿、保存全都
|
|
896
|
+
* 按原串走,遮住的只是屏幕上那一份。导出为纯函数是为了能被直接测:这一层的两条分支在
|
|
897
|
+
* 真浏览器里各要一次点击才走得到,藏在组件里就只能靠渲染来覆盖。
|
|
898
|
+
*
|
|
899
|
+
* @param field - 字段描述
|
|
900
|
+
* @param revealed - 用户是否已经点过「显示」
|
|
901
|
+
* @returns input 的 type
|
|
902
|
+
*/
|
|
903
|
+
function controlType(field, revealed) {
|
|
904
|
+
return field.secret === true && !revealed ? "password" : "text";
|
|
739
905
|
}
|
|
740
906
|
/** 一个字段的控件。 */
|
|
741
907
|
function renderControl(props) {
|
|
742
|
-
const { field, shown, disabled, onChange } = props;
|
|
908
|
+
const { field, label, shown, disabled, revealed, onReveal, t, onChange } = props;
|
|
743
909
|
if (field.kind === "boolean") return (0, react.createElement)("input", {
|
|
744
910
|
type: "checkbox",
|
|
745
911
|
className: "dss-switch",
|
|
912
|
+
role: "switch",
|
|
746
913
|
checked: shown === "true",
|
|
747
914
|
disabled,
|
|
748
|
-
"aria-label":
|
|
915
|
+
"aria-label": label,
|
|
749
916
|
onChange: (event) => {
|
|
750
917
|
onChange(String(event.target.checked));
|
|
751
918
|
}
|
|
@@ -753,7 +920,7 @@ function renderControl(props) {
|
|
|
753
920
|
if (field.kind === "enum") return (0, react.createElement)("select", {
|
|
754
921
|
disabled,
|
|
755
922
|
value: shown,
|
|
756
|
-
"aria-label":
|
|
923
|
+
"aria-label": label,
|
|
757
924
|
onChange: (event) => {
|
|
758
925
|
onChange(event.target.value);
|
|
759
926
|
}
|
|
@@ -761,106 +928,191 @@ function renderControl(props) {
|
|
|
761
928
|
key: option,
|
|
762
929
|
value: option
|
|
763
930
|
}, option)));
|
|
764
|
-
|
|
765
|
-
type: field.kind === "number" ? "number" :
|
|
931
|
+
const input = (0, react.createElement)("input", {
|
|
932
|
+
type: field.kind === "number" ? "number" : controlType(field, revealed),
|
|
766
933
|
value: shown,
|
|
767
934
|
disabled,
|
|
935
|
+
...field.secret === true ? {
|
|
936
|
+
autoComplete: "off",
|
|
937
|
+
spellCheck: false
|
|
938
|
+
} : {},
|
|
768
939
|
min: field.kind === "number" ? 1 : void 0,
|
|
769
|
-
"
|
|
940
|
+
step: field.kind === "number" ? 1 : void 0,
|
|
941
|
+
"aria-label": label,
|
|
770
942
|
onChange: (event) => {
|
|
771
943
|
onChange(event.target.value);
|
|
772
944
|
}
|
|
773
945
|
});
|
|
946
|
+
if (field.secret !== true) return input;
|
|
947
|
+
return (0, react.createElement)("span", { className: "dss-secret" }, input, (0, react.createElement)("button", {
|
|
948
|
+
type: "button",
|
|
949
|
+
className: "dss-button dss-reveal",
|
|
950
|
+
disabled,
|
|
951
|
+
"aria-pressed": revealed,
|
|
952
|
+
"aria-label": label,
|
|
953
|
+
onClick: () => {
|
|
954
|
+
onReveal();
|
|
955
|
+
}
|
|
956
|
+
}, t(revealed ? "conceal" : "reveal")));
|
|
774
957
|
}
|
|
775
958
|
/** 一行:左边标签与说明,右边控件。 */
|
|
776
959
|
function renderFieldRow(props) {
|
|
777
|
-
const { field, shown, disabled, onChange } = props;
|
|
778
|
-
|
|
960
|
+
const { field, t, shown, disabled, revealed, onReveal, onChange } = props;
|
|
961
|
+
const label = t(`field.${field.key}.label`);
|
|
962
|
+
const control = renderControl({
|
|
779
963
|
field,
|
|
964
|
+
label,
|
|
780
965
|
shown,
|
|
781
966
|
disabled,
|
|
967
|
+
revealed,
|
|
968
|
+
onReveal,
|
|
969
|
+
t,
|
|
782
970
|
onChange
|
|
783
|
-
})
|
|
971
|
+
});
|
|
972
|
+
const caption = (0, react.createElement)("div", { className: "dss-label" }, label, (0, react.createElement)("p", { className: "dss-hint" }, t(`field.${field.key}.hint`)));
|
|
973
|
+
return (0, react.createElement)("div", {
|
|
974
|
+
className: "dss-field",
|
|
975
|
+
key: field.key
|
|
976
|
+
}, caption, (0, react.createElement)("div", { className: "dss-control" }, control));
|
|
784
977
|
}
|
|
785
978
|
/** 一组字段。 */
|
|
786
979
|
function renderGroup(props) {
|
|
787
|
-
const { group, shown, disabled, onChange } = props;
|
|
788
|
-
return (0, react.createElement)("section", {
|
|
980
|
+
const { group, t, shown, disabled, revealed, onReveal, onChange } = props;
|
|
981
|
+
return (0, react.createElement)("section", {
|
|
982
|
+
className: "dss-group",
|
|
983
|
+
key: group.id
|
|
984
|
+
}, (0, react.createElement)("h3", { className: "dss-groupTitle" }, t(`group.${group.id}.title`)), (0, react.createElement)("p", { className: "dss-note" }, t(`group.${group.id}.note`)), (0, react.createElement)("div", { className: "dss-fields" }, group.fields.map((field) => renderFieldRow({
|
|
789
985
|
field,
|
|
986
|
+
t,
|
|
790
987
|
shown: shown(field),
|
|
791
988
|
disabled,
|
|
989
|
+
revealed: revealed(field),
|
|
990
|
+
onReveal: () => {
|
|
991
|
+
onReveal(field);
|
|
992
|
+
},
|
|
792
993
|
onChange: (raw) => {
|
|
793
994
|
onChange(field, raw);
|
|
794
995
|
}
|
|
795
996
|
}))));
|
|
796
997
|
}
|
|
797
998
|
/** 顶部那行状态说明。拆成函数是为了不在 JSX 里套三元。 */
|
|
798
|
-
function statusLine(state, changed) {
|
|
799
|
-
if (state.status === "loading") return "
|
|
800
|
-
if (
|
|
801
|
-
|
|
999
|
+
function statusLine(t, state, changed, invalid) {
|
|
1000
|
+
if (state.status === "loading") return t("statusLoading");
|
|
1001
|
+
if (invalid > 0) return t("statusInvalid", { count: invalid });
|
|
1002
|
+
if (state.status === "unavailable" || !state.writable) return t("statusReadonly");
|
|
1003
|
+
return changed === 0 ? t("statusClean") : t("statusChanged", { count: changed });
|
|
1004
|
+
}
|
|
1005
|
+
const EMPTY_DRAFT = {
|
|
1006
|
+
values: {},
|
|
1007
|
+
baseRevision: void 0,
|
|
1008
|
+
invalid: []
|
|
1009
|
+
};
|
|
1010
|
+
/** 底部那一行按钮。 */
|
|
1011
|
+
function renderActions(props) {
|
|
1012
|
+
const { t, saving, editable, blocked, changed, onSave, onUndo } = props;
|
|
1013
|
+
const idle = changed === 0;
|
|
1014
|
+
return (0, react.createElement)("div", { className: "dss-actions" }, (0, react.createElement)("button", {
|
|
1015
|
+
type: "button",
|
|
1016
|
+
className: "dss-button",
|
|
1017
|
+
"data-primary": "true",
|
|
1018
|
+
disabled: idle || blocked || saving || !editable,
|
|
1019
|
+
onClick: onSave
|
|
1020
|
+
}, saving ? t("saving") : t("save")), (0, react.createElement)("button", {
|
|
1021
|
+
type: "button",
|
|
1022
|
+
className: "dss-button",
|
|
1023
|
+
disabled: idle || blocked || saving,
|
|
1024
|
+
onClick: onUndo
|
|
1025
|
+
}, t("undo")));
|
|
802
1026
|
}
|
|
803
1027
|
/** 设置卡本体。导出为常量而非函数声明:它是 React 组件,不是可 new 的类。 */
|
|
804
1028
|
function SettingsCard(props) {
|
|
805
|
-
const { form } = props;
|
|
806
|
-
const [draft, setDraft] = (0, react.useState)(
|
|
1029
|
+
const { form, t } = props;
|
|
1030
|
+
const [draft, setDraft] = (0, react.useState)(EMPTY_DRAFT);
|
|
807
1031
|
const [failure, setFailure] = (0, react.useState)("");
|
|
808
1032
|
const [saving, setSaving] = (0, react.useState)(false);
|
|
809
|
-
const
|
|
810
|
-
|
|
1033
|
+
const [revealed, setRevealed] = (0, react.useState)([]);
|
|
1034
|
+
const state = (0, react.useSyncExternalStore)(form === void 0 ? loadingSubscribe : form.subscribe, form === void 0 ? loadingSnapshot : form.getSnapshot);
|
|
811
1035
|
if (props.view !== "page" || form === void 0) return (0, react.createElement)("div", { className: "dss-card" });
|
|
812
|
-
const { state } = form;
|
|
813
1036
|
const editable = state.writable && state.status === "ready";
|
|
814
|
-
const ops = buildOps(draft);
|
|
1037
|
+
const ops = buildOps(draft.values);
|
|
815
1038
|
const save = async () => {
|
|
816
1039
|
setSaving(true);
|
|
817
1040
|
setFailure("");
|
|
818
1041
|
try {
|
|
819
|
-
if (await form.mutate(ops,
|
|
820
|
-
|
|
1042
|
+
if (await form.mutate(ops, draft.baseRevision)) setDraft((previous) => {
|
|
1043
|
+
const values = { ...previous.values };
|
|
1044
|
+
for (const op of ops) {
|
|
1045
|
+
const [key] = op.path;
|
|
1046
|
+
Reflect.deleteProperty(values, key);
|
|
1047
|
+
}
|
|
1048
|
+
return Object.keys(values).length === 0 ? EMPTY_DRAFT : {
|
|
1049
|
+
...previous,
|
|
1050
|
+
values
|
|
1051
|
+
};
|
|
1052
|
+
});
|
|
1053
|
+
else setFailure(draft.baseRevision !== void 0 && draft.baseRevision !== state.revision ? t("stale") : t("rejected"));
|
|
821
1054
|
} catch (error) {
|
|
822
|
-
setFailure(
|
|
1055
|
+
setFailure(t("failed", { reason: String(error) }));
|
|
823
1056
|
} finally {
|
|
824
1057
|
setSaving(false);
|
|
825
1058
|
}
|
|
826
1059
|
};
|
|
827
1060
|
const onFieldChange = (field, raw) => {
|
|
828
1061
|
setFailure("");
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
1062
|
+
const parsed = parseInput(field, raw);
|
|
1063
|
+
setDraft((previous) => {
|
|
1064
|
+
const values = { ...previous.values };
|
|
1065
|
+
const invalid = previous.invalid.filter((key) => key !== field.key);
|
|
1066
|
+
const baseRevision = previous.baseRevision ?? state.revision;
|
|
1067
|
+
if (parsed.kind === "invalid") return {
|
|
1068
|
+
values,
|
|
1069
|
+
baseRevision,
|
|
1070
|
+
invalid: [...invalid, field.key]
|
|
1071
|
+
};
|
|
1072
|
+
values[field.key] = parsed.kind === "clear" ? null : parsed.value;
|
|
1073
|
+
return {
|
|
1074
|
+
values,
|
|
1075
|
+
baseRevision,
|
|
1076
|
+
invalid
|
|
1077
|
+
};
|
|
1078
|
+
});
|
|
833
1079
|
};
|
|
834
1080
|
const groups = SETTINGS_GROUPS.map((group) => renderGroup({
|
|
835
1081
|
group,
|
|
836
|
-
|
|
837
|
-
|
|
1082
|
+
t,
|
|
1083
|
+
shown: (field) => displayValue(field, state.value, draft.values),
|
|
1084
|
+
disabled: !editable || saving,
|
|
1085
|
+
revealed: (field) => revealed.includes(field.key),
|
|
1086
|
+
onReveal: (field) => {
|
|
1087
|
+
setRevealed((previous) => previous.includes(field.key) ? previous.filter((key) => key !== field.key) : [...previous, field.key]);
|
|
1088
|
+
},
|
|
838
1089
|
onChange: onFieldChange
|
|
839
1090
|
}));
|
|
840
|
-
const actions = (
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
1091
|
+
const actions = renderActions({
|
|
1092
|
+
t,
|
|
1093
|
+
saving,
|
|
1094
|
+
editable,
|
|
1095
|
+
blocked: draft.invalid.length > 0,
|
|
1096
|
+
changed: ops.length,
|
|
1097
|
+
onSave: () => {
|
|
846
1098
|
save();
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
className: "dss-button",
|
|
851
|
-
disabled: ops.length === 0 || saving,
|
|
852
|
-
onClick: () => {
|
|
853
|
-
setDraft({});
|
|
1099
|
+
},
|
|
1100
|
+
onUndo: () => {
|
|
1101
|
+
setDraft(EMPTY_DRAFT);
|
|
854
1102
|
setFailure("");
|
|
855
1103
|
}
|
|
856
|
-
}
|
|
1104
|
+
});
|
|
857
1105
|
const status = (0, react.createElement)("p", {
|
|
858
1106
|
className: "dss-status",
|
|
859
|
-
"data-error": "false"
|
|
860
|
-
|
|
1107
|
+
"data-error": "false",
|
|
1108
|
+
role: "status",
|
|
1109
|
+
"aria-live": "polite"
|
|
1110
|
+
}, statusLine(t, state, ops.length, draft.invalid.length));
|
|
861
1111
|
const reported = failure === "" ? null : (0, react.createElement)("p", {
|
|
862
1112
|
className: "dss-status",
|
|
863
|
-
"data-error": "true"
|
|
1113
|
+
"data-error": "true",
|
|
1114
|
+
role: "alert",
|
|
1115
|
+
"aria-live": "assertive"
|
|
864
1116
|
}, failure);
|
|
865
1117
|
return (0, react.createElement)("div", { className: "dss-card" }, status, reported, ...groups, actions);
|
|
866
1118
|
}
|
|
@@ -869,8 +1121,9 @@ function SettingsCard(props) {
|
|
|
869
1121
|
/**
|
|
870
1122
|
* 需要专用结果行的工具。
|
|
871
1123
|
*
|
|
872
|
-
*
|
|
873
|
-
*
|
|
1124
|
+
* 每个工具一个 key:slot 按 key 派发,漏掉一个只是那一个不画行,不会连累别的。这份清单
|
|
1125
|
+
* 必须与 `host.ts` 的 `TOOL_SPECS` 对齐 —— 少登记一个,用户看到的就是宿主那条不带本包
|
|
1126
|
+
* 摘要信息的通用行。
|
|
874
1127
|
*/
|
|
875
1128
|
const ROW_TOOLS = [
|
|
876
1129
|
"scrapling_fetch",
|
|
@@ -878,6 +1131,7 @@ const ROW_TOOLS = [
|
|
|
878
1131
|
"scrapling_render",
|
|
879
1132
|
"scrapling_capture_xhr",
|
|
880
1133
|
"scrapling_stealth_fetch",
|
|
1134
|
+
"scrapling_answer",
|
|
881
1135
|
"scrapling_session_open",
|
|
882
1136
|
"scrapling_session_fetch",
|
|
883
1137
|
"scrapling_session_list",
|
|
@@ -919,7 +1173,7 @@ function buildRow(tool, args, meta) {
|
|
|
919
1173
|
tool,
|
|
920
1174
|
title: selector === "" ? tool : `${tool} ${selector}`,
|
|
921
1175
|
fields: [{
|
|
922
|
-
|
|
1176
|
+
labelKey: "row.matched",
|
|
923
1177
|
value: text(projected["count"])
|
|
924
1178
|
}]
|
|
925
1179
|
};
|
|
@@ -928,7 +1182,7 @@ function buildRow(tool, args, meta) {
|
|
|
928
1182
|
tool,
|
|
929
1183
|
title: tool,
|
|
930
1184
|
fields: [{
|
|
931
|
-
|
|
1185
|
+
labelKey: "row.sessionCount",
|
|
932
1186
|
value: text(projected["count"])
|
|
933
1187
|
}]
|
|
934
1188
|
};
|
|
@@ -936,10 +1190,10 @@ function buildRow(tool, args, meta) {
|
|
|
936
1190
|
tool,
|
|
937
1191
|
title: tool,
|
|
938
1192
|
fields: [{
|
|
939
|
-
|
|
1193
|
+
labelKey: "row.type",
|
|
940
1194
|
value: text(parameters["sessionType"])
|
|
941
1195
|
}, {
|
|
942
|
-
|
|
1196
|
+
labelKey: "row.session",
|
|
943
1197
|
value: text(projected["sessionId"])
|
|
944
1198
|
}]
|
|
945
1199
|
};
|
|
@@ -947,7 +1201,7 @@ function buildRow(tool, args, meta) {
|
|
|
947
1201
|
tool,
|
|
948
1202
|
title: tool,
|
|
949
1203
|
fields: [{
|
|
950
|
-
|
|
1204
|
+
labelKey: "row.session",
|
|
951
1205
|
value: text(parameters["sessionId"])
|
|
952
1206
|
}]
|
|
953
1207
|
};
|
|
@@ -956,32 +1210,33 @@ function buildRow(tool, args, meta) {
|
|
|
956
1210
|
title: tool,
|
|
957
1211
|
fields: [
|
|
958
1212
|
{
|
|
959
|
-
|
|
1213
|
+
labelKey: "row.start",
|
|
960
1214
|
value: url
|
|
961
1215
|
},
|
|
962
1216
|
{
|
|
963
|
-
|
|
1217
|
+
labelKey: "row.pageCap",
|
|
964
1218
|
value: text(parameters["maxPages"])
|
|
965
1219
|
},
|
|
966
1220
|
{
|
|
967
|
-
|
|
1221
|
+
labelKey: "row.job",
|
|
968
1222
|
value: text(projected["jobId"])
|
|
969
1223
|
}
|
|
970
1224
|
]
|
|
971
1225
|
};
|
|
972
1226
|
const fields = [];
|
|
973
1227
|
if (url !== "") fields.push({
|
|
974
|
-
|
|
1228
|
+
labelKey: "row.url",
|
|
975
1229
|
value: url
|
|
976
1230
|
});
|
|
977
1231
|
const status = projected["statusCode"];
|
|
978
1232
|
if (typeof status === "number") fields.push({
|
|
979
|
-
|
|
1233
|
+
labelKey: "row.http",
|
|
980
1234
|
value: String(status)
|
|
981
1235
|
});
|
|
982
1236
|
if (projected["truncated"] === true) fields.push({
|
|
983
|
-
|
|
984
|
-
value: "
|
|
1237
|
+
labelKey: "row.body",
|
|
1238
|
+
value: "",
|
|
1239
|
+
valueKey: "row.truncated"
|
|
985
1240
|
});
|
|
986
1241
|
return {
|
|
987
1242
|
tool,
|
|
@@ -989,15 +1244,102 @@ function buildRow(tool, args, meta) {
|
|
|
989
1244
|
fields
|
|
990
1245
|
};
|
|
991
1246
|
}
|
|
992
|
-
/**
|
|
1247
|
+
/** 结果行用得到的参数键。视图是惰性的,只挑这几个读才不会物化整段参数 JSON。 */
|
|
1248
|
+
const ARG_KEYS = [
|
|
1249
|
+
"url",
|
|
1250
|
+
"selector",
|
|
1251
|
+
"sessionType",
|
|
1252
|
+
"sessionId",
|
|
1253
|
+
"maxPages"
|
|
1254
|
+
];
|
|
1255
|
+
/**
|
|
1256
|
+
* 把宿主的参数视图摊成 buildRow 认得的普通对象。
|
|
1257
|
+
*
|
|
1258
|
+
* @param args - 宿主给的参数视图
|
|
1259
|
+
* @returns 普通对象;视图缺席时是空对象
|
|
1260
|
+
*/
|
|
1261
|
+
function readArgs(args) {
|
|
1262
|
+
if (args === void 0) return {};
|
|
1263
|
+
const values = {};
|
|
1264
|
+
for (const key of ARG_KEYS) {
|
|
1265
|
+
const asValue = args.text(key) ?? args.value(key);
|
|
1266
|
+
if (asValue !== void 0) values[key] = asValue;
|
|
1267
|
+
}
|
|
1268
|
+
return values;
|
|
1269
|
+
}
|
|
1270
|
+
/** 结果行自己的样式。跟着宿主的语义色走,明暗两套主题都成立。 */
|
|
1271
|
+
const ROW_CSS = `
|
|
1272
|
+
.dsh-scrapling-row{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
1273
|
+
.dsh-scrapling-rowTitle{color:var(--dsw-alias-label-primary);font-size:13px;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1274
|
+
.dsh-scrapling-rowFields{display:flex;flex-wrap:wrap;gap:2px 12px;margin:0;padding:0;list-style:none}
|
|
1275
|
+
.dsh-scrapling-rowField{display:flex;gap:4px;min-width:0;font-size:12px;line-height:18px}
|
|
1276
|
+
.dsh-scrapling-rowLabel{color:var(--dsw-alias-label-tertiary);flex:none}
|
|
1277
|
+
.dsh-scrapling-rowValue{color:var(--dsw-alias-label-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1278
|
+
.dsh-scrapling-rowButton{align-self:flex-start;border:0;background:0 0;padding:0;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:12px;cursor:pointer}
|
|
1279
|
+
.dsh-scrapling-rowButton:hover{color:var(--dsw-alias-label-primary)}
|
|
1280
|
+
.dsh-scrapling-rowButton:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
|
|
1281
|
+
`;
|
|
1282
|
+
/**
|
|
1283
|
+
* 一行结果的渲染。
|
|
1284
|
+
*
|
|
1285
|
+
* 入参走 `block.args`,结果侧的投影走 `block.meta`;两者都按「可能还没到」处理 —— 调用刚发出
|
|
1286
|
+
* 时既没有 meta 也没有完整入参,这一行就只画标题。
|
|
1287
|
+
*/
|
|
993
1288
|
function RowView(props) {
|
|
1289
|
+
const { toolName, block, inspect, t } = props;
|
|
1290
|
+
const meta = block.phase === "result" ? block.meta : void 0;
|
|
1291
|
+
const spec = buildRow(toolName, readArgs(block.args), meta);
|
|
1292
|
+
const children = [(0, react.createElement)("div", {
|
|
1293
|
+
className: "dsh-scrapling-rowTitle",
|
|
1294
|
+
key: "title"
|
|
1295
|
+
}, spec.title)];
|
|
1296
|
+
if (spec.fields.length > 0) children.push((0, react.createElement)("ul", {
|
|
1297
|
+
className: "dsh-scrapling-rowFields",
|
|
1298
|
+
key: "fields"
|
|
1299
|
+
}, spec.fields.map((field) => (0, react.createElement)("li", {
|
|
1300
|
+
className: "dsh-scrapling-rowField",
|
|
1301
|
+
key: field.labelKey
|
|
1302
|
+
}, (0, react.createElement)("span", { className: "dsh-scrapling-rowLabel" }, t(field.labelKey)), (0, react.createElement)("span", { className: "dsh-scrapling-rowValue" }, field.valueKey ?? field.value)))));
|
|
1303
|
+
if (inspect !== void 0) children.push((0, react.createElement)("button", {
|
|
1304
|
+
type: "button",
|
|
1305
|
+
className: "dsh-scrapling-rowButton",
|
|
1306
|
+
key: "inspect",
|
|
1307
|
+
onClick: () => {
|
|
1308
|
+
inspect();
|
|
1309
|
+
}
|
|
1310
|
+
}, t("row.inspect")));
|
|
994
1311
|
return (0, react.createElement)("div", {
|
|
995
1312
|
className: "dsh-scrapling-row",
|
|
996
|
-
"data-tool":
|
|
997
|
-
},
|
|
1313
|
+
"data-tool": toolName
|
|
1314
|
+
}, ...children);
|
|
1315
|
+
}
|
|
1316
|
+
/** 本 Client 半注入的服务。三个都得在这儿 —— 见文件头第二条。 */
|
|
1317
|
+
const inject = [
|
|
1318
|
+
"slots",
|
|
1319
|
+
"configForms",
|
|
1320
|
+
"locale"
|
|
1321
|
+
];
|
|
1322
|
+
/**
|
|
1323
|
+
* 给每个需要专用结果行的工具登记一行视图。
|
|
1324
|
+
*
|
|
1325
|
+
* @param ctx - 已就绪 slots 与 locale 的上下文
|
|
1326
|
+
* @returns 注销全部登记的函数
|
|
1327
|
+
*/
|
|
1328
|
+
function registerToolViews(ctx) {
|
|
1329
|
+
const t = ctx.locale.bind(LOCALE_NS);
|
|
1330
|
+
const disposers = [];
|
|
1331
|
+
for (const tool of ROW_TOOLS) disposers.push(ctx.slots.register({
|
|
1332
|
+
name: "tool.call.toolview",
|
|
1333
|
+
key: tool,
|
|
1334
|
+
locale: LOCALE_NS
|
|
1335
|
+
}, (props) => (0, react.createElement)(RowView, {
|
|
1336
|
+
...props,
|
|
1337
|
+
t
|
|
1338
|
+
})));
|
|
1339
|
+
return () => {
|
|
1340
|
+
for (const dispose of disposers) dispose();
|
|
1341
|
+
};
|
|
998
1342
|
}
|
|
999
|
-
/** 本 Client 半注入的服务。 */
|
|
1000
|
-
const inject = ["slots"];
|
|
1001
1343
|
/**
|
|
1002
1344
|
* Client 插件入口:给每个工具注册一行结果视图,并把设置卡挂上插件详情页。
|
|
1003
1345
|
*
|
|
@@ -1005,24 +1347,60 @@ const inject = ["slots"];
|
|
|
1005
1347
|
*/
|
|
1006
1348
|
function apply(ctx) {
|
|
1007
1349
|
if (!e$1(ctx, "__dshScraplingToolviewApplied", "dsh-scrapling toolview")) return;
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1350
|
+
ctx.effect(() => {
|
|
1351
|
+
const doc = browserDocument();
|
|
1352
|
+
if (doc === void 0) return () => void 0;
|
|
1353
|
+
const disposeCard = installStyles(doc);
|
|
1354
|
+
const disposeRow = installStyle(doc, "dsh-scrapling-row-css", ROW_CSS);
|
|
1355
|
+
return () => {
|
|
1356
|
+
disposeCard();
|
|
1357
|
+
disposeRow();
|
|
1358
|
+
};
|
|
1359
|
+
}, "dsh-scrapling: client styles");
|
|
1360
|
+
ctx.effect(() => {
|
|
1361
|
+
const dictionaries = localeDictionaries();
|
|
1362
|
+
const disposers = [ctx.locale.register(LOCALE_NS, "zh", dictionaries.zh), ctx.locale.register(LOCALE_NS, "en", dictionaries.en)];
|
|
1363
|
+
let disposeRows;
|
|
1364
|
+
ctx.slots.inject("tool.call.toolview", () => {
|
|
1365
|
+
disposeRows = registerToolViews(ctx);
|
|
1366
|
+
});
|
|
1367
|
+
return () => {
|
|
1368
|
+
disposeRows?.();
|
|
1369
|
+
for (const dispose of disposers) dispose();
|
|
1370
|
+
};
|
|
1371
|
+
}, "dsh-scrapling: dictionaries and tool rows");
|
|
1372
|
+
ctx.effect(() => {
|
|
1373
|
+
const form = ctx.configForms.get(SETTINGS_ENTRY_ID);
|
|
1374
|
+
const t = ctx.locale.bind(LOCALE_NS);
|
|
1375
|
+
const source = {
|
|
1376
|
+
getSnapshot: () => form.getSnapshot(),
|
|
1377
|
+
subscribe: (listener) => form.subscribe(listener),
|
|
1378
|
+
mutate: (operations, revision) => form.mutate(operations, revision)
|
|
1379
|
+
};
|
|
1380
|
+
let disposeCard;
|
|
1381
|
+
ctx.slots.inject("plugins.bundle.config", () => {
|
|
1382
|
+
disposeCard = ctx.slots.register({
|
|
1383
|
+
name: "plugins.bundle.config",
|
|
1384
|
+
key: BUNDLE_PACKAGE_NAME,
|
|
1385
|
+
locale: LOCALE_NS
|
|
1386
|
+
}, (props) => (0, react.createElement)(SettingsCard, {
|
|
1387
|
+
...props,
|
|
1388
|
+
t,
|
|
1389
|
+
form: source
|
|
1390
|
+
}));
|
|
1391
|
+
});
|
|
1392
|
+
return () => {
|
|
1393
|
+
disposeCard?.();
|
|
1394
|
+
};
|
|
1395
|
+
}, "dsh-scrapling: settings card");
|
|
1020
1396
|
}
|
|
1021
1397
|
//#endregion
|
|
1022
1398
|
exports.ROW_TOOLS = ROW_TOOLS;
|
|
1023
1399
|
exports.apply = apply;
|
|
1024
1400
|
exports.buildRow = buildRow;
|
|
1025
1401
|
exports.inject = inject;
|
|
1402
|
+
exports.readArgs = readArgs;
|
|
1403
|
+
|
|
1026
1404
|
return module.exports;
|
|
1027
1405
|
},
|
|
1028
1406
|
});
|