dsh-workbench-danmaku 0.3.0 → 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 CHANGED
@@ -3008,7 +3008,7 @@ var require_config_scheme_bar = __commonJS({
3008
3008
  ];
3009
3009
  function SchemeBar(props) {
3010
3010
  var lang = props.lang === "en" ? "en" : "zh";
3011
- var c = COPY[lang];
3011
+ var c = props.copy ? Object.assign({}, COPY[lang], props.copy) : COPY[lang];
3012
3012
  var prefix = props.prefix || "wb";
3013
3013
  var cls = function(suffix) {
3014
3014
  return "." + prefix + "-cfg-" + suffix;
@@ -3577,1844 +3577,6 @@ var require_config = __commonJS({
3577
3577
  }
3578
3578
  });
3579
3579
 
3580
- // packages/addons/lib/data-copy.cjs
3581
- var require_data_copy = __commonJS({
3582
- "packages/addons/lib/data-copy.cjs"(exports2, module2) {
3583
- "use strict";
3584
- var COPY = {
3585
- zh: {
3586
- title: "\u6570\u636E",
3587
- subtitle: "\u53EA\u8BFB\u6D4F\u89C8\u672C\u63D2\u4EF6\u8D1F\u8D23\u7684\u8868\uFF1B\u7CFB\u7EDF\u5217\u4E0E\u5DF2\u5220\u9664\u884C\u9ED8\u8BA4\u9690\u85CF",
3588
- tables: "\u8868",
3589
- rows: "\u884C",
3590
- deleted: "\u5DF2\u5220\u9664",
3591
- rowCount: "\u5171 {n} \u884C",
3592
- deletedCount: "\u5176\u4E2D {n} \u884C\u5DF2\u5220\u9664",
3593
- search: "\u641C\u7D22\u6240\u6709\u6587\u672C\u5217\u2026",
3594
- pageSize: "\u6BCF\u9875",
3595
- includeDeleted: "\u542B\u5DF2\u5220\u9664",
3596
- showSystem: "\u7CFB\u7EDF\u5217",
3597
- refresh: "\u5237\u65B0",
3598
- loading: "\u8F7D\u5165\u4E2D\u2026",
3599
- empty: "\u8FD9\u5F20\u8868\u8FD8\u6CA1\u6709\u6570\u636E",
3600
- emptyTable: "\u6CA1\u6709\u53EF\u5C55\u793A\u7684\u8868",
3601
- loadFail: "\u6570\u636E\u670D\u52A1\u4E0D\u53EF\u7528\uFF08\u63D2\u4EF6\u7248\u672C\u8FC7\u65E7\uFF1F\uFF09",
3602
- retry: "\u91CD\u8BD5",
3603
- queryFail: "\u67E5\u8BE2\u5931\u8D25\uFF1A",
3604
- noRows: "\u6CA1\u6709\u5339\u914D\u7684\u884C",
3605
- prev: "\u4E0A\u4E00\u9875",
3606
- next: "\u4E0B\u4E00\u9875",
3607
- pageInfo: "\u7B2C {page} / {pages} \u9875",
3608
- jump: "\u8DF3\u8F6C",
3609
- total: "\u5171 {n} \u884C",
3610
- copied: "\u5DF2\u590D\u5236",
3611
- copy: "\u590D\u5236",
3612
- close: "\u5173\u95ED",
3613
- drawerTitle: "{column} \xB7 \u7B2C {row} \u884C",
3614
- nullText: "NULL",
3615
- emptyText: "\u7A7A",
3616
- yes: "\u662F",
3617
- no: "\u5426",
3618
- json: "JSON",
3619
- queryTime: "{n} ms",
3620
- sortAsc: "\u5347\u5E8F",
3621
- sortDesc: "\u964D\u5E8F",
3622
- filterCol: "\u7B5B\u9009\u2026",
3623
- filterClear: "\u6E05\u9664\u7B5B\u9009",
3624
- index: "\u8868\u7D22\u5F15",
3625
- indexSub: "\u5F53\u524D\u9009\u4E2D\u8868\u7684\u7D22\u5F15\uFF08\u53EA\u8BFB\uFF09\uFF1B\u884C\u6570\u4E3A\u6240\u5C5E\u8868\u603B\u884C\u6570\uFF0C\u4E0D\u662F\u7D22\u5F15\u6761\u76EE\u6570",
3626
- idxName: "\u7D22\u5F15\u540D",
3627
- idxColumns: "\u5217",
3628
- idxType: "\u7C7B\u578B",
3629
- idxSource: "\u6765\u6E90",
3630
- idxUnique: "\u552F\u4E00",
3631
- idxNormal: "\u666E\u901A",
3632
- idxAuto: "\u81EA\u52A8",
3633
- idxCreated: "\u663E\u5F0F\u521B\u5EFA",
3634
- idxCount: "\u5171 {n} \u4E2A\u7D22\u5F15",
3635
- idxNoExtra: "\u8BE5\u8868\u9664\u4E3B\u952E\u5916\u6CA1\u6709\u989D\u5916\u7D22\u5F15",
3636
- idxRowsHelp: "\u6240\u5C5E\u8868\u603B\u884C\u6570\uFF08\u542B\u5DF2\u5220\u9664\u884C\uFF09\uFF0C\u4E0D\u662F\u7D22\u5F15\u6761\u76EE\u6570",
3637
- idxTable: "\u8868",
3638
- idxRows: "\u884C\u6570",
3639
- idxCols: "\u5217\u6570",
3640
- idxKey: "\u4E3B\u952E",
3641
- idxIndexes: "\u7D22\u5F15",
3642
- idxLastWrite: "\u6700\u8FD1\u5199\u5165",
3643
- idxNone: "\u65E0",
3644
- idxEmpty: "\u5F53\u524D\u8868\u6CA1\u6709\u53EF\u7528\u7684\u7D22\u5F15\u7EDF\u8BA1",
3645
- idxTables: "\u8868",
3646
- idxAt: "\u7EDF\u8BA1\u65F6\u95F4"
3647
- },
3648
- en: {
3649
- title: "Data",
3650
- subtitle: "Read-only view of this plugin's tables; system and deleted rows are hidden by default",
3651
- tables: "Tables",
3652
- rows: "rows",
3653
- deleted: "deleted",
3654
- rowCount: "{n} rows",
3655
- deletedCount: "{n} deleted",
3656
- search: "Search all text columns\u2026",
3657
- pageSize: "Rows",
3658
- includeDeleted: "Deleted",
3659
- showSystem: "System",
3660
- refresh: "Refresh",
3661
- loading: "Loading\u2026",
3662
- empty: "This table has no rows yet",
3663
- emptyTable: "No tables to show",
3664
- loadFail: "Data service unavailable (plugin too old?)",
3665
- retry: "Retry",
3666
- queryFail: "Query failed: ",
3667
- noRows: "No matching rows",
3668
- prev: "Previous",
3669
- next: "Next",
3670
- pageInfo: "Page {page} / {pages}",
3671
- jump: "Jump",
3672
- total: "{n} rows",
3673
- copied: "Copied",
3674
- copy: "Copy",
3675
- close: "Close",
3676
- drawerTitle: "{column} \xB7 row {row}",
3677
- nullText: "NULL",
3678
- emptyText: "empty",
3679
- yes: "Yes",
3680
- no: "No",
3681
- json: "JSON",
3682
- queryTime: "{n} ms",
3683
- sortAsc: "ascending",
3684
- sortDesc: "descending",
3685
- filterCol: "Filter\u2026",
3686
- filterClear: "Clear filter",
3687
- index: "Table index",
3688
- indexSub: "Indexes of the selected table (read-only); rows are the table total, not index entries",
3689
- idxName: "Index name",
3690
- idxColumns: "Columns",
3691
- idxType: "Type",
3692
- idxSource: "Source",
3693
- idxUnique: "Unique",
3694
- idxNormal: "Normal",
3695
- idxAuto: "Automatic",
3696
- idxCreated: "Explicit",
3697
- idxCount: "{n} indexes",
3698
- idxNoExtra: "This table has no indexes other than its primary key",
3699
- idxRowsHelp: "Total table rows (including deleted rows), not index entries",
3700
- idxTable: "Table",
3701
- idxRows: "Rows",
3702
- idxCols: "Cols",
3703
- idxKey: "Primary key",
3704
- idxIndexes: "Indexes",
3705
- idxLastWrite: "Last write",
3706
- idxNone: "\u2014",
3707
- idxEmpty: "No index statistics available for this table",
3708
- idxTables: "Tables",
3709
- idxAt: "Generated"
3710
- }
3711
- };
3712
- module2.exports = COPY;
3713
- }
3714
- });
3715
-
3716
- // packages/addons/lib/visual-tokens.cjs
3717
- var require_visual_tokens = __commonJS({
3718
- "packages/addons/lib/visual-tokens.cjs"(exports2, module2) {
3719
- module2.exports = `
3720
- :where(.wbt-root,.wbi-root,.wbi-cfg,.wbt-data,.wbs-data,.wbg-data,.wbi-data,.wb-desc){--wb-radius-sm:8px;--wb-radius-card:12px;--wb-space-sm:8px;--wb-space-md:14px;--wb-border:var(--dsw-alias-border-l2,color-mix(in oklab,currentColor 16%,transparent));--wb-description-bg:color-mix(in oklab,var(--dsw-alias-brand-primary,#5b7fd6) 7%,transparent);--wb-description-line:color-mix(in oklab,var(--dsw-alias-brand-primary,#5b7fd6) 34%,transparent);--wb-motion:140ms;--wb-btn-bg:transparent;--wb-btn-hover-bg:color-mix(in oklab,currentColor 6%,transparent);--wb-btn-active-bg:color-mix(in oklab,currentColor 11%,transparent);--wb-btn-primary-bg:var(--dsw-alias-brand-primary,#2563eb);--wb-btn-primary-fg:var(--dsw-alias-label-primary-inverted,#fff);--wb-btn-danger-fg:var(--dsw-alias-state-error-primary,#b91c1c);--wb-btn-size-sm:32px;--wb-btn-focus:2px solid var(--dsw-alias-brand-primary,#2563eb);--wb-btn-focus-offset:2px}
3721
- .wb-desc{background:var(--wb-description-bg);border-left-color:var(--wb-description-line);border-radius:0 var(--wb-radius-sm) var(--wb-radius-sm) 0}
3722
- `;
3723
- }
3724
- });
3725
-
3726
- // packages/addons/lib/data-style.cjs
3727
- var require_data_style = __commonJS({
3728
- "packages/addons/lib/data-style.cjs"(exports2, module2) {
3729
- "use strict";
3730
- module2.exports = function(DOMAIN, PREFIX) {
3731
- var P = PREFIX + "-data";
3732
- var CSS = [
3733
- require_visual_tokens(),
3734
- "." + P + "-search:has(.wbi-svg) input{padding-left:30px}." + P + "-search>.wbi-svg{position:absolute;left:10px;top:50%;transform:translateY(-50%)}",
3735
- "." + P + "-btn{transition:background var(--wb-motion),border-color var(--wb-motion)}",
3736
- "@media(max-width:480px){." + P + "-head>." + P + "-btn:has(.wbi-svg){width:32px;height:32px;padding:0;justify-content:center}." + P + "-head>." + P + "-btn:has(.wbi-svg) ." + P + "-btnlabel{display:none}}",
3737
- "." + P + "{--cfg-line:var(--wb-border);--cfg-surface:var(--wb-surface,var(--dsw-alias-bg-layer-1,transparent));--cfg-muted:var(--dsw-alias-label-secondary,color-mix(in oklab,currentColor 62%,transparent));--cfg-faint:var(--dsw-alias-label-tertiary,color-mix(in oklab,currentColor 42%,transparent));--cfg-hover:var(--dsw-alias-interactive-bg-hover,color-mix(in oklab,currentColor 5%,transparent));display:grid;grid-template-columns:216px minmax(0,1fr);gap:16px;width:100%;min-width:0;color:inherit;font-size:13px;align-items:start}",
3738
- "." + P + "-side{position:sticky;top:12px;display:flex;flex-direction:column;gap:3px;border:1px solid var(--cfg-line);border-radius:var(--wb-radius-card);background:var(--cfg-surface);padding:8px;box-shadow:0 1px 2px color-mix(in oklab,currentColor 3%,transparent)}",
3739
- "." + P + "-sidetitle{display:flex;align-items:center;justify-content:space-between;padding:6px 10px 8px;font-size:11px;font-weight:660;letter-spacing:.6px;text-transform:uppercase;color:var(--cfg-faint)}",
3740
- "." + P + "-stab{display:flex;flex-direction:column;gap:3px;align-items:stretch;border:1px solid transparent;background:transparent;border-radius:9px;padding:8px 10px;font:inherit;color:inherit;text-align:left;cursor:pointer;position:relative;transition:background .12s ease,border-color .12s ease}",
3741
- "." + P + "-stab:hover{background:var(--cfg-hover)}",
3742
- "." + P + "-stab:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
3743
- "." + P + "-stab.on{background:color-mix(in oklab,currentColor 6%,transparent);border-color:var(--cfg-line)}",
3744
- "." + P + "-stab.on::before{content:'';position:absolute;left:-1px;top:9px;bottom:9px;width:2px;border-radius:2px;background:var(--dsw-alias-brand-primary,currentColor)}",
3745
- "." + P + "-stabname{display:flex;align-items:center;gap:6px;font-size:12.5px;font-weight:600;line-height:1.4;min-width:0}",
3746
- "." + P + "-stabname span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
3747
- "." + P + "-sidetable{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px;color:var(--cfg-muted);margin-top:3px;letter-spacing:.2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
3748
- "." + P + "-sidecount{margin-left:auto;font-size:10.5px;font-variant-numeric:tabular-nums;color:var(--cfg-muted);background:color-mix(in oklab,currentColor 8%,transparent);border-radius:999px;padding:1px 7px;flex:none}",
3749
- "." + P + "-main{display:flex;flex-direction:column;gap:10px;min-width:0;border:1px solid var(--cfg-line);border-radius:var(--wb-radius-card);background:var(--cfg-surface);padding:14px 16px 12px;box-shadow:0 1px 2px color-mix(in oklab,currentColor 3%,transparent)}",
3750
- "." + P + "-head{display:flex;align-items:flex-start;gap:12px;flex-wrap:wrap}",
3751
- "." + P + "-headmain{min-width:0;flex:1}",
3752
- "." + P + "-head h2{margin:0;font-size:16px;font-weight:660;letter-spacing:.1px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
3753
- "." + P + "-code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;font-weight:500;color:var(--cfg-muted);background:color-mix(in oklab,currentColor 6%,transparent);border-radius:6px;padding:2px 6px}",
3754
- "." + P + "-sub{font-size:11.5px;color:var(--cfg-muted);line-height:1.55;margin-top:4px}",
3755
- "." + P + "-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:2px 0 4px}",
3756
- "." + P + "-search{position:relative;flex:1;min-width:180px;max-width:340px}",
3757
- "." + P + "-search input{width:100%;border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:9px;padding:8px 11px;font:inherit;font-size:12.5px;outline:none;transition:border-color .15s ease,box-shadow .15s ease}",
3758
- "." + P + "-search input:hover{border-color:color-mix(in oklab,currentColor 28%,var(--cfg-line))}",
3759
- "." + P + "-search input:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
3760
- "." + P + "-select{border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:9px;padding:7px 10px;font:inherit;font-size:12px;outline:none}",
3761
- "." + P + "-select:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
3762
- "." + P + "-btn{display:inline-flex;align-items:center;gap:5px;border:1px solid var(--cfg-line);background:transparent;color:var(--cfg-muted);border-radius:8px;padding:6px 10px;font:inherit;font-size:11.5px;cursor:pointer;white-space:nowrap;transition:background .12s ease,color .12s ease}",
3763
- "." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
3764
- "." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
3765
- "." + P + "-btn:disabled{opacity:.45;cursor:not-allowed}",
3766
- "." + P + "-btn[aria-busy='true']{opacity:.6}",
3767
- "." + P + "-tablewrap{overflow:auto;max-height:calc(100vh - 300px);border:1px solid var(--cfg-line);border-radius:11px;background:var(--dsw-alias-bg-base,transparent)}",
3768
- "." + P + "-table{border-collapse:separate;border-spacing:0;width:max-content;min-width:100%;font-size:12.5px}",
3769
- "." + P + "-table th{position:sticky;top:0;z-index:2;background:var(--cfg-surface);border-bottom:1px solid var(--cfg-line);padding:0;text-align:left;font-weight:600;white-space:nowrap}",
3770
- "." + P + "-thbtn{display:flex;align-items:baseline;gap:6px;width:100%;border:0;background:transparent;color:inherit;font:inherit;font-size:11.5px;font-weight:660;letter-spacing:.2px;padding:9px 12px;cursor:pointer;text-align:left;white-space:nowrap}",
3771
- "." + P + "-thbtn:hover{background:var(--cfg-hover)}",
3772
- "." + P + "-thbtn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:-2px}",
3773
- "." + P + "-coltype{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:9.5px;font-weight:500;color:var(--cfg-faint);letter-spacing:.3px}",
3774
- "." + P + "-sortmark{color:var(--dsw-alias-brand-primary,currentColor);font-size:10px}",
3775
- "." + P + "-rownum{position:sticky;left:0;z-index:1;background:var(--cfg-surface);color:var(--cfg-faint);text-align:right;font-variant-numeric:tabular-nums;font-size:10.5px;padding:0 8px;width:1%;white-space:nowrap;border-right:1px solid color-mix(in oklab,currentColor 7%,transparent)}",
3776
- "." + P + "-table thead ." + P + "-rownum{z-index:3}",
3777
- "." + P + "-cell{padding:7px 12px;border-bottom:1px solid color-mix(in oklab,currentColor 6%,transparent);max-width:340px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:default;vertical-align:top}",
3778
- "." + P + "-table tbody tr:hover ." + P + "-cell{background:var(--cfg-hover)}",
3779
- "." + P + "-table tbody tr:nth-child(even) ." + P + "-cell,." + P + "-table tbody tr:nth-child(even) ." + P + "-rownum{background:color-mix(in oklab,currentColor 2.5%,transparent)}",
3780
- "." + P + "-cell.num{text-align:right;font-variant-numeric:tabular-nums}",
3781
- "." + P + "-cell.mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px}",
3782
- "." + P + "-cell.null{color:var(--cfg-faint);font-style:italic}",
3783
- "." + P + "-cell.json .v{color:var(--dsw-alias-brand-primary,inherit)}",
3784
- "." + P + "-tr.deleted ." + P + "-cell,." + P + "-tr.deleted ." + P + "-rownum{opacity:.55}",
3785
- "." + P + "-tr.deleted ." + P + "-cell .v{text-decoration:line-through;text-decoration-color:color-mix(in oklab,currentColor 35%,transparent)}",
3786
- "." + P + "-delbadge{display:inline-block;margin-left:6px;font-size:9.5px;line-height:1.5;padding:0 5px;border-radius:999px;background:color-mix(in oklab,var(--dsw-alias-state-error-primary,currentColor) 14%,transparent);color:var(--dsw-alias-state-error-primary,inherit);vertical-align:middle}",
3787
- "." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
3788
- "." + P + "-grow{flex:1}",
3789
- "." + P + "-pageinfo{font-variant-numeric:tabular-nums}",
3790
- "." + P + "-jump .wbctl-num-input{width:56px;padding:4px 7px;font-size:11.5px;text-align:right}",
3791
- "." + P + "-jump .wbctl-num-hint{display:none}",
3792
- "." + P + "-empty{border:1px dashed var(--cfg-line);border-radius:11px;padding:44px 16px;text-align:center;font-size:12.5px;color:var(--cfg-muted)}",
3793
- "." + P + "-err{display:flex;align-items:center;gap:10px;flex-wrap:wrap;border:1px solid color-mix(in oklab,var(--dsw-alias-state-error-primary,currentColor) 32%,var(--cfg-line));border-radius:10px;padding:9px 12px;color:var(--dsw-alias-state-error-primary,inherit);font-size:12px;line-height:1.5}",
3794
- "." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
3795
- "." + P + "-sk{height:26px;border-radius:4px;background:var(--dsw-alias-bg-skeleton,color-mix(in oklab,currentColor 6%,transparent));animation:" + PREFIX + "-data-pulse 1.4s ease-in-out infinite}",
3796
- "@keyframes " + PREFIX + "-data-pulse{0%,100%{opacity:.6}50%{opacity:1}}",
3797
- "." + P + "-toast{position:fixed;left:50%;bottom:26px;transform:translateX(-50%);z-index:40;background:var(--dsw-alias-bg-layer-1,var(--cfg-surface));border:1px solid var(--cfg-line);border-radius:999px;padding:7px 14px;font-size:12px;color:var(--dsw-alias-label-primary,inherit);box-shadow:0 6px 24px color-mix(in oklab,currentColor 18%,transparent)}",
3798
- "." + P + "-mask{position:fixed;inset:0;z-index:30;background:color-mix(in oklab,currentColor 26%,transparent)}",
3799
- "." + P + "-drawer{position:fixed;top:0;right:0;bottom:0;z-index:31;width:min(520px,92vw);display:flex;flex-direction:column;gap:12px;background:var(--dsw-alias-bg-layer-1,var(--cfg-surface));border-left:1px solid var(--cfg-line);box-shadow:-8px 0 28px color-mix(in oklab,currentColor 16%,transparent);padding:18px 20px}",
3800
- "." + P + "-drawer h3{margin:0;font-size:14px;font-weight:660;display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
3801
- "." + P + "-drawer pre{margin:0;flex:1;overflow:auto;border:1px solid var(--cfg-line);border-radius:10px;background:var(--dsw-alias-bg-base,transparent);padding:12px 14px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;line-height:1.65;white-space:pre-wrap;word-break:break-word}",
3802
- "." + P + "-drawerfoot{display:flex;gap:8px;justify-content:flex-end}",
3803
- "." + P + "-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}",
3804
- "@media (max-width:900px){." + P + "{grid-template-columns:minmax(0,1fr)}." + P + "-side{position:static;flex-direction:row;flex-wrap:wrap;gap:6px;padding:6px}." + P + "-sidetitle{display:none}." + P + "-stab{padding:6px 10px;flex:none}." + P + "-sidecount{display:none}." + P + "-tablewrap{max-height:calc(100vh - 260px)}}",
3805
- "@media (prefers-reduced-motion:reduce){." + P + " *,." + P + "-track,." + P + "-track::after,." + P + "-sk,." + P + "-drawer{transition:none;animation:none}}",
3806
- "." + P + "-idxsub{font-size:11.5px;color:var(--cfg-muted);line-height:1.55}",
3807
- "." + P + "-idxsum{display:flex;gap:16px;flex-wrap:wrap;font-size:11.5px;color:var(--cfg-muted)}",
3808
- "." + P + "-idxsum b{font-weight:660;color:var(--dsw-alias-label-primary,inherit);font-variant-numeric:tabular-nums}",
3809
- "." + P + "-idxtable{width:100%;table-layout:fixed}." + P + "-idxtable ." + P + "-cell{white-space:normal;overflow-wrap:anywhere;max-width:none}." + P + "-idxtable th:first-child{width:30%}." + P + "-idxtable th:nth-child(2){width:28%}",
3810
- "." + P + "-idxtags{display:flex;flex-wrap:wrap;gap:4px;max-width:280px}",
3811
- "." + P + "-idxchip{display:inline-block;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10px;line-height:1.6;border-radius:999px;padding:0 7px;background:color-mix(in oklab,currentColor 7%,transparent);color:var(--cfg-muted);white-space:nowrap}",
3812
- "." + P + "-idxchip.u{background:color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 15%,transparent);color:var(--dsw-alias-brand-primary,inherit)}",
3813
- "." + P + "-idxnone{color:var(--cfg-faint)}",
3814
- "." + P + "-frow th{padding:0 8px 6px;border-bottom:1px solid var(--cfg-line)}",
3815
- "." + P + "-fcell{position:relative;display:block;min-width:96px}",
3816
- "." + P + "-finput{width:100%;box-sizing:border-box;border:1px solid transparent;border-radius:6px;background:color-mix(in oklab,currentColor 4%,transparent);color:inherit;font:inherit;font-size:11.5px;padding:3px 18px 3px 6px;min-width:0}",
3817
- "." + P + "-finput:hover{background:color-mix(in oklab,currentColor 7%,transparent)}",
3818
- "." + P + "-finput:focus{outline:none;border-color:var(--dsw-alias-brand-primary,currentColor);background:var(--cfg-surface)}",
3819
- "." + P + "-fclear{position:absolute;right:2px;top:50%;transform:translateY(-50%);border:0;background:transparent;color:var(--cfg-muted);cursor:pointer;font-size:13px;line-height:1;padding:2px 4px;border-radius:4px}",
3820
- "." + P + "-fclear:hover{color:inherit;background:var(--cfg-hover)}",
3821
- "." + P + "-emptycell{padding:22px 12px;text-align:center;color:var(--cfg-muted)}",
3822
- "." + P + " *{box-sizing:border-box}",
3823
- "." + P + "-tabs{display:flex;gap:6px;border-bottom:1px solid var(--cfg-line);padding-bottom:9px}",
3824
- "." + P + "-tabs [aria-selected=true]{background:var(--cfg-hover);color:inherit;font-weight:660}",
3825
- "." + P + "-images{display:flex;gap:5px;align-items:center}",
3826
- "." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
3827
- "." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
3828
- "." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
3829
- ].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
3830
- if (DOMAIN === "storage") {
3831
- var buttons = "." + P + " :is(button)";
3832
- CSS += buttons + "{border:none;background:var(--wb-btn-bg);min-height:var(--wb-btn-size-sm);min-width:var(--wb-btn-size-sm)}" + buttons + ":enabled:hover{background:var(--wb-btn-hover-bg)}" + buttons + ":enabled:active{background:var(--wb-btn-active-bg)}" + buttons + ":disabled{background:var(--wb-btn-bg);color:var(--cfg-muted)}" + buttons + ":focus-visible{outline:var(--wb-btn-focus);outline-offset:var(--wb-btn-focus-offset)}." + P + "-fcell:has(button) input{padding-right:34px}";
3833
- }
3834
- function injectCss() {
3835
- if (typeof document === "undefined") return;
3836
- var old = document.getElementById("wb-addon-" + DOMAIN + "-data-css");
3837
- if (old) {
3838
- old.textContent = CSS;
3839
- return;
3840
- }
3841
- var style = document.createElement("style");
3842
- style.id = "wb-addon-" + DOMAIN + "-data-css";
3843
- style.setAttribute("data-wb-addon", "wb-addon-" + DOMAIN);
3844
- style.textContent = CSS;
3845
- document.head.appendChild(style);
3846
- }
3847
- return injectCss;
3848
- };
3849
- }
3850
- });
3851
-
3852
- // packages/addons/lib/data-view.cjs
3853
- var require_data_view = __commonJS({
3854
- "packages/addons/lib/data-view.cjs"(exports2, module2) {
3855
- "use strict";
3856
- var React = require("react");
3857
- var NF = require_number_field();
3858
- var h = React.createElement;
3859
- var COPY = require_data_copy();
3860
- var SW = require_switch();
3861
- module2.exports = function createDataView(options) {
3862
- var DOMAIN = options.domain;
3863
- function icon(name) {
3864
- return options.Icon ? h(options.Icon, { name }) : null;
3865
- }
3866
- var P = options.prefix + "-data";
3867
- var configView = { useConfig: options.useConfig };
3868
- var columnHooks = options.columns || {};
3869
- var injectCss = require_data_style()(DOMAIN, options.prefix);
3870
- var CFG_FALLBACK = {
3871
- "data.pageSize": 50,
3872
- "data.showSystemColumns": false,
3873
- "data.includeDeleted": false
3874
- };
3875
- var PAGE_SIZES = [10, 25, 50, 100, 200];
3876
- function unwrap(r) {
3877
- return r && r.result !== void 0 ? r.result : r;
3878
- }
3879
- function fmt(template, vars) {
3880
- return String(template).replace(/\{(\w+)\}/g, function(m, key) {
3881
- return vars[key] === void 0 ? m : String(vars[key]);
3882
- });
3883
- }
3884
- function pad2(n) {
3885
- return n < 10 ? "0" + n : String(n);
3886
- }
3887
- function timeText(ms) {
3888
- var d = new Date(Number(ms));
3889
- if (!Number.isFinite(d.getTime())) return String(ms);
3890
- return d.getFullYear() + "-" + pad2(d.getMonth() + 1) + "-" + pad2(d.getDate()) + " " + pad2(d.getHours()) + ":" + pad2(d.getMinutes());
3891
- }
3892
- function looksJson(value) {
3893
- var text = String(value).trim();
3894
- if (!text || text[0] !== "{" && text[0] !== "[") return false;
3895
- try {
3896
- JSON.parse(text);
3897
- return true;
3898
- } catch (e) {
3899
- return false;
3900
- }
3901
- }
3902
- function rawText(value, col) {
3903
- if (value === null || value === void 0) return "";
3904
- return String(value);
3905
- }
3906
- function DataView(props) {
3907
- var api = props.api;
3908
- var lang = props.lang === "en" ? "en" : "zh";
3909
- var t = Object.assign({}, COPY[lang], { indexSub: fmt(COPY[lang].indexSub, { tables: options.tables.join(" / "), domain: DOMAIN }) });
3910
- var cfgWrap = configView.useConfig(api, CFG_FALLBACK);
3911
- var cfg = cfgWrap.values;
3912
- var tablesS = React.useState(null);
3913
- var tables = tablesS[0], setTables = tablesS[1];
3914
- var activeS = React.useState("");
3915
- var active = activeS[0], setActive = activeS[1];
3916
- var dataS = React.useState(null);
3917
- var data = dataS[0], setData = dataS[1];
3918
- var loadingS = React.useState(false);
3919
- var loadingRows = loadingS[0], setLoadingRows = loadingS[1];
3920
- var loadingTablesS = React.useState(true);
3921
- var loadingTables = loadingTablesS[0], setLoadingTables = loadingTablesS[1];
3922
- var errorS = React.useState("");
3923
- var error = errorS[0], setError = errorS[1];
3924
- var pageS = React.useState(1);
3925
- var page = pageS[0], setPage = pageS[1];
3926
- var sizeS = React.useState(0);
3927
- var pageSize = sizeS[0], setPageSize = sizeS[1];
3928
- var sortS = React.useState("");
3929
- var sort = sortS[0], setSort = sortS[1];
3930
- var orderS = React.useState("desc");
3931
- var order = orderS[0], setOrder = orderS[1];
3932
- var searchDraftS = React.useState("");
3933
- var searchDraft = searchDraftS[0], setSearchDraft = searchDraftS[1];
3934
- var searchS = React.useState("");
3935
- var search = searchS[0], setSearch = searchS[1];
3936
- var filterDraftS = React.useState({});
3937
- var filterDraft = filterDraftS[0], setFilterDraft = filterDraftS[1];
3938
- var filtersS = React.useState({});
3939
- var filters = filtersS[0], setFilters = filtersS[1];
3940
- var includeDeletedS = React.useState(null);
3941
- var includeDeletedRaw = includeDeletedS[0], setIncludeDeleted = includeDeletedS[1];
3942
- var showSystemS = React.useState(null);
3943
- var showSystemRaw = showSystemS[0], setShowSystem = showSystemS[1];
3944
- var drawerS = React.useState(null);
3945
- var drawer = drawerS[0], setDrawer = drawerS[1];
3946
- var toastS = React.useState("");
3947
- var toast = toastS[0], setToast = toastS[1];
3948
- var filtersKey = JSON.stringify(filters);
3949
- var reqRef = React.useRef(0);
3950
- var toastTimer = React.useRef(null);
3951
- var refreshS = React.useState(0);
3952
- function refresh() {
3953
- loadTables();
3954
- refreshS[1](function(n) {
3955
- return n + 1;
3956
- });
3957
- }
3958
- var indexReqRef = React.useRef(0);
3959
- var indexS = React.useState(null);
3960
- var index = indexS[0], setIndex = indexS[1];
3961
- var indexBusyS = React.useState(false);
3962
- var indexBusy = indexBusyS[0], setIndexBusy = indexBusyS[1];
3963
- var cfgSize = Number(cfg["data.pageSize"]) || 50;
3964
- var size = pageSize || (PAGE_SIZES.indexOf(cfgSize) >= 0 ? cfgSize : 50);
3965
- var includeDeleted = includeDeletedRaw === null ? cfg["data.includeDeleted"] === true : includeDeletedRaw;
3966
- var showSystem = showSystemRaw === null ? cfg["data.showSystemColumns"] === true : showSystemRaw;
3967
- function say(text) {
3968
- setToast(text);
3969
- if (toastTimer.current) clearTimeout(toastTimer.current);
3970
- toastTimer.current = setTimeout(function() {
3971
- setToast("");
3972
- }, 1600);
3973
- }
3974
- function loadTables() {
3975
- setLoadingTables(true);
3976
- Promise.resolve((options.tablesLoader || function(a) {
3977
- return a.call(DOMAIN + ".dataTables");
3978
- })(api)).then(function(r) {
3979
- if (r && r.ok === false) throw new Error(r && r.error || t.loadFail);
3980
- var body = unwrap(r);
3981
- if (!body || !Array.isArray(body.tables)) throw new Error(t.loadFail);
3982
- setTables(body.tables);
3983
- setError("");
3984
- if (!active && body.tables.length) setActive(body.tables[0].name);
3985
- }).catch(function(e) {
3986
- setError(String(e && e.message || e) || t.loadFail);
3987
- }).then(function() {
3988
- setLoadingTables(false);
3989
- });
3990
- }
3991
- React.useEffect(function() {
3992
- injectCss();
3993
- loadTables();
3994
- return function() {
3995
- indexReqRef.current++;
3996
- if (toastTimer.current) clearTimeout(toastTimer.current);
3997
- };
3998
- }, []);
3999
- function selectTable(name) {
4000
- if (name === active) return;
4001
- reqRef.current++;
4002
- setActive(name);
4003
- setData(null);
4004
- setDrawer(null);
4005
- setError("");
4006
- setLoadingRows(true);
4007
- setPage(1);
4008
- setSort("");
4009
- setOrder("desc");
4010
- setSearch("");
4011
- setSearchDraft("");
4012
- setFilterDraft({});
4013
- setFilters({});
4014
- }
4015
- React.useEffect(function() {
4016
- if (searchDraft === search) return void 0;
4017
- var timer = setTimeout(function() {
4018
- setSearch(searchDraft);
4019
- setPage(1);
4020
- }, 280);
4021
- return function() {
4022
- clearTimeout(timer);
4023
- };
4024
- }, [searchDraft]);
4025
- React.useEffect(function() {
4026
- if (JSON.stringify(filterDraft) === JSON.stringify(filters)) return void 0;
4027
- var timer = setTimeout(function() {
4028
- setFilters(filterDraft);
4029
- setPage(1);
4030
- }, 280);
4031
- return function() {
4032
- clearTimeout(timer);
4033
- };
4034
- }, [filterDraft]);
4035
- React.useEffect(function() {
4036
- if (!active || !cfgWrap.ready || index) return void 0;
4037
- var req = ++reqRef.current;
4038
- setLoadingRows(true);
4039
- var args = { table: active, page, pageSize: size, order, includeDeleted };
4040
- if (sort) args.sort = sort;
4041
- if (search) args.search = search;
4042
- if (Object.keys(filters).length) args.filters = filters;
4043
- Promise.resolve((options.query || function(a, q) {
4044
- return a.call(DOMAIN + ".dataQuery", q);
4045
- })(api, args)).then(function(r) {
4046
- if (req !== reqRef.current) return;
4047
- if (r && r.ok === false) throw new Error(r && r.error || t.queryFail);
4048
- var body = unwrap(r);
4049
- if (!body) throw new Error(t.queryFail);
4050
- setData(body);
4051
- setError("");
4052
- if (body.page !== page) setPage(body.page);
4053
- }).catch(function(e) {
4054
- if (req !== reqRef.current) return;
4055
- setError(String(e && e.message || e) || t.queryFail);
4056
- }).then(function() {
4057
- if (req === reqRef.current) setLoadingRows(false);
4058
- });
4059
- return function() {
4060
- reqRef.current++;
4061
- };
4062
- }, [active, page, size, sort, order, search, includeDeleted, cfgWrap.ready, filtersKey, refreshS[0], !!index]);
4063
- React.useEffect(function() {
4064
- if (!drawer) return void 0;
4065
- function onKey(e) {
4066
- if (e.key === "Escape") setDrawer(null);
4067
- }
4068
- document.addEventListener("keydown", onKey);
4069
- return function() {
4070
- document.removeEventListener("keydown", onKey);
4071
- };
4072
- }, [drawer]);
4073
- var current = null;
4074
- if (tables) {
4075
- for (var i = 0; i < tables.length; i++) if (tables[i].name === active) current = tables[i];
4076
- }
4077
- function leaveIndex() {
4078
- indexReqRef.current++;
4079
- setIndex(null);
4080
- setIndexBusy(false);
4081
- setError("");
4082
- }
4083
- function loadIndex() {
4084
- reqRef.current++;
4085
- setError("");
4086
- var req = ++indexReqRef.current;
4087
- setIndex([]);
4088
- setIndexBusy(true);
4089
- Promise.resolve(api.call(DOMAIN + ".dataTables", { stats: true })).then(function(r) {
4090
- if (req !== indexReqRef.current) return;
4091
- if (r && r.ok === false) throw new Error(r.error || t.loadFail);
4092
- var payload = unwrap(r) || {};
4093
- var rows = (payload.tables || []).map(function(tb) {
4094
- return { table: tb, stats: tb.stats || null };
4095
- });
4096
- setIndex(rows);
4097
- setError("");
4098
- setIndexBusy(false);
4099
- }).catch(function(e) {
4100
- if (req !== indexReqRef.current) return;
4101
- setError(String(e.message || e));
4102
- setIndex([]);
4103
- setIndexBusy(false);
4104
- });
4105
- }
4106
- function renderIndex() {
4107
- var row = (index || []).filter(function(r) {
4108
- return r.table.name === active;
4109
- })[0];
4110
- var tb = row ? row.table : current;
4111
- var st = row && row.stats;
4112
- var indexes = st ? st.indexes || [] : [];
4113
- var hasExtra = indexes.some(function(ix) {
4114
- return ix.origin !== "pk";
4115
- });
4116
- var count = st && st.rows !== void 0 ? st.rows : tb && tb.count;
4117
- return h(
4118
- "div",
4119
- { className: P + "-idx" },
4120
- h(
4121
- "div",
4122
- { className: P + "-head" },
4123
- h(
4124
- "div",
4125
- { className: P + "-headmain" },
4126
- h("h2", null, icon("database"), tableLabel(tb), h("span", { className: P + "-code" }, active)),
4127
- h("div", { className: P + "-idxsub" }, t.indexSub)
4128
- ),
4129
- h("button", {
4130
- type: "button",
4131
- className: P + "-btn",
4132
- "aria-label": t.refresh,
4133
- title: t.refresh,
4134
- "aria-busy": indexBusy ? "true" : "false",
4135
- onClick: function() {
4136
- loadIndex();
4137
- }
4138
- }, icon("refresh"), h("span", { className: P + "-btnlabel" }, t.refresh))
4139
- ),
4140
- st ? h(
4141
- "div",
4142
- { className: P + "-idxsum" },
4143
- h("span", null, t.idxRows, " ", h("b", null, String(count))),
4144
- h("span", null, t.idxCols, " ", h("b", null, String(st.columnCount === void 0 ? (tb.columns || []).length : st.columnCount))),
4145
- h("span", null, fmt(t.idxCount, { n: indexes.length }))
4146
- ) : null,
4147
- indexBusy ? options.Skeleton ? h(options.Skeleton, { lang, label: t.loading }) : h("div", { className: P + "-empty", role: "status", "aria-busy": "true" }, t.loading) : !st ? h("div", { className: P + "-empty" }, t.idxEmpty) : !hasExtra ? h("div", { className: P + "-empty" }, t.idxNoExtra) : h(
4148
- "div",
4149
- { className: P + "-tablewrap" },
4150
- h(
4151
- "table",
4152
- { className: P + "-table " + P + "-idxtable" },
4153
- h("thead", null, h(
4154
- "tr",
4155
- null,
4156
- [t.idxName, t.idxColumns, t.idxType, t.idxSource, t.idxRows].map(function(label) {
4157
- return h("th", { scope: "col", key: label }, h("span", { className: P + "-thbtn" }, label));
4158
- })
4159
- )),
4160
- h("tbody", null, indexes.map(function(ix) {
4161
- return h(
4162
- "tr",
4163
- { className: P + "-tr", key: ix.name },
4164
- h("td", { className: P + "-cell mono" }, ix.name),
4165
- h("td", { className: P + "-cell mono" }, (ix.columns || []).join(", ") || t.idxNone),
4166
- h("td", { className: P + "-cell" }, ix.origin === "pk" ? t.idxKey : ix.unique ? t.idxUnique : t.idxNormal),
4167
- h("td", { className: P + "-cell" }, /^sqlite_autoindex_/.test(ix.name) ? t.idxAuto : t.idxCreated),
4168
- h("td", { className: P + "-cell num", title: t.idxRowsHelp }, String(count))
4169
- );
4170
- }))
4171
- )
4172
- )
4173
- );
4174
- }
4175
- function tableLabel(tb) {
4176
- if (!tb || !tb.label) return "";
4177
- return lang === "en" ? tb.label.en || tb.label.zh : tb.label.zh || tb.label.en;
4178
- }
4179
- function colLabel(col) {
4180
- if (!col.label) return col.name;
4181
- return lang === "en" ? col.label.en || col.label.zh : col.label.zh || col.label.en;
4182
- }
4183
- function visibleColumns() {
4184
- var cols = data && data.columns ? data.columns.map(function(col) {
4185
- var hook = columnHooks[col.name];
4186
- return hook && hook.kind ? Object.assign({}, col, { kind: hook.kind, type: hook.type || col.type }) : col;
4187
- }) : [];
4188
- return cols.filter(function(c) {
4189
- return showSystem || !c.system;
4190
- });
4191
- }
4192
- function toggleSort(name) {
4193
- if (sort !== name) {
4194
- setSort(name);
4195
- setOrder("desc");
4196
- return;
4197
- }
4198
- if (order === "desc") {
4199
- setOrder("asc");
4200
- return;
4201
- }
4202
- setSort("");
4203
- setOrder("desc");
4204
- }
4205
- function ariaSort(name) {
4206
- if (sort !== name) return "none";
4207
- return order === "asc" ? "ascending" : "descending";
4208
- }
4209
- function copyCell(value) {
4210
- var text = value === null || value === void 0 ? "" : String(value);
4211
- try {
4212
- if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(text);
4213
- else {
4214
- var ta = document.createElement("textarea");
4215
- ta.value = text;
4216
- ta.style.position = "fixed";
4217
- ta.style.opacity = "0";
4218
- document.body.appendChild(ta);
4219
- ta.select();
4220
- document.execCommand("copy");
4221
- document.body.removeChild(ta);
4222
- }
4223
- say(t.copied);
4224
- } catch (e) {
4225
- }
4226
- }
4227
- function cellText(col, value) {
4228
- if (value === null || value === void 0) return null;
4229
- if (col.kind === "bool") return value ? t.yes : t.no;
4230
- if (col.kind === "timestamp") return timeText(value);
4231
- return String(value);
4232
- }
4233
- function cellClass(col, value) {
4234
- var cls = P + "-cell";
4235
- if (value === null || value === void 0) return cls + " null";
4236
- if (col.kind === "number") return cls + " num";
4237
- if (col.kind === "id" || col.kind === "path") return cls + " mono";
4238
- if (col.kind === "text" && looksJson(value)) return cls + " json";
4239
- return cls;
4240
- }
4241
- function cellTitle(col, value) {
4242
- if (value === null || value === void 0) return t.nullText;
4243
- if (col.kind === "timestamp") return String(value);
4244
- if (col.kind === "bool") return value ? "1" : "0";
4245
- return String(value);
4246
- }
4247
- function renderCell(row, col) {
4248
- var value = row[col.name];
4249
- var hook = columnHooks[col.name];
4250
- function openDetail() {
4251
- setDrawer({ column: colLabel(col), name: col.name, row: (data.page - 1) * data.pageSize + row.__i + 1, value });
4252
- }
4253
- var text = cellText(col, value);
4254
- var content;
4255
- if (text === null) content = h("span", { className: "v" }, t.nullText);
4256
- else if (text === "") content = h("span", { className: "v" }, '""');
4257
- else content = h("span", { className: "v" }, text);
4258
- if (hook && hook.render) content = hook.render({ value, row, col, lang, prefix: P, openDetail });
4259
- return h("td", {
4260
- key: col.name,
4261
- className: cellClass(col, value),
4262
- title: cellTitle(col, value),
4263
- onClick: function() {
4264
- copyCell(value);
4265
- },
4266
- onDoubleClick: openDetail
4267
- }, content);
4268
- }
4269
- function activeFilterCount() {
4270
- var n = 0;
4271
- for (var k in filters) if (Object.prototype.hasOwnProperty.call(filters, k)) n++;
4272
- return n;
4273
- }
4274
- function filterCell(col) {
4275
- var val = filterDraft[col.name] === void 0 ? "" : filterDraft[col.name];
4276
- return h(
4277
- "th",
4278
- { key: col.name, scope: "col", className: P + "-fth" },
4279
- h(
4280
- "span",
4281
- { className: P + "-fcell" },
4282
- h("input", {
4283
- className: P + "-finput",
4284
- type: "search",
4285
- value: val,
4286
- placeholder: t.filterCol,
4287
- "aria-label": t.filterCol + " " + colLabel(col),
4288
- title: colLabel(col) + " \xB7 " + t.filterCol,
4289
- onChange: function(e) {
4290
- var v = e.target.value;
4291
- setFilterDraft(function(prev) {
4292
- var next = Object.assign({}, prev);
4293
- if (v) next[col.name] = v;
4294
- else delete next[col.name];
4295
- return next;
4296
- });
4297
- }
4298
- }),
4299
- val ? h("button", {
4300
- type: "button",
4301
- className: P + "-fclear",
4302
- title: t.filterClear,
4303
- "aria-label": t.filterClear + " " + colLabel(col),
4304
- onClick: function() {
4305
- setFilterDraft(function(prev) {
4306
- var next = Object.assign({}, prev);
4307
- delete next[col.name];
4308
- return next;
4309
- });
4310
- }
4311
- }, "\xD7") : null
4312
- )
4313
- );
4314
- }
4315
- function renderRows() {
4316
- if (loadingRows && !data && options.Skeleton) return h(options.Skeleton, { lang, label: t.loading });
4317
- if (loadingRows && !data) {
4318
- return h(
4319
- "div",
4320
- { className: P + "-skwrap", "aria-busy": "true" },
4321
- h("span", { className: P + "-sr" }, t.loading),
4322
- [0, 1, 2, 3, 4, 5, 6, 7].map(function(i2) {
4323
- return h("div", { key: i2, className: P + "-sk" });
4324
- })
4325
- );
4326
- }
4327
- if (error) {
4328
- return h(
4329
- "div",
4330
- { className: P + "-err", role: "alert" },
4331
- h("span", null, t.queryFail + error),
4332
- h("button", { type: "button", className: P + "-btn", onClick: refresh }, t.retry)
4333
- );
4334
- }
4335
- if (!data) return h("div", { className: P + "-empty" }, t.empty);
4336
- var cols = visibleColumns();
4337
- var rows = data.rows || [];
4338
- var narrowing = !!search || activeFilterCount() > 0;
4339
- return h(
4340
- "div",
4341
- { className: P + "-tablewrap" },
4342
- h(
4343
- "table",
4344
- { className: P + "-table" },
4345
- h(
4346
- "thead",
4347
- null,
4348
- h(
4349
- "tr",
4350
- null,
4351
- h("th", { className: P + "-rownum", scope: "col" }, "#"),
4352
- cols.map(function(col) {
4353
- return h(
4354
- "th",
4355
- { key: col.name, scope: "col", "aria-sort": ariaSort(col.name) },
4356
- h(
4357
- "button",
4358
- {
4359
- type: "button",
4360
- className: P + "-thbtn",
4361
- title: colLabel(col) + " \xB7 " + col.type,
4362
- onClick: function() {
4363
- toggleSort(col.name);
4364
- }
4365
- },
4366
- h("span", null, colLabel(col)),
4367
- h("span", { className: P + "-coltype" }, String(col.type || "").toLowerCase()),
4368
- sort === col.name ? h("span", { className: P + "-sortmark", "aria-hidden": "true" }, order === "asc" ? "\u25B2" : "\u25BC") : null
4369
- )
4370
- );
4371
- })
4372
- ),
4373
- h(
4374
- "tr",
4375
- { className: P + "-frow" },
4376
- h("th", { className: P + "-rownum", scope: "col" }, ""),
4377
- cols.map(filterCell)
4378
- )
4379
- ),
4380
- h("tbody", null, rows.length ? rows.map(function(row, idx) {
4381
- row.__i = idx;
4382
- var deleted = row.deleted_at !== null && row.deleted_at !== void 0;
4383
- return h(
4384
- "tr",
4385
- { key: row.id || idx, className: P + "-tr" + (deleted ? " deleted" : "") },
4386
- h("td", { className: P + "-rownum" }, (data.page - 1) * data.pageSize + idx + 1),
4387
- cols.map(function(col) {
4388
- var cell = renderCell(row, col);
4389
- if (deleted && col.name === "id") {
4390
- return React.cloneElement(cell, { key: col.name }, cell.props.children, h("span", { className: P + "-delbadge" }, t.deleted));
4391
- }
4392
- return cell;
4393
- })
4394
- );
4395
- }) : h("tr", null, h("td", { className: P + "-emptycell", colSpan: cols.length + 1 }, narrowing ? t.noRows : t.empty)))
4396
- )
4397
- );
4398
- }
4399
- function renderFoot() {
4400
- var pages = data ? data.pages : 1;
4401
- var total = data ? data.total : 0;
4402
- return h(
4403
- "div",
4404
- { className: P + "-foot" },
4405
- h("span", null, fmt(t.total, { n: total })),
4406
- h("span", { className: P + "-grow" }),
4407
- h("button", { type: "button", className: P + "-btn", disabled: !data || page <= 1, onClick: function() {
4408
- setPage(Math.max(1, page - 1));
4409
- } }, "\u2039 " + t.prev),
4410
- h("span", { className: P + "-pageinfo" }, fmt(t.pageInfo, { page: data ? data.page : 1, pages })),
4411
- h("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
4412
- setPage(Math.min(pages, page + 1));
4413
- } }, t.next + " \u203A"),
4414
- h(NF.NumberField, {
4415
- h,
4416
- lang,
4417
- className: P + "-jump",
4418
- value: page,
4419
- min: 1,
4420
- max: pages,
4421
- integer: true,
4422
- ariaLabel: t.jump,
4423
- hint: false,
4424
- onCommit: function(next) {
4425
- if (next !== null) setPage(next);
4426
- }
4427
- }),
4428
- data && data.queryMs !== void 0 ? h("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
4429
- );
4430
- }
4431
- if (!tables && loadingTables && options.Skeleton) return h(options.Skeleton, { lang, label: t.loading });
4432
- if (!tables && loadingTables) {
4433
- return h("div", { className: P + "-skwrap", "aria-busy": "true" }, h("span", { className: P + "-sr" }, t.loading), [0, 1, 2, 3].map(function(i2) {
4434
- return h("div", { key: i2, className: P + "-sk" });
4435
- }));
4436
- }
4437
- if (!tables) {
4438
- return h("div", { className: P + "-err", role: "alert" }, h("span", null, t.loadFail), h("button", { type: "button", className: P + "-btn", onClick: loadTables }, t.retry));
4439
- }
4440
- if (!tables.length) return h("div", { className: P + "-empty" }, t.emptyTable);
4441
- return h(
4442
- "div",
4443
- { className: P },
4444
- h(
4445
- "div",
4446
- { className: P + "-side" },
4447
- h("div", { className: P + "-sidetitle" }, h("span", null, icon("table"), t.tables), h("span", null, String(tables.length))),
4448
- tables.map(function(tb) {
4449
- return h(
4450
- "button",
4451
- {
4452
- key: tb.name,
4453
- type: "button",
4454
- className: P + "-stab" + (tb.name === active ? " on" : ""),
4455
- "aria-pressed": tb.name === active,
4456
- onClick: function() {
4457
- selectTable(tb.name);
4458
- }
4459
- },
4460
- h(
4461
- "span",
4462
- { className: P + "-stabname" },
4463
- h("span", null, tableLabel(tb)),
4464
- h("span", { className: P + "-sidecount" }, tb.count === void 0 || tb.count === null ? "" : String(tb.count))
4465
- ),
4466
- h("span", { className: P + "-sidetable" }, tb.name)
4467
- );
4468
- })
4469
- ),
4470
- h(
4471
- "div",
4472
- { className: P + "-main" },
4473
- h(
4474
- "div",
4475
- { className: P + "-tabs", role: "tablist", "aria-label": t.title },
4476
- h("button", { type: "button", role: "tab", className: P + "-btn", "aria-selected": !index, onClick: leaveIndex }, icon("list"), lang === "en" ? "Row data" : "\u884C\u6570\u636E"),
4477
- h("button", { type: "button", role: "tab", className: P + "-btn", "aria-selected": !!index, onClick: loadIndex }, icon("database"), t.index)
4478
- ),
4479
- index && error ? h("div", { className: P + "-err", role: "alert" }, error) : null,
4480
- index ? renderIndex() : [
4481
- h(
4482
- "div",
4483
- { className: P + "-head" },
4484
- h(
4485
- "div",
4486
- { className: P + "-headmain" },
4487
- h("h2", null, icon("database"), tableLabel(current), h("span", { className: P + "-code" }, active)),
4488
- h(
4489
- "div",
4490
- { className: P + "-sub" },
4491
- current && data && data.total !== void 0 ? fmt(t.rowCount, { n: data.total }) : "",
4492
- current && current.deletedCount ? " \xB7 " + fmt(t.deletedCount, { n: current.deletedCount }) : "",
4493
- " \xB7 " + t.subtitle
4494
- )
4495
- ),
4496
- h("button", {
4497
- type: "button",
4498
- className: P + "-btn",
4499
- "aria-label": t.refresh,
4500
- title: t.refresh,
4501
- "aria-busy": loadingRows ? "true" : "false",
4502
- onClick: refresh
4503
- }, icon("refresh"), h("span", { className: P + "-btnlabel" }, t.refresh))
4504
- ),
4505
- h(
4506
- "div",
4507
- { className: P + "-toolbar" },
4508
- h(
4509
- "div",
4510
- { className: P + "-search" },
4511
- icon("search"),
4512
- h("input", {
4513
- type: "search",
4514
- value: searchDraft,
4515
- placeholder: t.search,
4516
- "aria-label": t.search,
4517
- onChange: function(e) {
4518
- setSearchDraft(e.target.value);
4519
- }
4520
- })
4521
- ),
4522
- h(SW.Switch, {
4523
- h,
4524
- checked: includeDeleted,
4525
- label: t.includeDeleted,
4526
- onChange: function(next) {
4527
- setIncludeDeleted(next);
4528
- setPage(1);
4529
- }
4530
- }),
4531
- h(SW.Switch, {
4532
- h,
4533
- checked: showSystem,
4534
- label: t.showSystem,
4535
- onChange: function(next) {
4536
- setShowSystem(next);
4537
- }
4538
- }),
4539
- h("span", { className: P + "-grow" }),
4540
- h(
4541
- "label",
4542
- { style: { display: "inline-flex", alignItems: "center", gap: "6px", fontSize: "11.5px", color: "var(--cfg-muted)" } },
4543
- h("span", null, t.pageSize),
4544
- h("select", {
4545
- className: P + "-select",
4546
- value: size,
4547
- onChange: function(e) {
4548
- setPageSize(Number(e.target.value));
4549
- setPage(1);
4550
- }
4551
- }, PAGE_SIZES.map(function(n) {
4552
- return h("option", { key: n, value: n }, String(n));
4553
- }))
4554
- )
4555
- ),
4556
- renderRows(),
4557
- renderFoot()
4558
- ]
4559
- ),
4560
- drawer ? h(
4561
- "div",
4562
- null,
4563
- h("div", { className: P + "-mask", onClick: function() {
4564
- setDrawer(null);
4565
- } }),
4566
- h(
4567
- "aside",
4568
- { className: P + "-drawer", role: "dialog", "aria-modal": "true", "aria-label": drawer.column },
4569
- h("h3", null, fmt(t.drawerTitle, { column: drawer.column, row: drawer.row }), h("span", { className: P + "-code" }, drawer.name)),
4570
- columnHooks[drawer.name] && columnHooks[drawer.name].detail ? columnHooks[drawer.name].detail({ value: drawer.value, lang, prefix: P }) : h("pre", null, drawerText(drawer.value)),
4571
- h(
4572
- "div",
4573
- { className: P + "-drawerfoot" },
4574
- h("button", { type: "button", className: P + "-btn", onClick: function() {
4575
- copyCell(drawer.value);
4576
- } }, t.copy),
4577
- h("button", { type: "button", className: P + "-btn", onClick: function() {
4578
- setDrawer(null);
4579
- } }, t.close)
4580
- )
4581
- )
4582
- ) : null,
4583
- toast ? h("div", { className: P + "-toast", role: "status" }, toast) : null
4584
- );
4585
- }
4586
- function drawerText(value) {
4587
- if (value === null || value === void 0) return "NULL";
4588
- if (typeof value === "string" && looksJson(value)) {
4589
- try {
4590
- return JSON.stringify(JSON.parse(value), null, 2);
4591
- } catch (e) {
4592
- return value;
4593
- }
4594
- }
4595
- if (typeof value === "object") {
4596
- try {
4597
- return JSON.stringify(value, null, 2);
4598
- } catch (e) {
4599
- return String(value);
4600
- }
4601
- }
4602
- return String(value);
4603
- }
4604
- return { DataView, DOMAIN };
4605
- };
4606
- }
4607
- });
4608
-
4609
- // packages/addons/danmaku/client/views/data.cjs
4610
- var require_data = __commonJS({
4611
- "packages/addons/danmaku/client/views/data.cjs"(exports2, module2) {
4612
- "use strict";
4613
- module2.exports = require_data_view()({
4614
- domain: "danmaku",
4615
- prefix: "wbdm",
4616
- tables: ["danmaku"],
4617
- useConfig: require_config().useConfig
4618
- });
4619
- }
4620
- });
4621
-
4622
- // packages/addons/lib/highlight.cjs
4623
- var require_highlight = __commonJS({
4624
- "packages/addons/lib/highlight.cjs"(exports2, module2) {
4625
- "use strict";
4626
- module2.exports = function(React) {
4627
- var h = React.createElement;
4628
- function sourceOf(keyword) {
4629
- var pattern = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4630
- return pattern.replace(/[a-zA-Z]/g, function(letter) {
4631
- return "[" + letter.toLowerCase() + letter.toUpperCase() + "]";
4632
- });
4633
- }
4634
- return function createHighlight(prefix) {
4635
- var className = String(prefix || "wb") + "-hit";
4636
- function hit(rawText, rawKeyword) {
4637
- var text = rawText == null ? "" : String(rawText);
4638
- var keyword = rawKeyword == null ? "" : String(rawKeyword);
4639
- if (!keyword) return text;
4640
- var matcher, match, end = 0, parts = [];
4641
- try {
4642
- matcher = new RegExp(sourceOf(keyword), "g");
4643
- } catch (error) {
4644
- return text;
4645
- }
4646
- while (match = matcher.exec(text)) {
4647
- if (match.index > end) parts.push(text.slice(end, match.index));
4648
- parts.push(h("mark", { className, key: match.index }, match[0]));
4649
- end = match.index + match[0].length;
4650
- if (!match[0]) matcher.lastIndex += 1;
4651
- }
4652
- if (!parts.length) return text;
4653
- if (end < text.length) parts.push(text.slice(end));
4654
- return parts;
4655
- }
4656
- function Highlight(props) {
4657
- return hit(props.text, props.keyword);
4658
- }
4659
- Highlight.hit = hit;
4660
- return Highlight;
4661
- };
4662
- };
4663
- }
4664
- });
4665
-
4666
- // packages/addons/lib/action-schema-style.cjs
4667
- var require_action_schema_style = __commonJS({
4668
- "packages/addons/lib/action-schema-style.cjs"(exports2, module2) {
4669
- "use strict";
4670
- module2.exports = function(PREFIX, DOMAIN) {
4671
- var P = PREFIX + "-as";
4672
- var hairline = "1px solid color-mix(in oklab,currentColor 8%,transparent)";
4673
- var CSS = [
4674
- "." + P + "{display:flex;flex-direction:column;gap:12px;width:100%;min-width:0;font-size:13px;color:inherit}",
4675
- "." + P + "-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
4676
- "." + P + "-title{font-size:15px;font-weight:660;margin:0}",
4677
- "." + 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}",
4678
- "." + P + "-mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px}",
4679
- "." + P + "-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
4680
- "." + P + "-search{position:relative;flex:1 1 220px;min-width:0;display:flex;align-items:center}",
4681
- "." + 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}",
4682
- "." + P + "-search input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}",
4683
- "." + P + "-search .wbi-svg{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--dsw-alias-label-tertiary,inherit)}",
4684
- "." + 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%}",
4685
- "." + P + " select:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}",
4686
- "." + P + "-list{display:flex;flex-direction:column;gap:8px}",
4687
- "." + 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}",
4688
- "." + P + "-cardhead{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:8px}",
4689
- "." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
4690
- "." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
4691
- "." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
4692
- "." + P + "-origins{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end;min-width:0}",
4693
- "." + P + "-origins-label{font-size:11px;color:var(--wb-muted);white-space:nowrap}",
4694
- "." + P + "-origin{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--wb-muted);cursor:pointer;user-select:none}",
4695
- // 该 action 本身不支持的来源:整项置灰、不可点,示意「不是没开,是开不了」。
4696
- "." + P + "-origin-off{opacity:.55;cursor:not-allowed}",
4697
- "." + P + "-origin input[type=checkbox]{width:13px;height:13px;margin:0;accent-color:var(--wb-accent);cursor:inherit}",
4698
- "." + P + "-origin input[type=checkbox]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
4699
- "." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
4700
- "." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px;overflow-wrap:anywhere}",
4701
- // 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
4702
- "." + 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}",
4703
- "." + P + "-table{width:100%;border-collapse:collapse;font-size:12px;table-layout:auto}",
4704
- "." + 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}",
4705
- "." + P + "-table td{padding:4px 8px 4px 0;vertical-align:top;border-top:" + hairline + ";line-height:1.5;overflow-wrap:anywhere}",
4706
- "." + P + "-req{color:var(--dsw-alias-state-error-primary,#d9534f);font-weight:620}",
4707
- "." + P + "-opt{color:var(--dsw-alias-label-tertiary,inherit)}",
4708
- "." + P + "-none{color:var(--dsw-alias-label-tertiary,inherit);font-size:12px}",
4709
- "." + P + "-example{position:relative;display:flex;flex-direction:column;gap:4px;min-width:0}",
4710
- "." + P + "-examplehead{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}",
4711
- "." + 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}",
4712
- "." + 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}",
4713
- "." + P + "-copy:hover{background:var(--dsw-alias-interactive-bg-hover,color-mix(in oklab,currentColor 5%,transparent))}",
4714
- "." + P + "-copy:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:2px}",
4715
- "." + P + " details>summary{cursor:pointer;font-size:11.5px;color:var(--dsw-alias-label-secondary,inherit);width:max-content}",
4716
- "." + P + " details>summary:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:2px}",
4717
- // 参数折叠面板:折叠时只留一行「参数 · 必填 n」,展开后与表格之间留一点气口。
4718
- "." + P + "-params{min-width:0}",
4719
- "." + P + "-params>summary{user-select:none;max-width:100%}",
4720
- "." + P + "-params[open]>summary{margin-bottom:6px}",
4721
- "." + P + "-empty{padding:24px;text-align:center;border:1px dashed var(--wb-border,#e3e5e9);border-radius:10px;color:var(--dsw-alias-label-tertiary,inherit)}",
4722
- "." + 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}",
4723
- "." + 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%}",
4724
- // 窄屏:五列参数表压成一列会丢失列名、且 table 布局按最小内容宽度撑破容器,
4725
- // 这里整体改成块级网格:每行 = 名称 / 类型 / 必填 + 约束行 + 说明行,行间用细线分隔。
4726
- "@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}}",
4727
- // 中等宽度(521–760px)三个筛选项正好排成一行,避免第三项独占一行显得参差。
4728
- "@media(min-width:521px) and (max-width:760px){." + P + "-toolbar{grid-template-columns:repeat(3,minmax(0,1fr))}}",
4729
- "@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}}"
4730
- ].join("\n");
4731
- return function injectCss() {
4732
- if (typeof document === "undefined") return;
4733
- var id = "wb-addon-" + DOMAIN + "-actions-css";
4734
- var old = document.getElementById(id);
4735
- if (old) {
4736
- old.textContent = CSS;
4737
- return;
4738
- }
4739
- var style = document.createElement("style");
4740
- style.id = id;
4741
- style.setAttribute("data-wb-addon", "wb-addon-" + DOMAIN);
4742
- style.textContent = CSS;
4743
- document.head.appendChild(style);
4744
- };
4745
- };
4746
- }
4747
- });
4748
-
4749
- // packages/addons/lib/action-schema-view.cjs
4750
- var require_action_schema_view = __commonJS({
4751
- "packages/addons/lib/action-schema-view.cjs"(exports2, module2) {
4752
- "use strict";
4753
- var React = require("react");
4754
- var createHighlight = require_highlight()(React);
4755
- var h = React.createElement;
4756
- var COPY = {
4757
- zh: {
4758
- title: "Action",
4759
- hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
4760
- 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",
4761
- hostHint: "\u5BBF\u4E3B action \u7684\u5141\u8BB8\u6765\u6E90\uFF1B\u6807\u300C\u6765\u6E90\u56FA\u5B9A\u300D\u7684\u4E0D\u53EF\u4FEE\u6539\u3002",
4762
- originsLabel: "\u5141\u8BB8\u6765\u6E90",
4763
- originUi: "\u754C\u9762",
4764
- originPlugin: "\u63D2\u4EF6",
4765
- originAgent: "agent",
4766
- originSync: "\u540C\u6B65",
4767
- originsSaving: "\u4FDD\u5B58\u4E2D\u2026",
4768
- originsToast: "\u5DF2\u66F4\u65B0\u5141\u8BB8\u6765\u6E90",
4769
- originsFail: "\u66F4\u65B0\u5141\u8BB8\u6765\u6E90\u5931\u8D25",
4770
- originsEmpty: "\u81F3\u5C11\u8981\u4FDD\u7559\u4E00\u4E2A\u6765\u6E90",
4771
- originsUnsupported: "\u8BE5 action \u672C\u8EAB\u4E0D\u652F\u6301\u8FD9\u4E2A\u6765\u6E90",
4772
- originsPinned: "\u6765\u6E90\u56FA\u5B9A",
4773
- originsPinnedHint: "\u8BE5 action \u7684\u5141\u8BB8\u6765\u6E90\u88AB\u56FA\u5B9A\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539",
4774
- domain: "\u57DF",
4775
- versionLabel: "\u7248\u672C",
4776
- shell: "\u5BBF\u4E3B",
4777
- count: function(shown, total) {
4778
- return shown + " / " + total + " \u4E2A action";
4779
- },
4780
- search: "\u641C\u7D22\u540D\u79F0\u3001\u63CF\u8FF0\u3001\u53C2\u6570\uFF08\u547D\u4E2D\u5904\u9AD8\u4EAE\uFF09",
4781
- filterReq: "\u5FC5\u586B\u7B5B\u9009",
4782
- all: "\u5168\u90E8",
4783
- onlyRequired: "\u542B\u5FC5\u586B\u9879",
4784
- onlyOptional: "\u65E0\u5FC5\u586B\u9879",
4785
- filterType: "\u53C2\u6570\u7C7B\u578B",
4786
- allTypes: "\u5168\u90E8\u7C7B\u578B",
4787
- filterOrigin: "\u5141\u8BB8\u6765\u6E90",
4788
- allOrigins: "\u5168\u90E8\u6765\u6E90",
4789
- colName: "\u53C2\u6570",
4790
- colType: "\u7C7B\u578B",
4791
- colReq: "\u5FC5\u586B",
4792
- colExtra: "\u9ED8\u8BA4 / \u679A\u4E3E / \u7EA6\u675F",
4793
- colDesc: "\u8BF4\u660E",
4794
- required: "\u5FC5\u586B",
4795
- optional: "\u53EF\u9009",
4796
- noParams: "\u65E0\u53C2\u6570",
4797
- paramCount: function(n) {
4798
- return n + " \u4E2A\u53C2\u6570";
4799
- },
4800
- params: "\u53C2\u6570",
4801
- requiredCount: function(n) {
4802
- return "\u5FC5\u586B " + n;
4803
- },
4804
- examples: "\u793A\u4F8B",
4805
- noExamples: "\u65E0\u793A\u4F8B",
4806
- copy: "\u590D\u5236",
4807
- copied: "\u5DF2\u590D\u5236",
4808
- raw: "\u539F\u59CB JSON Schema",
4809
- loading: "\u8F7D\u5165\u4E2D\u2026",
4810
- loadFail: "\u8BFB\u53D6 action schema \u5931\u8D25",
4811
- retry: "\u91CD\u8BD5",
4812
- empty: "\u6CA1\u6709\u5339\u914D\u7684 action",
4813
- emptyRegistry: "\u8BE5\u57DF\u6CA1\u6709\u6CE8\u518C action",
4814
- envelope: "\u9ED8\u8BA4",
4815
- enumLabel: "\u679A\u4E3E",
4816
- range: "\u8303\u56F4",
4817
- length: "\u957F\u5EA6",
4818
- pattern: "\u6B63\u5219",
4819
- format: "\u683C\u5F0F",
4820
- items: "\u5143\u7D20\u6570"
4821
- },
4822
- en: {
4823
- title: "Actions",
4824
- hint: "runtime registry \xB7 read-only",
4825
- switchHint: "Allowed origins are stored locally and apply immediately: only checked origins may call the action; others get ACTION_ORIGIN_DENIED.",
4826
- hostHint: "Allowed origins for host actions; items marked pinned cannot be changed.",
4827
- originsLabel: "Origins",
4828
- originUi: "UI",
4829
- originPlugin: "Plugin",
4830
- originAgent: "Agent",
4831
- originSync: "Sync",
4832
- originsSaving: "Saving\u2026",
4833
- originsToast: "Allowed origins updated",
4834
- originsFail: "Failed to update allowed origins",
4835
- originsEmpty: "Keep at least one origin",
4836
- originsUnsupported: "This action does not support this origin",
4837
- originsPinned: "Pinned",
4838
- originsPinnedHint: "Allowed origins are pinned for this action (security constraint) and cannot be changed",
4839
- originsDefaultOn: "Allowed by default",
4840
- originsDefaultOff: "Off by default, can be enabled",
4841
- domain: "Domain",
4842
- versionLabel: "Version",
4843
- shell: "Host",
4844
- count: function(shown, total) {
4845
- return shown + " / " + total + " actions";
4846
- },
4847
- search: "Search name, description, params (matches highlighted)",
4848
- filterReq: "Required",
4849
- all: "All",
4850
- onlyRequired: "Has required",
4851
- onlyOptional: "No required",
4852
- filterType: "Param type",
4853
- allTypes: "All types",
4854
- filterOrigin: "Origins",
4855
- allOrigins: "All origins",
4856
- colName: "Param",
4857
- colType: "Type",
4858
- colReq: "Required",
4859
- colExtra: "Default / enum / constraints",
4860
- colDesc: "Description",
4861
- required: "required",
4862
- optional: "optional",
4863
- noParams: "No parameters",
4864
- paramCount: function(n) {
4865
- return n + " params";
4866
- },
4867
- params: "Parameters",
4868
- requiredCount: function(n) {
4869
- return n + " required";
4870
- },
4871
- examples: "Examples",
4872
- noExamples: "No examples",
4873
- copy: "Copy",
4874
- copied: "Copied",
4875
- raw: "Raw JSON Schema",
4876
- loading: "Loading\u2026",
4877
- loadFail: "Failed to read action schema",
4878
- retry: "Retry",
4879
- empty: "No matching action",
4880
- emptyRegistry: "This domain has no registered action",
4881
- envelope: "Default",
4882
- enumLabel: "Enum",
4883
- range: "Range",
4884
- length: "Length",
4885
- pattern: "Pattern",
4886
- format: "Format",
4887
- items: "Items"
4888
- }
4889
- };
4890
- function typeLabel(schema) {
4891
- if (!schema || typeof schema !== "object") return "";
4892
- if (Array.isArray(schema.type)) return schema.type.join(" | ");
4893
- if (typeof schema.type === "string") {
4894
- if (schema.type === "array" && schema.items) {
4895
- var inner = typeLabel(schema.items);
4896
- return inner ? inner + "[]" : "array";
4897
- }
4898
- return schema.type;
4899
- }
4900
- if (Array.isArray(schema.oneOf)) return schema.oneOf.map(typeLabel).filter(Boolean).join(" | ");
4901
- if (Array.isArray(schema.anyOf)) return schema.anyOf.map(typeLabel).filter(Boolean).join(" | ");
4902
- return "";
4903
- }
4904
- function typeNames(schema) {
4905
- var label = typeLabel(schema);
4906
- if (!label) return [];
4907
- return label.split("|").map(function(x) {
4908
- return x.trim().replace(/\[\]$/, "");
4909
- }).filter(Boolean);
4910
- }
4911
- function scalar(value) {
4912
- if (typeof value === "string") return JSON.stringify(value);
4913
- return String(value);
4914
- }
4915
- function extraText(schema, t) {
4916
- if (!schema || typeof schema !== "object") return "";
4917
- var parts = [];
4918
- if (Object.prototype.hasOwnProperty.call(schema, "default")) {
4919
- parts.push(t.envelope + " " + scalar(schema.default));
4920
- }
4921
- if (Array.isArray(schema.enum)) {
4922
- parts.push(t.enumLabel + " " + schema.enum.map(scalar).join(" / "));
4923
- }
4924
- if (typeof schema.minimum === "number" || typeof schema.maximum === "number") {
4925
- var lo = typeof schema.minimum === "number" ? schema.minimum : null;
4926
- var hi = typeof schema.maximum === "number" ? schema.maximum : null;
4927
- if (lo !== null && hi !== null) parts.push(t.range + " \u2265" + lo + " \u4E14 \u2264" + hi);
4928
- else if (lo !== null) parts.push(t.range + " \u2265" + lo);
4929
- else parts.push(t.range + " \u2264" + hi);
4930
- }
4931
- if (typeof schema.minLength === "number" || typeof schema.maxLength === "number") {
4932
- parts.push(t.length + " " + (schema.minLength ?? 0) + "\u2013" + (schema.maxLength ?? "\u221E"));
4933
- }
4934
- if (typeof schema.minItems === "number" || typeof schema.maxItems === "number") {
4935
- parts.push(t.items + " " + (schema.minItems ?? 0) + "\u2013" + (schema.maxItems ?? "\u221E"));
4936
- }
4937
- if (typeof schema.pattern === "string") parts.push(t.pattern + " " + schema.pattern);
4938
- if (typeof schema.format === "string") parts.push(t.format + " " + schema.format);
4939
- return parts.join(" \xB7 ");
4940
- }
4941
- function paramRows(action) {
4942
- var input = action && action.input && typeof action.input === "object" ? action.input : {};
4943
- var props = input.properties && typeof input.properties === "object" ? input.properties : {};
4944
- var required = Array.isArray(input.required) ? input.required : [];
4945
- return Object.keys(props).map(function(key) {
4946
- var schema = props[key] && typeof props[key] === "object" ? props[key] : {};
4947
- return {
4948
- name: key,
4949
- schema,
4950
- type: typeLabel(schema),
4951
- types: typeNames(schema),
4952
- required: required.indexOf(key) >= 0,
4953
- description: typeof schema.description === "string" ? schema.description : ""
4954
- };
4955
- });
4956
- }
4957
- module2.exports = function createActionSchemaView(options) {
4958
- var raw = String(options.domain || "");
4959
- var SOURCE = options.source === "actions.list" ? "actions.list" : "actionSchema";
4960
- var DOMAIN = SOURCE === "actions.list" ? raw : raw.indexOf("wb-addon-") === 0 ? raw : "wb-addon-" + raw;
4961
- var LIST_DOMAIN = options.listDomain ? String(options.listDomain) : DOMAIN;
4962
- var prefix = options.prefix;
4963
- var P = prefix + "-as";
4964
- var Icon2 = options.Icon || null;
4965
- var injectCss = require_action_schema_style()(prefix, DOMAIN);
4966
- var Highlight = createHighlight(P);
4967
- function icon(name, size) {
4968
- return Icon2 ? h(Icon2, { name, size: size || 14 }) : null;
4969
- }
4970
- function plainCopy(text) {
4971
- if (typeof document === "undefined") return;
4972
- var area = document.createElement("textarea");
4973
- area.value = text;
4974
- area.setAttribute("readonly", "readonly");
4975
- area.style.position = "fixed";
4976
- area.style.opacity = "0";
4977
- document.body.appendChild(area);
4978
- area.select();
4979
- try {
4980
- document.execCommand("copy");
4981
- } catch (e) {
4982
- }
4983
- document.body.removeChild(area);
4984
- }
4985
- function ActionSchemaView(props) {
4986
- var lang = props.lang === "en" ? "en" : "zh";
4987
- var t = COPY[lang];
4988
- var api = props.api;
4989
- var snapState = React.useState(null);
4990
- var snap = snapState[0], setSnap = snapState[1];
4991
- var errState = React.useState("");
4992
- var err = errState[0], setErr = errState[1];
4993
- var loadingState = React.useState(true);
4994
- var loading = loadingState[0], setLoading = loadingState[1];
4995
- var reloadState = React.useState(0);
4996
- var reload = reloadState[0], setReload = reloadState[1];
4997
- var queryState = React.useState("");
4998
- var query = queryState[0], setQuery = queryState[1];
4999
- var reqState = React.useState("all");
5000
- var reqMode = reqState[0], setReqMode = reqState[1];
5001
- var typeState = React.useState("");
5002
- var typePick = typeState[0], setTypePick = typeState[1];
5003
- var originFilterState = React.useState("");
5004
- var originPick = originFilterState[0], setOriginPick = originFilterState[1];
5005
- var toastState = React.useState("");
5006
- var toast = toastState[0], setToast = toastState[1];
5007
- var savingState = React.useState("");
5008
- var saving = savingState[0], setSaving = savingState[1];
5009
- var foldsState = React.useState({});
5010
- var folds = foldsState[0], setFolds = foldsState[1];
5011
- React.useEffect(function() {
5012
- injectCss();
5013
- }, []);
5014
- React.useEffect(function() {
5015
- var alive = true;
5016
- setLoading(true);
5017
- setErr("");
5018
- var pending;
5019
- var actionName = SOURCE === "actions.list" ? "actions.list" : DOMAIN.replace(/^wb-addon-/, "") + ".actionSchema";
5020
- var callArgs = SOURCE === "actions.list" ? { detail: true, domain: LIST_DOMAIN } : void 0;
5021
- if (api && typeof api.call === "function") {
5022
- pending = Promise.resolve(api.call(actionName, callArgs)).then(function(r) {
5023
- if (r && r.ok === false) return r;
5024
- return r && r.result || r;
5025
- });
5026
- } else {
5027
- pending = Promise.reject(new Error("no call api"));
5028
- }
5029
- Promise.resolve(pending).then(function(r) {
5030
- if (!alive) return;
5031
- if (!r || r.ok === false) {
5032
- setSnap(null);
5033
- setErr(String(r && (r.error || r.text) || t.loadFail));
5034
- } else {
5035
- setSnap(r);
5036
- }
5037
- setLoading(false);
5038
- }, function(e) {
5039
- if (!alive) return;
5040
- setSnap(null);
5041
- setErr(String(e && e.message || e || t.loadFail));
5042
- setLoading(false);
5043
- });
5044
- return function() {
5045
- alive = false;
5046
- };
5047
- }, [reload]);
5048
- function copy(text) {
5049
- var done = function() {
5050
- setToast(t.copied);
5051
- };
5052
- if (typeof navigator !== "undefined" && navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
5053
- navigator.clipboard.writeText(text).then(done, function() {
5054
- plainCopy(text);
5055
- done();
5056
- });
5057
- return;
5058
- }
5059
- plainCopy(text);
5060
- done();
5061
- }
5062
- var ORIGINS = ["ui", "plugin", "agent", "sync"];
5063
- var originText = { ui: t.originUi, plugin: t.originPlugin, agent: t.originAgent, sync: t.originSync };
5064
- function setOrigins(action, origin) {
5065
- var name = action.name;
5066
- var current = Array.isArray(action.origins) ? action.origins.slice() : [];
5067
- var index = current.indexOf(origin);
5068
- var next = index >= 0 ? current.filter(function(o) {
5069
- return o !== origin;
5070
- }) : current.concat([origin]);
5071
- if (next.length === 0) {
5072
- setToast(t.originsEmpty);
5073
- return;
5074
- }
5075
- next = ORIGINS.filter(function(o) {
5076
- return next.indexOf(o) >= 0;
5077
- });
5078
- setSaving(name);
5079
- setToast("");
5080
- var fail = function(e) {
5081
- setSaving("");
5082
- setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
5083
- };
5084
- var done = function(r) {
5085
- setSaving("");
5086
- var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
5087
- if (r && r.ok === false) {
5088
- setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
5089
- return;
5090
- }
5091
- var value = payload && Array.isArray(payload.origins) ? payload.origins : next;
5092
- var source = payload && typeof payload.source === "string" ? payload.source : action.originsSource;
5093
- setSnap(function(prev) {
5094
- if (!prev || !Array.isArray(prev.actions)) return prev;
5095
- return Object.assign({}, prev, {
5096
- actions: prev.actions.map(function(a) {
5097
- if (!a || a.name !== name) return a;
5098
- return Object.assign({}, a, { origins: value, originsSource: source });
5099
- })
5100
- });
5101
- });
5102
- setToast(t.originsToast);
5103
- };
5104
- if (!api || typeof api.call !== "function") {
5105
- fail(new Error("no call api"));
5106
- return;
5107
- }
5108
- Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
5109
- }
5110
- function paramsOpen(action) {
5111
- if (Object.prototype.hasOwnProperty.call(folds, action.name)) return folds[action.name] === true;
5112
- return Boolean(String(query || "").trim()) || reqMode !== "all" || Boolean(typePick);
5113
- }
5114
- function resetFolds() {
5115
- setFolds(function(prev) {
5116
- return Object.keys(prev).length ? {} : prev;
5117
- });
5118
- }
5119
- var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
5120
- return a && a.domain === DOMAIN;
5121
- }) : [];
5122
- var info = snap && Array.isArray(snap.domains) ? snap.domains.filter(function(d) {
5123
- return d && d.id === DOMAIN;
5124
- })[0] || null : null;
5125
- var typeOptions = [];
5126
- all.forEach(function(a) {
5127
- paramRows(a).forEach(function(row) {
5128
- row.types.forEach(function(name) {
5129
- if (typeOptions.indexOf(name) < 0) typeOptions.push(name);
5130
- });
5131
- });
5132
- });
5133
- typeOptions.sort();
5134
- var kw = String(query || "").trim();
5135
- var q = kw.toLowerCase();
5136
- var visible = all.filter(function(a) {
5137
- var rows = paramRows(a);
5138
- if (q) {
5139
- var hay = [a.name || "", a.description || ""].concat(rows.map(function(row) {
5140
- return row.name + " " + row.type + " " + row.description;
5141
- })).join(" ").toLowerCase();
5142
- if (hay.indexOf(q) < 0) return false;
5143
- }
5144
- var hasRequired = rows.some(function(row) {
5145
- return row.required;
5146
- });
5147
- if (reqMode === "required" && !hasRequired) return false;
5148
- if (reqMode === "optional" && hasRequired) return false;
5149
- if (typePick && !rows.some(function(row) {
5150
- return row.types.indexOf(typePick) >= 0;
5151
- })) return false;
5152
- if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
5153
- return true;
5154
- });
5155
- function paramRow(row) {
5156
- var extra = extraText(row.schema, t);
5157
- return h(
5158
- "tr",
5159
- { key: row.name },
5160
- h("td", { className: P + "-mono " + P + "-pname" }, Highlight.hit(row.name, kw)),
5161
- h("td", { className: P + "-mono " + P + "-ptype" }, Highlight.hit(row.type, kw)),
5162
- h(
5163
- "td",
5164
- { className: row.required ? P + "-req " + P + "-pneed" : P + "-opt " + P + "-pneed" },
5165
- row.required ? t.required : t.optional
5166
- ),
5167
- // extra(默认 / 枚举 / 约束)不在过滤 haystack 里,因此也不高亮,保持「显示即命中」口径。
5168
- h("td", { className: P + "-mono " + P + "-pextra" }, extra),
5169
- h("td", { className: P + "-pdesc" }, Highlight.hit(row.description, kw))
5170
- );
5171
- }
5172
- function originsChips(action) {
5173
- if (!Array.isArray(action.origins)) return null;
5174
- if (action.originsSource === "invalid") {
5175
- return h("span", { className: P + "-badge " + P + "-locked", title: t.originsPinnedHint, "data-origins-invalid": action.name }, t.originsPinned);
5176
- }
5177
- var busy = saving === action.name;
5178
- var pinned = action.name === "actions.setActionOrigins";
5179
- var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
5180
- return h(
5181
- "div",
5182
- { className: P + "-origins", "data-origins-row": action.name },
5183
- h("span", { className: P + "-origins-label" }, t.originsLabel),
5184
- ORIGINS.map(function(origin) {
5185
- var on = action.origins.indexOf(origin) >= 0;
5186
- var allowed = supported.indexOf(origin) >= 0;
5187
- var preset = Array.isArray(action.originsDefault) ? action.originsDefault : supported;
5188
- var byDefault = preset.indexOf(origin) >= 0;
5189
- return h(
5190
- "label",
5191
- {
5192
- key: origin,
5193
- className: P + "-origin" + (allowed ? "" : " " + P + "-origin-off"),
5194
- title: pinned ? t.originsPinnedHint : !allowed ? t.originsUnsupported : originText[origin] + " \xB7 " + action.name + " \xB7 " + (byDefault ? t.originsDefaultOn : t.originsDefaultOff)
5195
- },
5196
- h("input", {
5197
- type: "checkbox",
5198
- checked: on,
5199
- disabled: busy || pinned || !allowed,
5200
- "data-origin": origin,
5201
- "data-origin-row": action.name,
5202
- "data-origin-supported": allowed ? "1" : "0",
5203
- onChange: function() {
5204
- setOrigins(action, origin);
5205
- }
5206
- }),
5207
- h("span", null, originText[origin])
5208
- );
5209
- }),
5210
- busy ? h("span", { className: P + "-origins-label" }, t.originsSaving) : null
5211
- );
5212
- }
5213
- function card(action) {
5214
- var rows = paramRows(action);
5215
- var required = rows.filter(function(row) {
5216
- return row.required;
5217
- }).length;
5218
- var open = paramsOpen(action);
5219
- var examples = Array.isArray(action.examples) ? action.examples : [];
5220
- return h(
5221
- "div",
5222
- { className: P + "-card", key: action.name },
5223
- h(
5224
- "div",
5225
- { className: P + "-cardhead" },
5226
- h(
5227
- "div",
5228
- { className: P + "-cardmeta" },
5229
- h("code", { className: P + "-mono" }, Highlight.hit(action.name, kw)),
5230
- h("span", { className: P + "-badge" }, rows.length ? t.paramCount(rows.length) : t.noParams),
5231
- rows.some(function(row) {
5232
- return row.required;
5233
- }) ? h("span", { className: P + "-badge " + P + "-req" }, t.required) : null
5234
- ),
5235
- originsChips(action)
5236
- ),
5237
- action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
5238
- rows.length ? h(
5239
- "details",
5240
- {
5241
- className: P + "-params",
5242
- "data-params-fold": action.name,
5243
- open,
5244
- // 原生 details 自带键盘与无障碍语义,这里只记下用户的开合;
5245
- // 筛选变化引起的程序性开合也会触发 toggle,记下的值与当次默认一致,随后由 resetFolds 清掉。
5246
- onToggle: function(e) {
5247
- var next = !!(e && e.currentTarget && e.currentTarget.open);
5248
- setFolds(function(prev) {
5249
- if (prev[action.name] === next) return prev;
5250
- var out = Object.assign({}, prev);
5251
- out[action.name] = next;
5252
- return out;
5253
- });
5254
- }
5255
- },
5256
- h("summary", null, t.params + (required ? " \xB7 " + t.requiredCount(required) : "")),
5257
- h(
5258
- "table",
5259
- { className: P + "-table" },
5260
- h("thead", null, h(
5261
- "tr",
5262
- null,
5263
- h("th", null, t.colName),
5264
- h("th", null, t.colType),
5265
- h("th", null, t.colReq),
5266
- h("th", null, t.colExtra),
5267
- h("th", null, t.colDesc)
5268
- )),
5269
- h("tbody", null, rows.map(paramRow))
5270
- )
5271
- ) : h("div", { className: P + "-none" }, t.noParams),
5272
- h(
5273
- "div",
5274
- { className: P + "-example" },
5275
- h(
5276
- "div",
5277
- { className: P + "-examplehead" },
5278
- h("span", { className: P + "-none" }, t.examples),
5279
- examples.length ? h("button", {
5280
- type: "button",
5281
- className: P + "-copy",
5282
- "data-copy-example": action.name,
5283
- onClick: function() {
5284
- copy(JSON.stringify(examples.length === 1 ? examples[0] : examples, null, 2));
5285
- }
5286
- }, t.copy) : null
5287
- ),
5288
- examples.length ? examples.map(function(example, index) {
5289
- return h("pre", { className: P + "-pre", key: index }, JSON.stringify(example, null, 2));
5290
- }) : h("div", { className: P + "-none" }, t.noExamples)
5291
- ),
5292
- h(
5293
- "details",
5294
- null,
5295
- h("summary", null, t.raw),
5296
- h("pre", { className: P + "-pre" }, JSON.stringify(action.input || {}, null, 2))
5297
- )
5298
- );
5299
- }
5300
- var body;
5301
- if (loading) {
5302
- body = h("div", { className: P + "-empty", role: "status" }, t.loading);
5303
- } else if (err) {
5304
- body = h(
5305
- "div",
5306
- { className: P + "-error", role: "alert" },
5307
- h("span", null, t.loadFail + "\uFF1A" + err),
5308
- h("button", { type: "button", className: P + "-copy", onClick: function() {
5309
- setReload(reload + 1);
5310
- } }, t.retry)
5311
- );
5312
- } else if (!all.length) {
5313
- body = h("div", { className: P + "-empty" }, t.emptyRegistry);
5314
- } else if (!visible.length) {
5315
- body = h("div", { className: P + "-empty" }, t.empty);
5316
- } else {
5317
- body = h("div", { className: P + "-list" }, visible.map(card));
5318
- }
5319
- return h(
5320
- "div",
5321
- { className: P },
5322
- h(
5323
- "div",
5324
- { className: P + "-head" },
5325
- h("h3", { className: P + "-title" }, t.title),
5326
- h("span", { className: P + "-badge" }, t.domain + " " + DOMAIN),
5327
- info && info.version ? h("span", { className: P + "-badge" }, t.versionLabel + " v" + info.version) : null,
5328
- snap && snap.shellVersion ? h("span", { className: P + "-badge" }, t.shell + " v" + snap.shellVersion) : null,
5329
- h("span", { className: P + "-badge" }, t.count(visible.length, all.length)),
5330
- h("span", { className: P + "-none" }, t.hint)
5331
- ),
5332
- h("p", { className: P + "-hintline" }, SOURCE === "actions.list" ? t.hostHint : t.switchHint),
5333
- snap ? h(
5334
- "div",
5335
- { className: P + "-toolbar" },
5336
- h(
5337
- "label",
5338
- { className: P + "-search" },
5339
- icon("search", 14),
5340
- h("input", {
5341
- type: "search",
5342
- value: query,
5343
- placeholder: t.search,
5344
- "aria-label": t.search,
5345
- onChange: function(e) {
5346
- setQuery(e.target.value);
5347
- resetFolds();
5348
- }
5349
- })
5350
- ),
5351
- h(
5352
- "label",
5353
- { className: P + "-none" },
5354
- t.filterReq + " ",
5355
- h(
5356
- "select",
5357
- { value: reqMode, "aria-label": t.filterReq, onChange: function(e) {
5358
- setReqMode(e.target.value);
5359
- resetFolds();
5360
- } },
5361
- h("option", { value: "all" }, t.all),
5362
- h("option", { value: "required" }, t.onlyRequired),
5363
- h("option", { value: "optional" }, t.onlyOptional)
5364
- )
5365
- ),
5366
- h(
5367
- "label",
5368
- { className: P + "-none" },
5369
- t.filterType + " ",
5370
- h(
5371
- "select",
5372
- { value: typePick, "aria-label": t.filterType, onChange: function(e) {
5373
- setTypePick(e.target.value);
5374
- resetFolds();
5375
- } },
5376
- h("option", { value: "" }, t.allTypes),
5377
- typeOptions.map(function(name) {
5378
- return h("option", { value: name, key: name }, name);
5379
- })
5380
- )
5381
- ),
5382
- h(
5383
- "label",
5384
- { className: P + "-none" },
5385
- t.filterOrigin + " ",
5386
- h(
5387
- "select",
5388
- { value: originPick, "aria-label": t.filterOrigin, "data-origin-filter": "", onChange: function(e) {
5389
- setOriginPick(e.target.value);
5390
- } },
5391
- h("option", { value: "" }, t.allOrigins),
5392
- ORIGINS.map(function(origin) {
5393
- return h("option", { value: origin, key: origin }, originText[origin]);
5394
- })
5395
- )
5396
- )
5397
- ) : null,
5398
- body,
5399
- toast ? h("div", { className: P + "-toast", role: "status" }, toast) : null
5400
- );
5401
- }
5402
- return { ActionSchemaView, DOMAIN, typeLabel, paramRows };
5403
- };
5404
- }
5405
- });
5406
-
5407
- // packages/addons/danmaku/client/views/actions.cjs
5408
- var require_actions = __commonJS({
5409
- "packages/addons/danmaku/client/views/actions.cjs"(exports2, module2) {
5410
- "use strict";
5411
- module2.exports = require_action_schema_view()({
5412
- domain: "danmaku",
5413
- prefix: "wbdm"
5414
- });
5415
- }
5416
- });
5417
-
5418
3580
  // packages/addons/danmaku/client/client.src.cjs
