@meng-xi/vite-plugin 0.1.3 → 0.1.5

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 (142) hide show
  1. package/README-en.md +49 -775
  2. package/README.md +46 -770
  3. package/dist/common/format/index.cjs +1 -1
  4. package/dist/common/format/index.d.cts +1 -130
  5. package/dist/common/format/index.d.mts +1 -130
  6. package/dist/common/format/index.d.ts +1 -130
  7. package/dist/common/format/index.mjs +1 -1
  8. package/dist/common/fs/index.cjs +1 -1
  9. package/dist/common/fs/index.d.cts +1 -89
  10. package/dist/common/fs/index.d.mts +1 -89
  11. package/dist/common/fs/index.d.ts +1 -89
  12. package/dist/common/fs/index.mjs +1 -1
  13. package/dist/common/html/index.cjs +2 -2
  14. package/dist/common/html/index.d.cts +19 -81
  15. package/dist/common/html/index.d.mts +19 -81
  16. package/dist/common/html/index.d.ts +19 -81
  17. package/dist/common/html/index.mjs +2 -2
  18. package/dist/common/index.cjs +1 -1
  19. package/dist/common/index.d.cts +7 -8
  20. package/dist/common/index.d.mts +7 -8
  21. package/dist/common/index.d.ts +7 -8
  22. package/dist/common/index.mjs +1 -1
  23. package/dist/common/script/index.cjs +1 -1
  24. package/dist/common/script/index.d.cts +1 -44
  25. package/dist/common/script/index.d.mts +1 -44
  26. package/dist/common/script/index.d.ts +1 -44
  27. package/dist/common/script/index.mjs +1 -1
  28. package/dist/common/ui/index.cjs +1 -0
  29. package/dist/common/ui/index.d.cts +22 -0
  30. package/dist/common/ui/index.d.mts +22 -0
  31. package/dist/common/ui/index.d.ts +22 -0
  32. package/dist/common/ui/index.mjs +1 -0
  33. package/dist/common/validation/index.cjs +1 -1
  34. package/dist/common/validation/index.d.cts +2 -79
  35. package/dist/common/validation/index.d.mts +2 -79
  36. package/dist/common/validation/index.d.ts +2 -79
  37. package/dist/common/validation/index.mjs +1 -1
  38. package/dist/factory/index.cjs +1 -1
  39. package/dist/factory/index.d.cts +1 -1
  40. package/dist/factory/index.d.mts +1 -1
  41. package/dist/factory/index.d.ts +1 -1
  42. package/dist/factory/index.mjs +1 -1
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.d.cts +12 -10
  45. package/dist/index.d.mts +12 -10
  46. package/dist/index.d.ts +12 -10
  47. package/dist/index.mjs +1 -1
  48. package/dist/logger/index.d.cts +92 -1
  49. package/dist/logger/index.d.mts +92 -1
  50. package/dist/logger/index.d.ts +92 -1
  51. package/dist/plugins/autoImport/index.cjs +17 -0
  52. package/dist/plugins/autoImport/index.d.cts +291 -0
  53. package/dist/plugins/autoImport/index.d.mts +291 -0
  54. package/dist/plugins/autoImport/index.d.ts +291 -0
  55. package/dist/plugins/autoImport/index.mjs +17 -0
  56. package/dist/plugins/buildProgress/index.cjs +2 -2
  57. package/dist/plugins/buildProgress/index.d.cts +1 -1
  58. package/dist/plugins/buildProgress/index.d.mts +1 -1
  59. package/dist/plugins/buildProgress/index.d.ts +1 -1
  60. package/dist/plugins/buildProgress/index.mjs +2 -2
  61. package/dist/plugins/bundleAnalyzer/index.cjs +11 -11
  62. package/dist/plugins/bundleAnalyzer/index.d.cts +1 -1
  63. package/dist/plugins/bundleAnalyzer/index.d.mts +1 -1
  64. package/dist/plugins/bundleAnalyzer/index.d.ts +1 -1
  65. package/dist/plugins/bundleAnalyzer/index.mjs +18 -18
  66. package/dist/plugins/compressAssets/index.cjs +1 -1
  67. package/dist/plugins/compressAssets/index.d.cts +1 -1
  68. package/dist/plugins/compressAssets/index.d.mts +1 -1
  69. package/dist/plugins/compressAssets/index.d.ts +1 -1
  70. package/dist/plugins/compressAssets/index.mjs +1 -1
  71. package/dist/plugins/copyFile/index.cjs +1 -1
  72. package/dist/plugins/copyFile/index.d.cts +21 -3
  73. package/dist/plugins/copyFile/index.d.mts +21 -3
  74. package/dist/plugins/copyFile/index.d.ts +21 -3
  75. package/dist/plugins/copyFile/index.mjs +1 -1
  76. package/dist/plugins/envGuard/index.cjs +67 -0
  77. package/dist/plugins/envGuard/index.d.cts +255 -0
  78. package/dist/plugins/envGuard/index.d.mts +255 -0
  79. package/dist/plugins/envGuard/index.d.ts +255 -0
  80. package/dist/plugins/envGuard/index.mjs +67 -0
  81. package/dist/plugins/faviconManager/index.cjs +1 -1
  82. package/dist/plugins/faviconManager/index.d.cts +44 -6
  83. package/dist/plugins/faviconManager/index.d.mts +44 -6
  84. package/dist/plugins/faviconManager/index.d.ts +44 -6
  85. package/dist/plugins/faviconManager/index.mjs +1 -1
  86. package/dist/plugins/generateRouter/index.cjs +4 -4
  87. package/dist/plugins/generateRouter/index.d.cts +62 -15
  88. package/dist/plugins/generateRouter/index.d.mts +62 -15
  89. package/dist/plugins/generateRouter/index.d.ts +62 -15
  90. package/dist/plugins/generateRouter/index.mjs +4 -4
  91. package/dist/plugins/generateVersion/index.cjs +1 -1
  92. package/dist/plugins/generateVersion/index.d.cts +13 -1
  93. package/dist/plugins/generateVersion/index.d.mts +13 -1
  94. package/dist/plugins/generateVersion/index.d.ts +13 -1
  95. package/dist/plugins/generateVersion/index.mjs +1 -1
  96. package/dist/plugins/htmlInject/index.cjs +7 -7
  97. package/dist/plugins/htmlInject/index.d.cts +50 -195
  98. package/dist/plugins/htmlInject/index.d.mts +50 -195
  99. package/dist/plugins/htmlInject/index.d.ts +50 -195
  100. package/dist/plugins/htmlInject/index.mjs +7 -7
  101. package/dist/plugins/index.cjs +1 -1
  102. package/dist/plugins/index.d.cts +5 -2
  103. package/dist/plugins/index.d.mts +5 -2
  104. package/dist/plugins/index.d.ts +5 -2
  105. package/dist/plugins/index.mjs +1 -1
  106. package/dist/plugins/loadingManager/index.cjs +26 -26
  107. package/dist/plugins/loadingManager/index.d.cts +1 -1
  108. package/dist/plugins/loadingManager/index.d.mts +1 -1
  109. package/dist/plugins/loadingManager/index.d.ts +1 -1
  110. package/dist/plugins/loadingManager/index.mjs +11 -11
  111. package/dist/plugins/versionUpdateChecker/index.cjs +1 -1
  112. package/dist/plugins/versionUpdateChecker/index.d.cts +1 -1
  113. package/dist/plugins/versionUpdateChecker/index.d.mts +1 -1
  114. package/dist/plugins/versionUpdateChecker/index.d.ts +1 -1
  115. package/dist/plugins/versionUpdateChecker/index.mjs +1 -1
  116. package/dist/shared/vite-plugin.B8FuZce1.d.cts +45 -0
  117. package/dist/shared/vite-plugin.B8FuZce1.d.mts +45 -0
  118. package/dist/shared/vite-plugin.B8FuZce1.d.ts +45 -0
  119. package/dist/shared/vite-plugin.BI9taN75.d.cts +122 -0
  120. package/dist/shared/vite-plugin.BI9taN75.d.mts +122 -0
  121. package/dist/shared/vite-plugin.BI9taN75.d.ts +122 -0
  122. package/dist/shared/vite-plugin.BPFqtmWa.mjs +1 -0
  123. package/dist/shared/vite-plugin.CnOy46d3.cjs +1 -0
  124. package/package.json +16 -16
  125. package/dist/common/compress/index.cjs +0 -1
  126. package/dist/common/compress/index.d.cts +0 -23
  127. package/dist/common/compress/index.d.mts +0 -23
  128. package/dist/common/compress/index.d.ts +0 -23
  129. package/dist/common/compress/index.mjs +0 -1
  130. package/dist/common/object/index.cjs +0 -1
  131. package/dist/common/object/index.d.cts +0 -30
  132. package/dist/common/object/index.d.mts +0 -30
  133. package/dist/common/object/index.d.ts +0 -30
  134. package/dist/common/object/index.mjs +0 -1
  135. package/dist/common/path/index.cjs +0 -1
  136. package/dist/common/path/index.d.cts +0 -22
  137. package/dist/common/path/index.d.mts +0 -22
  138. package/dist/common/path/index.d.ts +0 -22
  139. package/dist/common/path/index.mjs +0 -1
  140. package/dist/shared/vite-plugin.CLr0ttuO.d.cts +0 -135
  141. package/dist/shared/vite-plugin.CLr0ttuO.d.mts +0 -135
  142. package/dist/shared/vite-plugin.CLr0ttuO.d.ts +0 -135
