@boteteam/utils 0.0.34 → 0.0.35

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.
Files changed (98) hide show
  1. package/README.md +175 -9
  2. package/dist/cjs/aiGenerateFill.d.ts +2 -0
  3. package/dist/cjs/aiGenerateFill.js +44 -0
  4. package/dist/cjs/aiGenerateFill.js.map +7 -0
  5. package/dist/cjs/copyToClipboard.d.ts +6 -0
  6. package/dist/cjs/copyToClipboard.js +55 -0
  7. package/dist/cjs/copyToClipboard.js.map +7 -0
  8. package/dist/cjs/dealStorageData.d.ts +35 -0
  9. package/dist/cjs/dealStorageData.js +331 -0
  10. package/dist/cjs/dealStorageData.js.map +7 -0
  11. package/dist/cjs/docchainContextFill.d.ts +2 -0
  12. package/dist/cjs/docchainContextFill.js +38 -0
  13. package/dist/cjs/docchainContextFill.js.map +7 -0
  14. package/dist/cjs/formatModule/formatModuleData.js +53 -10
  15. package/dist/cjs/formatModule/formatModuleData.js.map +2 -2
  16. package/dist/cjs/formatModule/helpers/formatDescriptionsProps.js +13 -2
  17. package/dist/cjs/formatModule/helpers/formatDescriptionsProps.js.map +3 -3
  18. package/dist/cjs/formatModule/helpers/formatEchartLineProps.js +12 -5
  19. package/dist/cjs/formatModule/helpers/formatEchartLineProps.js.map +3 -3
  20. package/dist/cjs/formatModule/helpers/formatEchartPieProps.d.ts +1 -0
  21. package/dist/cjs/formatModule/helpers/formatEchartPieProps.js +26 -2
  22. package/dist/cjs/formatModule/helpers/formatEchartPieProps.js.map +3 -3
  23. package/dist/cjs/formatModule/helpers/formatFormProps.js +11 -0
  24. package/dist/cjs/formatModule/helpers/formatFormProps.js.map +3 -3
  25. package/dist/cjs/formatModule/helpers/formatHighCodeProps.js +3 -0
  26. package/dist/cjs/formatModule/helpers/formatHighCodeProps.js.map +2 -2
  27. package/dist/cjs/formatModule/helpers/formatImageProps.js +9 -3
  28. package/dist/cjs/formatModule/helpers/formatImageProps.js.map +2 -2
  29. package/dist/cjs/getClassPrefix.d.ts +2 -0
  30. package/dist/cjs/getClassPrefix.js +43 -0
  31. package/dist/cjs/getClassPrefix.js.map +7 -0
  32. package/dist/cjs/http.d.ts +10 -0
  33. package/dist/cjs/http.js +18 -0
  34. package/dist/cjs/http.js.map +2 -2
  35. package/dist/cjs/index.d.ts +10 -2
  36. package/dist/cjs/index.js +33 -4
  37. package/dist/cjs/index.js.map +3 -3
  38. package/dist/cjs/onCallSkillEvent.d.ts +21 -0
  39. package/dist/cjs/onCallSkillEvent.js +81 -0
  40. package/dist/cjs/onCallSkillEvent.js.map +7 -0
  41. package/dist/cjs/treeUtils.js +1 -1
  42. package/dist/cjs/treeUtils.js.map +2 -2
  43. package/dist/cjs/unitConversion.d.ts +2 -0
  44. package/dist/cjs/unitConversion.js +45 -0
  45. package/dist/cjs/unitConversion.js.map +7 -0
  46. package/dist/cjs/watermark.d.ts +0 -28
  47. package/dist/cjs/watermark.js +4 -277
  48. package/dist/cjs/watermark.js.map +2 -2
  49. package/dist/esm/aiGenerateFill.d.ts +2 -0
  50. package/dist/esm/aiGenerateFill.js +17 -0
  51. package/dist/esm/aiGenerateFill.js.map +1 -0
  52. package/dist/esm/copyToClipboard.d.ts +6 -0
  53. package/dist/esm/copyToClipboard.js +23 -0
  54. package/dist/esm/copyToClipboard.js.map +1 -0
  55. package/dist/esm/dealStorageData.d.ts +35 -0
  56. package/dist/esm/dealStorageData.js +441 -0
  57. package/dist/esm/dealStorageData.js.map +1 -0
  58. package/dist/esm/docchainContextFill.d.ts +2 -0
  59. package/dist/esm/docchainContextFill.js +17 -0
  60. package/dist/esm/docchainContextFill.js.map +1 -0
  61. package/dist/esm/formatModule/formatModuleData.js +58 -11
  62. package/dist/esm/formatModule/formatModuleData.js.map +1 -1
  63. package/dist/esm/formatModule/helpers/formatDescriptionsProps.js +20 -3
  64. package/dist/esm/formatModule/helpers/formatDescriptionsProps.js.map +1 -1
  65. package/dist/esm/formatModule/helpers/formatEchartLineProps.js +12 -5
  66. package/dist/esm/formatModule/helpers/formatEchartLineProps.js.map +1 -1
  67. package/dist/esm/formatModule/helpers/formatEchartPieProps.d.ts +1 -0
  68. package/dist/esm/formatModule/helpers/formatEchartPieProps.js +30 -5
  69. package/dist/esm/formatModule/helpers/formatEchartPieProps.js.map +1 -1
  70. package/dist/esm/formatModule/helpers/formatFormProps.js +8 -0
  71. package/dist/esm/formatModule/helpers/formatFormProps.js.map +1 -1
  72. package/dist/esm/formatModule/helpers/formatHighCodeProps.js +6 -1
  73. package/dist/esm/formatModule/helpers/formatHighCodeProps.js.map +1 -1
  74. package/dist/esm/formatModule/helpers/formatImageProps.js +9 -3
  75. package/dist/esm/formatModule/helpers/formatImageProps.js.map +1 -1
  76. package/dist/esm/getClassPrefix.d.ts +2 -0
  77. package/dist/esm/getClassPrefix.js +15 -0
  78. package/dist/esm/getClassPrefix.js.map +1 -0
  79. package/dist/esm/http.d.ts +10 -0
  80. package/dist/esm/http.js +90 -58
  81. package/dist/esm/http.js.map +1 -1
  82. package/dist/esm/index.d.ts +10 -2
  83. package/dist/esm/index.js +9 -3
  84. package/dist/esm/index.js.map +1 -1
  85. package/dist/esm/onCallSkillEvent.d.ts +21 -0
  86. package/dist/esm/onCallSkillEvent.js +90 -0
  87. package/dist/esm/onCallSkillEvent.js.map +1 -0
  88. package/dist/esm/treeUtils.js +1 -3
  89. package/dist/esm/treeUtils.js.map +1 -1
  90. package/dist/esm/unitConversion.d.ts +2 -0
  91. package/dist/esm/unitConversion.js +21 -0
  92. package/dist/esm/unitConversion.js.map +1 -0
  93. package/dist/esm/watermark.d.ts +0 -28
  94. package/dist/esm/watermark.js +2 -411
  95. package/dist/esm/watermark.js.map +1 -1
  96. package/dist/umd/index.min.js +1 -1
  97. package/dist/umd/index.min.js.map +1 -1
  98. package/package.json +8 -3