5419
3581
  var GLYPHS = require_icons2().ICONS;
5420
3582
  var styles = require_styles();
@@ -5448,7 +3610,6 @@ var icons = {
5448
3610
  megaphone: GLYPHS["megaphone"],
5449
3611
  list: GLYPHS["list"],
5450
3612
  settings: GLYPHS["settings"],
5451
- database: GLYPHS["database"],
5452
3613
  play: GLYPHS["play"]
5453
3614
  };
5454
3615
  function makeTab(React) {
@@ -5463,7 +3624,7 @@ function definition(host) {
5463
3624
  var tab = makeTab(host.react);
5464
3625
  return {
5465
3626
  id: ADDON_ID,
5466
- version: "0.3.0",
3627
+ version: "0.3.3",
5467
3628
  icon: tab("megaphone"),
5468
3629
  views: [
5469
3630
  {
@@ -5477,18 +3638,6 @@ function definition(host) {
5477
3638
  icon: tab("settings"),
5478
3639
  title: { zh: "\u914D\u7F6E", en: "Settings" },
5479
3640
  component: require_config()
5480
- },
5481
- {
5482
- id: "data",
5483
- icon: tab("database"),
5484
- title: { zh: "\u6570\u636E", en: "Data" },
5485
- component: require_data()
5486
- },
5487
- {
5488
- id: "actions",
5489
- icon: tab("play"),
5490
- title: { zh: "Action", en: "Actions" },
5491
- component: require_actions()
5492
3641
  }
5493
3642
  ]
5494
3643
  };