@@ -1,2 +1,2 @@
1
- function d(e,t,l){const n=new RegExp(t,"i");return n.test(e)?{html:e.replace(n,`${l}
2
- ${t}`),injected:!0}:{html:e,injected:!1}}function o(e,t,l=["</head>","</body>","</html>"]){for(const n of l){const c=d(e,n,t);if(c.injected)return c}return{html:e+t,injected:!0}}function a(e,t,l){const n=d(e,"</body>",t);if(n.injected)return{...n,usedFallback:!1};const c=d(e,"</html>",t);return c.injected?{...c,usedFallback:!1}:{html:e+t,injected:!0,usedFallback:!0}}function u(e,t,l){let n=e,c=!1;if(t){const i=d(n,"</head>",t);i.injected&&(n=i.html,c=!0)}const r=a(n,l);return{html:r.html,headInjected:c,bodyInjected:r.injected,usedFallback:r.usedFallback}}export{d as injectBeforeTag,a as injectBeforeTagWithFallback,u as injectHeadAndBody,o as injectHtmlByPriority};
1
+ export{s as sanitizeContent}from"../../shared/vite-plugin.BPFqtmWa.mjs";function a(e,t,l){const n=new RegExp(t,"i");return n.test(e)?{html:e.replace(n,`${l}
2
+ ${t}`),injected:!0}:{html:e,injected:!1}}function i(e,t,l){const n=a(e,"</body>",t);if(n.injected)return{...n,usedFallback:!1};const c=a(e,"</html>",t);return c.injected?{...c,usedFallback:!1}:{html:e+t,injected:!0,usedFallback:!0}}function r(e,t,l){let n=e,c=!1;if(t){const s=a(n,"</head>",t);s.injected&&(n=s.html,c=!0)}const d=i(n,l);return{html:d.html,headInjected:c,bodyInjected:d.injected,usedFallback:d.usedFallback}}export{a as injectBeforeTag,r as injectHeadAndBody};
@@ -1 +1 @@
1
- "use strict";const common_compress_index=require("./compress/index.cjs"),common_format_index=require("./format/index.cjs"),common_fs_index=require("./fs/index.cjs"),common_html_index=require("./html/index.cjs"),common_object_index=require("./object/index.cjs"),common_path_index=require("./path/index.cjs"),common_script_index=require("./script/index.cjs"),validator=require("../shared/vite-plugin.Bcg6RW2N.cjs"),common_validation_index=require("./validation/index.cjs");require("node:zlib"),require("node:stream/promises"),require("node:stream"),require("crypto"),require("node:path"),require("fs"),require("path"),exports.calculateGzipSize=common_compress_index.calculateGzipSize,exports.escapeHtmlAttr=common_format_index.escapeHtmlAttr,exports.formatDate=common_format_index.formatDate,exports.formatFileSize=common_format_index.formatFileSize,exports.generateRandomHash=common_format_index.generateRandomHash,exports.getDateFormatParams=common_format_index.getDateFormatParams,exports.getExtension=common_format_index.getExtension,exports.padNumber=common_format_index.padNumber,exports.parseTemplate=common_format_index.parseTemplate,exports.stripJsonComments=common_format_index.stripJsonComments,exports.toCamelCase=common_format_index.toCamelCase,exports.toPascalCase=common_format_index.toPascalCase,exports.checkSourceExists=common_fs_index.checkSourceExists,exports.copySourceToTarget=common_fs_index.copySourceToTarget,exports.ensureTargetDir=common_fs_index.ensureTargetDir,exports.fileExists=common_fs_index.fileExists,exports.readDirRecursive=common_fs_index.readDirRecursive,exports.readFileContent=common_fs_index.readFileContent,exports.readFileSync=common_fs_index.readFileSync,exports.runWithConcurrency=common_fs_index.runWithConcurrency,exports.scanDirectory=common_fs_index.scanDirectory,exports.shouldUpdateFile=common_fs_index.shouldUpdateFile,exports.writeFileContent=common_fs_index.writeFileContent,exports.writeJsonReport=common_fs_index.writeJsonReport,exports.injectBeforeTag=common_html_index.injectBeforeTag,exports.injectBeforeTagWithFallback=common_html_index.injectBeforeTagWithFallback,exports.injectHeadAndBody=common_html_index.injectHeadAndBody,exports.injectHtmlByPriority=common_html_index.injectHtmlByPriority,exports.deepMerge=common_object_index.deepMerge,exports.isNodeModule=common_path_index.isNodeModule,exports.containsScriptTag=common_script_index.containsScriptTag,exports.makeCallback=common_script_index.makeCallback,exports.validateIdentifierName=common_script_index.validateIdentifierName,exports.Validator=validator.Validator,exports.validateCallbackFields=common_validation_index.validateCallbackFields,exports.validateEnumValue=common_validation_index.validateEnumValue,exports.validateGlobalName=common_validation_index.validateGlobalName,exports.validateNestedDuration=common_validation_index.validateNestedDuration,exports.validateNoScriptInTemplate=common_validation_index.validateNoScriptInTemplate,exports.validateNonNegativeNumber=common_validation_index.validateNonNegativeNumber;
1
+ "use strict";const common_format_index=require("./format/index.cjs"),common_fs_index=require("./fs/index.cjs"),common_html_index=require("./html/index.cjs"),common_script_index=require("./script/index.cjs"),common_ui_index=require("./ui/index.cjs"),validator=require("../shared/vite-plugin.Bcg6RW2N.cjs"),common_validation_index=require("./validation/index.cjs"),security=require("../shared/vite-plugin.CnOy46d3.cjs");require("fs"),require("path"),exports.formatFileSize=common_format_index.formatFileSize,exports.getDateFormatParams=common_format_index.getDateFormatParams,exports.checkSourceExists=common_fs_index.checkSourceExists,exports.copySourceToTarget=common_fs_index.copySourceToTarget,exports.scanDirectory=common_fs_index.scanDirectory,exports.writeFileContent=common_fs_index.writeFileContent,exports.writeJsonReport=common_fs_index.writeJsonReport,exports.injectBeforeTag=common_html_index.injectBeforeTag,exports.injectHeadAndBody=common_html_index.injectHeadAndBody,exports.makeCallback=common_script_index.makeCallback,exports.ANSI=common_ui_index.ANSI,exports.Validator=validator.Validator,exports.validateCallbackFields=common_validation_index.validateCallbackFields,exports.validateGlobalName=common_validation_index.validateGlobalName,exports.validateNoScriptInTemplate=common_validation_index.validateNoScriptInTemplate,exports.sanitizeContent=security.sanitizeContent;
@@ -1,9 +1,8 @@
1
- export { calculateGzipSize } from './compress/index.cjs';
2
- export { DateFormatOptions, escapeHtmlAttr, formatDate, formatFileSize, generateRandomHash, getDateFormatParams, getExtension, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase } from './format/index.cjs';
3
- export { CopyOptions, CopyResult, ScanDirectoryOptions, ScannedFile, checkSourceExists, copySourceToTarget, ensureTargetDir, fileExists, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, scanDirectory, shouldUpdateFile, writeFileContent, writeJsonReport } from './fs/index.cjs';
4
- export { DualInjectResult, HtmlInjectResult, injectBeforeTag, injectBeforeTagWithFallback, injectHeadAndBody, injectHtmlByPriority } from './html/index.cjs';
5
- export { deepMerge } from './object/index.cjs';
6
- export { isNodeModule } from './path/index.cjs';
7
- export { containsScriptTag, makeCallback, validateIdentifierName } from './script/index.cjs';
1
+ export { DateFormatOptions, formatFileSize, getDateFormatParams } from './format/index.cjs';
2
+ export { CopyOptions, CopyResult, ScanDirectoryOptions, ScannedFile, checkSourceExists, copySourceToTarget, scanDirectory, writeFileContent, writeJsonReport } from './fs/index.cjs';
3
+ export { SanitizeRuleOptions, injectBeforeTag, injectHeadAndBody, sanitizeContent } from './html/index.cjs';
4
+ export { makeCallback } from './script/index.cjs';
5
+ export { ANSI } from './ui/index.cjs';
8
6
  export { V as Validator } from '../shared/vite-plugin.DRRlWY8P.cjs';