package/README.md CHANGED
@@ -1,22 +1,188 @@
1
- # pro-components
1
+ # @boteteam/utils
2
2
 
3
- [![NPM version](https://img.shields.io/npm/v/pro-components.svg?style=flat)](https://npmjs.com/package/pro-components)
4
- [![NPM downloads](http://img.shields.io/npm/dm/pro-components.svg?style=flat)](https://npmjs.com/package/pro-components)
3
+ 工具包,提供文件处理、Cookie、URL 参数、存储、字符串、树/模板、模块格式化、脚本执行、文件 URL、安全、环境检测、媒体查询、HTTP、时间、水印、会话/变量解析、单位换算等能力。
5
4
 
6
- ## Install
5
+ ## 安装
7
6
 
8
7
  ```bash
9
- $ yarn install
8
+ yarn add @boteteam/utils
10
9
  ```
11
10
 
11
+
12
+
12
13
  ```bash
13
- $ npm run dev
14
- $ npm run build
14
+ npm install @boteteam/utils
15
15
  ```
16
16
 
17
- ## Options
17
+ ## 导出的工具方法说明
18
+
19
+ ### 文件与 Base64
20
+
21
+ | 方法 | 说明 |
22
+ |------|------|
23
+ | **fileToBase64** | 将 `File` 对象转为 Base64 数据 URL(Promise)。常用于图片上传前预览或提交。 |
24
+
25
+ ### Cookie
26
+
27
+ | 方法 | 说明 |
28
+ |------|------|
29
+ | **CookieUtils** | Cookie 工具对象,兼容 Web 与 React Native。提供 `get(name)`、`set(name, value, expires?, path?, domain?, secure?)`、`unset(name, path?, domain?, secure?)`,以及异步版本 `getAsync`、`setAsync`、`unsetAsync`。内部通过 `getDocument()` 获取 document,在无 DOM 环境返回 null 不报错。 |
30
+
31
+ ### URL 与路径参数
32
+
33
+ | 方法 | 说明 |
34
+ |------|------|
35
+ | **argsToString** | 将对象转为查询字符串,如 `{ a: 1, b: 2 }` → `"a=1&b=2"`。非对象或空对象返回空字符串。 |
36
+ | **argsToObject** | 将查询字符串转为对象。支持 `?key=value` 或 `key=value` 形式;将 `"true"`/`"false"` 转为布尔值,`"undefined"`/`"null"` 转为空字符串。 |
37
+ | **getSearchObj** | 从当前页面 URL(或传入的 `url`)解析 query,返回键值对对象。React Native 下无 location 时返回空对象。 |
38
+
39
+ ### 异步存储
40
+
41
+ | 方法 | 说明 |
42
+ |------|------|
43
+ | **asyncLocalStorage** | 对 `localStorage` 的异步封装,提供 `setItem`、`getItem`、`removeItem`,均返回 Promise,便于在异步流程中统一使用。 |
44
+ | **asyncSessionStorage** | 对 `sessionStorage` 的异步封装,接口同 `asyncLocalStorage`。 |
45
+
46
+ ### 字符串
47
+
48
+ | 方法 | 说明 |
49
+ |------|------|
50
+ | **camelToSnake** | 驼峰转下划线,如 `fooBar` → `foo_bar`。 |
51
+ | **underscoreToCamelCase** | 下划线转驼峰,如 `foo_bar` → `fooBar`。 |
52
+ | **generateRandom18Int** | 生成 18 位随机整数(10^17 ~ 10^18-1),返回 Promise\<number\>。 |
53
+
54
+ ### 树与模板参数(treeUtils)
55
+
56
+ | 方法 | 说明 |
57
+ |------|------|
58
+ | **getParamsArr** | 从字符串中解析 `${xxx.yyy.zzz}` 或 `${{xxx.yyy.zzz}}`,得到路径数组,如 `["xxx","yyy","zzz"]`。 |
59
+ | **getDataArr** | 同 `getParamsArr`,但会过滤掉首段的 `root`、`pageParams`,用于从数据根节点取值的路径。 |
60
+ | **replaceParamsValue** | 在字符串中替换 `${...}`、`${{...}}` 为参数对象中对应路径的值。支持 `isObject2String`:为 true 时对象会 `JSON.stringify`。 |
61
+ | **replaceParamsValueForEvent** | 专用于事件参数:保留 `pageParams` 层级、对象会做 `JSON.stringify`、替换失败时返回原始字符串。 |
62
+ | **getParamsContentByParamKeys** | 根据参数字符串(如 `"${a.b.c}"`)和 data 对象,按路径取值;支持 `${{}}` 转义内容。 |
63
+
64
+ ### 模块数据格式化
65
+
66
+ | 方法 | 说明 |
67
+ |------|------|
68
+ | **formatModuleData** | 根据模块配置(moduleData)、父模块、页面数据、参数、循环项、静态资源等,递归格式化出可直接渲染的模块树(含各类组件 props、事件、样式等)。用于低代码/页面配置驱动渲染。 |
69
+
70
+ ### 格式模块辅助(formatModule/helpers)
71
+
72
+ | 方法 | 说明 |
73
+ |------|------|
74
+ | **patternTransitionRegExp** | 将字符串转为 RegExp。支持 `/pattern/flags` 形式或普通字符串。异常时返回空字符串。 |
75
+ | **stringPramarsValTransition** | 即 `replaceParamsValue`:在字符串中把 `${...}`、`${{...}}` 替换为参数对象中的值。 |
76
+ | **stringScriptExecution** | 在 SES Compartment 中执行脚本字符串,传入 `root`(及 `window`)作为全局,返回执行结果。执行失败返回 undefined。 |
77
+ | **createCompartmentExecution** | 创建 SES 的 `Compartment` 实例,可传入 `globals` 作为沙箱全局。 |
78
+ | **checkDataSourceOfFn** | 判断字符串是否为“函数形式”数据源:去空格后不以 `$` 开头,且以 `(function()` 开头、以 `})()` 结尾。用于区分静态配置与可执行脚本。 |
79
+
80
+ ### 页面静态与接口映射
81
+
82
+ | 方法 | 说明 |
83
+ |------|------|
84
+ | **loopPageStaticCodeMap** | 遍历页面配置树(items),收集所有 `compProps.attrs` 中的 `staticCode` 以及 `dataOptions.staticCode`,去重后返回静态编码列表。 |
85
+ | **loopPageServiceApiMap** | 从页面配置第一个 `compType="page"` 的 `dataSources` 中收集 type 为 `api` 或 `custom` 的配置,返回 `{ apiId, reqParams, dataPath, name, type, ... }` 等字段的数组。 |
86
+
87
+ ### 路径取值
88
+
89
+ | 方法 | 说明 |
90
+ |------|------|
91
+ | **getValueByPath** | 根据路径字符串(如 `res.data.list`、`user.name`)从对象中取值。路径以 `res` 开头时会从 `obj.res` 起算。路径无效或中间缺失返回 null。 |
92
+
93
+ ### 脚本执行
94
+
95
+ | 方法 | 说明 |
96
+ |------|------|
97
+ | **scriptExecution** | 在 SES Compartment 中执行 `scriptCode`,传入 `options` 作为沙箱全局,返回执行结果。用于安全执行用户或配置中的脚本。 |
98
+
99
+ ### 文件与远程资源 URL
100
+
101
+ | 方法 | 说明 |
102
+ |------|------|
103
+ | **getFileUrlById** | 根据文件 ID 生成下载 URL,支持 prefix、isSecurity(默认 true,会加签/加密)、params。会自动带上当前 URL 的 token。 |
104
+ | **getFileUrlByFileInfoId** | 根据 fileInfoId 生成下载 URL,选项同 `getFileUrlById`,并支持 tenantId。 |
105
+ | **getRemoteComponentUrlByCode** | 根据页面编码(pageCode)生成远程组件请求 URL。 |
106
+ | **getRemoteComponentUrlById** | 根据 fileInfoId 生成远程组件请求 URL。 |
107
+
108
+ ### 安全
109
+
110
+ | 方法 | 说明 |
111
+ |------|------|
112
+ | **isValidUrl** | 校验 URL 是否安全:仅允许 http/https,并检测 javascript:、data:、`<script`、onload 等危险模式,防止 XSS。 |
113
+ | **sanitizeRedirectUrl** | 清理并校验重定向 URL;可传允许域名列表,未传则仅允许同源。不安全时返回 defaultUrl(默认 `/`)。 |
114
+ | **safeRedirect** | 先经 `sanitizeRedirectUrl` 得到安全 URL,再设置 `window.location.href` 跳转。React Native 下仅打日志不跳转。 |
115
+ | **sanitizeEventHandler** | 包装事件处理函数,非函数返回空函数;执行时 try-catch,避免异常抛出影响其他逻辑。 |
116
+
117
+ ### 环境检测
118
+
119
+ | 方法 | 说明 |
120
+ |------|------|
121
+ | **isReactNative** | 判断是否为 React Native 环境(通过 `global.navigator.product === 'ReactNative'`)。 |
122
+ | **isWeb** | 判断是否为 Web 环境(存在 window 与 document 且非 RN)。 |
123
+ | **isNode** | 判断是否为 Node.js 环境。 |
124
+ | **getEnvironment** | 返回当前环境:`'web'` \| `'react-native'` \| `'node'`。 |
125
+ | **getWindow** | 安全获取 `window`,非 Web 返回 null。 |
126
+ | **getDocument** | 安全获取 `document`,非 Web 返回 null。 |
127
+ | **getLocation** | 安全获取 `window.location`,非 Web 返回 null。 |
128
+ | **isMobile** | 根据 `navigator.userAgent` 判断是否为移动端设备。 |
129
+
130
+ ### 响应式与媒体查询
131
+
132
+ | 方法 | 说明 |
133
+ |------|------|
134
+ | **watchMatchMedia** | 根据主题中的断点(mobile/mini/tablet/compact/middle/large)做一次 matchMedia 检测,返回当前页面尺寸类型:`'default'` \| `'mobile'` \| `'mini'` \| `'compact'` \| `'middle'` \| `'large'` \| `'tablet'`。 |
135
+
136
+ ### HTTP 与访问地址
137
+
138
+ | 方法 | 说明 |
139
+ |------|------|
140
+ | **request** | HTTP 请求对象:`get`、`post`、`download`,以及 `getBaseUrl`、`setUrlPrefix`、`setTenantId`、`getManagerUrl`、`getBotUrl`、各类图标 URL 等。请求会自动带 token 与 Tenant-Id。 |
141
+ | **tenantIdSessionKey** | 当前租户 ID 在 sessionStorage 中的 key 常量:`'botSelectedTenantID'`。 |
142
+ | **getAccessUrl** | 根据环境变量或传入的 url 构造完整访问地址;若 url 为纯数字则视为端口号,与当前 hostname 拼接。 |
143
+
144
+ ### 时间格式化
145
+
146
+ | 方法 | 说明 |
147
+ |------|------|
148
+ | **formatTime** | 格式化时间:当天显示 HH:mm,非当天显示 YYYY-MM-DD HH:mm。 |
149
+ | **formatTimeCustom** | 自定义当天与非当天的格式,默认当天 `HH:mm`,非当天 `YYYY-MM-DD HH:mm`。 |
150
+ | **isToday** | 判断给定时间是否为今天。 |
151
+ | **getRelativeTime** | 返回相对时间文案:刚刚、N分钟前、N小时前、昨天、N天前,超过约一周则返回 YYYY-MM-DD。 |
152
+
153
+ ### 水印与 XML
154
+
155
+ | 方法 | 说明 |
156
+ |------|------|
157
+ | **generateWatermarkBase64** | 根据水印配置(内容、样式、布局、行配置等)生成水印图片的 Base64 数据 URL,支持变量解析。 |
158
+ | **generateWatermarkStyle** | 将水印样式配置转为 React CSSProperties(颜色、字号、透明度、旋转等)。 |
159
+ | **escapeXml** | 对字符串做 XML 转义:`&` `<>` `"` `'` 转为对应实体。 |
160
+
161
+ ### 会话与变量解析
162
+
163
+ | 方法 | 说明 |
164
+ |------|------|
165
+ | **getVariableRealValue** | 根据变量 key 取真实值。支持 `${system.now}`、`${system.today}`、`${system.ip}`、`${session.userId}`、`${session.userName}`、`${session.realName}`、`${contextParams.xxx}`。 |
166
+ | **parseContentVariables** | 解析字符串中所有 `${system.xxx}`、`${session.xxx}`、`${contextParams.xxx}` 并替换为真实值。 |
167
+ | **getUserInfoFromStorage** | 从 sessionStorage 或 localStorage 的 `userStores` 中读取 userInfo,返回 `{ userId, userName, realName }`。 |
168
+ | **fetchClientIp** | 异步通过第三方 API 获取客户端 IP,并写入 storage 缓存。 |
169
+ | **getClientIp** | 同步从缓存读取客户端 IP;无缓存时返回默认值并触发一次异步 fetch。 |
170
+
171
+ ### 其他
172
+
173
+ | 方法 | 说明 |
174
+ |------|------|
175
+ | **aiGenerateFill** | 在 document.body 中插入一个隐藏的 SVG,用于定义 AI 生成图标的渐变(linearGradient),供其他 SVG 通过 id 引用。 |
176
+ | **unitConversion** | 将数字(或可解析为数字的字符串)按 1024 换算为带单位的字符串,如 `1536` → `"1.5KB"`,支持 B/KB/MB/GB,整数会去掉 `.00`。 |
177
+
178
+ ## 导出的类型
18
179
 
19
- TODO
180
+ - **fileToBase64Type**:`fileToBase64` 的函数类型
181
+ - **asyncLocalStorageType** / **asyncSessionStorageType**:异步存储的 setItem/getItem/removeItem 接口
182
+ - **scriptExecutionType**:脚本执行函数类型
183
+ - **pageSizeType**:`watchMatchMedia` 返回的尺寸类型联合
184
+ - **WatermarkStyles** / **WatermarkLayout** / **WatermarkConfig** / **WatermarkRow** / **ContextVariable**:水印与上下文变量相关类型
185
+ - **SessionInfo**:会话用户信息 `{ userId?, userName?, realName? }`
20
186
 
21
187
  ## LICENSE
22
188
 
@@ -0,0 +1,2 @@
1
+ declare const aiGenearteFill: () => void;
2
+ export default aiGenearteFill;
@@ -0,0 +1,44 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/aiGenerateFill.ts
20
+ var aiGenerateFill_exports = {};
21
+ __export(aiGenerateFill_exports, {
22
+ default: () => aiGenerateFill_default
23
+ });
24
+ module.exports = __toCommonJS(aiGenerateFill_exports);
25
+ var aiGenearteFill = () => {
26
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
27
+ svg.style.position = "absolute";
28
+ svg.style.width = "0";
29
+ svg.style.height = "0";
30
+ svg.style.visibility = "hidden";
31
+ svg.style.overflow = "hidden";
32
+ svg.innerHTML = `
33
+ <defs>
34
+ <linearGradient id="icon-ai-generate_svg__a" x1="-6.64737" y1="3.91997" x2="17.3507" y2="13.7217" gradientUnits="userSpaceOnUse">
35
+ <stop stop-color="#409DFF" style="stop-color:#409DFF;stop-color:color(display-p3 0.2495 0.6157 1.0000);stop-opacity:1;"></stop>
36
+ <stop offset="0.5" stop-color="#5279FF" style="stop-color:#5279FF;stop-color:color(display-p3 0.3216 0.4745 1.0000);stop-opacity:1;"></stop>
37
+ <stop offset="1" stop-color="#C173FF" style="stop-color:#C173FF;stop-color:color(display-p3 0.7555 0.4512 1.0000);stop-opacity:1;"></stop>
38
+ </linearGradient>
39
+ </defs>
40
+ `;
41
+ document.body.appendChild(svg);
42
+ };
43
+ var aiGenerateFill_default = aiGenearteFill;
44
+ //# sourceMappingURL=aiGenerateFill.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/aiGenerateFill.ts"],
4
+ "sourcesContent": ["const aiGenearteFill = () => {\n // 使用 SVG 命名空间创建 SVG 元素,确保正确的 SVG 上下文\n const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n // 设置 SVG 为隐藏,作为渐变定义的容器(outlet)\n svg.style.position = 'absolute';\n svg.style.width = '0';\n svg.style.height = '0';\n svg.style.visibility = 'hidden';\n svg.style.overflow = 'hidden';\n \n svg.innerHTML = `\n <defs>\n <linearGradient id=\"icon-ai-generate_svg__a\" x1=\"-6.64737\" y1=\"3.91997\" x2=\"17.3507\" y2=\"13.7217\" gradientUnits=\"userSpaceOnUse\">\n <stop stop-color=\"#409DFF\" style=\"stop-color:#409DFF;stop-color:color(display-p3 0.2495 0.6157 1.0000);stop-opacity:1;\"></stop>\n <stop offset=\"0.5\" stop-color=\"#5279FF\" style=\"stop-color:#5279FF;stop-color:color(display-p3 0.3216 0.4745 1.0000);stop-opacity:1;\"></stop>\n <stop offset=\"1\" stop-color=\"#C173FF\" style=\"stop-color:#C173FF;stop-color:color(display-p3 0.7555 0.4512 1.0000);stop-opacity:1;\"></stop>\n </linearGradient>\n </defs>\n `;\n \n // 将 SVG 元素添加到 body,作为渐变定义的出口(outlet)\n // 这样其他 SVG 元素就可以通过 ID 引用其中的渐变\n document.body.appendChild(svg);\n};\n\nexport default aiGenearteFill;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,iBAAiB,MAAM;AAE3B,QAAM,MAAM,SAAS,gBAAgB,8BAA8B,KAAK;AAExE,MAAI,MAAM,WAAW;AACrB,MAAI,MAAM,QAAQ;AAClB,MAAI,MAAM,SAAS;AACnB,MAAI,MAAM,aAAa;AACvB,MAAI,MAAM,WAAW;AAErB,MAAI,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYhB,WAAS,KAAK,YAAY,GAAG;AAC/B;AAEA,IAAO,yBAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 使用 copy-to-clipboard 库的复制方法
3
+ * @param text 要复制的文本
4
+ * @returns Promise<boolean> 是否复制成功
5
+ */
6
+ export declare const copyToClipboard: (text: string) => Promise<boolean>;
@@ -0,0 +1,55 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/copyToClipboard.ts
30
+ var copyToClipboard_exports = {};
31
+ __export(copyToClipboard_exports, {
32
+ copyToClipboard: () => copyToClipboard
33
+ });
34
+ module.exports = __toCommonJS(copyToClipboard_exports);
35
+ var import_copy_to_clipboard = __toESM(require("copy-to-clipboard"));
36
+ var copyToClipboard = (text) => {
37
+ const str = typeof text === "string" ? text : String(text);
38
+ if (!str) {
39
+ return Promise.resolve(false);
40
+ }
41
+ if (typeof window === "undefined" || typeof document === "undefined") {
42
+ return Promise.resolve(false);
43
+ }
44
+ try {
45
+ const ok = (0, import_copy_to_clipboard.default)(str);
46
+ return Promise.resolve(ok);
47
+ } catch {
48
+ return Promise.resolve(false);
49
+ }
50
+ };
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ copyToClipboard
54
+ });
55
+ //# sourceMappingURL=copyToClipboard.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/copyToClipboard.ts"],
4
+ "sourcesContent": ["import copy from 'copy-to-clipboard';\n\n/**\n * 使用 copy-to-clipboard 库的复制方法\n * @param text 要复制的文本\n * @returns Promise<boolean> 是否复制成功\n */\nexport const copyToClipboard = (text: string): Promise<boolean> => {\n const str = typeof text === 'string' ? text : String(text);\n if (!str) {\n return Promise.resolve(false);\n }\n\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return Promise.resolve(false);\n }\n\n try {\n const ok = copy(str);\n return Promise.resolve(ok);\n } catch {\n return Promise.resolve(false);\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAiB;AAOV,IAAM,kBAAkB,CAAC,SAAmC;AACjE,QAAM,MAAM,OAAO,SAAS,WAAW,OAAO,OAAO,IAAI;AACzD,MAAI,CAAC,KAAK;AACR,WAAO,QAAQ,QAAQ,KAAK;AAAA,EAC9B;AAEA,MAAI,OAAO,WAAW,eAAe,OAAO,aAAa,aAAa;AACpE,WAAO,QAAQ,QAAQ,KAAK;AAAA,EAC9B;AAEA,MAAI;AACF,UAAM,SAAK,yBAAAA,SAAK,GAAG;AACnB,WAAO,QAAQ,QAAQ,EAAE;AAAA,EAC3B,QAAE;AACA,WAAO,QAAQ,QAAQ,KAAK;AAAA,EAC9B;AACF;",
6
+ "names": ["copy"]
7
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 会话信息类型
3
+ */
4
+ export interface SessionInfo {
5
+ userId?: string;
6
+ userName?: string;
7
+ realName?: string;
8
+ }
9
+ /**
10
+ * 根据 key 获取变量的真实值
11
+ * @param key 变量 key,支持格式:${system.now}、${system.today}、${system.ip}、${session.userId}、${session.userName}、${session.realName}、${contextParams.xxx}
12
+ */
13
+ export declare function getVariableRealValue(key: string): string;
14
+ /**
15
+ * 从 storage 获取用户信息(优先从 sessionStorage,其次从 localStorage)
16
+ */
17
+ export declare function getUserInfoFromStorage(): SessionInfo;
18
+ export declare function getDriverInfoFromStorage(): {
19
+ [key: string]: any;
20
+ } | null;
21
+ /**
22
+ * 异步获取客户端 IP(通过第三方 API)
23
+ * @returns Promise<string> 返回客户端 IP 地址
24
+ */
25
+ export declare function fetchClientIp(): Promise<string>;
26
+ /**
27
+ * 获取客户端 IP(同步方法,从缓存读取)
28
+ * @returns string 返回客户端 IP 地址,如果缓存中没有则返回默认值 '127.0.0.1'
29
+ */
30
+ export declare function getClientIp(): string;
31
+ /**
32
+ * 解析 content 中的所有变量并替换为真实值
33
+ * @param content 原始内容,可能包含变量如 ${system.now}、${session.userId}、${contextParams.userName} 等
34
+ */
35
+ export declare function parseContentVariables(content: string): string;