9
- export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber } from './validation/index.cjs';
7
+ export { validateCallbackFields, validateGlobalName, validateNoScriptInTemplate } from './validation/index.cjs';
8
+ export { C as ConditionType, D as DualInjectResult, H as HtmlInjectResult, I as InjectCondition, a as InjectPosition, S as SecurityConfig, b as SelectorMatch } from '../shared/vite-plugin.BI9taN75.cjs';
@@ -1,9 +1,8 @@
1
- export { calculateGzipSize } from './compress/index.mjs';
2
- export { DateFormatOptions, escapeHtmlAttr, formatDate, formatFileSize, generateRandomHash, getDateFormatParams, getExtension, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase } from './format/index.mjs';
3
- export { CopyOptions, CopyResult, ScanDirectoryOptions, ScannedFile, checkSourceExists, copySourceToTarget, ensureTargetDir, fileExists, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, scanDirectory, shouldUpdateFile, writeFileContent, writeJsonReport } from './fs/index.mjs';
4
- export { DualInjectResult, HtmlInjectResult, injectBeforeTag, injectBeforeTagWithFallback, injectHeadAndBody, injectHtmlByPriority } from './html/index.mjs';
5
- export { deepMerge } from './object/index.mjs';
6
- export { isNodeModule } from './path/index.mjs';
7
- export { containsScriptTag, makeCallback, validateIdentifierName } from './script/index.mjs';
1
+ export { DateFormatOptions, formatFileSize, getDateFormatParams } from './format/index.mjs';
2
+ export { CopyOptions, CopyResult, ScanDirectoryOptions, ScannedFile, checkSourceExists, copySourceToTarget, scanDirectory, writeFileContent, writeJsonReport } from './fs/index.mjs';
3
+ export { SanitizeRuleOptions, injectBeforeTag, injectHeadAndBody, sanitizeContent } from './html/index.mjs';
4
+ export { makeCallback } from './script/index.mjs';
5
+ export { ANSI } from './ui/index.mjs';
8
6
  export { V as Validator } from '../shared/vite-plugin.DRRlWY8P.mjs';
9
- export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber } from './validation/index.mjs';
7
+ export { validateCallbackFields, validateGlobalName, validateNoScriptInTemplate } from './validation/index.mjs';
8
+ export { C as ConditionType, D as DualInjectResult, H as HtmlInjectResult, I as InjectCondition, a as InjectPosition, S as SecurityConfig, b as SelectorMatch } from '../shared/vite-plugin.BI9taN75.mjs';
@@ -1,9 +1,8 @@
1
- export { calculateGzipSize } from './compress/index.js';
2
- export { DateFormatOptions, escapeHtmlAttr, formatDate, formatFileSize, generateRandomHash, getDateFormatParams, getExtension, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase } from './format/index.js';
3
- export { CopyOptions, CopyResult, ScanDirectoryOptions, ScannedFile, checkSourceExists, copySourceToTarget, ensureTargetDir, fileExists, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, scanDirectory, shouldUpdateFile, writeFileContent, writeJsonReport } from './fs/index.js';
4
- export { DualInjectResult, HtmlInjectResult, injectBeforeTag, injectBeforeTagWithFallback, injectHeadAndBody, injectHtmlByPriority } from './html/index.js';
5
- export { deepMerge } from './object/index.js';
6
- export { isNodeModule } from './path/index.js';
7
- export { containsScriptTag, makeCallback, validateIdentifierName } from './script/index.js';
1
+ export { DateFormatOptions, formatFileSize, getDateFormatParams } from './format/index.js';
2
+ export { CopyOptions, CopyResult, ScanDirectoryOptions, ScannedFile, checkSourceExists, copySourceToTarget, scanDirectory, writeFileContent, writeJsonReport } from './fs/index.js';
3
+ export { SanitizeRuleOptions, injectBeforeTag, injectHeadAndBody, sanitizeContent } from './html/index.js';
4
+ export { makeCallback } from './script/index.js';
5
+ export { ANSI } from './ui/index.js';
8
6
  export { V as Validator } from '../shared/vite-plugin.DRRlWY8P.js';
9
- export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber } from './validation/index.js';
7
+ export { validateCallbackFields, validateGlobalName, validateNoScriptInTemplate } from './validation/index.js';
8
+ export { C as ConditionType, D as DualInjectResult, H as HtmlInjectResult, I as InjectCondition, a as InjectPosition, S as SecurityConfig, b as SelectorMatch } from '../shared/vite-plugin.BI9taN75.js';
@@ -1 +1 @@
1
- export{calculateGzipSize}from"./compress/index.mjs";export{escapeHtmlAttr,formatDate,formatFileSize,generateRandomHash,getDateFormatParams,getExtension,padNumber,parseTemplate,stripJsonComments,toCamelCase,toPascalCase}from"./format/index.mjs";export{checkSourceExists,copySourceToTarget,ensureTargetDir,fileExists,readDirRecursive,readFileContent,readFileSync,runWithConcurrency,scanDirectory,shouldUpdateFile,writeFileContent,writeJsonReport}from"./fs/index.mjs";export{injectBeforeTag,injectBeforeTagWithFallback,injectHeadAndBody,injectHtmlByPriority}from"./html/index.mjs";export{deepMerge}from"./object/index.mjs";export{isNodeModule}from"./path/index.mjs";export{containsScriptTag,makeCallback,validateIdentifierName}from"./script/index.mjs";export{V as Validator}from"../shared/vite-plugin.DcExl6jd.mjs";export{validateCallbackFields,validateEnumValue,validateGlobalName,validateNestedDuration,validateNoScriptInTemplate,validateNonNegativeNumber}from"./validation/index.mjs";import"node:zlib";import"node:stream/promises";import"node:stream";import"crypto";import"node:path";import"fs";import"path";
1
+ export{formatFileSize,getDateFormatParams}from"./format/index.mjs";export{checkSourceExists,copySourceToTarget,scanDirectory,writeFileContent,writeJsonReport}from"./fs/index.mjs";export{injectBeforeTag,injectHeadAndBody}from"./html/index.mjs";export{makeCallback}from"./script/index.mjs";export{ANSI}from"./ui/index.mjs";export{V as Validator}from"../shared/vite-plugin.DcExl6jd.mjs";export{validateCallbackFields,validateGlobalName,validateNoScriptInTemplate}from"./validation/index.mjs";export{s as sanitizeContent}from"../shared/vite-plugin.BPFqtmWa.mjs";import"fs";import"path";
@@ -1 +1 @@
1
- "use strict";function makeCallback(u,r="callback",t=""){return u?`function(${t}) { try { ${u} } catch(e) { console.error('[${r}] error:', e); } }`:`function(${t}) {}`}function containsScriptTag(u){return/<script\b/i.test(u)}function validateIdentifierName(u){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(u))throw new Error(`"${u}" \u4E0D\u662F\u5408\u6CD5\u7684 JavaScript \u6807\u8BC6\u7B26\uFF0C\u5FC5\u987B\u4EE5\u5B57\u6BCD\u3001\u4E0B\u5212\u7EBF\u6216\u7F8E\u5143\u7B26\u5F00\u5934\uFF0C\u4EC5\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u7F8E\u5143\u7B26`);if(["__proto__","constructor","prototype"].includes(u))throw new Error(`"${u}" \u662F JavaScript \u5185\u7F6E\u5C5E\u6027\uFF0C\u53EF\u80FD\u5BFC\u81F4\u539F\u578B\u6C61\u67D3\uFF0C\u8BF7\u4F7F\u7528\u5176\u4ED6\u540D\u79F0`)}exports.containsScriptTag=containsScriptTag,exports.makeCallback=makeCallback,exports.validateIdentifierName=validateIdentifierName;
1
+ "use strict";function makeCallback(c,r="callback",e=""){return c?`function(${e}) { try { ${c} } catch(e) { console.error('[${r}] error:', e); } }`:`function(${e}) {}`}exports.makeCallback=makeCallback;
@@ -5,50 +5,7 @@
5
5
  * @param context - 回调上下文标识,用于错误日志
6
6
  * @param params - 函数参数列表字符串,默认为空
7
7
  * @returns 安全的函数表达式字符串(包含 try-catch 保护)
8
- *
9
- * @example
10
- * ```typescript
11
- * makeCallback('console.log("done")')
12
- * // 'function() { try { console.log("done") } catch(e) { console.error('[callback] error:', e); } }'
13
- *
14
- * makeCallback('console.log(a, b)', 'callback', 'a, b')
15
- * // 'function(a, b) { try { console.log(a, b) } catch(e) { console.error('[callback] error:', e); } }'
16
- *
17
- * makeCallback('')
18
- * // 'function() {}'
19
- * ```
20
8
  */
21
9
  declare function makeCallback(body?: string, context?: string, params?: string): string;
22
- /**
23
- * 检测字符串是否包含 `<script>` 标签
24
- *
25
- * @param str - 待检测的字符串
26
- * @returns 是否包含 script 标签
27
- *
28
- * @example
29
- * ```typescript
30
- * containsScriptTag('<div onclick="alert(1)">') // false
31
- * containsScriptTag('<script>alert(1)</script>') // true
32
- * ```
33
- */
34
- declare function containsScriptTag(str: string): boolean;
35
- /**
36
- * 验证字符串是否为合法的 JavaScript 标识符
37
- *
38
- * @description 检查名称是否以字母、下划线或美元符开头,
39
- * 仅包含字母、数字、下划线和美元符,并排除可能导致原型污染的内置属性
40
- *
41
- * @param name - 待验证的标识符名称
42
- * @throws 当名称不是合法标识符时抛出错误
43
- * @throws 当名称为 JavaScript 内置属性时抛出错误
44
- *
45
- * @example
46
- * ```typescript
47
- * validateIdentifierName('__LOADING_MANAGER__') // 通过
48
- * validateIdentifierName('123abc') // 抛出错误
49
- * validateIdentifierName('__proto__') // 抛出错误(内置属性)
50
- * ```
51
- */
52
- declare function validateIdentifierName(name: string): void;
53
10
 
54
- export { containsScriptTag, makeCallback, validateIdentifierName };
11
+ export { makeCallback };
@@ -5,50 +5,7 @@
5
5
  * @param context - 回调上下文标识,用于错误日志
6
6
  * @param params - 函数参数列表字符串,默认为空
7
7
  * @returns 安全的函数表达式字符串(包含 try-catch 保护)
8
- *
9
- * @example
10
- * ```typescript
11
- * makeCallback('console.log("done")')
12
- * // 'function() { try { console.log("done") } catch(e) { console.error('[callback] error:', e); } }'
13
- *
14
- * makeCallback('console.log(a, b)', 'callback', 'a, b')
15
- * // 'function(a, b) { try { console.log(a, b) } catch(e) { console.error('[callback] error:', e); } }'
16
- *
17
- * makeCallback('')
18
- * // 'function() {}'
19
- * ```
20
8
  */
21
9
  declare function makeCallback(body?: string, context?: string, params?: string): string;
22
- /**
23
- * 检测字符串是否包含 `<script>` 标签
24
- *
25
- * @param str - 待检测的字符串
26
- * @returns 是否包含 script 标签
27
- *
28
- * @example
29
- * ```typescript
30
- * containsScriptTag('<div onclick="alert(1)">') // false
31
- * containsScriptTag('<script>alert(1)</script>') // true
32
- * ```
33
- */
34
- declare function containsScriptTag(str: string): boolean;
35
- /**
36
- * 验证字符串是否为合法的 JavaScript 标识符
37
- *
38
- * @description 检查名称是否以字母、下划线或美元符开头,
39
- * 仅包含字母、数字、下划线和美元符,并排除可能导致原型污染的内置属性
40
- *
41
- * @param name - 待验证的标识符名称
42
- * @throws 当名称不是合法标识符时抛出错误
43
- * @throws 当名称为 JavaScript 内置属性时抛出错误
44
- *
45
- * @example
46
- * ```typescript
47
- * validateIdentifierName('__LOADING_MANAGER__') // 通过
48
- * validateIdentifierName('123abc') // 抛出错误
49
- * validateIdentifierName('__proto__') // 抛出错误(内置属性)
50
- * ```
51
- */
52
- declare function validateIdentifierName(name: string): void;
53
10
 
54
- export { containsScriptTag, makeCallback, validateIdentifierName };
11
+ export { makeCallback };
@@ -5,50 +5,7 @@
5
5
  * @param context - 回调上下文标识,用于错误日志
6
6
  * @param params - 函数参数列表字符串,默认为空
7
7
  * @returns 安全的函数表达式字符串(包含 try-catch 保护)
8
- *
9
- * @example
10
- * ```typescript
11
- * makeCallback('console.log("done")')
12
- * // 'function() { try { console.log("done") } catch(e) { console.error('[callback] error:', e); } }'
13
- *
14
- * makeCallback('console.log(a, b)', 'callback', 'a, b')
15
- * // 'function(a, b) { try { console.log(a, b) } catch(e) { console.error('[callback] error:', e); } }'
16
- *
17
- * makeCallback('')
18
- * // 'function() {}'
19
- * ```
20
8
  */
21
9
  declare function makeCallback(body?: string, context?: string, params?: string): string;
22
- /**
23
- * 检测字符串是否包含 `<script>` 标签
24
- *
25
- * @param str - 待检测的字符串
26
- * @returns 是否包含 script 标签
27
- *
28
- * @example
29
- * ```typescript
30
- * containsScriptTag('<div onclick="alert(1)">') // false
31
- * containsScriptTag('<script>alert(1)</script>') // true
32
- * ```
33
- */
34
- declare function containsScriptTag(str: string): boolean;
35
- /**
36
- * 验证字符串是否为合法的 JavaScript 标识符
37
- *
38
- * @description 检查名称是否以字母、下划线或美元符开头,
39
- * 仅包含字母、数字、下划线和美元符,并排除可能导致原型污染的内置属性
40
- *
41
- * @param name - 待验证的标识符名称
42
- * @throws 当名称不是合法标识符时抛出错误
43
- * @throws 当名称为 JavaScript 内置属性时抛出错误
44
- *
45
- * @example
46
- * ```typescript
47
- * validateIdentifierName('__LOADING_MANAGER__') // 通过
48
- * validateIdentifierName('123abc') // 抛出错误
49
- * validateIdentifierName('__proto__') // 抛出错误(内置属性)
50
- * ```
51
- */
52
- declare function validateIdentifierName(name: string): void;
53
10
 
54
- export { containsScriptTag, makeCallback, validateIdentifierName };
11
+ export { makeCallback };
@@ -1 +1 @@
1
- function r(u,F="callback",t=""){return u?`function(${t}) { try { ${u} } catch(e) { console.error('[${F}] error:', e); } }`:`function(${t}) {}`}function o(u){return/<script\b/i.test(u)}function c(u){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(u))throw new Error(`"${u}" \u4E0D\u662F\u5408\u6CD5\u7684 JavaScript \u6807\u8BC6\u7B26\uFF0C\u5FC5\u987B\u4EE5\u5B57\u6BCD\u3001\u4E0B\u5212\u7EBF\u6216\u7F8E\u5143\u7B26\u5F00\u5934\uFF0C\u4EC5\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u7F8E\u5143\u7B26`);if(["__proto__","constructor","prototype"].includes(u))throw new Error(`"${u}" \u662F JavaScript \u5185\u7F6E\u5C5E\u6027\uFF0C\u53EF\u80FD\u5BFC\u81F4\u539F\u578B\u6C61\u67D3\uFF0C\u8BF7\u4F7F\u7528\u5176\u4ED6\u540D\u79F0`)}export{o as containsScriptTag,r as makeCallback,c as validateIdentifierName};
1
+ function o(c,e="callback",r=""){return c?`function(${r}) { try { ${c} } catch(e) { console.error('[${e}] error:', e); } }`:`function(${r}) {}`}export{o as makeCallback};
@@ -0,0 +1 @@
1
+ "use strict";const ANSI={reset:"\x1B[0G",clearLine:"\x1B[2K",hideCursor:"\x1B[?25l",showCursor:"\x1B[?25h",green:x=>`\x1B[32m${x}\x1B[39m`,cyan:x=>`\x1B[36m${x}\x1B[39m`,gray:x=>`\x1B[90m${x}\x1B[39m`,bold:x=>`\x1B[1m${x}\x1B[22m`,red:x=>`\x1B[31m${x}\x1B[39m`,yellow:x=>`\x1B[33m${x}\x1B[39m`,magenta:x=>`\x1B[35m${x}\x1B[39m`};exports.ANSI=ANSI;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * ANSI 转义码工具集
3
+ */
4
+ declare const ANSI: {
5
+ /** 将光标重置到行首 */
6
+ reset: string;
7
+ /** 清除当前行内容 */
8
+ clearLine: string;
9
+ /** 隐藏终端光标 */
10
+ hideCursor: string;
11
+ /** 显示终端光标 */
12
+ showCursor: string;
13
+ green: (t: string) => string;
14
+ cyan: (t: string) => string;
15
+ gray: (t: string) => string;
16
+ bold: (t: string) => string;
17
+ red: (t: string) => string;
18
+ yellow: (t: string) => string;
19
+ magenta: (t: string) => string;
20
+ };
21
+
22
+ export { ANSI };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * ANSI 转义码工具集
3
+ */
4
+ declare const ANSI: {
5
+ /** 将光标重置到行首 */
6
+ reset: string;
7
+ /** 清除当前行内容 */
8
+ clearLine: string;
9
+ /** 隐藏终端光标 */
10
+ hideCursor: string;
11
+ /** 显示终端光标 */
12
+ showCursor: string;
13
+ green: (t: string) => string;
14
+ cyan: (t: string) => string;
15
+ gray: (t: string) => string;
16
+ bold: (t: string) => string;
17
+ red: (t: string) => string;
18
+ yellow: (t: string) => string;
19
+ magenta: (t: string) => string;
20
+ };
21
+
22
+ export { ANSI };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * ANSI 转义码工具集
3
+ */
4
+ declare const ANSI: {
5
+ /** 将光标重置到行首 */
6
+ reset: string;
7
+ /** 清除当前行内容 */
8
+ clearLine: string;
9
+ /** 隐藏终端光标 */
10
+ hideCursor: string;
11
+ /** 显示终端光标 */
12
+ showCursor: string;
13
+ green: (t: string) => string;
14
+ cyan: (t: string) => string;
15
+ gray: (t: string) => string;
16
+ bold: (t: string) => string;
17
+ red: (t: string) => string;
18
+ yellow: (t: string) => string;
19
+ magenta: (t: string) => string;
20
+ };
21
+
22
+ export { ANSI };
@@ -0,0 +1 @@
1
+ const B={reset:"\x1B[0G",clearLine:"\x1B[2K",hideCursor:"\x1B[?25l",showCursor:"\x1B[?25h",green:x=>`\x1B[32m${x}\x1B[39m`,cyan:x=>`\x1B[36m${x}\x1B[39m`,gray:x=>`\x1B[90m${x}\x1B[39m`,bold:x=>`\x1B[1m${x}\x1B[22m`,red:x=>`\x1B[31m${x}\x1B[39m`,yellow:x=>`\x1B[33m${x}\x1B[39m`,magenta:x=>`\x1B[35m${x}\x1B[39m`};export{B as ANSI};
@@ -1 +1 @@
1
- "use strict";const validator=require("../../shared/vite-plugin.Bcg6RW2N.cjs"),common_script_index=require("../script/index.cjs");function validateGlobalName(t,e){if(t)try{common_script_index.validateIdentifierName(t)}catch(i){throw new Error(`${e} ${i.message}`)}}function validateNoScriptInTemplate(t,e){if(t&&common_script_index.containsScriptTag(t))throw new Error(`${e} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}function validateCallbackFields(t,e,i){for(const o of e){const a=t[o];if(a!==void 0&&typeof a!="string")throw new Error(`${i}.${o} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`);if(a&&common_script_index.containsScriptTag(a))throw new Error(`${i}.${o} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}}function validateNonNegativeNumber(t,e){if(t!==void 0&&(typeof t!="number"||t<0))throw new Error(`${e} \u5FC5\u987B\u662F\u975E\u8D1F\u6570`)}function validateNestedDuration(t,e){if(t?.duration!==void 0&&(typeof t.duration!="number"||t.duration<0))throw new Error(e)}function validateEnumValue(t,e,i){if(t&&!e.includes(t))throw new Error(`${i} \u5FC5\u987B\u662F ${e.join(", ")}`)}exports.Validator=validator.Validator,exports.validateCallbackFields=validateCallbackFields,exports.validateEnumValue=validateEnumValue,exports.validateGlobalName=validateGlobalName,exports.validateNestedDuration=validateNestedDuration,exports.validateNoScriptInTemplate=validateNoScriptInTemplate,exports.validateNonNegativeNumber=validateNonNegativeNumber;
1
+ "use strict";const validator=require("../../shared/vite-plugin.Bcg6RW2N.cjs");function validateGlobalName(u,t){if(u){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(u))throw new Error(`${t} "${u}" \u4E0D\u662F\u5408\u6CD5\u7684 JavaScript \u6807\u8BC6\u7B26\uFF0C\u5FC5\u987B\u4EE5\u5B57\u6BCD\u3001\u4E0B\u5212\u7EBF\u6216\u7F8E\u5143\u7B26\u5F00\u5934\uFF0C\u4EC5\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u7F8E\u5143\u7B26`);if(["__proto__","constructor","prototype"].includes(u))throw new Error(`${t} "${u}" \u662F JavaScript \u5185\u7F6E\u5C5E\u6027\uFF0C\u53EF\u80FD\u5BFC\u81F4\u539F\u578B\u6C61\u67D3\uFF0C\u8BF7\u4F7F\u7528\u5176\u4ED6\u540D\u79F0`)}}function validateNoScriptInTemplate(u,t){if(u&&/<script\b/i.test(u))throw new Error(`${t} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}function validateCallbackFields(u,t,o){for(const i of t){const r=u[i];if(r!==void 0&&typeof r!="string")throw new Error(`${o}.${i} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`);if(r&&/<script\b/i.test(r))throw new Error(`${o}.${i} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}}exports.Validator=validator.Validator,exports.validateCallbackFields=validateCallbackFields,exports.validateGlobalName=validateGlobalName,exports.validateNoScriptInTemplate=validateNoScriptInTemplate;
@@ -1,93 +1,16 @@
1
1
  export { V as Validator } from '../../shared/vite-plugin.DRRlWY8P.cjs';
2
2
 
3
3
  /**
4
- * 验证全局变量名的合法性(包装 validateIdentifierName,附加字段上下文信息)
5
- *
6
- * @param name - 全局变量名
7
- * @param fieldName - 字段名称,用于错误消息上下文(如 'globalName'、'defineName')
8
- * @throws 当名称不合法时抛出带字段上下文的错误
9
- *
10
- * @example
11
- * ```typescript
12
- * validateGlobalName('__LOADING_MANAGER__', 'globalName')
13
- * validateGlobalName('__APP_VERSION__', 'defineName')
14
- * ```
4
+ * 验证全局变量名的合法性
15
5
  */
16
6
  declare function validateGlobalName(name: string | undefined, fieldName: string): void;
17
7
  /**
18
8
  * 验证模板字符串不包含 script 标签(XSS 防护)
19
- *
20
- * @param template - 模板字符串
21
- * @param fieldName - 字段名称,用于错误消息上下文
22
- * @throws 当模板包含 `<script>` 标签时抛出错误
23
- *
24
- * @example
25
- * ```typescript
26
- * validateNoScriptInTemplate('<div>safe</div>', 'customTemplate')
27
- * validateNoScriptInTemplate(options.customPromptTemplate, 'customPromptTemplate')
28
- * ```
29
9
  */
30
10
  declare function validateNoScriptInTemplate(template: string | undefined, fieldName: string): void;
31
11
  /**
32
12
  * 验证回调字段不包含 script 标签
33
- *
34
- * @param callbacks - 回调配置对象
35
- * @param fields - 需要验证的回调字段名数组
36
- * @param objectName - 回调所属对象名称,用于错误消息上下文
37
- * @throws 当回调字段非字符串类型时抛出错误
38
- * @throws 当回调字符串包含 `<script>` 标签时抛出错误
39
- *
40
- * @example
41
- * ```typescript
42
- * validateCallbackFields(callbacks, ['onShow', 'onHide'], 'callbacks')
43
- * validateCallbackFields(options, ['onUpdateAvailable', 'onRefresh'], 'callbacks')
44
- * ```
45
13
  */
46
14
  declare function validateCallbackFields(callbacks: Record<string, any>, fields: string[], objectName: string): void;
47
- /**
48
- * 验证数值为非负数
49
- *
50
- * @param value - 待验证的数值
51
- * @param fieldName - 字段名称,用于错误消息
52
- * @throws 当值存在但不是数字或为负数时抛出错误
53
- *
54
- * @example
55
- * ```typescript
56
- * validateNonNegativeNumber(100, 'zIndex')
57
- * validateNonNegativeNumber(-1, 'duration') // 抛出错误
58
- * ```
59
- */
60
- declare function validateNonNegativeNumber(value: number | undefined, fieldName: string): void;
61
- /**
62
- * 验证嵌套配置项的 duration 合法性
63
- *
64
- * @param config - 嵌套配置对象(包含 enabled 和 duration 字段)
65
- * @param errorMsg - 验证失败时的错误提示信息
66
- * @throws 当 duration 存在但不是非负数时抛出错误
67
- *
68
- * @example
69
- * ```typescript
70
- * validateNestedDuration({ enabled: true, duration: 300 }, 'minDisplayTime.duration 必须是非负数')
71
- * ```
72
- */
73
- declare function validateNestedDuration(config: {
74
- enabled?: boolean;
75
- duration?: number;
76
- } | undefined, errorMsg: string): void;
77
- /**
78
- * 验证字符串值是否在允许的枚举列表中
79
- *
80
- * @param value - 待验证的值
81
- * @param allowedValues - 允许的值列表
82
- * @param fieldName - 字段名称,用于错误消息
83
- * @throws 当值存在但不在允许列表中时抛出错误
84
- *
85
- * @example
86
- * ```typescript
87
- * validateEnumValue('center', ['center', 'top', 'bottom'], 'position')
88
- * validateEnumValue('modal', ['modal', 'banner', 'toast'], 'promptStyle')
89
- * ```
90
- */
91
- declare function validateEnumValue(value: string | undefined, allowedValues: string[], fieldName: string): void;
92
15
 
93
- export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber };
16
+ export { validateCallbackFields, validateGlobalName, validateNoScriptInTemplate };
@@ -1,93 +1,16 @@
1
1
  export { V as Validator } from '../../shared/vite-plugin.DRRlWY8P.mjs';
2
2
 
3
3
  /**
4
- * 验证全局变量名的合法性(包装 validateIdentifierName,附加字段上下文信息)
5
- *
6
- * @param name - 全局变量名
7
- * @param fieldName - 字段名称,用于错误消息上下文(如 'globalName'、'defineName')
8
- * @throws 当名称不合法时抛出带字段上下文的错误
9
- *
10
- * @example
11
- * ```typescript
12
- * validateGlobalName('__LOADING_MANAGER__', 'globalName')
13
- * validateGlobalName('__APP_VERSION__', 'defineName')
14
- * ```
4
+ * 验证全局变量名的合法性
15
5
  */
16
6
  declare function validateGlobalName(name: string | undefined, fieldName: string): void;
17
7
  /**
18
8
  * 验证模板字符串不包含 script 标签(XSS 防护)
19
- *
20
- * @param template - 模板字符串
21
- * @param fieldName - 字段名称,用于错误消息上下文
22
- * @throws 当模板包含 `<script>` 标签时抛出错误
23
- *
24
- * @example
25
- * ```typescript
26
- * validateNoScriptInTemplate('<div>safe</div>', 'customTemplate')
27
- * validateNoScriptInTemplate(options.customPromptTemplate, 'customPromptTemplate')
28
- * ```
29
9
  */
30
10
  declare function validateNoScriptInTemplate(template: string | undefined, fieldName: string): void;
31
11
  /**
32
12
  * 验证回调字段不包含 script 标签
33
- *
34
- * @param callbacks - 回调配置对象
35
- * @param fields - 需要验证的回调字段名数组
36
- * @param objectName - 回调所属对象名称,用于错误消息上下文
37
- * @throws 当回调字段非字符串类型时抛出错误
38
- * @throws 当回调字符串包含 `<script>` 标签时抛出错误
39
- *
40
- * @example
41
- * ```typescript
42
- * validateCallbackFields(callbacks, ['onShow', 'onHide'], 'callbacks')
43
- * validateCallbackFields(options, ['onUpdateAvailable', 'onRefresh'], 'callbacks')
44
- * ```
45
13
  */
46
14
  declare function validateCallbackFields(callbacks: Record<string, any>, fields: string[], objectName: string): void;
47
- /**
48
- * 验证数值为非负数
49
- *
50
- * @param value - 待验证的数值
51
- * @param fieldName - 字段名称,用于错误消息
52
- * @throws 当值存在但不是数字或为负数时抛出错误
53
- *
54
- * @example
55
- * ```typescript
56
- * validateNonNegativeNumber(100, 'zIndex')
57
- * validateNonNegativeNumber(-1, 'duration') // 抛出错误
58
- * ```
59
- */
60
- declare function validateNonNegativeNumber(value: number | undefined, fieldName: string): void;
61
- /**
62
- * 验证嵌套配置项的 duration 合法性
63
- *
64
- * @param config - 嵌套配置对象(包含 enabled 和 duration 字段)
65
- * @param errorMsg - 验证失败时的错误提示信息
66
- * @throws 当 duration 存在但不是非负数时抛出错误
67
- *
68
- * @example
69
- * ```typescript
70
- * validateNestedDuration({ enabled: true, duration: 300 }, 'minDisplayTime.duration 必须是非负数')
71
- * ```
72
- */
73
- declare function validateNestedDuration(config: {
74
- enabled?: boolean;
75
- duration?: number;
76
- } | undefined, errorMsg: string): void;
77
- /**
78
- * 验证字符串值是否在允许的枚举列表中
79
- *
80
- * @param value - 待验证的值
81
- * @param allowedValues - 允许的值列表
82
- * @param fieldName - 字段名称,用于错误消息
83
- * @throws 当值存在但不在允许列表中时抛出错误
84
- *
85
- * @example
86
- * ```typescript
87
- * validateEnumValue('center', ['center', 'top', 'bottom'], 'position')
88
- * validateEnumValue('modal', ['modal', 'banner', 'toast'], 'promptStyle')
89
- * ```
90
- */
91
- declare function validateEnumValue(value: string | undefined, allowedValues: string[], fieldName: string): void;
92
15
 
93
- export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber };
16
+ export { validateCallbackFields, validateGlobalName, validateNoScriptInTemplate };
@@ -1,93 +1,16 @@
1
1
  export { V as Validator } from '../../shared/vite-plugin.DRRlWY8P.js';
2
2
 
3
3
  /**
4
- * 验证全局变量名的合法性(包装 validateIdentifierName,附加字段上下文信息)
5
- *
6
- * @param name - 全局变量名
7
- * @param fieldName - 字段名称,用于错误消息上下文(如 'globalName'、'defineName')
8
- * @throws 当名称不合法时抛出带字段上下文的错误
9
- *
10
- * @example
11
- * ```typescript
12
- * validateGlobalName('__LOADING_MANAGER__', 'globalName')
13
- * validateGlobalName('__APP_VERSION__', 'defineName')
14
- * ```
4
+ * 验证全局变量名的合法性
15
5
  */
16
6
  declare function validateGlobalName(name: string | undefined, fieldName: string): void;
17
7
  /**
18
8
  * 验证模板字符串不包含 script 标签(XSS 防护)
19
- *
20
- * @param template - 模板字符串
21
- * @param fieldName - 字段名称,用于错误消息上下文
22
- * @throws 当模板包含 `<script>` 标签时抛出错误
23
- *
24
- * @example
25
- * ```typescript
26
- * validateNoScriptInTemplate('<div>safe</div>', 'customTemplate')
27
- * validateNoScriptInTemplate(options.customPromptTemplate, 'customPromptTemplate')
28
- * ```
29
9
  */
30
10
  declare function validateNoScriptInTemplate(template: string | undefined, fieldName: string): void;
31
11
  /**
32
12
  * 验证回调字段不包含 script 标签
33
- *
34
- * @param callbacks - 回调配置对象
35
- * @param fields - 需要验证的回调字段名数组
36
- * @param objectName - 回调所属对象名称,用于错误消息上下文
37
- * @throws 当回调字段非字符串类型时抛出错误
38
- * @throws 当回调字符串包含 `<script>` 标签时抛出错误
39
- *
40
- * @example
41
- * ```typescript
42
- * validateCallbackFields(callbacks, ['onShow', 'onHide'], 'callbacks')
43
- * validateCallbackFields(options, ['onUpdateAvailable', 'onRefresh'], 'callbacks')
44
- * ```
45
13
  */
46
14
  declare function validateCallbackFields(callbacks: Record<string, any>, fields: string[], objectName: string): void;
47
- /**
48
- * 验证数值为非负数
49
- *
50
- * @param value - 待验证的数值
51
- * @param fieldName - 字段名称,用于错误消息
52
- * @throws 当值存在但不是数字或为负数时抛出错误
53
- *
54
- * @example
55
- * ```typescript
56
- * validateNonNegativeNumber(100, 'zIndex')
57
- * validateNonNegativeNumber(-1, 'duration') // 抛出错误
58
- * ```
59
- */
60
- declare function validateNonNegativeNumber(value: number | undefined, fieldName: string): void;
61
- /**
62
- * 验证嵌套配置项的 duration 合法性
63
- *
64
- * @param config - 嵌套配置对象(包含 enabled 和 duration 字段)
65
- * @param errorMsg - 验证失败时的错误提示信息
66
- * @throws 当 duration 存在但不是非负数时抛出错误
67
- *
68
- * @example
69
- * ```typescript
70
- * validateNestedDuration({ enabled: true, duration: 300 }, 'minDisplayTime.duration 必须是非负数')
71
- * ```
72
- */
73
- declare function validateNestedDuration(config: {
74
- enabled?: boolean;
75
- duration?: number;
76
- } | undefined, errorMsg: string): void;
77
- /**
78
- * 验证字符串值是否在允许的枚举列表中
79
- *
80
- * @param value - 待验证的值
81
- * @param allowedValues - 允许的值列表
82
- * @param fieldName - 字段名称,用于错误消息
83
- * @throws 当值存在但不在允许列表中时抛出错误
84
- *
85
- * @example
86
- * ```typescript
87
- * validateEnumValue('center', ['center', 'top', 'bottom'], 'position')
88
- * validateEnumValue('modal', ['modal', 'banner', 'toast'], 'promptStyle')
89
- * ```
90
- */
91
- declare function validateEnumValue(value: string | undefined, allowedValues: string[], fieldName: string): void;
92
15
 
93
- export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber };
16
+ export { validateCallbackFields, validateGlobalName, validateNoScriptInTemplate };
@@ -1 +1 @@
1
- export{V as Validator}from"../../shared/vite-plugin.DcExl6jd.mjs";import{containsScriptTag as e,validateIdentifierName as n}from"../script/index.mjs";function a(u,t){if(u)try{n(u)}catch(o){throw new Error(`${t} ${o.message}`)}}function f(u,t){if(u&&e(u))throw new Error(`${t} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}function d(u,t,o){for(const i of t){const r=u[i];if(r!==void 0&&typeof r!="string")throw new Error(`${o}.${i} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`);if(r&&e(r))throw new Error(`${o}.${i} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}}function c(u,t){if(u!==void 0&&(typeof u!="number"||u<0))throw new Error(`${t} \u5FC5\u987B\u662F\u975E\u8D1F\u6570`)}function l(u,t){if(u?.duration!==void 0&&(typeof u.duration!="number"||u.duration<0))throw new Error(t)}function B(u,t,o){if(u&&!t.includes(u))throw new Error(`${o} \u5FC5\u987B\u662F ${t.join(", ")}`)}export{d as validateCallbackFields,B as validateEnumValue,a as validateGlobalName,l as validateNestedDuration,f as validateNoScriptInTemplate,c as validateNonNegativeNumber};
1
+ export{V as Validator}from"../../shared/vite-plugin.DcExl6jd.mjs";function F(u,t){if(u){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(u))throw new Error(`${t} "${u}" \u4E0D\u662F\u5408\u6CD5\u7684 JavaScript \u6807\u8BC6\u7B26\uFF0C\u5FC5\u987B\u4EE5\u5B57\u6BCD\u3001\u4E0B\u5212\u7EBF\u6216\u7F8E\u5143\u7B26\u5F00\u5934\uFF0C\u4EC5\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u7F8E\u5143\u7B26`);if(["__proto__","constructor","prototype"].includes(u))throw new Error(`${t} "${u}" \u662F JavaScript \u5185\u7F6E\u5C5E\u6027\uFF0C\u53EF\u80FD\u5BFC\u81F4\u539F\u578B\u6C61\u67D3\uFF0C\u8BF7\u4F7F\u7528\u5176\u4ED6\u540D\u79F0`)}}function i(u,t){if(u&&/<script\b/i.test(u))throw new Error(`${t} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}function E(u,t,o){for(const B of t){const r=u[B];if(r!==void 0&&typeof r!="string")throw new Error(`${o}.${B} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`);if(r&&/<script\b/i.test(r))throw new Error(`${o}.${B} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}}export{E as validateCallbackFields,F as validateGlobalName,i as validateNoScriptInTemplate};